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

GH-130415: Optimize JIT path for _TO_BOOL_INT branching#130477

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Klaus117 wants to merge5 commits intopython:mainfromKlaus117:hack-night

Conversation

Klaus117
Copy link
Contributor

@Klaus117Klaus117 commentedFeb 22, 2025
edited by bedevere-appbot
Loading

@ghost
Copy link

ghost commentedFeb 22, 2025
edited by ghost
Loading

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link

Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply theskip news label instead.

@brandtbucherbrandtbucher added performancePerformance or resource usage interpreter-core(Objects, Python, Grammar, and Parser dirs) topic-JIT labelsFeb 22, 2025
trace = []
for i in range(n):
# f is always (int) 0, but we can only prove that it's a integer:
f = i - i # at this point python knows f is an int, but doesnt know that it is 0 (we know it is 0 though)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can you renamef in this function tozero?

Comment on lines 1471 to 1500
# def test_narrow_type_to_constant_bool_true(self):
# def f(n):
# trace = []
# for i in range(n):
# # f is always True, but we can only prove that it's a bool:
# f = i != TIER2_THRESHOLD
# trace.append("A")
# if f: # Kept.
# trace.append("B")
# if not f: # Removed!
# trace.append("X")
# trace.append("C")
# if f: # Removed!
# trace.append("D")
# trace.append("E")
# trace.append("F")
# if not f: # Removed!
# trace.append("X")
# trace.append("G")
# return trace

# trace, ex = self._run_with_optimizer(f, TIER2_THRESHOLD)
# self.assertEqual(trace, list("ABCDEFG") * TIER2_THRESHOLD)
# self.assertIsNotNone(ex)
# uops = get_opnames(ex)
# # Only one guard remains:
# self.assertEqual(uops.count("_GUARD_IS_FALSE_POP"), 0)
# self.assertEqual(uops.count("_GUARD_IS_TRUE_POP"), 1)
# # But all of the appends we care about are still there:
# self.assertEqual(uops.count("_CALL_LIST_APPEND"), len("ABCDEFG"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can you remove this commented test?

Comment on lines 422 to 425
// else if (next_opcode == _GUARD_IS_TRUE_POP) {
// sym_set_const(value, Py_True);
// res = sym_new_type(ctx, &PyBool_Type);
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
// else if (next_opcode == _GUARD_IS_TRUE_POP) {
// sym_set_const(value, Py_True);
// res = sym_new_type(ctx, &PyBool_Type);
// }

// removed and the narrowed value to be invalid:
if (next_opcode == _GUARD_IS_FALSE_POP) {
sym_set_const(value, Py_GetConstant(Py_CONSTANT_ZERO));
res = sym_new_type(ctx, &PyLong_Type);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is always a boolean, since it's the output of the_TO_BOOL op.

Suggested change
res=sym_new_type(ctx,&PyLong_Type);
res=sym_new_type(ctx,&PyBool_Type);

@bedevere-app
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phraseI have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@brandtbucherbrandtbucher changed the titleGH-130415 optimize JIT path for _TO_BOOL_INT int=0 branching.GH-130415: Optimize JIT path for _TO_BOOL_INT branchingFeb 22, 2025
@markshannon
Copy link
Member

Thanks for the contribution. Unfortunately this has a critical flaw.
See#130476 (comment) for the same problem with that PR.

@brandtbucher
Copy link
Member

Closing in favor of#130477.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@brandtbucherbrandtbucherbrandtbucher approved these changes

@Fidget-SpinnerFidget-SpinnerAwaiting requested review from Fidget-SpinnerFidget-Spinner is a code owner

Assignees

@brandtbucherbrandtbucher

Labels
awaiting mergeinterpreter-core(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagetopic-JIT
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@Klaus117@markshannon@brandtbucher

[8]ページ先頭

©2009-2025 Movatter.jp