Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[browser][MT] cleanup #98672

Merged
merged 22 commits into from
Feb 21, 2024
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7463a3c
cleanup
pavelsavara Feb 19, 2024
71b6f6c
more
pavelsavara Feb 19, 2024
0024dc4
more
pavelsavara Feb 19, 2024
5c7757e
wip
pavelsavara Feb 19, 2024
18e5aed
more
pavelsavara Feb 19, 2024
df9a2ef
Update src/libraries/System.Runtime.InteropServices.JavaScript/src/Sy…
pavelsavara Feb 20, 2024
279b8b2
Update src/libraries/System.Runtime.InteropServices.JavaScript/src/Sy…
pavelsavara Feb 20, 2024
795d479
Update src/libraries/System.Runtime.InteropServices.JavaScript/src/Sy…
pavelsavara Feb 20, 2024
9cf90ed
Update src/libraries/System.Runtime.InteropServices.JavaScript/src/Sy…
pavelsavara Feb 20, 2024
0bfe8b0
Update src/libraries/System.Runtime.InteropServices.JavaScript/src/Sy…
pavelsavara Feb 20, 2024
b7679d7
Merge branch 'main' into browser_cleanup2
pavelsavara Feb 20, 2024
81117b7
more
pavelsavara Feb 20, 2024
633e77a
Merge branch 'main' into browser_cleanup2
pavelsavara Feb 20, 2024
b709e39
Update src/mono/browser/runtime/pthreads/worker-thread.ts
pavelsavara Feb 21, 2024
7e0bc77
more
pavelsavara Feb 21, 2024
81b76a6
Merge branch 'browser_cleanup2' of https://github.com/pavelsavara/run…
pavelsavara Feb 21, 2024
e1e1e17
Merge branch 'main' into browser_cleanup2
pavelsavara Feb 21, 2024
718a351
fix ShowBuildOutput
pavelsavara Feb 21, 2024
c94a8db
feedback
pavelsavara Feb 21, 2024
effd1a2
more
pavelsavara Feb 21, 2024
250c8e6
disable failing test ActiveIssue https://github.com/dotnet/runtime/is…
pavelsavara Feb 21, 2024
c8615ae
more
pavelsavara Feb 21, 2024
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
@@ -45,7 +45,7 @@ public static void CallEntrypoint(JSMarshalerArgument* arguments_buffer)
}
catch (Exception ex)
{
Environment.FailFast("CallEntrypoint: Unexpected synchronous failure. " + ex);
Environment.FailFast($"CallEntrypoint: Unexpected synchronous failure (ManagedThreadId {Environment.CurrentManagedThreadId}): " + ex);
}
}

@@ -110,7 +110,7 @@ public static void ReleaseJSOwnedObjectByGCHandle(JSMarshalerArgument* arguments
}
catch (Exception ex)
{
Environment.FailFast("ReleaseJSOwnedObjectByGCHandle: Unexpected synchronous failure. " + ex);
Environment.FailFast($"ReleaseJSOwnedObjectByGCHandle: Unexpected synchronous failure (ManagedThreadId {Environment.CurrentManagedThreadId}): " + ex);
}
}

@@ -205,7 +205,7 @@ public static void CompleteTask(JSMarshalerArgument* arguments_buffer)
}
catch (Exception ex)
{
Environment.FailFast("CompleteTask: Unexpected synchronous failure. " + ex);
Environment.FailFast($"CompleteTask: Unexpected synchronous failure (ManagedThreadId {Environment.CurrentManagedThreadId}): " + ex);
}
}

@@ -280,7 +280,7 @@ public static void BindAssemblyExports(JSMarshalerArgument* arguments_buffer)
}
catch (Exception ex)
{
Environment.FailFast("BindAssemblyExports: Unexpected synchronous failure. " + ex);
Environment.FailFast($"BindAssemblyExports: Unexpected synchronous failure (ManagedThreadId {Environment.CurrentManagedThreadId}): " + ex);
}
}

