-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Empty Main works for corerun on WASM
#119448
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
Conversation
Additional changes to get to where we need to execute an unmanaged FCall implementation.
|
Tagging subscribers to this area: @mangod9 |
There was a problem hiding this comment.
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 implements essential array allocation functionality for WebAssembly (WASM) to enable empty Main() method execution in corerun. The implementation provides basic memory allocation, method invocation infrastructure, and interpreter support necessary for minimal CLR functionality on WASM.
Key changes include:
- Implementation of array allocation helpers (
RhpNewArrayFast,RhNewString) to support basic object creation - Addition of managed method invocation support through portable entry points and call stubs
- Updates to method compilation and invocation infrastructure for WASM interpreter compatibility
Reviewed Changes
Copilot reviewed 22 out of 23 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/vm/wasm/helpers.cpp | Implements calli stubs and managed method invocation for WASM interpreter |
| src/coreclr/vm/threads.cpp | Fixes preprocessor directive placement for portable helpers |
| src/coreclr/vm/runtimehandles.cpp | Adds null check assertion for type handle validation |
| src/coreclr/vm/prestub.cpp | Enhances FCall handling with portable entry point support and managed implementation detection |
| src/coreclr/vm/precode_portable.hpp | Adds method for creating portable entry points from native code |
| src/coreclr/vm/precode_portable.cpp | Implements portable entry point creation and code address management |
| src/coreclr/vm/portable/AllocSlow.cpp | Adds allocation failure handler stub |
| src/coreclr/vm/object.h | Adds SetNumComponents method and removes unused friend declarations |
| src/coreclr/vm/method.cpp | Refactors code entry point setting logic for portable entry points |
| src/coreclr/vm/jitinterface.cpp | Optimizes helper function entry point creation and caching |
| src/coreclr/vm/gchelpers.cpp | Updates array allocation to use new SetNumComponents method |
| src/coreclr/vm/gcheaputilities.h | Refactors allocation context methods for better encapsulation |
| src/coreclr/vm/finalizerthread.h | Moves RaiseShutdownEvents implementation to source file |
| src/coreclr/vm/finalizerthread.cpp | Implements RaiseShutdownEvents with WASM-specific handling |
| src/coreclr/vm/ecall.h | Adds optional output parameter for managed implementation detection |
| src/coreclr/vm/ecall.cpp | Enhances FCall implementation detection and managed constructor handling |
| src/coreclr/vm/callstubgenerator.cpp | Fixes variable shadowing in call stub generation |
| src/coreclr/runtime/portable/AllocFast.cpp | Implements fast array and string allocation with allocation context management |
| src/coreclr/nativeaot/Runtime/portable.cpp | Updates NativeAOT allocation helpers to use consistent method names |
| src/coreclr/nativeaot/Runtime/ObjectLayout.h | Standardizes method naming for array initialization |
| src/coreclr/nativeaot/Runtime/ObjectLayout.cpp | Updates method implementation to match new naming convention |
| src/coreclr/nativeaot/Runtime/GCHelpers.cpp | Updates allocation helper to use SetMethodTable naming |
for getting a JIT helper.
jkotas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
|
I tested it and it works 🎉 |
This hit a buggy path discussed in #119355 (comment) . I have reapplied the feedback with additional fix. |
radekdoulik
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I will address the remaining feedback on caching cookie in another PR
FYI @kotlarmilos |
Implement array allocators for WASM.
Calling empty
Main()works forcorerun. Steps:./build.sh -os browser -c Debug -subset clr.runtime+libsSystem.Runtime.dllto build.System.Runtime.dllto the IL location containingSystem.Private.CoreLib.dllSystem.Private.CoreLib.dll,System.Runtime.dlland<app>.dll.