mirror of
https://github.com/python/cpython.git
synced 2026-01-04 06:22:20 +00:00
gh-143092: Make CALL_LIST_APPEND and BINARY_OP_INPLACE_ADD_UNICODE normal instructions (GH-143124)
These super instructions need many special cases in the interpreter, specializer, and JIT. It's best we convert them to normal instructions.
This commit is contained in:
parent
594a4631c3
commit
cf6758ff9e
14 changed files with 167 additions and 205 deletions
48
Python/generated_cases.c.h
generated
48
Python/generated_cases.c.h
generated
|
|
@ -382,6 +382,7 @@
|
|||
_PyStackRef nos;
|
||||
_PyStackRef left;
|
||||
_PyStackRef right;
|
||||
_PyStackRef res;
|
||||
// _GUARD_TOS_UNICODE
|
||||
{
|
||||
value = stack_pointer[-1];
|
||||
|
|
@ -426,27 +427,22 @@
|
|||
}
|
||||
STAT_INC(BINARY_OP, hit);
|
||||
assert(Py_REFCNT(left_o) >= 2 || !PyStackRef_IsHeapSafe(left));
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, _PyUnicode_ExactDealloc);
|
||||
PyObject *temp = PyStackRef_AsPyObjectSteal(*target_local);
|
||||
PyObject *right_o = PyStackRef_AsPyObjectSteal(right);
|
||||
stack_pointer += -2;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyUnicode_Append(&temp, right_o);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
*target_local = PyStackRef_FromPyObjectSteal(temp);
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
Py_DECREF(right_o);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
if (PyStackRef_IsNull(*target_local)) {
|
||||
JUMP_TO_LABEL(error);
|
||||
PyStackRef_CLOSE_SPECIALIZED(right, _PyUnicode_ExactDealloc);
|
||||
PyStackRef_CLOSE_SPECIALIZED(left, _PyUnicode_ExactDealloc);
|
||||
if (temp == NULL) {
|
||||
JUMP_TO_LABEL(pop_2_error);
|
||||
}
|
||||
#if TIER_ONE
|
||||
|
||||
assert(next_instr->op.code == STORE_FAST);
|
||||
SKIP_OVER(1);
|
||||
#endif
|
||||
res = PyStackRef_FromPyObjectSteal(temp);
|
||||
*target_local = PyStackRef_NULL;
|
||||
}
|
||||
stack_pointer[-2] = res;
|
||||
stack_pointer += -1;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
|
|
@ -3250,6 +3246,7 @@
|
|||
_PyStackRef nos;
|
||||
_PyStackRef self;
|
||||
_PyStackRef arg;
|
||||
_PyStackRef none;
|
||||
_PyStackRef c;
|
||||
_PyStackRef s;
|
||||
_PyStackRef value;
|
||||
|
|
@ -3304,17 +3301,14 @@
|
|||
}
|
||||
c = callable;
|
||||
s = self;
|
||||
#if TIER_ONE
|
||||
|
||||
assert(next_instr->op.code == POP_TOP);
|
||||
SKIP_OVER(1);
|
||||
#endif
|
||||
none = PyStackRef_None;
|
||||
}
|
||||
// _POP_TOP
|
||||
{
|
||||
value = s;
|
||||
stack_pointer[-3] = c;
|
||||
stack_pointer += -2;
|
||||
stack_pointer[-3] = none;
|
||||
stack_pointer[-2] = c;
|
||||
stack_pointer += -1;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyStackRef_XCLOSE(value);
|
||||
|
|
@ -11425,15 +11419,7 @@
|
|||
DISPATCH();
|
||||
}
|
||||
_PyThreadStateImpl *_tstate = (_PyThreadStateImpl *)tstate;
|
||||
if ((_tstate->jit_tracer_state.prev_state.instr->op.code == CALL_LIST_APPEND &&
|
||||
opcode == POP_TOP) ||
|
||||
(_tstate->jit_tracer_state.prev_state.instr->op.code == BINARY_OP_INPLACE_ADD_UNICODE &&
|
||||
opcode == STORE_FAST)) {
|
||||
_tstate->jit_tracer_state.prev_state.instr_is_super = true;
|
||||
}
|
||||
else {
|
||||
_tstate->jit_tracer_state.prev_state.instr = next_instr;
|
||||
}
|
||||
_tstate->jit_tracer_state.prev_state.instr = next_instr;
|
||||
PyObject *prev_code = PyStackRef_AsPyObjectBorrow(frame->f_executable);
|
||||
if (_tstate->jit_tracer_state.prev_state.instr_code != (PyCodeObject *)prev_code) {
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue