Skip to content
Merged
3 changes: 2 additions & 1 deletion docs/workflow/building/coreclr/wasm.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ In config below please replace `/path/to/runtime/` by a **absolute unix path** t
"<node_internals>/**"
],
"runtimeArgs": [
"--stack-trace-limit=1000"
"--stack-trace-limit=10000",
"--experimental-wasm-exnref"
],
"args": [
"HelloWorld.dll"
Expand Down
11 changes: 11 additions & 0 deletions eng/native.wasm.targets
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@
<Target Name="GenerateEmccExports" Condition="'$(TargetsBrowser)' == 'true'">
<ItemGroup>
<EmccExportedRuntimeMethod Include="FS" />
<EmccExportedRuntimeMethod Include="HEAP8" />
<EmccExportedRuntimeMethod Include="HEAP16" />
<EmccExportedRuntimeMethod Include="HEAPU8" />
<EmccExportedRuntimeMethod Include="HEAPU16" />
<EmccExportedRuntimeMethod Include="HEAP32" />
<EmccExportedRuntimeMethod Include="HEAPU32" />
<EmccExportedRuntimeMethod Include="HEAPF32" />
<EmccExportedRuntimeMethod Include="HEAPF64" />
<!-- HEAP64+HEAPU64 are removed for corerun under NodeJS -->
<EmccExportedRuntimeMethod Include="HEAP64" />
<EmccExportedRuntimeMethod Include="HEAPU64" />
Comment thread
pavelsavara marked this conversation as resolved.
<EmccExportedRuntimeMethod Include="out" />
<EmccExportedRuntimeMethod Include="err" />
<EmccExportedRuntimeMethod Include="ccall" />
Expand Down
8 changes: 4 additions & 4 deletions eng/testing/BrowserVersions.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<win_ChromeRevision>1625079</win_ChromeRevision>
<win_ChromeBaseSnapshotUrl>https://storage.googleapis.com/chromium-browser-snapshots/Win_x64/1625123</win_ChromeBaseSnapshotUrl>
<win_V8Version>14.9.207</win_V8Version>
<linux_FirefoxRevision>125.0.1</linux_FirefoxRevision>
<linux_GeckoDriverRevision>0.34.0</linux_GeckoDriverRevision>
<win_FirefoxRevision>125.0.1</win_FirefoxRevision>
<win_GeckoDriverRevision>0.34.0</win_GeckoDriverRevision>
<linux_FirefoxRevision>140.11.0esr</linux_FirefoxRevision>
<linux_GeckoDriverRevision>0.37.0</linux_GeckoDriverRevision>
<win_FirefoxRevision>140.11.0esr</win_FirefoxRevision>
<win_GeckoDriverRevision>0.37.0</win_GeckoDriverRevision>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion eng/testing/wasm-provisioning.targets
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<GeckoDriverDir>$(ArtifactsBinDir)geckodriver\</GeckoDriverDir>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('linux'))">
<FirefoxUrl>https://ftp.mozilla.org/pub/firefox/releases/$(linux_FirefoxRevision)/linux-x86_64/en-US/firefox-$(linux_FirefoxRevision).tar.bz2</FirefoxUrl>
<FirefoxUrl>https://ftp.mozilla.org/pub/firefox/releases/$(linux_FirefoxRevision)/linux-x86_64/en-US/firefox-$(linux_FirefoxRevision).tar.xz</FirefoxUrl>
<GeckoDriverUrl>https://github.com/mozilla/geckodriver/releases/download/v$(linux_GeckoDriverRevision)/geckodriver-v$(linux_GeckoDriverRevision)-linux64.tar.gz</GeckoDriverUrl>
<FirefoxBinaryName>firefox</FirefoxBinaryName>
<GeckoDriverBinaryName>geckodriver</GeckoDriverBinaryName>
Expand Down
39 changes: 18 additions & 21 deletions src/coreclr/hosts/corerun/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,24 @@ else()
LINK_DEPENDS "${JS_CORE_RUN};${JS_CORE_RUN_EXTPOST};${JS_SYSTEM_NATIVE_BROWSER};${JS_SYSTEM_BROWSER_UTILS};"
LINK_FLAGS "--js-library ${JS_SYSTEM_NATIVE_BROWSER} --js-library ${JS_SYSTEM_BROWSER_UTILS} --js-library ${JS_CORE_RUN} --extern-post-js ${JS_CORE_RUN_EXTPOST}"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
if (CORERUN_IN_BROWSER)
target_link_options(corerun PRIVATE -sWASM_BIGINT=1)
# Include the virtual file system data for the browser scenario.
set(WASM_PRELOAD_DIR "${CMAKE_INSTALL_PREFIX}/IL")
if (EXISTS "${WASM_PRELOAD_DIR}")
target_link_options(corerun PRIVATE --preload-file ${WASM_PRELOAD_DIR}@/)
endif()
else()
# Node.js doesn't have good support for WASM_BIGINT, so disable it for the Node/shell.
target_link_options(corerun PRIVATE -sWASM_BIGINT=0)

