Skip to content

[browser][coreCLR] R2R: R2R composite for the startup set #130519

Description

@pavelsavara

R2R composite for the startup set (follow-up to per-assembly)

Part of #130524.

Status: draft / issue candidate · Area: CoreCLR-on-WASM, precompilation/R2R · Related: #130522 (R2R over in-memory IL), #130523 (sharded IL), D4 · Builds on the upstream per-assembly R2R + webcil-in-wasm async-load foundation (#129634).

Goal

Combine the per-assembly startup R2R images into a single composite image, so the precompiled startup and hot code ships and loads as one unit rather than many per-assembly files. This is the follow-up to the first prototype's per-assembly R2R (D4).

Why

Per-assembly R2R is the simplest first step, but many small images mean more files, more per-image load/instantiate/fixup overhead, and cross-image calls that go through import indirection. A composite consolidates the startup set into one image with direct intra-composite calls and a single load — better code quality (fewer cross-image thunks) and more efficient startup load.

Direction

Scope

In: producing a single startup composite from the profile; loadable-on-WASM packaging; direct intra-composite calls with coherent fallback.

Out: the per-assembly R2R baseline (the prototype path); lazily-streamed shard R2R; the IL splitter/consumer.

Success criteria

  • The startup hot set ships and loads as one composite; behavior identical to the per-assembly set.
  • Measurable reduction in cross-image thunking and/or load overhead versus per-assembly R2R.

Open questions

Note

This issue was drafted with GitHub Copilot assistance.

Activity

  1. added this to the Future milestone on Jul 10, 2026
  2. self-assigned this
    on Jul 10, 2026
  3. dotnet-policy-service commented on Jul 10, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
    See info in area-owners.md if you want to be subscribed.

  4. changed the title [-][browser][coreCLR] R2R: X6 — R2R composite for the startup set[/-] [+][browser][coreCLR] R2R: R2R composite for the startup set[/+] on Jul 10, 2026
  5. modified the milestones: Future, 12.0.0 on Jul 13, 2026
  6. dotnet-policy-service commented on Jul 15, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @agocke, @elinor-fung
    See info in area-owners.md if you want to be subscribed.

  7. added
    os-wasiRelated to WASI variant of arch-wasm
    on Jul 18, 2026
  8. lewing commented on Jul 18, 2026

    @lewing
    Member

    Re: the open question "Whether the composite container is fully browser-loadable today or needs work (the component-file form may be desktop-shaped)" —

    It loads today with a small, OS-neutral VM change (~30 lines, TARGET_WASM). crossgen2 emits the startup composite as a flat webcil-in-wasm image, but the R2R/PE-decoder path assumes a mapped PE (a named RTR_HEADER export + IsMapped() RVA addressing), so out of the box it can't find the R2R header or address sections in a flat webcil composite. Four touch-points close that:

    File Change
    vm/nativeimage.cpp webcil composite exposes no RTR_HEADER export → fall back to the decoder's R2R header
    vm/readytoruninfo.cpp treat flat webcil as RVA-addressable from base (IsWebcilFormat() alongside IsMapped())
    vm/peimagelayout.inl route IsComponentAssembly() through the webcil decoder (DECODER_DISPATCH)
    vm/peimagelayout.cpp guard re-relocation of a host-probed shared buffer (a second ApplyBaseRelocations over the same memory doubles the additive wasm table-index relocs)

    Notes:

    • OS-neutral. Guarded on TARGET_WASM / FEATURE_PORTABLE_ENTRYPOINTS, so the same code serves browser (this issue / [browser][coreCLR] R2R on WebAssembly (R1) — tracking #130524) and wasi from one path.
    • The peimagelayout.cpp reloc-guard is only really exercised by the wasi single-shared-buffer host probe; on browser each probe open gets a fresh buffer, so ApplyBaseRelocations runs once per image and the guard is an inert no-op there.
    • Out of scope here: composite production/packaging (this issue's core), the SPC execution gates (Running wasm with R2R'd System.Private.CoreLib #129850), SIMD ISA reporting, and the host-side merge/probe.

    Validated on the prototype: a composite CoreLib R2R image (~49k R2R functions) loads and dispatches through these four changes. Happy to put up a small draft PR against main with just these files if it's useful for the composite work.

    Note

    Drafted with GitHub Copilot assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions