summaryrefslogtreecommitdiffstats
path: root/Python/executor_cases.c.h
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2023-07-17 19:12:33 (GMT)
committerGitHub <noreply@github.com>2023-07-17 19:12:33 (GMT)
commit8e9a1a032233f06ce0f1acdf5f983d614c8745a5 (patch)
treed9a31c1c33b6b363d12f5e258a169835dbf29cd6 /Python/executor_cases.c.h
parent7e96370a946a2ca0f2f25af4ce5b3b59f020721b (diff)
downloadcpython-8e9a1a032233f06ce0f1acdf5f983d614c8745a5.zip
cpython-8e9a1a032233f06ce0f1acdf5f983d614c8745a5.tar.gz
cpython-8e9a1a032233f06ce0f1acdf5f983d614c8745a5.tar.bz2
gh-106603: Make uop struct a triple (opcode, oparg, operand) (#106794)
Diffstat (limited to 'Python/executor_cases.c.h')
-rw-r--r--Python/executor_cases.c.h85
1 files changed, 80 insertions, 5 deletions
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h
index d85e23b..f492c1f 100644
--- a/Python/executor_cases.c.h
+++ b/Python/executor_cases.c.h
@@ -485,18 +485,15 @@
PyObject *sub = stack_pointer[-1];
PyObject *container = stack_pointer[-2];
PyObject *v = stack_pointer[-3];
- uint16_t counter = (uint16_t)operand;
#if ENABLE_SPECIALIZATION
- if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
+ _PyStoreSubscrCache *cache = (_PyStoreSubscrCache *)next_instr;
+ if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
next_instr--;
_Py_Specialize_StoreSubscr(container, sub, next_instr);
DISPATCH_SAME_OPARG();
}
STAT_INC(STORE_SUBSCR, deferred);
- _PyStoreSubscrCache *cache = (_PyStoreSubscrCache *)next_instr;
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
- #else
- (void)counter; // Unused.
#endif /* ENABLE_SPECIALIZATION */
/* container[sub] = v */
int err = PyObject_SetItem(container, sub, v);
@@ -849,6 +846,30 @@
break;
}
+ case STORE_ATTR: {
+ static_assert(INLINE_CACHE_ENTRIES_STORE_ATTR == 4, "incorrect cache size");
+ PyObject *owner = stack_pointer[-1];
+ PyObject *v = stack_pointer[-2];
+ #if ENABLE_SPECIALIZATION
+ _PyAttrCache *cache = (_PyAttrCache *)next_instr;
+ if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
+ PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
+ next_instr--;
+ _Py_Specialize_StoreAttr(owner, next_instr, name);
+ DISPATCH_SAME_OPARG();
+ }
+ STAT_INC(STORE_ATTR, deferred);
+ DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ #endif /* ENABLE_SPECIALIZATION */
+ PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
+ int err = PyObject_SetAttr(owner, name, v);
+ Py_DECREF(v);
+ Py_DECREF(owner);
+ if (err) goto pop_2_error;
+ STACK_SHRINK(2);
+ break;
+ }
+
case DELETE_ATTR: {
PyObject *owner = stack_pointer[-1];
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
@@ -1010,6 +1031,42 @@
break;
}
+ case _LOAD_GLOBAL_MODULE: {
+ PyObject *null = NULL;
+ PyObject *res;
+ uint16_t index = (uint16_t)operand;
+ PyDictObject *dict = (PyDictObject *)GLOBALS();
+ PyDictUnicodeEntry *entries = DK_UNICODE_ENTRIES(dict->ma_keys);
+ res = entries[index].me_value;
+ DEOPT_IF(res == NULL, LOAD_GLOBAL);
+ Py_INCREF(res);
+ STAT_INC(LOAD_GLOBAL, hit);
+ null = NULL;
+ STACK_GROW(1);
+ STACK_GROW(((oparg & 1) ? 1 : 0));
+ stack_pointer[-1] = res;
+ if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = null; }
+ break;
+ }
+
+ case _LOAD_GLOBAL_BUILTINS: {
+ PyObject *null = NULL;
+ PyObject *res;
+ uint16_t index = (uint16_t)operand;
+ PyDictObject *bdict = (PyDictObject *)BUILTINS();
+ PyDictUnicodeEntry *entries = DK_UNICODE_ENTRIES(bdict->ma_keys);
+ res = entries[index].me_value;
+ DEOPT_IF(res == NULL, LOAD_GLOBAL);
+ Py_INCREF(res);
+ STAT_INC(LOAD_GLOBAL, hit);
+ null = NULL;
+ STACK_GROW(1);
+ STACK_GROW(((oparg & 1) ? 1 : 0));
+ stack_pointer[-1] = res;
+ if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = null; }
+ break;
+ }
+
case DELETE_FAST: {
PyObject *v = GETLOCAL(oparg);
if (v == NULL) goto unbound_local_error;
@@ -1443,6 +1500,24 @@
break;
}
+ case _LOAD_ATTR_INSTANCE_VALUE: {
+ PyObject *owner = stack_pointer[-1];
+ PyObject *res2 = NULL;
+ PyObject *res;
+ uint16_t index = (uint16_t)operand;
+ PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
+ res = _PyDictOrValues_GetValues(dorv)->values[index];
+ DEOPT_IF(res == NULL, LOAD_ATTR);
+ STAT_INC(LOAD_ATTR, hit);
+ Py_INCREF(res);
+ res2 = NULL;
+ Py_DECREF(owner);
+ STACK_GROW(((oparg & 1) ? 1 : 0));
+ stack_pointer[-1] = res;
+ if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; }
+ break;
+ }
+
case COMPARE_OP: {
static_assert(INLINE_CACHE_ENTRIES_COMPARE_OP == 1, "incorrect cache size");
PyObject *right = stack_pointer[-1];