Skip to content

feat(codegen): migrate UrlNew onto the Layer 1 rooting API - #7461

Merged
proggeramlug merged 2 commits into
mainfrom
feat/layer1-migrate-urlnew
Aug 5, 2026
Merged

feat(codegen): migrate UrlNew onto the Layer 1 rooting API#7461
proggeramlug merged 2 commits into
mainfrom
feat/layer1-migrate-urlnew

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

First production lowering migrated onto the Layer 1 discipline (#7459), and it closed a window my own hand-fix in #7453 left behind.

Why the combinator, not the borrow form

FnCtx has no interior mutability — ctx.block() needs &mut — so #7459's borrow-carrying Raw cannot be built on it directly: root(self) would need a second borrow while the handle still holds the first. That is the same E0499 the RFC's own API hits.

The shape that works against a &mut-only emitter is the combinator, and it is exactly what the runtime settled on for layer 3 (RuntimeHandle::across_*): never hand out an unrooted handle at all. call_rooted emits the collecting call and roots its result in one step, so there is no window in which an unrooted register exists to be misused.

This is weaker than the borrow formulation — it prevents the bug rather than rejecting attempts to write it — but it needs no emitter rewrite, which is what makes the migration incremental instead of all-at-once.

It caught something I missed by hand

#7453 (hand-written) after migration
coerce url coerce url
root url root url
mk() — user call mk()
coerce base coerce base
read url root base ← closed
new_with_base(url, base_raw) read url
read base
new_with_base(read, read)

base_ptr was live and unrooted across js_gc_temp_root_get in the hand-written version. A small window, but a window — and I did not see it when writing that fix, which is the whole argument for having an API instead of a review checklist.

Verification

  • 11/11 new URL / URLPattern gap tests byte-identical to the pinned Node oracle
  • repro exits 0 under PERRY_GC_HEAP_LIMIT=8 PERRY_GC_FORCE_EVACUATE=1
  • IR inspected directly (above), not inferred
  • rooting unit tests and doctests green; cargo fmt --check clean

Scope

One lowering. UrlPatternNew and the rest of perry-codegen are unchanged, and this does not finish Layer 1 — but the migration is now started against real code rather than a mock, and the first site it touched had a residual bug in it.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@proggeramlug, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 2 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7a89febb-5e22-494a-8b5a-d8f6f9067d2e

📥 Commits

Reviewing files that changed from the base of the PR and between a5478e6 and 46938d3.

📒 Files selected for processing (3)
  • changelog.d/7461-layer1-migrate-urlnew.md
  • crates/perry-codegen/src/expr/url_main.rs
  • crates/perry-codegen/src/rooting.rs
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/layer1-migrate-urlnew

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Ralph Küpper added 2 commits August 5, 2026 17:28
First production lowering on the layer 1 discipline, and it closed a
window the hand-fix in #7453 left behind.

FnCtx has no interior mutability -- ctx.block() needs &mut -- so the
borrow-carrying Raw from #7459 cannot be built on it: root(self) would
need a second borrow while the handle holds the first. The shape that
works against a &mut-only emitter is the combinator, which is what the
runtime settled on for layer 3 (RuntimeHandle::across_*): never hand out
an unrooted handle at all. call_rooted emits the collecting call and
roots its result in one step.

Emitted window, #7453 vs now:

  before                          after
  coerce url                      coerce url
  root url                        root url
  mk()          <- user call      mk()
  coerce base   <- UNROOTED       coerce base
  read url                        root base      <- closed
  new_with_base(url, base_raw)    read url
                                  read base
                                  new_with_base(read, read)

base_ptr was live and unrooted across js_gc_temp_root_get in the
hand-written version. Small window, but a window -- and I did not see it
when writing that fix by hand, which is the argument for the API.

11/11 URL gap tests byte-identical to node; repro clean under
PERRY_GC_HEAP_LIMIT=8 PERRY_GC_FORCE_EVACUATE=1.
@proggeramlug
proggeramlug force-pushed the feat/layer1-migrate-urlnew branch from c3d355f to 46938d3 Compare August 5, 2026 15:28
@proggeramlug
proggeramlug merged commit 01d1249 into main Aug 5, 2026
@proggeramlug
proggeramlug deleted the feat/layer1-migrate-urlnew branch August 5, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant