mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2025-01-01 16:04:51 +03: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 {
|
||||
__inner: ::wasm_bindgen::__rt::core::cell::UnsafeCell::new(None),
|
||||
__inner: unsafe { &_VAL },
|
||||
__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
|
||||
/// it were `&T`.
|
||||
pub struct JsStatic<T> {
|
||||
pub struct JsStatic<T: 'static> {
|
||||
#[doc(hidden)]
|
||||
pub __inner: UnsafeCell<Option<T>>,
|
||||
pub __inner: &'static UnsafeCell<Option<T>>,
|
||||
#[doc(hidden)]
|
||||
pub __init: fn() -> T,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user