[Wasm RyuJIT] Generate element section and populate function pointer table#125531
[Wasm RyuJIT] Generate element section and populate function pointer table#125531kg merged 5 commits intodotnet:mainfrom
Conversation
Add image_pointer_base Scaffolding for element sections
…for every function in the module
|
cc @adamperlin |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Pull request overview
This PR updates the Wasm object writer used by CoreCLR tooling to support function-pointer table initialization by emitting a WebAssembly element section, and aligns the imported globals used as bases for data and function-pointer placement.
Changes:
- Rename the imported module base global from
__r2r_startto__image_baseand update data segment placement to use it. - Add a new imported global
__image_pointer_baseand use it as the offset expression for an emitted element segment. - Emit an element section that initializes the table with function indices in sequential order, and prepend the element-segment count during emission.
You can also share your feedback on Copilot code review. Take the survey.
src/coreclr/tools/Common/Compiler/ObjectWriter/WasmObjectWriter.cs
Outdated
Show resolved
Hide resolved
|
With these changes applied, using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
public static unsafe class Program {
[MethodImpl(MethodImplOptions.NoInlining)]
static void voidFunc () {
}
[MethodImpl(MethodImplOptions.NoInlining)]
static void callVoidFunc () {
voidFunc();
}
}Because |
There was a problem hiding this comment.
Pull request overview
This PR updates the Wasm object writer to emit a Wasm Element section that initializes the function pointer table, and adjusts related global imports/offset handling to use __image_base/__image_pointer_base.
Changes:
- Added a Wasm Element section and logic to write an element segment that initializes table entries for all generated functions.
- Renamed
__r2r_startusage to__image_baseand added a new__image_pointer_baseglobal import for table population offsets. - Fixed table section limits so the function pointer table is allocated with a non-zero initial size.
You can also share your feedback on Copilot code review. Take the survey.
src/coreclr/tools/Common/Compiler/ObjectWriter/WasmObjectWriter.cs
Outdated
Show resolved
Hide resolved
src/coreclr/tools/Common/Compiler/ObjectWriter/WasmObjectWriter.cs
Outdated
Show resolved
Hide resolved
src/coreclr/tools/Common/Compiler/ObjectWriter/WasmObjectWriter.cs
Outdated
Show resolved
Hide resolved
adamperlin
left a comment
There was a problem hiding this comment.
I think this looks good! Thanks for doing this work. Now that I'm reading it, we might want to rename __image_pointer_base to _image_table_base or something similar, just so we're very clear to distinguish between data pointers and function/table indices. Not crucial though.
|
I think that works! |
There was a problem hiding this comment.
Pull request overview
This PR updates the CoreCLR Wasm object writer to support initializing the function pointer table via an emitted element section, while also renaming the module base import and introducing a new imported global intended to represent the function-pointer-table base offset.
Changes:
- Add a new
wasm.elementsection and emit a single active element segment that initializes the table with all generated functions. - Rename the imported module base global from
__r2r_startto__image_baseand add a new imported global for the function pointer table base (__image_function_pointer_base). - Fix the table limits encoding so the table’s minimum/maximum size are no longer emitted with an initial size of 0.
You can also share your feedback on Copilot code review. Take the survey.
|
/ba-g iOS deadletter and known flakes for configurations unaffected by this wasm-only change |
Uh oh!
There was an error while loading. Please reload this page.