mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-04-03 16:10:29 +00:00
Store TAO in IdentityMap
The object can be accessed from any context in the same origin, so the TAO should exist for as long.
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user