Skip to content

Commit b44c008

Browse files
lambdageekradekdoulikRadek DoulikvargazSteve Pfister
authored
[mono] merge wasm-threading-eventpipe into main (#68232)
Merge initial work on multi-threaded WebAssembly. The normal wasm build is single-threaded. There should be no functional changes to its behavior. To enable a multi-threaded build pass `/p:WasmEnableThreads=true`. See `src/mono/wasm/threads.md` for details. The big changes are: 1. The normal ref assemblies related to threading retain `[UnsupportedOSPlatform("browser")]` attributes for various threading-related functions 2. In System.Private.CoreLib, the `[UnsupportedOSPlatform]` attributes are removed, and functions that used to always throw PNSE nwo do a runtime check using `System.Threading.Thread.IsThreadStartSupported` to check if threading is enabled in the current build. 3. A new nuget `Microsoft.NET.WebAssembly.Threading` is created. It contains experimental ref assemblies without the `[UnsupportedOSPlatform]` attributes. The intention is that code opting into experimenting with multithreading will include this nuget by setting some property that will be used by the wasm MSBuild SDK to pick a multi-threaded runtime build and configure things appropriately. (The SDK updates don't exist yet). 4. In the multi-threaded runtime we don't use Emscripten's "main thread" option (ie: the browser thread is the main one); we also continue to run certain runtime-internal jobs (finalizers, GC pump) on the main thread even in the multi-threaded runtime. Remaining work is tracked in the related issue #68162 --- * Initial changes for emscripten 2.0.34 * Use emcc-link.rsp in build targets * Use updated docker images * Fix compiler warnings * Put `--profiling-funcs` to `_EmccLinkFlags` * Fix build src/mono/mono/mini/mini-runtime.c:3407:25: error: ‘invoke’ undeclared (first use in this function); did you mean ‘revoke’? 3407 | invoke = mono_marshal_get_runtime_invoke_dynamic (); * Add shell to the environment Environment setting https://github.com/emscripten-core/emscripten/blob/2.0.34/src/settings.js#L616-L641 From emscripten 2.0.25 release notes - Support for the 'shell' environment is now disabled by default. Running under `d8`, `js`, or `jsc` is not something that most emscripten users ever want to do, so including the support code is, more often than not, unnecessary. Users who want shell support can enable it by including 'shell' in `-s ENVIRONMENT` (#14535). Example of the the size increase for bench sample: -a--- 12/10/2021 3:35 PM 382113 dotnet.js -a--- 12/13/2021 10:37 AM 383589 dotnet.js * Add emcc-link.rsp to PlatformManifestFileEntry * Feedback https://github.com/emscripten-core/emscripten/blob/2fda25eea756c78c8cb024aa5b6c2b188bf7990f/src/settings.js#L1173-L1176 -s EXPORT_ES6 is link option * Bump emscripten version * Bump llvm package version and use its libclang * Use newer docker images with emscripten 3.1.1 * Remove unused variable * Add runtime support for threads in the wasm build To enable, pass `/p:WasmEnableThreads` when building the runtime ./build.sh -Subset mono+libs -os Browser -arch wasm /p:WasmEnableThreads=true * Prevent runtime from starting twice when loaded in a web worker * Automatically populate the emscripten mainScriptUrlOrBlob property so that worker initialization can find dotnet.js * Add compatibility shim so that emscripten's generated worker.js can properly get a Module instance, since we broke the API * Checkpoint * Bring back threadpool and add some tracing in diagnostics * Add comments and fix a typo * Introduce 'MonoObjectRef' ts type. Migrate mono_string_intern to not have a retval * Checkpoint (strings are broken for some reason) * Fix string interning * Migrate ObjectToString and GetDateValue * Checkpoint gc safe/unsafe region work * More ref conversion * Checkpoint (broken?) * Fix missing method * Fix incorrect signatures * Fix lint * Add new 'R' signature char for 'ref object' * Remove AddEventListener and RemoveEventListener Checkpoint * eslint fixes * Update call_method signature to avoid passing raw object pointers * Ref-ify one websocket API and fix types and incorrect rooting of two others * Deprecation metadata * More ref * Remove outdated comments * Convert typed_array_new to ref * Add volatile modifiers, satisfy eslint * Update src/mono/wasm/runtime/corebindings.c * Missing conflict * Fix build, set coop gc, and always copy dotnet.worker.js when it's around for apps * Disable sample profiler, add some functions that were missing from katelyn's PR. * Add safepoint around ep_rt_wait_event_set. Tweak sample to explicitly exit wasm in order to properly flush event to the nettrace file (w/ rundown events). * [gc] Start the GC Finalizer thread on threaded WASM * [mono] add GC Unsafe in mono_assembly_load; remove in EventPipe Remove GC Unsafe hack in ep_rt_wait_event_set * post-merge cleanup: delete duplicated definitions * [sample] Env vars should be stringy * updated dotnet.d.ts * Add mono_threads_wasm_async_run_in_main_thread; do background work on main Don't start a finalizer thread Queue all background work to run on the main thread * [mono] Fix non-threaded wasm build * Add a System.Threading.Thread.WebAssembly.Threading ref assembly * Update the browser sample to use System.Threading.Thread.WebAssembly.Threading * Rationalize System.Threading.Thread build In CoreLib, never add the [UnsupportedOSPlatform("browser")] attribute. Rely on runtime checks (`ThrowIfNoThreadStart()`). In System.Threading.Thread ref assembly, always add the unsupported platform attribute. Add mismatches to ApiCompat baseline. In System.Threading.Thread.WebAssembly.Threading don't add the attributes, and also set DisablePackageBaselineValidation to prevent Restore from looking for a System.Threading.Thread.WebAssembly.Threading nuget (fixes in-tree ProjectReferences for testing) * only turn on analyzers for the browser sample not all wasm samples * Make a single Microsoft.NET.WebAssembly.Threading nupkg that holds all the special ref assemblies * works: sample has ProjectReference to the Microsoft.NET.WebAssembly.Threading.proj * Add System.Threading.ThreadPool.WebAssembly.Threading ref assembly * ThreadPool: throw PNSE if no thread start * Update wasm threads.md * apicompat: correct warnings for System.Threading.ThreadPool * Add dotnet.worker.js to the runtime pack; update PlatformManifestFileEntry * [wasm] startup: detect Blazor dotnet.[version].[hash].js location Blazor injects a `<link rel="modulepreload" />` element into the header when it boots; detect it and extract the URL of the script. This is needed by Emscripten's dotnet.worker.js to run WorkerGlobalScope.importScripts * one more fix to Microsoft.NET.WebAssembly.Threading Seems to be necessary in order for the resulting .nupkg not to reference non-existent nugets for the ProjectReferences * rename sample to browser-mt-eventpipe * bring back unmodified browser sample The multithreading sample is browser-mt-eventpipe * update browser-mt-eventpipe sample to use ref assembly refs Referencing the rollup Microsoft.NET.WebAssembly.Threading.proj doesn't work (it ends up bundling the ref assemblies into the publish dir and breaking the app) * Use correct ifdef in AppContext.AnyOS.cs * [build] support WasmEnableThreads and WasmEnablePerfTracing These toplevel options either turn on multi-threading in general, or turn on multithreading only for eventpipe internals. For libraries these define `FeatureWasmThreads` and `FeatureWasmPerfTracing` properties and the `FEATURE_WASM_THREADS` and `FEATURE_WASM_PERFTRACING` compiler constants. For the native code, they control `DISABLE_THREADS` and `DISABLE_WASM_USER_THREADS` cmake and preprocessor settings. * Only add the portable threadpool on wasm if threading is enabled * rename browser-mt-eventpipe csproj and main assembly Give it a unique name distinct from Wasm.Browser.CJS.Sample.csproj * fix /p:WasmEnableThreads=false build after merge * now fix the WasmEnableThreads=true build * we need two ThreadPoolBoundHandle implementation stubs one for PortableThreadPool when threads are enabled, one for single-threaded wasm * Add a System.Diagnostics.Tracing ref assembly gated by FeatureWasmPerfTracing * [eventpipe] use the correct cmake option name see src/mono/mono.proj * revert debug printf and commented out code * turn off additional logging * hack: set FeatureWasmPerfTracing in the browser-mt-eventpipe sample It would be better to drive this (the inclusion of the tracing runtime component) from a user-visible flag. not the FeatureWasmPerfTracing implementation detail * remove unused variable, remove unneeded configure checks, revert line damage; add better comment in export.ts * Exclude Microsoft.NET.WebAssembly.Threading from testPackages.proj * review feedback, Apply suggestions from code review * Use a testPackages settings file to skip package runtime item verification * remove unneeded Directory.Build.props for ref package since ti doesn't compile its own assembly, none of these properties are needed * use one ProjectReference item to share metadata for the ref assemblies * remove ProjectReference comment and NoTargetsDoNotReferenceOutputAssemblies prop * Remove unneeded target * packaging simplification - move `_ExperimentalUpdateFileVersion` target to packaging.targets, conditioned on a new `IsExperimentalRefAssembly` attribute. (The target increments the file version of the ref assembly to make it easier to distinguish from the real non-experimental ref assembly) - Remove unneeded src subdirectories in ref assembly libraries - Move properties that are only used in the ref assembly projects directory into the projects and delete Directory.Build.props in the experimental ref assembly subdirectories. * move and rename UpdateExperimentalRefAssemblyFileVersion target packages.targets is only included for IsPackable=true projects, and these ref assemblies are not packable. * Assorted code review nits * Don't build/pack the multi-threaded sample on single-threaded runtime * remove gratuitous debug printfs * Apply suggestions from code review * merge followup: nullable is enabled by default now * make eslint happy * include wasm-config.h in wasm runtime host * include wasm-config.h into the runtime pack fixes aot compilation * Add wasm-config.h to manifest * put wasm-config.h into include/wasm from the outset * put back noExitRuntime replacement for CJS Co-authored-by: Radek Doulik <[email protected]> Co-authored-by: Radek Doulik <[email protected]> Co-authored-by: Zoltan Varga <[email protected]> Co-authored-by: Steve Pfister <[email protected]> Co-authored-by: Katelyn Gadd <[email protected]> Co-authored-by: Viktor Hofer <[email protected]>
1 parent 8006e6a commit b44c008

File tree

66 files changed

+793
-85
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+793
-85
lines changed

eng/references.targets

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,20 @@
9191
Condition="$(NetCoreAppLibraryNoReference.Contains('%(Filename);'))" />
9292
</ItemGroup>
9393
</Target>
94+
95+
<!-- For experimental ref assemblies (which typically have the same name as a regular ref
96+
assembly), bump their minor file version by 100 to make it distinguishable from the regular
97+
ref assembly.
98+
-->
99+
<Target Name="UpdateExperimentalRefAssemblyFileVersion"
100+
AfterTargets="_InitializeAssemblyVersion"
101+
Condition="'$(IsReferenceAssemblyProject)' == 'true' and '$(IsExperimentalRefAssembly)' == 'true'">
102+
<PropertyGroup>
103+
<_FileVersionMaj>$(FileVersion.Split('.')[0])</_FileVersionMaj>
104+
<_FileVersionMin>$(FileVersion.Split('.')[1])</_FileVersionMin>
105+
<_FileVersionBld>$(FileVersion.Split('.')[2])</_FileVersionBld>
106+
<_FileVersionRev>$(FileVersion.Split('.')[3])</_FileVersionRev>
107+
<FileVersion>$(_FileVersionMaj).$([MSBuild]::Add($(_FileVersionMin), 100)).$(_FileVersionBld).$(_FileVersionRev)</FileVersion>
108+
</PropertyGroup>
109+
</Target>
94110
</Project>

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/ThreadPool.Windows.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ namespace System.Threading
1313
//
1414
// Windows-specific implementation of ThreadPool
1515
//
16-
[UnsupportedOSPlatform("browser")]
1716
public sealed class RegisteredWaitHandle : MarshalByRefObject
1817
{
1918
private readonly Lock _lock;

src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@
211211
<PlatformManifestFileEntry Include="libmono-wasm-eh-wasm.a" IsNative="true" />
212212
<PlatformManifestFileEntry Include="System.Private.Runtime.InteropServices.Javascript.dll" />
213213
<PlatformManifestFileEntry Include="dotnet.js" IsNative="true" />
214+
<PlatformManifestFileEntry Include="dotnet.worker.js" IsNative="true" />
214215
<PlatformManifestFileEntry Include="dotnet.js.symbols" IsNative="true" />
215216
<PlatformManifestFileEntry Include="dotnet.d.ts" IsNative="true" />
216217
<PlatformManifestFileEntry Include="dotnet.wasm" IsNative="true" />
@@ -237,6 +238,7 @@
237238
<PlatformManifestFileEntry Include="pinvoke.c" IsNative="true" />
238239
<PlatformManifestFileEntry Include="pinvoke.h" IsNative="true" />
239240
<PlatformManifestFileEntry Include="gc-common.h" IsNative="true" />
241+
<PlatformManifestFileEntry Include="wasm-config.h" IsNative="true" />
240242
<PlatformManifestFileEntry Include="emcc-default.rsp" IsNative="true" />
241243
<PlatformManifestFileEntry Include="emcc-link.rsp" IsNative="true" />
242244
<PlatformManifestFileEntry Include="emcc-props.json" IsNative="true" />
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Project Sdk="Microsoft.Build.NoTargets">
2+
<PropertyGroup>
3+
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
4+
<IncludeBuildOutput>true</IncludeBuildOutput>
5+
<DebugSymbols>false</DebugSymbols>
6+
<DebugType>none</DebugType>
7+
<NoTargetsDoNotReferenceOutputAssemblies>false</NoTargetsDoNotReferenceOutputAssemblies>
8+
<DisablePackageBaselineValidation>true</DisablePackageBaselineValidation>
9+
<IsPackable>true</IsPackable>
10+
<PackageDescription>Exposes Threading APIs for WebAssembly projects</PackageDescription>
11+
<!-- XXX FIXME: NU5128 suppresses a really scary message about missing net7.0 dependencies -->
12+
<NoWarn>$(NoWarn);NU5128;NU5131</NoWarn>
13+
<!-- Place assemblies in the nuget ref folder -->
14+
<BuildOutputTargetFolder>ref</BuildOutputTargetFolder>
15+
</PropertyGroup>
16+
17+
<ItemGroup>
18+
<ProjectReference
19+
Include="$(LibrariesProjectRoot)System.Threading.Thread.WebAssembly.Threading\ref\System.Threading.Thread.WebAssembly.Threading.csproj;
20+
$(LibrariesProjectRoot)System.Threading.ThreadPool.WebAssembly.Threading\ref\System.Threading.ThreadPool.WebAssembly.Threading.csproj;
21+
$(LibrariesProjectRoot)System.Diagnostics.Tracing.WebAssembly.PerfTracing\ref\System.Diagnostics.Tracing.WebAssembly.PerfTracing.csproj"
22+
Pack="true" PrivateAssets="all" Private="true" IncludeReferenceAssemblyInPackage="true" />
23+
</ItemGroup>
24+
25+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
4+
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
5+
<FeatureWasmPerfTracing>true</FeatureWasmPerfTracing>
6+
<AssemblyName>System.Diagnostics.Tracing</AssemblyName>
7+
<!-- tell references.targets to bump the assembly version -->
8+
<IsExperimentalRefAssembly>true</IsExperimentalRefAssembly>
9+
<!-- Disable all binplacing since this assembly will clash with the real ref assembly -->
10+
<EnableBinPlacing>false</EnableBinPlacing>
11+
<StrongNameKeyId>Microsoft</StrongNameKeyId>
12+
<IncludePlatformAttributes>true</IncludePlatformAttributes>
13+
<DefineConstants Condition="'$(FeatureWasmPerfTracing)' == 'true'">$(DefineConstants);FEATURE_WASM_PERFTRACING</DefineConstants>
14+
</PropertyGroup>
15+
<ItemGroup>
16+
<Compile Include="..\..\System.Diagnostics.Tracing\ref\System.Diagnostics.Tracing.cs" />
17+
<Compile Include="..\..\System.Diagnostics.Tracing\ref\System.Diagnostics.Tracing.Counters.cs" />
18+
</ItemGroup>
19+
<ItemGroup>
20+
<ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" PrivateAssets="all" />
21+
</ItemGroup>
22+
</Project>

src/libraries/System.Diagnostics.Tracing/ref/System.Diagnostics.Tracing.Counters.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
namespace System.Diagnostics.Tracing
55
{
6+
#if !FEATURE_WASM_PERFTRACING
67
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
8+
#endif
79
public abstract partial class DiagnosticCounter : System.IDisposable
810
{
911
internal DiagnosticCounter() { }
@@ -14,28 +16,36 @@ internal DiagnosticCounter() { }
1416
public void AddMetadata(string key, string? value) { }
1517
public void Dispose() { }
1618
}
19+
#if !FEATURE_WASM_PERFTRACING
1720
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
21+
#endif
1822
public partial class PollingCounter : System.Diagnostics.Tracing.DiagnosticCounter
1923
{
2024
public PollingCounter(string name, System.Diagnostics.Tracing.EventSource eventSource, System.Func<double> metricProvider) { }
2125
public override string ToString() { throw null; }
2226
}
27+
#if !FEATURE_WASM_PERFTRACING
2328
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
29+
#endif
2430
public partial class IncrementingEventCounter : System.Diagnostics.Tracing.DiagnosticCounter
2531
{
2632
public IncrementingEventCounter(string name, System.Diagnostics.Tracing.EventSource eventSource) { }
2733
public System.TimeSpan DisplayRateTimeScale { get { throw null; } set { } }
2834
public void Increment(double increment = 1) { }
2935
public override string ToString() { throw null; }
3036
}
37+
#if !FEATURE_WASM_PERFTRACING
3138
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
39+
#endif
3240
public partial class IncrementingPollingCounter : System.Diagnostics.Tracing.DiagnosticCounter
3341
{
3442
public IncrementingPollingCounter(string name, System.Diagnostics.Tracing.EventSource eventSource, System.Func<double> totalValueProvider) { }
3543
public System.TimeSpan DisplayRateTimeScale { get { throw null; } set { } }
3644
public override string ToString() { throw null; }
3745
}
46+
#if !FEATURE_WASM_PERFTRACING
3847
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
48+
#endif
3949
public partial class EventCounter : System.Diagnostics.Tracing.DiagnosticCounter
4050
{
4151
public EventCounter(string name, System.Diagnostics.Tracing.EventSource eventSource) { }

src/libraries/System.Diagnostics.Tracing/ref/System.Diagnostics.Tracing.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<PropertyGroup>
33
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
44
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
5+
<FeatureWasmPerfTracing>false</FeatureWasmPerfTracing>
6+
<DefineConstants Condition="'$(FeatureWasmPerfTracing)' == 'true'">$(DefineConstants);FEATURE_WASM_PERFTRACING</DefineConstants>
57
</PropertyGroup>
68
<ItemGroup>
79
<Compile Include="System.Diagnostics.Tracing.cs" />
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Compat issues with assembly System.Diagnostics.Tracing:
2+
CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' exists on 'System.Diagnostics.Tracing.DiagnosticCounter' in the contract but not the implementation.
3+
CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' exists on 'System.Diagnostics.Tracing.EventCounter' in the contract but not the implementation.
4+
CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' exists on 'System.Diagnostics.Tracing.IncrementingEventCounter' in the contract but not the implementation.
5+
CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' exists on 'System.Diagnostics.Tracing.IncrementingPollingCounter' in the contract but not the implementation.
6+
CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' exists on 'System.Diagnostics.Tracing.PollingCounter' in the contract but not the implementation.
7+
Total Issues: 4
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Compat issues with assembly System.Diagnostics.Tracing:
2+
CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' exists on 'System.Diagnostics.Tracing.DiagnosticCounter' in the contract but not the implementation.
3+
CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' exists on 'System.Diagnostics.Tracing.EventCounter' in the contract but not the implementation.
4+
CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' exists on 'System.Diagnostics.Tracing.IncrementingEventCounter' in the contract but not the implementation.
5+
CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' exists on 'System.Diagnostics.Tracing.IncrementingPollingCounter' in the contract but not the implementation.
6+
CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' exists on 'System.Diagnostics.Tracing.PollingCounter' in the contract but not the implementation.
27
MembersMustExist : Member 'protected void System.Diagnostics.Tracing.EventCounter.Flush()' does not exist in the reference but it does exist in the implementation.
38
CannotMakeTypeAbstract : Type 'System.Diagnostics.Tracing.EventListener' is abstract in the reference but is not abstract in the implementation.
49
CannotMakeMoreVisible : Visibility of member 'System.Diagnostics.Tracing.EventListener..ctor()' is 'protected' in the reference but 'public' in the implementation.
510
CannotMakeMoreVisible : Visibility of member 'System.Diagnostics.Tracing.EventListener.EventSourceIndex(System.Diagnostics.Tracing.EventSource)' is 'protected' in the reference but 'public' in the implementation.
6-
Total Issues: 4
11+
Total Issues: 8

src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
<Compile Include="$(MSBuildThisFileDirectory)System\Activator.RuntimeType.cs" Condition="'$(TargetsCoreRT)' != 'true'" />
7575
<Compile Include="$(MSBuildThisFileDirectory)System\AggregateException.cs" />
7676
<Compile Include="$(MSBuildThisFileDirectory)System\AppContext.cs" />
77-
<Compile Include="$(MSBuildThisFileDirectory)System\AppContext.AnyOS.cs" Condition="'$(TargetsBrowser)' != 'true'" />
77+
<Compile Include="$(MSBuildThisFileDirectory)System\AppContext.AnyOS.cs" />
7878
<Compile Include="$(MSBuildThisFileDirectory)System\AppContextConfigHelper.cs" />
7979
<Compile Include="$(MSBuildThisFileDirectory)System\AppDomain.cs" />
8080
<Compile Include="$(MSBuildThisFileDirectory)System\AppDomainSetup.cs" />
@@ -2329,7 +2329,7 @@
23292329
<ItemGroup Condition="'$(FeaturePortableThreadPool)' == 'true'">
23302330
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadPool.Portable.cs" Condition="'$(FeatureCoreCLR)' != 'true'" />
23312331
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadPool.Portable.Windows.cs" Condition="'$(TargetsWindows)' == 'true' and '$(FeatureCoreCLR)' != 'true'" />
2332-
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadPool.Portable.Unix.cs" Condition="'$(TargetsUnix)' == 'true'" />
2332+
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadPool.Portable.Unix.cs" Condition="'$(TargetsUnix)' == 'true' or '$(TargetsBrowser)' == 'true'" />
23332333
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\NativeRuntimeEventSource.PortableThreadPool.cs" Condition="'$(FeatureCoreCLR)' != 'true' and '$(FeatureMono)' != 'true'" />
23342334
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\NativeRuntimeEventSource.PortableThreadPool.NativeSinks.cs" Condition="'$(FeatureCoreCLR)' == 'true' or '$(FeatureMono)' == 'true'" />
23352335
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\PortableThreadPool.cs" />
@@ -2346,7 +2346,7 @@
23462346
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\PortableThreadPool.CpuUtilizationReader.Windows.cs" Condition="'$(TargetsWindows)' == 'true'" />
23472347
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\LowLevelLifoSemaphore.cs" />
23482348
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\LowLevelLifoSemaphore.Windows.cs" Condition="'$(TargetsWindows)' == 'true'" />
2349-
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\PreAllocatedOverlapped.cs" />
2349+
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\PreAllocatedOverlapped.cs" Condition="'$(TargetsBrowser)' != 'true' or '$(FeatureWasmThreads)' == 'true'"/>
23502350
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\RegisteredWaitHandle.Portable.cs" />
23512351
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadPoolBoundHandle.cs" />
23522352
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadPoolBoundHandle.Unix.cs" Condition="'$(TargetsUnix)' == 'true'" />

src/libraries/System.Private.CoreLib/src/System/AppContext.AnyOS.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace System
1212
{
1313
public static partial class AppContext
1414
{
15+
#if !TARGET_BROWSER
1516
[UnconditionalSuppressMessage("SingleFile", "IL3000: Avoid accessing Assembly file path when publishing as a single file",
1617
Justification = "Single File apps should always set APP_CONTEXT_BASE_DIRECTORY therefore code handles Assembly.Location equals null")]
1718
private static string GetBaseDirectoryCore()
@@ -33,6 +34,7 @@ private static string GetBaseDirectoryCore()
3334

3435
return directory;
3536
}
37+
#endif
3638

3739
#if FEATURE_PERFTRACING
3840
internal static void LogSwitchValues(RuntimeEventSource ev)

src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterGroup.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ namespace Microsoft.Diagnostics.Tracing
1515
namespace System.Diagnostics.Tracing
1616
#endif
1717
{
18-
#if NETCOREAPP
19-
[UnsupportedOSPlatform("browser")]
20-
#endif
2118
internal sealed class CounterGroup
2219
{
2320
private readonly EventSource _eventSource;

src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/DiagnosticCounter.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ namespace System.Diagnostics.Tracing
2020
/// DiagnosticCounter is an abstract class that serves as the parent class for various Counter* classes,
2121
/// namely EventCounter, PollingCounter, IncrementingEventCounter, and IncrementingPollingCounter.
2222
/// </summary>
23-
#if NETCOREAPP
24-
[UnsupportedOSPlatform("browser")]
25-
#endif
2623
public abstract class DiagnosticCounter : IDisposable
2724
{
2825
/// <summary>

src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventCounter.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ namespace System.Diagnostics.Tracing
2424
/// See https://github.com/dotnet/runtime/blob/main/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestEventCounter.cs
2525
/// which shows tests, which are also useful in seeing actual use.
2626
/// </summary>
27-
#if NETCOREAPP
28-
[UnsupportedOSPlatform("browser")]
29-
#endif
3027
public partial class EventCounter : DiagnosticCounter
3128
{
3229
/// <summary>

src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingEventCounter.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ namespace System.Diagnostics.Tracing
2121
/// It does not calculate statistics like mean, standard deviation, etc. because it only accumulates
2222
/// the counter value.
2323
/// </summary>
24-
#if NETCOREAPP
25-
[UnsupportedOSPlatform("browser")]
26-
#endif
2724
public partial class IncrementingEventCounter : DiagnosticCounter
2825
{
2926
/// <summary>

src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingPollingCounter.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ namespace System.Diagnostics.Tracing
2222
/// Unlike IncrementingEventCounter, this takes in a polling callback that it can call to update
2323
/// its own metric periodically.
2424
/// </summary>
25-
#if NETCOREAPP
26-
[UnsupportedOSPlatform("browser")]
27-
#endif
2825
public partial class IncrementingPollingCounter : DiagnosticCounter
2926
{
3027
/// <summary>

src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/PollingCounter.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ namespace System.Diagnostics.Tracing
2020
/// function to collect metrics on its own rather than the user having to call WriteMetric()
2121
/// every time.
2222
/// </summary>
23-
#if NETCOREAPP
24-
[UnsupportedOSPlatform("browser")]
25-
#endif
2623
public partial class PollingCounter : DiagnosticCounter
2724
{
2825
/// <summary>

src/libraries/System.Private.CoreLib/src/System/Threading/RegisteredWaitHandle.Portable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ namespace System.Threading
1010
/// <summary>
1111
/// An object representing the registration of a <see cref="WaitHandle"/> via <see cref="ThreadPool.RegisterWaitForSingleObject"/>.
1212
/// </summary>
13-
[UnsupportedOSPlatform("browser")]
1413
public sealed partial class RegisteredWaitHandle : MarshalByRefObject
1514
{
1615
internal RegisteredWaitHandle(WaitHandle waitHandle, _ThreadPoolWaitOrTimerCallback callbackHelper,
1716
int millisecondsTimeout, bool repeating)
1817
{
18+
Thread.ThrowIfNoThreadStart();
1919
Handle = waitHandle.SafeWaitHandle;
2020
Callback = callbackHelper;
2121
TimeoutDurationMs = millisecondsTimeout;

0 commit comments

Comments
 (0)