Skip to content

Commit faefa19

Browse files
committed
persistent context cleanup
1 parent bb20cfe commit faefa19

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

build.zig.zon

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
.hash = "tigerbeetle_io-0.0.0-ViLgxpyRBAB5BMfIcj3KMXfbJzwARs9uSl8aRy2OXULd",
1414
},
1515
.v8 = .{
16-
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/97bcfb61da8c97de1321d677a6727a927a9db9a4.tar.gz",
17-
.hash = "v8-0.0.0-xddH69DoIADZ8YXZ_EIx_tKdQKEoGsgob_3_ZIi0O_nV",
16+
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/363e2899e6d782ad999edbfae048228871230467.tar.gz",
17+
.hash = "v8-0.0.0-xddH6wHzIAARDy1uFvPqqBpTXzhlnEGDTuX9IAUQz3oU",
1818
},
19-
//.v8 = .{ .path = "../zig-v8-fork" },
19+
// .v8 = .{ .path = "../zig-v8-fork" },
2020
//.tigerbeetle_io = .{ .path = "../tigerbeetle-io" },
2121
},
2222
}

src/runtime/js.zig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,9 @@ pub fn Env(comptime S: type, comptime types: anytype) type {
264264
const templates = &self.templates;
265265

266266
// The global FunctionTemplate (i.e. Window).
267-
// env.generateClass(@field(types, s.name))
268-
const globals = v8.Persistent(v8.FunctionTemplate).init(isolate, v8.FunctionTemplate.initDefault(isolate)).castToFunctionTemplate();
267+
const globals = v8.FunctionTemplate.initDefault(isolate);
269268

270-
const global_template = v8.Persistent(v8.ObjectTemplate).init(isolate, globals.getInstanceTemplate()).castToObjectTemplate();
269+
const global_template = globals.getInstanceTemplate();
271270
global_template.setInternalFieldCount(1);
272271
self.attachClass(Global, globals);
273272

@@ -752,6 +751,7 @@ pub fn Env(comptime S: type, comptime types: anytype) type {
752751

753752
// @intFromPtr of our Executor is stored in this context, so given
754753
// a context, we can always get the Executor back.
754+
// This context is a persistent object. The persistent needs to be recovered and reset.
755755
context: v8.Context,
756756

757757
// Because calls can be nested (i.e.a function calling a callback),
@@ -800,6 +800,8 @@ pub fn Env(comptime S: type, comptime types: anytype) type {
800800
fn deinit(self: *Executor) void {
801801
if (self.scope != null) self.endScope();
802802
self.context.exit();
803+
var presistent_context = v8.Persistent(v8.Context).recoverCast(self.context);
804+
presistent_context.deinit();
803805

804806
self._call_arena_instance.deinit();
805807
self._scope_arena_instance.deinit();

0 commit comments

Comments
 (0)