镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup>
<FeatureWasmThreads Condition="'$(TargetOS)' == 'browser' and '$(WasmEnableThreads)' == 'true'">true</FeatureWasmThreads>
</PropertyGroup>

<PropertyGroup>
<DefineConstants Condition="'$(FeatureWasmThreads)' == 'true'" >$(DefineConstants);FEATURE_WASM_THREADS</DefineConstants>
</PropertyGroup>

<!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
<PropertyGroup>
<TargetPlatformIdentifier>$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))</TargetPlatformIdentifier>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ public static void CompleteTask(JSMarshalerArgument* arguments_buffer)
}
}

#if FEATURE_WASM_THREADS

[MethodImpl(MethodImplOptions.NoInlining)] // https://github.com/dotnet/runtime/issues/71425
// the marshaled signature is:
// void InstallSynchronizationContext()
Expand All @@ -207,6 +209,8 @@ public static void InstallSynchronizationContext (JSMarshalerArgument* arguments
}
}

#endif

[MethodImpl(MethodImplOptions.NoInlining)] // https://github.com/dotnet/runtime/issues/71425
public static void StopProfile()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// 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

using System;
using System.Threading;
using System.Threading.Channels;
Expand Down Expand Up @@ -141,3 +143,5 @@ private void Pump () {
}
}
}

#endif
31 changes: 17 additions & 14 deletions src/mono/wasm/runtime/managed-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,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_sync_context = get_method("InstallSynchronizationContext");
mono_assert(install_sync_context, "Can't find InstallSynchronizationContext method");
const install_sync_context = cwraps.mono_wasm_assembly_find_method(runtimeHelpers.runtime_interop_exports_class, "InstallSynchronizationContext", -1);
// mono_assert(install_sync_context, "Can't find InstallSynchronizationContext 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");
Expand Down Expand Up @@ -134,19 +134,22 @@ export function init_managed_exports(): void {
anyModule.stackRestore(sp);
}
};
runtimeHelpers.javaScriptExports.install_synchronization_context = () => {
const sp = anyModule.stackSave();
try {
const args = alloc_stack_frame(2);
invoke_method_and_handle_exception(install_sync_context, args);
} finally {
anyModule.stackRestore(sp);
}
};

if (!ENVIRONMENT_IS_PTHREAD)
// Install our sync context so that async continuations will migrate back to this thread (the main thread) automatically
runtimeHelpers.javaScriptExports.install_synchronization_context();
if (install_sync_context) {
runtimeHelpers.javaScriptExports.install_synchronization_context = () => {
const sp = anyModule.stackSave();
try {
const args = alloc_stack_frame(2);
invoke_method_and_handle_exception(install_sync_context, args);
} finally {
anyModule.stackRestore(sp);
}
};

if (!ENVIRONMENT_IS_PTHREAD)
// Install our sync context so that async continuations will migrate back to this thread (the main thread) automatically
runtimeHelpers.javaScriptExports.install_synchronization_context();
}
}

export function get_method(method_name: string): MonoMethod {
Expand Down