Merge pull request #1409 from lightpanda-io/cleanup

zig fmt, remove unused code
This commit is contained in:
Karl Seguin
2026-01-24 07:49:25 +08:00
committed by GitHub
11 changed files with 11 additions and 35 deletions

View File

@@ -872,7 +872,7 @@ pub fn startHeapProfiler(self: *Context) void {
self.heap_profiler = heap_profiler; self.heap_profiler = heap_profiler;
} }
pub fn stopHeapProfiler(self: *Context) !struct{[]const u8, []const u8} { pub fn stopHeapProfiler(self: *Context) !struct { []const u8, []const u8 } {
var ls: js.Local.Scope = undefined; var ls: js.Local.Scope = undefined;
self.localScope(&ls); self.localScope(&ls);
defer ls.deinit(); defer ls.deinit();
@@ -893,5 +893,5 @@ pub fn stopHeapProfiler(self: *Context) !struct{[]const u8, []const u8} {
break :blk try ls.local.jsStringToZig(string_handle, .{}); break :blk try ls.local.jsStringToZig(string_handle, .{});
}; };
return .{allocating, snapshot}; return .{ allocating, snapshot };
} }

View File

@@ -134,11 +134,3 @@ pub fn removeContext(self: *ExecutionWorld) void {
self.env.isolate.notifyContextDisposed(); self.env.isolate.notifyContextDisposed();
_ = self.context_arena.reset(.{ .retain_with_limit = CONTEXT_ARENA_RETAIN }); _ = self.context_arena.reset(.{ .retain_with_limit = CONTEXT_ARENA_RETAIN });
} }
pub fn terminateExecution(self: *const ExecutionWorld) void {
self.env.isolate.terminateExecution();
}
pub fn resumeExecution(self: *const ExecutionWorld) void {
self.env.isolate.cancelTerminateExecution();
}

View File

