Repository navigation
Avoid copying all exports in applySignatureConversions #27996
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1165,8 +1165,6 @@ def create_pointer_conversion_wrappers(metadata): | |
| // that it is recognised by metadce and minify-import-export-names | ||
| // passes. | ||
| function applySignatureConversions(wasmExports) { | ||
| // First, make a copy of the incoming exports object | ||
| wasmExports = Object.assign({}, wasmExports); | ||
| ''' | ||
|
|
||
| sigs_seen = set() | ||
|
|
@@ -1195,9 +1193,17 @@ def create_pointer_conversion_wrappers(metadata): | |
| sigs_seen.add(sig) | ||
| wrap_functions.append(symbol) | ||
|
|
||
| for f in wrap_functions: | ||
| sig = native_sigs[f] | ||
| wrappers += f"\n wasmExports['{f}'] = makeWrapper_{sig}(wasmExports['{f}']);" | ||
| if wrap_functions: | ||
| # Rather than copying the entire exports object (which is slow when there | ||
| # are many exports) we put just the wrapped exports on a new object, which | ||
| # then inherits all the others from the original. The wrappers can't be | ||
| # assigned to an object that already inherits from the original exports | ||
| # object, since that is frozen, so we set the prototype afterwards. | ||
| wrappers += '\n var origExports = wasmExports;\n wasmExports = {};' | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I've updated the PR description to serve as the commit message. If you're happy with this, is it OK to merge? |
||
| for f in wrap_functions: | ||
| sig = native_sigs[f] | ||
| wrappers += f"\n wasmExports['{f}'] = makeWrapper_{sig}(origExports['{f}']);" | ||
| wrappers += '\n Object.setPrototypeOf(wasmExports, origExports);' | ||
| wrappers += '\n return wasmExports;\n}' | ||
|
|
||
| return wrappers | ||
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.
Don't we already have tests for this elsewhere?
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.
The wrapping itself is covered (
core_2gb,wasm64), but I couldn't find coverage for the two paths this PR changes, and the test suites agree. With theacorn-optimizer.mjschange reverted, all 2374 tests inwasm64_O2+core_2gbgive the same results as with it; only theO3variant here fails. Nothing else combines wrapping withDECLARE_ASM_MODULE_EXPORTS=0, so theno_declare_asm_module_exportsvariant is the only thing that catches thelibcore.jschange. If you'd rather not have a new test, I could instead add 4GB variants totest_no_declare_asm_module_exportsand to an optimized test that minifies export names. Let me know which you prefer.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.
I'm not to concerned about adding a new test here if it makes sense.
We do have several tests that use
-sDECLARE_ASM_MODULE_EXPORTS=0intest_core.py.. maybe tho issue is that we don't have awasm64_O3configuration? Should we add one maybe? (Possibly in addition to this new test).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.
You're right, and I was wrong earlier:
test_no_declare_asm_module_exportsdoes catch thelibcore.jschange (it fails underwasm64,wasm64_4gbandcore_2gbwithout it). I've removed that variant from the new test in ffe1224.A
wasm64_O3config would catch the acorn change. Export names are only minified at-O3, sowasm64_O2can't see it. I tried it locally: 841 of its 1187 tests fail with the acorn change reverted. With this PR, 12 fail, and the same 12 fail underwasm64_O2onmainfor me.I can add
wasm64_O3in a follow-up PR, if that sounds good.