Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/pipelines/common/templates/wasm-runtime-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
testRunNamePrefixSuffix: Mono_$(_BuildConfig)
testBuildArgs: /p:InstallV8ForTests=false
# Build the runtime tests for browser, but don't send them to Helix to run on V8: the
# V8 baked into the helix-webassembly container doesn't support --experimental-wasm-exnref
# V8 baked into the helix-webassembly container doesn't support exnref
# yet, so the tests abort at startup. Re-enable the run once the new V8 image is
Comment thread
pavelsavara marked this conversation as resolved.
# available. See ActiveIssue https://github.com/dotnet/runtime/issues/129849
sendToHelix: false
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/performance/runtime-wasm-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
trigger: none

# Disabled: the perf wasm v8 job installs V8 via jsvu, and the V8 binary it currently
# installs does not support --experimental-wasm-exnref yet, so the MicroBenchmarks Helix
# installs does not support exnref yet, so the MicroBenchmarks Helix
# job aborts at startup. Re-enable once an exnref-capable V8 is pinned. See
# ActiveIssue https://github.com/dotnet/runtime/issues/129849
pr: none
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/runtime-linker-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ extends:
- template: /eng/pipelines/libraries/execute-trimming-tests-steps.yml
parameters:
# Publish the trimmed browser apps, but don't run them on V8: the V8 baked into
# the helix-webassembly container doesn't support --experimental-wasm-exnref yet,
# the helix-webassembly container doesn't support exnref yet,
# so run-v8.sh aborts at startup. SkipTrimmingTestsRun keeps the build/publish
# coverage and only skips ExecuteApplications. Re-enable the run once the new V8
# image is available. See
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/build/BrowserWasmApp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@

<WriteLinesToFile
File="$(WasmRunV8ScriptPath)"
Lines="$(V8ScriptShebang);v8 --experimental-wasm-exnref $(_WasmMainJSFileName) -- ${RUNTIME_ARGS} --run $(WasmMainAssemblyFileName) $*"
Lines="$(V8ScriptShebang);v8 $(_WasmMainJSFileName) -- ${RUNTIME_ARGS} --run $(WasmMainAssemblyFileName) $*"
Overwrite="true">
Comment thread
pavelsavara marked this conversation as resolved.
</WriteLinesToFile>

Expand Down
16 changes: 16 additions & 0 deletions src/mono/browser/runtime/loader/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ export function verifyEnvironment () {
}

