Skip to content

Commit 9623699

Browse files
committed
Add _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW
1 parent 71c42b7 commit 9623699

File tree

7 files changed

+118
-45
lines changed

7 files changed

+118
-45
lines changed

Include/internal/pycore_uop_ids.h

Lines changed: 42 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_metadata.h

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/test/test_capi/test_opt.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,9 +1955,10 @@ def testfunc(n):
19551955
self.assertEqual(res, TIER2_THRESHOLD)
19561956
self.assertIsNotNone(ex)
19571957
uops = get_opnames(ex)
1958-
self.assertIn("_CALL_ISINSTANCE", uops)
1958+
self.assertNotIn("_CALL_ISINSTANCE", uops)
19591959
self.assertNotIn("_GUARD_THIRD_NULL", uops)
19601960
self.assertNotIn("_GUARD_CALLABLE_ISINSTANCE", uops)
1961+
self.assertIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW", uops)
19611962

19621963
def test_call_isinstance_is_true(self):
19631964
def testfunc(n):
@@ -1972,9 +1973,10 @@ def testfunc(n):
19721973
self.assertEqual(res, TIER2_THRESHOLD)
19731974
self.assertIsNotNone(ex)
19741975
uops = get_opnames(ex)
1975-
self.assertIn("_CALL_ISINSTANCE", uops)
1976+
self.assertNotIn("_CALL_ISINSTANCE", uops)
19761977
self.assertNotIn("_TO_BOOL_BOOL", uops)
19771978
self.assertNotIn("_GUARD_IS_TRUE_POP", uops)
1979+
self.assertIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW", uops)
19781980

19791981
def test_call_isinstance_is_false(self):
19801982
def testfunc(n):
@@ -1989,9 +1991,10 @@ def testfunc(n):
19891991
self.assertEqual(res, TIER2_THRESHOLD)
19901992
self.assertIsNotNone(ex)
19911993
uops = get_opnames(ex)
1992-
self.assertIn("_CALL_ISINSTANCE", uops)
1994+
self.assertNotIn("_CALL_ISINSTANCE", uops)
19931995
self.assertNotIn("_TO_BOOL_BOOL", uops)
19941996
self.assertNotIn("_GUARD_IS_FALSE_POP", uops)
1997+
self.assertIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW", uops)
19951998

19961999
def test_call_isinstance_subclass(self):
19972000
def testfunc(n):
@@ -2006,9 +2009,10 @@ def testfunc(n):
20062009
self.assertEqual(res, TIER2_THRESHOLD)
20072010
self.assertIsNotNone(ex)
20082011
uops = get_opnames(ex)
2009-
self.assertIn("_CALL_ISINSTANCE", uops)
2012+
self.assertNotIn("_CALL_ISINSTANCE", uops)
20102013
self.assertNotIn("_TO_BOOL_BOOL", uops)
20112014
self.assertNotIn("_GUARD_IS_TRUE_POP", uops)
2015+
self.assertIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW", uops)
20122016

20132017
def test_call_isinstance_unknown_object(self):
20142018
def testfunc(n):

Python/bytecodes.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5327,6 +5327,14 @@ dummy_func(
53275327
value = PyStackRef_FromPyObjectImmortal(ptr);
53285328
}
53295329

5330+
tier2 pure op(_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW, (ptr/4, callable, null, pop1, pop2 -- value)) {
5331+
PyStackRef_CLOSE(pop2);
5332+
PyStackRef_CLOSE(pop1);
5333+
PyStackRef_CLOSE(null);
5334+
PyStackRef_CLOSE(callable);
5335+
value = PyStackRef_FromPyObjectImmortal(ptr);
5336+
}
5337+
53305338
tier2 op(_CHECK_FUNCTION, (func_version/2 -- )) {
53315339
assert(PyStackRef_FunctionCheck(frame->f_funcobj));
53325340
PyFunctionObject *func = (PyFunctionObject *)PyStackRef_AsPyObjectBorrow(frame->f_funcobj);

Python/executor_cases.c.h

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/optimizer_bytecodes.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,10 @@ dummy_func(void) {
550550
value = sym_new_const(ctx, ptr);
551551
}
552552

553+
op(_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW, (ptr/4, unused, unused, unused, unused -- value)) {
554+
value = sym_new_const(ctx, ptr);
555+
}
556+
553557
op(_COPY, (bottom, unused[oparg-1] -- bottom, unused[oparg-1], top)) {
554558
assert(oparg > 0);
555559
top = bottom;
@@ -903,9 +907,11 @@ dummy_func(void) {
903907
// The below check is equivalent to PyObject_TypeCheck(inst, cls)
904908
if (inst_type == cls_o || PyType_IsSubtype(inst_type, cls_o)) {
905909
sym_set_const(res, Py_True);
910+
REPLACE_OP(this_instr, _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)Py_True);
906911
}
907912
else {
908913
sym_set_const(res, Py_False);
914+
REPLACE_OP(this_instr, _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)Py_False);
909915
}
910916
}
911917
}

Python/optimizer_cases.c.h

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)