Skip to content

Commit

Permalink
fix(api): bz_newVM should instanciate JIT compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
giann committed Sep 18, 2023
1 parent a918642 commit dc88ef4
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/buzz_api.zig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const FunctionNode = @import("node.zig").FunctionNode;
const dumpStack = @import("disassembler.zig").dumpStack;
const ZigType = @import("zigtypes.zig").Type;
const Token = @import("token.zig").Token;
const MIRJIT = @import("mirjit.zig");

const Value = _value.Value;
const valueToStringAlloc = _value.valueToStringAlloc;
Expand Down Expand Up @@ -618,6 +619,11 @@ export fn bz_newVM(self: *VM) ?*VM {
return null;
};

vm.mir_jit = if (BuildOptions.jit)
MIRJIT.init(vm)
else
null;

return vm;
}

Expand All @@ -633,9 +639,11 @@ export fn bz_startVM(self: *VM) void {
) catch @panic("Out of memory");
}

export fn bz_deinitVM(_: *VM) void {
// FIXME
// self.deinit();
export fn bz_deinitVM(self: *VM) void {
if (self.mir_jit) |*jit| {
jit.deinit();
}
self.deinit();
}

export fn bz_compile(self: *VM, source: ?[*]const u8, source_len: usize, file_name: ?[*]const u8, file_name_len: usize) ?*ObjFunction {
Expand Down

0 comments on commit dc88ef4

Please sign in to comment.