export async function detect_features_and_polyfill (module: DotnetModuleInternal): Promise<void> {
if (ENVIRONMENT_IS_SHELL) {
if (typeof globalThis.atob !== "function") {
const b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
globalThis.atob = (input) => {
const str = String(input).replace(/=+$/, "");
let output = "";
for (let bc = 0, bs = 0, i = 0; i < str.length; i++) {
const c = b64.indexOf(str.charAt(i));
if (c === -1) continue;
bs = bc % 4 ? bs * 64 + c : c;
if (bc++ % 4) output += String.fromCharCode(255 & (bs >> ((-2 * bc) & 6)));
}
return output;
};
}
}
if (ENVIRONMENT_IS_NODE) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<WasmGenerateRunV8Script>true</WasmGenerateRunV8Script>

<GenerateRunScriptForSample Condition="'$(ArchiveTests)' == 'true'">true</GenerateRunScriptForSample>
<RunScriptCommand>$(ExecXHarnessVar) wasm test --app=. --engine=V8 --engine-arg=--stack-trace-limit=1000 --engine-arg=--experimental-wasm-exnref --js-file=main.mjs --output-directory=$(XHarnessOutputVar)</RunScriptCommand>
<RunScriptCommand>$(ExecXHarnessVar) wasm test --app=. --engine=V8 --engine-arg=--stack-trace-limit=1000 --js-file=main.mjs --output-directory=$(XHarnessOutputVar)</RunScriptCommand>
</PropertyGroup>

<Target Name="RunSample" DependsOnTargets="RunSampleWithV8" />
Expand Down
6 changes: 3 additions & 3 deletions src/mono/sample/wasm/wasm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ run-browser:
fi

run-console:
cd bin/$(CONFIG)/wwwroot && $(V8_PATH) --stack-trace-limit=1000 --experimental-wasm-exnref --single-threaded $(MAIN_JS) -- $(ARGS)
cd bin/$(CONFIG)/wwwroot && $(V8_PATH) --stack-trace-limit=1000 --single-threaded $(MAIN_JS) -- $(ARGS)

run-console-node:
cd bin/$(CONFIG)/wwwroot && node --stack-trace-limit=1000 --experimental-wasm-exnref --single-threaded $(MAIN_JS) $(ARGS)
cd bin/$(CONFIG)/wwwroot && node --stack-trace-limit=1000 --single-threaded $(MAIN_JS) $(ARGS)

debug-console-node:
cd bin/$(CONFIG)/wwwroot && node --inspect=9222 --stack-trace-limit=1000 --experimental-wasm-exnref --single-threaded $(MAIN_JS) $(ARGS)
cd bin/$(CONFIG)/wwwroot && node --inspect=9222 --stack-trace-limit=1000 --single-threaded $(MAIN_JS) $(ARGS)
4 changes: 2 additions & 2 deletions src/native/libs/Common/JavaScript/loader/dotnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
import type { DotnetHostBuilder } from "./types";

import { HostBuilder } from "./host-builder";
import { initPolyfillsAsync } from "./polyfills";
import { initPolyfillsEarly } from "./polyfills";
import { exit } from "./exit";
import { dotnetInitializeModule } from ".";

dotnetInitializeModule();
await initPolyfillsAsync();
await initPolyfillsEarly();

export const dotnet: DotnetHostBuilder | undefined = new HostBuilder() as DotnetHostBuilder;
export { exit };
Expand Down
22 changes: 19 additions & 3 deletions src/native/libs/Common/JavaScript/loader/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.

import { dotnetAssert } from "./cross-module";
import { ENVIRONMENT_IS_NODE } from "./per-module";
import { ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_SHELL } from "./per-module";

let hasFetch = false;

export async function initPolyfills(): Promise<void> {
export async function initPolyfillsLoader(): Promise<void> {
if (ENVIRONMENT_IS_NODE) {
await nodeFs();
await nodeUrl();
Expand All @@ -17,7 +17,23 @@ export async function initPolyfills(): Promise<void> {
}
}

export async function initPolyfillsAsync(): Promise<void> {
export async function initPolyfillsEarly(): Promise<void> {
if (ENVIRONMENT_IS_SHELL) {
if (typeof globalThis.atob !== "function") {
const b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
globalThis.atob = (input) => {
const str = String(input).replace(/=+$/, "");
let output = "";
for (let bc = 0, bs = 0, i = 0; i < str.length; i++) {
const c = b64.indexOf(str.charAt(i));
if (c === -1) continue;
bs = bc % 4 ? bs * 64 + c : c;
if (bc++ % 4) output += String.fromCharCode(255 & (bs >> ((-2 * bc) & 6)));
}
return output;
};
}
}
if (ENVIRONMENT_IS_NODE) {
if (!globalThis.crypto) {
globalThis.crypto = <any>{};
Expand Down
4 changes: 2 additions & 2 deletions src/native/libs/Common/JavaScript/loader/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { createPromiseCompletionSource } from "./promise-completion-source";
import { getIcuResourceName } from "./icu";
import { loaderConfig, validateLoaderConfig } from "./config";
import { fetchAssembly, fetchIcu, fetchNativeSymbols, fetchPdb, fetchSatelliteAssemblies, fetchVfs, fetchMainWasm, loadDotnetModule, loadJSModule, nativeModulePromiseController, verifyAllAssetsDownloaded, callLibraryInitializerOnRuntimeReady, callLibraryInitializerOnRuntimeConfigLoaded, prefetchAllResources, prefetchJSModuleLinks, resolveAllDownloadsQueued } from "./assets";
import { initPolyfills } from "./polyfills";
import { initPolyfillsLoader } from "./polyfills";
import { validateEngineFeatures } from "./bootstrap";

const runMainPromiseController = createPromiseCompletionSource<number>();
Expand Down Expand Up @@ -90,7 +90,7 @@ export async function createRuntime(downloadOnly: boolean, httpCacheOnly: boolea
}

// after onConfigLoaded hooks that could install polyfills, our polyfills can be initialized
await initPolyfills();
await initPolyfillsLoader();

configInitialized = true;
modulesAfterConfigLoadedCache = modulesAfterConfigLoadedPromises;
Expand Down
Loading