-
-
Notifications
You must be signed in to change notification settings - Fork 32k
f_lasti
points to CACHE
opcode during inlined CALL
#96970
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
Comments
The issue is that when "inlining" a pure-Python call like Personally, I think the docs you linked to cover this:
So, in my opinion, the correct thing to do here is for tools to scan backwards over any caches when trying to find the last "real" instruction. I can see why we might want to make this more consistent, though. If others agree, we can look into ways of making that happen, but I'm worried that they'll either come with a performance cost for many types of calls, or be too invasive to justify in a patch release. |
I see you updated your comment. I read the original wording as "this is completely wrong". |
Not for 3.11, but maybe we could change the - #define INSTRUCTION_START(op) (frame->prev_instr = next_instr++)
+ #define INSTRUCTION_START(op) do {
+ frame->prev_instr = next_instr;
+ next_instr += (1 + INLINE_CACHE_ENTRIES_ ## op); // fixme for adaptive instructions
+ while (0) Then we could remove most I'm not sure whether the resulting code would look better or worse, but I believe it would make |
We can work with the current implementation. Our work around already is that we scan backwards to the last instruction.
This confused me and I got the impression that this might be a bug. |
Actually, I think I misunderstood, what I wrote would make prev_instr always point to the next instruction. |
f_lasti
points to CACHE
opcode during inlined CALL
@carljm had an interesting idea: leave next_instr += _PyOpcode_Caches[_PyOpcode_Deopt[_Py_OPCODE(next_instr[-1])]]; This should "fix" the issue, but we should definitely measure its performance impact, since it adds quite a bit of logic to every return from an inlined call. I'll experiment with this approach over the next couple of days. |
The situation is probably very different following #109095. |
Indeed, a slightly tweaked example (since It does still reproduce on 3.12, but I'm not sure that's really worth changing at this point? |
On 3.14, we have different outputs and |
The current behavior is ok for me. My initial assumption was that it could be a bug based on what I read in the docs. |
Is it ok to close the issue then? |
Yes it is ok for me if you close this issue |
Uh oh!
There was an error while loading. Please reload this page.
The instruction pointer
f_lasti
points under some conditions to a CACHE opcode.This is not completely wrong, because this cache opcode comes after the expected
CALL
opcode, but the documetation says that CACHE opcodes should be skipped. Which it is not in this case.script:
output (Python 3.11.0rc2+):
The text was updated successfully, but these errors were encountered: