Skip to content

Commit 8d0b47c

Browse files
committed
Complete the store_subscr family: STORE_SUBSCR{,DICT,LIST_INT}
STORE_SUBSCR was alread half converted, but wasn't using cache effects yet.
1 parent d24cc5a commit 8d0b47c

File tree

2 files changed

+27
-40
lines changed

2 files changed

+27
-40
lines changed

Python/bytecodes.c

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -489,31 +489,32 @@ dummy_func(
489489
PREDICT(JUMP_BACKWARD);
490490
}
491491

492-
inst(STORE_SUBSCR, (v, container, sub -- )) {
493-
_PyStoreSubscrCache *cache = (_PyStoreSubscrCache *)next_instr;
494-
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
492+
family(store_subscr) = {
493+
STORE_SUBSCR,
494+
STORE_SUBSCR_DICT,
495+
STORE_SUBSCR_LIST_INT,
496+
};
497+
498+
inst(STORE_SUBSCR, (counter/1, v, container, sub -- )) {
499+
if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
495500
assert(cframe.use_tracing == 0);
496501
next_instr--;
497502
_Py_Specialize_StoreSubscr(container, sub, next_instr);
498503
DISPATCH_SAME_OPARG();
499504
}
500505
STAT_INC(STORE_SUBSCR, deferred);
506+
_PyStoreSubscrCache *cache = (_PyStoreSubscrCache *)next_instr;
501507
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
502508
/* container[sub] = v */
503509
int err = PyObject_SetItem(container, sub, v);
504510
Py_DECREF(v);
505511
Py_DECREF(container);
506512
Py_DECREF(sub);
507513
ERROR_IF(err != 0, error);
508-
JUMPBY(INLINE_CACHE_ENTRIES_STORE_SUBSCR);
509514
}
510515

511-
// stack effect: (__0, __1, __2 -- )
512-
inst(STORE_SUBSCR_LIST_INT) {
516+
inst(STORE_SUBSCR_LIST_INT, (unused/1, value, list, sub -- )) {
513517
assert(cframe.use_tracing == 0);
514-
PyObject *sub = TOP();
515-
PyObject *list = SECOND();
516-
PyObject *value = THIRD();
517518
DEOPT_IF(!PyLong_CheckExact(sub), STORE_SUBSCR);
518519
DEOPT_IF(!PyList_CheckExact(list), STORE_SUBSCR);
519520

@@ -526,29 +527,19 @@ dummy_func(
526527

527528
PyObject *old_value = PyList_GET_ITEM(list, index);
528529
PyList_SET_ITEM(list, index, value);
529-
STACK_SHRINK(3);
530530
assert(old_value != NULL);
531531
Py_DECREF(old_value);
532532
_Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free);
533533
Py_DECREF(list);
534-
JUMPBY(INLINE_CACHE_ENTRIES_STORE_SUBSCR);
535534
}
536535

537-
// stack effect: (__0, __1, __2 -- )
538-
inst(STORE_SUBSCR_DICT) {
536+
inst(STORE_SUBSCR_DICT, (unused/1, value, dict, sub -- )) {
539537
assert(cframe.use_tracing == 0);
540-
PyObject *sub = TOP();
541-
PyObject *dict = SECOND();
542-
PyObject *value = THIRD();
543538
DEOPT_IF(!PyDict_CheckExact(dict), STORE_SUBSCR);
544-
STACK_SHRINK(3);
545539
STAT_INC(STORE_SUBSCR, hit);
546540
int err = _PyDict_SetItem_Take2((PyDictObject *)dict, sub, value);
547541
Py_DECREF(dict);
548-
if (err != 0) {
549-
goto error;
550-
}
551-
JUMPBY(INLINE_CACHE_ENTRIES_STORE_SUBSCR);
542+
ERROR_IF(err != 0, error);
552543
}
553544

554545
// stack effect: (__0, __1 -- )
@@ -3655,9 +3646,6 @@ family(load_global) = {
36553646
LOAD_GLOBAL, LOAD_GLOBAL_BUILTIN,
36563647
LOAD_GLOBAL_MODULE };
36573648
family(store_fast) = { STORE_FAST, STORE_FAST__LOAD_FAST, STORE_FAST__STORE_FAST };
3658-
family(store_subscr) = {
3659-
STORE_SUBSCR, STORE_SUBSCR_DICT,
3660-
STORE_SUBSCR_LIST_INT };
36613649
family(unpack_sequence) = {
36623650
UNPACK_SEQUENCE, UNPACK_SEQUENCE_LIST,
36633651
UNPACK_SEQUENCE_TUPLE, UNPACK_SEQUENCE_TWO_TUPLE };

Python/generated_cases.c.h

Lines changed: 15 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)