-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add zeroMemory JS utility function to avoid exporting _memset. NFC #14441
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
Conversation
| }, | ||
|
|
||
| $zeroMemory: function(address, size) { | ||
| HEAPU8.fill(0, address, address + size); |
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.
How about adding something like this:
#if LEGACY_VM_SUPPORT
if (!HEAPU8.fill) {
(for var i = 0; i < size; i++) {
HEAPU8[address + i] = 0;
}
return;
}
#endifThere 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.
Good idea!
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 do kind of worry, in general, about adding complexity like this before knowing if we really need it because it will make it really hard to ever know it is used, and its really hard to 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.
We can test it, if we think it's worth it - do HEAPU8.fill = null to force the "polyfill" to be used, and build with legacy VM support. I think we have some tests like that.
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.
Do you want me to go back to add one? I'm tempted to leave it.
This avoids the extra export from wasm and the potential codesize of including memset. Its probably faster and smaller over the wire too. Using TypedArray:fill looks fine on all the current min browser versions we support: https://caniuse.com/mdn-javascript_builtins_typedarray_fill If we need to support even older browsers we can always ifdef/polyfill at this single location in the future.
…5654) I recently landed emscripten-core#15617 which inadvertently broke asan builds because, under asan, there was a real dependency on `_memset` in the `withBuiltinMalloc` wrapper. However this dependency is no longer needed since the use of `_memset` was removed from the JS library code in emscripten-core#14441.
This avoids the extra export from wasm and the potential
codesize of including memset. Its probably faster and
smaller over the wire too.
Using TypedArray:fill looks fine on all the current
min browser versions we support:
https://caniuse.com/mdn-javascript_builtins_typedarray_fill
If we need to support even older browsers we can always
ifdef/polyfill at this single location in the future.