mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
GH-126599: Remove the PyOptimizer API (GH-129194)
This commit is contained in:
parent
5c930a26fb
commit
828b27680f
23 changed files with 345 additions and 435 deletions
125
Python/generated_cases.c.h
generated
125
Python/generated_cases.c.h
generated
|
@ -180,6 +180,7 @@
|
|||
|
||||
TARGET(BINARY_OP_EXTEND) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 6;
|
||||
INSTRUCTION_STATS(BINARY_OP_EXTEND);
|
||||
static_assert(INLINE_CACHE_ENTRIES_BINARY_OP == 5, "incorrect cache size");
|
||||
|
@ -1087,6 +1088,7 @@
|
|||
|
||||
TARGET(CALL_ALLOC_AND_ENTER_INIT) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 4;
|
||||
INSTRUCTION_STATS(CALL_ALLOC_AND_ENTER_INIT);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
|
||||
|
@ -1185,6 +1187,7 @@
|
|||
|
||||
TARGET(CALL_BOUND_METHOD_EXACT_ARGS) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 4;
|
||||
INSTRUCTION_STATS(CALL_BOUND_METHOD_EXACT_ARGS);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
|
||||
|
@ -1288,6 +1291,7 @@
|
|||
|
||||
TARGET(CALL_BOUND_METHOD_GENERAL) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 4;
|
||||
INSTRUCTION_STATS(CALL_BOUND_METHOD_GENERAL);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
|
||||
|
@ -2113,6 +2117,7 @@
|
|||
|
||||
TARGET(CALL_KW_BOUND_METHOD) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 4;
|
||||
INSTRUCTION_STATS(CALL_KW_BOUND_METHOD);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL_KW == 3, "incorrect cache size");
|
||||
|
@ -2313,6 +2318,7 @@
|
|||
|
||||
TARGET(CALL_KW_PY) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 4;
|
||||
INSTRUCTION_STATS(CALL_KW_PY);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL_KW == 3, "incorrect cache size");
|
||||
|
@ -2890,6 +2896,7 @@
|
|||
|
||||
TARGET(CALL_PY_EXACT_ARGS) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 4;
|
||||
INSTRUCTION_STATS(CALL_PY_EXACT_ARGS);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
|
||||
|
@ -2971,6 +2978,7 @@
|
|||
|
||||
TARGET(CALL_PY_GENERAL) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 4;
|
||||
INSTRUCTION_STATS(CALL_PY_GENERAL);
|
||||
static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
|
||||
|
@ -5160,10 +5168,24 @@
|
|||
}
|
||||
|
||||
TARGET(JUMP_BACKWARD) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
frame->instr_ptr = next_instr;
|
||||
next_instr += 2;
|
||||
INSTRUCTION_STATS(JUMP_BACKWARD);
|
||||
PREDICTED_JUMP_BACKWARD:;
|
||||
_Py_CODEUNIT* const this_instr = next_instr - 2;
|
||||
(void)this_instr;
|
||||
/* Skip 1 cache entry */
|
||||
// _SPECIALIZE_JUMP_BACKWARD
|
||||
{
|
||||
#if ENABLE_SPECIALIZATION
|
||||
if (this_instr->op.code == JUMP_BACKWARD) {
|
||||
this_instr->op.code = tstate->interp->jit ? JUMP_BACKWARD_JIT : JUMP_BACKWARD_NO_JIT;
|
||||
// Need to re-dispatch so the warmup counter isn't off by one:
|
||||
next_instr = this_instr;
|
||||
DISPATCH_SAME_OPARG();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
// _CHECK_PERIODIC
|
||||
{
|
||||
_Py_CHECK_EMSCRIPTEN_SIGNALS_PERIODICALLY();
|
||||
|
@ -5175,16 +5197,52 @@
|
|||
if (err != 0) goto error;
|
||||
}
|
||||
}
|
||||
// _JUMP_BACKWARD
|
||||
// _JUMP_BACKWARD_NO_INTERRUPT
|
||||
{
|
||||
uint16_t the_counter = read_u16(&this_instr[1].cache);
|
||||
(void)the_counter;
|
||||
/* This bytecode is used in the `yield from` or `await` loop.
|
||||
* If there is an interrupt, we want it handled in the innermost
|
||||
* generator or coroutine, so we deliberately do not check it here.
|
||||
* (see bpo-30039).
|
||||
*/
|
||||
assert(oparg <= INSTR_OFFSET());
|
||||
JUMPBY(-oparg);
|
||||
}
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(JUMP_BACKWARD_JIT) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 2;
|
||||
INSTRUCTION_STATS(JUMP_BACKWARD_JIT);
|
||||
static_assert(1 == 1, "incorrect cache size");
|
||||
/* Skip 1 cache entry */
|
||||
// _CHECK_PERIODIC
|
||||
{
|
||||
_Py_CHECK_EMSCRIPTEN_SIGNALS_PERIODICALLY();
|
||||
QSBR_QUIESCENT_STATE(tstate);
|
||||
if (_Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) & _PY_EVAL_EVENTS_MASK) {
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
int err = _Py_HandlePending(tstate);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
if (err != 0) goto error;
|
||||
}
|
||||
}
|
||||
// _JUMP_BACKWARD_NO_INTERRUPT
|
||||
{
|
||||
/* This bytecode is used in the `yield from` or `await` loop.
|
||||
* If there is an interrupt, we want it handled in the innermost
|
||||
* generator or coroutine, so we deliberately do not check it here.
|
||||
* (see bpo-30039).
|
||||
*/
|
||||
assert(oparg <= INSTR_OFFSET());
|
||||
JUMPBY(-oparg);
|
||||
}
|
||||
// _JIT
|
||||
{
|
||||
#ifdef _Py_TIER2
|
||||
#if ENABLE_SPECIALIZATION
|
||||
_Py_BackoffCounter counter = this_instr[1].counter;
|
||||
if (backoff_counter_triggers(counter) && this_instr->op.code == JUMP_BACKWARD) {
|
||||
if (backoff_counter_triggers(counter) && this_instr->op.code == JUMP_BACKWARD_JIT) {
|
||||
_Py_CODEUNIT *start = this_instr;
|
||||
/* Back up over EXTENDED_ARGs so optimizer sees the whole instruction */
|
||||
while (oparg > 255) {
|
||||
|
@ -5211,8 +5269,7 @@
|
|||
else {
|
||||
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
|
||||
}
|
||||
#endif /* ENABLE_SPECIALIZATION */
|
||||
#endif /* _Py_TIER2 */
|
||||
#endif
|
||||
}
|
||||
DISPATCH();
|
||||
}
|
||||
|
@ -5226,10 +5283,41 @@
|
|||
* generator or coroutine, so we deliberately do not check it here.
|
||||
* (see bpo-30039).
|
||||
*/
|
||||
assert(oparg <= INSTR_OFFSET());
|
||||
JUMPBY(-oparg);
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(JUMP_BACKWARD_NO_JIT) {
|
||||
frame->instr_ptr = next_instr;
|
||||
next_instr += 2;
|
||||
INSTRUCTION_STATS(JUMP_BACKWARD_NO_JIT);
|
||||
static_assert(1 == 1, "incorrect cache size");
|
||||
/* Skip 1 cache entry */
|
||||
// _CHECK_PERIODIC
|
||||
{
|
||||
_Py_CHECK_EMSCRIPTEN_SIGNALS_PERIODICALLY();
|
||||
QSBR_QUIESCENT_STATE(tstate);
|
||||
if (_Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) & _PY_EVAL_EVENTS_MASK) {
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
int err = _Py_HandlePending(tstate);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
if (err != 0) goto error;
|
||||
}
|
||||
}
|
||||
// _JUMP_BACKWARD_NO_INTERRUPT
|
||||
{
|
||||
/* This bytecode is used in the `yield from` or `await` loop.
|
||||
* If there is an interrupt, we want it handled in the innermost
|
||||
* generator or coroutine, so we deliberately do not check it here.
|
||||
* (see bpo-30039).
|
||||
*/
|
||||
assert(oparg <= INSTR_OFFSET());
|
||||
JUMPBY(-oparg);
|
||||
}
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(JUMP_FORWARD) {
|
||||
frame->instr_ptr = next_instr;
|
||||
next_instr += 1;
|
||||
|
@ -5369,6 +5457,7 @@
|
|||
|
||||
TARGET(LOAD_ATTR_CLASS) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 10;
|
||||
INSTRUCTION_STATS(LOAD_ATTR_CLASS);
|
||||
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
|
||||
|
@ -5407,6 +5496,7 @@
|
|||
|
||||
TARGET(LOAD_ATTR_CLASS_WITH_METACLASS_CHECK) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 10;
|
||||
INSTRUCTION_STATS(LOAD_ATTR_CLASS_WITH_METACLASS_CHECK);
|
||||
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
|
||||
|
@ -5451,6 +5541,7 @@
|
|||
|
||||
TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 10;
|
||||
INSTRUCTION_STATS(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN);
|
||||
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
|
||||
|
@ -5487,6 +5578,7 @@
|
|||
|
||||
TARGET(LOAD_ATTR_INSTANCE_VALUE) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 10;
|
||||
INSTRUCTION_STATS(LOAD_ATTR_INSTANCE_VALUE);
|
||||
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
|
||||
|
@ -5540,6 +5632,7 @@
|
|||
|
||||
TARGET(LOAD_ATTR_METHOD_LAZY_DICT) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 10;
|
||||
INSTRUCTION_STATS(LOAD_ATTR_METHOD_LAZY_DICT);
|
||||
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
|
||||
|
@ -5583,6 +5676,7 @@
|
|||
|
||||
TARGET(LOAD_ATTR_METHOD_NO_DICT) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 10;
|
||||
INSTRUCTION_STATS(LOAD_ATTR_METHOD_NO_DICT);
|
||||
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
|
||||
|
@ -5619,6 +5713,7 @@
|
|||
|
||||
TARGET(LOAD_ATTR_METHOD_WITH_VALUES) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 10;
|
||||
INSTRUCTION_STATS(LOAD_ATTR_METHOD_WITH_VALUES);
|
||||
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
|
||||
|
@ -5669,6 +5764,7 @@
|
|||
|
||||
TARGET(LOAD_ATTR_MODULE) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 10;
|
||||
INSTRUCTION_STATS(LOAD_ATTR_MODULE);
|
||||
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
|
||||
|
@ -5724,6 +5820,7 @@
|
|||
|
||||
TARGET(LOAD_ATTR_NONDESCRIPTOR_NO_DICT) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 10;
|
||||
INSTRUCTION_STATS(LOAD_ATTR_NONDESCRIPTOR_NO_DICT);
|
||||
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
|
||||
|
@ -5755,6 +5852,7 @@
|
|||
|
||||
TARGET(LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 10;
|
||||
INSTRUCTION_STATS(LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES);
|
||||
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
|
||||
|
@ -5799,6 +5897,7 @@
|
|||
|
||||
TARGET(LOAD_ATTR_PROPERTY) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 10;
|
||||
INSTRUCTION_STATS(LOAD_ATTR_PROPERTY);
|
||||
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
|
||||
|
@ -5864,6 +5963,7 @@
|
|||
|
||||
TARGET(LOAD_ATTR_SLOT) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 10;
|
||||
INSTRUCTION_STATS(LOAD_ATTR_SLOT);
|
||||
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
|
||||
|
@ -5909,6 +6009,7 @@
|
|||
|
||||
TARGET(LOAD_ATTR_WITH_HINT) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 10;
|
||||
INSTRUCTION_STATS(LOAD_ATTR_WITH_HINT);
|
||||
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
|
||||
|
@ -6326,6 +6427,7 @@
|
|||
|
||||
TARGET(LOAD_GLOBAL_BUILTIN) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 5;
|
||||
INSTRUCTION_STATS(LOAD_GLOBAL_BUILTIN);
|
||||
static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size");
|
||||
|
@ -6380,6 +6482,7 @@
|
|||
|
||||
TARGET(LOAD_GLOBAL_MODULE) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 5;
|
||||
INSTRUCTION_STATS(LOAD_GLOBAL_MODULE);
|
||||
static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size");
|
||||
|
@ -7557,6 +7660,7 @@
|
|||
|
||||
TARGET(STORE_ATTR_INSTANCE_VALUE) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 5;
|
||||
INSTRUCTION_STATS(STORE_ATTR_INSTANCE_VALUE);
|
||||
static_assert(INLINE_CACHE_ENTRIES_STORE_ATTR == 4, "incorrect cache size");
|
||||
|
@ -7615,6 +7719,7 @@
|
|||
|
||||
TARGET(STORE_ATTR_SLOT) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 5;
|
||||
INSTRUCTION_STATS(STORE_ATTR_SLOT);
|
||||
static_assert(INLINE_CACHE_ENTRIES_STORE_ATTR == 4, "incorrect cache size");
|
||||
|
@ -7652,6 +7757,7 @@
|
|||
|
||||
TARGET(STORE_ATTR_WITH_HINT) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 5;
|
||||
INSTRUCTION_STATS(STORE_ATTR_WITH_HINT);
|
||||
static_assert(INLINE_CACHE_ENTRIES_STORE_ATTR == 4, "incorrect cache size");
|
||||
|
@ -8046,6 +8152,7 @@
|
|||
|
||||
TARGET(TO_BOOL_ALWAYS_TRUE) {
|
||||
_Py_CODEUNIT* const this_instr = frame->instr_ptr = next_instr;
|
||||
(void)this_instr;
|
||||
next_instr += 4;
|
||||
INSTRUCTION_STATS(TO_BOOL_ALWAYS_TRUE);
|
||||
static_assert(INLINE_CACHE_ENTRIES_TO_BOOL == 3, "incorrect cache size");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue