mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-31 17:31:06 +00:00
Fix logic for is_enabled
in the threads transform (#1791)
The threads transform is implicitly enabled nowadays when the memory looks like it's shared, so ensure that's taken into account in the `is_enabled` check.
This commit is contained in:
parent
f4a7fe3ddb
commit
6f52f2a37c
@ -283,7 +283,7 @@ impl Bindgen {
|
|||||||
// pointer, so temporarily export it so that our many GC's don't remove
|
// pointer, so temporarily export it so that our many GC's don't remove
|
||||||
// it before the xform runs.
|
// it before the xform runs.
|
||||||
let mut exported_shadow_stack_pointer = false;
|
let mut exported_shadow_stack_pointer = false;
|
||||||
if self.multi_value || self.threads.is_enabled() {
|
if self.multi_value || self.threads.is_enabled(&module) {
|
||||||
wasm_conventions::export_shadow_stack_pointer(&mut module)?;
|
wasm_conventions::export_shadow_stack_pointer(&mut module)?;
|
||||||
exported_shadow_stack_pointer = true;
|
exported_shadow_stack_pointer = true;
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,21 @@ impl Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Is threaded Wasm enabled?
|
/// Is threaded Wasm enabled?
|
||||||
pub fn is_enabled(&self) -> bool {
|
pub fn is_enabled(&self, module: &Module) -> bool {
|
||||||
self.enabled
|
if self.enabled {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compatibility with older LLVM outputs. Newer LLVM outputs, when
|
||||||
|
// atomics are enabled, emit a shared memory. That's a good indicator
|
||||||
|
// that we have work to do. If shared memory isn't enabled, though then
|
||||||
|
// this isn't an atomic module so there's nothing to do. We still allow,
|
||||||
|
// though, an environment variable to force us to go down this path to
|
||||||
|
// remain compatibile with older LLVM outputs.
|
||||||
|
match wasm_conventions::get_memory(module) {
|
||||||
|
Ok(memory) => module.memories.get(memory).shared,
|
||||||
|
Err(_) => false,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Specify the maximum amount of memory the wasm module can ever have.
|
/// Specify the maximum amount of memory the wasm module can ever have.
|
||||||
@ -87,21 +100,11 @@ impl Config {
|
|||||||
///
|
///
|
||||||
/// More and/or less may happen here over time, stay tuned!
|
/// More and/or less may happen here over time, stay tuned!
|
||||||
pub fn run(&self, module: &mut Module) -> Result<(), Error> {
|
pub fn run(&self, module: &mut Module) -> Result<(), Error> {
|
||||||
if !self.enabled {
|
if !self.is_enabled(module) {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compatibility with older LLVM outputs. Newer LLVM outputs, when
|
|
||||||
// atomics are enabled, emit a shared memory. That's a good indicator
|
|
||||||
// that we have work to do. If shared memory isn't enabled, though then
|
|
||||||
// this isn't an atomic module so there's nothing to do. We still allow,
|
|
||||||
// though, an environment variable to force us to go down this path to
|
|
||||||
// remain compatibile with older LLVM outputs.
|
|
||||||
let memory = wasm_conventions::get_memory(module)?;
|
let memory = wasm_conventions::get_memory(module)?;
|
||||||
if !module.memories.get(memory).shared {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
let stack_pointer = wasm_conventions::get_shadow_stack_pointer(module)?;
|
let stack_pointer = wasm_conventions::get_shadow_stack_pointer(module)?;
|
||||||
let addr = allocate_static_data(module, memory, 4, 4)?;
|
let addr = allocate_static_data(module, memory, 4, 4)?;
|
||||||
let zero = InitExpr::Value(Value::I32(0));
|
let zero = InitExpr::Value(Value::I32(0));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user