-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[WASM] Use relocs for tableBase / imageBase / stackPointer globals #129717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jtschuster
merged 23 commits into
dotnet:main
from
jtschuster:jtschuster/wasm-base-global-reloc-test
Jul 16, 2026
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
832f9d8
Emit wasm base globals as WASM_GLOBAL_INDEX_LEB relocations
jtschuster fc8462b
Cover wasm base-global relocations in WasmWebcilModule R2R test
jtschuster d03465e
Validate wasm base-global global.get emission in WasmWebcilModule R2R…
jtschuster 2083974
Restrict wasm base-global emitter to global.get
jtschuster e45baaf
Add getWasmBaseGlobals JIT-EE API for wasm base globals
jtschuster a192e3a
Resolve wasm base-global relocs via WasmBaseGlobalSymbolNode.GlobalIndex
jtschuster 9227ffb
Address PR review: append getWasmBaseGlobals last, guard wasm-only JI…
jtschuster 29ce847
Merge remote-tracking branch 'upstream/main' into jtschuster/wasm-bas…
jtschuster 71346df
Rename WASM base globals to well-known globals; cache symbol nodes on…
jtschuster 6d4bd72
Merge remote-tracking branch 'upstream/main' into jtschuster/wasm-bas…
jtschuster 9a7d534
Make WasmWellKnownGlobalNode inherit from ExternSymbolNode
jtschuster 2def050
Make symbol name the identity of WasmWellKnownGlobalSymbol
jtschuster c19051f
Merge branch 'main' of https://github.com/dotnet/runtime into jtschus…
jtschuster 2ec6045
Jit format and delete unused STACK_POINTER_GLOBAL
jtschuster 5ef08a4
Merge branch 'main' into jtschuster/wasm-base-global-reloc-test
jtschuster aec85c0
Merge branch 'main' of https://github.com/dotnet/runtime into jtschus…
jtschuster 2eb601b
Update JIT-EE interfacae Guid
jtschuster 799f95b
Merge branch 'main' of https://github.com/dotnet/runtime into jtschus…
jtschuster efbd9b2
Update test to avoid optimization of try/catch and include method cal…
jtschuster b83daa5
Merge upstream/main into jtschuster/wasm-base-global-reloc-test
jtschuster dbd7484
Remove usings
jtschuster 83ef375
Merge upstream/main into jtschuster/wasm-base-global-reloc-test
jtschuster 1ca50fb
Merge upstream/main into jtschuster/wasm-base-global-reloc-test
jtschuster File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
File renamed without changes.
34 changes: 34 additions & 0 deletions
34
src/coreclr/tools/Common/Compiler/DependencyAnalysis/NodeFactory.Wasm.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Collections.Frozen; | ||
| using System.Threading; | ||
| using Internal.Text; | ||
|
|
||
| namespace ILCompiler.DependencyAnalysis | ||
| { | ||
| public partial class NodeFactory | ||
| { | ||
| // The well-known wasm globals are immutable relocation targets. They are created | ||
| // lazily on first access (only wasm targets ever request them) so non-wasm compilations don't | ||
| // pay the allocation. | ||
| private FrozenDictionary<Utf8String, WasmWellKnownGlobalSymbolNode> _wasmWellKnownGlobals; | ||
|
|
||
| public WasmWellKnownGlobalSymbolNode GetWellKnownWasmGlobalSymbol(Utf8String symbolName) | ||
| { | ||
| FrozenDictionary<Utf8String, WasmWellKnownGlobalSymbolNode> globals = _wasmWellKnownGlobals; | ||
| if (globals is null) | ||
| { | ||
| globals = FrozenDictionary.Create<Utf8String, WasmWellKnownGlobalSymbolNode>([ | ||
| new(new(WasmWellKnownGlobalSymbolNode.StackPointerName), new WasmWellKnownGlobalSymbolNode(WasmWellKnownGlobalSymbolNode.StackPointerName)), | ||
| new(new(WasmWellKnownGlobalSymbolNode.ImageBaseName), new WasmWellKnownGlobalSymbolNode(WasmWellKnownGlobalSymbolNode.ImageBaseName)), | ||
| new(new(WasmWellKnownGlobalSymbolNode.TableBaseName), new WasmWellKnownGlobalSymbolNode(WasmWellKnownGlobalSymbolNode.TableBaseName)) | ||
| ]); | ||
|
|
||
| globals = Interlocked.CompareExchange(ref _wasmWellKnownGlobals, globals, null) ?? globals; | ||
| } | ||
|
|
||
| return globals[symbolName]; | ||
| } | ||
|
jtschuster marked this conversation as resolved.
|
||
| } | ||
| } | ||
24 changes: 24 additions & 0 deletions
24
src/coreclr/tools/Common/Compiler/DependencyAnalysis/WasmWellKnownGlobalSymbolNode.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using Internal.Text; | ||
|
|
||
| namespace ILCompiler.DependencyAnalysis | ||
| { | ||
| /// <summary> | ||
| /// Represents one of the well-known wasm globals referenced by JIT-generated code. | ||
| /// These are imported globals whose final index is assigned by the ObjectWriter / wasm linker. | ||
| /// crossgen2/R2R resolves it back to the fixed index defined in the WebCIL format, while a relocatable | ||
| /// NativeAOT object emits it as an undefined imported global for wasm-ld to resolve. | ||
| /// </summary> | ||
| public class WasmWellKnownGlobalSymbolNode(string symbolName) : ExternDataSymbolNode(new Utf8String(symbolName)) | ||
| { | ||
| public const string StackPointerName = "__stack_pointer"; | ||
| public const string ImageBaseName = "__memory_base"; | ||
| public const string TableBaseName = "__table_base"; | ||
|
|
||
| public override int ClassCode => 0x79046cf9; | ||
|
|
||
| protected override string GetName(NodeFactory factory) => $"WasmWellKnownGlobal {this.ToString()}"; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.