[wasm] Redesign of JS objects marshaling and lifecycle (#57098)
authorPavel Savara <pavelsavara@microsoft.com>
Tue, 17 Aug 2021 04:48:45 +0000 (06:48 +0200)
committerGitHub <noreply@github.com>
Tue, 17 Aug 2021 04:48:45 +0000 (23:48 -0500)
commitead035b1774e91b871929b74a00726b6b9d23025
treead570e0e848bbd12e62c2ac995e1b0b685f74758
parent53d328146b25bca28f2e273c873ddcc85b5eecf6
[wasm] Redesign of JS objects marshaling and lifecycle (#57098)

* thenable and datetime cleanup

* removed ownsHandle for readability, removed AnyRef from hierarchy, removed old refcount debug code

* rename _csOwnedObjects

* rename _csOwnedObjects

* redirect to Inflight counter

* renames

* rename and move

* rename

* New+BindCoreObject -> CreateCsOwnedObject single call

* remove refcount frames

* differentiate gcHandles

* get rid of weak GCHandle

* feedback

* added MappedType enum

* naming consistency

* feedback

* rename _cs_owned_objects_by_js_handle

* split and rename files

* shouldAddInflight to more methods

* improved in-flight references

* assert for JSObject not disposed

* introduce in-flight assert

* move should_add_in_flight arg to fisrt position, so that we could bind it in convert

* doc

* cleanup

* doc

* implement fallback for missing support of FInalizationRegistry/WeakRef in onlder browsers

* feedback

* no polyfill feedback

* feedback

* name consistency feedback

* use symbols for helper fields

* feedback
30 files changed:
src/libraries/Common/src/Interop/Browser/Interop.Runtime.cs
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System.Private.Runtime.InteropServices.JavaScript.csproj
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/AnyRef.cs [deleted file]
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Array.cs
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/ArrayBuffer.cs
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/CoreObject.cs
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/DataView.cs
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Float32Array.cs
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Float64Array.cs
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Function.cs
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/HostObject.cs
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Int16Array.cs
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Int32Array.cs
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Int8Array.cs
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSObject.References.cs [new file with mode: 0644]
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSObject.cs
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Map.cs
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Runtime.CS.Owned.cs [new file with mode: 0644]
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Runtime.JS.Owned.cs [new file with mode: 0644]
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Runtime.cs
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/SharedArrayBuffer.cs
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/TypedArray.cs
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Uint16Array.cs
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Uint32Array.cs
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Uint8Array.cs
src/libraries/System.Private.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Uint8ClampedArray.cs
src/libraries/System.Private.Runtime.InteropServices.JavaScript/tests/System/Runtime/InteropServices/JavaScript/DelegateTests.cs
src/libraries/System.Private.Runtime.InteropServices.JavaScript/tests/System/Runtime/InteropServices/JavaScript/JavaScriptTests.cs
src/mono/wasm/runtime/binding_support.js
src/mono/wasm/runtime/corebindings.c