File tree Expand file tree Collapse file tree 3 files changed +46
-13
lines changed
Expand file tree Collapse file tree 3 files changed +46
-13
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,13 @@ struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> {
105105 }
106106
107107 void visitLocalSet (LocalSet* curr) {
108+ // We don't instrument pop instructions. They are automatically deleted when
109+ // writing binary and generated when reading binary, so they don't work with
110+ // local set/get instrumentation.
111+ if (curr->value ->is <Pop>()) {
112+ return ;
113+ }
114+
108115 Builder builder (*getModule ());
109116 Name import ;
110117 switch (curr->value ->type ) {
Original file line number Diff line number Diff line change 127127 )
128128 (local.set $a
129129 (call $set_anyref
130- (i32.const 13 )
130+ (i32.const 14 )
131131 (i32.const 4)
132- (anyref.pop)
132+ (call $get_anyref
133+ (i32.const 13)
134+ (i32.const 4)
135+ (local.get $a)
136+ )
133137 )
134138 )
135139 (local.set $e
136140 (call $set_exnref
137- (i32.const 14 )
141+ (i32.const 16 )
138142 (i32.const 5)
139- (exnref.pop)
143+ (call $get_exnref
144+ (i32.const 15)
145+ (i32.const 5)
146+ (local.get $e)
147+ )
140148 )
141149 )
142150 (local.set $x
143151 (call $set_i32
144- (i32.const 15 )
152+ (i32.const 17 )
145153 (i32.const 0)
146154 (i32.const 11)
147155 )
151159 )
152160 (local.set $z
153161 (call $set_f32
154- (i32.const 16 )
162+ (i32.const 18 )
155163 (i32.const 2)
156164 (f32.const 33.209999084472656)
157165 )
158166 )
159167 (local.set $w
160168 (call $set_f64
161- (i32.const 17 )
169+ (i32.const 19 )
162170 (i32.const 3)
163171 (f64.const 44.321)
164172 )
165173 )
166174 (local.set $a
167175 (call $set_anyref
168- (i32.const 18 )
176+ (i32.const 21 )
169177 (i32.const 4)
170- (anyref.pop)
178+ (call $get_anyref
179+ (i32.const 20)
180+ (i32.const 4)
181+ (local.get $a)
182+ )
171183 )
172184 )
173185 (local.set $e
174186 (call $set_exnref
175- (i32.const 19 )
187+ (i32.const 23 )
176188 (i32.const 5)
177- (exnref.pop)
189+ (call $get_exnref
190+ (i32.const 22)
191+ (i32.const 5)
192+ (local.get $e)
193+ )
178194 )
179195 )
196+ (local.set $a
197+ (anyref.pop)
198+ )
199+ (local.set $e
200+ (exnref.pop)
201+ )
180202 )
181203)
Original file line number Diff line number Diff line change 2525 (local.set $y (i64.const 2 ))
2626 (local.set $z (f32.const 3.21 ))
2727 (local.set $w (f64.const 4.321 ))
28- (local.set $a (anyref.pop ))
29- (local.set $e (exnref.pop ))
28+ (local.set $a (local.get $a ))
29+ (local.set $e (local.get $e ))
3030
3131 (local.set $x (i32.const 11 ))
3232 (local.set $y (i64.const 22 ))
3333 (local.set $z (f32.const 33.21 ))
3434 (local.set $w (f64.const 44.321 ))
35+ (local.set $a (local.get $a ))
36+ (local.set $e (local.get $e ))
37+
38+ ;; Pop instructions should not be instrumented
3539 (local.set $a (anyref.pop))
3640 (local.set $e (exnref.pop))
3741 )
You can’t perform that action at this time.
0 commit comments