Skip to content

Commit f37b9c3

Browse files
committed
Add _POP_CALL_LOAD_CONST_INLINE_BORROW
1 parent 3744da4 commit f37b9c3

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
@@ -5353,6 +5353,13 @@ dummy_func(
53535353
PyStackRef_CLOSE(pop1);
53545354
}
53555355

5356+
tier2 pure op(_POP_CALL_LOAD_CONST_INLINE_BORROW, (ptr/4, callable, null -- value)) {
5357+
(void)null; // Silence compiler warnings about unused variables
5358+
DEAD(null);
5359+
PyStackRef_CLOSE(callable);
5360+
value = PyStackRef_FromPyObjectImmortal(ptr);
5361+
}
5362+
53565363
tier2 pure op(_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW, (ptr/4, callable, null, pop -- value)) {
53575364
PyStackRef_CLOSE(pop);
53585365
(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
@@ -550,6 +550,10 @@ dummy_func(void) {
550550
value = sym_new_const(ctx, ptr);
551551
}
552552

553+
op(_POP_CALL_LOAD_CONST_INLINE_BORROW, (ptr/4, unused, unused -- value)) {
554+
value = sym_new_const(ctx, ptr);
555+
}
556+
553557
op(_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW, (ptr/4, unused, unused, unused -- value)) {
554558
value = sym_new_const(ctx, ptr);
555559
}

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy