Skip to content

Commit 4dced39

Browse files
committed
add Compiler::global_set helper function
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
1 parent 8045e34 commit 4dced39

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

crates/environ/src/fact/trampoline.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,11 +543,8 @@ impl<'a, 'b> Compiler<'a, 'b> {
543543
self.instruction(Drop);
544544

545545
if let Some(globals) = result_globals {
546-
self.flush_code();
547546
for global in globals {
548-
self.module.funcs[self.result]
549-
.body
550-
.push(Body::GlobalGet(*global));
547+
self.global_set(*global);
551548
}
552549
}
553550

@@ -3160,6 +3157,13 @@ impl<'a, 'b> Compiler<'a, 'b> {
31603157
self.instruction(Unreachable);
31613158
}
31623159

3160+
fn global_set(&mut self, index: u32) {
3161+
self.flush_code();
3162+
self.module.funcs[self.result]
3163+
.body
3164+
.push(Body::GlobalGet(index));
3165+
}
3166+
31633167
/// Flushes out the current `code` instructions (and `traps` if there are
31643168
/// any) into the destination function.
31653169
///

0 commit comments

Comments
 (0)