Support undefined static imports with Option#4319
Support undefined static imports with Option#4319daxpedda merged 6 commits intowasm-bindgen:mainfrom
undefined static imports with Option#4319Conversation
07cf60b to
8a1553a
Compare
|
The title of this PR doesn't make sense to me. If the global I think what you really mean is that it now supports undeclared variables, right? So for your example, Also, please document this feature. Its behavior is not at all obvious. E.g. WBG doesn't support |
It would not, that's why
Right, the distinction between
I might consider expanding this feature to cover |
Or not actually? As you said, this feature is not about |
8a1553a to
92a7912
Compare
|
Adjusted and added documentation. So to be clear: this PR does not add support for |
050bb5c to
dff35ce
Compare
b13f517 to
da0c13c
Compare
Co-Authored-By: Michael Schmidt <msrd0000@gmail.com>
Co-Authored-By: Michael Schmidt <msrd0000@gmail.com>
da0c13c to
2b5ebdc
Compare
RunDevelopment
left a comment
There was a problem hiding this comment.
LGTM! Thank you @daxpedda!
As discussed in #541. This PR adds the following improvements: - Caching of the global `Crypto` object. - Detecting if our Wasm memory is based on a `SharedArrayBuffer`. If not, we can copy bytes directly into our memory instead of having to go through JS. This saves allocating the buffer in JS and copying the bytes into Wasm memory. This is also the most common path. `SharedArrayBuffer` requires `target_feature = "atomics"`, which is unstable and requires Rust nightly. See #559 (comment) for full context. - The atomic path only creates a sub-array when necessary, potentially saving another FFI call. - The atomic path will now allocate an `Uint8Array` with the minimum amount of bytes necessary instead of a fixed size. - The maximum chunk size for the non-atomic path and the maximum `Uint8Array` size for the atomic paths have been increased to 65536 bytes: the maximum allowed buffer size for `Crypto.getRandomValues()`. All in all this should give a performance improvement of ~5% to ~500% depending on the amount of requested bytes and which path is taken. See #559 (comment) for some benchmark results. This spawned a bunch of improvements and fixes in `wasm-bindgen` that are being used here: - wasm-bindgen/wasm-bindgen#4315 - wasm-bindgen/wasm-bindgen#4316 - wasm-bindgen/wasm-bindgen#4318 - wasm-bindgen/wasm-bindgen#4319 - wasm-bindgen/wasm-bindgen#4340
As discussed in rust-random#541. This PR adds the following improvements: - Caching of the global `Crypto` object. - Detecting if our Wasm memory is based on a `SharedArrayBuffer`. If not, we can copy bytes directly into our memory instead of having to go through JS. This saves allocating the buffer in JS and copying the bytes into Wasm memory. This is also the most common path. `SharedArrayBuffer` requires `target_feature = "atomics"`, which is unstable and requires Rust nightly. See rust-random#559 (comment) for full context. - The atomic path only creates a sub-array when necessary, potentially saving another FFI call. - The atomic path will now allocate an `Uint8Array` with the minimum amount of bytes necessary instead of a fixed size. - The maximum chunk size for the non-atomic path and the maximum `Uint8Array` size for the atomic paths have been increased to 65536 bytes: the maximum allowed buffer size for `Crypto.getRandomValues()`. All in all this should give a performance improvement of ~5% to ~500% depending on the amount of requested bytes and which path is taken. See rust-random#559 (comment) for some benchmark results. This spawned a bunch of improvements and fixes in `wasm-bindgen` that are being used here: - wasm-bindgen/wasm-bindgen#4315 - wasm-bindgen/wasm-bindgen#4316 - wasm-bindgen/wasm-bindgen#4318 - wasm-bindgen/wasm-bindgen#4319 - wasm-bindgen/wasm-bindgen#4340
This currently throws an error in JS if
cryptoisundefined.This change would set
CRYPTOtoNoneinstead.