aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/generated_cases.c.h
diff options
context:
space:
mode:
Diffstat (limited to 'Python/generated_cases.c.h')
-rw-r--r--Python/generated_cases.c.h307
1 files changed, 109 insertions, 198 deletions
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h
index 4e9b665db1a..da6b34038cd 100644
--- a/Python/generated_cases.c.h
+++ b/Python/generated_cases.c.h
@@ -301,6 +301,15 @@
PyObject *sub = PEEK(1);
PyObject *container = PEEK(2);
PyObject *res;
+ _PyBinarySubscrCache *cache = (_PyBinarySubscrCache *)next_instr;
+ if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
+ assert(cframe.use_tracing == 0);
+ next_instr--;
+ _Py_Specialize_BinarySubscr(container, sub, next_instr);
+ DISPATCH_SAME_OPARG();
+ }
+ STAT_INC(BINARY_SUBSCR, deferred);
+ DECREMENT_ADAPTIVE_COUNTER(cache->counter);
res = PyObject_GetItem(container, sub);
Py_DECREF(container);
Py_DECREF(sub);
@@ -354,25 +363,6 @@
DISPATCH();
}
- TARGET(BINARY_SUBSCR_ADAPTIVE) {
- _PyBinarySubscrCache *cache = (_PyBinarySubscrCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache)) {
- PyObject *sub = TOP();
- PyObject *container = SECOND();
- next_instr--;
- if (_Py_Specialize_BinarySubscr(container, sub, next_instr) < 0) {
- goto error;
- }
- DISPATCH_SAME_OPARG();
- }
- else {
- STAT_INC(BINARY_SUBSCR, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache);
- GO_TO_INSTRUCTION(BINARY_SUBSCR);
- }
- DISPATCH();
- }
-
TARGET(BINARY_SUBSCR_LIST_INT) {
assert(cframe.use_tracing == 0);
PyObject *sub = TOP();
@@ -504,9 +494,17 @@
PyObject *sub = PEEK(1);
PyObject *container = PEEK(2);
PyObject *v = PEEK(3);
- int err;
+ _PyStoreSubscrCache *cache = (_PyStoreSubscrCache *)next_instr;
+ if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
+ assert(cframe.use_tracing == 0);
+ next_instr--;
+ _Py_Specialize_StoreSubscr(container, sub, next_instr);
+ DISPATCH_SAME_OPARG();
+ }
+ STAT_INC(STORE_SUBSCR, deferred);
+ DECREMENT_ADAPTIVE_COUNTER(cache->counter);
/* container[sub] = v */
- err = PyObject_SetItem(container, sub, v);
+ int err = PyObject_SetItem(container, sub, v);
Py_DECREF(v);
Py_DECREF(container);
Py_DECREF(sub);
@@ -516,25 +514,6 @@
DISPATCH();
}
- TARGET(STORE_SUBSCR_ADAPTIVE) {
- _PyStoreSubscrCache *cache = (_PyStoreSubscrCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache)) {
- PyObject *sub = TOP();
- PyObject *container = SECOND();
- next_instr--;
- if (_Py_Specialize_StoreSubscr(container, sub, next_instr) < 0) {
- goto error;
- }
- DISPATCH_SAME_OPARG();
- }
- else {
- STAT_INC(STORE_SUBSCR, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache);
- GO_TO_INSTRUCTION(STORE_SUBSCR);
- }
- DISPATCH();
- }
-
TARGET(STORE_SUBSCR_LIST_INT) {
assert(cframe.use_tracing == 0);
PyObject *sub = TOP();
@@ -1078,6 +1057,16 @@
TARGET(UNPACK_SEQUENCE) {
PREDICTED(UNPACK_SEQUENCE);
+ _PyUnpackSequenceCache *cache = (_PyUnpackSequenceCache *)next_instr;
+ if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
+ assert(cframe.use_tracing == 0);
+ PyObject *seq = TOP();
+ next_instr--;
+ _Py_Specialize_UnpackSequence(seq, next_instr, oparg);
+ DISPATCH_SAME_OPARG();
+ }
+ STAT_INC(UNPACK_SEQUENCE, deferred);
+ DECREMENT_ADAPTIVE_COUNTER(cache->counter);
PyObject *seq = POP();
PyObject **top = stack_pointer + oparg;
if (!unpack_iterable(tstate, seq, oparg, -1, top)) {
@@ -1090,23 +1079,6 @@
DISPATCH();
}
- TARGET(UNPACK_SEQUENCE_ADAPTIVE) {
- assert(cframe.use_tracing == 0);
- _PyUnpackSequenceCache *cache = (_PyUnpackSequenceCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache)) {
- PyObject *seq = TOP();
- next_instr--;
- _Py_Specialize_UnpackSequence(seq, next_instr, oparg);
- DISPATCH_SAME_OPARG();
- }
- else {
- STAT_INC(UNPACK_SEQUENCE, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache);
- GO_TO_INSTRUCTION(UNPACK_SEQUENCE);
- }
- DISPATCH();
- }
-
TARGET(UNPACK_SEQUENCE_TWO_TUPLE) {
PyObject *seq = TOP();
DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE);
@@ -1164,6 +1136,19 @@
TARGET(STORE_ATTR) {
PREDICTED(STORE_ATTR);
+ _PyAttrCache *cache = (_PyAttrCache *)next_instr;
+ if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
+ assert(cframe.use_tracing == 0);
+ PyObject *owner = TOP();
+ PyObject *name = GETITEM(names, oparg);
+ next_instr--;
+ if (_Py_Specialize_StoreAttr(owner, next_instr, name)) {
+ goto error;
+ }
+ DISPATCH_SAME_OPARG();
+ }
+ STAT_INC(STORE_ATTR, deferred);
+ DECREMENT_ADAPTIVE_COUNTER(cache->counter);
PyObject *name = GETITEM(names, oparg);
PyObject *owner = TOP();
PyObject *v = SECOND();
@@ -1281,6 +1266,16 @@
TARGET(LOAD_GLOBAL) {
PREDICTED(LOAD_GLOBAL);
+ _PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr;
+ if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
+ assert(cframe.use_tracing == 0);
+ PyObject *name = GETITEM(names, oparg>>1);
+ next_instr--;
+ _Py_Specialize_LoadGlobal(GLOBALS(), BUILTINS(), next_instr, name);
+ DISPATCH_SAME_OPARG();
+ }
+ STAT_INC(LOAD_GLOBAL, deferred);
+ DECREMENT_ADAPTIVE_COUNTER(cache->counter);
int push_null = oparg & 1;
PEEK(0) = NULL;
PyObject *name = GETITEM(names, oparg>>1);
@@ -1332,25 +1327,6 @@
DISPATCH();
}
- TARGET(LOAD_GLOBAL_ADAPTIVE) {
- assert(cframe.use_tracing == 0);
- _PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache)) {
- PyObject *name = GETITEM(names, oparg>>1);
- next_instr--;
- if (_Py_Specialize_LoadGlobal(GLOBALS(), BUILTINS(), next_instr, name) < 0) {
- goto error;
- }
- DISPATCH_SAME_OPARG();
- }
- else {
- STAT_INC(LOAD_GLOBAL, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache);
- GO_TO_INSTRUCTION(LOAD_GLOBAL);
- }
- DISPATCH();
- }
-
TARGET(LOAD_GLOBAL_MODULE) {
assert(cframe.use_tracing == 0);
DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL);
@@ -1743,6 +1719,19 @@
TARGET(LOAD_ATTR) {
PREDICTED(LOAD_ATTR);
+ _PyAttrCache *cache = (_PyAttrCache *)next_instr;
+ if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
+ assert(cframe.use_tracing == 0);
+ PyObject *owner = TOP();
+ PyObject *name = GETITEM(names, oparg>>1);
+ next_instr--;
+ if (_Py_Specialize_LoadAttr(owner, next_instr, name)) {
+ goto error;
+ }
+ DISPATCH_SAME_OPARG();
+ }
+ STAT_INC(LOAD_ATTR, deferred);
+ DECREMENT_ADAPTIVE_COUNTER(cache->counter);
PyObject *name = GETITEM(names, oparg >> 1);
PyObject *owner = TOP();
if (oparg & 1) {
@@ -1790,26 +1779,6 @@
DISPATCH();
}
- TARGET(LOAD_ATTR_ADAPTIVE) {
- assert(cframe.use_tracing == 0);
- _PyAttrCache *cache = (_PyAttrCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache)) {
- PyObject *owner = TOP();
- PyObject *name = GETITEM(names, oparg>>1);
- next_instr--;
- if (_Py_Specialize_LoadAttr(owner, next_instr, name) < 0) {
- goto error;
- }
- DISPATCH_SAME_OPARG();
- }
- else {
- STAT_INC(LOAD_ATTR, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache);
- GO_TO_INSTRUCTION(LOAD_ATTR);
- }
- DISPATCH();
- }
-
TARGET(LOAD_ATTR_INSTANCE_VALUE) {
assert(cframe.use_tracing == 0);
PyObject *owner = TOP();
@@ -1999,7 +1968,7 @@
DEOPT_IF(f->func_version != func_version, LOAD_ATTR);
PyCodeObject *code = (PyCodeObject *)f->func_code;
assert(code->co_argcount == 2);
- DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), CALL);
+ DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), LOAD_ATTR);
STAT_INC(LOAD_ATTR, hit);
PyObject *name = GETITEM(names, oparg >> 1);
@@ -2023,26 +1992,6 @@
goto start_frame;
}
- TARGET(STORE_ATTR_ADAPTIVE) {
- assert(cframe.use_tracing == 0);
- _PyAttrCache *cache = (_PyAttrCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache)) {
- PyObject *owner = TOP();
- PyObject *name = GETITEM(names, oparg);
- next_instr--;
- if (_Py_Specialize_StoreAttr(owner, next_instr, name) < 0) {
- goto error;
- }
- DISPATCH_SAME_OPARG();
- }
- else {
- STAT_INC(STORE_ATTR, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache);
- GO_TO_INSTRUCTION(STORE_ATTR);
- }
- DISPATCH();
- }
-
TARGET(STORE_ATTR_INSTANCE_VALUE) {
assert(cframe.use_tracing == 0);
PyObject *owner = TOP();
@@ -2082,7 +2031,7 @@
DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR);
assert(tp->tp_flags & Py_TPFLAGS_MANAGED_DICT);
PyDictOrValues dorv = *_PyObject_DictOrValuesPointer(owner);
- DEOPT_IF(_PyDictOrValues_IsValues(dorv), LOAD_ATTR);
+ DEOPT_IF(_PyDictOrValues_IsValues(dorv), STORE_ATTR);
PyDictObject *dict = (PyDictObject *)_PyDictOrValues_GetDict(dorv);
DEOPT_IF(dict == NULL, STORE_ATTR);
assert(PyDict_CheckExact((PyObject *)dict));
@@ -2144,8 +2093,8 @@
DISPATCH();
}
- TARGET(COMPARE_OP) {
- PREDICTED(COMPARE_OP);
+ TARGET(COMPARE_OP_GENERIC) {
+ PREDICTED(COMPARE_OP_GENERIC);
assert(oparg <= Py_GE);
PyObject *right = POP();
PyObject *left = TOP();
@@ -2160,22 +2109,20 @@
DISPATCH();
}
- TARGET(COMPARE_OP_ADAPTIVE) {
- assert(cframe.use_tracing == 0);
+ TARGET(COMPARE_OP) {
+ PREDICTED(COMPARE_OP);
_PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache)) {
+ if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
+ assert(cframe.use_tracing == 0);
PyObject *right = TOP();
PyObject *left = SECOND();
next_instr--;
_Py_Specialize_CompareOp(left, right, next_instr, oparg);
DISPATCH_SAME_OPARG();
}
- else {
- STAT_INC(COMPARE_OP, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache);
- GO_TO_INSTRUCTION(COMPARE_OP);
- }
- DISPATCH();
+ STAT_INC(COMPARE_OP, deferred);
+ DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ GO_TO_INSTRUCTION(COMPARE_OP_GENERIC);
}
TARGET(COMPARE_OP_FLOAT_JUMP) {
@@ -2658,6 +2605,15 @@
TARGET(FOR_ITER) {
PREDICTED(FOR_ITER);
+ _PyForIterCache *cache = (_PyForIterCache *)next_instr;
+ if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
+ assert(cframe.use_tracing == 0);
+ next_instr--;
+ _Py_Specialize_ForIter(TOP(), next_instr, oparg);
+ DISPATCH_SAME_OPARG();
+ }
+ STAT_INC(FOR_ITER, deferred);
+ DECREMENT_ADAPTIVE_COUNTER(cache->counter);
/* before: [iter]; after: [iter, iter()] *or* [] */
PyObject *iter = TOP();
PyObject *next = (*Py_TYPE(iter)->tp_iternext)(iter);
@@ -2684,22 +2640,6 @@
DISPATCH();
}
- TARGET(FOR_ITER_ADAPTIVE) {
- assert(cframe.use_tracing == 0);
- _PyForIterCache *cache = (_PyForIterCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache)) {
- next_instr--;
- _Py_Specialize_ForIter(TOP(), next_instr, oparg);
- DISPATCH_SAME_OPARG();
- }
- else {
- STAT_INC(FOR_ITER, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache);
- GO_TO_INSTRUCTION(FOR_ITER);
- }
- DISPATCH();
- }
-
TARGET(FOR_ITER_LIST) {
assert(cframe.use_tracing == 0);
_PyListIterObject *it = (_PyListIterObject *)TOP();
@@ -3009,6 +2949,18 @@
TARGET(CALL) {
PREDICTED(CALL);
+ _PyCallCache *cache = (_PyCallCache *)next_instr;
+ if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
+ assert(cframe.use_tracing == 0);
+ int is_meth = is_method(stack_pointer, oparg);
+ int nargs = oparg + is_meth;
+ PyObject *callable = PEEK(nargs + 1);
+ next_instr--;
+ _Py_Specialize_Call(callable, next_instr, nargs, call_shape.kwnames);
+ DISPATCH_SAME_OPARG();
+ }
+ STAT_INC(CALL, deferred);
+ DECREMENT_ADAPTIVE_COUNTER(cache->counter);
int total_args, is_meth;
is_meth = is_method(stack_pointer, oparg);
PyObject *function = PEEK(oparg + 1);
@@ -3083,28 +3035,6 @@
DISPATCH();
}
- TARGET(CALL_ADAPTIVE) {
- _PyCallCache *cache = (_PyCallCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache)) {
- next_instr--;
- int is_meth = is_method(stack_pointer, oparg);
- int nargs = oparg + is_meth;
- PyObject *callable = PEEK(nargs + 1);
- int err = _Py_Specialize_Call(callable, next_instr, nargs,
- call_shape.kwnames);
- if (err < 0) {
- goto error;
- }
- DISPATCH_SAME_OPARG();
- }
- else {
- STAT_INC(CALL, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache);
- GO_TO_INSTRUCTION(CALL);
- }
- DISPATCH();
- }
-
TARGET(CALL_PY_EXACT_ARGS) {
PREDICTED(CALL_PY_EXACT_ARGS);
assert(call_shape.kwnames == NULL);
@@ -3799,8 +3729,8 @@
DISPATCH();
}
- TARGET(BINARY_OP) {
- PREDICTED(BINARY_OP);
+ TARGET(BINARY_OP_GENERIC) {
+ PREDICTED(BINARY_OP_GENERIC);
PyObject *rhs = POP();
PyObject *lhs = TOP();
assert(0 <= oparg);
@@ -3817,22 +3747,20 @@
DISPATCH();
}
- TARGET(BINARY_OP_ADAPTIVE) {
- assert(cframe.use_tracing == 0);
+ TARGET(BINARY_OP) {
+ PREDICTED(BINARY_OP);
_PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache)) {
+ if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
+ assert(cframe.use_tracing == 0);
PyObject *lhs = SECOND();
PyObject *rhs = TOP();
next_instr--;
_Py_Specialize_BinaryOp(lhs, rhs, next_instr, oparg, &GETLOCAL(0));
DISPATCH_SAME_OPARG();
}
- else {
- STAT_INC(BINARY_OP, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache);
- GO_TO_INSTRUCTION(BINARY_OP);
- }
- DISPATCH();
+ STAT_INC(BINARY_OP, deferred);
+ DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ GO_TO_INSTRUCTION(BINARY_OP_GENERIC);
}
TARGET(SWAP) {
@@ -3845,27 +3773,10 @@
TARGET(EXTENDED_ARG) {
assert(oparg);
- oparg <<= 8;
- oparg |= _Py_OPARG(*next_instr);
- // We might be tracing. To avoid breaking tracing guarantees in
- // quickened instructions, always deoptimize the next opcode:
- opcode = _PyOpcode_Deopt[_Py_OPCODE(*next_instr)];
- PRE_DISPATCH_GOTO();
- // CPython hasn't traced the following instruction historically
- // (DO_TRACING would clobber our extended oparg anyways), so just
- // skip our usual cframe.use_tracing check before dispatch. Also,
- // make sure the next instruction isn't a RESUME, since that needs
- // to trace properly (and shouldn't have an extended arg anyways):
- assert(opcode != RESUME);
- DISPATCH_GOTO();
- }
-
- TARGET(EXTENDED_ARG_QUICK) {
assert(cframe.use_tracing == 0);
- assert(oparg);
- int oldoparg = oparg;
- NEXTOPARG();
- oparg |= oldoparg << 8;
+ opcode = _Py_OPCODE(*next_instr);
+ oparg = oparg << 8 | _Py_OPARG(*next_instr);
+ PRE_DISPATCH_GOTO();
DISPATCH_GOTO();
}