mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-100712: make it possible to disable specialization (for debugging) (#100713)
This commit is contained in:
parent
a1e051a237
commit
e9ccfe4a63
11 changed files with 87 additions and 3 deletions
24
Python/generated_cases.c.h
generated
24
Python/generated_cases.c.h
generated
|
@ -410,6 +410,7 @@
|
|||
PyObject *sub = PEEK(1);
|
||||
PyObject *container = PEEK(2);
|
||||
PyObject *res;
|
||||
#if ENABLE_SPECIALIZATION
|
||||
_PyBinarySubscrCache *cache = (_PyBinarySubscrCache *)next_instr;
|
||||
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
|
||||
assert(cframe.use_tracing == 0);
|
||||
|
@ -419,6 +420,7 @@
|
|||
}
|
||||
STAT_INC(BINARY_SUBSCR, deferred);
|
||||
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
|
||||
#endif /* ENABLE_SPECIALIZATION */
|
||||
res = PyObject_GetItem(container, sub);
|
||||
Py_DECREF(container);
|
||||
Py_DECREF(sub);
|
||||
|
@ -598,6 +600,7 @@
|
|||
PyObject *container = PEEK(2);
|
||||
PyObject *v = PEEK(3);
|
||||
uint16_t counter = read_u16(&next_instr[0].cache);
|
||||
#if ENABLE_SPECIALIZATION
|
||||
if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
|
||||
assert(cframe.use_tracing == 0);
|
||||
next_instr--;
|
||||
|
@ -607,6 +610,9 @@
|
|||
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);
|
||||
Py_DECREF(v);
|
||||
|
@ -1092,6 +1098,7 @@
|
|||
|
||||
TARGET(UNPACK_SEQUENCE) {
|
||||
PREDICTED(UNPACK_SEQUENCE);
|
||||
#if ENABLE_SPECIALIZATION
|
||||
_PyUnpackSequenceCache *cache = (_PyUnpackSequenceCache *)next_instr;
|
||||
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
|
||||
assert(cframe.use_tracing == 0);
|
||||
|
@ -1102,6 +1109,7 @@
|
|||
}
|
||||
STAT_INC(UNPACK_SEQUENCE, deferred);
|
||||
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
|
||||
#endif /* ENABLE_SPECIALIZATION */
|
||||
PyObject *seq = POP();
|
||||
PyObject **top = stack_pointer + oparg;
|
||||
if (!unpack_iterable(tstate, seq, oparg, -1, top)) {
|
||||
|
@ -1174,6 +1182,7 @@
|
|||
PyObject *owner = PEEK(1);
|
||||
PyObject *v = PEEK(2);
|
||||
uint16_t counter = read_u16(&next_instr[0].cache);
|
||||
#if ENABLE_SPECIALIZATION
|
||||
if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
|
||||
assert(cframe.use_tracing == 0);
|
||||
PyObject *name = GETITEM(names, oparg);
|
||||
|
@ -1184,6 +1193,9 @@
|
|||
STAT_INC(STORE_ATTR, deferred);
|
||||
_PyAttrCache *cache = (_PyAttrCache *)next_instr;
|
||||
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
|
||||
#else
|
||||
(void)counter; // Unused.
|
||||
#endif /* ENABLE_SPECIALIZATION */
|
||||
PyObject *name = GETITEM(names, oparg);
|
||||
int err = PyObject_SetAttr(owner, name, v);
|
||||
Py_DECREF(v);
|
||||
|
@ -1296,6 +1308,7 @@
|
|||
|
||||
TARGET(LOAD_GLOBAL) {
|
||||
PREDICTED(LOAD_GLOBAL);
|
||||
#if ENABLE_SPECIALIZATION
|
||||
_PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr;
|
||||
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
|
||||
assert(cframe.use_tracing == 0);
|
||||
|
@ -1306,6 +1319,7 @@
|
|||
}
|
||||
STAT_INC(LOAD_GLOBAL, deferred);
|
||||
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
|
||||
#endif /* ENABLE_SPECIALIZATION */
|
||||
int push_null = oparg & 1;
|
||||
PEEK(0) = NULL;
|
||||
PyObject *name = GETITEM(names, oparg>>1);
|
||||
|
@ -1733,6 +1747,7 @@
|
|||
|
||||
TARGET(LOAD_ATTR) {
|
||||
PREDICTED(LOAD_ATTR);
|
||||
#if ENABLE_SPECIALIZATION
|
||||
_PyAttrCache *cache = (_PyAttrCache *)next_instr;
|
||||
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
|
||||
assert(cframe.use_tracing == 0);
|
||||
|
@ -1744,6 +1759,7 @@
|
|||
}
|
||||
STAT_INC(LOAD_ATTR, deferred);
|
||||
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
|
||||
#endif /* ENABLE_SPECIALIZATION */
|
||||
PyObject *name = GETITEM(names, oparg >> 1);
|
||||
PyObject *owner = TOP();
|
||||
if (oparg & 1) {
|
||||
|
@ -2104,6 +2120,7 @@
|
|||
PREDICTED(COMPARE_AND_BRANCH);
|
||||
PyObject *right = PEEK(1);
|
||||
PyObject *left = PEEK(2);
|
||||
#if ENABLE_SPECIALIZATION
|
||||
_PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr;
|
||||
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
|
||||
assert(cframe.use_tracing == 0);
|
||||
|
@ -2113,6 +2130,7 @@
|
|||
}
|
||||
STAT_INC(COMPARE_AND_BRANCH, deferred);
|
||||
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
|
||||
#endif /* ENABLE_SPECIALIZATION */
|
||||
assert((oparg >> 4) <= Py_GE);
|
||||
PyObject *cond = PyObject_RichCompare(left, right, oparg>>4);
|
||||
Py_DECREF(left);
|
||||
|
@ -2571,6 +2589,7 @@
|
|||
|
||||
TARGET(FOR_ITER) {
|
||||
PREDICTED(FOR_ITER);
|
||||
#if ENABLE_SPECIALIZATION
|
||||
_PyForIterCache *cache = (_PyForIterCache *)next_instr;
|
||||
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
|
||||
assert(cframe.use_tracing == 0);
|
||||
|
@ -2580,6 +2599,7 @@
|
|||
}
|
||||
STAT_INC(FOR_ITER, deferred);
|
||||
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
|
||||
#endif /* ENABLE_SPECIALIZATION */
|
||||
/* before: [iter]; after: [iter, iter()] *or* [] */
|
||||
PyObject *iter = TOP();
|
||||
PyObject *next = (*Py_TYPE(iter)->tp_iternext)(iter);
|
||||
|
@ -2901,6 +2921,7 @@
|
|||
|
||||
TARGET(CALL) {
|
||||
PREDICTED(CALL);
|
||||
#if ENABLE_SPECIALIZATION
|
||||
_PyCallCache *cache = (_PyCallCache *)next_instr;
|
||||
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
|
||||
assert(cframe.use_tracing == 0);
|
||||
|
@ -2913,6 +2934,7 @@
|
|||
}
|
||||
STAT_INC(CALL, deferred);
|
||||
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
|
||||
#endif /* ENABLE_SPECIALIZATION */
|
||||
int total_args, is_meth;
|
||||
is_meth = is_method(stack_pointer, oparg);
|
||||
PyObject *function = PEEK(oparg + 1);
|
||||
|
@ -3650,6 +3672,7 @@
|
|||
PyObject *rhs = PEEK(1);
|
||||
PyObject *lhs = PEEK(2);
|
||||
PyObject *res;
|
||||
#if ENABLE_SPECIALIZATION
|
||||
_PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr;
|
||||
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
|
||||
assert(cframe.use_tracing == 0);
|
||||
|
@ -3659,6 +3682,7 @@
|
|||
}
|
||||
STAT_INC(BINARY_OP, deferred);
|
||||
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
|
||||
#endif /* ENABLE_SPECIALIZATION */
|
||||
assert(0 <= oparg);
|
||||
assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops));
|
||||
assert(binary_ops[oparg]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue