Skip to content
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

Support RETURN from tracing through a function #107925

Closed
wants to merge 35 commits into from

Conversation

gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented Aug 14, 2023

This depends on gh-107793.

This is only the first step for doing `CALL` in Tier 2.
The next step involves tracing into the called code object.
After that we'll have to do the remaining `CALL` specialization.
Finally we'll have to tweak various things like `KW_NAMES`,
and possibly move the `NULL` (for method calls) *above* the callable.
But those are things for future PRs.

Note: this moves setting `frame->return_offset` directly in front of
`DISPATCH_INLINED()`, to make it easier to move it into `_PUSH_FRAME`.
Instead, the special case is an opcode using SAVE_FRAME_STATE().
Introducing #if TIER_ONE and #if TIER_TWO so we can implement
_PUSH_FRAME differently for both tiers.
Instead, we special-case SAVE_IP:
- Its Tier 2 expansion sets oparg to the instruction offset
- In Tier 1 it is a no-op (and skipped if present in a macro)
@gvanrossum
Copy link
Member Author

gvanrossum commented Aug 14, 2023

Running tests with -Xuops seems to indicate that my translation of RETURN_CONST into LOAD_CONST + _POP_FRAME doesn't work -- it requires an extra stack slot which isn't always available. Back to the drawing board...

@gvanrossum
Copy link
Member Author

Running tests with -Xuops seems to indicate that my translation of RETURN_CONST into LOAD_CONST + _POP_FRAME doesn't work -- it requires an extra stack slot which isn't always available. Back to the drawing board...

This should be easy -- require that every function has at least one stack slot. The compiler guarantees that there is nothing on the stack below the return value, so RETURN_CONST would always start with an empty stack.

- This uses the function-by-version cache I just added
- There's not yet a way to trace back via `RETURN_VALUE`
This should fix leaks and hopefully most failing tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants