-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[wasm] optional legacy JS interop #79622
[wasm] optional legacy JS interop #79622
Conversation
Tagging subscribers to 'arch-wasm': @lewing Issue Detailscurrently only build time switch, not workload switch
|
We should make decision on how to proceed with this
thoughts ? @kg @lewing @lambdageek |
I think we should start with 1 (merge close to what it is now, only disable for threading and for new scenarios going forward) and then prepare 2 as a separate PR |
src/libraries/System.Runtime.InteropServices.JavaScript/src/Resources/Strings.resx
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime.InteropServices.JavaScript/src/Resources/Strings.resx
Outdated
Show resolved
Hide resolved
<EmscriptenEnvVars Include="MonoWasmLegacyJsInterop=$(MonoWasmLegacyJsInterop)"/> | ||
<EmscriptenEnvVars Include="MonoWasmThreads=$(MonoWasmThreads)"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be set only when they have value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They must have value even if we just default it to false
or true
.
The env variable is the way how to evaluate it in dotnet.es6.lib.js
while linking.
But when this code would be running on user dev machine, I don't know how to get the value which was previously used to compile this runtime flavor in our CI.
There was USE_PTHREADS
which is pre-processor directive, but it works only for existing emcc settings. Whatever could be passed with -s XXX
. Benefit is, that emcc-link.rsp
would have that value stored for the runtime flavor.
But here I want to add something which emcc doesn't know about and so I went with env variables. But those are not in emcc-link.rsp
. As I write this comment now I rememebred that there is emcc-props.json
which could carry that value for me. That would work.
But is that wasted effort if we go for 2) as next step ?
# Conflicts: # src/mono/wasm/runtime/cwraps.ts
Co-authored-by: Ankit Jain <radical@gmail.com>
Co-authored-by: Ankit Jain <radical@gmail.com>
Co-authored-by: Ankit Jain <radical@gmail.com>
I love the idea here perhaps we can gate the actual managed bits on a linker flag like the latest simd settings and keep most of the size improvement that way? I'd love a better way to solve the unmanage<->managed linking problem but we don't always need a general solution. |
...rvices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Interop/JavaScriptExports.cs
Outdated
Show resolved
Hide resolved
#if FEATURE_LEGACY_JS_INTEROP | ||
[DynamicDependency(DynamicallyAccessedMemberTypes.PublicMethods, "System.Runtime.InteropServices.JavaScript.LegacyExports", "System.Runtime.InteropServices.JavaScript")] | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not let us to remove LegacyExports because it's a library compile time setting. We could remove this DynamicDependency
and use XML descriptor with System.Runtime.InteropServices.JavaScript.LegacyExports
and pass it to linker only when legacy interop is enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That XML would become embedded resource, right ? How do I tell the linker to ignore it or not in WasmApp.Native.targets
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be additional file passed conditionally to the linker (we run it all the time to this should work).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For threaded runtime flavor everything would be already trimmed away.
For normal runtime flavor we would keep the code with DynamicDependency
above.
User would be able to opt in for trimming on customer's dev machine.
I can follow example of WasmEnableSIMD
and ILLink.Substitutions.WasmIntrinsics.xml
.
Except I need ILLink.LinkAttributes.xml
which could remove the attribute ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That won't work DynamicDependency
is always processed and it only removed later. The attribute cannot be visible to linker in this case to work as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should discuss the mechanisms we need in the regular build to pass additional linker files based on options as part of the bunder/sdk changes
# Conflicts: # src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Interop/JavaScriptExports.cs
# Conflicts: # src/mono/wasm/runtime/startup.ts
Today I tried to separate the I was able to draft detaching the runtime->legacy dependency into small surface of few initialization functions which would the runtime all on the legacy module to connect it. But, there are many dependencies in the opposite direction. Legacy interop uses almost all internal infrastructure of the runtime. JS code we have. We could export internal "API" for this purpose. It means that all the internal function names would have to be protected from minification. I'm scratching my head what to do about it conceptually, so that we could use the same approach for jiterpreter code and possibly also for MT infrastructure.
|
re 1)
|
note to self |
The closure compiler (and the trimming side effects) could be only run without |
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
currently only build time switch, not workload switch
runtime\net6-legacy\*
fromdotnet.js
338118
->304870
=33248
driver.c
fromdotnet.wasm
2409118
->2407787
=1331
System.Runtime.InteropServices.JavaScript.dll
32256
->24064
=8192