Skip to content

Group cold-exclusive WebAssembly R2R imports before layout - #107

Merged
jtschuster merged 1 commit into
wasm-r2r-partitioned-modulesfrom
wasm-r2r-import-layout
Oct 29, 2026
Merged

jtschuster merged 1 commit into
wasm-r2r-partitioned-modulesfrom
wasm-r2r-import-layout

Conversation

@jtschuster

Copy link
Copy Markdown
Owner

Summary

Follow-up to dotnet#136607, targeting jtschuster/runtime:wasm-r2r-partitioned-modules.

Classify import ownership before object emission assigns table indices and offsets, then place primary-needed cells before cold-exclusive cells within every import table. Apply the same partition key to each parallel signature-RVA entry; retain the existing deterministic comparison within each group. Reuse this ownership result when extracting auxiliary data rather than rediscovering ownership after layout.

GC reference maps now retain import identities and follow physical cell order, including empty records for non-method cells and the 1024-record lookup stride. Table identities, entry sizes, alignment, relocation targets, and pointer-scaled fixup-list encoding are unchanged; their dependent offsets are generated from the partitioned layout.

Keep eager, shared, unused, and resident-data-referenced imports primary. Determine signature ownership after symbol deduplication, preserving signatures shared with primary cells or directly referenced by resident data. Stably group cold-exclusive signature blobs at the end of data emission.

Safety boundaries

  • Resident portable import-thunk records pin their referenced import cells primary. Moving them based only on a cold method's use would not establish exclusive ownership of all consumers.
  • GC maps remain resident: their stride-indexed encoding spans primary and cold cells.
  • Alignment gaps are not claimed as cold-owned bytes. Aligned signature blobs can therefore still require separate passive segments; the implementation does not merge across primary-owned bytes to reduce the count.
  • Existing guarded, status-last sidecar activation is unchanged. Both activation-order host tests now check preservation of a previously resolved primary-owned cell and data resolved after the first sidecar activates.

Coverage and validation

Passed

  • Browser-WASM Release compiler library build, zero warnings/errors:
    ./.dotnet/dotnet build src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj \
      -c Release --no-restore /p:NuGetAudit=false /p:PublishReadyToRun=false \
      /p:TargetOS=browser /p:TargetArchitecture=wasm
  • All 15 focused xUnit cases in WasmImportLayoutTests.cs, run against that built compiler using a session-only project and the existing xUnit 2.9.3 console runner. This bypasses the normal test project's native-artifact staging requirement; it does not substitute for the full compiler suite.
  • Actual emitted import-table symbols show 4 cold-owned runs reduced to 1 for an eight-cell mixed table, and 513 reduced to 1 for a 1025-cell mixed table. Assertions also check signature-array relocation targets, indices and offsets, alignment, GC-map lookup-stride offsets, and fixup-list bytes. These are table-level range counts, not a whole-application sidecar-size or passive-segment measurement.
  • Focused cases cover deterministic grouping in reversed insertion order, shared/eager/unused/resident-data imports, eager validation-before-R2R-commit ordering, shared/deduplicated/directly referenced signatures, stable blob grouping, generic-method GC maps, non-method GC records, and empty/all-primary/all-cold partitions.
  • npm --prefix src/native run test:auxiliary-modules: 17 passed, including both activation orders, idempotence, empty-body activation, and the added resolved-data preservation assertions. TypeScript 5.9.2 was restored to a session-only directory and selected with TYPESCRIPT_PATH after the repository's npm restore encountered a registry connection reset.
  • git diff --check.

Not run / blocked

  • The normal ILCompiler.ReadyToRun.Tests.csproj build/test invocation was attempted. After restoring the required SDK and bypassing an unavailable NuGet audit endpoint and SDK R2R package download, it stops while staging missing artifacts/bin/coreclr/browser.wasm.Release/x64/libjitinterface_x64.so.
  • A native browser JIT prerequisite build was attempted and stops at missing Ninja; CMake and Clang are also absent. This checkout has no built Browser-WASM runtime, libraries, or Core_Root.
  • Consequently the full compiler integration suite and five physical PartitionedR2RActivation runtime variants were not run. Their existing managed fixture is extended to exercise mixed and shared type imports and a generic import before, between, and after activation. All-hot/all-cold boundary coverage is retained.

No whole-application performance or download-size claim is made. Full native/runtime validation remains necessary before merging.

@jtschuster
jtschuster marked this pull request as ready for review October 29, 2026 23:35
@jtschuster
jtschuster merged commit 1cd46b8 into wasm-r2r-partitioned-modules Oct 29, 2026
1 check passed
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