Skip to content

[browser][coreCLR] adopt new API for async main#124909

Draft
pavelsavara wants to merge 3 commits intodotnet:mainfrom
pavelsavara:browser_async_main_cleanup
Draft

[browser][coreCLR] adopt new API for async main#124909
pavelsavara wants to merge 3 commits intodotnet:mainfrom
pavelsavara:browser_async_main_cleanup

Conversation

@pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented Feb 26, 2026

Fixes #121064

removes temporary code handling the async managed Main()

@pavelsavara pavelsavara added this to the 11.0.0 milestone Feb 26, 2026
@pavelsavara pavelsavara self-assigned this Feb 26, 2026
@pavelsavara pavelsavara added the arch-wasm WebAssembly architecture label Feb 26, 2026
Copilot AI review requested due to automatic review settings February 26, 2026 17:42
@pavelsavara pavelsavara added area-Host os-browser Browser variant of arch-wasm labels Feb 26, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @agocke, @jeffschwMSFT, @elinor-fung
See info in area-owners.md if you want to be subscribed.

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 pull request removes temporary async Main handling code in favor of adopting a new compiler-generated API pattern for async entry points. The changes enable asyncV2 support for browser/CoreCLR configurations by implementing a flag-based mechanism to distinguish between synchronous and asynchronous Main methods, rather than using metadata-based lookup of compiler-generated wrapper methods.

Changes:

  • Introduces SystemJS_MarkAsyncMain() API to mark when an async Main is executing, setting a flag that causes the first SystemJS_ResolveMainPromise call to be ignored until the actual async result is available
  • Removes temporary validation and lookup code in CoreCLR that attempted to find the original async Main method by name pattern matching
  • Enables browser platform for runtime-async feature in test configuration

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/native/libs/System.Native.Browser/native/main.ts Adds SystemJS_MarkAsyncMain() function and logic to ignore first promise resolution for async mains
src/native/libs/System.Native.Browser/native/index.ts Exports the new SystemJS_MarkAsyncMain function
src/native/libs/Common/JavaScript/types/ems-ambient.ts Adds isAsyncMain boolean flag to DOTNET ambient type
src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncHelpers.Browser.cs Calls SystemJS_MarkAsyncMain() at the start of both HandleAsyncEntryPoint overloads via new P/Invoke declaration
src/coreclr/vm/wasm/entrypoints.h Declares external SystemJS_MarkAsyncMain() function for browser target
src/coreclr/vm/qcallentrypoints.cpp Registers SystemJS_MarkAsyncMain as a QCall entry point
src/coreclr/vm/corelib.h Removes temporary HANDLE_ASYNC_ENTRYPOINT method definitions that were used for lookup-based approach
src/coreclr/vm/assembly.cpp Removes temporary async Main validation, lookup, and invocation code; simplifies to single SystemJS_ResolveMainPromise call for all mains
eng/testing/tests.targets Removes browser exclusion from runtime-async feature enablement condition

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.

[browser][coreCLR] adopt new API for async main and enable asyncV2

2 participants