-
Notifications
You must be signed in to change notification settings - Fork 19
jit: the inlined-callee frame image and the escape attribution behind VableEscapedDuringResidualCall #1015
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
jit: the inlined-callee frame image and the escape attribution behind VableEscapedDuringResidualCall #1015
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
620be27
AGENTS: record the PyPy oracle as the first step for orthodoxy questions
youknowone b953978
sys: split _getframe into the unwrap_spec wrapper and the getframe walk
youknowone 502eb74
check.py: add a self-check guard for an inlined callee's own frame image
youknowone 206b3de
jit: record the inlined callee's Python pc on its virtual frame at ma…
youknowone c251aa5
jit: report a virtualizable escape independently of whether the flush…
youknowone 6bdb29c
jit: attribute each virtualizable-escape force to the portal or publi…
youknowone aa3d9dc
jit(fbw): write folded inline-callee vable stores through to the live…
youknowone e81a5ca
jit(fbw): materialize folded inline-callee locals when a residual for…
youknowone 8fe75a7
jit(fbw): publish the callee's own pc when LiveLastInstrGuard retarge…
youknowone 05df83c
jit: call the renamed py_coord helper from the two inline-callee pc s…
youknowone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
pyre/bench/frame_inlined_callee_own_image_regression.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| # Self-checking regression guard for the image an INLINED CALLEE's own frame | ||
| # reports (registered via check.py run_selfcheck, NOT the synthetic suite). | ||
| # | ||
| # Sibling of `frame_lineno_mid_replay_regression`, which reads the coordinate | ||
| # through `sys._getframe(1)` from a callee whose caller is the portal — the | ||
| # frame the JIT treats as the virtualizable, and whose fields the walk keeps | ||
| # current. The shape here is the other one: the frame handed out is the | ||
| # INLINED CALLEE's own, materialised through a `jit.virtual_ref` rather than | ||
| # being the virtualizable. Such a frame is built with `last_instr = -1` | ||
| # (`pyre-jit-trace/src/helpers.rs`) and nothing updates it through the inlined | ||
| # body, and its locals region is not what the escape flush writes — that flush | ||
| # is keyed on the virtualizable. So the image has to come from the force, and | ||
| # `offset2lineno(code, -1)` answers the `def` line when it does not. | ||
| # | ||
| # What routes these reads to a correct answer today is the abort: | ||
| # `sys._getframe` forces the virtualizable, `vable_after_residual_call` reads | ||
| # the cleared token as a callee escape, and the interpreter finishes the | ||
| # iteration. That makes this guard load-bearing in an unusual way — it pins | ||
| # the ANSWER, not the mechanism, so a change that removes the abort in favour | ||
| # of a consumer-side force has to keep the answer. Removing the two forces in | ||
| # `sys._getframe` and forcing from the `f_lineno` / `f_lasti` getsets instead | ||
| # left the whole 370-fixture corpus green while making `own_lineno` below | ||
| # report the `def` line, `own_locals` grow a second entry, and `own_combined` | ||
| # segfault. None of the three had a fixture; that is why this one exists. | ||
| # | ||
| # Splitting each survey across several calls is what makes it a test, for the | ||
| # same reason the sibling guard does it: the loop compiles part-way through, so | ||
| # a set over the rounds holds the interpreted answer and the compiled one | ||
| # together, and a divergence appears as a SECOND element rather than a shifted | ||
| # single value. | ||
| # | ||
| # Offsets are relative to `co_firstlineno` so the expectations survive an edit | ||
| # above them. It asserts rather than diffing against pypy3 because the shape | ||
| # it pins is a pyre-internal one; cpython and pypy3 both answer the same values | ||
| # and agree with `PYRE_NO_JIT=1`. | ||
| import sys | ||
|
|
||
| N = 4000 | ||
| ROUNDS = 8 | ||
|
|
||
|
|
||
| def own_lineno(x): # +0 | ||
| f = sys._getframe(0) # +1 | ||
| return f.f_lineno - f.f_code.co_firstlineno # +2 | ||
|
|
||
|
|
||
| def own_locals(x): # +0 | ||
| f = sys._getframe(0) # +1 | ||
| return tuple(sorted(f.f_locals)) # +2 | ||
|
|
||
|
|
||
| def own_combined(x): # +0 | ||
| f = sys._getframe(0) # +1 | ||
| return (f.f_lineno - f.f_code.co_firstlineno, tuple(sorted(f.f_locals)), f.f_lasti >= 0) | ||
|
|
||
|
|
||
| def drive_lineno(n): | ||
| seen = set() | ||
| i = 0 | ||
| while i < n: | ||
| seen.add(own_lineno(i)) | ||
| i += 1 | ||
| return seen | ||
|
|
||
|
|
||
| def drive_locals(n): | ||
| seen = set() | ||
| i = 0 | ||
| while i < n: | ||
| seen.add(own_locals(i)) | ||
| i += 1 | ||
| return seen | ||
|
|
||
|
|
||
| def drive_combined(n): | ||
| seen = set() | ||
| i = 0 | ||
| while i < n: | ||
| seen.add(own_combined(i)) | ||
| i += 1 | ||
| return seen | ||
|
|
||
|
|
||
| def main(): | ||
| each = N // ROUNDS | ||
| failures = [] | ||
|
|
||
| def check(label, got, want): | ||
| if got != want: | ||
| failures.append(f"{label}: got {got!r}, want {want!r}") | ||
|
|
||
| seen = set() | ||
| for _ in range(ROUNDS): | ||
| seen |= drive_lineno(each) | ||
| check("own_lineno", sorted(seen), [2]) | ||
|
|
||
| seen = set() | ||
| for _ in range(ROUNDS): | ||
| seen |= drive_locals(each) | ||
| check("own_locals", sorted(seen), [("f", "x")]) | ||
|
|
||
| seen = set() | ||
| for _ in range(ROUNDS): | ||
| seen |= drive_combined(each) | ||
| check("own_combined", sorted(seen), [(2, ("f", "x"), True)]) | ||
|
|
||
| if failures: | ||
| for f in failures: | ||
| print("FAIL", f) | ||
| return 1 | ||
| print("PASS inlined-callee own frame image") | ||
| return 0 | ||
|
|
||
|
|
||
| sys.exit(main()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Specify the fenced code-block language.
Line 204 starts a shell command block without a language identifier. Add
shto satisfy markdownlint.Proposed fix
🧰 Tools
🪛 markdownlint-cli2 (0.23.1)
[warning] 204-204: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents
Source: Linters/SAST tools