Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-131798: JIT: Add _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW #134268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW
  • Loading branch information
tomasr8 committed May 19, 2025
commit 96236997a8d9f956c554ef81ab2988b3c2f9eb05
83 changes: 42 additions & 41 deletions 83 Include/internal/pycore_uop_ids.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions 4 Include/internal/pycore_uop_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions 12 Lib/test/test_capi/test_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1955,9 +1955,10 @@ def testfunc(n):
self.assertEqual(res, TIER2_THRESHOLD)
self.assertIsNotNone(ex)
uops = get_opnames(ex)
self.assertIn("_CALL_ISINSTANCE", uops)
self.assertNotIn("_CALL_ISINSTANCE", uops)
self.assertNotIn("_GUARD_THIRD_NULL", uops)
self.assertNotIn("_GUARD_CALLABLE_ISINSTANCE", uops)
self.assertIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW", uops)

def test_call_isinstance_is_true(self):
def testfunc(n):
Expand All @@ -1972,9 +1973,10 @@ def testfunc(n):
self.assertEqual(res, TIER2_THRESHOLD)
self.assertIsNotNone(ex)
uops = get_opnames(ex)
self.assertIn("_CALL_ISINSTANCE", uops)
self.assertNotIn("_CALL_ISINSTANCE", uops)
self.assertNotIn("_TO_BOOL_BOOL", uops)
self.assertNotIn("_GUARD_IS_TRUE_POP", uops)
self.assertIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW", uops)

def test_call_isinstance_is_false(self):
def testfunc(n):
Expand All @@ -1989,9 +1991,10 @@ def testfunc(n):
self.assertEqual(res, TIER2_THRESHOLD)
self.assertIsNotNone(ex)
uops = get_opnames(ex)
self.assertIn("_CALL_ISINSTANCE", uops)
self.assertNotIn("_CALL_ISINSTANCE", uops)
self.assertNotIn("_TO_BOOL_BOOL", uops)
self.assertNotIn("_GUARD_IS_FALSE_POP", uops)
self.assertIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW", uops)

def test_call_isinstance_subclass(self):
def testfunc(n):
Expand All @@ -2006,9 +2009,10 @@ def testfunc(n):
self.assertEqual(res, TIER2_THRESHOLD)
self.assertIsNotNone(ex)
uops = get_opnames(ex)
self.assertIn("_CALL_ISINSTANCE", uops)
self.assertNotIn("_CALL_ISINSTANCE", uops)
self.assertNotIn("_TO_BOOL_BOOL", uops)
self.assertNotIn("_GUARD_IS_TRUE_POP", uops)
self.assertIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW", uops)

def test_call_isinstance_unknown_object(self):
def testfunc(n):
Expand Down
8 changes: 8 additions & 0 deletions 8 Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -5327,6 +5327,14 @@ 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);
PyStackRef_CLOSE(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);
Expand Down
38 changes: 38 additions & 0 deletions 38 Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions 6 Python/optimizer_bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -903,9 +907,11 @@ dummy_func(void) {
// The below check is equivalent to PyObject_TypeCheck(inst, cls)
if (inst_type == cls_o || PyType_IsSubtype(inst_type, cls_o)) {
sym_set_const(res, Py_True);
REPLACE_OP(this_instr, _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)Py_True);
}
else {
sym_set_const(res, Py_False);
REPLACE_OP(this_instr, _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)Py_False);
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions 12 Python/optimizer_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.