expose eager thread-local initialization by the Engine
This commit is contained in:
@@ -49,8 +49,8 @@ pub use crate::memory::{Memory, RuntimeLinearMemory, RuntimeMemoryCreator};
|
||||
pub use crate::mmap::Mmap;
|
||||
pub use crate::table::{Table, TableElement};
|
||||
pub use crate::traphandlers::{
|
||||
catch_traps, init_traps, raise_lib_trap, raise_user_trap, resume_panic, SignalHandler,
|
||||
TlsRestore, Trap,
|
||||
catch_traps, init_traps, raise_lib_trap, raise_user_trap, resume_panic, tls_eager_initialize,
|
||||
SignalHandler, TlsRestore, Trap,
|
||||
};
|
||||
pub use crate::vmcontext::{
|
||||
VMCallerCheckedAnyfunc, VMContext, VMFunctionBody, VMFunctionImport, VMGlobalDefinition,
|
||||
|
||||
@@ -12,7 +12,7 @@ use std::sync::atomic::Ordering::SeqCst;
|
||||
use std::sync::Once;
|
||||
use wasmtime_environ::ir;
|
||||
|
||||
pub use self::tls::TlsRestore;
|
||||
pub use self::tls::{tls_eager_initialize, TlsRestore};
|
||||
|
||||
extern "C" {
|
||||
#[allow(improper_ctypes)]
|
||||
@@ -386,12 +386,29 @@ mod tls {
|
||||
})
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
/// Eagerly initialize thread-local runtime functionality. This will be performed
|
||||
/// lazily by the runtime if users do not perform it eagerly.
|
||||
pub fn initialize() -> Result<(), Trap> {
|
||||
PTR.with(|p| {
|
||||
let (state, mut initialized) = p.get();
|
||||
if !initialized {
|
||||
super::super::sys::lazy_per_thread_init()?;
|
||||
initialized = true;
|
||||
}
|
||||
p.set((state, initialized));
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
#[inline(never)] // see module docs for why this is here
|
||||
pub fn get() -> Ptr {
|
||||
PTR.with(|p| p.get().0)
|
||||
}
|
||||
}
|
||||
|
||||
pub use raw::initialize as tls_eager_initialize;
|
||||
|
||||
/// Opaque state used to help control TLS state across stack switches for
|
||||
/// async support.
|
||||
pub struct TlsRestore(raw::Ptr);
|
||||
|
||||
Reference in New Issue
Block a user