Repository navigation
[browser] modularize corerun - #121318
Merged
Merged
[browser] modularize corerun#121318
Conversation
Contributor
|
Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov |
This was referenced Nov 4, 2025
Open
pavelsavara
force-pushed
the
browser_modularize_corerun
branch
from
November 7, 2025 19:06
7501a3b to
e993dc3
Compare
pavelsavara
marked this pull request as ready for review
November 7, 2025 19:37
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements infrastructure for WASM/browser diagnostics support and refactors module initialization, including renaming PromiseController to PromiseCompletionSource, consolidating Emscripten export definitions, and adding support for Virtual File System (VFS) operations.
- Adds new
dotnet.diagnostics.jsmodule infrastructure with rollup configuration - Refactors promise-related APIs from PromiseController to PromiseCompletionSource across the codebase
- Consolidates Emscripten export definitions into a centralized
GenerateEmccExportstarget innative.wasm.targets - Adds VFS file installation support and runtime registration for corehost browserhost
- Introduces unsigned right-shift operations (
>>> 0) for memory safety in pointer operations
Reviewed Changes
Copilot reviewed 47 out of 50 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/native/rollup.config.js | Adds dotnetDiagnosticsJS configuration for new diagnostics module build |
| src/native/rollup.config.defines.js | Adds fallback default path for StaticLibDestination to support local development |
| src/native/libs/build-native.proj | Changes import from native.props to native.wasm.targets and adds GenerateEmccExports dependency |
| src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/weak-ref.ts | Adds weak reference utility functions with polyfill fallback for browsers lacking WeakRef support |
| src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/types.ts | Defines WeakRefInternal type extending WeakRef with optional dispose method |
| src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts | Formatting: adds spacing in function signature |
| src/native/libs/System.Native.Browser/utils/types.ts | Re-exports types from parent types module |
| src/native/libs/System.Native.Browser/utils/strings.ts | Adds unsigned right-shift operations for pointer safety |
| src/native/libs/System.Native.Browser/utils/runtime-list.ts | Implements runtime registry using WeakRef for managing multiple dotnet runtimes on a page |
| src/native/libs/System.Native.Browser/utils/polyfills.ts | Adds WeakRef polyfill for browsers lacking native support |
| src/native/libs/System.Native.Browser/utils/memory.ts | Adds unsigned right-shift operations for safe memory access and updates import path |
| src/native/libs/System.Native.Browser/utils/index.ts | Initializes polyfills, registers runtime and CDAC, adds zeroRegion export |
| src/native/libs/System.Native.Browser/utils/host.ts | Renames parameter from exit_code to exitCode |
| src/native/libs/System.Native.Browser/utils/cdac.ts | Registers CDAC (Contract Descriptor for Active Contract) functions to runtime API |
| src/native/libs/System.Native.Browser/native/timer.ts | Updates to use global functions instead of Module namespace |
| src/native/libs/System.Native.Browser/native/main.ts | Adds return type annotations and SystemJS_ConsoleClear function |
| src/native/libs/System.Native.Browser/native/index.ts | Exports SystemJS_ConsoleClear and formatting improvements |
| src/native/libs/System.Native.Browser/native/cross-linked.ts | Adds _GetDotNetRuntimeContractDescriptor function declaration |
| src/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js | Adds GetDotNetRuntimeContractDescriptor to dependencies |
| src/native/libs/System.Native.Browser/entrypoints.c | Adds SystemJS_ConsoleClear entrypoint |
| src/native/libs/System.Native.Browser/diagnostics/index.ts | Creates placeholder diagnostics module with dummy export |
| src/native/libs/Common/JavaScript/types/public-api.ts | Renames parameter from exit_code to exitCode and adds VfsAsset type |
| src/native/libs/Common/JavaScript/types/internal.ts | Renames PromiseController to PromiseCompletionSource |
| src/native/libs/Common/JavaScript/types/exchange.ts | Adds exports for debug logging, promise utilities, VFS operations, and zeroRegion |
| src/native/libs/Common/JavaScript/cross-module/index.ts | Updates table indices after adding debug logger and new loader exports |
| src/native/libs/Common/JavaScript/cross-linked/index.ts | Adds type annotations, RuntimeExports, and global function declarations |
| src/native/libs/Common/JavaScript/CMakeLists.txt | Reorganizes source file list and adds new diagnostics, polyfills, and utility files |
| src/native/corehost/corehost.proj | Changes import and adds GenerateEmccExports and ResolveRuntimeFilesFromLocalBuild dependencies |
| src/native/corehost/browserhost/sample/CMakeLists.txt | Adds dotnet.diagnostics.js and map file to sample assets |
| src/native/corehost/browserhost/loader/run.ts | Renames PromiseController to PromiseCompletionSource and adds selfHostNodeJS for Node.js auto-start |
| src/native/corehost/browserhost/loader/promise-completion-source.ts | Renames from promise-controller.ts with updated symbol and function names |
| src/native/corehost/browserhost/loader/polyfills.ts | Removes WeakRef polyfill (moved to utils), adds nodeFs/nodeUrl helpers |
| src/native/corehost/browserhost/loader/logging.ts | Adds debug logging function |
| src/native/corehost/browserhost/loader/index.ts | Adds debug logger and promise completion source exports to loader exchange |
| src/native/corehost/browserhost/loader/exit.ts | Renames parameter from exit_code to exitCode |
| src/native/corehost/browserhost/loader/dotnet.ts | Removes registerRuntime call and adds selfHostNodeJS for auto-start |
| src/native/corehost/browserhost/loader/dotnet.d.ts | Renames parameter and adds VfsAsset type definition |
| src/native/corehost/browserhost/loader/bootstrap.ts | Adds findResources, isNodeHosted, isShellHosted functions and VFS fetching support |
| src/native/corehost/browserhost/libBrowserHost.footer.js | Adds FS and NODEFS dependencies and Node.js filesystem mounting |
| src/native/corehost/browserhost/host/index.ts | Adds installVfsFile export to browser host exports |
| src/native/corehost/browserhost/host/host.ts | Implements installVfsFile for creating files in Emscripten virtual filesystem |
| src/native/corehost/browserhost/browserhost.cpp | Updates library name matching from libSystem.JavaScript to libSystem.JavaScript.Native |
| src/native/corehost/browserhost/CMakeLists.txt | Refactors to use CMAKE variables for Emscripten exports, adds environment and error limit flags |
| src/coreclr/vm/wasm/callhelpers.cpp | Adds CallFunc_I32_I32_IND_RetVoid thunk for new call signature |
| src/coreclr/runtime.proj | Changes import and adds GenerateEmccExports dependency |
| src/coreclr/hosts/corerun/wasm/libCorerun.pre.js | Removed file (functionality moved to extpost) |
| src/coreclr/hosts/corerun/wasm/libCorerun.extpost.js | New file implementing corerun initialization as ES6 module |
| src/coreclr/hosts/corerun/CMakeLists.txt | Switches from pre-js to extern-post-js and uses CMAKE variables for exports |
| eng/native.wasm.targets | New file consolidating WASM/browser build configuration and Emscripten export generation |
| eng/native.props | Removed file (moved to native.wasm.targets) |
This was referenced Nov 8, 2025
maraf
reviewed
Nov 10, 2025
Co-authored-by: Marek Fišera <[email protected]>
maraf
approved these changes
Nov 11, 2025
Member
|
/ba-g Failures are unrelated |
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
eng\native.propstoeng\native.wasm.targetsand addGenerateEmccExportstargetGenerateEmccExportsthe target to calculateEmccExportedRuntimeMethodandEmccExportedFunctionCMAKE_EMCC_EXPORTED_RUNTIME_METHODSandCMAKE_EMCC_EXPORTED_FUNCTIONSTargetotherwise MSBuild doesn't respectItemGroup/PropertyGrouporderCMAKE_EMCC_EXPORTED_RUNTIME_METHODSandCMAKE_EMCC_EXPORTED_FUNCTIONSin corerun and browserhostcorerun.jsglobalThislibCorerun.pre.jstolibCorerun.extpost.jsthis changes howselfRunworks for corerun-sNODERAWFS=1- this also fixes$PATHemscripten moduleCallFunc_I32_I32_IND_RetVoidinwasm\callhelpers.cppdotnet.diagnostics.jspinvoke_overridenamesfetchVfs,installVfsFilenode dotnet.js hello.dllshould behave same asdotnet hello.dlldotnet.boot.jsmanifest - self-configure infindResourcesisNodeHostedselfHostNodeJS/managedPromiseCompletionSourceand export more helpers to cross-module exchangeRuntimeListso thatglobalThis.getDotnetRuntime(0)works also for corerunSystemJS_ConsoleClearGetDotNetRuntimeContractDescriptorviaglobalThis.getDotnetRuntime(0).INTERNAL.GetDotNetRuntimeContractDescriptor()GetDotNetRuntimeHeapviaglobalThis.getDotnetRuntime(0).INTERNAL.GetDotNetRuntimeHeap(ptr, length)Module.HEAPU8