Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ inputs:
zig-v8:
description: 'zig v8 version to install'
required: false
default: 'v0.1.27'
default: 'v0.1.28'
v8:
description: 'v8 version to install'
required: false
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARG MINISIG=0.12
ARG ZIG=0.14.1
ARG ZIG_MINISIG=RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U
ARG V8=13.6.233.8
ARG ZIG_V8=v0.1.27
ARG ZIG_V8=v0.1.28
ARG TARGETPLATFORM

RUN apt-get update -yq && \
Expand Down
4 changes: 2 additions & 2 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
.hash = "tigerbeetle_io-0.0.0-ViLgxpyRBAB5BMfIcj3KMXfbJzwARs9uSl8aRy2OXULd",
},
.v8 = .{
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/dd087771378ea854452bcb010309fa9ffe5a9cac.tar.gz",
.hash = "v8-0.0.0-xddH66e8AwBL3O_A8yWQYQIyfMbKHFNVQr_NqM6YjU11",
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/10025d52cb1d33434f18634c326e67038fd927d5.tar.gz",
.hash = "v8-0.0.0-xddH6-vCAwCtIRfzEw1zKu0TnMbDrFltZ8I0x-PALyIh",
},
//.v8 = .{ .path = "../zig-v8-fork" },
//.tigerbeetle_io = .{ .path = "../tigerbeetle-io" },
Expand Down
30 changes: 20 additions & 10 deletions src/runtime/js.zig
Original file line number Diff line number Diff line change
Expand Up @@ -747,18 +747,9 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
}

pub fn exec(self: *JsContext, src: []const u8, name: ?[]const u8) !Value {
const isolate = self.isolate;
const v8_context = self.v8_context;

var origin: ?v8.ScriptOrigin = null;
if (name) |n| {
const scr_name = v8.String.initUtf8(isolate, n);
origin = v8.ScriptOrigin.initDefault(scr_name.toValue());
}
const scr_js = v8.String.initUtf8(isolate, src);
const scr = v8.Script.compile(v8_context, scr_js, origin) catch {
return error.CompilationError;
};
const scr = try compileScript(self.isolate, v8_context, src, name);

const value = scr.run(v8_context) catch {
return error.ExecutionError;
Expand Down Expand Up @@ -2035,6 +2026,25 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
};
}

fn compileScript(isolate: v8.Isolate, ctx: v8.Context, src: []const u8, name: ?[]const u8) !v8.Script {
// compile
const script_name = v8.String.initUtf8(isolate, name orelse "anonymous");
const script_source = v8.String.initUtf8(isolate, src);

const origin = v8.ScriptOrigin.initDefault(script_name.toValue());

var script_comp_source: v8.ScriptCompilerSource = undefined;
v8.ScriptCompilerSource.init(&script_comp_source, script_source, origin, null);
defer script_comp_source.deinit();

return v8.ScriptCompiler.compile(
ctx,
&script_comp_source,
.kNoCompileOptions,
.kNoCacheNoReason,
) catch return error.CompilationError;
}

fn compileModule(isolate: v8.Isolate, src: []const u8, name: []const u8) !v8.Module {
// compile
const script_name = v8.String.initUtf8(isolate, name);
Expand Down