diff --git a/src/libraries/Common/src/Interop/Browser/Interop.Runtime.cs b/src/libraries/Common/src/Interop/Browser/Interop.Runtime.cs
index 67509d17a362e..ef12917e5edce 100644
--- a/src/libraries/Common/src/Interop/Browser/Interop.Runtime.cs
+++ b/src/libraries/Common/src/Interop/Browser/Interop.Runtime.cs
@@ -21,41 +21,37 @@ internal static partial class Runtime
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object CompileFunction(string str, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern object InvokeJSWithArgs(int jsObjHandle, string method, object?[] parms, out int exceptionalResult);
+ internal static extern object InvokeJSWithArgs(int jsHandle, string method, object?[] parms, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern object GetObjectProperty(int jsObjHandle, string propertyName, out int exceptionalResult);
+ internal static extern object GetObjectProperty(int jsHandle, string propertyName, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern object SetObjectProperty(int jsObjHandle, string propertyName, object value, bool createIfNotExists, bool hasOwnProperty, out int exceptionalResult);
+ internal static extern object SetObjectProperty(int jsHandle, string propertyName, object value, bool createIfNotExists, bool hasOwnProperty, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern object GetByIndex(int jsObjHandle, int index, out int exceptionalResult);
+ internal static extern object GetByIndex(int jsHandle, int index, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern object SetByIndex(int jsObjHandle, int index, object? value, out int exceptionalResult);
+ internal static extern object SetByIndex(int jsHandle, int index, object? value, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object GetGlobalObject(string? globalName, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern object ReleaseHandle(int jsObjHandle, out int exceptionalResult);
+ internal static extern object ReleaseHandle(int jsHandle, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern object ReleaseObject(int jsObjHandle, out int exceptionalResult);
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern object BindCoreObject(int jsObjHandle, int gcHandle, out int exceptionalResult);
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern object BindHostObject(int jsObjHandle, int gcHandle, out int exceptionalResult);
+ internal static extern object BindCoreObject(int jsHandle, int gcHandle, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object New(string className, object[] parms, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern object TypedArrayToArray(int jsObjHandle, out int exceptionalResult);
+ internal static extern object TypedArrayToArray(int jsHandle, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern object TypedArrayCopyTo(int jsObjHandle, int arrayPtr, int begin, int end, int bytesPerElement, out int exceptionalResult);
+ internal static extern object TypedArrayCopyTo(int jsHandle, int arrayPtr, int begin, int end, int bytesPerElement, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object TypedArrayFrom(int arrayPtr, int begin, int end, int bytesPerElement, int type, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern object TypedArrayCopyFrom(int jsObjHandle, int arrayPtr, int begin, int end, int bytesPerElement, out int exceptionalResult);
+ internal static extern object TypedArrayCopyFrom(int jsHandle, int arrayPtr, int begin, int end, int bytesPerElement, out int exceptionalResult);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern string? AddEventListener(int jsObjHandle, string name, int weakDelegateHandle, int optionsObjHandle);
+ internal static extern string? AddEventListener(int jsHandle, string name, int gcHandle, int optionsJsHandle);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern string? RemoveEventListener(int jsObjHandle, string name, int weakDelegateHandle, bool capture);
+ internal static extern string? RemoveEventListener(int jsHandle, string name, int gcHandle, bool capture);
// /
// / Execute the provided string in the JavaScript context
diff --git a/src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/AnyRef.cs b/src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/AnyRef.cs
index 58587eb15a479..2bd4afb20deb4 100644
--- a/src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/AnyRef.cs
+++ b/src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/AnyRef.cs
@@ -1,9 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System;
using System.Diagnostics;
-using System.Runtime.InteropServices;
using System.Threading;
using Microsoft.Win32.SafeHandles;
@@ -16,9 +14,6 @@ public abstract class AnyRef : SafeHandleMinusOneIsInvalid
private GCHandle AnyRefHandle;
public int JSHandle => (int)handle;
- internal AnyRef(int jsHandle, bool ownsHandle) : this((IntPtr)jsHandle, ownsHandle)
- { }
-
internal AnyRef(IntPtr jsHandle, bool ownsHandle) : base(ownsHandle)
{
SetHandle(jsHandle);
@@ -26,7 +21,7 @@ internal AnyRef(IntPtr jsHandle, bool ownsHandle) : base(ownsHandle)
InFlight = null;
InFlightCounter = 0;
}
- internal int Int32Handle => (int)(IntPtr)AnyRefHandle;
+ internal int GCHandleValue => (int)(IntPtr)AnyRefHandle;
internal void AddInFlight()
{
diff --git a/src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/CoreObject.cs b/src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/CoreObject.cs
index 791a3ab5480c7..33c475027d452 100644
--- a/src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/CoreObject.cs
+++ b/src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/CoreObject.cs
@@ -20,7 +20,7 @@ public abstract class CoreObject : JSObject
{
protected CoreObject(int jsHandle) : base(jsHandle, true)
{
- object result = Interop.Runtime.BindCoreObject(jsHandle, Int32Handle, out int exception);
+ object result = Interop.Runtime.BindCoreObject(jsHandle, GCHandleValue, out int exception);
if (exception != 0)
throw new JSException(SR.Format(SR.CoreObjectErrorBinding, result));
}
diff --git a/src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/HostObject.cs b/src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/HostObject.cs
index 1d3b3bf4d8676..b9dec0f68c5cd 100644
--- a/src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/HostObject.cs
+++ b/src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/HostObject.cs
@@ -27,9 +27,9 @@ public HostObject(string hostName, params object[] _params) : base(Interop.Runti
public abstract class HostObjectBase : JSObject, IHostObject
{
- protected HostObjectBase(int jHandle) : base(jHandle, true)
+ protected HostObjectBase(int jsHandle) : base(jsHandle, true)
{
- object result = Interop.Runtime.BindHostObject(jHandle, Int32Handle, out int exception);
+ object result = Interop.Runtime.BindCoreObject(jsHandle, GCHandleValue, out int exception);
if (exception != 0)
throw new JSException(SR.Format(SR.HostObjectErrorBinding, result));
}
diff --git a/src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSObject.cs b/src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSObject.cs
index 85eb8285f3932..7aac370f5d117 100644
--- a/src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSObject.cs
+++ b/src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSObject.cs
@@ -18,16 +18,12 @@ public interface IJSObject
///
public class JSObject : AnyRef, IJSObject, IDisposable
{
- internal object? RawObject;
-
- private WeakReference? WeakRawObject;
-
// to detect redundant calls
public bool IsDisposed { get; private set; }
public JSObject() : this(Interop.Runtime.New