Skip to content

Make all entries in WASM tables SymbolDefinitions#130920

Draft
jtschuster wants to merge 4 commits into
dotnet:mainfrom
jtschuster:jtschuster-wasm-table-symbols
Draft

Make all entries in WASM tables SymbolDefinitions#130920
jtschuster wants to merge 4 commits into
dotnet:mainfrom
jtschuster:jtschuster-wasm-table-symbols

Conversation

@jtschuster

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings July 16, 2026 20:07
@github-actions github-actions Bot added the area-crossgen2-coreclr only use for closed issues label Jul 16, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging @dotnet/jit-contrib for JIT-EE GUID update

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the WASM object writer to assign and resolve WASM structural indices (function/type/table) via a shared symbol-index table, and extends SuperPMI recording support for getWasmWellKnownGlobals alongside a JIT/EE interface GUID bump.

Changes:

  • Replace ad-hoc _uniqueSymbols/_uniqueSignatures bookkeeping with per-section symbol index assignment and use it to self-resolve WASM index relocations.
  • Update well-known WASM global symbol names for READYTORUN and wire them into default import creation.
  • Add SuperPMI record support for GetWasmWellKnownGlobals and update JITEEVersionIdentifier.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h Adds a recGetWasmWellKnownGlobals declaration (currently duplicated in the header).
src/coreclr/tools/Common/Compiler/ObjectWriter/WasmObjectWriter.cs Centralizes symbol index assignment and uses it for WASM index relocations; updates exports/elements counts to use derived method count.
src/coreclr/tools/Common/Compiler/ObjectWriter/ObjectWriter.cs Makes EmitSymbolDefinition virtual to allow format-specific overrides.
src/coreclr/tools/Common/Compiler/DependencyAnalysis/WasmWellKnownGlobalSymbolNode.cs Switches well-known global import names based on READYTORUN.
src/coreclr/inc/jiteeversionguid.h Updates the JIT/EE interface version GUID.

Comment thread src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h Outdated
Comment thread src/coreclr/tools/Common/Compiler/ObjectWriter/WasmObjectWriter.cs
Comment thread src/coreclr/tools/Common/Compiler/ObjectWriter/WasmObjectWriter.cs
And use the symbol definitions for reloc lookups. This creates a single location for all named entries in each section of the module, and makes _uniqueSignatures, _uniqueSymbols, and _methodCount unnecessary.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2b88048c-7bbb-40bb-ae53-e990e71779c0
Copilot AI review requested due to automatic review settings July 16, 2026 20:34
@jtschuster
jtschuster force-pushed the jtschuster-wasm-table-symbols branch from d2f13bb to 2b84bf9 Compare July 16, 2026 20:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment on lines 1092 to 1099
SectionWriter typeSectionWriter = GetOrCreateSection(ObjectNodeSection.WasmTypeSection);
byte[] encodedSignature = new byte[signature.EncodeSize()];
signature.Encode(encodedSignature);
typeSectionWriter.EmitData(encodedSignature);
// Assigns the type index (via the EmitSymbolDefinition override) and registers the
// signature in the defined-symbol table used during relocation resolution.
typeSectionWriter.EmitSymbolDefinition(signatureKey);

Comment on lines +846 to +847
private int RegisterFunctionSymbol(Utf8String name) =>
GetOrCreateSymbolIndex(name, GetOrCreateSection(WasmObjectNodeSection.FunctionSection).SectionIndex);
Copilot AI review requested due to automatic review settings July 16, 2026 23:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Debug.Assert(bytesWritten == encodeSize);
writer.Buffer.Advance((int)bytesWritten);

writer.EmitSymbolDefinition(new Utf8String(import.Name));
if (!_wasmSymbolDefinitions.TryGetValue(reloc.SymbolName, out var symbol))
{
throw new InvalidDataException($"Type signature symbol definition '{reloc.SymbolName}' not found");
throw new NotImplementedException($"No wasm index registered for symbol '{reloc.SymbolName}' (relocation {reloc.Type}).");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-crossgen2-coreclr only use for closed issues

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants