From 1babaa64ccc42e8b115a133e73975c85d769404f Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Sun, 19 May 2024 22:03:16 +0200 Subject: [PATCH] fix(hotspot): Hotspot need currents closure --- src/Jit.zig | 8 ++++++-- src/vm.zig | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Jit.zig b/src/Jit.zig index 623c3ec3..04b29768 100644 --- a/src/Jit.zig +++ b/src/Jit.zig @@ -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( @@ -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); diff --git a/src/vm.zig b/src/vm.zig index f90180f8..e6112748 100644 --- a/src/vm.zig +++ b/src/vm.zig @@ -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, .{