mirror of
https://github.com/python/cpython.git
synced 2025-08-29 05:05:03 +00:00
Revert "GH-128914: Remove conditional stack effects from bytecodes.c
and the code generators (GH-128918)" (GH-129202)
The commit introduced a ~2.5-3% regression in the free threading build.
This reverts commit ab61d3f430
.
This commit is contained in:
parent
d7d066c3ab
commit
a10f99375e
44 changed files with 1679 additions and 1460 deletions
104
Python/optimizer_cases.c.h
generated
104
Python/optimizer_cases.c.h
generated
|
@ -928,9 +928,12 @@
|
|||
|
||||
case _LOAD_GLOBAL: {
|
||||
JitOptSymbol **res;
|
||||
JitOptSymbol *null = NULL;
|
||||
res = &stack_pointer[0];
|
||||
res[0] = sym_new_not_null(ctx);
|
||||
stack_pointer += 1;
|
||||
null = sym_new_null(ctx);
|
||||
if (oparg & 1) stack_pointer[1] = null;
|
||||
stack_pointer += 1 + (oparg & 1);
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
@ -963,15 +966,25 @@
|
|||
|
||||
case _LOAD_GLOBAL_MODULE_FROM_KEYS: {
|
||||
JitOptSymbol *res;
|
||||
JitOptSymbol *null = NULL;
|
||||
res = sym_new_not_null(ctx);
|
||||
null = sym_new_null(ctx);
|
||||
stack_pointer[-1] = res;
|
||||
if (oparg & 1) stack_pointer[0] = null;
|
||||
stack_pointer += (oparg & 1);
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
||||
case _LOAD_GLOBAL_BUILTINS_FROM_KEYS: {
|
||||
JitOptSymbol *res;
|
||||
JitOptSymbol *null = NULL;
|
||||
res = sym_new_not_null(ctx);
|
||||
null = sym_new_null(ctx);
|
||||
stack_pointer[-1] = res;
|
||||
if (oparg & 1) stack_pointer[0] = null;
|
||||
stack_pointer += (oparg & 1);
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1096,8 +1109,6 @@
|
|||
|
||||
/* _INSTRUMENTED_LOAD_SUPER_ATTR is not a viable micro-op for tier 2 */
|
||||
|
||||
/* _INSTRUMENTED_LOAD_SUPER_METHOD is not a viable micro-op for tier 2 */
|
||||
|
||||
case _LOAD_SUPER_ATTR_ATTR: {
|
||||
JitOptSymbol *attr_st;
|
||||
attr_st = sym_new_not_null(ctx);
|
||||
|
@ -1107,7 +1118,7 @@
|
|||
break;
|
||||
}
|
||||
|
||||
case _LOAD_SUPER_METHOD_METHOD: {
|
||||
case _LOAD_SUPER_ATTR_METHOD: {
|
||||
JitOptSymbol *attr;
|
||||
JitOptSymbol *self_or_null;
|
||||
attr = sym_new_not_null(ctx);
|
||||
|
@ -1119,31 +1130,21 @@
|
|||
break;
|
||||
}
|
||||
|
||||
case _LOAD_METHOD: {
|
||||
case _LOAD_ATTR: {
|
||||
JitOptSymbol *owner;
|
||||
JitOptSymbol *attr;
|
||||
JitOptSymbol *self_or_null;
|
||||
JitOptSymbol *self_or_null = NULL;
|
||||
owner = stack_pointer[-1];
|
||||
(void)owner;
|
||||
attr = sym_new_not_null(ctx);
|
||||
self_or_null = sym_new_unknown(ctx);
|
||||
stack_pointer[-1] = attr;
|
||||
stack_pointer[0] = self_or_null;
|
||||
stack_pointer += 1;
|
||||
if (oparg & 1) stack_pointer[0] = self_or_null;
|
||||
stack_pointer += (oparg & 1);
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
||||
case _LOAD_ATTR: {
|
||||
JitOptSymbol *owner;
|
||||
JitOptSymbol *attr;
|
||||
owner = stack_pointer[-1];
|
||||
(void)owner;
|
||||
attr = sym_new_not_null(ctx);
|
||||
stack_pointer[-1] = attr;
|
||||
break;
|
||||
}
|
||||
|
||||
case _GUARD_TYPE_VERSION: {
|
||||
JitOptSymbol *owner;
|
||||
owner = stack_pointer[-1];
|
||||
|
@ -1181,12 +1182,17 @@
|
|||
case _LOAD_ATTR_INSTANCE_VALUE: {
|
||||
JitOptSymbol *owner;
|
||||
JitOptSymbol *attr;
|
||||
JitOptSymbol *null = NULL;
|
||||
owner = stack_pointer[-1];
|
||||
uint16_t offset = (uint16_t)this_instr->operand0;
|
||||
attr = sym_new_not_null(ctx);
|
||||
null = sym_new_null(ctx);
|
||||
(void)offset;
|
||||
(void)owner;
|
||||
stack_pointer[-1] = attr;
|
||||
if (oparg & 1) stack_pointer[0] = null;
|
||||
stack_pointer += (oparg & 1);
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1224,9 +1230,11 @@
|
|||
case _LOAD_ATTR_MODULE_FROM_KEYS: {
|
||||
JitOptSymbol *owner;
|
||||
JitOptSymbol *attr;
|
||||
JitOptSymbol *null = NULL;
|
||||
owner = stack_pointer[-2];
|
||||
uint16_t index = (uint16_t)this_instr->operand0;
|
||||
(void)index;
|
||||
null = sym_new_null(ctx);
|
||||
attr = NULL;
|
||||
if (this_instr[-1].opcode == _NOP) {
|
||||
// Preceding _CHECK_ATTR_MODULE_PUSH_KEYS was removed: mod is const and dict is watched.
|
||||
|
@ -1235,7 +1243,8 @@
|
|||
assert(PyModule_CheckExact(mod));
|
||||
PyObject *dict = mod->md_dict;
|
||||
stack_pointer[-2] = attr;
|
||||
stack_pointer += -1;
|
||||
if (oparg & 1) stack_pointer[-1] = null;
|
||||
stack_pointer += -1 + (oparg & 1);
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
PyObject *res = convert_global_to_const(this_instr, dict);
|
||||
if (res != NULL) {
|
||||
|
@ -1245,7 +1254,7 @@
|
|||
else {
|
||||
this_instr->opcode = _LOAD_ATTR_MODULE;
|
||||
}
|
||||
stack_pointer += 1;
|
||||
stack_pointer += 1 - (oparg & 1);
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
}
|
||||
if (attr == NULL) {
|
||||
|
@ -1253,7 +1262,8 @@
|
|||
attr = sym_new_not_null(ctx);
|
||||
}
|
||||
stack_pointer[-2] = attr;
|
||||
stack_pointer += -1;
|
||||
if (oparg & 1) stack_pointer[-1] = null;
|
||||
stack_pointer += -1 + (oparg & 1);
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
@ -1274,15 +1284,18 @@
|
|||
JitOptSymbol *dict;
|
||||
JitOptSymbol *owner;
|
||||
JitOptSymbol *attr;
|
||||
JitOptSymbol *null = NULL;
|
||||
dict = stack_pointer[-1];
|
||||
owner = stack_pointer[-2];
|
||||
uint16_t hint = (uint16_t)this_instr->operand0;
|
||||
attr = sym_new_not_null(ctx);
|
||||
null = sym_new_null(ctx);
|
||||
(void)hint;
|
||||
(void)owner;
|
||||
(void)dict;
|
||||
stack_pointer[-2] = attr;
|
||||
stack_pointer += -1;
|
||||
if (oparg & 1) stack_pointer[-1] = null;
|
||||
stack_pointer += -1 + (oparg & 1);
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
@ -1290,12 +1303,17 @@
|
|||
case _LOAD_ATTR_SLOT: {
|
||||
JitOptSymbol *owner;
|
||||
JitOptSymbol *attr;
|
||||
JitOptSymbol *null = NULL;
|
||||
owner = stack_pointer[-1];
|
||||
uint16_t index = (uint16_t)this_instr->operand0;
|
||||
attr = sym_new_not_null(ctx);
|
||||
null = sym_new_null(ctx);
|
||||
(void)index;
|
||||
(void)owner;
|
||||
stack_pointer[-1] = attr;
|
||||
if (oparg & 1) stack_pointer[0] = null;
|
||||
stack_pointer += (oparg & 1);
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1306,12 +1324,17 @@
|
|||
case _LOAD_ATTR_CLASS: {
|
||||
JitOptSymbol *owner;
|
||||
JitOptSymbol *attr;
|
||||
JitOptSymbol *null = NULL;
|
||||
owner = stack_pointer[-1];
|
||||
PyObject *descr = (PyObject *)this_instr->operand0;
|
||||
attr = sym_new_not_null(ctx);
|
||||
null = sym_new_null(ctx);
|
||||
(void)descr;
|
||||
(void)owner;
|
||||
stack_pointer[-1] = attr;
|
||||
if (oparg & 1) stack_pointer[0] = null;
|
||||
stack_pointer += (oparg & 1);
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1697,10 +1720,10 @@
|
|||
break;
|
||||
}
|
||||
|
||||
case _LOAD_METHOD_WITH_VALUES: {
|
||||
case _LOAD_ATTR_METHOD_WITH_VALUES: {
|
||||
JitOptSymbol *owner;
|
||||
JitOptSymbol *attr;
|
||||
JitOptSymbol *self;
|
||||
JitOptSymbol *self = NULL;
|
||||
owner = stack_pointer[-1];
|
||||
PyObject *descr = (PyObject *)this_instr->operand0;
|
||||
(void)descr;
|
||||
|
@ -1713,10 +1736,10 @@
|
|||
break;
|
||||
}
|
||||
|
||||
case _LOAD_METHOD_NO_DICT: {
|
||||
case _LOAD_ATTR_METHOD_NO_DICT: {
|
||||
JitOptSymbol *owner;
|
||||
JitOptSymbol *attr;
|
||||
JitOptSymbol *self;
|
||||
JitOptSymbol *self = NULL;
|
||||
owner = stack_pointer[-1];
|
||||
PyObject *descr = (PyObject *)this_instr->operand0;
|
||||
(void)descr;
|
||||
|
@ -1747,10 +1770,10 @@
|
|||
break;
|
||||
}
|
||||
|
||||
case _LOAD_METHOD_LAZY_DICT: {
|
||||
case _LOAD_ATTR_METHOD_LAZY_DICT: {
|
||||
JitOptSymbol *owner;
|
||||
JitOptSymbol *attr;
|
||||
JitOptSymbol *self;
|
||||
JitOptSymbol *self = NULL;
|
||||
owner = stack_pointer[-1];
|
||||
PyObject *descr = (PyObject *)this_instr->operand0;
|
||||
(void)descr;
|
||||
|
@ -2239,11 +2262,11 @@
|
|||
|
||||
case _MAKE_CALLARGS_A_TUPLE: {
|
||||
JitOptSymbol *tuple;
|
||||
JitOptSymbol *kwargs_out;
|
||||
JitOptSymbol *kwargs_out = NULL;
|
||||
tuple = sym_new_not_null(ctx);
|
||||
kwargs_out = sym_new_not_null(ctx);
|
||||
stack_pointer[-2] = tuple;
|
||||
stack_pointer[-1] = kwargs_out;
|
||||
stack_pointer[-1 - (oparg & 1)] = tuple;
|
||||
if (oparg & 1) stack_pointer[-(oparg & 1)] = kwargs_out;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2292,8 +2315,8 @@
|
|||
case _BUILD_SLICE: {
|
||||
JitOptSymbol *slice;
|
||||
slice = sym_new_not_null(ctx);
|
||||
stack_pointer[-oparg] = slice;
|
||||
stack_pointer += 1 - oparg;
|
||||
stack_pointer[-2 - ((oparg == 3) ? 1 : 0)] = slice;
|
||||
stack_pointer += -1 - ((oparg == 3) ? 1 : 0);
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
@ -2616,26 +2639,37 @@
|
|||
|
||||
case _LOAD_GLOBAL_MODULE: {
|
||||
JitOptSymbol *res;
|
||||
JitOptSymbol *null = NULL;
|
||||
res = sym_new_not_null(ctx);
|
||||
null = sym_new_null(ctx);
|
||||
stack_pointer[0] = res;
|
||||
stack_pointer += 1;
|
||||
if (oparg & 1) stack_pointer[1] = null;
|
||||
stack_pointer += 1 + (oparg & 1);
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
||||
case _LOAD_GLOBAL_BUILTINS: {
|
||||
JitOptSymbol *res;
|
||||
JitOptSymbol *null = NULL;
|
||||
res = sym_new_not_null(ctx);
|
||||
null = sym_new_null(ctx);
|
||||
stack_pointer[0] = res;
|
||||
stack_pointer += 1;
|
||||
if (oparg & 1) stack_pointer[1] = null;
|
||||
stack_pointer += 1 + (oparg & 1);
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
||||
case _LOAD_ATTR_MODULE: {
|
||||
JitOptSymbol *attr;
|
||||
JitOptSymbol *null = NULL;
|
||||
attr = sym_new_not_null(ctx);
|
||||
null = sym_new_null(ctx);
|
||||
stack_pointer[-1] = attr;
|
||||
if (oparg & 1) stack_pointer[0] = null;
|
||||
stack_pointer += (oparg & 1);
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue