mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-15 22:11:23 +00:00
Improve link_mem_intrinsics
hack
Previously the `link_mem_intrinsics` hack actually had a runtime overhead by storing a value into a global location, but it turns out we can actually use a non-inlined function call as part of the *descriptor* which requires this to be in the final binary, but we'll end up snip'ing the value at the end. All in all this should mean that it's not a zero-overhead solution for linking these intrinsics! The `#[wasm_bindgen]` attribute already has other problems if the descriptors don't show up, so that's the least of our issues!
This commit is contained in:
14
src/lib.rs
14
src/lib.rs
@ -846,21 +846,7 @@ pub mod __rt {
|
||||
/// above. That means if this function is called and referenced we'll pull
|
||||
/// in the object file and link the intrinsics.
|
||||
///
|
||||
/// Note that this is an `#[inline]` function to remove the function call
|
||||
/// overhead we inject in functions, but right now it's unclear how to do
|
||||
/// this in a zero-cost fashion. The lowest cost seems to be generating a
|
||||
/// store that can't be optimized away (to a global), which is listed below.
|
||||
///
|
||||
/// Ideas for how to improve this are most welcome!
|
||||
#[inline]
|
||||
pub fn link_mem_intrinsics() {
|
||||
// the above symbols only exist with the `std` feature enabled.
|
||||
if !cfg!(feature = "std") {
|
||||
return
|
||||
}
|
||||
|
||||
use core::sync::atomic::*;
|
||||
static FOO: AtomicUsize = ATOMIC_USIZE_INIT;
|
||||
FOO.store(0, Ordering::SeqCst);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user