File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 202202
203203#include " ir/effects.h"
204204#include " ir/literal-utils.h"
205+ #include " ir/memory-utils.h"
205206#include " ir/module-utils.h"
206207#include " ir/utils.h"
207208#include " pass.h"
@@ -948,6 +949,10 @@ struct BysyncifyLocals : public WalkerPass<PostWalker<BysyncifyLocals>> {
948949struct Bysyncify : public Pass {
949950 void run (PassRunner* runner, Module* module ) override {
950951 bool optimize = runner->options .optimizeLevel > 0 ;
952+
953+ // Ensure there is a memory, as we need it.
954+ MemoryUtils::ensureExists (module ->memory );
955+
951956 // Find which things can change the state.
952957 auto stateChangingImports =
953958 runner->options .getArgumentOrDefault (" bysyncify-imports" , " " );
Original file line number Diff line number Diff line change 28352835 )
28362836 )
28372837)
2838+ (module
2839+ (memory $0 1 1)
2840+ (global $__bysyncify_state (mut i32) (i32.const 0))
2841+ (global $__bysyncify_data (mut i32) (i32.const 0))
2842+ (export "bysyncify_start_unwind" (func $bysyncify_start_unwind))
2843+ (export "bysyncify_stop_unwind" (func $bysyncify_stop_unwind))
2844+ (export "bysyncify_start_rewind" (func $bysyncify_start_rewind))
2845+ (export "bysyncify_stop_rewind" (func $bysyncify_stop_rewind))
2846+ (func $bysyncify_start_unwind (; 0 ;) (param $0 i32)
2847+ (if
2848+ (i32.gt_u
2849+ (i32.load
2850+ (local.get $0)
2851+ )
2852+ (i32.load offset=4
2853+ (local.get $0)
2854+ )
2855+ )
2856+ (unreachable)
2857+ )
2858+ (global.set $__bysyncify_state
2859+ (i32.const 1)
2860+ )
2861+ (global.set $__bysyncify_data
2862+ (local.get $0)
2863+ )
2864+ )
2865+ (func $bysyncify_stop_unwind (; 1 ;)
2866+ (global.set $__bysyncify_state
2867+ (i32.const 0)
2868+ )
2869+ )
2870+ (func $bysyncify_start_rewind (; 2 ;) (param $0 i32)
2871+ (if
2872+ (i32.gt_u
2873+ (i32.load
2874+ (local.get $0)
2875+ )
2876+ (i32.load offset=4
2877+ (local.get $0)
2878+ )
2879+ )
2880+ (unreachable)
2881+ )
2882+ (global.set $__bysyncify_state
2883+ (i32.const 2)
2884+ )
2885+ (global.set $__bysyncify_data
2886+ (local.get $0)
2887+ )
2888+ )
2889+ (func $bysyncify_stop_rewind (; 3 ;)
2890+ (global.set $__bysyncify_state
2891+ (i32.const 0)
2892+ )
2893+ )
2894+ )
Original file line number Diff line number Diff line change 146146 (call $import )
147147 )
148148)
149+ ;; empty module, in particular with no memory
150+ (module
151+ )
149152
You can’t perform that action at this time.
0 commit comments