Skip to content

Commit afd5bb0

Browse files
committed
more optmization
1 parent 6b2c10d commit afd5bb0

File tree

8 files changed

+85
-11
lines changed

8 files changed

+85
-11
lines changed

Include/internal/pycore_uop_ids.h

Lines changed: 10 additions & 9 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,6 +1988,7 @@ def testfunc(n):
19881988
self.assertNotIn("_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW", uops)
19891989
self.assertNotIn("_POP_CALL_LOAD_CONST_INLINE_BORROW", uops)
19901990
self.assertNotIn("_POP_TOP_LOAD_CONST_INLINE_BORROW", uops)
1991+
self.assertIn("_SWAP_CALL_LOAD_CONST_INLINE_BORROW", uops)
19911992

19921993
def test_call_len_known_length(self):
19931994
def testfunc(n):

Python/bytecodes.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5244,6 +5244,16 @@ dummy_func(
52445244
#endif
52455245
}
52465246

5247+
tier2 op(_SWAP_CALL_LOAD_CONST_INLINE_BORROW, (ptr/4, callable, null, arg -- res, a, c)) {
5248+
(void)null; // Silence compiler warnings about unused variables
5249+
DEAD(null);
5250+
PyStackRef_CLOSE(arg);
5251+
PyStackRef_CLOSE(callable);
5252+
res = PyStackRef_FromPyObjectBorrow(ptr);
5253+
a = arg;
5254+
c = callable;
5255+
}
5256+
52475257
tier2 op(_EXIT_TRACE, (exit_p/4 --)) {
52485258
_PyExitData *exit = (_PyExitData *)exit_p;
52495259
PyCodeObject *code = _PyFrame_GetCode(frame);

Python/executor_cases.c.h

Lines changed: 33 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ const uint16_t op_without_push[MAX_UOP_ID + 1] = {
574574
[_POP_TOP_LOAD_CONST_INLINE_BORROW] = _POP_TOP,
575575
[_POP_TWO_LOAD_CONST_INLINE_BORROW] = _POP_TWO,
576576
[_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW] = _POP_CALL_TWO,
577+
[_SWAP_CALL_LOAD_CONST_INLINE_BORROW] = _SWAP_CALL_LOAD_CONST_INLINE_BORROW,
577578
};
578579

579580
const bool op_skip[MAX_UOP_ID + 1] = {

Python/optimizer_bytecodes.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,12 @@ dummy_func(void) {
516516
value = PyJitRef_Borrow(sym_new_const(ctx, ptr));
517517
}
518518

519+
op(_SWAP_CALL_LOAD_CONST_INLINE_BORROW, (ptr/4, callable, null, arg -- res, a, c)) {
520+
res = PyJitRef_Borrow(sym_new_const(ctx, ptr));
521+
a = arg;
522+
c = callable;
523+
}
524+
519525
op(_POP_TOP, (value -- )) {
520526
PyTypeObject *typ = sym_get_type(value);
521527
if (PyJitRef_IsBorrowed(value) ||
@@ -1187,7 +1193,7 @@ dummy_func(void) {
11871193
goto error;
11881194
}
11891195
if (_Py_IsImmortal(temp)) {
1190-
REPLACE_OP(this_instr, _POP_CALL_ONE_LOAD_CONST_INLINE_BORROW,
1196+
REPLACE_OP(this_instr, _SWAP_CALL_LOAD_CONST_INLINE_BORROW,
11911197
0, (uintptr_t)temp);
11921198
}
11931199
res = sym_new_const(ctx, temp);

Python/optimizer_cases.c.h

Lines changed: 19 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)