Original file line number Diff line number Diff line change
@@ -151,7 +151,9 @@ internal unsafe JSBindingType this[int position]
/// </summary>
/// <param name="signature">Generated metadata about the method signature used for marshaling.</param>
/// <param name="arguments">The intermediate buffer with marshalled arguments.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public static void InvokeJS(JSFunctionBinding signature, Span<JSMarshalerArgument> arguments)
{
InvokeJSImportImpl(signature, arguments);
Original file line number Diff line number Diff line change
@@ -44,7 +44,9 @@ public static JSObject DotnetInstance
/// <param name="moduleUrl">The location of the module file.</param>
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
/// <returns>A proxy for the JavaScript object that contains the module's exports.</returns>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public static Task<JSObject> ImportAsync(string moduleName, string moduleUrl, CancellationToken cancellationToken = default)
{
return JSHostImplementation.ImportAsync(moduleName, moduleUrl, cancellationToken);
Original file line number Diff line number Diff line change
@@ -64,7 +64,9 @@ public static MethodInfo GetTaskResultMethodInfo(Type taskType)
throw new InvalidOperationException();
}

#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public static void ThrowException(ref JSMarshalerArgument arg)
{
arg.ToManaged(out Exception? ex);
@@ -85,7 +87,9 @@ public static async Task<JSObject> ImportAsync(string moduleName, string moduleU
ConfigureAwaitOptions.ForceYielding); // this helps to finish the import before we bind the module in [JSImport]
}

#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public static async Task<JSObject> CancellationHelper(Task<JSObject> jsTask, CancellationToken cancellationToken)
{
if (jsTask.IsCompletedSuccessfully)
@@ -293,6 +297,7 @@ public static unsafe JSFunctionBinding BindManagedFunction(string fullyQualified

var signature = GetMethodSignature(signatures, null, null);

// this will hit JS side possibly on another thread, depending on JSProxyContext.CurrentThreadContext
JavaScriptImports.BindCSFunction(monoMethod, assemblyName, nameSpace, shortClassName, methodName, signatureHash, (IntPtr)signature.Header);

FreeMethodSignatureBuffer(signature);
@@ -310,7 +315,9 @@ public static void SetHasExternalEventLoop(Thread thread)
}
#endif

#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public static RuntimeMethodHandle GetMethodHandleFromIntPtr(IntPtr ptr)
{
var temp = new IntPtrAndHandle { ptr = ptr };
Original file line number Diff line number Diff line change
@@ -71,7 +71,9 @@ internal struct JSMarshalerArgumentImpl
/// <summary>
/// This API supports JSImport infrastructure and is not intended to be used directly from your code.
/// </summary>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public unsafe void Initialize()
{
slot.Type = MarshalerType.None;
@@ -85,7 +87,9 @@ public unsafe void Initialize()
}

#if FEATURE_WASM_MANAGED_THREADS
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
internal unsafe void InitializeWithContext(JSProxyContext knownProxyContext)
{
slot.Type = MarshalerType.None;
@@ -111,11 +115,11 @@ internal JSProxyContext ToManagedContext
// during JSExport, this is marshaling parameters and it would be set by:
// - alloc_stack_frame
// - set_js_handle/set_gc_handle
var proxyContextGCHandle = (GCHandle)slot.ContextHandle;
if (proxyContextGCHandle == default)
if (slot.ContextHandle == IntPtr.Zero)
{
Environment.FailFast($"ContextHandle not set, ManagedThreadId: {Environment.CurrentManagedThreadId}. {Environment.NewLine} {Environment.StackTrace}");
Environment.FailFast($"ContextHandle not set (ManagedThreadId {Environment.CurrentManagedThreadId}): {Environment.NewLine} {Environment.StackTrace}");
}
var proxyContextGCHandle = (GCHandle)slot.ContextHandle;
var argumentContext = (JSProxyContext)proxyContextGCHandle.Target!;
return argumentContext;
#endif
Original file line number Diff line number Diff line change
@@ -42,7 +42,9 @@ internal JSObject(IntPtr jsHandle, JSProxyContext ctx)
/// <inheritdoc />
public override string ToString() => $"(js-obj js '{JSHandle}')";

#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
internal void AssertNotDisposed()
{
lock (ProxyContext)
Original file line number Diff line number Diff line change
@@ -41,7 +41,9 @@ private JSProxyContext()
public bool IsMainThread;
public JSSynchronizationContext SynchronizationContext;

#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public bool IsCurrentThread()
{
return ManagedTID == Environment.CurrentManagedThreadId;
@@ -232,7 +234,9 @@ public static JSProxyContext CurrentOperationContext

#endif

#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public static JSProxyContext AssertIsInteropThread()
{
#if FEATURE_WASM_MANAGED_THREADS
Original file line number Diff line number Diff line change
@@ -12,7 +12,9 @@ public partial struct JSMarshalerArgument
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public unsafe void ToManagedBig(out long value)
{
if (slot.Type == MarshalerType.None)
@@ -28,7 +30,9 @@ public unsafe void ToManagedBig(out long value)
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public void ToJSBig(long value)
{
slot.Type = MarshalerType.BigInt64;
@@ -40,7 +44,9 @@ public void ToJSBig(long value)
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public unsafe void ToManagedBig(out long? value)
{
if (slot.Type == MarshalerType.None)
@@ -56,7 +62,9 @@ public unsafe void ToManagedBig(out long? value)
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public void ToJSBig(long? value)
{
if (value.HasValue)
Original file line number Diff line number Diff line change
@@ -12,7 +12,9 @@ public partial struct JSMarshalerArgument
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public unsafe void ToManaged(out bool value)
{
if (slot.Type == MarshalerType.None)
@@ -28,7 +30,9 @@ public unsafe void ToManaged(out bool value)
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public void ToJS(bool value)
{
slot.Type = MarshalerType.Boolean;
@@ -40,7 +44,9 @@ public void ToJS(bool value)
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public unsafe void ToManaged(out bool? value)
{
if (slot.Type == MarshalerType.None)
@@ -56,7 +62,9 @@ public unsafe void ToManaged(out bool? value)
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public void ToJS(bool? value)
{
if (value.HasValue)
Original file line number Diff line number Diff line change
@@ -12,7 +12,9 @@ public partial struct JSMarshalerArgument
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public unsafe void ToManaged(out byte value)
{
if (slot.Type == MarshalerType.None)
@@ -28,7 +30,9 @@ public unsafe void ToManaged(out byte value)
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public void ToJS(byte value)
{
slot.Type = MarshalerType.Byte;
@@ -40,7 +44,9 @@ public void ToJS(byte value)
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public unsafe void ToManaged(out byte? value)
{
if (slot.Type == MarshalerType.None)
@@ -56,7 +62,9 @@ public unsafe void ToManaged(out byte? value)
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public void ToJS(byte? value)
{
if (value.HasValue)
Original file line number Diff line number Diff line change
@@ -12,7 +12,9 @@ public partial struct JSMarshalerArgument
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public unsafe void ToManaged(out char value)
{
if (slot.Type == MarshalerType.None)
@@ -28,7 +30,9 @@ public unsafe void ToManaged(out char value)
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public void ToJS(char value)
{
slot.Type = MarshalerType.Char;
@@ -40,7 +44,9 @@ public void ToJS(char value)
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public unsafe void ToManaged(out char? value)
{
if (slot.Type == MarshalerType.None)
@@ -56,7 +62,9 @@ public unsafe void ToManaged(out char? value)
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public void ToJS(char? value)
{
if (value.HasValue)
Original file line number Diff line number Diff line change
@@ -12,7 +12,9 @@ public partial struct JSMarshalerArgument
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public unsafe void ToManaged(out DateTimeOffset value)
{
if (slot.Type == MarshalerType.None)
@@ -28,7 +30,9 @@ public unsafe void ToManaged(out DateTimeOffset value)
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public void ToJS(DateTimeOffset value)
{
slot.Type = MarshalerType.DateTimeOffset;
@@ -40,7 +44,9 @@ public void ToJS(DateTimeOffset value)
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public unsafe void ToManaged(out DateTimeOffset? value)
{
if (slot.Type == MarshalerType.None)
@@ -56,7 +62,9 @@ public unsafe void ToManaged(out DateTimeOffset? value)
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public void ToJS(DateTimeOffset? value)
{
if (value.HasValue)
@@ -75,7 +83,9 @@ public void ToJS(DateTimeOffset? value)
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public unsafe void ToManaged(out DateTime value)
{
if (slot.Type == MarshalerType.None)
@@ -91,7 +101,9 @@ public unsafe void ToManaged(out DateTime value)
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public void ToJS(DateTime value)
{
slot.Type = MarshalerType.DateTime;
@@ -103,7 +115,9 @@ public void ToJS(DateTime value)
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public unsafe void ToManaged(out DateTime? value)
{
if (slot.Type == MarshalerType.None)
@@ -119,7 +133,9 @@ public unsafe void ToManaged(out DateTime? value)
/// It's used by JSImport code generator and should not be used by developers in source code.
/// </summary>
/// <param name="value">The value to be marshaled.</param>
#if !DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public void ToJS(DateTime? value)
{
if (value.HasValue)
Loading
Loading