Merge pull request #2074 from lightpanda-io/tao_in_identity_map

Store TAO in IdentityMap
This commit is contained in:
Karl Seguin
2026-04-03 08:21:52 +08:00
committed by GitHub
2 changed files with 5 additions and 2 deletions

View File

@@ -296,7 +296,7 @@ pub fn createContext(self: *Env, page: *Page, params: ContextParams) !*Context {
// it gets setup automatically as objects are created, but the Window // it gets setup automatically as objects are created, but the Window
// object already exists in v8 (it's the global) so we manually create // object already exists in v8 (it's the global) so we manually create
// the mapping here. // the mapping here.
const tao = try context_arena.create(@import("TaggedOpaque.zig")); const tao = try params.identity_arena.create(@import("TaggedOpaque.zig"));
tao.* = .{ tao.* = .{
.value = @ptrCast(page.window), .value = @ptrCast(page.window),
.prototype_chain = (&Window.JsApi.Meta.prototype_chain).ptr, .prototype_chain = (&Window.JsApi.Meta.prototype_chain).ptr,

View File

@@ -244,7 +244,10 @@ pub fn mapZigInstanceToJs(self: *const Local, js_obj_handle: ?*const v8.Object,
// The TAO contains the pointer to our Zig instance as // The TAO contains the pointer to our Zig instance as
// well as any meta data we'll need to use it later. // well as any meta data we'll need to use it later.
// See the TaggedOpaque struct for more details. // See the TaggedOpaque struct for more details.
const tao = try context_arena.create(TaggedOpaque); // Use identity_arena so TAOs survive context destruction. V8 objects
// are stored in identity_map (session-level) and may be referenced
// after their creating context is destroyed (e.g., via microtasks).
const tao = try ctx.identity_arena.create(TaggedOpaque);
tao.* = .{ tao.* = .{
.value = resolved.ptr, .value = resolved.ptr,
.prototype_chain = resolved.prototype_chain.ptr, .prototype_chain = resolved.prototype_chain.ptr,