Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit8c5e555

Browse files
authored
GH-131798: Turn _LOAD_SMALL_INT into _LOAD_CONST_INLINE_BORROW in the JIT (GH-134406)
1 parent3effede commit8c5e555

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

‎Lib/test/test_capi/test_opt.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,6 +2156,18 @@ def testfunc(n):
21562156
self.assertIn("_GUARD_TYPE_VERSION",uops)
21572157
self.assertNotIn("_CHECK_ATTR_CLASS",uops)
21582158

2159+
deftest_load_small_int(self):
2160+
deftestfunc(n):
2161+
x=0
2162+
foriinrange(n):
2163+
x+=1
2164+
returnx
2165+
res,ex=self._run_with_optimizer(testfunc,TIER2_THRESHOLD)
2166+
self.assertEqual(res,TIER2_THRESHOLD)
2167+
self.assertIsNotNone(ex)
2168+
uops=get_opnames(ex)
2169+
self.assertNotIn("_LOAD_SMALL_INT",uops)
2170+
self.assertIn("_LOAD_CONST_INLINE_BORROW",uops)
21592171

21602172
defglobal_identity(x):
21612173
returnx
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
JIT: replace ``_LOAD_SMALL_INT`` with ``_LOAD_CONST_INLINE_BORROW``

‎Python/optimizer_bytecodes.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,10 @@ dummy_func(void) {
528528
}
529529

530530
op(_LOAD_SMALL_INT, (--value)) {
531-
PyObject*val=PyLong_FromLong(this_instr->oparg);
531+
PyObject*val=PyLong_FromLong(oparg);
532+
assert(val);
533+
assert(_Py_IsImmortal(val));
534+
REPLACE_OP(this_instr,_LOAD_CONST_INLINE_BORROW,0, (uintptr_t)val);
532535
value=sym_new_const(ctx,val);
533536
}
534537

‎Python/optimizer_cases.c.h

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp