@@ -31,8 +31,21 @@ impl Config {
31
31
}
32
32
33
33
/// Is threaded Wasm enabled?
34
- pub fn is_enabled ( & self ) -> bool {
35
- self . enabled
34
+ pub fn is_enabled ( & self , module : & Module ) -> bool {
35
+ if self . enabled {
36
+ return true ;
37
+ }
38
+
39
+ // Compatibility with older LLVM outputs. Newer LLVM outputs, when
40
+ // atomics are enabled, emit a shared memory. That's a good indicator
41
+ // that we have work to do. If shared memory isn't enabled, though then
42
+ // this isn't an atomic module so there's nothing to do. We still allow,
43
+ // though, an environment variable to force us to go down this path to
44
+ // remain compatibile with older LLVM outputs.
45
+ match wasm_conventions:: get_memory ( module) {
46
+ Ok ( memory) => module. memories . get ( memory) . shared ,
47
+ Err ( _) => false ,
48
+ }
36
49
}
37
50
38
51
/// Specify the maximum amount of memory the wasm module can ever have.
@@ -87,21 +100,11 @@ impl Config {
87
100
///
88
101
/// More and/or less may happen here over time, stay tuned!
89
102
pub fn run ( & self , module : & mut Module ) -> Result < ( ) , Error > {
90
- if !self . enabled {
103
+ if !self . is_enabled ( module ) {
91
104
return Ok ( ( ) ) ;
92
105
}
93
106
94
- // Compatibility with older LLVM outputs. Newer LLVM outputs, when
95
- // atomics are enabled, emit a shared memory. That's a good indicator
96
- // that we have work to do. If shared memory isn't enabled, though then
97
- // this isn't an atomic module so there's nothing to do. We still allow,
98
- // though, an environment variable to force us to go down this path to
99
- // remain compatibile with older LLVM outputs.
100
107
let memory = wasm_conventions:: get_memory ( module) ?;
101
- if !module. memories . get ( memory) . shared {
102
- return Ok ( ( ) ) ;
103
- }
104
-
105
108
let stack_pointer = wasm_conventions:: get_shadow_stack_pointer ( module) ?;
106
109
let addr = allocate_static_data ( module, memory, 4 , 4 ) ?;
107
110
let zero = InitExpr :: Value ( Value :: I32 ( 0 ) ) ;
0 commit comments