mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
GH-131798: Narrow the return type of isinstance for some known arguments in the JIT (GH-133172)
This commit is contained in:
parent
9859791f9e
commit
8d490b3687
4 changed files with 152 additions and 1 deletions
16
Python/optimizer_cases.c.h
generated
16
Python/optimizer_cases.c.h
generated
|
@ -2124,8 +2124,22 @@
|
|||
}
|
||||
|
||||
case _CALL_ISINSTANCE: {
|
||||
JitOptSymbol *cls;
|
||||
JitOptSymbol *instance;
|
||||
JitOptSymbol *res;
|
||||
res = sym_new_not_null(ctx);
|
||||
cls = stack_pointer[-1];
|
||||
instance = stack_pointer[-2];
|
||||
res = sym_new_type(ctx, &PyBool_Type);
|
||||
PyTypeObject *inst_type = sym_get_type(instance);
|
||||
PyTypeObject *cls_o = (PyTypeObject *)sym_get_const(ctx, cls);
|
||||
if (inst_type && cls_o && sym_matches_type(cls, &PyType_Type)) {
|
||||
if (inst_type == cls_o || PyType_IsSubtype(inst_type, cls_o)) {
|
||||
sym_set_const(res, Py_True);
|
||||
}
|
||||
else {
|
||||
sym_set_const(res, Py_False);
|
||||
}
|
||||
}
|
||||
stack_pointer[-4] = res;
|
||||
stack_pointer += -3;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue