Skip to content

Conversation

@pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented Nov 3, 2025

  • rename eng\native.props to eng\native.wasm.targets and add GenerateEmccExports target
    • use GenerateEmccExports the target to calculate EmccExportedRuntimeMethod and EmccExportedFunction
    • to configure CMAKE_EMCC_EXPORTED_RUNTIME_METHODS and CMAKE_EMCC_EXPORTED_FUNCTIONS
    • this needs to be Target otherwise MSBuild doesn't respect ItemGroup/PropertyGroup order
  • use CMAKE_EMCC_EXPORTED_RUNTIME_METHODS and CMAKE_EMCC_EXPORTED_FUNCTIONS in corerun and browserhost
    • later we could also use it to create .rsp file for workload re-link
  • ES6/harmony modularize corerun.js
    • so that it's guts don't leak to globalThis
    • rename libCorerun.pre.js to libCorerun.extpost.js this changes how selfRun works for corerun
    • use -sNODERAWFS=1 - this also fixes $PATH emscripten module
  • implement CallFunc_I32_I32_IND_RetVoid in wasm\callhelpers.cpp
  • produce dummy/empty dotnet.diagnostics.js
  • fix pinvoke_override names
  • fix dealing with pointers bigger than 2GB (negative offset to WASM linear memory)
  • implement VFS files loading fetchVfs, installVfsFile
  • make browserhost to detect that it's running from NodeJS directly
    • node dotnet.js hello.dll should behave same as dotnet hello.dll
    • this should work even without dotnet.boot.js manifest - self-configure in findResources
    • detect via isNodeHosted
    • self-start in selfHostNodeJS
    • mount host current directory into VFS /managed
  • camelCase fixes
  • move WeakRef polyfill
  • rename PromiseCompletionSource and export more helpers to cross-module exchange
  • move and fix RuntimeList so that globalThis.getDotnetRuntime(0) works also for corerun
  • implement SystemJS_ConsoleClear
  • expose GetDotNetRuntimeContractDescriptor via globalThis.getDotnetRuntime(0).INTERNAL.GetDotNetRuntimeContractDescriptor()
  • expose GetDotNetRuntimeHeap via globalThis.getDotnetRuntime(0).INTERNAL.GetDotNetRuntimeHeap(ptr, length)
    • this returns unsigned Module.HEAPU8

@pavelsavara pavelsavara added this to the 11.0.0 milestone Nov 3, 2025
@pavelsavara pavelsavara self-assigned this Nov 3, 2025
@pavelsavara pavelsavara added arch-wasm WebAssembly architecture area-Host os-browser Browser variant of arch-wasm labels Nov 3, 2025
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov
See info in area-owners.md if you want to be subscribed.

@pavelsavara pavelsavara force-pushed the browser_modularize_corerun branch from 7501a3b to e993dc3 Compare November 7, 2025 19:06
@pavelsavara pavelsavara removed the NO-REVIEW Experimental/testing PR, do NOT review it label Nov 7, 2025
@pavelsavara pavelsavara marked this pull request as ready for review November 7, 2025 19:37
Copilot AI review requested due to automatic review settings November 7, 2025 19:37
Copy link
Contributor

Copilot AI left a 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 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.js module infrastructure with rollup configuration
  • Refactors promise-related APIs from PromiseController to PromiseCompletionSource across the codebase
  • Consolidates Emscripten export definitions into a centralized GenerateEmccExports target in native.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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-Host os-browser Browser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant