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: replace _LOAD_SMALL_INT with _LOAD_CONST_INLINE_BORROW #134406

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 4 commits into from
May 22, 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
gh-131798: JIT: replace _LOAD_SMALL_INT with
`_LOAD_CONST_INLINE_BORROW`

Signed-off-by: Manjusaka <me@manjusaka.me>

add news

Signed-off-by: Manjusaka <me@manjusaka.me>

add tests

Signed-off-by: Manjusaka <me@manjusaka.me>

fix review idea

Signed-off-by: Manjusaka <me@manjusaka.me>
  • Loading branch information
Zheaoli committed May 21, 2025
commit ee6e90bfab9600b54cf7a83675356b8beeb3678b
11 changes: 11 additions & 0 deletions 11 Lib/test/test_capi/test_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2156,6 +2156,17 @@ def testfunc(n):
self.assertIn("_GUARD_TYPE_VERSION", uops)
self.assertNotIn("_CHECK_ATTR_CLASS", uops)

def test_load_small_int(self):
def testfunc(n):
x = 0
for i in range(n):
x += 1
return x
res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
self.assertEqual(res, TIER2_THRESHOLD)
self.assertIsNotNone(ex)
uops = get_opnames(ex)
self.assertIn("_LOAD_CONST_INLINE_BORROW", uops)
Zheaoli marked this conversation as resolved.
Show resolved Hide resolved

def global_identity(x):
return x
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
JIT: replace ``_LOAD_SMALL_INT`` with ``_LOAD_CONST_INLINE_BORROW``
1 change: 1 addition & 0 deletions 1 Python/optimizer_bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ dummy_func(void) {

op(_LOAD_SMALL_INT, (-- value)) {
PyObject *val = PyLong_FromLong(this_instr->oparg);
Zheaoli marked this conversation as resolved.
Show resolved Hide resolved
REPLACE_OP(this_instr, _LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)val);
Zheaoli marked this conversation as resolved.
Show resolved Hide resolved
value = sym_new_const(ctx, val);
}

Expand Down
1 change: 1 addition & 0 deletions 1 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.