-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
gh-126902: Strength reduce _CHECK_FUNCTION #126856
base: main
Are you sure you want to change the base?
Conversation
@markshannon would you prefer this as its own PR, or would you prefer I merge this into the function inlining PR that I will be doing later? |
Sorry I realized this is logically incorrect. |
5fbc47a
to
462cf77
Compare
462cf77
to
115bd0e
Compare
I think I've said this before, but please link to an appropriate issue. Why are you doing this? The issue doesn't explain it at all. |
@markshannon the issue is right, just too broad. I've created a smaller issue to further explain why we need this for partial evaluation at #126902 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to use the symbol for the function, rather than a reference in the optimizer.
@@ -1515,9 +1515,33 @@ def test_jit_error_pops(self): | |||
with self.assertRaises(TypeError): | |||
{item for item in items} | |||
|
|||
def test_global_guard_strength_reduced_if_possible(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nicer (not necessarily in this PR) if we created tracelets directly, rather than this complex approach.
When you're done making the requested changes, leave the comment: And if you don't make the requested changes, you will be put in the comfy chair! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to replace NULL
with sym_new_unknown
when f_funcobj
is not known.
Otherwise, LGTM.
@@ -4941,6 +4941,12 @@ dummy_func( | |||
DEOPT_IF(func->func_version != func_version); | |||
} | |||
|
|||
tier2 op(_CHECK_FUNCTION_UNMODIFIED, (func_version/2, callable_p/4 --)) { | |||
assert(PyFunction_Check(callable_p)); | |||
PyFunctionObject *func = (PyFunctionObject *)callable_p; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What guarantee is there that func == frame->f_funcobj
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's constant propagated (and frames shouldn't be able to swap out f_funcobj on the fly like that). To be sure I added a runtime assert.
Small PR to strength reduce _CHECK_FUNCTION so it reads from operand instead of reading from the frame struct. This prevents _CHECK_FUNCTION from interfering with the partial evaluation later on. It interferes because once we remove the frame, there is no
frame->func_obj
to check anymore.An added benefit is that the "burned in" version is also cheaper as it doesn't have to read from the frame struct, rather reading from the instruction itself in the JIT.