mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
GH-131798: Optimize away type(x) in the JIT when the result is known (GH-135194)
This commit is contained in:
parent
f00512db20
commit
46151648ca
4 changed files with 36 additions and 9 deletions
|
@ -937,8 +937,11 @@ dummy_func(void) {
|
|||
}
|
||||
|
||||
op(_CALL_TYPE_1, (unused, unused, arg -- res)) {
|
||||
if (sym_has_type(arg)) {
|
||||
res = sym_new_const(ctx, (PyObject *)sym_get_type(arg));
|
||||
PyObject* type = (PyObject *)sym_get_type(arg);
|
||||
if (type) {
|
||||
res = sym_new_const(ctx, type);
|
||||
REPLACE_OP(this_instr, _POP_CALL_ONE_LOAD_CONST_INLINE_BORROW, 0,
|
||||
(uintptr_t)type);
|
||||
}
|
||||
else {
|
||||
res = sym_new_not_null(ctx);
|
||||
|
|
7
Python/optimizer_cases.c.h
generated
7
Python/optimizer_cases.c.h
generated
|
@ -2056,8 +2056,11 @@
|
|||
JitOptSymbol *arg;
|
||||
JitOptSymbol *res;
|
||||
arg = stack_pointer[-1];
|
||||
if (sym_has_type(arg)) {
|
||||
res = sym_new_const(ctx, (PyObject *)sym_get_type(arg));
|
||||
PyObject* type = (PyObject *)sym_get_type(arg);
|
||||
if (type) {
|
||||
res = sym_new_const(ctx, type);
|
||||
REPLACE_OP(this_instr, _POP_CALL_ONE_LOAD_CONST_INLINE_BORROW, 0,
|
||||
(uintptr_t)type);
|
||||
}
|
||||
else {
|
||||
res = sym_new_not_null(ctx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue