Skip to content

Commit 1519a5e

Browse files
committed
Add _POP_CALL_LOAD_CONST_INLINE_BORROW
1 parent 514dc9f commit 1519a5e

File tree

8 files changed

+104
-50
lines changed

8 files changed

+104
-50
lines changed

Include/internal/pycore_uop_ids.h

Lines changed: 46 additions & 45 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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,7 +1958,7 @@ def testfunc(n):
19581958
self.assertNotIn("_CALL_ISINSTANCE", uops)
19591959
self.assertNotIn("_GUARD_THIRD_NULL", uops)
19601960
self.assertNotIn("_GUARD_CALLABLE_ISINSTANCE", uops)
1961-
self.assertIn("_POP_TWO_LOAD_CONST_INLINE_BORROW", uops)
1961+
self.assertIn("_POP_CALL_LOAD_CONST_INLINE_BORROW", uops)
19621962

19631963
def test_call_list_append(self):
19641964
def testfunc(n):
@@ -1991,7 +1991,7 @@ def testfunc(n):
19911991
self.assertNotIn("_CALL_ISINSTANCE", uops)
19921992
self.assertNotIn("_TO_BOOL_BOOL", uops)
19931993
self.assertNotIn("_GUARD_IS_TRUE_POP", uops)
1994-
self.assertIn("_POP_TWO_LOAD_CONST_INLINE_BORROW", uops)
1994+
self.assertIn("_POP_CALL_LOAD_CONST_INLINE_BORROW", uops)
19951995

19961996
def test_call_isinstance_is_false(self):
19971997
def testfunc(n):
@@ -2009,7 +2009,7 @@ def testfunc(n):
20092009
self.assertNotIn("_CALL_ISINSTANCE", uops)
20102010
self.assertNotIn("_TO_BOOL_BOOL", uops)
20112011
self.assertNotIn("_GUARD_IS_FALSE_POP", uops)
2012-
self.assertIn("_POP_TWO_LOAD_CONST_INLINE_BORROW", uops)
2012+
self.assertIn("_POP_CALL_LOAD_CONST_INLINE_BORROW", uops)
20132013

20142014
def test_call_isinstance_subclass(self):
20152015
def testfunc(n):
@@ -2027,7 +2027,7 @@ def testfunc(n):
20272027
self.assertNotIn("_CALL_ISINSTANCE", uops)
20282028
self.assertNotIn("_TO_BOOL_BOOL", uops)
20292029
self.assertNotIn("_GUARD_IS_TRUE_POP", uops)
2030-
self.assertIn("_POP_TWO_LOAD_CONST_INLINE_BORROW", uops)
2030+
self.assertIn("_POP_CALL_LOAD_CONST_INLINE_BORROW", uops)
20312031

20322032
def test_call_isinstance_unknown_object(self):
20332033
def testfunc(n):

Python/bytecodes.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5304,6 +5304,13 @@ dummy_func(
53045304
PyStackRef_CLOSE(pop1);
53055305
}
53065306

5307+
tier2 pure op(_POP_CALL_LOAD_CONST_INLINE_BORROW, (ptr/4, callable, null -- value)) {
5308+
(void)null; // Silence compiler warnings about unused variables
5309+
DEAD(null);
5310+
PyStackRef_CLOSE(callable);
5311+
value = PyStackRef_FromPyObjectImmortal(ptr);
5312+
}
5313+
53075314
tier2 pure op(_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW, (ptr/4, callable, null, pop -- value)) {
53085315
PyStackRef_CLOSE(pop);
53095316
(void)null; // Silence compiler warnings about unused variables

Python/executor_cases.c.h

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

Python/optimizer_analysis.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size)
557557
case _POP_TOP_LOAD_CONST_INLINE:
558558
case _POP_TOP_LOAD_CONST_INLINE_BORROW:
559559
case _POP_TWO_LOAD_CONST_INLINE_BORROW:
560+
case _POP_CALL_LOAD_CONST_INLINE_BORROW:
560561
case _POP_CALL_ONE_LOAD_CONST_INLINE_BORROW:
561562
case _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW:
562563
optimize_pop_top_again:
@@ -572,6 +573,9 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size)
572573
case _POP_CALL_ONE_LOAD_CONST_INLINE_BORROW:
573574
last->opcode = _POP_TWO;
574575
break;
576+
case _POP_CALL_LOAD_CONST_INLINE_BORROW:
577+
last->opcode = _POP_TOP;
578+
break;
575579
case _POP_TWO_LOAD_CONST_INLINE_BORROW:
576580
last->opcode = _POP_TOP;
577581
break;
@@ -605,8 +609,12 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size)
605609
opcode = buffer[pc].opcode = _POP_TOP_LOAD_CONST_INLINE_BORROW;
606610
goto optimize_pop_top_again;
607611
}
612+
else if (opcode == _POP_CALL_LOAD_CONST_INLINE_BORROW) {
613+
opcode = buffer[pc].opcode = _POP_TOP_LOAD_CONST_INLINE_BORROW;
614+
goto optimize_pop_top_again;
615+
}
608616
else if (opcode == _POP_CALL_ONE_LOAD_CONST_INLINE_BORROW) {
609-
opcode = buffer[pc].opcode = _POP_TWO_LOAD_CONST_INLINE_BORROW;
617+
opcode = buffer[pc].opcode = _POP_CALL_LOAD_CONST_INLINE_BORROW;
610618
goto optimize_pop_top_again;
611619
}
612620
else {

Python/optimizer_bytecodes.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,10 @@ dummy_func(void) {
536536
value = sym_new_const(ctx, ptr);
537537
}
538538

539+
op(_POP_CALL_LOAD_CONST_INLINE_BORROW, (ptr/4, unused, unused -- value)) {
540+
value = sym_new_const(ctx, ptr);
541+
}
542+
539543
op(_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW, (ptr/4, unused, unused, unused -- value)) {
540544
value = sym_new_const(ctx, ptr);
541545
}

Python/optimizer_cases.c.h

Lines changed: 10 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)