Skip to content

Commit

Permalink
fix(hotspot): Hotspot need currents closure
Browse files Browse the repository at this point in the history
  • Loading branch information
giann committed May 19, 2024
1 parent 9aa961b commit 1babaa6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/Jit.zig
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ pub fn compileFunction(self: *Self, ast: Ast, closure: *o.ObjClosure) Error!void
self.reset();
}

pub fn compileHotSpot(self: *Self, ast: Ast, hotspot_node: Ast.Node.Index) Error!*anyopaque {
pub fn compileHotSpot(self: *Self, ast: Ast, closure: *o.ObjClosure, hotspot_node: Ast.Node.Index) Error!*anyopaque {
var seen = std.AutoHashMap(Ast.Node.Index, void).init(self.vm.gc.allocator);
defer seen.deinit();
if (try ast.usesFiber(
Expand All @@ -253,7 +253,11 @@ pub fn compileHotSpot(self: *Self, ast: Ast, hotspot_node: Ast.Node.Index) Error
}

// Build function surrounding the node
try self.buildFunction(ast, null, hotspot_node);
try self.buildFunction(
ast,
closure,
hotspot_node,
);

// Did we encounter other functions to compile?
try self.buildCollateralFunctions(ast);
Expand Down
6 changes: 5 additions & 1 deletion src/vm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4020,7 +4020,11 @@ pub const VM = struct {
if (self.shouldCompileHotspot(node)) {
var timer = std.time.Timer.start() catch unreachable;

if (self.jit.?.compileHotSpot(self.current_ast, node) catch null) |native| {
if (self.jit.?.compileHotSpot(
self.current_ast,
self.currentFrame().?.closure,
node,
) catch null) |native| {
const obj_native = self.gc.allocateObject(
ObjNative,
.{
Expand Down

0 comments on commit 1babaa6

Please sign in to comment.