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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion eng/pipelines/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,6 @@ extends:
- wasi_wasm_win
nameSuffix: '_Smoke'
extraBuildArgs: /p:EnableAggressiveTrimming=true /p:RunWasmSamples=true /p:AotHostArchitecture=x64 /p:AotHostOS=$(_hostedOS)
shouldContinueOnError: true
shouldRunSmokeOnly: true
alwaysRun: ${{ variables.isRollingBuild }}
scenarios:
Expand Down
6 changes: 5 additions & 1 deletion src/libraries/Common/tests/WasmTestRunner/WasmTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ public static async Task<int> Main(string[] args)
IncludedMethods = includedMethods
};

await Task.Yield();
if (OperatingSystem.IsBrowser())
{
await Task.Yield();
}

return await runner.Run();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,18 @@
<Compile Include="$(BclSourcesRoot)\System\Threading\ThreadPool.Browser.Threads.Mono.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\WebWorkerEventLoop.Browser.Threads.Mono.cs" />
</ItemGroup>
<ItemGroup Condition="('$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true') and '$(FeatureWasmThreads)' != 'true'">
<ItemGroup Condition="'$(TargetsBrowser)' == 'true' and '$(FeatureWasmThreads)' != 'true'">
<Compile Include="$(BclSourcesRoot)\System\Threading\ThreadPoolBoundHandle.Browser.Mono.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\PreAllocatedOverlapped.Browser.Mono.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\ThreadPool.Browser.Mono.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\TimerQueue.Browser.Mono.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsWasi)' == 'true'">
<Compile Include="$(BclSourcesRoot)\System\Threading\ThreadPoolBoundHandle.Browser.Mono.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\PreAllocatedOverlapped.Browser.Mono.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\ThreadPool.Wasi.Mono.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\TimerQueue.Wasi.Mono.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(BclSourcesRoot)\Mono\HotReload.cs" />
<Compile Include="$(BclSourcesRoot)\Mono\RuntimeStructs.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Win32.SafeHandles;

#pragma warning disable IDE0060

namespace System.Threading
{
#if FEATURE_WASM_THREADS
#error when compiled with FEATURE_WASM_THREADS
#endif
[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
public sealed class RegisteredWaitHandle : MarshalByRefObject
{
internal RegisteredWaitHandle()
{
}

#pragma warning disable CA1822 // Mark members as static
internal bool Repeating => false;
#pragma warning restore CA1822

public bool Unregister(WaitHandle? waitObject)
{
throw new PlatformNotSupportedException();
}
}

public static partial class ThreadPool
{
// 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 => true;

private const bool IsWorkerTrackingEnabledInConfig = false;

public static bool SetMaxThreads(int workerThreads, int completionPortThreads)
{
if (workerThreads == 1 && completionPortThreads == 1)
return true;
return false;
}

public static void GetMaxThreads(out int workerThreads, out int completionPortThreads)
{
workerThreads = 1;
completionPortThreads = 1;
}

public static bool SetMinThreads(int workerThreads, int completionPortThreads)
{
if (workerThreads == 1 && completionPortThreads == 1)
return true;
return false;
}

public static void GetMinThreads(out int workerThreads, out int completionPortThreads)
{
workerThreads = 1;
completionPortThreads = 1;
}

public static void GetAvailableThreads(out int workerThreads, out int completionPortThreads)
{
workerThreads = 1;
completionPortThreads = 1;
}

public static int ThreadCount => 1;

public static long CompletedWorkItemCount => 0;

internal static unsafe void RequestWorkerThread()
{
throw new PlatformNotSupportedException();
}

internal static void NotifyWorkItemProgress()
{
}

internal static bool NotifyThreadBlocked() => false;

internal static void NotifyThreadUnblocked()
{
throw new PlatformNotSupportedException();
}

internal static object? GetOrCreateThreadLocalCompletionCountObject() => null;

internal static bool NotifyWorkItemComplete(object? _1, int _2)
{
throw new PlatformNotSupportedException();
}

private static RegisteredWaitHandle RegisterWaitForSingleObject(
WaitHandle? waitObject,
WaitOrTimerCallback? callBack,
object? state,
uint millisecondsTimeOutInterval,
bool executeOnlyOnce,
bool flowExecutionContext)
{
throw new PlatformNotSupportedException();
}

private static unsafe void NativeOverlappedCallback(nint overlappedPtr) =>
IOCompletionCallbackHelper.PerformSingleIOCompletionCallback(0, 0, (NativeOverlapped*)overlappedPtr);

[CLSCompliant(false)]
[SupportedOSPlatform("windows")]
public static unsafe bool UnsafeQueueNativeOverlapped(NativeOverlapped* overlapped)
{
throw new PlatformNotSupportedException();
}

[Obsolete("ThreadPool.BindHandle(IntPtr) has been deprecated. Use ThreadPool.BindHandle(SafeHandle) instead.")]
[SupportedOSPlatform("windows")]
public static bool BindHandle(IntPtr osHandle)
{
throw new PlatformNotSupportedException(SR.Arg_PlatformNotSupported); // Replaced by ThreadPoolBoundHandle.BindHandle
}

[SupportedOSPlatform("windows")]
public static bool BindHandle(SafeHandle osHandle)
{
throw new PlatformNotSupportedException(SR.Arg_PlatformNotSupported); // Replaced by ThreadPoolBoundHandle.BindHandle
}

[Conditional("unnecessary")]
internal static void ReportThreadStatus(bool isWorking)
{

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace System.Threading
{
//
// WebAssembly-specific implementation of Timer
// Browser-specific implementation of Timer
// Based on TimerQueue.Portable.cs
// Not thread safe
//
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;

namespace System.Threading
{
//
// Wasi-specific implementation of Timer
// Based on TimerQueue.Portable.cs
// Not thread safe
//
internal partial class TimerQueue
{
private static long TickCount64 => Environment.TickCount64;

private TimerQueue(int _)
{
throw new PlatformNotSupportedException();
}
#pragma warning disable CA1822 // Mark members as static
private bool SetTimer(uint actualDuration)
{
throw new PlatformNotSupportedException();
}
#pragma warning restore CA1822
}
}
2 changes: 1 addition & 1 deletion src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
<ActualWasiSdkVersion>%(_ActualVersionLines.Identity)</ActualWasiSdkVersion>
<ExpectedWasiSdkVersion>%(_ExpectedVersionLines.Identity)</ExpectedWasiSdkVersion>
</PropertyGroup>
<Error Text="Expected and actual version of WASI SDK does not match. Please delete $(WASI_SDK_PATH) folder to provision a new version."
<Error Text="Expected version: %(_ExpectedVersionLines.Identity) and actual version: %(_ActualVersionLines.Identity) of WASI SDK does not match. Please delete $(WASI_SDK_PATH) folder to provision a new version."
Condition="'$(ActualWasiSdkVersion)' != '$(ExpectedWasiSdkVersion)'" />
</Target>

Expand Down