mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-12 15:16:06 +00:00
Avoid invoking a function pointer with JsStatic
The previous codegen wasn't enough to convince LLVM that the function pointer was a constant value and could be aggressively inlined, so this updates the `JsStatic` internals slightly to guarantee to LLVM that the function pointer is constant and no dynamic dispatch is needed after all
This commit is contained in:
parent
947386ee57
commit
4436c0eae6
@ -779,8 +779,10 @@ impl ToTokens for ast::ImportStatic {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static mut _VAL: ::wasm_bindgen::__rt::core::cell::UnsafeCell<Option<#ty>> =
|
||||||
|
::wasm_bindgen::__rt::core::cell::UnsafeCell::new(None);
|
||||||
::wasm_bindgen::JsStatic {
|
::wasm_bindgen::JsStatic {
|
||||||
__inner: ::wasm_bindgen::__rt::core::cell::UnsafeCell::new(None),
|
__inner: unsafe { &_VAL },
|
||||||
__init: init,
|
__init: init,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -303,9 +303,9 @@ impl Drop for JsValue {
|
|||||||
///
|
///
|
||||||
/// This type implements `Deref` to the inner type so it's typically used as if
|
/// This type implements `Deref` to the inner type so it's typically used as if
|
||||||
/// it were `&T`.
|
/// it were `&T`.
|
||||||
pub struct JsStatic<T> {
|
pub struct JsStatic<T: 'static> {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub __inner: UnsafeCell<Option<T>>,
|
pub __inner: &'static UnsafeCell<Option<T>>,
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub __init: fn() -> T,
|
pub __init: fn() -> T,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user