Skip to content

Commit

Permalink
[browser] es6 test main (#85542)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelsavara authored May 3, 2023
1 parent 6a5a704 commit bda61b9
Show file tree
Hide file tree
Showing 19 changed files with 301 additions and 226 deletions.
14 changes: 10 additions & 4 deletions eng/testing/WasmRunnerAOTTemplate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ if [[ -z "$XHARNESS_COMMAND" ]]; then
fi

if [[ "$XHARNESS_COMMAND" == "test" ]]; then
if [[ -z "$JS_ENGINE_ARGS" ]]; then
JS_ENGINE_ARGS="--engine-arg=--stack-trace-limit=1000 --engine-arg=--experimental-wasm-eh"
fi

if [[ -z "$JS_ENGINE" ]]; then
if [[ "$SCENARIO" == "WasmTestOnNodeJS" || "$SCENARIO" == "wasmtestonnodejs" ]]; then
JS_ENGINE="--engine=NodeJS"
Expand All @@ -46,6 +42,16 @@ if [[ "$XHARNESS_COMMAND" == "test" ]]; then
fi
fi

if [[ -z "$JS_ENGINE_ARGS" ]]; then
JS_ENGINE_ARGS="--engine-arg=--stack-trace-limit=1000"
if [[ "$SCENARIO" != "WasmTestOnNodeJS" && "$SCENARIO" != "wasmtestonnodejs" ]]; then
JS_ENGINE_ARGS="$JS_ENGINE_ARGS --engine-arg=--module"
fi
if [[ "$SCENARIO" == "WasmTestOnNodeJS" || "$SCENARIO" == "wasmtestonnodejs" ]]; then
JS_ENGINE_ARGS="$JS_ENGINE_ARGS --engine-arg=--experimental-wasm-eh"
fi
fi

if [[ -z "$MAIN_JS" ]]; then
MAIN_JS="--js-file=test-main.js"
fi
Expand Down
8 changes: 7 additions & 1 deletion eng/testing/WasmRunnerTemplate.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ if /I [%XHARNESS_COMMAND%] == [test] (
)

if [%JS_ENGINE_ARGS%] == [] (
set "JS_ENGINE_ARGS=--engine-arg^=--stack-trace-limit^=1000 --engine-arg^=--experimental-wasm-eh"
set "JS_ENGINE_ARGS=--engine-arg^=--stack-trace-limit^=1000"
if /I NOT [%SCENARIO%] == [WasmTestOnNodeJS] (
set "JS_ENGINE_ARGS=%JS_ENGINE_ARGS% --engine-arg^=--module"
)
if /I [%SCENARIO%] == [WasmTestOnNodeJS] (
set "JS_ENGINE_ARGS=%JS_ENGINE_ARGS% --engine-arg^=--experimental-wasm-eh"
)
)
) else (
if [%BROWSER_PATH%] == [] if not [%HELIX_CORRELATION_PAYLOAD%] == [] (
Expand Down
8 changes: 7 additions & 1 deletion eng/testing/WasmRunnerTemplate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ if [[ "$XHARNESS_COMMAND" == "test" ]]; then
fi

if [[ -z "$JS_ENGINE_ARGS" ]]; then
JS_ENGINE_ARGS="--engine-arg=--stack-trace-limit=1000 --engine-arg=--experimental-wasm-eh"
JS_ENGINE_ARGS="--engine-arg=--stack-trace-limit=1000"
if [[ "$SCENARIO" != "WasmTestOnNodeJS" && "$SCENARIO" != "wasmtestonnodejs" ]]; then
JS_ENGINE_ARGS="$JS_ENGINE_ARGS --engine-arg=--module"
fi
if [[ "$SCENARIO" == "WasmTestOnNodeJS" || "$SCENARIO" == "wasmtestonnodejs" ]]; then
JS_ENGINE_ARGS="$JS_ENGINE_ARGS --engine-arg=--experimental-wasm-eh"
fi
fi
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,10 @@ public void JsExportCatchStack()
{
var stack = JavaScriptTestHelper.catch1stack("-t-e-s-t-", nameof(JavaScriptTestHelper.ThrowFromJSExport));
Assert.Contains(nameof(JavaScriptTestHelper.ThrowFromJSExport), stack);
Assert.Contains("catch1stack", stack);
if (PlatformDetection.IsBrowserDomSupportedOrNodeJS)
{
Assert.Contains("catch1stack", stack);
}
}

#endregion Exception
Expand Down
2 changes: 1 addition & 1 deletion src/mono/sample/wasm/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
</PropertyGroup>
</Target>
<Target Name="RunSampleWithV8" DependsOnTargets="BuildSampleInTree;_ComputeMainJSFileName">
<Exec WorkingDirectory="bin/$(Configuration)/AppBundle" Command="v8 --expose_wasm $(_WasmMainJSFileName) -- $(DOTNET_MONO_LOG_LEVEL) --run $(_SampleAssembly) $(Args)" IgnoreExitCode="true" />
<Exec WorkingDirectory="bin/$(Configuration)/AppBundle" Command="v8 --expose_wasm --module $(_WasmMainJSFileName) -- $(DOTNET_MONO_LOG_LEVEL) --run $(_SampleAssembly) $(Args)" IgnoreExitCode="true" />
</Target>
<Target Name="RunSampleWithNode" DependsOnTargets="BuildSampleInTree;_ComputeMainJSFileName">
<Exec WorkingDirectory="bin/$(Configuration)/AppBundle" Command="node --expose_wasm $(_WasmMainJSFileName) -- $(DOTNET_MONO_LOG_LEVEL) --run $(_SampleAssembly) $(Args)" IgnoreExitCode="true" />
Expand Down
2 changes: 1 addition & 1 deletion src/mono/sample/wasm/console-node/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { dotnet } from './dotnet.js'

dotnet
await dotnet
.withDiagnosticTracing(false)
.withApplicationArguments("dotnet", "is", "great!")
.run()
2 changes: 1 addition & 1 deletion src/mono/sample/wasm/console-v8/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { dotnet } from './dotnet.js'

dotnet
await dotnet
.withDiagnosticTracing(false)
.withApplicationArguments(...arguments)
.run()
2 changes: 1 addition & 1 deletion src/mono/sample/wasm/wasm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ run-browser:
fi

run-console:
cd bin/$(CONFIG)/AppBundle && $(V8_PATH) --stack-trace-limit=1000 --single-threaded --expose_wasm $(MAIN_JS) -- $(ARGS)
cd bin/$(CONFIG)/AppBundle && $(V8_PATH) --stack-trace-limit=1000 --single-threaded --expose_wasm --module $(MAIN_JS) -- $(ARGS)

run-console-node:
cd bin/$(CONFIG)/AppBundle && node --stack-trace-limit=1000 --single-threaded --expose_wasm $(MAIN_JS) $(ARGS)
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/build/WasmApp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@
<Error Condition="'$(WasmMainAssemblyFileName)' == ''" Text="%24(WasmMainAssemblyFileName) property needs to be set for generating $(WasmRunV8ScriptPath)." />
<WriteLinesToFile
File="$(WasmRunV8ScriptPath)"
Lines="v8 --expose_wasm $(_WasmMainJSFileName) -- ${RUNTIME_ARGS} --run $(WasmMainAssemblyFileName) $*"
Lines="v8 --expose_wasm --module $(_WasmMainJSFileName) -- ${RUNTIME_ARGS} --run $(WasmMainAssemblyFileName) $*"
Overwrite="true">
</WriteLinesToFile>

Expand Down
12 changes: 9 additions & 3 deletions src/mono/wasm/runtime/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,15 @@ export async function instantiate_wasm_asset(
}
const arrayBuffer = await response.arrayBuffer();
if (runtimeHelpers.diagnosticTracing) console.debug("MONO_WASM: instantiate_wasm_module buffered");
const arrayBufferResult = await WebAssembly.instantiate(arrayBuffer, wasmModuleImports!);
compiledInstance = arrayBufferResult.instance;
compiledModule = arrayBufferResult.module;
if (ENVIRONMENT_IS_SHELL) {
// workaround for old versions of V8 with https://bugs.chromium.org/p/v8/issues/detail?id=13823
compiledModule = new WebAssembly.Module(arrayBuffer);
compiledInstance = new WebAssembly.Instance(compiledModule, wasmModuleImports);
} else {
const arrayBufferResult = await WebAssembly.instantiate(arrayBuffer, wasmModuleImports!);
compiledInstance = arrayBufferResult.instance;
compiledModule = arrayBufferResult.module;
}
}
successCallback(compiledInstance, compiledModule);
}
Expand Down
3 changes: 3 additions & 0 deletions src/mono/wasm/runtime/jiterpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,9 @@ export function mono_interp_tier_prepare_jiterpreter(
}

export function jiterpreter_dump_stats(b?: boolean, concise?: boolean) {
if (!runtimeHelpers.runtimeReady) {
return;
}
if (!mostRecentOptions || (b !== undefined))
mostRecentOptions = getOptions();

Expand Down
Loading

0 comments on commit bda61b9

Please sign in to comment.