mirror of
https://github.com/python/cpython.git
synced 2026-04-20 02:40:59 +00:00
gh-148604: change ADD_OP(_POP_TOP, ...) to optimize_pop_top in optimizer_bytecodes.c (GH-148619)
This commit is contained in:
parent
55c9d60a3a
commit
e998eb9a83
3 changed files with 31 additions and 16 deletions
|
|
@ -1480,13 +1480,13 @@ dummy_func(void) {
|
|||
next = sym_new_type(ctx, &PyLong_Type);
|
||||
}
|
||||
|
||||
op(_CALL_TYPE_1, (unused, unused, arg -- res, a)) {
|
||||
op(_CALL_TYPE_1, (callable, null, arg -- res, a)) {
|
||||
PyObject* type = (PyObject *)sym_get_type(arg);
|
||||
if (type) {
|
||||
res = sym_new_const(ctx, type);
|
||||
ADD_OP(_SWAP, 3, 0);
|
||||
ADD_OP(_POP_TOP, 0, 0);
|
||||
ADD_OP(_POP_TOP, 0, 0);
|
||||
optimize_pop_top(ctx, this_instr, callable);
|
||||
optimize_pop_top(ctx, this_instr, null);
|
||||
ADD_OP(_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)type);
|
||||
ADD_OP(_SWAP, 2, 0);
|
||||
}
|
||||
|
|
@ -1509,7 +1509,7 @@ dummy_func(void) {
|
|||
a = arg;
|
||||
}
|
||||
|
||||
op(_CALL_ISINSTANCE, (unused, unused, instance, cls -- res)) {
|
||||
op(_CALL_ISINSTANCE, (callable, null, instance, cls -- res)) {
|
||||
// the result is always a bool, but sometimes we can
|
||||
// narrow it down to True or False
|
||||
res = sym_new_type(ctx, &PyBool_Type);
|
||||
|
|
@ -1525,10 +1525,10 @@ dummy_func(void) {
|
|||
out = Py_True;
|
||||
}
|
||||
sym_set_const(res, out);
|
||||
ADD_OP(_POP_TOP, 0, 0);
|
||||
ADD_OP(_POP_TOP, 0, 0);
|
||||
ADD_OP(_POP_TOP_NOP, 0, 0);
|
||||
ADD_OP(_POP_TOP, 0, 0);
|
||||
optimize_pop_top(ctx, this_instr, cls);
|
||||
optimize_pop_top(ctx, this_instr, instance);
|
||||
optimize_pop_top(ctx, this_instr, null);
|
||||
optimize_pop_top(ctx, this_instr, callable);
|
||||
ADD_OP(_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)out);
|
||||
}
|
||||
}
|
||||
|
|
@ -1902,7 +1902,7 @@ dummy_func(void) {
|
|||
ADD_OP(immortal ? _LOAD_CONST_INLINE_BORROW : _LOAD_CONST_INLINE,
|
||||
0, (uintptr_t)descr);
|
||||
ADD_OP(_SWAP, 3, 0);
|
||||
ADD_OP(_POP_TOP, 0, 0);
|
||||
optimize_pop_top(ctx, this_instr, method_and_self[0]);
|
||||
if ((type->tp_flags & Py_TPFLAGS_IMMUTABLETYPE) == 0) {
|
||||
PyType_Watch(TYPE_WATCHER_ID, (PyObject *)type);
|
||||
_Py_BloomFilter_Add(dependencies, type);
|
||||
|
|
|
|||
22
Python/optimizer_cases.c.h
generated
22
Python/optimizer_cases.c.h
generated
|
|
@ -3614,7 +3614,7 @@
|
|||
ADD_OP(immortal ? _LOAD_CONST_INLINE_BORROW : _LOAD_CONST_INLINE,
|
||||
0, (uintptr_t)descr);
|
||||
ADD_OP(_SWAP, 3, 0);
|
||||
ADD_OP(_POP_TOP, 0, 0);
|
||||
optimize_pop_top(ctx, this_instr, method_and_self[0]);
|
||||
if ((type->tp_flags & Py_TPFLAGS_IMMUTABLETYPE) == 0) {
|
||||
PyType_Watch(TYPE_WATCHER_ID, (PyObject *)type);
|
||||
_Py_BloomFilter_Add(dependencies, type);
|
||||
|
|
@ -4035,15 +4035,19 @@
|
|||
|
||||
case _CALL_TYPE_1: {
|
||||
JitOptRef arg;
|
||||
JitOptRef null;
|
||||
JitOptRef callable;
|
||||
JitOptRef res;
|
||||
JitOptRef a;
|
||||
arg = stack_pointer[-1];
|
||||
null = stack_pointer[-2];
|
||||
callable = stack_pointer[-3];
|
||||
PyObject* type = (PyObject *)sym_get_type(arg);
|
||||
if (type) {
|
||||
res = sym_new_const(ctx, type);
|
||||
ADD_OP(_SWAP, 3, 0);
|
||||
ADD_OP(_POP_TOP, 0, 0);
|
||||
ADD_OP(_POP_TOP, 0, 0);
|
||||
optimize_pop_top(ctx, this_instr, callable);
|
||||
optimize_pop_top(ctx, this_instr, null);
|
||||
ADD_OP(_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)type);
|
||||
ADD_OP(_SWAP, 2, 0);
|
||||
}
|
||||
|
|
@ -4404,9 +4408,13 @@
|
|||
case _CALL_ISINSTANCE: {
|
||||
JitOptRef cls;
|
||||
JitOptRef instance;
|
||||
JitOptRef null;
|
||||
JitOptRef callable;
|
||||
JitOptRef res;
|
||||
cls = stack_pointer[-1];
|
||||
instance = stack_pointer[-2];
|
||||
null = stack_pointer[-3];
|
||||
callable = stack_pointer[-4];
|
||||
res = sym_new_type(ctx, &PyBool_Type);
|
||||
PyTypeObject *inst_type = sym_get_type(instance);
|
||||
PyTypeObject *cls_o = (PyTypeObject *)sym_get_const(ctx, cls);
|
||||
|
|
@ -4416,10 +4424,10 @@
|
|||
out = Py_True;
|
||||
}
|
||||
sym_set_const(res, out);
|
||||
ADD_OP(_POP_TOP, 0, 0);
|
||||
ADD_OP(_POP_TOP, 0, 0);
|
||||
ADD_OP(_POP_TOP_NOP, 0, 0);
|
||||
ADD_OP(_POP_TOP, 0, 0);
|
||||
optimize_pop_top(ctx, this_instr, cls);
|
||||
optimize_pop_top(ctx, this_instr, instance);
|
||||
optimize_pop_top(ctx, this_instr, null);
|
||||
optimize_pop_top(ctx, this_instr, callable);
|
||||
ADD_OP(_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)out);
|
||||
}
|
||||
CHECK_STACK_BOUNDS(-3);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue