aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/bytecodes.c9
-rw-r--r--Python/executor_cases.c.h34
-rw-r--r--Python/optimizer_bytecodes.c12
-rw-r--r--Python/optimizer_cases.c.h18
4 files changed, 65 insertions, 8 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index c10327916fc..477a84b170a 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -5342,6 +5342,15 @@ dummy_func(
value = PyStackRef_FromPyObjectImmortal(ptr);
}
+ tier2 pure op(_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW, (ptr/4, callable, null, pop1, pop2 -- value)) {
+ PyStackRef_CLOSE(pop2);
+ PyStackRef_CLOSE(pop1);
+ (void)null; // Silence compiler warnings about unused variables
+ DEAD(null);
+ PyStackRef_CLOSE(callable);
+ value = PyStackRef_FromPyObjectImmortal(ptr);
+ }
+
tier2 op(_CHECK_FUNCTION, (func_version/2 -- )) {
assert(PyStackRef_FunctionCheck(frame->f_funcobj));
PyFunctionObject *func = (PyFunctionObject *)PyStackRef_AsPyObjectBorrow(frame->f_funcobj);
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h
index c5e481932e7..c3da7a63b9e 100644
--- a/Python/executor_cases.c.h
+++ b/Python/executor_cases.c.h
@@ -7103,6 +7103,40 @@
break;
}
+ case _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW: {
+ _PyStackRef pop2;
+ _PyStackRef pop1;
+ _PyStackRef null;
+ _PyStackRef callable;
+ _PyStackRef value;
+ pop2 = stack_pointer[-1];
+ pop1 = stack_pointer[-2];
+ null = stack_pointer[-3];
+ callable = stack_pointer[-4];
+ PyObject *ptr = (PyObject *)CURRENT_OPERAND0();
+ stack_pointer += -1;
+ assert(WITHIN_STACK_BOUNDS());
+ _PyFrame_SetStackPointer(frame, stack_pointer);
+ PyStackRef_CLOSE(pop2);
+ stack_pointer = _PyFrame_GetStackPointer(frame);
+ stack_pointer += -1;
+ assert(WITHIN_STACK_BOUNDS());
+ _PyFrame_SetStackPointer(frame, stack_pointer);
+ PyStackRef_CLOSE(pop1);
+ stack_pointer = _PyFrame_GetStackPointer(frame);
+ (void)null;
+ stack_pointer += -2;
+ assert(WITHIN_STACK_BOUNDS());
+ _PyFrame_SetStackPointer(frame, stack_pointer);
+ PyStackRef_CLOSE(callable);
+ stack_pointer = _PyFrame_GetStackPointer(frame);
+ value = PyStackRef_FromPyObjectImmortal(ptr);
+ stack_pointer[0] = value;
+ stack_pointer += 1;
+ assert(WITHIN_STACK_BOUNDS());
+ break;
+ }
+
case _CHECK_FUNCTION: {
uint32_t func_version = (uint32_t)CURRENT_OPERAND0();
assert(PyStackRef_FunctionCheck(frame->f_funcobj));
diff --git a/Python/optimizer_bytecodes.c b/Python/optimizer_bytecodes.c
index 708b436f6e4..9811e9f348c 100644
--- a/Python/optimizer_bytecodes.c
+++ b/Python/optimizer_bytecodes.c
@@ -550,6 +550,10 @@ dummy_func(void) {
value = sym_new_const(ctx, ptr);
}
+ op(_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW, (ptr/4, unused, unused, unused, unused -- value)) {
+ value = sym_new_const(ctx, ptr);
+ }
+
op(_COPY, (bottom, unused[oparg-1] -- bottom, unused[oparg-1], top)) {
assert(oparg > 0);
top = bottom;
@@ -901,12 +905,12 @@ dummy_func(void) {
// known types, meaning we can deduce either True or False
// The below check is equivalent to PyObject_TypeCheck(inst, cls)
+ PyObject *out = Py_False;
if (inst_type == cls_o || PyType_IsSubtype(inst_type, cls_o)) {
- sym_set_const(res, Py_True);
- }
- else {
- sym_set_const(res, Py_False);
+ out = Py_True;
}
+ sym_set_const(res, out);
+ REPLACE_OP(this_instr, _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)out);
}
}
diff --git a/Python/optimizer_cases.c.h b/Python/optimizer_cases.c.h
index 3ac99e5c1b1..6e19319fbae 100644
--- a/Python/optimizer_cases.c.h
+++ b/Python/optimizer_cases.c.h
@@ -2143,12 +2143,12 @@
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)) {
+ PyObject *out = Py_False;
if (inst_type == cls_o || PyType_IsSubtype(inst_type, cls_o)) {
- sym_set_const(res, Py_True);
- }
- else {
- sym_set_const(res, Py_False);
+ out = Py_True;
}
+ sym_set_const(res, out);
+ REPLACE_OP(this_instr, _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)out);
}
stack_pointer[-4] = res;
stack_pointer += -3;
@@ -2556,6 +2556,16 @@
break;
}
+ case _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW: {
+ JitOptSymbol *value;
+ PyObject *ptr = (PyObject *)this_instr->operand0;
+ value = sym_new_const(ctx, ptr);
+ stack_pointer[-4] = value;
+ stack_pointer += -3;
+ assert(WITHIN_STACK_BOUNDS());
+ break;
+ }
+
case _CHECK_FUNCTION: {
break;
}