# remove HEAP64 and HEAPU64 from CMAKE_EMCC_EXPORTED_RUNTIME_METHODS
string(REPLACE "HEAP64," "" CMAKE_EMCC_EXPORTED_RUNTIME_METHODS "${CMAKE_EMCC_EXPORTED_RUNTIME_METHODS}")
string(REPLACE "HEAPU64," "" CMAKE_EMCC_EXPORTED_RUNTIME_METHODS "${CMAKE_EMCC_EXPORTED_RUNTIME_METHODS}")
Comment thread
pavelsavara marked this conversation as resolved.

# Add Node.js host file system support.
target_link_options(corerun PRIVATE -sNODERAWFS=1 -lnodefs.js)
endif()
target_link_options(corerun PRIVATE
-sINITIAL_MEMORY=134217728
-sMAXIMUM_MEMORY=4294967296
Expand All @@ -96,27 +114,6 @@ else()
-Wl,--export=__stack_pointer
-Wl,--export=__coreclr_wasm_rtlrestorecontext_tag
-Wl,--error-limit=0)

if (CORERUN_IN_BROWSER)
# Node.js doesn't have good support for WASM_BIGINT
# so it only is added when running in the browser.
target_link_options(corerun PRIVATE
-sWASM_BIGINT=1)

# Include the virtual file system data for the
# browser scenario.
set(WASM_PRELOAD_DIR "${CMAKE_INSTALL_PREFIX}/IL")
if (EXISTS "${WASM_PRELOAD_DIR}")
target_link_options(corerun PRIVATE
--preload-file ${WASM_PRELOAD_DIR}@/)
endif()
else()
# If not running in the browser, add
# Node.js file system support.
target_link_options(corerun PRIVATE
-sNODERAWFS=1
-lnodefs.js)
endif()
endif()

if (CORERUN_IN_BROWSER)
Expand Down
1 change: 1 addition & 0 deletions src/mono/browser/runtime/diagnostics/dotnet-gcdump.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function collectGcDump (options?:DiagnosticCommandOptions):Promise<Uint8A
// stop 500ms after last GC message on this session, there will be more messages after that
if (stopDelayedAfterLastMessage) {
clearTimeout(stopDelayedAfterLastMessage);
Module.runtimeKeepalivePop();
}
Comment thread
pavelsavara marked this conversation as resolved.
stopDelayedAfterLastMessage = Module.safeSetTimeout(() => {
stopSent = true;
Expand Down
1 change: 1 addition & 0 deletions src/mono/browser/runtime/loader/exit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ function set_exit_code_and_quit_now (exit_code: number, reason?: any): void {
}

async function flush_node_streams () {
if (!ENVIRONMENT_IS_NODE) return;
try {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore:
Expand Down
3 changes: 2 additions & 1 deletion src/mono/browser/runtime/scheduling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,19 @@ export function SystemJS_ScheduleTimerImpl (shortestDueTimeMs: number): void {
if (lastScheduledTimeoutId) {
globalThis.clearTimeout(lastScheduledTimeoutId);
lastScheduledTimeoutId = undefined;
Module.runtimeKeepalivePop();
}
Comment thread
pavelsavara marked this conversation as resolved.
lastScheduledTimeoutId = Module.safeSetTimeout(mono_wasm_schedule_timer_tick, shortestDueTimeMs);
}

function mono_wasm_schedule_timer_tick () {
if (WasmEnableThreads) return;
lastScheduledTimeoutId = undefined;
Module.maybeExit();
forceThreadMemoryViewRefresh();
if (!loaderHelpers.is_runtime_running()) {
return;
}
lastScheduledTimeoutId = undefined;
try {
cwraps.mono_wasm_execute_timer();
} catch (ex) {
Expand Down
6 changes: 5 additions & 1 deletion src/mono/browser/runtime/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ async function preRunAsync (userPreRun: ((module:EmscriptenModule) => void)[]) {
}

async function onRuntimeInitializedAsync (userOnRuntimeInitialized: (module:EmscriptenModule) => void) {
let keepAlivePushed = false;
try {
// wait for previous stage
await runtimeHelpers.afterPreRun.promise;
Expand Down Expand Up @@ -227,7 +228,10 @@ async function onRuntimeInitializedAsync (userOnRuntimeInitialized: (module:Emsc
setTimeout(maybeSaveInterpPgoTable, (runtimeHelpers.config.interpreterPgoSaveDelay || 15) * 1000);


// this push is unbalanced for short while until runtimeReady = true. Accepted trade-off.
Module.runtimeKeepalivePush();
keepAlivePushed = true;

if (WasmEnableThreads && BuildConfiguration === "Debug" && globalThis.setInterval) globalThis.setInterval(() => {
mono_log_info("UI thread is alive!");
}, 3000);
Expand Down Expand Up @@ -291,7 +295,7 @@ async function onRuntimeInitializedAsync (userOnRuntimeInitialized: (module:Emsc
await mono_wasm_after_user_runtime_initialized();
endMeasure(mark, MeasuredBlock.onRuntimeInitialized);
} catch (err) {
Module.runtimeKeepalivePop();
if (keepAlivePushed && !runtimeHelpers.runtimeReady) Module.runtimeKeepalivePop();
mono_log_error("onRuntimeInitializedAsync() failed", err);
loaderHelpers.mono_exit(1, err);
throw err;
Comment thread
pavelsavara marked this conversation as resolved.
Expand Down
Loading