diff --git a/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml b/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml index 5e6237c9880e5..4c3994a03be1b 100644 --- a/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml +++ b/eng/pipelines/extra-platforms/runtime-extra-platforms-wasm.yml @@ -124,7 +124,7 @@ jobs: - browser_wasm #- browser_wasm_win nameSuffix: _Threading - extraBuildArgs: /p:MonoWasmBuildVariant=multithread /p:WasmEnableThreads=true /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS) + extraBuildArgs: /p:WasmEnableThreads=true /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS) isExtraPlatformsBuild: ${{ parameters.isExtraPlatformsBuild }} isWasmOnlyBuild: ${{ parameters.isWasmOnlyBuild }} # Always run for runtime-wasm because tests are not run in runtime @@ -255,7 +255,7 @@ jobs: - browser_wasm - browser_wasm_win nameSuffix: MultiThreaded - extraBuildArgs: /p:MonoWasmBuildVariant=multithread /p:WasmEnableThreads=true /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS) + extraBuildArgs: /p:WasmEnableThreads=true /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS) condition: ne(variables['wasmMultiThreadedBuildOnlyNeededOnDefaultPipeline'], true) publishArtifactsForWorkload: true publishWBT: false @@ -313,7 +313,7 @@ jobs: platforms: - Browser_wasm - Browser_wasm_win - extraBuildArgs: /p:MonoWasmBuildVariant=multithread /p:WasmEnableThreads=true /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS) + extraBuildArgs: /p:WasmEnableThreads=true /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS) nameSuffix: DebuggerTests_MultiThreaded alwaysRun: ${{ parameters.isWasmOnlyBuild }} isExtraPlatformsBuild: ${{ parameters.isExtraPlatformsBuild }} diff --git a/eng/pipelines/runtime-official.yml b/eng/pipelines/runtime-official.yml index 618bf2b3f9953..d8ad9c571806a 100644 --- a/eng/pipelines/runtime-official.yml +++ b/eng/pipelines/runtime-official.yml @@ -394,7 +394,7 @@ extends: platforms: - browser_wasm jobParameters: - buildArgs: -s mono+libs+host+packs -c $(_BuildConfig) /p:MonoWasmBuildVariant=multithread /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS) + buildArgs: -s mono+libs+host+packs -c $(_BuildConfig) /p:WasmEnableThreads=true /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS) nameSuffix: Mono_multithread isOfficialBuild: ${{ variables.isOfficialBuild }} runtimeVariant: multithread diff --git a/eng/pipelines/runtime.yml b/eng/pipelines/runtime.yml index 8ad2dd191483c..edc433eacc946 100644 --- a/eng/pipelines/runtime.yml +++ b/eng/pipelines/runtime.yml @@ -565,7 +565,7 @@ extends: - browser_wasm_win condition: or(eq(variables.isRollingBuild, true), eq(variables.wasmSingleThreadedBuildOnlyNeededOnDefaultPipeline, true)) nameSuffix: MultiThreaded - extraBuildArgs: /p:MonoWasmBuildVariant=multithread /p:WasmEnableThreads=true /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS) + extraBuildArgs: /p:WasmEnableThreads=true /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS) publishArtifactsForWorkload: true publishWBT: false @@ -601,7 +601,7 @@ extends: platforms: - browser_wasm nameSuffix: _Threading_Smoke - extraBuildArgs: /p:MonoWasmBuildVariant=multithread /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS) + extraBuildArgs: /p:WasmEnableThreads=true /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS) shouldRunSmokeOnly: true alwaysRun: ${{ variables.isRollingBuild }} scenarios: diff --git a/eng/testing/tests.browser.targets b/eng/testing/tests.browser.targets index d856a41784e67..6a1a2e29d5286 100644 --- a/eng/testing/tests.browser.targets +++ b/eng/testing/tests.browser.targets @@ -87,15 +87,15 @@ <_AppArgs Condition="'$(IsFunctionalTest)' != 'true' and '$(WasmMainAssemblyFileName)' != ''">--run $(WasmMainAssemblyFileName) <_AppArgs Condition="'$(IsFunctionalTest)' == 'true'">--run $(AssemblyName).dll - <_XUnitBackgroundExec Condition="'$(_XUnitBackgroundExec)' == '' and '$(MonoWasmBuildVariant)' == 'multithread'">true + <_XUnitBackgroundExec Condition="'$(_XUnitBackgroundExec)' == '' and '$(WasmEnableThreads)' == 'true'">true $(WasmTestAppArgs) -backgroundExec <_AppArgs Condition="'$(WasmTestAppArgs)' != ''">$(_AppArgs) $(WasmTestAppArgs) $(WasmXHarnessMonoArgs) --setenv=XHARNESS_LOG_TEST_START=1 - $(WasmXHarnessMonoArgs) --no-memory-snapshot + $(WasmXHarnessMonoArgs) --no-memory-snapshot - $(WasmXHarnessMonoArgs) --setenv=IsBrowserThreadingSupported=true + $(WasmXHarnessMonoArgs) --setenv=IsBrowserThreadingSupported=true @@ -104,7 +104,7 @@ <_XHarnessArgs Condition="'$(IsFunctionalTest)' == 'true'" >$(_XHarnessArgs) --expected-exit-code=$(ExpectedExitCode) <_XHarnessArgs Condition="'$(WasmXHarnessArgs)' != ''" >$(_XHarnessArgs) $(WasmXHarnessArgs) - <_XHarnessArgs Condition="'$(MonoWasmBuildVariant)' == 'multithread' and '$(_XHarnessArs.Contains("--web-server-use-cop")' != 'true'">$(_XHarnessArgs) --web-server-use-cop + <_XHarnessArgs Condition="'$(WasmEnableThreads)' == 'true' and '$(_XHarnessArs.Contains("--web-server-use-cop")' != 'true'">$(_XHarnessArgs) --web-server-use-cop <_XHarnessArgs >$(_XHarnessArgs) -s dotnet.native.js.symbols <_XHarnessArgs Condition="'$(_UseWasmSymbolicator)' == 'true'" >$(_XHarnessArgs) --symbol-patterns wasm-symbol-patterns.txt <_XHarnessArgs Condition="'$(_UseWasmSymbolicator)' == 'true'" >$(_XHarnessArgs) --symbolicator WasmSymbolicator.dll,Microsoft.WebAssembly.Internal.SymbolicatorWrapperForXHarness diff --git a/eng/testing/workloads-browser.targets b/eng/testing/workloads-browser.targets index 270267385bab1..a312347ff12f6 100644 --- a/eng/testing/workloads-browser.targets +++ b/eng/testing/workloads-browser.targets @@ -47,10 +47,14 @@ - <_DefaultBuildVariant Condition="'$(MonoWasmBuildVariant)' == 'multithread'">.multithread. - <_DefaultBuildVariant Condition="'$(_DefaultBuildVariant)' == ''">. - - <_DefaultRuntimePackNuGetPath>$(LibrariesShippingPackagesDir)Microsoft.NETCore.App.Runtime.Mono$(_DefaultBuildVariant)$(RIDForWorkload).$(PackageVersionForWorkloadManifests).nupkg + <_BuildVariant Condition="'$(WasmEnableThreads)' == 'true'">multithread + <_Descriptor Condition="'$(WasmEnableThreads)' == 'true'">runtime pack for $(_BuildVariant) + <_Descriptor Condition="'$(WasmEnableThreads)' != 'true'">single threaded runtime pack + <_DefaultRuntimePackNuGetPath>$([System.String]::Join('.', + $(LibrariesShippingPackagesDir)Microsoft.NETCore.App.Runtime.Mono, + $(_BuildVariant), + $(RIDForWorkload).$(PackageVersionForWorkloadManifests).nupkg)) + @@ -63,22 +67,11 @@ Text="Expected to find either one or two in $(LibrariesShippingPackagesDir): @(_RuntimePackNugetAvailable->'%(FileName)%(Extension)')" /> - <_BuildVariants Include="multithread" Condition="'$(_DefaultBuildVariant)' != '.multithread.'" /> - - <_NuGetsToBuild Include="$(LibrariesShippingPackagesDir)Microsoft.NETCore.App.Runtime.Mono.%(_BuildVariants.Identity).$(RIDForWorkload).$(PackageVersionForWorkloadManifests).nupkg" - Project="$(InstallerProjectRoot)pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.sfxproj" - Dependencies="$(_DefaultRuntimePackNuGetPath)" - Properties="@(_DefaultPropsForNuGetBuild, ';');MonoWasmBuildVariant=%(_BuildVariants.Identity)" - Descriptor="runtime pack for %(_BuildVariants.Identity)" - Condition="'%(_BuildVariants.Identity)' != ''"/> - - - <_NuGetsToBuild Include="$(LibrariesShippingPackagesDir)Microsoft.NETCore.App.Runtime.Mono.$(RIDForWorkload).$(PackageVersionForWorkloadManifests).nupkg" + <_NuGetsToBuild Include="$(_DefaultRuntimePackNuGetPath)" Project="$(InstallerProjectRoot)pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.sfxproj" - Properties="@(_DefaultPropsForNuGetBuild, ';');MonoWasmBuildVariant=" Dependencies="$(_DefaultRuntimePackNuGetPath)" - Descriptor="single threaded runtime pack" - Condition="'$(_DefaultBuildVariant)' != '.'" /> + Properties="@(_DefaultPropsForNuGetBuild, ';');WasmEnableThreads=$(WasmEnableThreads)" + Descriptor="$(_Descriptor)"/> Mono.LLVM.AOT - - Mono.$(MonoWasmBuildVariant) + + Mono.multithread $(SharedFrameworkName).Runtime.$(RuntimeSpecificFrameworkSuffix).$(RuntimeIdentifier) diff --git a/src/libraries/Common/src/Interop/Browser/Interop.Runtime.cs b/src/libraries/Common/src/Interop/Browser/Interop.Runtime.cs index 61786b5b33748..bdfe0efa092b0 100644 --- a/src/libraries/Common/src/Interop/Browser/Interop.Runtime.cs +++ b/src/libraries/Common/src/Interop/Browser/Interop.Runtime.cs @@ -27,7 +27,7 @@ internal static unsafe partial class Runtime public static extern void DeregisterGCRoot(nint handle); #endif -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS [MethodImpl(MethodImplOptions.InternalCall)] public static extern void InstallWebWorkerInterop(nint proxyContextGCHandle); [MethodImpl(MethodImplOptions.InternalCall)] diff --git a/src/libraries/System.Diagnostics.Tracing/src/System.Diagnostics.Tracing.csproj b/src/libraries/System.Diagnostics.Tracing/src/System.Diagnostics.Tracing.csproj index 6af0cb0108f3c..8a0c4aad6f08e 100644 --- a/src/libraries/System.Diagnostics.Tracing/src/System.Diagnostics.Tracing.csproj +++ b/src/libraries/System.Diagnostics.Tracing/src/System.Diagnostics.Tracing.csproj @@ -6,7 +6,7 @@ false - + diff --git a/src/libraries/System.Linq.Parallel/src/System.Linq.Parallel.csproj b/src/libraries/System.Linq.Parallel/src/System.Linq.Parallel.csproj index abe40ca2e317e..3d7f38289ac0a 100644 --- a/src/libraries/System.Linq.Parallel/src/System.Linq.Parallel.csproj +++ b/src/libraries/System.Linq.Parallel/src/System.Linq.Parallel.csproj @@ -1,15 +1,15 @@ - $(NetCoreAppCurrent) - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-browser + $(NetCoreAppCurrent) + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-browser true false $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - true - $(DefineConstants);FEATURE_WASM_THREADS + true + $(DefineConstants);FEATURE_WASM_MANAGED_THREADS @@ -158,8 +158,8 @@ - - + + diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Channels/AsynchronousChannel.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Channels/AsynchronousChannel.cs index d00c969e0f8aa..775228fb66c5f 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Channels/AsynchronousChannel.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Channels/AsynchronousChannel.cs @@ -17,7 +17,7 @@ namespace System.Linq.Parallel /// This is a bounded channel meant for single-producer/single-consumer scenarios. /// /// Specifies the type of data in the channel. -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] #endif internal sealed class AsynchronousChannel : IDisposable diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/AsynchronousChannelMergeEnumerator.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/AsynchronousChannelMergeEnumerator.cs index b6c6d837379c5..9b101fb789132 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/AsynchronousChannelMergeEnumerator.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/AsynchronousChannelMergeEnumerator.cs @@ -26,7 +26,7 @@ namespace System.Linq.Parallel /// /// /// -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] #endif internal sealed class AsynchronousChannelMergeEnumerator : MergeEnumerator diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/MergeExecutor.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/MergeExecutor.cs index d6cb9a58245d6..11bf7fd5a233a 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/MergeExecutor.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/MergeExecutor.cs @@ -141,7 +141,7 @@ public IEnumerator GetEnumerator() // An array of asynchronous channels, one for each partition. // -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] #endif internal static AsynchronousChannel[] MakeAsynchronousChannels(int partitionCount, ParallelMergeOptions options, IntValueEvent? consumerEvent, CancellationToken cancellationToken) diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/OrderPreservingPipeliningMergeHelper.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/OrderPreservingPipeliningMergeHelper.cs index b964a36048977..2846d016ebb4e 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/OrderPreservingPipeliningMergeHelper.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/OrderPreservingPipeliningMergeHelper.cs @@ -36,7 +36,7 @@ namespace System.Linq.Parallel /// Finally, if the producer notices that its buffer has exceeded an even greater threshold, it will /// go to sleep and wait until the consumer takes the entire buffer. /// -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] #endif internal sealed class OrderPreservingPipeliningMergeHelper : IMergeHelper diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Scheduling/OrderPreservingPipeliningSpoolingTask.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Scheduling/OrderPreservingPipeliningSpoolingTask.cs index ac5d9ea432b9f..0e0e81ee6448a 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Scheduling/OrderPreservingPipeliningSpoolingTask.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Scheduling/OrderPreservingPipeliningSpoolingTask.cs @@ -18,7 +18,7 @@ namespace System.Linq.Parallel { -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] #endif internal sealed class OrderPreservingPipeliningSpoolingTask : SpoolingTaskBase diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Scheduling/SpoolingTask.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Scheduling/SpoolingTask.cs index 45e44d2be18eb..2a796d57aabae 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Scheduling/SpoolingTask.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Scheduling/SpoolingTask.cs @@ -82,7 +82,7 @@ internal static void SpoolStopAndGo( // taskScheduler - the task manager on which to execute // -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] #endif internal static void SpoolPipeline( @@ -264,7 +264,7 @@ protected override void SpoolingFinally() /// /// /// -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] #endif internal sealed class PipelineSpoolingTask : SpoolingTaskBase diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Utils/Sorting.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Utils/Sorting.cs index d475e7e8f2024..33288424eff27 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Utils/Sorting.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Utils/Sorting.cs @@ -351,7 +351,7 @@ private void QuickSortIndicesInPlace(GrowingArray keys, List // negatively impact speedups. // -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] #endif private void MergeSortCooperatively() diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/ParallelEnumerable.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/ParallelEnumerable.cs index a3e760b465929..55ef371ea0422 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/ParallelEnumerable.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/ParallelEnumerable.cs @@ -64,7 +64,7 @@ public static class ParallelEnumerable // When running in single partition mode, PLINQ operations will occur on a single partition and will not // be executed in parallel, but will retain PLINQ semantics (exceptions wrapped as aggregates, etc). -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.SupportedOSPlatformGuard("browser")] internal static bool SinglePartitionMode => OperatingSystem.IsBrowser(); #else diff --git a/src/libraries/System.Net.Http/src/System.Net.Http.csproj b/src/libraries/System.Net.Http/src/System.Net.Http.csproj index 109f4aba860dc..729f78dd752be 100644 --- a/src/libraries/System.Net.Http/src/System.Net.Http.csproj +++ b/src/libraries/System.Net.Http/src/System.Net.Http.csproj @@ -11,7 +11,7 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.PlatformNotSupported_NetHttp - true + true $(DefineConstants);SYSNETHTTP_NO_OPENSSL $(DefineConstants);TARGET_MOBILE $(DefineConstants);TARGET_ANDROID @@ -20,7 +20,7 @@ $(DefineConstants);TARGET_TVOS $(DefineConstants);TARGET_BROWSER $(DefineConstants);TARGET_WASI - $(DefineConstants);FEATURE_WASM_THREADS + $(DefineConstants);FEATURE_WASM_MANAGED_THREADS true diff --git a/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj b/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj index f017401d6aa99..a309737d6917d 100644 --- a/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj +++ b/src/libraries/System.Net.WebSockets.Client/src/System.Net.WebSockets.Client.csproj @@ -9,9 +9,9 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - true + true $(DefineConstants);TARGET_BROWSER - $(DefineConstants);FEATURE_WASM_THREADS + $(DefineConstants);FEATURE_WASM_MANAGED_THREADS true diff --git a/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs b/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs index c635a3d48aad8..478de9846cc25 100644 --- a/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs +++ b/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/BrowserWebSockets/BrowserWebSocket.cs @@ -268,7 +268,7 @@ static void Cleanup(object? _state) self.responseStatusHandle?.Dispose(); } -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS // if this is finalizer thread, we need to postpone the abort -> dispose _innerWebSocket?.SynchronizationContext.Post(Cleanup, this); #else diff --git a/src/libraries/System.Private.CoreLib/ref/System.Private.CoreLib.ExtraApis.cs b/src/libraries/System.Private.CoreLib/ref/System.Private.CoreLib.ExtraApis.cs index dedbdd6e27692..4294279eefc57 100644 --- a/src/libraries/System.Private.CoreLib/ref/System.Private.CoreLib.ExtraApis.cs +++ b/src/libraries/System.Private.CoreLib/ref/System.Private.CoreLib.ExtraApis.cs @@ -38,7 +38,7 @@ public static partial class Debug } } -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS namespace System.Threading { public partial class Monitor diff --git a/src/libraries/System.Private.CoreLib/ref/System.Private.CoreLib.csproj b/src/libraries/System.Private.CoreLib/ref/System.Private.CoreLib.csproj index 7e0202c10b9d7..82024e3887fd1 100644 --- a/src/libraries/System.Private.CoreLib/ref/System.Private.CoreLib.csproj +++ b/src/libraries/System.Private.CoreLib/ref/System.Private.CoreLib.csproj @@ -10,10 +10,10 @@ $(NoWarn);0809;0618;CS8614;CS3015 SilverlightPlatform true - true - true + true + true $(DefineConstants);FEATURE_WASM_PERFTRACING - $(DefineConstants);FEATURE_WASM_THREADS + $(DefineConstants);FEATURE_WASM_MANAGED_THREADS $(DefineConstants);BUILDING_CORELIB_REFERENCE false diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index e46bd04f7d695..9fc91793b7065 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -2666,13 +2666,13 @@ - + - + diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs index b049a9aaeebeb..a385543f9174a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs @@ -344,7 +344,7 @@ public void Reset() /// The caller of this method blocks indefinitely until the current instance is set. The caller will /// return immediately if the event is currently in a set state. /// -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public void Wait() @@ -367,7 +367,7 @@ public void Wait() /// The caller of this method blocks indefinitely until the current instance is set. The caller will /// return immediately if the event is currently in a set state. /// -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public void Wait(CancellationToken cancellationToken) @@ -390,7 +390,7 @@ public void Wait(CancellationToken cancellationToken) /// /// The maximum number of waiters has been exceeded. /// -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public bool Wait(TimeSpan timeout) @@ -423,7 +423,7 @@ public bool Wait(TimeSpan timeout) /// /// The maximum number of waiters has been exceeded. /// -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public bool Wait(TimeSpan timeout, CancellationToken cancellationToken) @@ -449,7 +449,7 @@ public bool Wait(TimeSpan timeout, CancellationToken cancellationToken) /// /// The maximum number of waiters has been exceeded. /// -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public bool Wait(int millisecondsTimeout) @@ -475,7 +475,7 @@ public bool Wait(int millisecondsTimeout) /// /// was canceled. -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken) diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Monitor.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Monitor.cs index 8fe478a52dc9a..c40c38dab4f0f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Monitor.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Monitor.cs @@ -13,25 +13,25 @@ public static bool TryEnter(object obj, TimeSpan timeout) public static void TryEnter(object obj, TimeSpan timeout, ref bool lockTaken) => TryEnter(obj, WaitHandle.ToTimeoutMilliseconds(timeout), ref lockTaken); -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public static bool Wait(object obj, TimeSpan timeout) => Wait(obj, WaitHandle.ToTimeoutMilliseconds(timeout)); -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public static bool Wait(object obj) => Wait(obj, Timeout.Infinite); // Remoting is not supported, exitContext argument is unused -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public static bool Wait(object obj, int millisecondsTimeout, bool exitContext) => Wait(obj, millisecondsTimeout); // Remoting is not supported, exitContext argument is unused -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public static bool Wait(object obj, TimeSpan timeout, bool exitContext) diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Overlapped.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Overlapped.cs index 29446e444073c..a4dae77a75116 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Overlapped.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Overlapped.cs @@ -184,7 +184,7 @@ public static void Free(NativeOverlapped* nativeOverlappedPtr) _pNativeOverlapped = pNativeOverlapped; #if FEATURE_PERFTRACING -#if !((TARGET_BROWSER || TARGET_WASI) && !FEATURE_WASM_THREADS) +#if !((TARGET_BROWSER || TARGET_WASI) && !FEATURE_WASM_MANAGED_THREADS) if (NativeRuntimeEventSource.Log.IsEnabled()) NativeRuntimeEventSource.Log.ThreadPoolIOPack(pNativeOverlapped); #endif diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/RegisteredWaitHandle.Portable.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/RegisteredWaitHandle.Portable.cs index b5672e243282e..2fb8d1fb3f63c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/RegisteredWaitHandle.Portable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/RegisteredWaitHandle.Portable.cs @@ -10,7 +10,7 @@ namespace System.Threading /// /// An object representing the registration of a via . /// -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public sealed partial class RegisteredWaitHandle : MarshalByRefObject diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs index aeed0604c301f..0c1c65348fa50 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs @@ -147,7 +147,7 @@ public Thread(ParameterizedThreadStart start, int maxStackSize) Initialize(); } -#if (!TARGET_BROWSER && !TARGET_WASI) || FEATURE_WASM_THREADS +#if (!TARGET_BROWSER && !TARGET_WASI) || FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatformGuard("browser")] internal static bool IsThreadStartSupported => true; internal static bool IsInternalThreadStartSupported => true; @@ -175,7 +175,7 @@ internal static void ThrowIfNoThreadStart(bool internalThread = false) /// The thread has already been started. /// There is not enough memory available to start this thread. /// This thread was created using a delegate instead of a delegate. -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public void Start(object? parameter) => Start(parameter, captureContext: true); @@ -189,7 +189,7 @@ internal static void ThrowIfNoThreadStart(bool internalThread = false) /// Unlike , which captures the current and uses that context to invoke the thread's delegate, /// explicitly avoids capturing the current context and flowing it to the invocation. /// -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public void UnsafeStart(object? parameter) => Start(parameter, captureContext: false); @@ -220,7 +220,7 @@ private void Start(object? parameter, bool captureContext, bool internalThread = /// Causes the operating system to change the state of the current instance to . /// The thread has already been started. /// There is not enough memory available to start this thread. -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public void Start() => Start(captureContext: true); @@ -232,7 +232,7 @@ private void Start(object? parameter, bool captureContext, bool internalThread = /// Unlike , which captures the current and uses that context to invoke the thread's delegate, /// explicitly avoids capturing the current context and flowing it to the invocation. /// -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public void UnsafeStart() => Start(captureContext: false); diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Unix.cs index 3c5888a6f80db..83faa720e3974 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Unix.cs @@ -16,7 +16,7 @@ public static partial class ThreadPool AppContextConfigHelper.GetBooleanConfig("System.Threading.ThreadPool.EnableWorkerTracking", "DOTNET_ThreadPool_EnableWorkerTracking"); #endif -#if !(TARGET_BROWSER && FEATURE_WASM_THREADS) +#if !(TARGET_BROWSER && FEATURE_WASM_MANAGED_THREADS) // Indicates whether the thread pool should yield the thread from the dispatch loop to the runtime periodically so that // the runtime may use the thread for processing other work. internal static bool YieldFromDispatchLoop => false; diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs index 9e4a2420c7edb..cc7c76922d996 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs @@ -1368,7 +1368,7 @@ public static partial class ThreadPool internal static bool EnableWorkerTracking => IsWorkerTrackingEnabledInConfig && EventSource.IsSupported; -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif [CLSCompliant(false)] @@ -1385,7 +1385,7 @@ public static RegisteredWaitHandle RegisterWaitForSingleObject( return RegisterWaitForSingleObject(waitObject, callBack, state, millisecondsTimeOutInterval, executeOnlyOnce, true); } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif [CLSCompliant(false)] @@ -1402,7 +1402,7 @@ public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( return RegisterWaitForSingleObject(waitObject, callBack, state, millisecondsTimeOutInterval, executeOnlyOnce, false); } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public static RegisteredWaitHandle RegisterWaitForSingleObject( @@ -1417,7 +1417,7 @@ public static RegisteredWaitHandle RegisterWaitForSingleObject( return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)millisecondsTimeOutInterval, executeOnlyOnce, true); } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( @@ -1432,7 +1432,7 @@ public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)millisecondsTimeOutInterval, executeOnlyOnce, false); } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public static RegisteredWaitHandle RegisterWaitForSingleObject( @@ -1448,7 +1448,7 @@ public static RegisteredWaitHandle RegisterWaitForSingleObject( return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)millisecondsTimeOutInterval, executeOnlyOnce, true); } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( @@ -1464,7 +1464,7 @@ public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)millisecondsTimeOutInterval, executeOnlyOnce, false); } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public static RegisteredWaitHandle RegisterWaitForSingleObject( @@ -1483,7 +1483,7 @@ bool executeOnlyOnce return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)tm, executeOnlyOnce, true); } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System.Runtime.InteropServices.JavaScript.csproj b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System.Runtime.InteropServices.JavaScript.csproj index 6a4b0af05c45b..9b20df8bd80e1 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System.Runtime.InteropServices.JavaScript.csproj +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System.Runtime.InteropServices.JavaScript.csproj @@ -11,10 +11,10 @@ $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) SR.SystemRuntimeInteropServicesJavaScript_PlatformNotSupported - true - true + true + true false - $(DefineConstants);FEATURE_WASM_THREADS + $(DefineConstants);FEATURE_WASM_MANAGED_THREADS $(DefineConstants);ENABLE_JS_INTEROP_BY_VALUE true @@ -64,12 +64,12 @@ - - + + - + diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/CancelablePromise.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/CancelablePromise.cs index aac9035997871..260a78f0c633c 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/CancelablePromise.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/CancelablePromise.cs @@ -22,7 +22,7 @@ public static void CancelPromise(Task promise) JSHostImplementation.PromiseHolder? holder = promise.AsyncState as JSHostImplementation.PromiseHolder; if (holder == null) throw new InvalidOperationException("Expected Task converted from JS Promise"); -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS if (holder.IsDisposed) { return; @@ -55,7 +55,7 @@ public static void CancelPromise(Task promise, Action callback, T state) JSHostImplementation.PromiseHolder? holder = promise.AsyncState as JSHostImplementation.PromiseHolder; if (holder == null) throw new InvalidOperationException("Expected Task converted from JS Promise"); -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS if (holder.IsDisposed) { return; diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Interop/JavaScriptExports.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Interop/JavaScriptExports.cs index aeb130a108f58..a329bf54eea82 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Interop/JavaScriptExports.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Interop/JavaScriptExports.cs @@ -26,7 +26,7 @@ public static void CallEntrypoint(JSMarshalerArgument* arguments_buffer) ref JSMarshalerArgument arg_2 = ref arguments_buffer[3]; // initialized and set by caller try { -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS // when we arrive here, we are on the thread which owns the proxies arg_exc.AssertCurrentThreadContext(); #endif @@ -108,7 +108,7 @@ public static void LoadLazyAssembly(JSMarshalerArgument* arguments_buffer) ref JSMarshalerArgument arg_2 = ref arguments_buffer[3]; try { -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS // when we arrive here, we are on the thread which owns the proxies arg_exc.AssertCurrentThreadContext(); #endif @@ -130,7 +130,7 @@ public static void LoadSatelliteAssembly(JSMarshalerArgument* arguments_buffer) ref JSMarshalerArgument arg_1 = ref arguments_buffer[2]; try { -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS // when we arrive here, we are on the thread which owns the proxies arg_exc.AssertCurrentThreadContext(); #endif @@ -178,7 +178,7 @@ public static void CallDelegate(JSMarshalerArgument* arguments_buffer) // arg_4 set by JS caller when there are arguments try { -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS // when we arrive here, we are on the thread which owns the proxies arg_exc.AssertCurrentThreadContext(); #endif @@ -215,7 +215,7 @@ public static void CompleteTask(JSMarshalerArgument* arguments_buffer) var ctx = arg_exc.AssertCurrentThreadContext(); var holder = ctx.GetPromiseHolder(arg_1.slot.GCHandle); -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS lock (ctx) { if (holder.Callback == null) @@ -274,7 +274,7 @@ public static void GetManagedStackTrace(JSMarshalerArgument* arguments_buffer) } } -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS // this is here temporarily, until JSWebWorker becomes public API [DynamicDependency(DynamicallyAccessedMemberTypes.NonPublicMethods, "System.Runtime.InteropServices.JavaScript.JSWebWorker", "System.Runtime.InteropServices.JavaScript")] diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Interop/JavaScriptImports.Generated.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Interop/JavaScriptImports.Generated.cs index 77716ab72c0c8..4ab7301e22b36 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Interop/JavaScriptImports.Generated.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Interop/JavaScriptImports.Generated.cs @@ -44,7 +44,7 @@ internal static unsafe partial class JavaScriptImports public static partial JSObject GetDotnetInstance(); [JSImport("INTERNAL.dynamic_import")] public static partial Task DynamicImport(string moduleName, string moduleUrl); -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS [JSImport("INTERNAL.thread_available")] public static partial Task ThreadAvailable(); #endif diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSException.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSException.cs index 1a9e2278d57ca..eede0b643a658 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSException.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSException.cs @@ -46,7 +46,7 @@ public override string? StackTrace return bs; } -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS if (!jsException.ProxyContext.IsCurrentThread()) { // if we are on another thread, it would be too expensive and risky to obtain lazy stack trace. diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSFunctionBinding.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSFunctionBinding.cs index 08619d5325df4..7c39d19df5027 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSFunctionBinding.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSFunctionBinding.cs @@ -202,7 +202,7 @@ internal static unsafe void InvokeJSFunction(JSObject jsFunction, Span arguments) { -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS var targetContext = JSProxyContext.SealJSImportCapturing(); arguments[0].slot.ContextHandle = targetContext.ContextHandle; arguments[1].slot.ContextHandle = targetContext.ContextHandle; @@ -280,7 +280,7 @@ internal static unsafe void InvokeJSImportImpl(JSFunctionBinding signature, Span arguments[1].slot.GCHandle = holder.GCHandle; } -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS // if we are on correct thread already or this is synchronous call, just call it if (targetContext.IsCurrentThread()) { @@ -324,7 +324,7 @@ internal static unsafe void InvokeJSImportCurrent(JSFunctionBinding signature, S { fixed (JSMarshalerArgument* args = arguments) { -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS Interop.Runtime.InvokeJSImportSync((nint)args, (nint)signature.Header); #else Interop.Runtime.InvokeJSImport(signature.ImportHandle, (nint)args); @@ -338,7 +338,7 @@ internal static unsafe void InvokeJSImportCurrent(JSFunctionBinding signature, S } } -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS #if !DEBUG [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -387,7 +387,7 @@ internal static unsafe JSFunctionBinding BindJSImportImpl(string functionName, s { var signature = JSHostImplementation.GetMethodSignature(signatures, functionName, moduleName); -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS Interop.Runtime.BindJSImport(signature.Header, out int isException, out object exceptionMessage); if (isException != 0) @@ -415,7 +415,7 @@ internal static unsafe JSFunctionBinding BindManagedFunctionImpl(string fullyQua return signature; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static unsafe void ResolveOrRejectPromise(Span arguments) { diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSHostImplementation.Types.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSHostImplementation.Types.cs index 8d4dd3e6a3e87..f093ffb0d8b2e 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSHostImplementation.Types.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSHostImplementation.Types.cs @@ -16,7 +16,7 @@ public sealed class PromiseHolder public ToManagedCallback? Callback; public JSProxyContext ProxyContext; public bool IsDisposed; -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS public ManualResetEventSlim? CallbackReady; #endif diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSHostImplementation.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSHostImplementation.cs index 361997414e6e7..3035781eb730f 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSHostImplementation.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSHostImplementation.cs @@ -147,7 +147,7 @@ public static unsafe JSFunctionBinding GetMethodSignature(ReadOnlySpan JSVHandleFreeList = new(); -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS private JSProxyContext() { } @@ -62,7 +62,7 @@ public JSProxyContext(bool isMainThread, JSSynchronizationContext synchronizatio #region Current operation context -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS public static readonly JSProxyContext MainThreadContext = new(); public static JSProxyContext CurrentThreadContext => MainThreadContext; public static JSProxyContext CurrentOperationContext => MainThreadContext; @@ -229,7 +229,7 @@ public static JSProxyContext CurrentOperationContext [MethodImpl(MethodImplOptions.AggressiveInlining)] public static JSProxyContext AssertIsInteropThread() { -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS var ctx = CurrentThreadContext; if (ctx == null) { @@ -436,7 +436,7 @@ public static void ReleaseCSOwnedObject(JSObject proxy, bool skipJS) return; } var ctx = proxy.ProxyContext; -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS if (!ctx.IsCurrentThread()) { throw new InvalidOperationException($"ReleaseCSOwnedObject has to run on the thread with same affinity as the proxy. ManagedThreadId: {Environment.CurrentManagedThreadId} JSHandle: {proxy.JSHandle}"); @@ -477,7 +477,7 @@ private void Dispose(bool disposing) { if (!_isDisposed) { -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS if (!IsCurrentThread()) { Environment.FailFast($"JSProxyContext must be disposed on the thread which owns it, ManagedThreadId: {Environment.CurrentManagedThreadId}. {Environment.NewLine} {Environment.StackTrace}"); @@ -494,7 +494,7 @@ private void Dispose(bool disposing) } } -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS Interop.Runtime.UninstallWebWorkerInterop(); #endif @@ -518,7 +518,7 @@ private void Dispose(bool disposing) if (disposing) { -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS SynchronizationContext.Dispose(); #endif } diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSSynchronizationContext.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSSynchronizationContext.cs index e6623cce82636..618be9bedf4e2 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSSynchronizationContext.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSSynchronizationContext.cs @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS using System.Threading; using System.Threading.Channels; diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSWebWorker.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSWebWorker.cs index ddbf5b8d619e5..27fe38e3f1991 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSWebWorker.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSWebWorker.cs @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS #pragma warning disable CA1416 diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Exception.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Exception.cs index d26d4e58dcadd..e526fe4b52c89 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Exception.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Exception.cs @@ -68,7 +68,7 @@ public unsafe void ToJS(Exception? value) { var jsException = jse.jsException; jsException.AssertNotDisposed(); -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS var ctx = jsException.ProxyContext; if (JSProxyContext.CapturingState == JSProxyContext.JSImportOperationState.JSImportParams) diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Func.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Func.cs index 3f713e1512885..271acab66bae0 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Func.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Func.cs @@ -23,7 +23,7 @@ public void InvokeJS() Span arguments = stackalloc JSMarshalerArgument[4]; ref JSMarshalerArgument args_exception = ref arguments[0]; ref JSMarshalerArgument args_return = ref arguments[1]; -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS args_exception.InitializeWithContext(JSObject.ProxyContext); args_return.InitializeWithContext(JSObject.ProxyContext); JSProxyContext.JSImportNoCapture(); @@ -56,7 +56,7 @@ public void InvokeJS(T arg1) ref JSMarshalerArgument args_return = ref arguments[1]; ref JSMarshalerArgument args_arg1 = ref arguments[2]; -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS args_exception.InitializeWithContext(JSObject.ProxyContext); args_return.InitializeWithContext(JSObject.ProxyContext); args_arg1.InitializeWithContext(JSObject.ProxyContext); @@ -94,7 +94,7 @@ public void InvokeJS(T1 arg1, T2 arg2) ref JSMarshalerArgument args_arg1 = ref arguments[2]; ref JSMarshalerArgument args_arg2 = ref arguments[3]; -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS args_exception.InitializeWithContext(JSObject.ProxyContext); args_return.InitializeWithContext(JSObject.ProxyContext); args_arg1.InitializeWithContext(JSObject.ProxyContext); @@ -137,7 +137,7 @@ public void InvokeJS(T1 arg1, T2 arg2, T3 arg3) ref JSMarshalerArgument args_arg2 = ref arguments[3]; ref JSMarshalerArgument args_arg3 = ref arguments[4]; -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS args_exception.InitializeWithContext(JSObject.ProxyContext); args_return.InitializeWithContext(JSObject.ProxyContext); args_arg1.InitializeWithContext(JSObject.ProxyContext); @@ -261,7 +261,7 @@ public TResult InvokeJS() Span arguments = stackalloc JSMarshalerArgument[4]; ref JSMarshalerArgument args_exception = ref arguments[0]; ref JSMarshalerArgument args_return = ref arguments[1]; -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS args_exception.InitializeWithContext(JSObject.ProxyContext); args_return.InitializeWithContext(JSObject.ProxyContext); JSProxyContext.JSImportNoCapture(); @@ -300,7 +300,7 @@ public TResult InvokeJS(T arg1) ref JSMarshalerArgument args_return = ref arguments[1]; ref JSMarshalerArgument args_arg1 = ref arguments[2]; -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS args_exception.InitializeWithContext(JSObject.ProxyContext); args_return.InitializeWithContext(JSObject.ProxyContext); args_arg1.InitializeWithContext(JSObject.ProxyContext); @@ -342,7 +342,7 @@ public TResult InvokeJS(T1 arg1, T2 arg2) ref JSMarshalerArgument args_arg1 = ref arguments[2]; ref JSMarshalerArgument args_arg2 = ref arguments[3]; -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS args_exception.InitializeWithContext(JSObject.ProxyContext); args_return.InitializeWithContext(JSObject.ProxyContext); args_arg1.InitializeWithContext(JSObject.ProxyContext); @@ -389,7 +389,7 @@ public TResult InvokeJS(T1 arg1, T2 arg2, T3 arg3) ref JSMarshalerArgument args_arg2 = ref arguments[3]; ref JSMarshalerArgument args_arg3 = ref arguments[4]; -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS args_exception.InitializeWithContext(JSObject.ProxyContext); args_return.InitializeWithContext(JSObject.ProxyContext); args_arg1.InitializeWithContext(JSObject.ProxyContext); diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.JSObject.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.JSObject.cs index 7a1d8a2695e55..7eb4440c565d6 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.JSObject.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.JSObject.cs @@ -41,7 +41,7 @@ public void ToJS(JSObject? value) else { value.AssertNotDisposed(); -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS var ctx = value.ProxyContext; if (JSProxyContext.CapturingState == JSProxyContext.JSImportOperationState.JSImportParams) diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Task.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Task.cs index d00636cbbfea7..b4ebf1b115dae 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Task.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Marshaling/JSMarshalerArgument.Task.cs @@ -74,7 +74,7 @@ public unsafe void ToManaged(out Task? value) }; holder.Callback = callback; value = tcs.Task; -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS // if the other thread created it, signal that it's ready holder.CallbackReady?.Set(); #endif @@ -128,7 +128,7 @@ public unsafe void ToManaged(out Task? value, ArgumentToManagedCallback }; holder.Callback = callback; value = tcs.Task; -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS // if the other thread created it, signal that it's ready holder.CallbackReady?.Set(); #endif @@ -188,7 +188,7 @@ internal void ToJSDynamic(Task? value) var taskHolder = ctx.CreateCSOwnedProxy(slot.JSHandle); -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS task.ContinueWith(Complete, taskHolder, TaskScheduler.FromCurrentSynchronizationContext()); #else task.ContinueWith(Complete, taskHolder, TaskScheduler.Current); @@ -268,7 +268,7 @@ public void ToJS(Task? value) var taskHolder = ctx.CreateCSOwnedProxy(slot.JSHandle); -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS task.ContinueWith(Complete, taskHolder, TaskScheduler.FromCurrentSynchronizationContext()); #else task.ContinueWith(Complete, taskHolder, TaskScheduler.Current); @@ -340,7 +340,7 @@ public void ToJS(Task? value, ArgumentToJSCallback marshaler) var taskHolder = ctx.CreateCSOwnedProxy(slot.JSHandle); -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS task.ContinueWith(Complete, new HolderAndMarshaler(taskHolder, marshaler), TaskScheduler.FromCurrentSynchronizationContext()); #else task.ContinueWith(Complete, new HolderAndMarshaler(taskHolder, marshaler), TaskScheduler.Current); @@ -373,7 +373,7 @@ private static void RejectPromise(JSObject holder, Exception ex) ref JSMarshalerArgument arg_handle = ref args[2]; ref JSMarshalerArgument arg_value = ref args[3]; -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS exc.InitializeWithContext(holder.ProxyContext); res.InitializeWithContext(holder.ProxyContext); arg_value.InitializeWithContext(holder.ProxyContext); @@ -394,7 +394,7 @@ private static void RejectPromise(JSObject holder, Exception ex) // we can free the JSHandle here and the holder.resolve_or_reject will do the rest holder.DisposeImpl(skipJsCleanup: true); -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS // order of operations with DisposeImpl matters JSFunctionBinding.ResolveOrRejectPromise(args); #else @@ -413,7 +413,7 @@ private static void ResolveVoidPromise(JSObject holder) ref JSMarshalerArgument arg_handle = ref args[2]; ref JSMarshalerArgument arg_value = ref args[3]; -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS exc.InitializeWithContext(holder.ProxyContext); res.InitializeWithContext(holder.ProxyContext); arg_value.InitializeWithContext(holder.ProxyContext); @@ -433,7 +433,7 @@ private static void ResolveVoidPromise(JSObject holder) // we can free the JSHandle here and the holder.resolve_or_reject will do the rest holder.DisposeImpl(skipJsCleanup: true); -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS // order of operations with DisposeImpl matters JSFunctionBinding.ResolveOrRejectPromise(args); #else @@ -452,7 +452,7 @@ private static void ResolvePromise(JSObject holder, T value, ArgumentToJSCall ref JSMarshalerArgument arg_handle = ref args[2]; ref JSMarshalerArgument arg_value = ref args[3]; -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS exc.InitializeWithContext(holder.ProxyContext); res.InitializeWithContext(holder.ProxyContext); arg_value.InitializeWithContext(holder.ProxyContext); @@ -473,7 +473,7 @@ private static void ResolvePromise(JSObject holder, T value, ArgumentToJSCall // we can free the JSHandle here and the holder.resolve_or_reject will do the rest holder.DisposeImpl(skipJsCleanup: true); -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS // order of operations with DisposeImpl matters JSFunctionBinding.ResolveOrRejectPromise(args); #else diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System.Runtime.InteropServices.JavaScript.Tests.csproj b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System.Runtime.InteropServices.JavaScript.Tests.csproj index e49a2bb455a50..84ed7cc71c176 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System.Runtime.InteropServices.JavaScript.Tests.csproj +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System.Runtime.InteropServices.JavaScript.Tests.csproj @@ -8,8 +8,8 @@ $(WasmXHarnessArgs) --engine-arg=--expose-gc --web-server-use-cop true true - true - $(DefineConstants);FEATURE_WASM_THREADS + true + $(DefineConstants);FEATURE_WASM_MANAGED_THREADS true @@ -38,12 +38,12 @@ - + - + diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JSImportExportTest.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JSImportExportTest.cs index e7e058e120fb4..bd76d9e80f8fd 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JSImportExportTest.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JSImportExportTest.cs @@ -36,7 +36,7 @@ public async Task MultipleImportAsync() instance1.Dispose(); } -#if !FEATURE_WASM_THREADS // because in MT JSHost.ImportAsync is really async, it will finish before the caller could cancel it +#if !FEATURE_WASM_MANAGED_THREADS // because in MT JSHost.ImportAsync is really async, it will finish before the caller could cancel it [Fact] public async Task CancelableImportAsync() { @@ -185,7 +185,7 @@ public unsafe void CreateFunctionDoubleThrow() var ex = Assert.Throws(() => doubleThrows(1, 2)); Assert.Equal("Error: test 1 2", ex.Message); -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS Assert.Contains("create_function", ex.StackTrace); #else Assert.Contains("omitted JavaScript stack trace", ex.StackTrace); @@ -2004,7 +2004,7 @@ public void JsImportMath() var exThrow0 = Assert.Throws(() => JavaScriptTestHelper.throw0()); Assert.Contains("throw-0-msg", exThrow0.Message); Assert.DoesNotContain(" at ", exThrow0.Message); -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS Assert.Contains("throw0fn", exThrow0.StackTrace); #else Assert.Contains("omitted JavaScript stack trace", exThrow0.StackTrace); @@ -2013,7 +2013,7 @@ public void JsImportMath() var exThrow1 = Assert.Throws(() => throw1(value)); Assert.Contains("throw1-msg", exThrow1.Message); Assert.DoesNotContain(" at ", exThrow1.Message); -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS Assert.Contains("throw1fn", exThrow1.StackTrace); #else Assert.Contains("omitted JavaScript stack trace", exThrow0.StackTrace); diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JavaScriptTestHelper.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JavaScriptTestHelper.cs index d3e63213078ad..bfd645039b56c 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JavaScriptTestHelper.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JavaScriptTestHelper.cs @@ -1003,7 +1003,7 @@ public static async Task InitializeAsync() await Setup(); } -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS // are we in the UI thread ? if (Environment.CurrentManagedThreadId == 1) #endif diff --git a/src/libraries/System.Threading.Tasks.Parallel/src/System.Threading.Tasks.Parallel.csproj b/src/libraries/System.Threading.Tasks.Parallel/src/System.Threading.Tasks.Parallel.csproj index 6332041eb43ff..3278b9f2c5e19 100644 --- a/src/libraries/System.Threading.Tasks.Parallel/src/System.Threading.Tasks.Parallel.csproj +++ b/src/libraries/System.Threading.Tasks.Parallel/src/System.Threading.Tasks.Parallel.csproj @@ -1,15 +1,15 @@ - $(NetCoreAppCurrent) - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-browser + $(NetCoreAppCurrent) + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-browser true false $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) - true - $(DefineConstants);FEATURE_WASM_THREADS + true + $(DefineConstants);FEATURE_WASM_MANAGED_THREADS diff --git a/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.cs b/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.cs index d7bca6aa99642..7a466d0501c2a 100644 --- a/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.cs +++ b/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.cs @@ -238,7 +238,7 @@ public static void Invoke(ParallelOptions parallelOptions, params Action[] actio { // If we've gotten this far, it's time to process the actions. -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS // Web browsers need special treatment that is implemented in TaskReplicator if (OperatingSystem.IsBrowser() || #else diff --git a/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/TaskReplicator.cs b/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/TaskReplicator.cs index eb09ba672f423..0239770284e4a 100644 --- a/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/TaskReplicator.cs +++ b/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/TaskReplicator.cs @@ -131,7 +131,7 @@ public static void Run(ReplicatableUserAction action, ParallelOp { // Browser hosts do not support synchronous Wait so we want to run the // replicated task directly instead of going through Task infrastructure -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS if (OperatingSystem.IsBrowser()) { // Since we are running on a single thread, we don't want the action to time out diff --git a/src/libraries/System.Threading.Thread.WebAssembly.Threading/ref/System.Threading.Thread.WebAssembly.Threading.csproj b/src/libraries/System.Threading.Thread.WebAssembly.Threading/ref/System.Threading.Thread.WebAssembly.Threading.csproj index ef7dc37aac2bb..074ca5b7f7ede 100644 --- a/src/libraries/System.Threading.Thread.WebAssembly.Threading/ref/System.Threading.Thread.WebAssembly.Threading.csproj +++ b/src/libraries/System.Threading.Thread.WebAssembly.Threading/ref/System.Threading.Thread.WebAssembly.Threading.csproj @@ -2,7 +2,7 @@ $(NetCoreAppCurrent) - true + true System.Threading.Thread true @@ -11,7 +11,7 @@ false Microsoft true - $(DefineConstants);FEATURE_WASM_THREADS + $(DefineConstants);FEATURE_WASM_MANAGED_THREADS diff --git a/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.cs b/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.cs index 6e90254a45f55..c4c038036ce34 100644 --- a/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.cs +++ b/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.cs @@ -91,22 +91,22 @@ public static void SetData(System.LocalDataStoreSlot slot, object? data) { } public static void Sleep(int millisecondsTimeout) { } public static void Sleep(System.TimeSpan timeout) { } public static void SpinWait(int iterations) { } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public void Start() { } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public void Start(object? parameter) { } [System.ObsoleteAttribute("Thread.Suspend has been deprecated. Use other classes in System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources.")] public void Suspend() { } public bool TrySetApartmentState(System.Threading.ApartmentState state) { throw null; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public void UnsafeStart() { } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public void UnsafeStart(object? parameter) { } diff --git a/src/libraries/System.Threading.Thread/src/System.Threading.Thread.csproj b/src/libraries/System.Threading.Thread/src/System.Threading.Thread.csproj index 5c984561dcba9..49050cfbf62e8 100644 --- a/src/libraries/System.Threading.Thread/src/System.Threading.Thread.csproj +++ b/src/libraries/System.Threading.Thread/src/System.Threading.Thread.csproj @@ -6,7 +6,7 @@ false - + diff --git a/src/libraries/System.Threading.ThreadPool.WebAssembly.Threading/ref/System.Threading.ThreadPool.WebAssembly.Threading.csproj b/src/libraries/System.Threading.ThreadPool.WebAssembly.Threading/ref/System.Threading.ThreadPool.WebAssembly.Threading.csproj index b7721040498a2..a354d46a0a98b 100644 --- a/src/libraries/System.Threading.ThreadPool.WebAssembly.Threading/ref/System.Threading.ThreadPool.WebAssembly.Threading.csproj +++ b/src/libraries/System.Threading.ThreadPool.WebAssembly.Threading/ref/System.Threading.ThreadPool.WebAssembly.Threading.csproj @@ -3,14 +3,14 @@ System.Threading.ThreadPool true $(NetCoreAppCurrent) - true + true true false Microsoft true - $(DefineConstants);FEATURE_WASM_THREADS + $(DefineConstants);FEATURE_WASM_MANAGED_THREADS diff --git a/src/libraries/System.Threading.ThreadPool/ref/System.Threading.ThreadPool.cs b/src/libraries/System.Threading.ThreadPool/ref/System.Threading.ThreadPool.cs index 20ca9318b980c..5ff1eb3924e8e 100644 --- a/src/libraries/System.Threading.ThreadPool/ref/System.Threading.ThreadPool.cs +++ b/src/libraries/System.Threading.ThreadPool/ref/System.Threading.ThreadPool.cs @@ -10,7 +10,7 @@ public partial interface IThreadPoolWorkItem { void Execute(); } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public sealed partial class RegisteredWaitHandle : System.MarshalByRefObject @@ -34,20 +34,20 @@ public static partial class ThreadPool public static bool QueueUserWorkItem(System.Threading.WaitCallback callBack) { throw null; } public static bool QueueUserWorkItem(System.Threading.WaitCallback callBack, object? state) { throw null; } public static bool QueueUserWorkItem(System.Action callBack, TState state, bool preferLocal) { throw null; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public static System.Threading.RegisteredWaitHandle RegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, int millisecondsTimeOutInterval, bool executeOnlyOnce) { throw null; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public static System.Threading.RegisteredWaitHandle RegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, long millisecondsTimeOutInterval, bool executeOnlyOnce) { throw null; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public static System.Threading.RegisteredWaitHandle RegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, System.TimeSpan timeout, bool executeOnlyOnce) { throw null; } [System.CLSCompliantAttribute(false)] -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public static System.Threading.RegisteredWaitHandle RegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, uint millisecondsTimeOutInterval, bool executeOnlyOnce) { throw null; } @@ -59,20 +59,20 @@ public static partial class ThreadPool public static bool UnsafeQueueUserWorkItem(System.Threading.IThreadPoolWorkItem callBack, bool preferLocal) { throw null; } public static bool UnsafeQueueUserWorkItem(System.Threading.WaitCallback callBack, object? state) { throw null; } public static bool UnsafeQueueUserWorkItem(System.Action callBack, TState state, bool preferLocal) { throw null; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, int millisecondsTimeOutInterval, bool executeOnlyOnce) { throw null; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, long millisecondsTimeOutInterval, bool executeOnlyOnce) { throw null; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, System.TimeSpan timeout, bool executeOnlyOnce) { throw null; } [System.CLSCompliantAttribute(false)] -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public static System.Threading.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(System.Threading.WaitHandle waitObject, System.Threading.WaitOrTimerCallback callBack, object? state, uint millisecondsTimeOutInterval, bool executeOnlyOnce) { throw null; } diff --git a/src/libraries/System.Threading.ThreadPool/ref/System.Threading.ThreadPool.csproj b/src/libraries/System.Threading.ThreadPool/ref/System.Threading.ThreadPool.csproj index 4c918c153ba69..5c55020cf70bc 100644 --- a/src/libraries/System.Threading.ThreadPool/ref/System.Threading.ThreadPool.csproj +++ b/src/libraries/System.Threading.ThreadPool/ref/System.Threading.ThreadPool.csproj @@ -2,7 +2,7 @@ $(NetCoreAppCurrent) true - $(DefineConstants);FEATURE_WASM_THREADS + $(DefineConstants);FEATURE_WASM_MANAGED_THREADS diff --git a/src/libraries/System.Threading.ThreadPool/src/System.Threading.ThreadPool.csproj b/src/libraries/System.Threading.ThreadPool/src/System.Threading.ThreadPool.csproj index f169f57631d94..d2b6942f141a9 100644 --- a/src/libraries/System.Threading.ThreadPool/src/System.Threading.ThreadPool.csproj +++ b/src/libraries/System.Threading.ThreadPool/src/System.Threading.ThreadPool.csproj @@ -6,7 +6,7 @@ false - + diff --git a/src/libraries/System.Threading.WebAssembly.Threading/ref/System.Threading.WebAssembly.Threading.csproj b/src/libraries/System.Threading.WebAssembly.Threading/ref/System.Threading.WebAssembly.Threading.csproj index b4d819a041fee..63dec7d5e54c2 100644 --- a/src/libraries/System.Threading.WebAssembly.Threading/ref/System.Threading.WebAssembly.Threading.csproj +++ b/src/libraries/System.Threading.WebAssembly.Threading/ref/System.Threading.WebAssembly.Threading.csproj @@ -2,7 +2,7 @@ $(NetCoreAppCurrent) - true + true System.Threading true @@ -11,7 +11,7 @@ false Microsoft true - $(DefineConstants);FEATURE_WASM_THREADS + $(DefineConstants);FEATURE_WASM_MANAGED_THREADS diff --git a/src/libraries/System.Threading/ref/System.Threading.cs b/src/libraries/System.Threading/ref/System.Threading.cs index 104d2e925c261..74743e946890c 100644 --- a/src/libraries/System.Threading/ref/System.Threading.cs +++ b/src/libraries/System.Threading/ref/System.Threading.cs @@ -14,11 +14,11 @@ public Barrier(int participantCount, System.Action? po public long CurrentPhaseNumber { get { throw null; } } public int ParticipantCount { get { throw null; } } public int ParticipantsRemaining { get { throw null; } } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public long AddParticipant() { throw null; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public long AddParticipants(int participantCount) { throw null; } @@ -26,27 +26,27 @@ public void Dispose() { } protected virtual void Dispose(bool disposing) { } public void RemoveParticipant() { } public void RemoveParticipants(int participantCount) { } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public void SignalAndWait() { } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public bool SignalAndWait(int millisecondsTimeout) { throw null; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public bool SignalAndWait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) { throw null; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public void SignalAndWait(System.Threading.CancellationToken cancellationToken) { } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public bool SignalAndWait(System.TimeSpan timeout) { throw null; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public bool SignalAndWait(System.TimeSpan timeout, System.Threading.CancellationToken cancellationToken) { throw null; } @@ -78,27 +78,27 @@ public void Reset(int count) { } public bool Signal(int signalCount) { throw null; } public bool TryAddCount() { throw null; } public bool TryAddCount(int signalCount) { throw null; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public void Wait() { } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public bool Wait(int millisecondsTimeout) { throw null; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public bool Wait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) { throw null; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public void Wait(System.Threading.CancellationToken cancellationToken) { } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public bool Wait(System.TimeSpan timeout) { throw null; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public bool Wait(System.TimeSpan timeout, System.Threading.CancellationToken cancellationToken) { throw null; } @@ -353,27 +353,27 @@ public void Dispose() { } protected virtual void Dispose(bool disposing) { } public void Reset() { } public void Set() { } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public void Wait() { } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public bool Wait(int millisecondsTimeout) { throw null; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public bool Wait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) { throw null; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public void Wait(System.Threading.CancellationToken cancellationToken) { } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public bool Wait(System.TimeSpan timeout) { throw null; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public bool Wait(System.TimeSpan timeout, System.Threading.CancellationToken cancellationToken) { throw null; } @@ -393,23 +393,23 @@ public static void TryEnter(object obj, ref bool lockTaken) { } public static void TryEnter(object obj, int millisecondsTimeout, ref bool lockTaken) { } public static bool TryEnter(object obj, System.TimeSpan timeout) { throw null; } public static void TryEnter(object obj, System.TimeSpan timeout, ref bool lockTaken) { } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public static bool Wait(object obj) { throw null; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public static bool Wait(object obj, int millisecondsTimeout) { throw null; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public static bool Wait(object obj, int millisecondsTimeout, bool exitContext) { throw null; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public static bool Wait(object obj, System.TimeSpan timeout) { throw null; } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] #endif public static bool Wait(object obj, System.TimeSpan timeout, bool exitContext) { throw null; } diff --git a/src/libraries/System.Threading/src/System.Threading.csproj b/src/libraries/System.Threading/src/System.Threading.csproj index 9dd69f0835fb4..e09ac58c61c41 100644 --- a/src/libraries/System.Threading/src/System.Threading.csproj +++ b/src/libraries/System.Threading/src/System.Threading.csproj @@ -6,8 +6,8 @@ true true false - true - $(DefineConstants);FEATURE_WASM_THREADS + true + $(DefineConstants);FEATURE_WASM_MANAGED_THREADS @@ -25,7 +25,7 @@ - + diff --git a/src/libraries/System.Threading/src/System/Threading/Barrier.cs b/src/libraries/System.Threading/src/System/Threading/Barrier.cs index c1f35c961184a..e5cd44e77fe9f 100644 --- a/src/libraries/System.Threading/src/System/Threading/Barrier.cs +++ b/src/libraries/System.Threading/src/System/Threading/Barrier.cs @@ -284,7 +284,7 @@ private bool SetCurrentTotal(int currentTotal, int current, int total, bool sens /// /// The current instance has already been /// disposed. -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public long AddParticipant() @@ -315,7 +315,7 @@ public long AddParticipant() /// /// The current instance has already been /// disposed. -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public long AddParticipants(int participantCount) @@ -475,7 +475,7 @@ public void RemoveParticipants(int participantCount) /// /// The current instance has already been /// disposed. -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public void SignalAndWait() @@ -498,7 +498,7 @@ public void SignalAndWait() /// canceled. /// The current instance has already been /// disposed. -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public void SignalAndWait(CancellationToken cancellationToken) @@ -530,7 +530,7 @@ public void SignalAndWait(CancellationToken cancellationToken) /// /// The current instance has already been /// disposed. -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public bool SignalAndWait(TimeSpan timeout) @@ -560,7 +560,7 @@ public bool SignalAndWait(TimeSpan timeout) /// canceled. /// The current instance has already been /// disposed. -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public bool SignalAndWait(TimeSpan timeout, CancellationToken cancellationToken) @@ -590,7 +590,7 @@ public bool SignalAndWait(TimeSpan timeout, CancellationToken cancellationToken) /// /// The current instance has already been /// disposed. -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public bool SignalAndWait(int millisecondsTimeout) @@ -619,7 +619,7 @@ public bool SignalAndWait(int millisecondsTimeout) /// canceled. /// The current instance has already been /// disposed. -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public bool SignalAndWait(int millisecondsTimeout, CancellationToken cancellationToken) @@ -861,7 +861,7 @@ private void WaitCurrentPhase(ManualResetEventSlim currentPhaseEvent, long obser /// cancellation token passed to SignalAndWait /// The current phase number for this thread /// True if the event is set or the phase number changed, false if the timeout expired -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif private bool DiscontinuousWait(ManualResetEventSlim currentPhaseEvent, int totalTimeout, CancellationToken token, long observedPhase) diff --git a/src/libraries/System.Threading/src/System/Threading/CountdownEvent.cs b/src/libraries/System.Threading/src/System/Threading/CountdownEvent.cs index 81afcb5d5e574..837be45812ac3 100644 --- a/src/libraries/System.Threading/src/System/Threading/CountdownEvent.cs +++ b/src/libraries/System.Threading/src/System/Threading/CountdownEvent.cs @@ -403,7 +403,7 @@ public void Reset(int count) /// /// The current instance has already been /// disposed. -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public void Wait() @@ -429,7 +429,7 @@ public void Wait() /// canceled. /// The current instance has already been /// disposed. -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public void Wait(CancellationToken cancellationToken) @@ -451,7 +451,7 @@ public void Wait(CancellationToken cancellationToken) /// than . /// The current instance has already been /// disposed. -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public bool Wait(TimeSpan timeout) @@ -482,7 +482,7 @@ public bool Wait(TimeSpan timeout) /// disposed. /// has /// been canceled. -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public bool Wait(TimeSpan timeout, CancellationToken cancellationToken) @@ -506,7 +506,7 @@ public bool Wait(TimeSpan timeout, CancellationToken cancellationToken) /// negative number other than -1, which represents an infinite time-out. /// The current instance has already been /// disposed. -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public bool Wait(int millisecondsTimeout) @@ -531,7 +531,7 @@ public bool Wait(int millisecondsTimeout) /// disposed. /// has /// been canceled. -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken) diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 6ac9ab572f03b..6a141a45afb9b 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -57,12 +57,12 @@ - + - + @@ -404,7 +404,7 @@ - + @@ -609,7 +609,7 @@ - + diff --git a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj index 4a76a29fce632..cf157fee87514 100644 --- a/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/mono/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -13,8 +13,8 @@ x64;x86;arm;armv6;arm64;riscv64;s390x;wasm;ppc64le true - true - $(DefineConstants);FEATURE_WASM_THREADS + true + $(DefineConstants);FEATURE_WASM_MANAGED_THREADS @@ -122,10 +122,10 @@ $(DefineConstants);MONO_FEATURE_SRE true - true - true - true - true + true + true + true + true true true @@ -133,7 +133,7 @@ $(DefineConstants);FEATURE_PERFTRACING $(DefineConstants);FEATURE_OBJCMARSHAL - $(DefineConstants);FEATURE_WASM_THREADS + $(DefineConstants);FEATURE_WASM_MANAGED_THREADS $(DefineConstants);FEATURE_WASM_PERFTRACING @@ -274,7 +274,7 @@ - + @@ -282,7 +282,7 @@ - + diff --git a/src/mono/System.Private.CoreLib/src/System/Threading/Monitor.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Threading/Monitor.Mono.cs index 78038d8769e4c..393c33d83d9f4 100644 --- a/src/mono/System.Private.CoreLib/src/System/Threading/Monitor.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Threading/Monitor.Mono.cs @@ -9,7 +9,7 @@ namespace System.Threading { public static partial class Monitor { -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS [ThreadStatic] public static bool ThrowOnBlockingWaitOnJSInteropThread; #endif @@ -76,13 +76,13 @@ public static bool IsEntered(object obj) return ObjectHeader.IsEntered(obj); } -#if !FEATURE_WASM_THREADS +#if !FEATURE_WASM_MANAGED_THREADS [UnsupportedOSPlatform("browser")] #endif public static bool Wait(object obj, int millisecondsTimeout) { ArgumentNullException.ThrowIfNull(obj); -#if FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS if (ThrowOnBlockingWaitOnJSInteropThread) { throw new PlatformNotSupportedException("blocking Wait is not supported on the JS interop threads."); diff --git a/src/mono/System.Private.CoreLib/src/System/Threading/ThreadPool.Browser.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Threading/ThreadPool.Browser.Mono.cs index a6690cea44a27..c707dd3506334 100644 --- a/src/mono/System.Private.CoreLib/src/System/Threading/ThreadPool.Browser.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Threading/ThreadPool.Browser.Mono.cs @@ -13,8 +13,8 @@ namespace System.Threading { -#if FEATURE_WASM_THREADS -#error when compiled with FEATURE_WASM_THREADS, we use PortableThreadPool.WorkerThread.Browser.Threads.Mono.cs +#if FEATURE_WASM_MANAGED_THREADS +#error when compiled with FEATURE_WASM_MANAGED_THREADS, we use PortableThreadPool.WorkerThread.Browser.Threads.Mono.cs #endif [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public sealed class RegisteredWaitHandle : MarshalByRefObject diff --git a/src/mono/System.Private.CoreLib/src/System/Threading/ThreadPool.Wasi.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Threading/ThreadPool.Wasi.Mono.cs index 68a4844de5d3d..557020c913efd 100644 --- a/src/mono/System.Private.CoreLib/src/System/Threading/ThreadPool.Wasi.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Threading/ThreadPool.Wasi.Mono.cs @@ -13,8 +13,8 @@ namespace System.Threading { -#if FEATURE_WASM_THREADS -#error when compiled with FEATURE_WASM_THREADS +#if FEATURE_WASM_MANAGED_THREADS +#error when compiled with FEATURE_WASM_MANAGED_THREADS #endif [System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")] public sealed class RegisteredWaitHandle : MarshalByRefObject diff --git a/src/mono/browser/browser.proj b/src/mono/browser/browser.proj index 3d8cc6b3306c9..3dbbe29d085be 100644 --- a/src/mono/browser/browser.proj +++ b/src/mono/browser/browser.proj @@ -16,17 +16,16 @@ - true false true - $([MSBuild]::NormalizeDirectory('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'lib')) - $([MSBuild]::NormalizeDirectory('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'lib')) + $([MSBuild]::NormalizeDirectory('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'lib')) + $([MSBuild]::NormalizeDirectory('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'lib')) true true - true + true false false emcc @@ -255,10 +254,10 @@ - + - + @@ -271,10 +270,10 @@ <_EmccLinkFlags Include="-s INITIAL_MEMORY=$(EmccInitialHeapSize)" /> <_EmccLinkFlags Include="-s STACK_SIZE=$(EmccStackSize)" /> - <_EmccCommonFlags Condition="'$(MonoWasmThreads)' == 'true'" Include="-s USE_PTHREADS=1" /> - <_EmccLinkFlags Condition="'$(MonoWasmThreads)' == 'true'" Include="-Wno-pthreads-mem-growth" /> - <_EmccLinkFlags Condition="'$(MonoWasmThreads)' == 'true'" Include="-s PTHREAD_POOL_SIZE=0" /> - <_EmccLinkFlags Condition="'$(MonoWasmThreads)' == 'true'" Include="-s PTHREAD_POOL_SIZE_STRICT=0" /> + <_EmccCommonFlags Condition="'$(WasmEnableThreads)' == 'true'" Include="-s USE_PTHREADS=1" /> + <_EmccLinkFlags Condition="'$(WasmEnableThreads)' == 'true'" Include="-Wno-pthreads-mem-growth" /> + <_EmccLinkFlags Condition="'$(WasmEnableThreads)' == 'true'" Include="-s PTHREAD_POOL_SIZE=0" /> + <_EmccLinkFlags Condition="'$(WasmEnableThreads)' == 'true'" Include="-s PTHREAD_POOL_SIZE_STRICT=0" /> <_EmccLinkFlags Include="-s ALLOW_MEMORY_GROWTH=1" /> <_EmccLinkFlags Include="-s ALLOW_TABLE_GROWTH=1" /> @@ -294,7 +293,7 @@ <_EmccLinkFlags Include="-Wno-limited-postlink-optimizations"/> - + @@ -373,7 +372,7 @@ $(CMakeConfigurationLinkFlags) -s EXPORT_ES6=1 -lexports.js $(CMakeConfigurationLinkFlags) -msimd128 - $(CMakeConfigurationLinkFlags) -Wno-pthreads-mem-growth + $(CMakeConfigurationLinkFlags) -Wno-pthreads-mem-growth $(CMakeConfigurationLinkFlags) --emit-symbol-map -DEMSDK_PATH="$(EMSDK_PATH.TrimEnd('\/').Replace('\','/'))" @@ -390,7 +389,7 @@ $(CMakeBuildRuntimeConfigureCmd) -DNATIVE_BIN_DIR="$(NativeBinDir.TrimEnd('\/').Replace('\','/'))" $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_COMPILE_OPTIONS="-msimd128" -DCONFIGURATION_INTERPSIMDTABLES_LIB="simd" $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_INTERPSIMDTABLES_LIB="nosimd" - $(CMakeBuildRuntimeConfigureCmd) -DDISABLE_THREADS=0 + $(CMakeBuildRuntimeConfigureCmd) -DDISABLE_THREADS=0 $(CMakeBuildRuntimeConfigureCmd) -DENABLE_JS_INTEROP_BY_VALUE=1 $(CMakeBuildRuntimeConfigureCmd) $(CMakeConfigurationEmsdkPath) @@ -539,7 +538,7 @@ <_MonoRollupEnvironmentVariable Include="NativeBinDir:$(NativeBinDir)" /> <_MonoRollupEnvironmentVariable Include="WasmObjDir:$(WasmObjDir)" /> <_MonoRollupEnvironmentVariable Include="ProductVersion:$(ProductVersion)" /> - <_MonoRollupEnvironmentVariable Include="MonoWasmThreads:$(MonoWasmThreads)" /> + <_MonoRollupEnvironmentVariable Include="WasmEnableThreads:$(WasmEnableThreads)" /> <_MonoRollupEnvironmentVariable Include="WASM_ENABLE_SIMD:1" Condition="'$(WasmEnableSIMD)' != 'false'" /> <_MonoRollupEnvironmentVariable Include="WASM_ENABLE_SIMD:0" Condition="'$(WasmEnableSIMD)' == 'false'" /> <_MonoRollupEnvironmentVariable Include="WASM_ENABLE_EH:1" Condition="'$(WasmEnableExceptionHandling)' != 'false'" /> @@ -562,7 +561,7 @@ + `WasmEnableThreads` property is changed between builds by a developer. --> - true + true false @@ -120,7 +120,6 @@ Condition="'$(WasmGenerateAppBundle)' == 'true'"> - <_WasmAppIncludeThreadsWorker Condition="'$(WasmEnableThreads)' == 'true' or '$(MonoWasmBuildVariant)' == 'multithread'">true <_WasmPThreadPoolSize Condition="'$(_WasmPThreadPoolSize)' == ''">-1 @@ -148,7 +147,7 @@ ExtraConfig="@(WasmExtraConfig)" NativeAssets="@(WasmNativeAsset)" DebugLevel="$(WasmDebugLevel)" - IncludeThreadsWorker="$(_WasmAppIncludeThreadsWorker)" + IncludeThreadsWorker="$(WasmEnableThreads)" PThreadPoolSize="$(_WasmPThreadPoolSize)" UseWebcil="$(WasmEnableWebcil)" WasmIncludeFullIcuData="$(WasmIncludeFullIcuData)" diff --git a/src/mono/browser/build/WasmApp.InTree.props b/src/mono/browser/build/WasmApp.InTree.props index 4e56c8fe5e5c6..951aeca06948e 100644 --- a/src/mono/browser/build/WasmApp.InTree.props +++ b/src/mono/browser/build/WasmApp.InTree.props @@ -29,7 +29,7 @@ <_MonoRuntimeComponentDontLink Include="libmono-component-debugger-stub-static.a" /> - <_MonoRuntimeComponentDontLink Include="libmono-component-diagnostics_tracing-static.a" Condition="'$(FeatureWasmPerfTracing)' != 'true' and $(FeatureWasmThreads) != 'true'"/> + <_MonoRuntimeComponentDontLink Include="libmono-component-diagnostics_tracing-static.a" Condition="'$(FeatureWasmPerfTracing)' != 'true' and $(FeatureWasmManagedThreads) != 'true'"/> <_MonoRuntimeComponentDontLink Include="libmono-component-hot_reload-stub-static.a" /> <_MonoRuntimeComponentDontLink Include="libmono-component-marshal-ilgen-stub-static.a" /> diff --git a/src/mono/browser/debugger/Wasm.Debugger.Tests/Wasm.Debugger.Tests.csproj b/src/mono/browser/debugger/Wasm.Debugger.Tests/Wasm.Debugger.Tests.csproj index 6c2ce61fee7c0..a06a731fc7be9 100644 --- a/src/mono/browser/debugger/Wasm.Debugger.Tests/Wasm.Debugger.Tests.csproj +++ b/src/mono/browser/debugger/Wasm.Debugger.Tests/Wasm.Debugger.Tests.csproj @@ -70,7 +70,7 @@ <_DotnetCommand Condition="'$(OS)' == 'Windows_NT'">dotnet.exe $(_DotnetCommand) test DebuggerTestSuite/DebuggerTestSuite.dll - $(RunScriptCommand) /e:WASM_TESTS_USING_VARIANT=multithreaded + $(RunScriptCommand) /e:WASM_TESTS_USING_VARIANT=multithreaded $(RunScriptCommand) "-l:trx%3BLogFileName=testResults.trx" $(RunScriptCommand) "-l:console%3BVerbosity=normal" diff --git a/src/mono/browser/runtime/cwraps.ts b/src/mono/browser/runtime/cwraps.ts index 3201d0f665f25..fe7ae5269f2f9 100644 --- a/src/mono/browser/runtime/cwraps.ts +++ b/src/mono/browser/runtime/cwraps.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import type { MonoAssembly, MonoClass, @@ -15,7 +15,7 @@ import { mono_assert } from "./globals"; type SigLine = [lazyOrSkip: boolean | (() => boolean), name: string, returnType: string | null, argTypes?: string[], opts?: any]; -const threading_cwraps: SigLine[] = MonoWasmThreads ? [ +const threading_cwraps: SigLine[] = WasmEnableThreads ? [ // MONO.diagnostics [true, "mono_wasm_event_pipe_enable", "bool", ["string", "number", "number", "string", "bool", "number"]], [true, "mono_wasm_event_pipe_session_start_streaming", "bool", ["number"]], diff --git a/src/mono/browser/runtime/diagnostics/browser/controller.ts b/src/mono/browser/runtime/diagnostics/browser/controller.ts index 6286da2b50539..8cc60f7742c4c 100644 --- a/src/mono/browser/runtime/diagnostics/browser/controller.ts +++ b/src/mono/browser/runtime/diagnostics/browser/controller.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import { threads_c_functions as cwraps } from "../../cwraps"; import { INTERNAL, mono_assert } from "../../globals"; @@ -54,7 +54,7 @@ export function getController(): ServerController { } export async function startDiagnosticServer(websocket_url: string): Promise { - mono_assert(MonoWasmThreads, "The diagnostic server requires threads to be enabled during build time."); + mono_assert(WasmEnableThreads, "The diagnostic server requires threads to be enabled during build time."); const sizeOfPthreadT = 4; mono_log_info(`starting the diagnostic server url: ${websocket_url}`); const result: number | undefined = withStackAlloc(sizeOfPthreadT, (pthreadIdPtr) => { diff --git a/src/mono/browser/runtime/diagnostics/index.ts b/src/mono/browser/runtime/diagnostics/index.ts index 1d93725a640b8..474fd8a824fd5 100644 --- a/src/mono/browser/runtime/diagnostics/index.ts +++ b/src/mono/browser/runtime/diagnostics/index.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import type { DiagnosticOptions, @@ -16,7 +16,7 @@ import { mono_assert, runtimeHelpers } from "../globals"; // called from C on the main thread export function mono_wasm_event_pipe_early_startup_callback(): void { - if (MonoWasmThreads) { + if (WasmEnableThreads) { return; } } @@ -39,7 +39,7 @@ let diagnosticsInitialized = false; export async function mono_wasm_init_diagnostics(): Promise { if (diagnosticsInitialized) return; - if (!MonoWasmThreads) { + if (!WasmEnableThreads) { mono_log_warn("ignoring diagnostics options because this runtime does not support diagnostics"); return; } @@ -144,7 +144,7 @@ function diagnostic_options_from_ports_spec(val: string): DiagnosticOptions | nu } export function mono_wasm_diagnostic_server_on_runtime_server_init(out_options: VoidPtr): void { - mono_assert(MonoWasmThreads, "The diagnostic server requires threads to be enabled during build time."); + mono_assert(WasmEnableThreads, "The diagnostic server requires threads to be enabled during build time."); if (diagnosticsServerEnabled) { /* called on the main thread when the runtime is sufficiently initialized */ const controller = getController(); diff --git a/src/mono/browser/runtime/diagnostics/server_pthread/index.ts b/src/mono/browser/runtime/diagnostics/server_pthread/index.ts index 1bec0f6b3efd9..1fbca276f3c89 100644 --- a/src/mono/browser/runtime/diagnostics/server_pthread/index.ts +++ b/src/mono/browser/runtime/diagnostics/server_pthread/index.ts @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. /// -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import monoDiagnosticsMock from "consts:monoDiagnosticsMock"; import { PromiseAndController, assertNever } from "../../types/internal"; @@ -285,7 +285,7 @@ function parseProtocolCommand(data: ArrayBuffer | BinaryProtocolCommand): ParseC /// Called by the runtime to initialize the diagnostic server workers export function mono_wasm_diagnostic_server_on_server_thread_created(websocketUrlPtr: CharPtr): void { - mono_assert(MonoWasmThreads, "The diagnostic server requires threads to be enabled during build time."); + mono_assert(WasmEnableThreads, "The diagnostic server requires threads to be enabled during build time."); const websocketUrl = utf8ToString(websocketUrlPtr); mono_log_debug(`mono_wasm_diagnostic_server_on_server_thread_created, url ${websocketUrl}`); let mock: PromiseAndController | undefined = undefined; diff --git a/src/mono/browser/runtime/diagnostics/server_pthread/streaming-session.ts b/src/mono/browser/runtime/diagnostics/server_pthread/streaming-session.ts index aa60222ed657d..6854261e4d00e 100644 --- a/src/mono/browser/runtime/diagnostics/server_pthread/streaming-session.ts +++ b/src/mono/browser/runtime/diagnostics/server_pthread/streaming-session.ts @@ -1,6 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import { EventPipeSessionIDImpl } from "../shared/types"; import { EventPipeSocketConnection, takeOverSocket } from "./socket-connection"; @@ -25,7 +25,7 @@ export class EventPipeStreamingSession { } export async function makeEventPipeStreamingSession(ws: WebSocket | MockRemoteSocket, cmd: EventPipeCommandCollectTracing2): Promise { - mono_assert(MonoWasmThreads, "The diagnostic server requires threads to be enabled during build time."); + mono_assert(WasmEnableThreads, "The diagnostic server requires threads to be enabled during build time."); // First, create the native IPC stream and get its queue. const ipcStreamAddr = cwraps.mono_wasm_diagnostic_server_create_stream(); // FIXME: this should be a wrapped in a JS object so we can free it when we're done. const queueAddr = getQueueAddrFromStreamAddr(ipcStreamAddr); diff --git a/src/mono/browser/runtime/exports-binding.ts b/src/mono/browser/runtime/exports-binding.ts index 8a363e8652db0..638f6afa4229d 100644 --- a/src/mono/browser/runtime/exports-binding.ts +++ b/src/mono/browser/runtime/exports-binding.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import { mono_wasm_debugger_log, mono_wasm_add_dbg_command_received, mono_wasm_set_entrypoint_breakpoint, mono_wasm_fire_debugger_agent_message_with_data, mono_wasm_fire_debugger_agent_message_with_data_to_pause } from "./debug"; import { mono_wasm_release_cs_owned_object } from "./gc-handles"; @@ -31,7 +31,7 @@ import { mono_wasm_browser_entropy } from "./crypto"; // the JS methods would be visible to EMCC linker and become imports of the WASM module -export const mono_wasm_threads_imports = !MonoWasmThreads ? [] : [ +export const mono_wasm_threads_imports = !WasmEnableThreads ? [] : [ // mono-threads-wasm.c mono_wasm_pthread_on_pthread_registered, mono_wasm_pthread_on_pthread_attached, diff --git a/src/mono/browser/runtime/gc-handles.ts b/src/mono/browser/runtime/gc-handles.ts index 6aab770b7b449..c192891e51423 100644 --- a/src/mono/browser/runtime/gc-handles.ts +++ b/src/mono/browser/runtime/gc-handles.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import BuildConfiguration from "consts:configuration"; import { loaderHelpers, mono_assert, runtimeHelpers } from "./globals"; @@ -187,7 +187,7 @@ export function _lookup_js_owned_object(gc_handle: GCHandle): any { } export function assertNoProxies(): void { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; mono_assert(_js_owned_object_table.size === 0, "There should be no proxies on this thread."); mono_assert(_cs_owned_objects_by_js_handle.length === 1, "There should be no proxies on this thread."); mono_assert(_cs_owned_objects_by_jsv_handle.length === 1, "There should be no proxies on this thread."); diff --git a/src/mono/browser/runtime/gc-lock.ts b/src/mono/browser/runtime/gc-lock.ts index 31b2db200c5b3..876e6a2eb5869 100644 --- a/src/mono/browser/runtime/gc-lock.ts +++ b/src/mono/browser/runtime/gc-lock.ts @@ -1,4 +1,4 @@ -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import { ENVIRONMENT_IS_PTHREAD } from "./globals"; import cwraps from "./cwraps"; @@ -8,7 +8,7 @@ export function mono_wasm_gc_lock(): void { if (locked) { throw new Error("GC is already locked"); } - if (MonoWasmThreads) { + if (WasmEnableThreads) { if (ENVIRONMENT_IS_PTHREAD) { throw new Error("GC lock only supported in main thread"); } @@ -21,7 +21,7 @@ export function mono_wasm_gc_unlock(): void { if (!locked) { throw new Error("GC is not locked"); } - if (MonoWasmThreads) { + if (WasmEnableThreads) { if (ENVIRONMENT_IS_PTHREAD) { throw new Error("GC lock only supported in main thread"); } diff --git a/src/mono/browser/runtime/invoke-cs.ts b/src/mono/browser/runtime/invoke-cs.ts index 2bdf952464318..fd0af4ca25dc4 100644 --- a/src/mono/browser/runtime/invoke-cs.ts +++ b/src/mono/browser/runtime/invoke-cs.ts @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. import BuildConfiguration from "consts:configuration"; -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import { Module, loaderHelpers, mono_assert, runtimeHelpers } from "./globals"; import { bind_arg_marshal_to_cs } from "./marshal-to-cs"; @@ -131,11 +131,11 @@ export function mono_wasm_bind_cs_function(fully_qualified_name: MonoStringRef, function bind_fn_0V(closure: BindingClosure) { const method = closure.method; const fqn = closure.fqn; - if (!MonoWasmThreads) (closure) = null; + if (!WasmEnableThreads) (closure) = null; return function bound_fn_0V() { const mark = startMeasure(); loaderHelpers.assert_runtime_running(); - mono_assert(!MonoWasmThreads || !closure.isDisposed, "The function was already disposed"); + mono_assert(!WasmEnableThreads || !closure.isDisposed, "The function was already disposed"); const sp = Module.stackSave(); try { const args = alloc_stack_frame(2); @@ -152,11 +152,11 @@ function bind_fn_1V(closure: BindingClosure) { const method = closure.method; const marshaler1 = closure.arg_marshalers[0]!; const fqn = closure.fqn; - if (!MonoWasmThreads) (closure) = null; + if (!WasmEnableThreads) (closure) = null; return function bound_fn_1V(arg1: any) { const mark = startMeasure(); loaderHelpers.assert_runtime_running(); - mono_assert(!MonoWasmThreads || !closure.isDisposed, "The function was already disposed"); + mono_assert(!WasmEnableThreads || !closure.isDisposed, "The function was already disposed"); const sp = Module.stackSave(); try { const args = alloc_stack_frame(3); @@ -176,11 +176,11 @@ function bind_fn_1R(closure: BindingClosure) { const marshaler1 = closure.arg_marshalers[0]!; const res_converter = closure.res_converter!; const fqn = closure.fqn; - if (!MonoWasmThreads) (closure) = null; + if (!WasmEnableThreads) (closure) = null; return function bound_fn_1R(arg1: any) { const mark = startMeasure(); loaderHelpers.assert_runtime_running(); - mono_assert(!MonoWasmThreads || !closure.isDisposed, "The function was already disposed"); + mono_assert(!WasmEnableThreads || !closure.isDisposed, "The function was already disposed"); const sp = Module.stackSave(); try { const args = alloc_stack_frame(3); @@ -203,11 +203,11 @@ function bind_fn_1RA(closure: BindingClosure) { const marshaler1 = closure.arg_marshalers[0]!; const res_converter = closure.res_converter!; const fqn = closure.fqn; - if (!MonoWasmThreads) (closure) = null; + if (!WasmEnableThreads) (closure) = null; return function bound_fn_1R(arg1: any) { const mark = startMeasure(); loaderHelpers.assert_runtime_running(); - mono_assert(!MonoWasmThreads || !closure.isDisposed, "The function was already disposed"); + mono_assert(!WasmEnableThreads || !closure.isDisposed, "The function was already disposed"); const sp = Module.stackSave(); try { const args = alloc_stack_frame(3); @@ -236,11 +236,11 @@ function bind_fn_2R(closure: BindingClosure) { const marshaler2 = closure.arg_marshalers[1]!; const res_converter = closure.res_converter!; const fqn = closure.fqn; - if (!MonoWasmThreads) (closure) = null; + if (!WasmEnableThreads) (closure) = null; return function bound_fn_2R(arg1: any, arg2: any) { const mark = startMeasure(); loaderHelpers.assert_runtime_running(); - mono_assert(!MonoWasmThreads || !closure.isDisposed, "The function was already disposed"); + mono_assert(!WasmEnableThreads || !closure.isDisposed, "The function was already disposed"); const sp = Module.stackSave(); try { const args = alloc_stack_frame(4); @@ -265,11 +265,11 @@ function bind_fn_2RA(closure: BindingClosure) { const marshaler2 = closure.arg_marshalers[1]!; const res_converter = closure.res_converter!; const fqn = closure.fqn; - if (!MonoWasmThreads) (closure) = null; + if (!WasmEnableThreads) (closure) = null; return function bound_fn_2R(arg1: any, arg2: any) { const mark = startMeasure(); loaderHelpers.assert_runtime_running(); - mono_assert(!MonoWasmThreads || !closure.isDisposed, "The function was already disposed"); + mono_assert(!WasmEnableThreads || !closure.isDisposed, "The function was already disposed"); const sp = Module.stackSave(); try { const args = alloc_stack_frame(4); @@ -300,11 +300,11 @@ function bind_fn(closure: BindingClosure) { const method = closure.method; const fqn = closure.fqn; const is_async = closure.is_async; - if (!MonoWasmThreads) (closure) = null; + if (!WasmEnableThreads) (closure) = null; return function bound_fn(...js_args: any[]) { const mark = startMeasure(); loaderHelpers.assert_runtime_running(); - mono_assert(!MonoWasmThreads || !closure.isDisposed, "The function was already disposed"); + mono_assert(!WasmEnableThreads || !closure.isDisposed, "The function was already disposed"); const sp = Module.stackSave(); try { const args = alloc_stack_frame(2 + args_count); @@ -435,7 +435,7 @@ export async function mono_wasm_get_assembly_exports(assembly: string): Promise< } } } else { - mono_assert(!MonoWasmThreads, () => `JSExport with multi-threading enabled is not supported with assembly ${assembly} as it was generated with the .NET 7 SDK`); + mono_assert(!WasmEnableThreads, () => `JSExport with multi-threading enabled is not supported with assembly ${assembly} as it was generated with the .NET 7 SDK`); // this needs to stay here for compatibility with assemblies generated in Net7 // it doesn't have the __GeneratedInitializer class cwraps.mono_wasm_runtime_run_module_cctor(asm); diff --git a/src/mono/browser/runtime/invoke-js.ts b/src/mono/browser/runtime/invoke-js.ts index f36d2ee1aa02b..79f676ee08b43 100644 --- a/src/mono/browser/runtime/invoke-js.ts +++ b/src/mono/browser/runtime/invoke-js.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import BuildConfiguration from "consts:configuration"; import { marshal_exception_to_cs, bind_arg_marshal_to_cs } from "./marshal-to-cs"; @@ -22,7 +22,7 @@ import { is_thread_available } from "./pthreads/shared/emscripten-replacements"; export const js_import_wrapper_by_fn_handle: Function[] = [null];// 0th slot is dummy, main thread we free them on shutdown. On web worker thread we free them when worker is detached. export function mono_wasm_bind_js_import(signature: JSFunctionSignature, is_exception: Int32Ptr, result_address: MonoObjectRef): void { - if (MonoWasmThreads) return; + if (WasmEnableThreads) return; assert_js_interop(); const resultRoot = mono_wasm_new_external_root(result_address); try { @@ -37,7 +37,7 @@ export function mono_wasm_bind_js_import(signature: JSFunctionSignature, is_exce } export function mono_wasm_invoke_import_async(args: JSMarshalerArguments, signature: JSFunctionSignature) { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; assert_js_interop(); const function_handle = get_signature_handle(signature); @@ -60,7 +60,7 @@ export function mono_wasm_invoke_import_async(args: JSMarshalerArguments, signat } } - if (MonoWasmThreads && !ENVIRONMENT_IS_WORKER) { + if (WasmEnableThreads && !ENVIRONMENT_IS_WORKER) { // give thread chance to load before we run more synchronous code on UI thread postpone_invoke_import_async(); } @@ -72,7 +72,7 @@ export function mono_wasm_invoke_import_async(args: JSMarshalerArguments, signat } export function mono_wasm_invoke_import_sync(args: JSMarshalerArguments, signature: JSFunctionSignature) { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; assert_js_interop(); const function_handle = get_signature_handle(signature); @@ -176,11 +176,11 @@ function bind_js_import(signature: JSFunctionSignature): Function { function bind_fn_0V(closure: BindingClosure) { const fn = closure.fn; const fqn = closure.fqn; - if (!MonoWasmThreads) (closure) = null; + if (!WasmEnableThreads) (closure) = null; return function bound_fn_0V(args: JSMarshalerArguments) { const mark = startMeasure(); try { - mono_assert(!MonoWasmThreads || !closure.isDisposed, "The function was already disposed"); + mono_assert(!WasmEnableThreads || !closure.isDisposed, "The function was already disposed"); // call user function fn(); } catch (ex) { @@ -196,11 +196,11 @@ function bind_fn_1V(closure: BindingClosure) { const fn = closure.fn; const marshaler1 = closure.arg_marshalers[0]!; const fqn = closure.fqn; - if (!MonoWasmThreads) (closure) = null; + if (!WasmEnableThreads) (closure) = null; return function bound_fn_1V(args: JSMarshalerArguments) { const mark = startMeasure(); try { - mono_assert(!MonoWasmThreads || !closure.isDisposed, "The function was already disposed"); + mono_assert(!WasmEnableThreads || !closure.isDisposed, "The function was already disposed"); const arg1 = marshaler1(args); // call user function fn(arg1); @@ -218,11 +218,11 @@ function bind_fn_1R(closure: BindingClosure) { const marshaler1 = closure.arg_marshalers[0]!; const res_converter = closure.res_converter!; const fqn = closure.fqn; - if (!MonoWasmThreads) (closure) = null; + if (!WasmEnableThreads) (closure) = null; return function bound_fn_1R(args: JSMarshalerArguments) { const mark = startMeasure(); try { - mono_assert(!MonoWasmThreads || !closure.isDisposed, "The function was already disposed"); + mono_assert(!WasmEnableThreads || !closure.isDisposed, "The function was already disposed"); const arg1 = marshaler1(args); // call user function const js_result = fn(arg1); @@ -242,11 +242,11 @@ function bind_fn_2R(closure: BindingClosure) { const marshaler2 = closure.arg_marshalers[1]!; const res_converter = closure.res_converter!; const fqn = closure.fqn; - if (!MonoWasmThreads) (closure) = null; + if (!WasmEnableThreads) (closure) = null; return function bound_fn_2R(args: JSMarshalerArguments) { const mark = startMeasure(); try { - mono_assert(!MonoWasmThreads || !closure.isDisposed, "The function was already disposed"); + mono_assert(!WasmEnableThreads || !closure.isDisposed, "The function was already disposed"); const arg1 = marshaler1(args); const arg2 = marshaler2(args); // call user function @@ -269,11 +269,11 @@ function bind_fn(closure: BindingClosure) { const has_cleanup = closure.has_cleanup; const fn = closure.fn; const fqn = closure.fqn; - if (!MonoWasmThreads) (closure) = null; + if (!WasmEnableThreads) (closure) = null; return function bound_fn(args: JSMarshalerArguments) { const mark = startMeasure(); try { - mono_assert(!MonoWasmThreads || !closure.isDisposed, "The function was already disposed"); + mono_assert(!WasmEnableThreads || !closure.isDisposed, "The function was already disposed"); const js_args = new Array(args_count); for (let index = 0; index < args_count; index++) { const marshaler = arg_marshalers[index]!; @@ -340,7 +340,7 @@ function mono_wasm_lookup_js_import(function_name: string, js_module_name: strin const parts = function_name.split("."); if (js_module_name) { scope = importedModules.get(js_module_name); - if (MonoWasmThreads) { + if (WasmEnableThreads) { mono_assert(scope, () => `ES6 module ${js_module_name} was not imported yet, please call JSHost.ImportAsync() on the UI or JSWebWorker thread first.`); } else { mono_assert(scope, () => `ES6 module ${js_module_name} was not imported yet, please call JSHost.ImportAsync() first.`); @@ -461,7 +461,7 @@ export function wrap_no_error_root(is_exception: Int32Ptr | null, result?: WasmR export function assert_js_interop(): void { loaderHelpers.assert_runtime_running(); - if (MonoWasmThreads) { + if (WasmEnableThreads) { mono_assert(runtimeHelpers.mono_wasm_bindings_is_ready && runtimeHelpers.proxy_context_gc_handle, "Please use dedicated worker for working with JavaScript interop. See https://github.com/dotnet/runtime/blob/main/src/mono/wasm/threads.md#JS-interop-on-dedicated-threads"); } else { mono_assert(runtimeHelpers.mono_wasm_bindings_is_ready, "The runtime must be initialized."); @@ -470,7 +470,7 @@ export function assert_js_interop(): void { export function assert_c_interop(): void { loaderHelpers.assert_runtime_running(); - if (MonoWasmThreads) { + if (WasmEnableThreads) { mono_assert(runtimeHelpers.mono_wasm_bindings_is_ready, "Please use dedicated worker for working with JavaScript interop. See https://github.com/dotnet/runtime/blob/main/src/mono/wasm/threads.md#JS-interop-on-dedicated-threads"); } else { mono_assert(runtimeHelpers.mono_wasm_bindings_is_ready, "The runtime must be initialized."); diff --git a/src/mono/browser/runtime/jiterpreter-support.ts b/src/mono/browser/runtime/jiterpreter-support.ts index d406fd68b94ce..cacd4d306695a 100644 --- a/src/mono/browser/runtime/jiterpreter-support.ts +++ b/src/mono/browser/runtime/jiterpreter-support.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import { NativePointer, ManagedPointer, VoidPtr } from "./types/emscripten"; import { Module, mono_assert, runtimeHelpers, linkerRunAOTCompilation } from "./globals"; import { WasmOpcode, WasmSimdOpcode, WasmValtype } from "./jiterpreter-opcodes"; @@ -513,7 +513,7 @@ export class WasmBuilder { // import the native heap this.appendName("m"); this.appendName("h"); - if (MonoWasmThreads) { + if (WasmEnableThreads) { // memtype (limits = 0x03 n:u32 m:u32 => {min n, max m, shared}) this.appendU8(0x02); this.appendU8(0x03); @@ -1821,7 +1821,7 @@ let observedTaintedZeroPage: boolean | undefined; export function isZeroPageReserved(): boolean { // FIXME: This check will always return true on worker threads. // Right now the jiterpreter is disabled when threading is active, so that's not an issue. - if (MonoWasmThreads) + if (WasmEnableThreads) return false; if (!cwraps.mono_wasm_is_zero_page_reserved()) @@ -1991,7 +1991,7 @@ function jiterpreter_allocate_table(type: JiterpreterTable, base: number, size: // In threaded builds we need to populate all the reserved slots with safe placeholder functions // This operation is expensive in v8, so avoid doing it in single-threaded builds (which SHOULD // be safe, since it was previously not necessary) - if (MonoWasmThreads) { + if (WasmEnableThreads) { // HACK: If possible, we want to copy any backing state associated with the first placeholder item, // so that additional work doesn't have to be done by the runtime for the following table sets const preparedValue = wasmTable.get(firstIndex); diff --git a/src/mono/browser/runtime/loader/assets.ts b/src/mono/browser/runtime/loader/assets.ts index d4a6653ca9b82..3cbfd663caa94 100644 --- a/src/mono/browser/runtime/loader/assets.ts +++ b/src/mono/browser/runtime/loader/assets.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import type { AssetEntryInternal, PromiseAndController } from "../types/internal"; import type { AssetBehaviors, AssetEntry, LoadingResource, ResourceList, SingleAssetBehaviors as SingleAssetBehaviors, WebAssemblyBootResourceType } from "../types"; @@ -284,11 +284,11 @@ export function prepareAssets() { mono_assert(resources.wasmNative, "resources.wasmNative must be defined"); mono_assert(resources.jsModuleNative, "resources.jsModuleNative must be defined"); mono_assert(resources.jsModuleRuntime, "resources.jsModuleRuntime must be defined"); - mono_assert(!MonoWasmThreads || resources.jsModuleWorker, "resources.jsModuleWorker must be defined"); + mono_assert(!WasmEnableThreads || resources.jsModuleWorker, "resources.jsModuleWorker must be defined"); convert_single_asset(alwaysLoadedAssets, resources.wasmNative, "dotnetwasm"); convert_single_asset(modulesAssets, resources.jsModuleNative, "js-module-native"); convert_single_asset(modulesAssets, resources.jsModuleRuntime, "js-module-runtime"); - if (MonoWasmThreads) { + if (WasmEnableThreads) { convert_single_asset(modulesAssets, resources.jsModuleWorker, "js-module-threads"); } diff --git a/src/mono/browser/runtime/loader/config.ts b/src/mono/browser/runtime/loader/config.ts index dcb12866e3d4e..68f62e2261ddd 100644 --- a/src/mono/browser/runtime/loader/config.ts +++ b/src/mono/browser/runtime/loader/config.ts @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. import BuildConfiguration from "consts:configuration"; -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import type { DotnetModuleInternal, MonoConfigInternal } from "../types/internal"; import type { DotnetModuleConfig, MonoConfig, ResourceGroups, ResourceList } from "../types"; @@ -188,7 +188,7 @@ export function normalizeConfig() { config.cachedResourcesPurgeDelay = 10000; } - if (MonoWasmThreads && !Number.isInteger(config.pthreadPoolSize)) { + if (WasmEnableThreads && !Number.isInteger(config.pthreadPoolSize)) { // ActiveIssue https://github.com/dotnet/runtime/issues/75602 config.pthreadPoolSize = 7; } diff --git a/src/mono/browser/runtime/loader/exit.ts b/src/mono/browser/runtime/loader/exit.ts index 0ebbb32b1eb05..9a9c78775cfd9 100644 --- a/src/mono/browser/runtime/loader/exit.ts +++ b/src/mono/browser/runtime/loader/exit.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import { ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_WEB, ENVIRONMENT_IS_WORKER, INTERNAL, emscriptenModule, loaderHelpers, mono_assert, runtimeHelpers } from "./globals"; import { mono_log_debug, mono_log_error, mono_log_info_no_prefix, mono_log_warn, teardown_proxy_console } from "./logging"; @@ -16,7 +16,7 @@ export function is_runtime_running() { export function assert_runtime_running() { if (!is_exited()) { - if (MonoWasmThreads && ENVIRONMENT_IS_WORKER) { + if (WasmEnableThreads && ENVIRONMENT_IS_WORKER) { mono_assert(runtimeHelpers.runtimeReady, "The WebWorker is not attached to the runtime. See https://github.com/dotnet/runtime/blob/main/src/mono/wasm/threads.md#JS-interop-on-dedicated-threads"); } else { mono_assert(runtimeHelpers.runtimeReady, ".NET runtime didn't start yet. Please call dotnet.create() first."); @@ -151,7 +151,7 @@ export function mono_exit(exit_code: number, reason?: any): void { } function set_exit_code_and_quit_now(exit_code: number, reason?: any): void { - if (MonoWasmThreads && ENVIRONMENT_IS_WORKER && runtimeHelpers.runtimeReady && runtimeHelpers.nativeAbort) { + if (WasmEnableThreads && ENVIRONMENT_IS_WORKER && runtimeHelpers.runtimeReady && runtimeHelpers.nativeAbort) { // note that the reason is not passed to UI thread runtimeHelpers.runtimeReady = false; runtimeHelpers.nativeAbort(reason); diff --git a/src/mono/browser/runtime/loader/logging.ts b/src/mono/browser/runtime/loader/logging.ts index ac8f0cb806822..bdd63c6e8473e 100644 --- a/src/mono/browser/runtime/loader/logging.ts +++ b/src/mono/browser/runtime/loader/logging.ts @@ -3,7 +3,7 @@ /* eslint-disable no-console */ -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import { ENVIRONMENT_IS_WORKER, loaderHelpers } from "./globals"; @@ -61,7 +61,7 @@ function proxyConsoleMethod(prefix: string, func: any, asJson: boolean) { } if (typeof payload === "string") { - if (MonoWasmThreads) { + if (WasmEnableThreads) { if (ENVIRONMENT_IS_WORKER && payload.indexOf("keeping the worker alive for asynchronous operation") !== -1) { // muting emscripten noise return; diff --git a/src/mono/browser/runtime/loader/polyfills.ts b/src/mono/browser/runtime/loader/polyfills.ts index b688e5a90eaaf..e60fb2111b8f5 100644 --- a/src/mono/browser/runtime/loader/polyfills.ts +++ b/src/mono/browser/runtime/loader/polyfills.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import type { DotnetModuleInternal } from "../types/internal"; import { INTERNAL, ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_SHELL, loaderHelpers, ENVIRONMENT_IS_WEB, mono_assert } from "./globals"; @@ -21,7 +21,7 @@ const URLPolyfill = class URL { export function verifyEnvironment() { mono_assert(ENVIRONMENT_IS_SHELL || typeof globalThis.URL === "function", "This browser/engine doesn't support URL API. Please use a modern version. See also https://aka.ms/dotnet-wasm-features"); mono_assert(typeof globalThis.BigInt64Array === "function", "This browser/engine doesn't support BigInt64Array API. Please use a modern version. See also https://aka.ms/dotnet-wasm-features"); - if (MonoWasmThreads) { + if (WasmEnableThreads) { mono_assert(!ENVIRONMENT_IS_SHELL && !ENVIRONMENT_IS_NODE, "This build of dotnet is multi-threaded, it doesn't support shell environments like V8 or NodeJS. See also https://aka.ms/dotnet-wasm-features"); mono_assert(globalThis.SharedArrayBuffer !== undefined, "SharedArrayBuffer is not enabled on this page. Please use a modern browser and set Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy http headers. See also https://aka.ms/dotnet-wasm-features"); mono_assert(typeof globalThis.EventTarget === "function", "This browser/engine doesn't support EventTarget API. Please use a modern version. See also https://aka.ms/dotnet-wasm-features"); diff --git a/src/mono/browser/runtime/managed-exports.ts b/src/mono/browser/runtime/managed-exports.ts index 6d2e54a551f6e..64db9fd82eb49 100644 --- a/src/mono/browser/runtime/managed-exports.ts +++ b/src/mono/browser/runtime/managed-exports.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import { GCHandle, MarshalerToCs, MarshalerToJs, MarshalerType, MonoMethod } from "./types/internal"; import cwraps from "./cwraps"; @@ -24,8 +24,8 @@ export function init_managed_exports(): void { if (!runtimeHelpers.runtime_interop_exports_class) throw "Can't find " + runtimeHelpers.runtime_interop_namespace + "." + runtimeHelpers.runtime_interop_exports_classname + " class"; - const install_main_synchronization_context = MonoWasmThreads ? get_method("InstallMainSynchronizationContext") : undefined; - mono_assert(!MonoWasmThreads || install_main_synchronization_context, "Can't find InstallMainSynchronizationContext method"); + const install_main_synchronization_context = WasmEnableThreads ? get_method("InstallMainSynchronizationContext") : undefined; + mono_assert(!WasmEnableThreads || install_main_synchronization_context, "Can't find InstallMainSynchronizationContext method"); const call_entry_point = get_method("CallEntrypoint"); mono_assert(call_entry_point, "Can't find CallEntrypoint method"); const release_js_owned_object_by_gc_handle_method = get_method("ReleaseJSOwnedObjectByGCHandle"); @@ -189,7 +189,7 @@ export function init_managed_exports(): void { Module.stackRestore(sp); } }; - if (MonoWasmThreads && install_main_synchronization_context) { + if (WasmEnableThreads && install_main_synchronization_context) { runtimeHelpers.javaScriptExports.install_main_synchronization_context = () => invoke_method_raw(install_main_synchronization_context); } } diff --git a/src/mono/browser/runtime/marshal-to-cs.ts b/src/mono/browser/runtime/marshal-to-cs.ts index fa5e0a7d7056d..2e6f2c2b50a07 100644 --- a/src/mono/browser/runtime/marshal-to-cs.ts +++ b/src/mono/browser/runtime/marshal-to-cs.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import BuildConfiguration from "consts:configuration"; import WasmEnableJsInteropByValue from "consts:wasmEnableJsInteropByValue"; @@ -267,7 +267,7 @@ function _marshal_function_to_cs(arg: JSMarshalerArgument, value: Function, _?: const arg3 = get_arg(args, 4); try { - mono_assert(!MonoWasmThreads || !wrapper.isDisposed, "Function is disposed and should not be invoked anymore."); + mono_assert(!WasmEnableThreads || !wrapper.isDisposed, "Function is disposed and should not be invoked anymore."); let arg1_js: any = undefined; let arg2_js: any = undefined; @@ -311,7 +311,7 @@ export class PromiseHolder extends ManagedObject { function _marshal_task_to_cs(arg: JSMarshalerArgument, value: Promise, _?: MarshalerType, res_converter?: MarshalerToCs) { const handleIsPreallocated = get_arg_type(arg) == MarshalerType.TaskPreCreated; if (value === null || value === undefined) { - if (MonoWasmThreads && handleIsPreallocated) { + if (WasmEnableThreads && handleIsPreallocated) { // This is multi-threading return from JSImport with Task result and we can't return synchronously, // because C# caller could be on different thread and sent us an async message. // It already returned pending Task to it's own caller. @@ -336,7 +336,7 @@ function _marshal_task_to_cs(arg: JSMarshalerArgument, value: Promise, _?: (holder as any)[proxy_debug_symbol] = `PromiseHolder with GCHandle ${gc_handle}`; } - if (MonoWasmThreads) + if (WasmEnableThreads) addUnsettledPromise(); function resolve(data: any) { @@ -346,7 +346,7 @@ function _marshal_task_to_cs(arg: JSMarshalerArgument, value: Promise, _?: } try { mono_assert(!holder.isDisposed, "This promise can't be propagated to managed code, because the Task was already freed."); - if (MonoWasmThreads) { + if (WasmEnableThreads) { settleUnsettledPromise(); } // we can unregister the GC handle just on JS side @@ -367,7 +367,7 @@ function _marshal_task_to_cs(arg: JSMarshalerArgument, value: Promise, _?: } try { mono_assert(!holder.isDisposed, "This promise can't be propagated to managed code, because the Task was already freed."); - if (MonoWasmThreads) { + if (WasmEnableThreads) { settleUnsettledPromise(); } // we can unregister the GC handle just on JS side diff --git a/src/mono/browser/runtime/marshal-to-js.ts b/src/mono/browser/runtime/marshal-to-js.ts index 4eb46d211e105..327ac664c2a58 100644 --- a/src/mono/browser/runtime/marshal-to-js.ts +++ b/src/mono/browser/runtime/marshal-to-js.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import BuildConfiguration from "consts:configuration"; import WasmEnableJsInteropByValue from "consts:wasmEnableJsInteropByValue"; @@ -197,7 +197,7 @@ function _marshal_delegate_to_js(arg: JSMarshalerArgument, _?: MarshalerType, re if (result === null || result === undefined) { // this will create new Function for the C# delegate result = (arg1_js: any, arg2_js: any, arg3_js: any): any => { - mono_assert(!MonoWasmThreads || !result.isDisposed, "Delegate is disposed and should not be invoked anymore."); + mono_assert(!WasmEnableThreads || !result.isDisposed, "Delegate is disposed and should not be invoked anymore."); // arg numbers are shifted by one, the real first is a gc handle of the callback return runtimeHelpers.javaScriptExports.call_delegate(gc_handle, arg1_js, arg2_js, arg3_js, res_converter, arg1_converter, arg2_converter, arg3_converter); }; @@ -349,7 +349,7 @@ export function mono_wasm_resolve_or_reject_promise(args: JSMarshalerArguments): mono_assert(holder, () => `Cannot find Promise for JSHandle ${js_handle}`); holder.resolve_or_reject(type, js_handle, arg_value); - if (MonoWasmThreads) { + if (WasmEnableThreads) { // this works together with AllocHGlobal in JSFunctionBinding.ResolveOrRejectPromise Module._free(args as any); return; @@ -358,7 +358,7 @@ export function mono_wasm_resolve_or_reject_promise(args: JSMarshalerArguments): set_arg_type(exc, MarshalerType.None); } catch (ex: any) { - if (MonoWasmThreads) { + if (WasmEnableThreads) { mono_assert(false, () => `Failed to resolve or reject promise ${ex}`); } marshal_exception_to_cs(exc, ex); diff --git a/src/mono/browser/runtime/marshal.ts b/src/mono/browser/runtime/marshal.ts index 2a91aa58ddceb..7af38977bff19 100644 --- a/src/mono/browser/runtime/marshal.ts +++ b/src/mono/browser/runtime/marshal.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import { js_owned_gc_handle_symbol, teardown_managed_proxy } from "./gc-handles"; import { Module, loaderHelpers, mono_assert, runtimeHelpers } from "./globals"; @@ -42,7 +42,7 @@ export function is_args_exception(args: JSMarshalerArguments): boolean { } export function set_args_context(args: JSMarshalerArguments): void { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; mono_assert(args, "Null args"); const exc = get_arg(args, 0); const res = get_arg(args, 1); @@ -263,7 +263,7 @@ export function get_arg_js_handle(arg: JSMarshalerArgument): JSHandle { } export function set_arg_proxy_context(arg: JSMarshalerArgument): void { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; mono_assert(arg, "Null arg"); setI32(arg + 16, runtimeHelpers.proxy_context_gc_handle); } @@ -353,7 +353,7 @@ export class ManagedError extends Error implements IDisposable { this.managed_stack = "... omitted managed stack trace.\n" + this.getSuperStack(); return this.managed_stack; } - if (!MonoWasmThreads || runtimeHelpers.proxy_context_gc_handle) { + if (!WasmEnableThreads || runtimeHelpers.proxy_context_gc_handle) { const gc_handle = (this)[js_owned_gc_handle_symbol]; if (gc_handle !== GCHandleNull) { const managed_stack = runtimeHelpers.javaScriptExports.get_managed_stack_trace(gc_handle); diff --git a/src/mono/browser/runtime/memory.ts b/src/mono/browser/runtime/memory.ts index 5f3314ad510eb..0ae04672797cf 100644 --- a/src/mono/browser/runtime/memory.ts +++ b/src/mono/browser/runtime/memory.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import { MemOffset, NumberOrPointer } from "./types/internal"; import { VoidPtr, CharPtr } from "./types/emscripten"; @@ -324,7 +324,7 @@ export function getEnv(name: string): string | null { const BuiltinAtomics = globalThis.Atomics; -export const Atomics = MonoWasmThreads ? { +export const Atomics = WasmEnableThreads ? { storeI32(offset: MemOffset, value: number): void { BuiltinAtomics.store(localHeapViewI32(), offset >>> 2, value); }, @@ -393,7 +393,7 @@ export function localHeapViewF64(): Float64Array { // when we run with multithreading enabled, we need to make sure that the memory views are updated on each worker // on non-MT build, this will be a no-op trimmed by rollup export function receiveWorkerHeapViews() { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; const memory = runtimeHelpers.getMemory(); if (memory.buffer !== Module.HEAPU8.buffer) { runtimeHelpers.updateMemoryViews(); @@ -403,7 +403,7 @@ export function receiveWorkerHeapViews() { const sharedArrayBufferDefined = typeof SharedArrayBuffer !== "undefined"; export function isSharedArrayBuffer(buffer: any): buffer is SharedArrayBuffer { // this condition should be eliminated by rollup on non-threading builds - if (!MonoWasmThreads) return false; + if (!WasmEnableThreads) return false; // BEWARE: In some cases, `instanceof SharedArrayBuffer` returns false even though buffer is an SAB. // Patch adapted from https://github.com/emscripten-core/emscripten/pull/16994 // See also https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag @@ -417,7 +417,7 @@ This is likely V8 bug. We don't have direct evidence, just failed debugger unit */ export function forceThreadMemoryViewRefresh() { // this condition should be eliminated by rollup on non-threading builds and it would become empty method. - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; const wasmMemory = runtimeHelpers.getMemory(); diff --git a/src/mono/browser/runtime/polyfills.ts b/src/mono/browser/runtime/polyfills.ts index 0a2a075cd7bc6..7aae92566b34a 100644 --- a/src/mono/browser/runtime/polyfills.ts +++ b/src/mono/browser/runtime/polyfills.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import type { EmscriptenReplacements } from "./types/internal"; import type { TypedArray } from "./types/emscripten"; import { ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_WORKER, INTERNAL, Module, loaderHelpers, runtimeHelpers } from "./globals"; @@ -33,14 +33,14 @@ export function initializeReplacements(replacements: EmscriptenReplacements): vo replacements.ENVIRONMENT_IS_WORKER = ENVIRONMENT_IS_WORKER; // threads - if (MonoWasmThreads && replacements.modulePThread) { + if (WasmEnableThreads && replacements.modulePThread) { replaceEmscriptenPThreadLibrary(replacements.modulePThread); } } export async function init_polyfills_async(): Promise { // v8 shell doesn't have Event and EventTarget - if (MonoWasmThreads && typeof globalThis.Event === "undefined") { + if (WasmEnableThreads && typeof globalThis.Event === "undefined") { globalThis.Event = class Event { readonly type: string; constructor(type: string) { @@ -48,7 +48,7 @@ export async function init_polyfills_async(): Promise { } } as any; } - if (MonoWasmThreads && typeof globalThis.EventTarget === "undefined") { + if (WasmEnableThreads && typeof globalThis.EventTarget === "undefined") { globalThis.EventTarget = class EventTarget { private subscribers = new Map>(); addEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions) { diff --git a/src/mono/browser/runtime/pthreads/browser/index.ts b/src/mono/browser/runtime/pthreads/browser/index.ts index 7e6a4f41f9402..f459508a93ef0 100644 --- a/src/mono/browser/runtime/pthreads/browser/index.ts +++ b/src/mono/browser/runtime/pthreads/browser/index.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import { MonoWorkerToMainMessage, pthreadPtr } from "../shared/types"; import { MonoThreadMessage } from "../shared"; @@ -24,10 +24,9 @@ class ThreadImpl implements Thread { } } - /// wait until the thread with the given id has set up a message port to the runtime export function waitForThread(pthreadPtr: pthreadPtr): Promise { - if (!MonoWasmThreads) return null as any; + if (!WasmEnableThreads) return null as any; const worker = getWorker(pthreadPtr); if (worker?.thread) { return Promise.resolve(worker?.thread); @@ -43,7 +42,7 @@ export function waitForThread(pthreadPtr: pthreadPtr): Promise { } export function resolveThreadPromises(pthreadPtr: pthreadPtr, thread?: Thread): void { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; const arr = threadPromises.get(pthreadPtr); if (arr !== undefined) { arr.forEach((controller) => { @@ -59,7 +58,7 @@ export function resolveThreadPromises(pthreadPtr: pthreadPtr, thread?: Thread): // handler that runs in the main thread when a message is received from a pthread worker function monoWorkerMessageHandler(worker: PThreadWorker, ev: MessageEvent): void { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; let pthreadId: pthreadPtr; // this is emscripten message if (ev.data.cmd === "killThread") { @@ -114,7 +113,7 @@ let pendingWorkerLoad: PromiseAndController | undefined; /// Called by Emscripten internals on the browser thread when a new pthread worker is created and added to the pthread worker pool. /// At this point the worker doesn't have any pthread assigned to it, yet. export function onWorkerLoadInitiated(worker: PThreadWorker, loaded: Promise): void { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; worker.addEventListener("message", (ev) => monoWorkerMessageHandler(worker, ev)); if (pendingWorkerLoad == undefined) { pendingWorkerLoad = createPromiseController(); @@ -129,7 +128,7 @@ export function onWorkerLoadInitiated(worker: PThreadWorker, loaded: Promise { - if (!MonoWasmThreads) return null as any; + if (!WasmEnableThreads) return null as any; if (pendingWorkerLoad == undefined) { return Promise.resolve(); } @@ -140,7 +139,7 @@ export function thread_available(): Promise { /// At this point asset resolution needs to be working (ie we loaded MonoConfig). /// This is used instead of the Emscripten PThread.initMainThread because we call it later. export function preAllocatePThreadWorkerPool(pthreadPoolSize: number): void { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; for (let i = 0; i < pthreadPoolSize; i++) { allocateUnusedWorker(); } @@ -152,7 +151,7 @@ export function preAllocatePThreadWorkerPool(pthreadPoolSize: number): void { /// This is used instead of the Emscripten "receiveInstance" in "createWasm" because that code is /// conditioned on a non-zero PTHREAD_POOL_SIZE (but we set it to 0 to avoid early worker allocation). export async function instantiateWasmPThreadWorkerPool(): Promise { - if (!MonoWasmThreads) return null as any; + if (!WasmEnableThreads) return null as any; // this is largely copied from emscripten's "receiveInstance" in "createWasm" in "src/preamble.js" const workers = getUnusedWorkerPool(); if (workers.length > 0) { diff --git a/src/mono/browser/runtime/pthreads/shared/emscripten-replacements.ts b/src/mono/browser/runtime/pthreads/shared/emscripten-replacements.ts index 202894cd1c2ea..c68de0a52a987 100644 --- a/src/mono/browser/runtime/pthreads/shared/emscripten-replacements.ts +++ b/src/mono/browser/runtime/pthreads/shared/emscripten-replacements.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import BuildConfiguration from "consts:configuration"; import { onWorkerLoadInitiated, resolveThreadPromises } from "../browser"; @@ -16,7 +16,7 @@ import { mono_log_warn } from "../../logging"; */ export function replaceEmscriptenPThreadLibrary(modulePThread: PThreadLibrary): void { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; const originalLoadWasmModuleToWorker = modulePThread.loadWasmModuleToWorker; const originalThreadInitTLS = modulePThread.threadInitTLS; @@ -76,7 +76,7 @@ export function is_thread_available() { } function getNewWorker(modulePThread: PThreadLibrary): PThreadWorker { - if (!MonoWasmThreads) return null as any; + if (!WasmEnableThreads) return null as any; if (modulePThread.unusedWorkers.length == 0) { mono_log_warn(`Failed to find unused WebWorker, this may deadlock. Please increase the pthreadPoolSize. Running threads ${modulePThread.runningWorkers.length}. Loading workers: ${modulePThread.unusedWorkers.length}`); @@ -107,7 +107,7 @@ function getNewWorker(modulePThread: PThreadLibrary): PThreadWorker { /// We replace Module["PThreads"].allocateUnusedWorker with this version that knows about assets function allocateUnusedWorker(): PThreadWorker { - if (!MonoWasmThreads) return null as any; + if (!WasmEnableThreads) return null as any; const asset = loaderHelpers.resolve_single_asset_path("js-module-threads"); const uri = asset.resolvedUrl; @@ -126,7 +126,7 @@ function allocateUnusedWorker(): PThreadWorker { export function dumpThreads(): void { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; // eslint-disable-next-line no-console console.log("Running workers:"); getRunningWorkers().forEach((worker) => { diff --git a/src/mono/browser/runtime/pthreads/shared/index.ts b/src/mono/browser/runtime/pthreads/shared/index.ts index 824a50fcbc66b..758f1e62b1ba0 100644 --- a/src/mono/browser/runtime/pthreads/shared/index.ts +++ b/src/mono/browser/runtime/pthreads/shared/index.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import BuildConfiguration from "consts:configuration"; import { ENVIRONMENT_IS_PTHREAD, Module, loaderHelpers, mono_assert, runtimeHelpers } from "../../globals"; @@ -31,7 +31,7 @@ export function isMonoThreadMessage(x: unknown): x is MonoThreadMessage { } export function mono_wasm_install_js_worker_interop(context_gc_handle: GCHandle): void { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; bindings_init(); if (!runtimeHelpers.proxy_context_gc_handle) { runtimeHelpers.proxy_context_gc_handle = context_gc_handle; @@ -49,7 +49,7 @@ export function mono_wasm_install_js_worker_interop(context_gc_handle: GCHandle) } export function mono_wasm_uninstall_js_worker_interop(): void { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; mono_assert(runtimeHelpers.mono_wasm_bindings_is_ready, "JS interop is not installed on this worker."); mono_assert(runtimeHelpers.proxy_context_gc_handle, "JSSynchronizationContext is not installed on this worker."); @@ -69,7 +69,7 @@ export function update_thread_info(): void { } (globalThis as any).monoThreadInfo = monoThreadInfo; - if (MonoWasmThreads && BuildConfiguration === "Debug" && !runtimeHelpers.cspPolicy) { + if (WasmEnableThreads && BuildConfiguration === "Debug" && !runtimeHelpers.cspPolicy) { monoThreadInfo.updateCount++; try { (globalThis as any).monoThreadInfoFn = new Function(`//# sourceURL=https://${monoThreadInfo.updateCount}WorkerInfo${monoThreadInfo.isAttached ? monoThreadInfo.threadName : ""}/\r\nconsole.log("${JSON.stringify(monoThreadInfo)}");`); @@ -81,12 +81,12 @@ export function update_thread_info(): void { } export function mono_wasm_pthread_ptr(): number { - if (!MonoWasmThreads) return 0; + if (!WasmEnableThreads) return 0; return (Module)["_pthread_self"](); } export function mono_wasm_main_thread_ptr(): number { - if (!MonoWasmThreads) return 0; + if (!WasmEnableThreads) return 0; return (Module)["_emscripten_main_runtime_thread_id"](); } diff --git a/src/mono/browser/runtime/pthreads/worker/events.ts b/src/mono/browser/runtime/pthreads/worker/events.ts index 6917a2cb8f4ab..ace256459d439 100644 --- a/src/mono/browser/runtime/pthreads/worker/events.ts +++ b/src/mono/browser/runtime/pthreads/worker/events.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import { PThreadSelf } from "./index"; export const dotnetPthreadCreated = "dotnet:pthread:created" as const; @@ -29,7 +29,7 @@ export interface WorkerThreadEventTarget extends EventTarget { } let WorkerThreadEventClassConstructor: new (type: keyof WorkerThreadEventMap, pthread_self: PThreadSelf) => WorkerThreadEvent; -export const makeWorkerThreadEvent: (type: keyof WorkerThreadEventMap, pthread_self: PThreadSelf) => WorkerThreadEvent = !MonoWasmThreads +export const makeWorkerThreadEvent: (type: keyof WorkerThreadEventMap, pthread_self: PThreadSelf) => WorkerThreadEvent = !WasmEnableThreads ? (() => { throw new Error("threads support disabled"); }) : ((type: keyof WorkerThreadEventMap, pthread_self: PThreadSelf) => { if (!WorkerThreadEventClassConstructor) WorkerThreadEventClassConstructor = class WorkerThreadEventImpl extends Event implements WorkerThreadEvent { diff --git a/src/mono/browser/runtime/pthreads/worker/index.ts b/src/mono/browser/runtime/pthreads/worker/index.ts index b1952b67a3723..c2af89871d676 100644 --- a/src/mono/browser/runtime/pthreads/worker/index.ts +++ b/src/mono/browser/runtime/pthreads/worker/index.ts @@ -3,7 +3,7 @@ /// -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import { ENVIRONMENT_IS_PTHREAD, loaderHelpers, mono_assert } from "../../globals"; import { mono_wasm_pthread_ptr, postMessageToMain, update_thread_info } from "../shared"; @@ -75,7 +75,7 @@ export let currentWorkerThreadEvents: WorkerThreadEventTarget = undefined as any // this is very very early in the worker startup export function initWorkerThreadEvents() { // treeshake if threads are disabled - currentWorkerThreadEvents = MonoWasmThreads ? new globalThis.EventTarget() : null as any as WorkerThreadEventTarget; + currentWorkerThreadEvents = WasmEnableThreads ? new globalThis.EventTarget() : null as any as WorkerThreadEventTarget; } // this is the message handler for the worker that receives messages from the main thread @@ -89,7 +89,7 @@ function monoDedicatedChannelMessageFromMainToWorker(event: MessageEvent /// for the same webworker, since emscripten can reuse workers. /// This is an implementation detail, that shouldn't be used directly. export function mono_wasm_pthread_on_pthread_created(): void { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; try { const pthread_id = mono_wasm_pthread_ptr(); mono_assert(!is_nullish(pthread_id), "pthread_self() returned null"); @@ -131,7 +131,7 @@ export function mono_wasm_pthread_on_pthread_created(): void { /// Called in the worker thread (not main thread) from mono when a pthread becomes registered to the mono runtime. export function mono_wasm_pthread_on_pthread_registered(pthread_id: number): void { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; try { mono_assert(monoThreadInfo !== null && monoThreadInfo.pthreadId == pthread_id, "expected monoThreadInfo to be set already when registering"); postMessageToMain({ @@ -149,7 +149,7 @@ export function mono_wasm_pthread_on_pthread_registered(pthread_id: number): voi /// Called in the worker thread (not main thread) from mono when a pthread becomes attached to the mono runtime. export function mono_wasm_pthread_on_pthread_attached(pthread_id: number, thread_name: CharPtr, background_thread: number, threadpool_thread: number, external_eventloop: number, debugger_thread: number): void { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; try { mono_assert(monoThreadInfo !== null && monoThreadInfo.pthreadId == pthread_id, "expected monoThreadInfo to be set already when attaching"); @@ -189,7 +189,7 @@ export function mono_wasm_pthread_on_pthread_attached(pthread_id: number, thread /// Called in the worker thread (not main thread) from mono when a pthread becomes detached from the mono runtime. export function mono_wasm_pthread_on_pthread_unregistered(pthread_id: number): void { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; try { mono_assert(pthread_id === monoThreadInfo.pthreadId, "expected pthread_id to match when un-registering"); postRunWorker(); diff --git a/src/mono/browser/runtime/rollup.config.js b/src/mono/browser/runtime/rollup.config.js index babd914374b7e..519879f7d8438 100644 --- a/src/mono/browser/runtime/rollup.config.js +++ b/src/mono/browser/runtime/rollup.config.js @@ -19,7 +19,7 @@ const isContinuousIntegrationBuild = process.env.ContinuousIntegrationBuild === const productVersion = process.env.ProductVersion || "8.0.0-dev"; const nativeBinDir = process.env.NativeBinDir ? process.env.NativeBinDir.replace(/"/g, "") : "bin"; const wasmObjDir = process.env.WasmObjDir ? process.env.WasmObjDir.replace(/"/g, "") : "obj"; -const monoWasmThreads = process.env.MonoWasmThreads === "true" ? true : false; +const wasmEnableThreads = process.env.WasmEnableThreads === "true" ? true : false; const wasmEnableSIMD = process.env.WASM_ENABLE_SIMD === "1" ? true : false; const wasmEnableExceptionHandling = process.env.WASM_ENABLE_EH === "1" ? true : false; const wasmEnableJsInteropByValue = process.env.ENABLE_JS_INTEROP_BY_VALUE == "1" ? true : false; @@ -97,7 +97,7 @@ try { const envConstants = { productVersion, configuration, - monoWasmThreads, + wasmEnableThreads, wasmEnableSIMD, wasmEnableExceptionHandling, monoDiagnosticsMock, diff --git a/src/mono/browser/runtime/run.ts b/src/mono/browser/runtime/run.ts index 6ba5076e53e21..0b8ab30725e25 100644 --- a/src/mono/browser/runtime/run.ts +++ b/src/mono/browser/runtime/run.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import { ENVIRONMENT_IS_NODE, loaderHelpers, mono_assert, runtimeHelpers } from "./globals"; import { mono_wasm_wait_for_debugger } from "./debug"; @@ -89,7 +89,7 @@ export function find_entry_point(assembly: string) { } export function nativeExit(code: number) { - if (MonoWasmThreads) { + if (WasmEnableThreads) { cancelThreads(); } cwraps.mono_wasm_exit(code); diff --git a/src/mono/browser/runtime/scheduling.ts b/src/mono/browser/runtime/scheduling.ts index 5b598861e4938..69412b7947329 100644 --- a/src/mono/browser/runtime/scheduling.ts +++ b/src/mono/browser/runtime/scheduling.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import cwraps from "./cwraps"; import { ENVIRONMENT_IS_WORKER, Module, loaderHelpers } from "./globals"; @@ -61,7 +61,7 @@ export function schedule_background_exec(): void { } } - if (MonoWasmThreads && !ENVIRONMENT_IS_WORKER) { + if (WasmEnableThreads && !ENVIRONMENT_IS_WORKER) { // give threads chance to load before we run more synchronous code on UI thread postpone_schedule_background(); } @@ -78,7 +78,7 @@ export function mono_wasm_schedule_timer(shortestDueTimeMs: number): void { // NOTE: Multi-threaded Module.safeSetTimeout() does the runtimeKeepalivePush() // and non-Multi-threaded Module.safeSetTimeout does not runtimeKeepalivePush() // but clearTimeout does not runtimeKeepalivePop() so we need to do it here in MT only. - if (MonoWasmThreads) Module.runtimeKeepalivePop(); + if (WasmEnableThreads) Module.runtimeKeepalivePop(); } lastScheduledTimeoutId = Module.safeSetTimeout(mono_wasm_schedule_timer_tick, shortestDueTimeMs); } diff --git a/src/mono/browser/runtime/snapshot.ts b/src/mono/browser/runtime/snapshot.ts index 1806c748bc28f..76aac0eecfaa2 100644 --- a/src/mono/browser/runtime/snapshot.ts +++ b/src/mono/browser/runtime/snapshot.ts @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. import ProductVersion from "consts:productVersion"; -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import { ENVIRONMENT_IS_WEB, ENVIRONMENT_IS_WORKER, loaderHelpers, runtimeHelpers } from "./globals"; import { mono_log_warn } from "./logging"; import { MonoConfigInternal } from "./types/internal"; @@ -122,7 +122,7 @@ export async function storeCacheEntry(cacheKey: string, memory: ArrayBuffer, mim if (!cache) { return false; } - const copy = MonoWasmThreads + const copy = WasmEnableThreads // storing SHaredArrayBuffer in the cache is not working ? (new Uint8Array(memory)).slice(0) : memory; diff --git a/src/mono/browser/runtime/startup.ts b/src/mono/browser/runtime/startup.ts index c8cac8a45f3d7..d7db9bc9a5567 100644 --- a/src/mono/browser/runtime/startup.ts +++ b/src/mono/browser/runtime/startup.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import { DotnetModuleInternal, CharPtrNull } from "./types/internal"; import { ENVIRONMENT_IS_NODE, exportedRuntimeAPI, INTERNAL, loaderHelpers, Module, runtimeHelpers, createPromiseController, mono_assert, linkerWasmEnableSIMD, linkerWasmEnableEH, ENVIRONMENT_IS_WORKER } from "./globals"; @@ -122,7 +122,7 @@ async function instantiateWasmWorker( imports: WebAssembly.Imports, successCallback: InstantiateWasmSuccessCallback ): Promise { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; // wait for the config to arrive by message from the main thread await loaderHelpers.afterConfigLoaded.promise; @@ -169,7 +169,7 @@ function preInit(userPreInit: (() => void)[]) { } async function preInitWorkerAsync() { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; const mark = startMeasure(); try { mono_log_debug("preInitWorker"); @@ -193,7 +193,7 @@ async function preInitWorkerAsync() { // runs for each re-attached worker export function preRunWorker() { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; const mark = startMeasure(); try { jiterpreter_allocate_tables(); // this will return quickly if already allocated @@ -246,7 +246,7 @@ async function onRuntimeInitializedAsync(userOnRuntimeInitialized: () => void) { // Threads early are not supported with memory snapshot. See below how we enable them later. // Please disable startupMemoryCache in order to be able to diagnose or pause runtime startup. - if (MonoWasmThreads && !runtimeHelpers.config.startupMemoryCache) { + if (WasmEnableThreads && !runtimeHelpers.config.startupMemoryCache) { await mono_wasm_init_threads(); } @@ -282,7 +282,7 @@ async function onRuntimeInitializedAsync(userOnRuntimeInitialized: () => void) { FS.chdir(cwd); } - if (MonoWasmThreads && runtimeHelpers.config.startupMemoryCache) { + if (WasmEnableThreads && runtimeHelpers.config.startupMemoryCache) { await mono_wasm_init_threads(); } @@ -296,7 +296,7 @@ async function onRuntimeInitializedAsync(userOnRuntimeInitialized: () => void) { runtimeHelpers.runtimeReady = true; runtimeList.registerRuntime(exportedRuntimeAPI); - if (MonoWasmThreads) { + if (WasmEnableThreads) { runtimeHelpers.javaScriptExports.install_main_synchronization_context(); } @@ -341,7 +341,7 @@ async function postRunAsync(userpostRun: (() => void)[]) { Module["FS_createPath"]("/", "usr", true, true); Module["FS_createPath"]("/", "usr/share", true, true); - if (MonoWasmThreads) { + if (WasmEnableThreads) { tcwraps.mono_wasm_init_finalizer_thread(); } @@ -359,7 +359,7 @@ async function postRunAsync(userpostRun: (() => void)[]) { // runs for each re-detached worker export function postRunWorker() { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; const mark = startMeasure(); try { if (runtimeHelpers.proxy_context_gc_handle) { @@ -381,7 +381,7 @@ export function postRunWorker() { } async function mono_wasm_init_threads() { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; const threadName = `0x${mono_wasm_main_thread_ptr().toString(16)}-main`; loaderHelpers.mono_set_thread_name(threadName); @@ -417,7 +417,7 @@ async function mono_wasm_pre_init_essential_async(): Promise { mono_log_debug("mono_wasm_pre_init_essential_async"); Module.addRunDependency("mono_wasm_pre_init_essential_async"); - if (MonoWasmThreads) { + if (WasmEnableThreads) { preAllocatePThreadWorkerPool(runtimeHelpers.config.pthreadPoolSize!); } @@ -661,7 +661,7 @@ export function mono_wasm_set_main_args(name: string, allRuntimeArguments: strin /// 2. Emscripten does not run any event but preInit in the workers. /// 3. At the point when this executes there is no pthread assigned to the worker yet. export async function configureWorkerStartup(module: DotnetModuleInternal): Promise { - if (!MonoWasmThreads) return; + if (!WasmEnableThreads) return; initWorkerThreadEvents(); currentWorkerThreadEvents.addEventListener(dotnetPthreadCreated, () => { diff --git a/src/mono/browser/runtime/types/consts.d.ts b/src/mono/browser/runtime/types/consts.d.ts index 3ada8dc3dcaae..7400c15b8bbc0 100644 --- a/src/mono/browser/runtime/types/consts.d.ts +++ b/src/mono/browser/runtime/types/consts.d.ts @@ -7,7 +7,7 @@ declare module "consts:*" { export default constant; } -declare module "consts:monoWasmThreads" { +declare module "consts:wasmEnableThreads" { const constant: boolean; export default constant; } diff --git a/src/mono/browser/runtime/web-socket.ts b/src/mono/browser/runtime/web-socket.ts index ad5c71b10949d..a5f783e0aeab8 100644 --- a/src/mono/browser/runtime/web-socket.ts +++ b/src/mono/browser/runtime/web-socket.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import MonoWasmThreads from "consts:monoWasmThreads"; +import WasmEnableThreads from "consts:wasmEnableThreads"; import { prevent_timer_throttling } from "./scheduling"; import { Queue } from "./queue"; @@ -404,7 +404,7 @@ function _mono_wasm_web_socket_send_buffering(ws: WebSocketExtension, buffer_vie else { if (length !== 0) { // we could use the un-pinned view, because it will be immediately used in ws.send() - if (MonoWasmThreads) { + if (WasmEnableThreads) { buffer = buffer_view.slice(); // copy, because the provided ArrayBufferView value must not be shared. } else { buffer = buffer_view; @@ -462,7 +462,7 @@ type Message = { } function resolvedPromise(): Promise | null { - if (!MonoWasmThreads) { + if (!WasmEnableThreads) { // signal that we are finished synchronously // this is optimization, which doesn't allocate and doesn't require to marshal resolve() call to C# side. return null; diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 022da2f21f010..3b0ade6bd89cc 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -8,7 +8,7 @@ - MonoAOTEnableLLVM - enable LLVM for an AOT-only Mono - MonoVerboseBuild - enable verbose build - MonoThreadSuspend - coop,hybrid,preemptive - default thread suspend mode - - MonoWasmThreads - build runtime with threading support for wasm + - WasmEnableThreads - build runtime with threading support for wasm --> @@ -51,8 +51,6 @@ <_CompilerTargetArch Condition="'$(AotHostArchitecture)' != ''">$(AotHostArchitecture) $([MSBuild]::NormalizeDirectory('$(RepositoryEngineeringDir)', 'common')) $([MSBuild]::NormalizePath('$(RepositoryEngineeringCommonDir)', 'cross', 'toolchain.cmake')) - false - true $(runtimelinuxx64MicrosoftNETCoreRuntimeMonoLLVMSdkVersion.Substring(0, $(runtimelinuxx64MicrosoftNETCoreRuntimeMonoLLVMSdkVersion.IndexOf('.')))) true @@ -60,7 +58,7 @@ coop - coop + coop preemptive @@ -428,7 +426,7 @@ <_MonoMinimal Condition="'$(Configuration)' == 'Release'">,debugger_agent,log_dest <_MonoMinimal Condition="'$(Configuration)' == 'Release' and '$(MonoEnableAssertMessages)' != 'true'">$(_MonoMinimal),assert_messages - <_MonoMinimal Condition="'$(MonoWasmThreads)' != 'true'">$(_MonoMinimal),threads + <_MonoMinimal Condition="'$(WasmEnableThreads)' != 'true'">$(_MonoMinimal),threads <_MonoCMakeArgs Include="-DENABLE_MINIMAL=jit,sgen_major_marksweep_conc,sgen_split_nursery,sgen_gc_bridge,sgen_toggleref,sgen_debug_helpers,sgen_binary_protocol,logging,interpreter,qcalls$(_MonoMinimal)"/> @@ -437,18 +435,18 @@ <_MonoCMakeArgs Include="-DENABLE_ICALL_EXPORT=1"/> <_MonoCMakeArgs Include="-DENABLE_LAZY_GC_THREAD_CREATION=1"/> <_MonoCMakeArgs Include="-DENABLE_WEBCIL=1"/> - <_MonoCFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="-pthread"/> - <_MonoCFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="-D_GNU_SOURCE=1" /> - <_MonoCXXFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="-pthread"/> - <_MonoCXXFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="-D_GNU_SOURCE=1" /> + <_MonoCFLAGS Condition="'$(WasmEnableThreads)' == 'true'" Include="-pthread"/> + <_MonoCFLAGS Condition="'$(WasmEnableThreads)' == 'true'" Include="-D_GNU_SOURCE=1" /> + <_MonoCXXFLAGS Condition="'$(WasmEnableThreads)' == 'true'" Include="-pthread"/> + <_MonoCXXFLAGS Condition="'$(WasmEnableThreads)' == 'true'" Include="-D_GNU_SOURCE=1" /> <_MonoCMakeArgs Include="-DENABLE_LLVM_RUNTIME=1"/> <_MonoCMakeArgs Include="-DEMSCRIPTEN_SYSTEM_PROCESSOR=wasm"/> - <_MonoCFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Condition="'$(WasmEnableThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm-threads', 'native', 'include'))$(EscapedQuoteW)"/> - <_MonoCFLAGS Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Condition="'$(WasmEnableThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/> @@ -463,8 +461,8 @@ <_MonoCFLAGS Include="-D_WASI_EMULATED_PROCESS_CLOCKS"/> <_MonoCFLAGS Include="-D_WASI_EMULATED_SIGNAL"/> <_MonoCFLAGS Include="-D_WASI_EMULATED_MMAN"/> - <_MonoCFLAGS Condition="'$(MonoWasmThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'wasi-wasm-threads', 'native', 'include').Replace('\','/'))$(EscapedQuoteW)"/> - <_MonoCFLAGS Condition="'$(MonoWasmThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'wasi-wasm', 'native', 'include').Replace('\','/'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Condition="'$(WasmEnableThreads)' == 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'wasi-wasm-threads', 'native', 'include').Replace('\','/'))$(EscapedQuoteW)"/> + <_MonoCFLAGS Condition="'$(WasmEnableThreads)' != 'true'" Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'wasi-wasm', 'native', 'include').Replace('\','/'))$(EscapedQuoteW)"/> diff --git a/src/mono/sample/wasm/browser-eventpipe/README.md b/src/mono/sample/wasm/browser-eventpipe/README.md index bbbf5d872a834..37e906ce9e3cd 100644 --- a/src/mono/sample/wasm/browser-eventpipe/README.md +++ b/src/mono/sample/wasm/browser-eventpipe/README.md @@ -1,10 +1,10 @@ [see also](../../../wasm/runtime/diagnostics/README.md) -To be able to run this sample you need to build the runtime with `/p:MonoWasmBuildVariant=multithread` and use Chrome browser +To be able to run this sample you need to build the runtime with `/p:WasmEnableThreads=true` and use Chrome browser # Testing with mock -Build the runtime with `/p:MonoWasmBuildVariant=multithread /p:MonoDiagnosticsMock=true` +Build the runtime with `/p:WasmEnableThreads=true /p:MonoDiagnosticsMock=true` Run this test with `/p:MonoDiagnosticsMock=true` It will inject file [mock.js](./mock.js) into the worker thread, which is mocking the `dotnet trace` tool. @@ -17,7 +17,7 @@ dotnet trace convert --format Speedscope c:\Downloads\trace.1665653486202.nettra # Testing with dotnet trace tool -Build the runtime with `/p:MonoWasmBuildVariant=multithread` +Build the runtime with `/p:WasmEnableThreads=true` Build a version of dsrouter with WebSockets support (versions from upstream that target net6.0 or later have the requisite support, see https://github.com/dotnet/diagnostics/blob/main/src/Tools/dotnet-dsrouter/dotnet-dsrouter.csproj) In console #1 start dsrouter diff --git a/src/mono/sample/wasm/browser-eventpipe/main.js b/src/mono/sample/wasm/browser-eventpipe/main.js index e4f4c949b09c4..c12072d724875 100644 --- a/src/mono/sample/wasm/browser-eventpipe/main.js +++ b/src/mono/sample/wasm/browser-eventpipe/main.js @@ -67,7 +67,7 @@ async function main() { btn.onclick = () => doWork(exports.Sample.Test.StartAsyncWork, exports.Sample.Test.StopWork, exports.Sample.Test.GetIterationsDone); if (INTERNAL.diagnosticServerThread === undefined) { - console.warn("please recompile runtime with /p:MonoWasmBuildVariant=multithread /p:MonoDiagnosticsMock=true" + event.type) + console.warn("please recompile runtime with /p:WasmEnableThreads=true /p:MonoDiagnosticsMock=true" + event.type) return; } diff --git a/src/mono/wasi/build/WasiApp.InTree.props b/src/mono/wasi/build/WasiApp.InTree.props index 2d2124c33699a..894b17f646e38 100644 --- a/src/mono/wasi/build/WasiApp.InTree.props +++ b/src/mono/wasi/build/WasiApp.InTree.props @@ -15,7 +15,7 @@ <_MonoRuntimeComponentDontLink Include="libmono-component-debugger-stub-static.a" /> - <_MonoRuntimeComponentDontLink Include="libmono-component-diagnostics_tracing-static.a" Condition="'$(FeatureWasmPerfTracing)' != 'true' and $(FeatureWasmThreads) != 'true'"/> + <_MonoRuntimeComponentDontLink Include="libmono-component-diagnostics_tracing-static.a" Condition="'$(FeatureWasmPerfTracing)' != 'true' and $(FeatureWasmManagedThreads) != 'true'"/> <_MonoRuntimeComponentDontLink Include="libmono-component-hot_reload-stub-static.a" /> <_MonoRuntimeComponentDontLink Include="libmono-component-marshal-ilgen-stub-static.a" /> diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj index 7b8772070596f..bd03a1a0e79b4 100644 --- a/src/mono/wasi/wasi.proj +++ b/src/mono/wasi/wasi.proj @@ -6,8 +6,8 @@ - $([MSBuild]::NormalizeDirectory('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'wasi-wasm', 'native', 'lib')) - $([MSBuild]::NormalizeDirectory('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'wasi-wasm-threads', 'native', 'lib')) + $([MSBuild]::NormalizeDirectory('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'wasi-wasm', 'native', 'lib')) + $([MSBuild]::NormalizeDirectory('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'wasi-wasm-threads', 'native', 'lib')) false false $(ArtifactsObjDir)wasi @@ -124,15 +124,15 @@ --> - + <_WasiFlags Include="@(_WasiCommonFlags)" /> - <_WasiCompileFlags Condition="'$(MonoWasmThreads)' == 'true'" Include="-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'wasi-wasm-threads', 'native', 'include').Replace('\','/'))"/> - <_WasiCompileFlags Condition="'$(MonoWasmThreads)' != 'true'" Include="-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'wasi-wasm', 'native', 'include').Replace('\','/'))"/> + <_WasiCompileFlags Condition="'$(WasmEnableThreads)' == 'true'" Include="-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'wasi-wasm-threads', 'native', 'include').Replace('\','/'))"/> + <_WasiCompileFlags Condition="'$(WasmEnableThreads)' != 'true'" Include="-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'wasi-wasm', 'native', 'include').Replace('\','/'))"/> <_WasiCompileFlags Include="-I$([MSBuild]::NormalizePath('$(WasiProjectRoot)', 'include').Replace('\','/'))"/> <_WasiCompileFlags Include="-I$([MSBuild]::NormalizePath('$(WasiProjectRoot)', 'mono-include').Replace('\','/'))"/> <_WasiCompileFlags Include="-I$([MSBuild]::NormalizePath('$(RepoRoot)', 'src', 'native', 'public').Replace('\','/'))"/> @@ -217,7 +217,7 @@ $(CMakeBuildRuntimeConfigureCmd) -DNATIVE_BIN_DIR="$(NativeBinDir.TrimEnd('\/'))" $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_COMPILE_OPTIONS="-msimd128" -DCONFIGURATION_INTERPSIMDTABLES_LIB="simd" $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_INTERPSIMDTABLES_LIB="nosimd" - $(CMakeBuildRuntimeConfigureCmd) -DDISABLE_THREADS=0 + $(CMakeBuildRuntimeConfigureCmd) -DDISABLE_THREADS=0 call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" wasm && $(CMakeBuildRuntimeConfigureCmd) -v diff --git a/src/mono/wasm/threads.md b/src/mono/wasm/threads.md index d5fc9e5e63f4a..91ebb7c929aa5 100644 --- a/src/mono/wasm/threads.md +++ b/src/mono/wasm/threads.md @@ -2,7 +2,7 @@ ## Building the runtime ## -Build the runtime with `/p:MonoWasmBuildVariant=multithread` to enable support for multi-threading. +Build the runtime with `/p:WasmEnableThreads=true` to enable support for multi-threading. ## Building sample apps ## @@ -11,8 +11,8 @@ This also works with released versions of .NET 7 or later and the `wasmbrowser` ## Libraries feature defines ## -We use the `FeatureWasmThreads` property in the libraries projects to conditionally define -`FEATURE_WASM_THREADS` which is used to affect how the libraries are built for the multi-threaded +We use the `FeatureWasmManagedThreads` property in the libraries projects to conditionally define +`FEATURE_WASM_MANAGED_THREADS` which is used to affect how the libraries are built for the multi-threaded runtime. We use the `FeatureWasmPerfTracing` property in the libraries projects to @@ -23,7 +23,7 @@ internally can use multithreading for EventPipe diagnostics. ### Ref asssemblies ### For ref assemblies that have APIs that are related to threading, we use -`[UnsupportedOSPlatform("browser")]` under a `FEATURE_WASM_THREADS` define to mark APIs that are not +`[UnsupportedOSPlatform("browser")]` under a `FEATURE_WASM_MANAGED_THREADS` define to mark APIs that are not supported with the single-threaded runtime. Each such ref assembly (for example `System.Threading.Thread`) is defined in two places: `src/libraries/System.Threading.Thread/ref` for the single-threaded ref assemblies, and diff --git a/src/native/libs/build-native.proj b/src/native/libs/build-native.proj index bbf272365a899..aec082e1c0a53 100644 --- a/src/native/libs/build-native.proj +++ b/src/native/libs/build-native.proj @@ -12,9 +12,9 @@ <_BuildNativeArgs Condition="'$(OfficialBuildId)' != ''">$(_BuildNativeArgs) /p:OfficialBuildId="$(OfficialBuildId)" <_RuntimeVariant /> - <_RuntimeVariant Condition="'$(MonoWasmBuildVariant)' == 'multithread'">-threads + <_RuntimeVariant Condition="'$(WasmEnableThreads)' == 'true'">-threads <_UsePThreads /> - <_UsePThreads Condition="'$(MonoWasmBuildVariant)' == 'multithread'"> usepthreads + <_UsePThreads Condition="'$(WasmEnableThreads)' == 'true'"> usepthreads <_IcuDir Condition="'$(TargetsAppleMobile)' != 'true' and '$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)' != ''">$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/$(TargetOS)-$(TargetArchitecture)$(_RuntimeVariant)/native <_IcuDirArg Condition="'$(_IcuDir)' != ''"> icudir "$(_IcuDir)"