Skip to content

Commit 6968ed6

Browse files
committed
gc when halted
1 parent 78a0e52 commit 6968ed6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

zenlang/src/vm/vm.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,19 +188,22 @@ impl VM {
188188

189189
pub fn step(&mut self) -> bool {
190190
if self.halted {
191+
self.gc();
191192
return false;
192193
}
193194

194195
let module_index = self.pc.get_high() as usize;
195196
let opcode_index = self.pc.get_low();
196197
if module_index >= self.modules.len() {
197198
self.halted = true;
199+
self.gc();
198200
return false;
199201
}
200202

201203
let opcodes = core::mem::take(&mut self.modules[module_index].opcodes);
202204
if opcode_index >= opcodes.len() as u32 {
203205
self.halted = true;
206+
self.gc();
204207
return false;
205208
}
206209

0 commit comments

Comments
 (0)