diff --git a/.github/actions/install/action.yml b/.github/actions/install/action.yml index d0f0bb55..88a672a0 100644 --- a/.github/actions/install/action.yml +++ b/.github/actions/install/action.yml @@ -13,7 +13,7 @@ inputs: zig-v8: description: 'zig v8 version to install' required: false - default: 'v0.2.8' + default: 'v0.2.9' v8: description: 'v8 version to install' required: false diff --git a/Dockerfile b/Dockerfile index 33282309..79ae2627 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM debian:stable-slim ARG MINISIG=0.12 ARG ZIG_MINISIG=RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U ARG V8=14.0.365.4 -ARG ZIG_V8=v0.2.8 +ARG ZIG_V8=v0.2.9 ARG TARGETPLATFORM RUN apt-get update -yq && \ diff --git a/build.zig.zon b/build.zig.zon index c7fbd917..946210d1 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -6,8 +6,8 @@ .minimum_zig_version = "0.15.2", .dependencies = .{ .v8 = .{ - .url = "https://github.com/lightpanda-io/zig-v8-fork/archive/refs/tags/v0.2.8.tar.gz", - .hash = "v8-0.0.0-xddH63lfBADJ7UE2zAJ8nJIBnxoSiimXSaX6Q_M_7DS3", + .url = "https://github.com/lightpanda-io/zig-v8-fork/archive/refs/tags/v0.2.9.tar.gz", + .hash = "v8-0.0.0-xddH689vBACgpqFVEhT2wxRin-qQQSOcKJoM37MVo0rU", }, //.v8 = .{ .path = "../zig-v8-fork" }, .@"boringssl-zig" = .{ diff --git a/src/browser/js/Env.zig b/src/browser/js/Env.zig index c73450a8..8f2cc6aa 100644 --- a/src/browser/js/Env.zig +++ b/src/browser/js/Env.zig @@ -78,6 +78,14 @@ pub const InitOpts = struct { }; pub fn init(app: *App, opts: InitOpts) !Env { + if (comptime IS_DEBUG) { + comptime { + // V8 requirement for any data using SetAlignedPointerInInternalField + const a = @alignOf(@import("TaggedOpaque.zig")); + std.debug.assert(a >= 2 and a % 2 == 0); + } + } + const allocator = app.allocator; const snapshot = &app.snapshot; diff --git a/src/browser/js/Inspector.zig b/src/browser/js/Inspector.zig index 7ba97257..245c5582 100644 --- a/src/browser/js/Inspector.zig +++ b/src/browser/js/Inspector.zig @@ -364,9 +364,8 @@ pub fn getTaggedOpaque(value: *const v8.Value) ?*TaggedOpaque { return null; } - const external_value = v8.v8__Object__GetInternalField(value, 0).?; - const external_data = v8.v8__External__Value(external_value).?; - return @ptrCast(@alignCast(external_data)); + const tao_ptr = v8.v8__Object__GetAlignedPointerFromInternalField(value, 0).?; + return @ptrCast(@alignCast(tao_ptr)); } fn cZigStringToString(s: v8.CZigString) ?[]const u8 { diff --git a/src/browser/js/Local.zig b/src/browser/js/Local.zig index 524dfd54..78ec45b0 100644 --- a/src/browser/js/Local.zig +++ b/src/browser/js/Local.zig @@ -181,11 +181,7 @@ pub fn mapZigInstanceToJs(self: *const Local, js_obj_handle: ?*const v8.Object, .subtype = if (@hasDecl(JsApi.Meta, "subtype")) JsApi.Meta.subype else .node, }; - // Skip setting internal field for the global object (Window) - // Window accessors get the instance from context.page.window instead - // if (resolved.class_id != @import("../webapi/Window.zig").JsApi.Meta.class_id) { - v8.v8__Object__SetInternalField(js_obj.handle, 0, isolate.createExternal(tao)); - // } + v8.v8__Object__SetAlignedPointerInInternalField(js_obj.handle, 0, tao); } else { // If the struct is empty, we don't need to do all // the TOA stuff and setting the internal data. diff --git a/src/browser/js/TaggedOpaque.zig b/src/browser/js/TaggedOpaque.zig index 68224b64..d62e735b 100644 --- a/src/browser/js/TaggedOpaque.zig +++ b/src/browser/js/TaggedOpaque.zig @@ -133,8 +133,8 @@ pub fn fromJS(comptime R: type, js_obj_handle: *const v8.Object) !R { @compileError("unknown Zig type: " ++ @typeName(R)); } - const internal_field_handle = v8.v8__Object__GetInternalField(js_obj_handle, 0).?; - const tao: *TaggedOpaque = @ptrCast(@alignCast(v8.v8__External__Value(internal_field_handle))); + const tao_ptr = v8.v8__Object__GetAlignedPointerFromInternalField(js_obj_handle, 0).?; + const tao: *TaggedOpaque = @ptrCast(@alignCast(tao_ptr)); const expected_type_index = bridge.JsApiLookup.getId(JsApi); const prototype_chain = tao.prototype_chain[0..tao.prototype_len];