From 47be1e22b58fb3ebf8305bb4740f6a42a1190ae5 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Wed, 18 Jan 2023 19:00:57 +0100 Subject: [PATCH 01/28] [wasm] Enable SIMD --- src/mono/wasm/build/WasmApp.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index e248125876003..48fb2977bbfd2 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -89,7 +89,7 @@ true false - false + true From a0fc3eb5cd14914f07ad76e6e5e195346aa63336 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Wed, 18 Jan 2023 21:24:12 +0100 Subject: [PATCH 02/28] Let old V8 use simd Co-authored-by: Ankit Jain --- eng/testing/WasmRunnerAOTTemplate.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/testing/WasmRunnerAOTTemplate.sh b/eng/testing/WasmRunnerAOTTemplate.sh index e44faf7f8c0aa..f9687d7735655 100644 --- a/eng/testing/WasmRunnerAOTTemplate.sh +++ b/eng/testing/WasmRunnerAOTTemplate.sh @@ -37,6 +37,7 @@ if [[ "$XHARNESS_COMMAND" == "test" ]]; then JS_ENGINE="--engine=NodeJS" else JS_ENGINE="--engine=V8" + JS_ENGINE_ARGS="$JS_ENGINE_ARGS --engine-arg=--experimental-wasm-simd" fi fi From b695c92c0ae9fb8d5ec67b0fdd714eadd4442306 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Thu, 19 Jan 2023 22:55:40 +0000 Subject: [PATCH 03/28] [wasm] ManagedToNativeGenerator: Skip unmanaged dlls .. instead crashing with an exception like: ``` src/mono/wasm/build/WasmApp.Native.targets(296,5): error MSB4018: (NETCORE_ENGINEERING_TELEMETRY=Build) The "ManagedToNativeGenerator" task failed unexpectedly. System.BadImageFormatException: This PE image is not a managed executable. at System.Reflection.MetadataLoadContext.LoadFromStreamCore(Stream peStream) at System.Reflection.MetadataLoadContext.LoadFromAssemblyPath(String assemblyPath) at PInvokeTableGenerator.Generate(String[] pinvokeModules, String[] assemblies, String outputPath) in /_/src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs:line 42 at ManagedToNativeGenerator.ExecuteInternal() in /_/src/tasks/WasmAppBuilder/ManagedToNativeGenerator.cs:line 68 at ManagedToNativeGenerator.Execute() in /_/src/tasks/WasmAppBuilder/ManagedToNativeGenerator.cs:line 53 at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) ``` The wasm targets currently are not able to differentiate the managed assemblies from the unmanaged ones. so it needs to be handled here. --- .../WasmAppBuilder/IcallTableGenerator.cs | 8 ++- .../ManagedToNativeGenerator.cs | 50 +++++++++++++++++-- .../WasmAppBuilder/PInvokeTableGenerator.cs | 8 ++- 3 files changed, 59 insertions(+), 7 deletions(-) diff --git a/src/tasks/WasmAppBuilder/IcallTableGenerator.cs b/src/tasks/WasmAppBuilder/IcallTableGenerator.cs index 9416c71760d0f..f60f84de15672 100644 --- a/src/tasks/WasmAppBuilder/IcallTableGenerator.cs +++ b/src/tasks/WasmAppBuilder/IcallTableGenerator.cs @@ -44,9 +44,13 @@ public IEnumerable Generate(string? runtimeIcallTableFile, string[] asse var resolver = new PathAssemblyResolver(assemblies); using var mlc = new MetadataLoadContext(resolver, "System.Private.CoreLib"); - foreach (var aname in assemblies) + foreach (var asmPath in assemblies) { - var a = mlc.LoadFromAssemblyPath(aname); + if (!File.Exists(asmPath)) + throw new LogAsErrorException($"Cannot find assembly {asmPath}"); + + Log.LogMessage(MessageImportance.Low, $"Loading {asmPath} to scan for icalls"); + var a = mlc.LoadFromAssemblyPath(asmPath); foreach (var type in a.GetTypes()) ProcessType(type); } diff --git a/src/tasks/WasmAppBuilder/ManagedToNativeGenerator.cs b/src/tasks/WasmAppBuilder/ManagedToNativeGenerator.cs index 1dff74a9dcc1c..37d7da99d6bf4 100644 --- a/src/tasks/WasmAppBuilder/ManagedToNativeGenerator.cs +++ b/src/tasks/WasmAppBuilder/ManagedToNativeGenerator.cs @@ -1,9 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.IO; using System.Linq; +using System.Reflection.PortableExecutable; using System.Text; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; @@ -11,7 +14,7 @@ public class ManagedToNativeGenerator : Task { [Required] - public string[]? Assemblies { get; set; } + public string[] Assemblies { get; set; } = Array.Empty(); public string? RuntimeIcallTableFile { get; set; } @@ -62,12 +65,14 @@ public override bool Execute() private void ExecuteInternal() { + string[] managedAssemblies = FilterOutUnmanagedBinaries(Assemblies); + var pinvoke = new PInvokeTableGenerator(FixupSymbolName, Log); var icall = new IcallTableGenerator(FixupSymbolName, Log); IEnumerable cookies = Enumerable.Concat( - pinvoke.Generate(PInvokeModules, Assemblies!, PInvokeOutputPath!), - icall.Generate(RuntimeIcallTableFile, Assemblies!, IcallOutputPath) + pinvoke.Generate(PInvokeModules, managedAssemblies, PInvokeOutputPath!), + icall.Generate(RuntimeIcallTableFile, managedAssemblies, IcallOutputPath) ); var m2n = new InterpToNativeGenerator(Log); @@ -110,4 +115,43 @@ public string FixupSymbolName(string name) _symbolNameFixups[name] = fixedName; return fixedName; } + + private string[] FilterOutUnmanagedBinaries(string[] assemblies) + { + List managedAssemblies = new(assemblies.Length); + foreach (string asmPath in Assemblies) + { + if (!File.Exists(asmPath)) + throw new LogAsErrorException($"Cannot find assembly {asmPath}"); + + try + { + if (!IsManagedAssembly(asmPath)) + { + Log.LogMessage(MessageImportance.Low, $"Skipping unmanaged {asmPath}."); + continue; + } + } + catch (Exception ex) + { + Log.LogMessage(MessageImportance.Low, $"Failed to read assembly {asmPath}: {ex}"); + throw new LogAsErrorException($"Failed to read assembly {asmPath}: {ex.Message}"); + } + + managedAssemblies.Add(asmPath); + } + + return managedAssemblies.ToArray(); + } + + private static bool IsManagedAssembly(string filePath) + { + if (!File.Exists(filePath)) + return false; + + using FileStream fileStream = File.OpenRead(filePath); + using PEReader reader = new(fileStream, PEStreamOptions.Default); + return reader.HasMetadata; + } + } diff --git a/src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs b/src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs index ab4eac397bc9f..389c7f7bd5b3a 100644 --- a/src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs +++ b/src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs @@ -37,9 +37,13 @@ public IEnumerable Generate(string[] pinvokeModules, string[] assemblies var resolver = new PathAssemblyResolver(assemblies); using var mlc = new MetadataLoadContext(resolver, "System.Private.CoreLib"); - foreach (var aname in assemblies) + foreach (var asmPath in assemblies) { - var a = mlc.LoadFromAssemblyPath(aname); + if (!File.Exists(asmPath)) + throw new LogAsErrorException($"Cannot find assembly {asmPath}"); + + Log.LogMessage(MessageImportance.Low, $"Loading {asmPath} to scan for pinvokes"); + var a = mlc.LoadFromAssemblyPath(asmPath); foreach (var type in a.GetTypes()) CollectPInvokes(pinvokes, callbacks, signatures, type); } From cb53bc65956db96dd2731f1fba255cdd7710f503 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Thu, 19 Jan 2023 23:13:06 +0000 Subject: [PATCH 04/28] [wasm] WasmApp.Native.targets: do not trigger relinking when WasmEnableSIMD=true Instead, let the property be effective only for the AOT case. --- src/mono/wasm/build/WasmApp.Native.targets | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/mono/wasm/build/WasmApp.Native.targets b/src/mono/wasm/build/WasmApp.Native.targets index 6f9524e7f7a30..d9edcfd22664c 100644 --- a/src/mono/wasm/build/WasmApp.Native.targets +++ b/src/mono/wasm/build/WasmApp.Native.targets @@ -111,8 +111,6 @@ true - true - true false @@ -123,7 +121,6 @@ true true - true false @@ -201,7 +198,7 @@ <_EmccCommonFlags Include="-v" Condition="'$(EmccVerbose)' != 'false'" /> <_EmccCommonFlags Include="-s DISABLE_EXCEPTION_CATCHING=0" Condition="'$(WasmEnableExceptionHandling)' == 'false'" /> <_EmccCommonFlags Include="-fwasm-exceptions" Condition="'$(WasmEnableExceptionHandling)' == 'true'" /> - <_EmccCommonFlags Include="-msimd128" Condition="'$(WasmEnableSIMD)' == 'true'" /> + <_EmccCommonFlags Include="-msimd128" Condition="'$(WasmEnableSIMD)' == 'true' and '$(_WasmShouldAOT)' == 'true'" /> <_EmccIncludePaths Include="$(_WasmIntermediateOutputPath.TrimEnd('\/'))" /> <_EmccIncludePaths Include="$(_WasmRuntimePackIncludeDir)mono-2.0" /> From 68da732f19ffcfa3745f2d4042c2cc979460133d Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Fri, 20 Jan 2023 00:28:54 +0100 Subject: [PATCH 05/28] Use staging image with newer v8 --- eng/pipelines/libraries/helix-queues-setup.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/libraries/helix-queues-setup.yml b/eng/pipelines/libraries/helix-queues-setup.yml index 734530b9b6889..92aba13db7605 100644 --- a/eng/pipelines/libraries/helix-queues-setup.yml +++ b/eng/pipelines/libraries/helix-queues-setup.yml @@ -193,7 +193,7 @@ jobs: # Browser WebAssembly Firefox - ${{ if eq(parameters.platform, 'browser_wasm_firefox') }}: - - (Ubuntu.1804.Amd64)Ubuntu.1804.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-helix-webassembly + - (Ubuntu.1804.Amd64)Ubuntu.1804.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-helix-webassembly-staging # Browser WebAssembly windows - ${{ if eq(parameters.platform, 'browser_wasm_win') }}: From b2603758b0bb0e29eaa4bab20de400f30ed68042 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 20 Jan 2023 01:03:12 +0000 Subject: [PATCH 06/28] [wasm] WasmAppHost: Add support for host arguments --- src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs | 4 ++-- src/mono/wasm/host/CommonConfiguration.cs | 8 +++++++- src/mono/wasm/host/JSEngineHost.cs | 5 ++--- src/mono/wasm/host/RuntimeConfigJson.cs | 2 ++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs b/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs index 0b4777ae7ac31..dedabf46423f3 100644 --- a/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs +++ b/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs @@ -160,8 +160,8 @@ protected string RunAndTestWasmApp(BuildArgs buildArgs, // Use wasm-console.log to get the xharness output for non-browser cases (string testCommand, string xharnessArgs, bool useWasmConsoleOutput) = host switch { - RunHost.V8 => ("wasm test", $"--js-file={jsRelativePath} --engine=V8 -v trace", true), - RunHost.NodeJS => ("wasm test", $"--js-file={jsRelativePath} --engine=NodeJS -v trace", true), + RunHost.V8 => ("wasm test", $"--js-file={jsRelativePath} --engine=V8 -v trace --engine-arg=--experimental-wasm-simd", true), + RunHost.NodeJS => ("wasm test", $"--js-file={jsRelativePath} --engine=NodeJS -v trace --engine-arg=--experimental-wasm-simd", true), _ => ("wasm test-browser", $"-v trace -b {host} --web-server-use-cop", false) }; diff --git a/src/mono/wasm/host/CommonConfiguration.cs b/src/mono/wasm/host/CommonConfiguration.cs index eb0a0af997d82..7d854cc47141e 100644 --- a/src/mono/wasm/host/CommonConfiguration.cs +++ b/src/mono/wasm/host/CommonConfiguration.cs @@ -22,6 +22,7 @@ internal sealed class CommonConfiguration public WasmHost Host { get; init; } public HostConfig HostConfig { get; init; } public WasmHostProperties HostProperties { get; init; } + public IEnumerable HostArguments { get; init; } private string? hostArg; private string? _runtimeConfigPath; @@ -30,11 +31,13 @@ internal sealed class CommonConfiguration private CommonConfiguration(string[] args) { + List hostArgsList = new(); var options = new OptionSet { { "debug|d", "Start debug server", _ => Debugging = true }, { "host|h=", "Host config name", v => hostArg = v }, - { "runtime-config|r=", "runtimeconfig.json path for the app", v => _runtimeConfigPath = v } + { "runtime-config|r=", "runtimeconfig.json path for the app", v => _runtimeConfigPath = v }, + { "extra-host-arg=", "Extra argument to be passed to the host", hostArgsList.Add }, }; RemainingArgs = options.Parse(args); @@ -95,6 +98,9 @@ private CommonConfiguration(string[] args) if (!Enum.TryParse(HostConfig.HostString, ignoreCase: true, out WasmHost wasmHost)) throw new CommandLineException($"Unknown host {HostConfig.HostString} in config named {HostConfig.Name}"); Host = wasmHost; + + hostArgsList.AddRange(HostConfig.HostArguments); + HostArguments = hostArgsList; } public ProxyOptions ToProxyOptions() diff --git a/src/mono/wasm/host/JSEngineHost.cs b/src/mono/wasm/host/JSEngineHost.cs index fc77d69818a41..cc80f068a18a5 100644 --- a/src/mono/wasm/host/JSEngineHost.cs +++ b/src/mono/wasm/host/JSEngineHost.cs @@ -37,8 +37,6 @@ public static async Task InvokeAsync(CommonConfiguration commonArgs, private async Task RunAsync() { - string[] engineArgs = Array.Empty(); - string engineBinary = _args.Host switch { WasmHost.V8 => "v8", @@ -79,9 +77,10 @@ private async Task RunAsync() args.Add("--expose_wasm"); } + args.AddRange(_args.CommonConfig.HostArguments); + args.Add(_args.JSPath!); - args.AddRange(engineArgs); if (_args.Host is WasmHost.V8 or WasmHost.JavaScriptCore) { // v8/jsc want arguments to the script separated by "--", others don't diff --git a/src/mono/wasm/host/RuntimeConfigJson.cs b/src/mono/wasm/host/RuntimeConfigJson.cs index 3b7b0564c4d09..ed698ed8fb372 100644 --- a/src/mono/wasm/host/RuntimeConfigJson.cs +++ b/src/mono/wasm/host/RuntimeConfigJson.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; @@ -32,6 +33,7 @@ internal sealed record WasmHostProperties( internal sealed record HostConfig(string? Name, [property: JsonPropertyName("host")] string? HostString) { + [property: JsonPropertyName("host-args")] public string[] HostArguments { get; set; } = Array.Empty(); // using an explicit property because the deserializer doesn't like // extension data in the record constructor [property: JsonExtensionData] public Dictionary? Properties { get; set; } From d12ab67842ca21bf973c2c8ca2e9e775422d84ce Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 20 Jan 2023 01:03:52 +0000 Subject: [PATCH 07/28] [wasm] console template: Add --experimental-wasm-simd to node, and remove v8 config as that isn't supported --- .../templates/console/runtimeconfig.template.json | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/mono/wasm/templates/templates/console/runtimeconfig.template.json b/src/mono/wasm/templates/templates/console/runtimeconfig.template.json index 4fac1499aad38..0be5fb5929fcd 100644 --- a/src/mono/wasm/templates/templates/console/runtimeconfig.template.json +++ b/src/mono/wasm/templates/templates/console/runtimeconfig.template.json @@ -4,12 +4,10 @@ { "name": "node", "js-path": "main.mjs", - "Host": "nodejs" - }, - { - "name": "v8", - "js-path": "main.mjs", - "Host": "v8" + "Host": "nodejs", + "host-args": [ + "--experimental-wasm-simd" + ] } ] } From 5f68d508ab7ad83d5942f06c320e651a062dfe31 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 20 Jan 2023 01:13:59 +0000 Subject: [PATCH 08/28] [wasm] Pass --experiment-wasm-simd for aot library tests too --- eng/testing/WasmRunnerAOTTemplate.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/testing/WasmRunnerAOTTemplate.sh b/eng/testing/WasmRunnerAOTTemplate.sh index f9687d7735655..b012eafabdef4 100644 --- a/eng/testing/WasmRunnerAOTTemplate.sh +++ b/eng/testing/WasmRunnerAOTTemplate.sh @@ -35,6 +35,7 @@ if [[ "$XHARNESS_COMMAND" == "test" ]]; then if [[ -z "$JS_ENGINE" ]]; then if [[ "$SCENARIO" == "WasmTestOnNodeJS" || "$SCENARIO" == "wasmtestonnodejs" ]]; then JS_ENGINE="--engine=NodeJS" + JS_ENGINE_ARGS="$JS_ENGINE_ARGS --engine-arg=--experimental-wasm-simd" else JS_ENGINE="--engine=V8" JS_ENGINE_ARGS="$JS_ENGINE_ARGS --engine-arg=--experimental-wasm-simd" From a15b3ef5dcab31b0abe2bc914eee6299df7cf56f Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Fri, 20 Jan 2023 10:25:04 +0100 Subject: [PATCH 09/28] Try to pass full path to v8 Also remove --experimental-wasm-simd option, which shouldn't be needed for newer v8 --- eng/testing/WasmRunnerAOTTemplate.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/eng/testing/WasmRunnerAOTTemplate.sh b/eng/testing/WasmRunnerAOTTemplate.sh index b012eafabdef4..e01ed72c17f02 100644 --- a/eng/testing/WasmRunnerAOTTemplate.sh +++ b/eng/testing/WasmRunnerAOTTemplate.sh @@ -37,8 +37,7 @@ if [[ "$XHARNESS_COMMAND" == "test" ]]; then JS_ENGINE="--engine=NodeJS" JS_ENGINE_ARGS="$JS_ENGINE_ARGS --engine-arg=--experimental-wasm-simd" else - JS_ENGINE="--engine=V8" - JS_ENGINE_ARGS="$JS_ENGINE_ARGS --engine-arg=--experimental-wasm-simd" + JS_ENGINE="--engine=/home/helixbot/.jsvu/bin/v8" fi fi From 033d47310c71f5682afeeedcb83b3353f932cffe Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Fri, 20 Jan 2023 11:50:28 +0100 Subject: [PATCH 10/28] Use docker image for all wasm helix jobs As we need newer v8 --- eng/pipelines/libraries/helix-queues-setup.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/libraries/helix-queues-setup.yml b/eng/pipelines/libraries/helix-queues-setup.yml index 92aba13db7605..c8677da09bc23 100644 --- a/eng/pipelines/libraries/helix-queues-setup.yml +++ b/eng/pipelines/libraries/helix-queues-setup.yml @@ -189,7 +189,7 @@ jobs: # Browser/WASI WebAssembly - ${{ if in(parameters.platform, 'browser_wasm', 'wasi_wasm') }}: - - Ubuntu.1804.Amd64.Open + - (Ubuntu.1804.Amd64)Ubuntu.1804.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-helix-webassembly-staging # Browser WebAssembly Firefox - ${{ if eq(parameters.platform, 'browser_wasm_firefox') }}: From 5dec1aaab403f4cbbd7b0e9f03d965e96efde51c Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Mon, 23 Jan 2023 11:44:30 +0100 Subject: [PATCH 11/28] Set DOTNET_CLI_HOME under workitem payload The correlation payload is read only --- src/libraries/sendtohelixhelp.proj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/sendtohelixhelp.proj b/src/libraries/sendtohelixhelp.proj index 6f0b7704b575f..8d3be7f885546 100644 --- a/src/libraries/sendtohelixhelp.proj +++ b/src/libraries/sendtohelixhelp.proj @@ -125,8 +125,8 @@ - - + + From 80f678a2b706e0cf9a3c4e0126e11dcaeb544aea Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Mon, 23 Jan 2023 15:26:28 +0100 Subject: [PATCH 12/28] Revert "Try to pass full path to v8" This reverts commit a15b3ef5dcab31b0abe2bc914eee6299df7cf56f. --- eng/testing/WasmRunnerAOTTemplate.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eng/testing/WasmRunnerAOTTemplate.sh b/eng/testing/WasmRunnerAOTTemplate.sh index e01ed72c17f02..b012eafabdef4 100644 --- a/eng/testing/WasmRunnerAOTTemplate.sh +++ b/eng/testing/WasmRunnerAOTTemplate.sh @@ -37,7 +37,8 @@ if [[ "$XHARNESS_COMMAND" == "test" ]]; then JS_ENGINE="--engine=NodeJS" JS_ENGINE_ARGS="$JS_ENGINE_ARGS --engine-arg=--experimental-wasm-simd" else - JS_ENGINE="--engine=/home/helixbot/.jsvu/bin/v8" + JS_ENGINE="--engine=V8" + JS_ENGINE_ARGS="$JS_ENGINE_ARGS --engine-arg=--experimental-wasm-simd" fi fi From 7242ab8ff69ac826976de7481eefc872eeda275e Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Mon, 23 Jan 2023 20:15:42 +0100 Subject: [PATCH 13/28] Use DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 Let see whether it will avoid all the writes to correlation payload path --- src/libraries/sendtohelixhelp.proj | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libraries/sendtohelixhelp.proj b/src/libraries/sendtohelixhelp.proj index 8d3be7f885546..0ea6e3e2653ae 100644 --- a/src/libraries/sendtohelixhelp.proj +++ b/src/libraries/sendtohelixhelp.proj @@ -121,6 +121,11 @@ + + + + + From 37080d6d5d32de323498d60b11ee24e873e56a3b Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Mon, 23 Jan 2023 20:22:19 +0100 Subject: [PATCH 14/28] Set NeedsEMSDKNode to false To try if we can use newer node in path --- src/libraries/sendtohelix-wasm.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/sendtohelix-wasm.targets b/src/libraries/sendtohelix-wasm.targets index e1afc40d2cb1f..fb476c39fa1ba 100644 --- a/src/libraries/sendtohelix-wasm.targets +++ b/src/libraries/sendtohelix-wasm.targets @@ -46,7 +46,7 @@ true true - true + false true true From aa544f44fbdc43acf1f9d6a33c49e04a5216c788 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Wed, 25 Jan 2023 11:53:01 +0100 Subject: [PATCH 15/28] Revert "Set DOTNET_CLI_HOME under workitem payload" This reverts commit 5dec1aaab403f4cbbd7b0e9f03d965e96efde51c. --- src/libraries/sendtohelixhelp.proj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/sendtohelixhelp.proj b/src/libraries/sendtohelixhelp.proj index 53c4e32ee1a65..606f2216b1362 100644 --- a/src/libraries/sendtohelixhelp.proj +++ b/src/libraries/sendtohelixhelp.proj @@ -130,8 +130,8 @@ - - + + From dc722683939e12f200bd7e08dbdf521787921258 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Mon, 23 Jan 2023 11:44:30 +0100 Subject: [PATCH 16/28] Set DOTNET_CLI_HOME under workitem payload The correlation payload is read only. And even with `export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1` we have still many failures. --- src/libraries/sendtohelixhelp.proj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/sendtohelixhelp.proj b/src/libraries/sendtohelixhelp.proj index 606f2216b1362..53c4e32ee1a65 100644 --- a/src/libraries/sendtohelixhelp.proj +++ b/src/libraries/sendtohelixhelp.proj @@ -130,8 +130,8 @@ - - + + From 9e1640ad86adc2d762a59d5982e229a913088bf3 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Tue, 31 Jan 2023 15:40:53 +0100 Subject: [PATCH 17/28] Reverse the test here as we don't relink anymore --- src/mono/wasm/Wasm.Build.Tests/WasmSIMDTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mono/wasm/Wasm.Build.Tests/WasmSIMDTests.cs b/src/mono/wasm/Wasm.Build.Tests/WasmSIMDTests.cs index 26aa0a7e62ce4..58219660acf11 100644 --- a/src/mono/wasm/Wasm.Build.Tests/WasmSIMDTests.cs +++ b/src/mono/wasm/Wasm.Build.Tests/WasmSIMDTests.cs @@ -18,7 +18,7 @@ public WasmSIMDTests(ITestOutputHelper output, SharedBuildPerTestClassFixture bu [Theory] [MemberData(nameof(MainMethodTestData), parameters: new object[] { /*aot*/ false, RunHost.All })] - public void BuildWithSIMD_NoAOT_ShouldRelink(BuildArgs buildArgs, RunHost host, string id) + public void BuildWithSIMD_NoAOT_ShouldNotRelink(BuildArgs buildArgs, RunHost host, string id) { string projectName = $"sim_with_workload_no_aot"; buildArgs = buildArgs with { ProjectName = projectName }; @@ -29,7 +29,7 @@ public void BuildWithSIMD_NoAOT_ShouldRelink(BuildArgs buildArgs, RunHost host, new BuildProjectOptions( InitProject: () => File.WriteAllText(Path.Combine(_projectDir!, "Program.cs"), s_simdProgramText), Publish: false, - DotnetWasmFromRuntimePack: false)); + DotnetWasmFromRuntimePack: true)); if (!_buildContext.TryGetBuildFor(buildArgs, out _)) { From 1371cceb1480c8191259f3a9359a4fe58c1e9487 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Mon, 6 Feb 2023 20:53:53 +0100 Subject: [PATCH 18/28] Set _ExtraTrimmerArgs for tests So that linker substitution files are used --- eng/testing/tests.wasm.targets | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eng/testing/tests.wasm.targets b/eng/testing/tests.wasm.targets index 6516302093b32..e8e3b2ab0e7e9 100644 --- a/eng/testing/tests.wasm.targets +++ b/eng/testing/tests.wasm.targets @@ -19,6 +19,9 @@ false true + <_ExtraTrimmerArgs Condition="'$(WasmEnableSIMD)' == 'true'">$(_ExtraTrimmerArgs) --substitutions "$(MonoProjectRoot)\wasm\build\ILLink.Substitutions.WasmIntrinsics.xml" + <_ExtraTrimmerArgs Condition="'$(WasmEnableSIMD)' != 'true'">$(_ExtraTrimmerArgs) --substitutions "$(MonoProjectRoot)\wasm\build\ILLink.Substitutions.NoWasmIntrinsics.xml" + <_ShellCommandSeparator Condition="'$(OS)' == 'Windows_NT'">&& <_ShellCommandSeparator Condition="'$(OS)' != 'Windows_NT'">&& From 758d5b66f1ff6da5ad0b6511f45f348bda5faff8 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Mon, 6 Feb 2023 21:01:33 +0100 Subject: [PATCH 19/28] Put the SIMD/trim related props in separate group More changes from Ankit --- eng/testing/tests.wasm.targets | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/eng/testing/tests.wasm.targets b/eng/testing/tests.wasm.targets index e8e3b2ab0e7e9..636ac6251fdf3 100644 --- a/eng/testing/tests.wasm.targets +++ b/eng/testing/tests.wasm.targets @@ -19,9 +19,6 @@ false true - <_ExtraTrimmerArgs Condition="'$(WasmEnableSIMD)' == 'true'">$(_ExtraTrimmerArgs) --substitutions "$(MonoProjectRoot)\wasm\build\ILLink.Substitutions.WasmIntrinsics.xml" - <_ExtraTrimmerArgs Condition="'$(WasmEnableSIMD)' != 'true'">$(_ExtraTrimmerArgs) --substitutions "$(MonoProjectRoot)\wasm\build\ILLink.Substitutions.NoWasmIntrinsics.xml" - <_ShellCommandSeparator Condition="'$(OS)' == 'Windows_NT'">&& <_ShellCommandSeparator Condition="'$(OS)' != 'Windows_NT'">&& @@ -54,6 +51,21 @@ local + + + <_ExtraTrimmerArgs Condition="'$(WasmEnableSIMD)' == 'true'">$(_ExtraTrimmerArgs) --substitutions "$(MonoProjectRoot)\wasm\build\ILLink.Substitutions.WasmIntrinsics.xml" + <_ExtraTrimmerArgs Condition="'$(WasmEnableSIMD)' != 'true'">$(_ExtraTrimmerArgs) --substitutions "$(MonoProjectRoot)\wasm\build\ILLink.Substitutions.NoWasmIntrinsics.xml" + + <_AOT_InternalForceInterpretAssemblies Include="@(HighAotMemoryUsageAssembly)" /> From f736fa53e3654b7dca1aca2543363c2265229962 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Tue, 7 Feb 2023 11:48:15 +0100 Subject: [PATCH 20/28] Add dynamic dependency --- .../System.Runtime.Intrinsics/tests/Vectors/Vector128Tests.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/System.Runtime.Intrinsics/tests/Vectors/Vector128Tests.cs b/src/libraries/System.Runtime.Intrinsics/tests/Vectors/Vector128Tests.cs index 22f1b7a20ca67..044cd5b002b0f 100644 --- a/src/libraries/System.Runtime.Intrinsics/tests/Vectors/Vector128Tests.cs +++ b/src/libraries/System.Runtime.Intrinsics/tests/Vectors/Vector128Tests.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; using System.Numerics; using System.Reflection; using System.Runtime.InteropServices; @@ -11,6 +12,7 @@ namespace System.Runtime.Intrinsics.Tests.Vectors public sealed class Vector128Tests { [Fact] + [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties, typeof(Vector128))] public unsafe void Vector128IsHardwareAcceleratedTest() { MethodInfo methodInfo = typeof(Vector128).GetMethod("get_IsHardwareAccelerated"); From 42ce1df7be734410e3bd28066c4d027769f466be Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Tue, 7 Feb 2023 22:10:21 +0100 Subject: [PATCH 21/28] Disable Vector128IsHardwareAcceleratedTest Til we have the interpreter support in place --- .../System.Runtime.Intrinsics/tests/Vectors/Vector128Tests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libraries/System.Runtime.Intrinsics/tests/Vectors/Vector128Tests.cs b/src/libraries/System.Runtime.Intrinsics/tests/Vectors/Vector128Tests.cs index 044cd5b002b0f..3894d835a60b0 100644 --- a/src/libraries/System.Runtime.Intrinsics/tests/Vectors/Vector128Tests.cs +++ b/src/libraries/System.Runtime.Intrinsics/tests/Vectors/Vector128Tests.cs @@ -13,6 +13,7 @@ public sealed class Vector128Tests { [Fact] [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties, typeof(Vector128))] + [ActiveIssue("https://github.com/dotnet/runtime/issues/81785", TestPlatforms.Browser)] public unsafe void Vector128IsHardwareAcceleratedTest() { MethodInfo methodInfo = typeof(Vector128).GetMethod("get_IsHardwareAccelerated"); From 3c02f898d8af87ed38059058f4a533be0428c64d Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Thu, 9 Feb 2023 19:59:12 +0100 Subject: [PATCH 22/28] Disable GenericVectorTests.IsHardwareAcceleratedTest Til we have the interpreter support in place --- .../System.Numerics.Vectors/tests/GenericVectorTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libraries/System.Numerics.Vectors/tests/GenericVectorTests.cs b/src/libraries/System.Numerics.Vectors/tests/GenericVectorTests.cs index 207b7dc0e7b2d..74b54a5437d2c 100644 --- a/src/libraries/System.Numerics.Vectors/tests/GenericVectorTests.cs +++ b/src/libraries/System.Numerics.Vectors/tests/GenericVectorTests.cs @@ -27,6 +27,7 @@ static GenericVectorTests() } [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/81785", TestPlatforms.Browser)] public unsafe void IsHardwareAcceleratedTest() { MethodInfo methodInfo = typeof(Vector).GetMethod("get_IsHardwareAccelerated"); From c401b5290ba3902c3afbcf28cd77c7276c9fd19f Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Fri, 10 Feb 2023 17:38:55 +0100 Subject: [PATCH 23/28] Disable check_no_intrinsic_cattr in emit_vector_2_3_4 And add note about opened issue --- src/mono/mono/mini/simd-intrinsics.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/mini/simd-intrinsics.c b/src/mono/mono/mini/simd-intrinsics.c index 9247e0f6ec390..8e7505bcd1ebf 100644 --- a/src/mono/mono/mini/simd-intrinsics.c +++ b/src/mono/mono/mini/simd-intrinsics.c @@ -1918,7 +1918,8 @@ emit_vector_2_3_4 (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *f id = lookup_intrins (vector2_methods, sizeof (vector2_methods), cmethod); if (id == -1) { - check_no_intrinsic_cattr (cmethod); + // https://github.com/dotnet/runtime/issues/81961 + // check_no_intrinsic_cattr (cmethod); return NULL; } From 143a73bcd33aa32aa5fa0c28ae524251f2d396d6 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Mon, 20 Feb 2023 21:09:00 +0100 Subject: [PATCH 24/28] [mono] Disable few quaternion intrinsics For * and / operators as these are not the same as vector operations. Opened https://github.com/dotnet/runtime/issues/82408 to implement correct ones in future. --- src/mono/mono/mini/simd-intrinsics.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/mini/simd-intrinsics.c b/src/mono/mono/mini/simd-intrinsics.c index e217d2f2c59e2..e5aa4d15d052b 100644 --- a/src/mono/mono/mini/simd-intrinsics.c +++ b/src/mono/mono/mini/simd-intrinsics.c @@ -2112,10 +2112,15 @@ emit_vector_2_3_4 (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *f case SN_op_Multiply: case SN_op_Subtraction: case SN_Max: - case SN_Min: + case SN_Min: { + const char *klass_name = m_class_get_name (klass); + // FIXME https://github.com/dotnet/runtime/issues/82408 + if (!strcmp (klass_name, "Quaternion") && (id == SN_op_Multiply || id == SN_Multiply || id == SN_op_Division || id == SN_Divide)) + return NULL; if (!(!fsig->hasthis && fsig->param_count == 2 && mono_metadata_type_equal (fsig->ret, type) && mono_metadata_type_equal (fsig->params [0], type) && mono_metadata_type_equal (fsig->params [1], type))) return NULL; return emit_simd_ins_for_binary_op (cfg, klass, fsig, args, MONO_TYPE_R4, id); + } case SN_Dot: { #if defined(TARGET_ARM64) || defined(TARGET_WASM) int instc0 = OP_FMUL; From 01145065dca379ec3afa1360c2e5a6b0beabde32 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Mon, 20 Feb 2023 21:44:52 +0100 Subject: [PATCH 25/28] Change comparison order --- src/mono/mono/mini/simd-intrinsics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/mini/simd-intrinsics.c b/src/mono/mono/mini/simd-intrinsics.c index e5aa4d15d052b..1adf7c1b4c203 100644 --- a/src/mono/mono/mini/simd-intrinsics.c +++ b/src/mono/mono/mini/simd-intrinsics.c @@ -2115,7 +2115,7 @@ emit_vector_2_3_4 (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *f case SN_Min: { const char *klass_name = m_class_get_name (klass); // FIXME https://github.com/dotnet/runtime/issues/82408 - if (!strcmp (klass_name, "Quaternion") && (id == SN_op_Multiply || id == SN_Multiply || id == SN_op_Division || id == SN_Divide)) + if ((id == SN_op_Multiply || id == SN_Multiply || id == SN_op_Division || id == SN_Divide) && !strcmp (klass_name, "Quaternion")) return NULL; if (!(!fsig->hasthis && fsig->param_count == 2 && mono_metadata_type_equal (fsig->ret, type) && mono_metadata_type_equal (fsig->params [0], type) && mono_metadata_type_equal (fsig->params [1], type))) return NULL; From d05cb530b9d500dee7db6afa86905bda1b2334f2 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Tue, 21 Feb 2023 13:30:02 +0100 Subject: [PATCH 26/28] Use stable images --- eng/pipelines/libraries/helix-queues-setup.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/pipelines/libraries/helix-queues-setup.yml b/eng/pipelines/libraries/helix-queues-setup.yml index 6e56087030f45..25c6d44dbd844 100644 --- a/eng/pipelines/libraries/helix-queues-setup.yml +++ b/eng/pipelines/libraries/helix-queues-setup.yml @@ -189,11 +189,11 @@ jobs: # Browser/WASI WebAssembly - ${{ if in(parameters.platform, 'browser_wasm', 'wasi_wasm') }}: - - (Ubuntu.1804.Amd64)Ubuntu.1804.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-helix-webassembly-staging + - (Ubuntu.1804.Amd64)Ubuntu.1804.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-helix-webassembly # Browser WebAssembly Firefox - ${{ if eq(parameters.platform, 'browser_wasm_firefox') }}: - - (Ubuntu.1804.Amd64)Ubuntu.1804.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-helix-webassembly-staging + - (Ubuntu.1804.Amd64)Ubuntu.1804.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-helix-webassembly # Browser WebAssembly windows - ${{ if in(parameters.platform, 'browser_wasm_win', 'wasi_wasm_win') }}: From aed4dd2d9873066178f9e01d86d6dcc731637206 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 24 Feb 2023 20:14:13 -0500 Subject: [PATCH 27/28] WBT: Add --engine-arg=--experimental-wasm-simd for node, and v8 --- src/mono/wasm/Wasm.Build.Tests/HostRunner/NodeJSHostRunner.cs | 4 ++-- src/mono/wasm/Wasm.Build.Tests/HostRunner/V8HostRunner.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mono/wasm/Wasm.Build.Tests/HostRunner/NodeJSHostRunner.cs b/src/mono/wasm/Wasm.Build.Tests/HostRunner/NodeJSHostRunner.cs index cf311557c27f2..9c81295012616 100644 --- a/src/mono/wasm/Wasm.Build.Tests/HostRunner/NodeJSHostRunner.cs +++ b/src/mono/wasm/Wasm.Build.Tests/HostRunner/NodeJSHostRunner.cs @@ -8,8 +8,8 @@ namespace Wasm.Build.Tests; public class NodeJSHostRunner : IHostRunner { public string GetTestCommand() => "wasm test"; - public string GetXharnessArgsWindowsOS(XHarnessArgsOptions options) => $"--js-file={options.jsRelativePath} --engine=NodeJS -v trace"; - public string GetXharnessArgsOtherOS(XHarnessArgsOptions options) => $"--js-file={options.jsRelativePath} --engine=NodeJS -v trace --locale={options.environmentLocale}"; + public string GetXharnessArgsWindowsOS(XHarnessArgsOptions options) => $"--js-file={options.jsRelativePath} --engine=NodeJS -v trace --engine-arg=--experimental-wasm-simd"; + public string GetXharnessArgsOtherOS(XHarnessArgsOptions options) => $"--js-file={options.jsRelativePath} --engine=NodeJS -v trace --locale={options.environmentLocale} --engine-arg=--experimental-wasm-simd"; public bool UseWasmConsoleOutput() => true; public bool CanRunWBT() => true; } diff --git a/src/mono/wasm/Wasm.Build.Tests/HostRunner/V8HostRunner.cs b/src/mono/wasm/Wasm.Build.Tests/HostRunner/V8HostRunner.cs index 885aba29ad463..76067e4641779 100644 --- a/src/mono/wasm/Wasm.Build.Tests/HostRunner/V8HostRunner.cs +++ b/src/mono/wasm/Wasm.Build.Tests/HostRunner/V8HostRunner.cs @@ -9,7 +9,7 @@ namespace Wasm.Build.Tests; public class V8HostRunner : IHostRunner { - private string GetXharnessArgs(string jsRelativePath) => $"--js-file={jsRelativePath} --engine=V8 -v trace"; + private string GetXharnessArgs(string jsRelativePath) => $"--js-file={jsRelativePath} --engine=V8 -v trace --engine-arg=--experimental-wasm-simd"; public string GetTestCommand() => "wasm test"; public string GetXharnessArgsWindowsOS(XHarnessArgsOptions options) => GetXharnessArgs(options.jsRelativePath); From cfc855eff6b9fa5fe7fbd7fb72044dde23fbb113 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Mon, 27 Feb 2023 13:47:29 +0100 Subject: [PATCH 28/28] Do not skip dotnet 1st time experience anymore --- src/libraries/sendtohelixhelp.proj | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/libraries/sendtohelixhelp.proj b/src/libraries/sendtohelixhelp.proj index 3c968ddb59c9e..e51814d790978 100644 --- a/src/libraries/sendtohelixhelp.proj +++ b/src/libraries/sendtohelixhelp.proj @@ -124,11 +124,6 @@ - - - - -