docs(gc): write down why the this-patch closure roots need no explicit release - #6979
Merged
Conversation
CodeRabbit read `rooted_handle_release` as a pop and flagged the `this_patches` closure roots as leaked. They are not: `js_gc_temp_root_truncate` is a stack CUT, and `rooted` is pushed before the property loop, so the single release at the end of the function drops the object handle and every closure root above it. That does depend on the push order, which was not written down — say so, and point at the unit test that pins the cut semantics.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe object literal lowering code and changelog document temporary-root lifetime handling in the ChangesObject literal rooting
Estimated code review effort: 1 (Trivial) | ~2 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Comment only — no codegen change.
CodeRabbit's review of #6975 raised one more finding after that PR merged:
That one is a false positive, but only because of a semantic that was never written down at the site:
js_gc_temp_root_truncateis a stack cut, not a pop. It truncates the vector tobase, droppingbaseand everything pushed above it. Inlower_object_literal:rooted_handle_beginpushes the object handle (index N),captures_thisclosure value (N+1, N+2, …),rooted_handle_release(ctx, rooted)at the end truncates to N,so the single release does drop every closure root.
gc::tests::temp_roots::truncate_drops_every_slot_above_the_basepins the cut semantics.It does depend on the push order, though, and nothing said so — a refactor that hoisted the closure pushes above
rooted_handle_begin, or moved the release before the patch loop, would silently leak (or under-root). This adds eight lines of comment stating the invariant, naming the two constraints it rests on, and pointing at the test.Verified:
cargo check -p perry-codegenandcargo fmt --all -- --checkclean; no emitted IR changes (comment only).Summary by CodeRabbit
this-related closure roots during object-literal lowering.temp_roottruncation works as a stack cut and how a later single release covers roots created afterward, removing ambiguity around expected cleanup behavior.