@@ -1190,7 +1190,8 @@ fn _debugValue(self: *const Local, js_val: js.Value, seen: *std.AutoHashMapUnman
const js_obj = js_val.toObject(); const js_obj = js_val.toObject();
{ {
// explicit scope because gop will become invalid in recursive call // explicit scope because gop will become invalid in recursive call
const gop = try seen.getOrPut(self.call_arena, js_obj.getId()); const obj_id: u32 = @bitCast(v8.v8__Object__GetIdentityHash(js_obj.handle));
const gop = try seen.getOrPut(self.call_arena, obj_id);
if (gop.found_existing) { if (gop.found_existing) {
return writer.writeAll("<circular>\n"); return writer.writeAll("<circular>\n");
} }

View File

@@ -31,10 +31,6 @@ const Object = @This();
local: *const js.Local, local: *const js.Local,
handle: *const v8.Object, handle: *const v8.Object,
pub fn getId(self: Object) u32 {
return @bitCast(v8.v8__Object__GetIdentityHash(self.handle));
}
pub fn has(self: Object, key: anytype) bool { pub fn has(self: Object, key: anytype) bool {
const ctx = self.local.ctx; const ctx = self.local.ctx;
const key_handle = if (@TypeOf(key) == *const v8.String) key else ctx.isolate.initStringHandle(key); const key_handle = if (@TypeOf(key) == *const v8.String) key else ctx.isolate.initStringHandle(key);

View File

@@ -32,12 +32,8 @@ pub fn init(self: *TryCatch, l: *const js.Local) void {
v8.v8__TryCatch__CONSTRUCT(&self.handle, l.isolate.handle); v8.v8__TryCatch__CONSTRUCT(&self.handle, l.isolate.handle);
} }
pub fn hasCaught(self: TryCatch) bool {
return v8.v8__TryCatch__HasCaught(&self.handle);
}
pub fn caught(self: TryCatch, allocator: Allocator) ?Caught { pub fn caught(self: TryCatch, allocator: Allocator) ?Caught {
if (!self.hasCaught()) { if (!v8.v8__TryCatch__HasCaught(&self.handle)) {
return null; return null;
} }

View File

@@ -81,10 +81,6 @@ pub const ArrayBuffer = struct {
pub const Exception = struct { pub const Exception = struct {
local: *const Local, local: *const Local,
handle: *const v8.Value, handle: *const v8.Value,
pub fn exception(self: Exception, allocator: Allocator) ![]const u8 {
return self.local.valueToString(self.handel, .{ .allocator = allocator });
}
}; };
// These are simple types that we can convert to JS with only an isolate. This // These are simple types that we can convert to JS with only an isolate. This

View File

@@ -49,7 +49,7 @@ pub fn dispatch(self: *NavigationEventTarget, event_type: DispatchType, page: *P
if (comptime IS_DEBUG) { if (comptime IS_DEBUG) {
if (page.js.local == null) { if (page.js.local == null) {
log.fatal(.bug, "null context scope", .{.src = "NavigationEventTarget.dispatch", .url = page.url}); log.fatal(.bug, "null context scope", .{ .src = "NavigationEventTarget.dispatch", .url = page.url });
std.debug.assert(page.js.local != null); std.debug.assert(page.js.local != null);
} }
} }

View File

@@ -143,7 +143,7 @@ pub fn callPullIfNeeded(self: *ReadableStream) !void {
if (comptime IS_DEBUG) { if (comptime IS_DEBUG) {
if (self._page.js.local == null) { if (self._page.js.local == null) {
log.fatal(.bug, "null context scope", .{.src = "ReadableStream.callPullIfNeeded", .url = self._page.url}); log.fatal(.bug, "null context scope", .{ .src = "ReadableStream.callPullIfNeeded", .url = self._page.url });
std.debug.assert(self._page.js.local != null); std.debug.assert(self._page.js.local != null);
} }
} }

View File

@@ -86,7 +86,7 @@ pub fn enqueue(self: *ReadableStreamDefaultController, chunk: Chunk) !void {
if (comptime IS_DEBUG) { if (comptime IS_DEBUG) {
if (self._page.js.local == null) { if (self._page.js.local == null) {
log.fatal(.bug, "null context scope", .{.src = "ReadableStreamDefaultController.enqueue", .url = self._page.url}); log.fatal(.bug, "null context scope", .{ .src = "ReadableStreamDefaultController.enqueue", .url = self._page.url });
std.debug.assert(self._page.js.local != null); std.debug.assert(self._page.js.local != null);
} }
} }
@@ -113,7 +113,7 @@ pub fn close(self: *ReadableStreamDefaultController) !void {
if (comptime IS_DEBUG) { if (comptime IS_DEBUG) {
if (self._page.js.local == null) { if (self._page.js.local == null) {
log.fatal(.bug, "null context scope", .{.src = "ReadableStreamDefaultController.close", .url = self._page.url}); log.fatal(.bug, "null context scope", .{ .src = "ReadableStreamDefaultController.close", .url = self._page.url });
std.debug.assert(self._page.js.local != null); std.debug.assert(self._page.js.local != null);
} }
} }

View File

@@ -771,11 +771,6 @@ const IsolatedWorld = struct {
false, false,
); );
} }
pub fn createContextAndLoadPolyfills(self: *IsolatedWorld, page: *Page) !void {
// We need to recreate the isolated world context
try self.createContext(page);
}
}; };
// This is a generic because when we send a result we have two different // This is a generic because when we send a result we have two different

View File

@@ -190,7 +190,7 @@ fn createIsolatedWorld(cmd: anytype) !void {
const world = try bc.createIsolatedWorld(params.worldName, params.grantUniveralAccess); const world = try bc.createIsolatedWorld(params.worldName, params.grantUniveralAccess);
const page = bc.session.currentPage() orelse return error.PageNotLoaded; const page = bc.session.currentPage() orelse return error.PageNotLoaded;
try world.createContextAndLoadPolyfills(page); try world.createContext(page);
const js_context = &world.executor.context.?; const js_context = &world.executor.context.?;
// Create the auxdata json for the contextCreated event // Create the auxdata json for the contextCreated event
@@ -292,7 +292,7 @@ pub fn pageRemove(bc: anytype) !void {
pub fn pageCreated(bc: anytype, page: *Page) !void { pub fn pageCreated(bc: anytype, page: *Page) !void {
for (bc.isolated_worlds.items) |*isolated_world| { for (bc.isolated_worlds.items) |*isolated_world| {
try isolated_world.createContextAndLoadPolyfills(page); try isolated_world.createContext(page);
} }
} }