aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/executor_cases.c.h
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2023-10-31 10:09:54 +0000
committerGitHub <noreply@github.com>2023-10-31 10:09:54 +0000
commitd27acd4461ee603bcf6f4a81ca6afccc9fc87331 (patch)
treeb989f6c029b1350612cc9df07d0d027df2a745d8 /Python/executor_cases.c.h
parente3353c498d79f0f3f108a9baf8807a12e77c2ebe (diff)
downloadcpython-d27acd4461ee603bcf6f4a81ca6afccc9fc87331.tar.gz
cpython-d27acd4461ee603bcf6f4a81ca6afccc9fc87331.zip
GH-111485: Increment `next_instr` consistently at the start of the instruction. (GH-111486)
Diffstat (limited to 'Python/executor_cases.c.h')
-rw-r--r--Python/executor_cases.c.h65
1 files changed, 28 insertions, 37 deletions
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h
index 9f37cd75b47..24de9eadf59 100644
--- a/Python/executor_cases.c.h
+++ b/Python/executor_cases.c.h
@@ -119,14 +119,13 @@
PyObject *res;
value = stack_pointer[-1];
#if ENABLE_SPECIALIZATION
- _PyToBoolCache *cache = (_PyToBoolCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_ToBool(value, next_instr);
DISPATCH_SAME_OPARG();
}
STAT_INC(TO_BOOL, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
int err = PyObject_IsTrue(value);
Py_DECREF(value);
@@ -380,14 +379,13 @@
sub = stack_pointer[-1];
container = stack_pointer[-2];
#if ENABLE_SPECIALIZATION
- _PyBinarySubscrCache *cache = (_PyBinarySubscrCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_BinarySubscr(container, sub, next_instr);
DISPATCH_SAME_OPARG();
}
STAT_INC(BINARY_SUBSCR, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
res = PyObject_GetItem(container, sub);
Py_DECREF(container);
@@ -574,14 +572,13 @@
container = stack_pointer[-2];
v = stack_pointer[-3];
#if ENABLE_SPECIALIZATION
- _PyStoreSubscrCache *cache = (_PyStoreSubscrCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_StoreSubscr(container, sub, next_instr);
DISPATCH_SAME_OPARG();
}
STAT_INC(STORE_SUBSCR, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
/* container[sub] = v */
int err = PyObject_SetItem(container, sub, v);
@@ -900,14 +897,13 @@
PyObject *seq;
seq = stack_pointer[-1];
#if ENABLE_SPECIALIZATION
- _PyUnpackSequenceCache *cache = (_PyUnpackSequenceCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_UnpackSequence(seq, next_instr, oparg);
DISPATCH_SAME_OPARG();
}
STAT_INC(UNPACK_SEQUENCE, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
PyObject **top = stack_pointer + oparg - 1;
int res = _PyEval_UnpackIterable(tstate, seq, oparg, -1, top);
@@ -989,15 +985,14 @@
owner = stack_pointer[-1];
v = stack_pointer[-2];
#if ENABLE_SPECIALIZATION
- _PyAttrCache *cache = (_PyAttrCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
- next_instr--;
+ next_instr = this_instr;
_Py_Specialize_StoreAttr(owner, next_instr, name);
DISPATCH_SAME_OPARG();
}
STAT_INC(STORE_ATTR, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
int err = PyObject_SetAttr(owner, name, v);
@@ -1133,15 +1128,14 @@
PyObject *res;
PyObject *null = NULL;
#if ENABLE_SPECIALIZATION
- _PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
- next_instr--;
+ next_instr = this_instr;
_Py_Specialize_LoadGlobal(GLOBALS(), BUILTINS(), next_instr, name);
DISPATCH_SAME_OPARG();
}
STAT_INC(LOAD_GLOBAL, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
if (PyDict_CheckExact(GLOBALS())
@@ -1624,15 +1618,14 @@
PyObject *self_or_null = NULL;
owner = stack_pointer[-1];
#if ENABLE_SPECIALIZATION
- _PyAttrCache *cache = (_PyAttrCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
- next_instr--;
+ next_instr = this_instr;
_Py_Specialize_LoadAttr(owner, next_instr, name);
DISPATCH_SAME_OPARG();
}
STAT_INC(LOAD_ATTR, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 1);
if (oparg & 1) {
@@ -1887,14 +1880,13 @@
right = stack_pointer[-1];
left = stack_pointer[-2];
#if ENABLE_SPECIALIZATION
- _PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_CompareOp(left, right, next_instr, oparg);
DISPATCH_SAME_OPARG();
}
STAT_INC(COMPARE_OP, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
assert((oparg >> 5) <= Py_GE);
res = PyObject_RichCompare(left, right, oparg >> 5);
@@ -3209,14 +3201,13 @@
rhs = stack_pointer[-1];
lhs = stack_pointer[-2];
#if ENABLE_SPECIALIZATION
- _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr;
- if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- next_instr--;
+ if (ADAPTIVE_COUNTER_IS_ZERO(this_instr[1].cache)) {
+ next_instr = this_instr;
_Py_Specialize_BinaryOp(lhs, rhs, next_instr, oparg, LOCALS_ARRAY);
DISPATCH_SAME_OPARG();
}
STAT_INC(BINARY_OP, deferred);
- DECREMENT_ADAPTIVE_COUNTER(cache->counter);
+ DECREMENT_ADAPTIVE_COUNTER(this_instr[1].cache);
#endif /* ENABLE_SPECIALIZATION */
assert(NB_ADD <= oparg);
assert(oparg <= NB_INPLACE_XOR);
@@ -3275,7 +3266,7 @@
case _SAVE_RETURN_OFFSET: {
#if TIER_ONE
- frame->return_offset = (uint16_t)(next_instr - frame->instr_ptr);
+ frame->return_offset = (uint16_t)(next_instr - this_instr);
#endif
#if TIER_TWO
frame->return_offset = oparg;