From 6d3d7b1e3c5cfc4f6c0ff9b3036e3ed2255a44b7 Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Mon, 21 Aug 2023 08:48:25 +0000 Subject: [PATCH 01/15] WIP --- .gitignore | 2 ++ build.zig | 39 ++++++++++++++------------- src/bundler.zig | 4 +-- src/css_scanner.zig | 22 +++++++-------- src/js_parser.zig | 38 +++++++++++++------------- src/resolver/resolver.zig | 56 +++++++++++++++++++-------------------- 6 files changed, 82 insertions(+), 79 deletions(-) diff --git a/.gitignore b/.gitignore index 5d4da2f8871604..abdc39118cba8d 100644 --- a/.gitignore +++ b/.gitignore @@ -130,3 +130,5 @@ src/js/out/tmp src/js/out/DebugPath.h make-dev-stats.csv + +.uuid \ No newline at end of file diff --git a/build.zig b/build.zig index 7d08b89933363d..95bbf4cf821256 100644 --- a/build.zig +++ b/build.zig @@ -202,6 +202,7 @@ pub fn build(b: *Build) !void { .root_source_file = FileSource.relative(root_src), .target = target, .optimize = optimize, + .main_pkg_path = .{ .cwd_relative = b.pathFromRoot(".") }, }); var default_build_options: BunBuildOptions = brk: { @@ -239,8 +240,6 @@ pub fn build(b: *Build) !void { }; { - obj.setMainPkgPath(b.pathFromRoot(".")); - try addInternalPackages( b, obj, @@ -271,9 +270,13 @@ pub fn build(b: *Build) !void { std.io.getStdErr().writer().print("Output: {s}/{s}\n\n", .{ output_dir, bun_executable_name }) catch unreachable; defer obj_step.dependOn(&obj.step); - obj.emit_bin = .{ - .emit_to = b.fmt("{s}/{s}.o", .{ output_dir, bun_executable_name }), - }; + + // = .{ + // .generated_path = .{ + // .path = b.fmt("{s}/{s}.o", .{ output_dir, bun_executable_name }), + // }, + // }; + var actual_build_options = default_build_options; if (b.option(bool, "generate-sizes", "Generate sizes of things") orelse false) { actual_build_options.sizegen = true; @@ -289,9 +292,9 @@ pub fn build(b: *Build) !void { // Disable stack probing on x86 so we don't need to include compiler_rt if (target.getCpuArch().isX86()) obj.disable_stack_probing = true; - if (b.option(bool, "for-editor", "Do not emit bin, just check for errors") orelse false) { - obj.emit_bin = .no_emit; - } + // if (b.option(bool, "for-editor", "Do not emit bin, just check for errors") orelse false) { + // obj.emit_bin = .no_emit; + // } if (target.getOsTag() == .linux) { // obj.want_lto = tar; @@ -310,7 +313,7 @@ pub fn build(b: *Build) !void { .optimize = optimize, }); defer headers_step.dependOn(&headers_obj.step); - try configureObjectStep(b, headers_obj, @TypeOf(target), target, obj.main_pkg_path.?); + try configureObjectStep(b, headers_obj, @TypeOf(target), target, obj.main_pkg_path); var headers_build_options = default_build_options; headers_build_options.bindgen = true; headers_obj.addOptions("build_options", default_build_options.step(b)); @@ -440,9 +443,9 @@ pub fn build(b: *Build) !void { headers_obj.filter = test_filter; if (test_bin_) |test_bin| { headers_obj.name = std.fs.path.basename(test_bin); - if (std.fs.path.dirname(test_bin)) |dir| headers_obj.emit_bin = .{ - .emit_to = b.fmt("{s}/{s}", .{ dir, headers_obj.name }), - }; + // if (std.fs.path.dirname(test_bin)) |dir| headers_obj.emit_bin = .{ + // .emit_to = b.fmt("{s}/{s}", .{ dir, headers_obj.name }), + // }; } try configureObjectStep(b, headers_obj, @TypeOf(target), target, obj.main_pkg_path.?); @@ -456,8 +459,8 @@ pub fn build(b: *Build) !void { pub var original_make_fn: ?*const fn (step: *std.build.Step) anyerror!void = null; -pub fn configureObjectStep(b: *std.build.Builder, obj: *CompileStep, comptime Target: type, target: Target, main_pkg_path: []const u8) !void { - obj.setMainPkgPath(main_pkg_path); +pub fn configureObjectStep(b: *std.build.Builder, obj: *CompileStep, comptime Target: type, target: Target, main_pkg_path: ?Build.LazyPath) !void { + obj.main_pkg_path = main_pkg_path; // obj.setTarget(target); try addInternalPackages(b, obj, std.heap.page_allocator, b.zig_exe, target); @@ -466,10 +469,10 @@ pub fn configureObjectStep(b: *std.build.Builder, obj: *CompileStep, comptime Ta // obj.setBuildMode(optimize); obj.bundle_compiler_rt = false; - if (obj.emit_bin == .default) - obj.emit_bin = .{ - .emit_to = b.fmt("{s}/{s}.o", .{ output_dir, obj.name }), - }; + // if (obj.emit_bin == .default) + // obj.emit_bin = .{ + // .emit_to = b.fmt("{s}/{s}.o", .{ output_dir, obj.name }), + // }; if (target.getOsTag() != .freestanding) obj.linkLibC(); if (target.getOsTag() != .freestanding) obj.bundle_compiler_rt = false; diff --git a/src/bundler.zig b/src/bundler.zig index b5912a96fe3287..6353f369f1b43b 100644 --- a/src/bundler.zig +++ b/src/bundler.zig @@ -653,9 +653,7 @@ pub const Bundler = struct { pub noinline fn dumpEnvironmentVariables(bundler: *const Bundler) void { @setCold(true); const opts = std.json.StringifyOptions{ - .whitespace = std.json.StringifyOptions.Whitespace{ - .separator = true, - }, + .whitespace = .indent_2, }; Output.flush(); std.json.stringify(bundler.env.map.*, opts, Output.writer()) catch unreachable; diff --git a/src/css_scanner.zig b/src/css_scanner.zig index e464a6d9fb360f..db5e6ee0d8dbcf 100644 --- a/src/css_scanner.zig +++ b/src/css_scanner.zig @@ -346,7 +346,7 @@ pub const Scanner = struct { comptime WriterType: type, writer: WriterType, writeChunk: (fn (ctx: WriterType, Chunk) anyerror!void), - ) !void { + ) anyerror!void { scanner.has_newline_before = scanner.end == 0; scanner.has_delimiter_before = false; scanner.step(); @@ -899,7 +899,7 @@ pub fn NewWriter( writer: *Writer, log: *logger.Log, allocator: std.mem.Allocator, - ) !void { + ) anyerror!void { std.debug.assert(writer.source.contents.len > 0); var scanner = Scanner.init( @@ -937,7 +937,7 @@ pub fn NewWriter( writer: *Writer, log: *logger.Log, allocator: std.mem.Allocator, - ) !void { + ) anyerror!void { std.debug.assert(writer.source.contents.len > 0); var scanner = Scanner.init( @@ -950,7 +950,7 @@ pub fn NewWriter( try scanner.next(.keep, @TypeOf(writer), writer, commitChunk); } - fn writeString(writer: *Writer, str: string, quote: Chunk.TextContent.Quote) !void { + fn writeString(writer: *Writer, str: string, quote: Chunk.TextContent.Quote) anyerror!void { switch (quote) { .none => { try writer.ctx.writeAll(str); @@ -974,7 +974,7 @@ pub fn NewWriter( } } - fn writeURL(writer: *Writer, url_str: string, text: Chunk.TextContent) !void { + fn writeURL(writer: *Writer, url_str: string, text: Chunk.TextContent) anyerror!void { switch (text.quote) { .none => { try writer.ctx.writeAll("url("); @@ -1001,7 +1001,7 @@ pub fn NewWriter( } } - pub fn scanChunk(writer: *Writer, chunk: Chunk) !void { + pub fn scanChunk(writer: *Writer, chunk: Chunk) anyerror!void { switch (chunk.content) { .t_url => {}, .t_import => |import| { @@ -1042,15 +1042,15 @@ pub fn NewWriter( } } - pub fn commitChunk(writer: *Writer, chunk: Chunk) !void { + pub fn commitChunk(writer: *Writer, chunk: Chunk) anyerror!void { return try writeChunk(writer, chunk, false); } - pub fn writeBundledChunk(writer: *Writer, chunk: Chunk) !void { + pub fn writeBundledChunk(writer: *Writer, chunk: Chunk) anyerror!void { return try writeChunk(writer, chunk, true); } - pub fn writeChunk(writer: *Writer, chunk: Chunk, comptime omit_imports: bool) !void { + pub fn writeChunk(writer: *Writer, chunk: Chunk, comptime omit_imports: bool) anyerror!void { switch (chunk.content) { .t_url => |url| { const url_str = try writer.linker.resolveCSS( @@ -1259,7 +1259,7 @@ pub fn NewBundler( return logger.Source.initFile(file, this.allocator); } - pub fn addCSSImport(this: *CSSBundler, absolute_path: string) !void { + pub fn addCSSImport(this: *CSSBundler, absolute_path: string) anyerror!void { const hash = Watcher.getHash(absolute_path); if (this.queued.items.len > 0 and std.mem.indexOfScalar(u32, this.queued.items, hash) != null) { return; @@ -1281,7 +1281,7 @@ pub fn NewBundler( try this.bundle_queue.append(hash); } - pub fn writeAll(this: *CSSBundler, buf: anytype) !void { + pub fn writeAll(this: *CSSBundler, buf: anytype) anyerror!void { _ = try this.writer.writeAll(buf); } diff --git a/src/js_parser.zig b/src/js_parser.zig index 0ba935c98d85c4..b278773aefbd1d 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -2653,7 +2653,7 @@ pub const Parser = struct { } }; - pub fn scanImports(self: *Parser, scan_pass: *ScanPassResult) !void { + pub fn scanImports(self: *Parser, scan_pass: *ScanPassResult) anyerror!void { if (self.options.ts and self.options.jsx.parse) { return try self._scanImports(TSXImportScanner, scan_pass); } else if (self.options.ts) { @@ -2665,7 +2665,7 @@ pub const Parser = struct { } } - fn _scanImports(self: *Parser, comptime ParserType: type, scan_pass: *ScanPassResult) !void { + fn _scanImports(self: *Parser, comptime ParserType: type, scan_pass: *ScanPassResult) anyerror!void { var p: ParserType = undefined; try ParserType.init(self.allocator, self.log, self.source, self.define, self.lexer, self.options, &p); @@ -5160,7 +5160,7 @@ fn NewParser_( return p.callRuntime(require_args[0].loc, "__require", require_args); } - pub fn recordExport(p: *P, loc: logger.Loc, alias: string, ref: Ref) !void { + pub fn recordExport(p: *P, loc: logger.Loc, alias: string, ref: Ref) anyerror!void { if (p.named_exports.get(alias)) |name| { // Duplicate exports are an error var notes = try p.allocator.alloc(logger.Data, 1); @@ -5311,7 +5311,7 @@ fn NewParser_( additional_stmt: ?Stmt, comptime suffix: string, comptime is_internal: bool, - ) !void { + ) anyerror!void { const allocator = p.allocator; const import_record_i = p.addImportRecordByRange(.stmt, logger.Range.None, import_path); var import_record: *ImportRecord = &p.import_records.items[import_record_i]; @@ -5865,7 +5865,7 @@ fn NewParser_( return .{ .failure = expr }; } - pub fn prepareForVisitPass(p: *P) !void { + pub fn prepareForVisitPass(p: *P) anyerror!void { { var count: usize = 0; for (p.scopes_in_order.items) |item| { @@ -6308,7 +6308,7 @@ fn NewParser_( return head; } - fn pushScopeForVisitPass(p: *P, kind: js_ast.Scope.Kind, loc: logger.Loc) !void { + fn pushScopeForVisitPass(p: *P, kind: js_ast.Scope.Kind, loc: logger.Loc) anyerror!void { // Output.print("\n+Loc: {d}\n", .{loc.start}); // for (p.scopes_in_order.items[p.scopes_in_order_visitor_index..p.scopes_in_order.items.len]) |scope_order, i| { // if (scope_order) |ord| { @@ -6520,7 +6520,7 @@ fn NewParser_( return ExprBindingTuple{ .binding = bind, .expr = initializer }; } - fn forbidLexicalDecl(p: *P, loc: logger.Loc) !void { + fn forbidLexicalDecl(p: *P, loc: logger.Loc) anyerror!void { try p.log.addError(p.source, loc, "Cannot use a declaration in a single-statement context"); } @@ -9481,7 +9481,7 @@ fn NewParser_( ); } - fn skipTypeScriptInterfaceStmt(p: *P, opts: *ParseStatementOptions) !void { + fn skipTypeScriptInterfaceStmt(p: *P, opts: *ParseStatementOptions) anyerror!void { const name = p.lexer.identifier; try p.lexer.expect(.t_identifier); @@ -9752,7 +9752,7 @@ fn NewParser_( }; } - fn forbidInitializers(p: *P, decls: []G.Decl, comptime loop_type: string, is_var: bool) !void { + fn forbidInitializers(p: *P, decls: []G.Decl, comptime loop_type: string, is_var: bool) anyerror!void { switch (decls.len) { 0 => {}, 1 => { @@ -9812,7 +9812,7 @@ fn NewParser_( return ExprOrLetStmt{ .stmt_or_expr = js_ast.StmtOrExpr{ .expr = try p.parseSuffix(expr, .lowest, null, Expr.EFlags.none) } }; } - fn requireInitializers(p: *P, decls: []G.Decl) !void { + fn requireInitializers(p: *P, decls: []G.Decl) anyerror!void { for (decls) |decl| { if (decl.value == null) { switch (decl.binding.data) { @@ -10555,7 +10555,7 @@ fn NewParser_( return stmts.items; } - fn markStrictModeFeature(p: *P, feature: StrictModeFeature, r: logger.Range, detail: string) !void { + fn markStrictModeFeature(p: *P, feature: StrictModeFeature, r: logger.Range, detail: string) anyerror!void { const can_be_transformed = feature == StrictModeFeature.for_in_var_init; const text = switch (feature) { .with_statement => "With statements", @@ -10868,7 +10868,7 @@ fn NewParser_( return E.Arrow{ .args = args, .prefer_expr = true, .body = G.FnBody{ .loc = arrow_loc, .stmts = stmts } }; } - fn declareBinding(p: *P, kind: Symbol.Kind, binding: *BindingNodeIndex, opts: *ParseStatementOptions) !void { + fn declareBinding(p: *P, kind: Symbol.Kind, binding: *BindingNodeIndex, opts: *ParseStatementOptions) anyerror!void { switch (binding.data) { .b_missing => {}, .b_identifier => |bind| { @@ -13958,7 +13958,7 @@ fn NewParser_( }; } - fn appendPart(p: *P, parts: *ListManaged(js_ast.Part), stmts: []Stmt) !void { + fn appendPart(p: *P, parts: *ListManaged(js_ast.Part), stmts: []Stmt) anyerror!void { // Reuse the memory if possible // This is reusable if the last part turned out to be dead p.symbol_uses.clearRetainingCapacity(); @@ -14182,7 +14182,7 @@ fn NewParser_( } } - fn recordDeclaredSymbol(p: *P, ref: Ref) !void { + fn recordDeclaredSymbol(p: *P, ref: Ref) anyerror!void { std.debug.assert(ref.isSymbol()); try p.declared_symbols.append(p.allocator, DeclaredSymbol{ .ref = ref, @@ -17198,7 +17198,7 @@ fn NewParser_( // the value is ignored because that's what the TypeScript compiler does. } - fn visitAndAppendStmt(p: *P, stmts: *ListManaged(Stmt), stmt: *Stmt) !void { + fn visitAndAppendStmt(p: *P, stmts: *ListManaged(Stmt), stmt: *Stmt) anyerror!void { // By default any statement ends the const local prefix const was_after_after_const_local_prefix = p.current_scope.is_after_const_local_prefix; p.current_scope.is_after_const_local_prefix = true; @@ -18626,7 +18626,7 @@ fn NewParser_( } } - pub fn appendIfBodyPreservingScope(p: *P, stmts: *ListManaged(Stmt), body: Stmt) !void { + pub fn appendIfBodyPreservingScope(p: *P, stmts: *ListManaged(Stmt), body: Stmt) anyerror!void { switch (body.data) { .s_block => |block| { var keep_block = false; @@ -19640,7 +19640,7 @@ fn NewParser_( } // Try separating the list for appending, so that it's not a pointer. - fn visitStmts(p: *P, stmts: *ListManaged(Stmt), _: StmtsKind) !void { + fn visitStmts(p: *P, stmts: *ListManaged(Stmt), _: StmtsKind) anyerror!void { if (only_scan_imports_and_do_not_visit) { @compileError("only_scan_imports_and_do_not_visit must not run this."); } @@ -20138,7 +20138,7 @@ fn NewParser_( stmts.* = output; } - fn extractDeclsForBinding(binding: Binding, decls: *ListManaged(G.Decl)) !void { + fn extractDeclsForBinding(binding: Binding, decls: *ListManaged(G.Decl)) anyerror!void { switch (binding.data) { .b_property, .b_missing => {}, .b_identifier => { @@ -21328,7 +21328,7 @@ fn NewParser_( lexer: js_lexer.Lexer, opts: Parser.Options, this: *P, - ) !void { + ) anyerror!void { var scope_order = try ScopeOrderList.initCapacity(allocator, 1); var scope = try allocator.create(Scope); scope.* = Scope{ diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig index fa7fd7d1672072..e2425e23b48ce6 100644 --- a/src/resolver/resolver.zig +++ b/src/resolver/resolver.zig @@ -68,34 +68,34 @@ const bufs = struct { // bundling 10 copies of Three.js. It may be worthwhile for more complicated // packages but we lack a decent module resolution benchmark right now. // Potentially revisit after https://github.com/oven-sh/bun/issues/2716 - threadlocal var extension_path: [512]u8 = undefined; - threadlocal var tsconfig_match_full_buf: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var tsconfig_match_full_buf2: [bun.MAX_PATH_BYTES]u8 = undefined; - - threadlocal var esm_subpath: [512]u8 = undefined; - threadlocal var esm_absolute_package_path: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var esm_absolute_package_path_joined: [bun.MAX_PATH_BYTES]u8 = undefined; - - threadlocal var dir_entry_paths_to_resolve: [256]DirEntryResolveQueueItem = undefined; - threadlocal var open_dirs: [256]std.fs.IterableDir = undefined; - threadlocal var resolve_without_remapping: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var index: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var dir_info_uncached_filename: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var node_bin_path: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var dir_info_uncached_path: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var tsconfig_base_url: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var relative_abs_path: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var load_as_file_or_directory_via_tsconfig_base_path: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var node_modules_check: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var field_abs_path: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var tsconfig_path_abs: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var check_browser_map: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var remap_path: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var load_as_file: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var remap_path_trailing_slash: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var path_in_global_disk_cache: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var abs_to_rel: [bun.MAX_PATH_BYTES]u8 = undefined; - threadlocal var node_modules_paths_buf: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var extension_path: [512]u8 = undefined; + pub threadlocal var tsconfig_match_full_buf: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var tsconfig_match_full_buf2: [bun.MAX_PATH_BYTES]u8 = undefined; + + pub threadlocal var esm_subpath: [512]u8 = undefined; + pub threadlocal var esm_absolute_package_path: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var esm_absolute_package_path_joined: [bun.MAX_PATH_BYTES]u8 = undefined; + + pub threadlocal var dir_entry_paths_to_resolve: [256]DirEntryResolveQueueItem = undefined; + pub threadlocal var open_dirs: [256]std.fs.IterableDir = undefined; + pub threadlocal var resolve_without_remapping: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var index: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var dir_info_uncached_filename: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var node_bin_path: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var dir_info_uncached_path: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var tsconfig_base_url: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var relative_abs_path: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var load_as_file_or_directory_via_tsconfig_base_path: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var node_modules_check: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var field_abs_path: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var tsconfig_path_abs: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var check_browser_map: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var remap_path: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var load_as_file: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var remap_path_trailing_slash: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var path_in_global_disk_cache: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var abs_to_rel: [bun.MAX_PATH_BYTES]u8 = undefined; + pub threadlocal var node_modules_paths_buf: [bun.MAX_PATH_BYTES]u8 = undefined; pub inline fn bufs(comptime field: std.meta.DeclEnum(@This())) *@TypeOf(@field(@This(), @tagName(field))) { return &@field(@This(), @tagName(field)); From 14d64398d3c84ced489c6ba27e98dfd3d429816e Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Mon, 21 Aug 2023 09:51:33 +0000 Subject: [PATCH 02/15] backup --- src/analytics/analytics_schema.zig | 12 ++-- src/api/schema.zig | 76 ++++++++++++------------ src/ast/base.zig | 4 +- src/bun.js/javascript.zig | 2 +- src/env_loader.zig | 6 +- src/fs.zig | 4 +- src/import_record.zig | 4 +- src/js_ast.zig | 92 +++++++++++++++--------------- src/logger.zig | 8 +-- src/sync.zig | 2 +- 10 files changed, 105 insertions(+), 105 deletions(-) diff --git a/src/analytics/analytics_schema.zig b/src/analytics/analytics_schema.zig index fbcc26fb0a112b..9f1cbd675e7e6d 100644 --- a/src/analytics/analytics_schema.zig +++ b/src/analytics/analytics_schema.zig @@ -346,8 +346,8 @@ pub const analytics = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -361,8 +361,8 @@ pub const analytics = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -411,8 +411,8 @@ pub const analytics = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; diff --git a/src/api/schema.zig b/src/api/schema.zig index 93b526d47425ca..efe9d2f9f02ae2 100644 --- a/src/api/schema.zig +++ b/src/api/schema.zig @@ -373,8 +373,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -391,8 +391,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -418,8 +418,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -648,8 +648,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -799,8 +799,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -820,8 +820,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -838,8 +838,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -856,8 +856,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -1124,8 +1124,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -1139,8 +1139,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -1246,8 +1246,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -1953,8 +1953,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -2180,8 +2180,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -2195,8 +2195,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -2266,8 +2266,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -2473,8 +2473,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -2506,8 +2506,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -2524,8 +2524,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -3142,8 +3142,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; diff --git a/src/ast/base.zig b/src/ast/base.zig index ab96dab3d8ca25..d53aa12579f2ce 100644 --- a/src/ast/base.zig +++ b/src/ast/base.zig @@ -285,8 +285,8 @@ pub const Ref = packed struct(u64) { return self.tag == .invalid; } - pub fn jsonStringify(self: *const Ref, options: anytype, writer: anytype) !void { - return try std.json.stringify([2]u32{ self.sourceIndex(), self.innerIndex() }, options, writer); + pub fn jsonStringify(self: *const Ref, writer: anytype) !void { + return try std.json.stringify([2]u32{ self.sourceIndex(), self.innerIndex() }, writer.options, writer); } }; diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index 07d3f64cfbb010..52250ab7af132f 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -2552,7 +2552,7 @@ pub const VirtualMachine = struct { } else if (kind.isObject() or kind.isArray()) { var bun_str = bun.String.empty; defer bun_str.deref(); - value.jsonStringify(this.global, 2, &bun_str); + value.jsonStringify(this.global, &bun_str); //2 try writer.print(comptime Output.prettyFmt(" {s}: {any}\n", allow_ansi_color), .{ field, bun_str }); add_extra_line = true; } diff --git a/src/env_loader.zig b/src/env_loader.zig index 088ec2d0cb3c19..3b584b211a14d1 100644 --- a/src/env_loader.zig +++ b/src/env_loader.zig @@ -869,18 +869,18 @@ pub const Map = struct { try this.map.put(key, value); } - pub fn jsonStringify(self: *const @This(), options: anytype, writer: anytype) !void { + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { var iterator = self.map.iterator(); _ = try writer.writeAll("{"); while (iterator.next()) |entry| { _ = try writer.writeAll("\n "); - std.json.stringify(entry.key_ptr.*, options, writer) catch unreachable; + std.json.stringify(entry.key_ptr.*, writer.options, writer) catch unreachable; _ = try writer.writeAll(": "); - std.json.stringify(entry.value_ptr.*, options, writer) catch unreachable; + std.json.stringify(entry.value_ptr.*, writer.options, writer) catch unreachable; if (iterator.index <= self.map.count() - 1) { _ = try writer.writeAll(", "); diff --git a/src/fs.zig b/src/fs.zig index 51d3fb4b7fe608..b0dd4e6668704e 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -1578,8 +1578,8 @@ pub const Path = struct { this.is_symlink = true; } - pub fn jsonStringify(self: *const @This(), options: anytype, writer: anytype) !void { - return try std.json.stringify(self.text, options, writer); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try std.json.stringify(self.text, writer.options, writer); } pub fn generateKey(p: *Path, allocator: std.mem.Allocator) !string { diff --git a/src/import_record.zig b/src/import_record.zig index 8fd29e805fcc82..16bf00131c8bfc 100644 --- a/src/import_record.zig +++ b/src/import_record.zig @@ -62,8 +62,8 @@ pub const ImportKind = enum(u8) { }; } - pub fn jsonStringify(self: @This(), options: anytype, writer: anytype) !void { - return try std.json.stringify(@tagName(self), options, writer); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try std.json.stringify(@tagName(self), writer.options, writer); } pub fn isFromCSS(k: ImportKind) bool { diff --git a/src/js_ast.zig b/src/js_ast.zig index 6c946b9d132132..6c64a7e14b8e3b 100644 --- a/src/js_ast.zig +++ b/src/js_ast.zig @@ -262,8 +262,8 @@ pub const ImportItemStatus = enum(u2) { // The printer will replace this import with "undefined" missing, - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -271,8 +271,8 @@ pub const AssignTarget = enum(u2) { none = 0, replace = 1, // "a = b" update = 2, // "a += b" - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -348,8 +348,8 @@ pub const Binding = struct { loc: logger.Loc, }; - pub fn jsonStringify(self: *const @This(), options: anytype, writer: anytype) !void { - return try std.json.stringify(Serializable{ .type = std.meta.activeTag(self.data), .object = "binding", .value = self.data, .loc = self.loc }, options, writer); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try std.json.stringify(Serializable{ .type = std.meta.activeTag(self.data), .object = "binding", .value = self.data, .loc = self.loc }, writer.options, writer); } pub fn ToExpr(comptime expr_type: type, comptime func_type: anytype) type { @@ -437,8 +437,8 @@ pub const Binding = struct { b_object, b_missing, - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -844,8 +844,8 @@ pub const G = struct { declare, class_static_block, - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; }; @@ -1152,8 +1152,8 @@ pub const Symbol = struct { // This annotates all other symbols that don't have special behavior. other, - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } pub inline fn isPrivate(kind: Symbol.Kind) bool { @@ -1371,8 +1371,8 @@ pub const OptionalChain = enum(u2) { // "(a?.b).c" => ".c" is OptionalChain null ccontinue, - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -1683,8 +1683,8 @@ pub const E = struct { }; pub const Missing = struct { - pub fn jsonStringify(_: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(null, opts, o); + pub fn jsonStringify(_: *const @This(), o: anytype) !void { + return try std.json.stringify(null, o.options, o); } }; @@ -1754,8 +1754,8 @@ pub const E = struct { return @as(T, @intFromFloat(@min(@max(@trunc(self.value), 0), comptime @min(std.math.floatMax(f64), std.math.maxInt(T))))); } - pub fn jsonStringify(self: *const Number, opts: anytype, o: anytype) !void { - return try std.json.stringify(self.value, opts, o); + pub fn jsonStringify(self: *const Number, o: anytype) !void { + return try std.json.stringify(self.value, o.options, o); } pub fn toJS(this: @This()) JSC.JSValue { @@ -1768,8 +1768,8 @@ pub const E = struct { pub var empty = BigInt{ .value = "" }; - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(self.value, opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(self.value, o.options, o); } pub fn toJS(_: @This()) JSC.JSValue { @@ -2400,7 +2400,7 @@ pub const E = struct { } } - pub fn jsonStringify(s: *const String, options: anytype, writer: anytype) !void { + pub fn jsonStringify(s: *const String, writer: anytype) !void { var buf = [_]u8{0} ** 4096; var i: usize = 0; for (s.slice16()) |char| { @@ -2411,7 +2411,7 @@ pub const E = struct { } } - return try std.json.stringify(buf[0..i], options, writer); + return try std.json.stringify(buf[0..i], writer.options, writer); } }; @@ -2579,8 +2579,8 @@ pub const E = struct { return ""; } - pub fn jsonStringify(self: *const RegExp, opts: anytype, o: anytype) !void { - return try std.json.stringify(self.value, opts, o); + pub fn jsonStringify(self: *const RegExp, o: anytype) !void { + return try std.json.stringify(self.value, o.options, o); } }; @@ -2657,8 +2657,8 @@ pub const Stmt = struct { loc: logger.Loc, }; - pub fn jsonStringify(self: *const Stmt, options: anytype, writer: anytype) !void { - return try std.json.stringify(Serializable{ .type = std.meta.activeTag(self.data), .object = "stmt", .value = self.data, .loc = self.loc }, options, writer); + pub fn jsonStringify(self: *const Stmt, writer: anytype) !void { + return try std.json.stringify(Serializable{ .type = std.meta.activeTag(self.data), .object = "stmt", .value = self.data, .loc = self.loc }, writer.options, writer); } pub fn isTypeScript(self: *Stmt) bool { @@ -2875,8 +2875,8 @@ pub const Stmt = struct { s_while, s_with, - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } pub fn isExportLike(tag: Tag) bool { @@ -3366,8 +3366,8 @@ pub const Expr = struct { } } - pub fn jsonStringify(self: *const @This(), options: anytype, writer: anytype) !void { - return try std.json.stringify(Serializable{ .type = std.meta.activeTag(self.data), .object = "expr", .value = self.data, .loc = self.loc }, options, writer); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try std.json.stringify(Serializable{ .type = std.meta.activeTag(self.data), .object = "expr", .value = self.data, .loc = self.loc }, writer.options, writer); } pub fn extractNumericValues(left: Expr.Data, right: Expr.Data) ?[2]f64 { @@ -4257,8 +4257,8 @@ pub const Expr = struct { }; } - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } pub fn isArray(self: Tag) bool { @@ -5597,8 +5597,8 @@ pub const S = struct { k_var, k_let, k_const, - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; }; @@ -5733,8 +5733,8 @@ pub const Op = struct { /// Right-associative bin_logical_and_assign, - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } pub fn unaryAssignTarget(code: Op.Code) AssignTarget { @@ -5834,8 +5834,8 @@ pub const Op = struct { }; } - pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(self.text, opts, o); + pub fn jsonStringify(self: *const @This(), o: anytype) !void { + return try std.json.stringify(self.text, o.options, o); } pub const TableType: std.EnumArray(Op.Code, Op) = undefined; @@ -6265,8 +6265,8 @@ pub const ExportsKind = enum { return dynamic.contains(self); } - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } pub fn isESMWithDynamicFallback(self: ExportsKind) bool { @@ -6440,8 +6440,8 @@ pub const Part = struct { }; pub const SymbolUseMap = std.ArrayHashMapUnmanaged(Ref, Symbol.Use, RefHashCtx, false); - pub fn jsonStringify(self: *const Part, options: std.json.StringifyOptions, writer: anytype) !void { - return std.json.stringify(self.stmts, options, writer); + pub fn jsonStringify(self: *const Part, writer: anytype) !void { + return std.json.stringify(self.stmts, writer.options, writer); } }; @@ -6487,8 +6487,8 @@ pub const StrictModeKind = enum(u4) { implicit_strict_mode_export, implicit_strict_mode_top_level_await, implicit_strict_mode_class, - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; @@ -6675,8 +6675,8 @@ pub const Scope = struct { function_body, class_static_init, - pub fn jsonStringify(self: @This(), opts: anytype, o: anytype) !void { - return try std.json.stringify(@tagName(self), opts, o); + pub fn jsonStringify(self: @This(), o: anytype) !void { + return try std.json.stringify(@tagName(self), o.options, o); } }; diff --git a/src/logger.zig b/src/logger.zig index 21a58243cc83d6..d03ec7dffc28e9 100644 --- a/src/logger.zig +++ b/src/logger.zig @@ -84,8 +84,8 @@ pub const Loc = struct { return loc.start == other.start; } - pub fn jsonStringify(self: *const Loc, options: anytype, writer: anytype) !void { - return try std.json.stringify(self.start, options, writer); + pub fn jsonStringify(self: *const Loc, writer: anytype) !void { + return try std.json.stringify(self.start, writer.options, writer); } }; @@ -616,8 +616,8 @@ pub const Range = struct { return std.math.lossyCast(usize, self.loc.start + self.len); } - pub fn jsonStringify(self: *const Range, options: anytype, writer: anytype) !void { - return try std.json.stringify([2]i32{ self.loc.start, self.len + self.loc.start }, options, writer); + pub fn jsonStringify(self: *const Range, writer: anytype) !void { + return try std.json.stringify([2]i32{ self.loc.start, self.len + self.loc.start }, writer.options, writer); } }; diff --git a/src/sync.zig b/src/sync.zig index d2ecd95bd38b48..ec9105cf3d76a8 100644 --- a/src/sync.zig +++ b/src/sync.zig @@ -69,7 +69,7 @@ pub const ThreadPool = struct { const allocator = self.allocator; const closure = try allocator.create(Closure); - errdefer allocator.free(closure); + errdefer allocator.destroy(closure); closure.* = Closure{ .func_args = args, .allocator = allocator, From fbe5182a8cc3b7a05a5606dfb6ad65066b75cb9e Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Mon, 21 Aug 2023 14:15:46 +0000 Subject: [PATCH 03/15] more change --- src/bun.js/javascript.zig | 2 +- src/env_loader.zig | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index 52250ab7af132f..9a05595c4580f6 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -2552,7 +2552,7 @@ pub const VirtualMachine = struct { } else if (kind.isObject() or kind.isArray()) { var bun_str = bun.String.empty; defer bun_str.deref(); - value.jsonStringify(this.global, &bun_str); //2 + value.jsonStringify(this.global, 2, &bun_str); //2 try writer.print(comptime Output.prettyFmt(" {s}: {any}\n", allow_ansi_color), .{ field, bun_str }); add_extra_line = true; } diff --git a/src/env_loader.zig b/src/env_loader.zig index 3b584b211a14d1..8dd605b3581e7e 100644 --- a/src/env_loader.zig +++ b/src/env_loader.zig @@ -872,22 +872,22 @@ pub const Map = struct { pub fn jsonStringify(self: *const @This(), writer: anytype) !void { var iterator = self.map.iterator(); - _ = try writer.writeAll("{"); + _ = try writer.write("{"); while (iterator.next()) |entry| { - _ = try writer.writeAll("\n "); + _ = try writer.write("\n "); std.json.stringify(entry.key_ptr.*, writer.options, writer) catch unreachable; - _ = try writer.writeAll(": "); + _ = try writer.write(": "); std.json.stringify(entry.value_ptr.*, writer.options, writer) catch unreachable; if (iterator.index <= self.map.count() - 1) { - _ = try writer.writeAll(", "); + _ = try writer.write(", "); } } - try writer.writeAll("\n}"); + try writer.write("\n}"); } pub inline fn get( From 7de2890244bc859fbfeb041b77f1e0522bf76e64 Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Tue, 22 Aug 2023 01:12:19 +0000 Subject: [PATCH 04/15] json related error sovled --- src/output.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/output.zig b/src/output.zig index 4feab61893b9e7..21e820e6b0202d 100644 --- a/src/output.zig +++ b/src/output.zig @@ -9,6 +9,8 @@ const StringTypes = @import("root").bun.StringTypes; const Global = @import("root").bun.Global; const ComptimeStringMap = @import("root").bun.ComptimeStringMap; const use_mimalloc = @import("root").bun.use_mimalloc; +const writeStream = std.json.writeStream; +const WriteStream = std.json.WriteStream; const SystemTimer = @import("./system_timer.zig").Timer; @@ -213,7 +215,7 @@ pub fn panic(comptime fmt: string, args: anytype) noreturn { } } -pub const WriterType: type = @TypeOf(Source.StreamType.writer(undefined)); +pub const WriterType: type = @TypeOf(WriteStream(Source.StreamType, undefined)); pub fn errorWriter() WriterType { std.debug.assert(source_set); @@ -227,7 +229,7 @@ pub fn errorStream() Source.StreamType { pub fn writer() WriterType { std.debug.assert(source_set); - return source.stream.writer(); + return writeStream(source.stream, .{ .whitespace = .indent_2 }); } pub fn resetTerminal() void { From 3be5af9ff2f8185266ed7ba45f9248e72f79b079 Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Tue, 22 Aug 2023 07:36:07 +0000 Subject: [PATCH 05/15] number related issue solved --- src/bun.js/test/expect.zig | 4 ++-- src/js_ast.zig | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bun.js/test/expect.zig b/src/bun.js/test/expect.zig index de3f185d5c500f..0d3ff663e88e9e 100644 --- a/src/bun.js/test/expect.zig +++ b/src/bun.js/test/expect.zig @@ -1131,12 +1131,12 @@ pub const Expect = struct { if (value.isAnyInt()) { const _value = value.toInt64(); pass = @mod(_value, 2) == 0; - if (_value == -0) { // negative zero is even + if (_value == -0.0) { // negative zero is even pass = true; } } else if (value.isBigInt() or value.isBigInt32()) { const _value = value.toInt64(); - pass = switch (_value == -0) { // negative zero is even + pass = switch (_value == -0.0) { // negative zero is even true => true, else => _value & 1 == 0, }; diff --git a/src/js_ast.zig b/src/js_ast.zig index 6c64a7e14b8e3b..c490569b3100ed 100644 --- a/src/js_ast.zig +++ b/src/js_ast.zig @@ -5111,7 +5111,7 @@ pub const Expr = struct { pub fn toNumber(data: Expr.Data) ?f64 { return switch (data) { .e_null => 0, - .e_undefined => std.math.nan_f64, + .e_undefined => std.math.nan(f64), .e_boolean => @as(f64, if (data.e_boolean.value) 1.0 else 0.0), .e_number => data.e_number.value, else => null, From 550c697e3057a5e47fb730b8e7264a04b1c8628b Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Tue, 22 Aug 2023 07:36:32 +0000 Subject: [PATCH 06/15] revert WriterType changed before --- src/output.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/output.zig b/src/output.zig index 21e820e6b0202d..2b3f8cca527933 100644 --- a/src/output.zig +++ b/src/output.zig @@ -215,7 +215,7 @@ pub fn panic(comptime fmt: string, args: anytype) noreturn { } } -pub const WriterType: type = @TypeOf(WriteStream(Source.StreamType, undefined)); +pub const WriterType: type = @TypeOf(Source.StreamType.writer(undefined)); pub fn errorWriter() WriterType { std.debug.assert(source_set); @@ -229,7 +229,7 @@ pub fn errorStream() Source.StreamType { pub fn writer() WriterType { std.debug.assert(source_set); - return writeStream(source.stream, .{ .whitespace = .indent_2 }); + return source.stream.writer(); } pub fn resetTerminal() void { From f76919e80d693dfebc2d1725fdec57001a3faaea Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Tue, 22 Aug 2023 07:37:12 +0000 Subject: [PATCH 07/15] destroy -> free --- src/bun.js/api/JSBundler.zig | 6 +++--- src/bun.js/api/bun/socket.zig | 6 +++--- src/bun.js/api/server.zig | 2 +- src/bun.js/node/path_watcher.zig | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/bun.js/api/JSBundler.zig b/src/bun.js/api/JSBundler.zig index af1a55ce6fdb71..f5c3793ed40052 100644 --- a/src/bun.js/api/JSBundler.zig +++ b/src/bun.js/api/JSBundler.zig @@ -594,8 +594,8 @@ pub const JSBundler = struct { external: bool = false, pub fn deinit(this: *@This()) void { - bun.default_allocator.destroy(this.path); - bun.default_allocator.destroy(this.namespace); + bun.default_allocator.free(this.path); + bun.default_allocator.free(this.namespace); } }, no_match: void, @@ -747,7 +747,7 @@ pub const JSBundler = struct { pub fn deinit(this: *Value) void { switch (this.*) { .success => |success| { - bun.default_allocator.destroy(success.source_code); + bun.default_allocator.free(success.source_code); }, .err => |*err| { err.deinit(bun.default_allocator); diff --git a/src/bun.js/api/bun/socket.zig b/src/bun.js/api/bun/socket.zig index 7d802587237872..24da32246db10b 100644 --- a/src/bun.js/api/bun/socket.zig +++ b/src/bun.js/api/bun/socket.zig @@ -497,10 +497,10 @@ pub const Listener = struct { pub fn deinit(this: UnixOrHost) void { switch (this) { .unix => |u| { - bun.default_allocator.destroy(@as([*]u8, @ptrFromInt(@intFromPtr(u.ptr)))); + bun.default_allocator.free(@as([*]u8, @ptrFromInt(@intFromPtr(u.ptr)))); }, .host => |h| { - bun.default_allocator.destroy(@as([*]u8, @ptrFromInt(@intFromPtr(h.host.ptr)))); + bun.default_allocator.free(@as([*]u8, @ptrFromInt(@intFromPtr(h.host.ptr)))); }, } } @@ -831,7 +831,7 @@ pub const Listener = struct { this.connection.deinit(); if (this.protos) |protos| { this.protos = null; - bun.default_allocator.destroy(protos); + bun.default_allocator.free(protos); } bun.default_allocator.destroy(this); } diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index 45c82b9fa246c3..c4bc05ac48471a 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -5077,7 +5077,7 @@ pub fn NewServer(comptime NamespaceType: type, comptime ssl_enabled_: bool, comp this.cached_protocol.deref(); if (this.config.hostname) |host| { - bun.default_allocator.destroy(host); + bun.default_allocator.free(host); } if (this.config.base_url.href.len > 0) { diff --git a/src/bun.js/node/path_watcher.zig b/src/bun.js/node/path_watcher.zig index 1d81661e9bd87f..1f1b9d1a12fd39 100644 --- a/src/bun.js/node/path_watcher.zig +++ b/src/bun.js/node/path_watcher.zig @@ -85,7 +85,7 @@ pub const PathWatcherManager = struct { return info.*; } const cloned_path = try bun.default_allocator.dupeZ(u8, path); - errdefer bun.default_allocator.destroy(cloned_path); + errdefer bun.default_allocator.free(cloned_path); if (std.fs.openIterableDirAbsoluteZ(cloned_path, .{ .access_sub_paths = true, @@ -657,7 +657,7 @@ pub const PathWatcherManager = struct { while (it.next()) |*entry| { const path = entry.value_ptr.*; std.os.close(path.fd); - bun.default_allocator.destroy(path.path); + bun.default_allocator.free(path.path); } this.file_paths.deinit(); From 4a9251e944c6fc66f3807ae1afdebd5464a4718f Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Tue, 22 Aug 2023 08:13:37 +0000 Subject: [PATCH 08/15] jsonStringify related issues solved --- src/analytics/analytics_schema.zig | 12 ++--- src/api/schema.zig | 76 +++++++++++++-------------- src/ast/base.zig | 2 +- src/env_loader.zig | 4 +- src/fs.zig | 2 +- src/import_record.zig | 2 +- src/js_ast.zig | 82 +++++++++++++++--------------- src/logger.zig | 4 +- 8 files changed, 92 insertions(+), 92 deletions(-) diff --git a/src/analytics/analytics_schema.zig b/src/analytics/analytics_schema.zig index 9f1cbd675e7e6d..3a22ed2b32a7ef 100644 --- a/src/analytics/analytics_schema.zig +++ b/src/analytics/analytics_schema.zig @@ -346,8 +346,8 @@ pub const analytics = struct { _, - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -361,8 +361,8 @@ pub const analytics = struct { _, - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -411,8 +411,8 @@ pub const analytics = struct { _, - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; diff --git a/src/api/schema.zig b/src/api/schema.zig index efe9d2f9f02ae2..feecf7657024ed 100644 --- a/src/api/schema.zig +++ b/src/api/schema.zig @@ -373,8 +373,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -391,8 +391,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -418,8 +418,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -648,8 +648,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -799,8 +799,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -820,8 +820,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -838,8 +838,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -856,8 +856,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -1124,8 +1124,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -1139,8 +1139,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -1246,8 +1246,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -1953,8 +1953,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -2180,8 +2180,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -2195,8 +2195,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -2266,8 +2266,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -2473,8 +2473,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -2506,8 +2506,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -2524,8 +2524,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -3142,8 +3142,8 @@ pub const Api = struct { _, - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; diff --git a/src/ast/base.zig b/src/ast/base.zig index d53aa12579f2ce..fb70e4565f16e6 100644 --- a/src/ast/base.zig +++ b/src/ast/base.zig @@ -286,7 +286,7 @@ pub const Ref = packed struct(u64) { } pub fn jsonStringify(self: *const Ref, writer: anytype) !void { - return try std.json.stringify([2]u32{ self.sourceIndex(), self.innerIndex() }, writer.options, writer); + return try writer.write([2]u32{ self.sourceIndex(), self.innerIndex() }); } }; diff --git a/src/env_loader.zig b/src/env_loader.zig index 8dd605b3581e7e..0da98579395929 100644 --- a/src/env_loader.zig +++ b/src/env_loader.zig @@ -876,11 +876,11 @@ pub const Map = struct { while (iterator.next()) |entry| { _ = try writer.write("\n "); - std.json.stringify(entry.key_ptr.*, writer.options, writer) catch unreachable; + writer.write(entry.key_ptr.*) catch unreachable; _ = try writer.write(": "); - std.json.stringify(entry.value_ptr.*, writer.options, writer) catch unreachable; + writer.write(entry.value_ptr.*) catch unreachable; if (iterator.index <= self.map.count() - 1) { _ = try writer.write(", "); diff --git a/src/fs.zig b/src/fs.zig index b0dd4e6668704e..3c35d068bf54df 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -1579,7 +1579,7 @@ pub const Path = struct { } pub fn jsonStringify(self: *const @This(), writer: anytype) !void { - return try std.json.stringify(self.text, writer.options, writer); + return try writer.write(self.text); } pub fn generateKey(p: *Path, allocator: std.mem.Allocator) !string { diff --git a/src/import_record.zig b/src/import_record.zig index 16bf00131c8bfc..3044c9b47e2d9c 100644 --- a/src/import_record.zig +++ b/src/import_record.zig @@ -63,7 +63,7 @@ pub const ImportKind = enum(u8) { } pub fn jsonStringify(self: @This(), writer: anytype) !void { - return try std.json.stringify(@tagName(self), writer.options, writer); + return try writer.write(@tagName(self)); } pub fn isFromCSS(k: ImportKind) bool { diff --git a/src/js_ast.zig b/src/js_ast.zig index c490569b3100ed..5da65340accead 100644 --- a/src/js_ast.zig +++ b/src/js_ast.zig @@ -262,8 +262,8 @@ pub const ImportItemStatus = enum(u2) { // The printer will replace this import with "undefined" missing, - pub fn jsonStringify(self: @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -271,8 +271,8 @@ pub const AssignTarget = enum(u2) { none = 0, replace = 1, // "a = b" update = 2, // "a += b" - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -349,7 +349,7 @@ pub const Binding = struct { }; pub fn jsonStringify(self: *const @This(), writer: anytype) !void { - return try std.json.stringify(Serializable{ .type = std.meta.activeTag(self.data), .object = "binding", .value = self.data, .loc = self.loc }, writer.options, writer); + return try writer.write(Serializable{ .type = std.meta.activeTag(self.data), .object = "binding", .value = self.data, .loc = self.loc }); } pub fn ToExpr(comptime expr_type: type, comptime func_type: anytype) type { @@ -437,8 +437,8 @@ pub const Binding = struct { b_object, b_missing, - pub fn jsonStringify(self: @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -844,8 +844,8 @@ pub const G = struct { declare, class_static_block, - pub fn jsonStringify(self: @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; }; @@ -1152,8 +1152,8 @@ pub const Symbol = struct { // This annotates all other symbols that don't have special behavior. other, - pub fn jsonStringify(self: @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } pub inline fn isPrivate(kind: Symbol.Kind) bool { @@ -1371,8 +1371,8 @@ pub const OptionalChain = enum(u2) { // "(a?.b).c" => ".c" is OptionalChain null ccontinue, - pub fn jsonStringify(self: @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -1683,8 +1683,8 @@ pub const E = struct { }; pub const Missing = struct { - pub fn jsonStringify(_: *const @This(), o: anytype) !void { - return try std.json.stringify(null, o.options, o); + pub fn jsonStringify(_: *const @This(), writer: anytype) !void { + return try writer.write(null); } }; @@ -1754,8 +1754,8 @@ pub const E = struct { return @as(T, @intFromFloat(@min(@max(@trunc(self.value), 0), comptime @min(std.math.floatMax(f64), std.math.maxInt(T))))); } - pub fn jsonStringify(self: *const Number, o: anytype) !void { - return try std.json.stringify(self.value, o.options, o); + pub fn jsonStringify(self: *const Number, writer: anytype) !void { + return try writer.write(self.value); } pub fn toJS(this: @This()) JSC.JSValue { @@ -1768,8 +1768,8 @@ pub const E = struct { pub var empty = BigInt{ .value = "" }; - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(self.value, o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(self.value); } pub fn toJS(_: @This()) JSC.JSValue { @@ -2411,7 +2411,7 @@ pub const E = struct { } } - return try std.json.stringify(buf[0..i], writer.options, writer); + return try writer.write(buf[0..i]); } }; @@ -2579,8 +2579,8 @@ pub const E = struct { return ""; } - pub fn jsonStringify(self: *const RegExp, o: anytype) !void { - return try std.json.stringify(self.value, o.options, o); + pub fn jsonStringify(self: *const RegExp, writer: anytype) !void { + return try writer.write(self.value); } }; @@ -2658,7 +2658,7 @@ pub const Stmt = struct { }; pub fn jsonStringify(self: *const Stmt, writer: anytype) !void { - return try std.json.stringify(Serializable{ .type = std.meta.activeTag(self.data), .object = "stmt", .value = self.data, .loc = self.loc }, writer.options, writer); + return try writer.write(Serializable{ .type = std.meta.activeTag(self.data), .object = "stmt", .value = self.data, .loc = self.loc }); } pub fn isTypeScript(self: *Stmt) bool { @@ -2875,8 +2875,8 @@ pub const Stmt = struct { s_while, s_with, - pub fn jsonStringify(self: @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } pub fn isExportLike(tag: Tag) bool { @@ -3367,7 +3367,7 @@ pub const Expr = struct { } pub fn jsonStringify(self: *const @This(), writer: anytype) !void { - return try std.json.stringify(Serializable{ .type = std.meta.activeTag(self.data), .object = "expr", .value = self.data, .loc = self.loc }, writer.options, writer); + return try writer.write(Serializable{ .type = std.meta.activeTag(self.data), .object = "expr", .value = self.data, .loc = self.loc }); } pub fn extractNumericValues(left: Expr.Data, right: Expr.Data) ?[2]f64 { @@ -4257,8 +4257,8 @@ pub const Expr = struct { }; } - pub fn jsonStringify(self: @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } pub fn isArray(self: Tag) bool { @@ -5597,8 +5597,8 @@ pub const S = struct { k_var, k_let, k_const, - pub fn jsonStringify(self: @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; }; @@ -5733,8 +5733,8 @@ pub const Op = struct { /// Right-associative bin_logical_and_assign, - pub fn jsonStringify(self: @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } pub fn unaryAssignTarget(code: Op.Code) AssignTarget { @@ -5834,8 +5834,8 @@ pub const Op = struct { }; } - pub fn jsonStringify(self: *const @This(), o: anytype) !void { - return try std.json.stringify(self.text, o.options, o); + pub fn jsonStringify(self: *const @This(), writer: anytype) !void { + return try writer.write(self.text); } pub const TableType: std.EnumArray(Op.Code, Op) = undefined; @@ -6265,8 +6265,8 @@ pub const ExportsKind = enum { return dynamic.contains(self); } - pub fn jsonStringify(self: @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } pub fn isESMWithDynamicFallback(self: ExportsKind) bool { @@ -6441,7 +6441,7 @@ pub const Part = struct { pub const SymbolUseMap = std.ArrayHashMapUnmanaged(Ref, Symbol.Use, RefHashCtx, false); pub fn jsonStringify(self: *const Part, writer: anytype) !void { - return std.json.stringify(self.stmts, writer.options, writer); + return writer.write(self.stmts); } }; @@ -6487,8 +6487,8 @@ pub const StrictModeKind = enum(u4) { implicit_strict_mode_export, implicit_strict_mode_top_level_await, implicit_strict_mode_class, - pub fn jsonStringify(self: @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; @@ -6675,8 +6675,8 @@ pub const Scope = struct { function_body, class_static_init, - pub fn jsonStringify(self: @This(), o: anytype) !void { - return try std.json.stringify(@tagName(self), o.options, o); + pub fn jsonStringify(self: @This(), writer: anytype) !void { + return try writer.write(@tagName(self)); } }; diff --git a/src/logger.zig b/src/logger.zig index d03ec7dffc28e9..9ec2dc7ca7fa93 100644 --- a/src/logger.zig +++ b/src/logger.zig @@ -85,7 +85,7 @@ pub const Loc = struct { } pub fn jsonStringify(self: *const Loc, writer: anytype) !void { - return try std.json.stringify(self.start, writer.options, writer); + return try writer.write(self.start); } }; @@ -617,7 +617,7 @@ pub const Range = struct { } pub fn jsonStringify(self: *const Range, writer: anytype) !void { - return try std.json.stringify([2]i32{ self.loc.start, self.len + self.loc.start }, writer.options, writer); + return try writer.write([2]i32{ self.loc.start, self.len + self.loc.start }); } }; From 9ac48ac94ac0aa0f6b45c3f279e2538979ac8186 Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Tue, 22 Aug 2023 09:14:33 +0000 Subject: [PATCH 09/15] fix mem.free expected []T or *[_]T, passed [*]const u8 --- src/bun.js/api/bun/socket.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bun.js/api/bun/socket.zig b/src/bun.js/api/bun/socket.zig index 24da32246db10b..cf4a4562a8b663 100644 --- a/src/bun.js/api/bun/socket.zig +++ b/src/bun.js/api/bun/socket.zig @@ -497,10 +497,10 @@ pub const Listener = struct { pub fn deinit(this: UnixOrHost) void { switch (this) { .unix => |u| { - bun.default_allocator.free(@as([*]u8, @ptrFromInt(@intFromPtr(u.ptr)))); + bun.default_allocator.free(u); }, .host => |h| { - bun.default_allocator.free(@as([*]u8, @ptrFromInt(@intFromPtr(h.host.ptr)))); + bun.default_allocator.free(h.host); }, } } From 25b14b76ce1a3c72075a1bd40128f3802885c902 Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Tue, 22 Aug 2023 10:52:12 +0000 Subject: [PATCH 10/15] fix expected []T or *[_]T, passed [*:0]const u8 --- src/bun.js/api/server.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index c4bc05ac48471a..847d75f25dc145 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -5077,7 +5077,7 @@ pub fn NewServer(comptime NamespaceType: type, comptime ssl_enabled_: bool, comp this.cached_protocol.deref(); if (this.config.hostname) |host| { - bun.default_allocator.free(host); + bun.default_allocator.free(host[0 .. std.mem.len(host) + 1]); } if (this.config.base_url.href.len > 0) { From e8e628f0798b253ebfe0cb9d8e9abc405a781acd Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Tue, 22 Aug 2023 15:04:26 +0000 Subject: [PATCH 11/15] fix build script --- build.zig | 93 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 58 insertions(+), 35 deletions(-) diff --git a/build.zig b/build.zig index f477834ce1d6ca..18053d7fdd87ed 100644 --- a/build.zig +++ b/build.zig @@ -186,12 +186,12 @@ pub fn build(b: *Build) !void { else "root.zig"; - const min_version: std.SemanticVersion = if (target.getOsTag() != .freestanding and !target.isWindows()) + const min_version: std.SemanticVersion = if (target.getOsTag() != .freestanding) target.getOsVersionMin().semver else .{ .major = 0, .minor = 0, .patch = 0 }; - const max_version: std.SemanticVersion = if (target.getOsTag() != .freestanding and !target.isWindows()) + const max_version: std.SemanticVersion = if (target.getOsTag() != .freestanding) target.getOsVersionMax().semver else .{ .major = 0, .minor = 0, .patch = 0 }; @@ -271,11 +271,13 @@ pub fn build(b: *Build) !void { defer obj_step.dependOn(&obj.step); - // = .{ - // .generated_path = .{ - // .path = b.fmt("{s}/{s}.o", .{ output_dir, bun_executable_name }), - // }, - // }; + var install = b.addInstallFileWithDir( + obj.getEmittedBin(), + .{.custom = output_dir}, + b.fmt("{s}.o", .{bun_executable_name}), + ); + install.step.dependOn(&obj.step); + defer obj_step.dependOn(&install.step); var actual_build_options = default_build_options; if (b.option(bool, "generate-sizes", "Generate sizes of things") orelse false) { @@ -292,9 +294,10 @@ pub fn build(b: *Build) !void { // Disable stack probing on x86 so we don't need to include compiler_rt if (target.getCpuArch().isX86()) obj.disable_stack_probing = true; - // if (b.option(bool, "for-editor", "Do not emit bin, just check for errors") orelse false) { - // obj.emit_bin = .no_emit; - // } + if (b.option(bool, "for-editor", "Do not emit bin, just check for errors") orelse false) { + // obj.emit_bin = .no_emit; + obj.generated_bin = null; + } if (target.getOsTag() == .linux) { // obj.want_lto = tar; @@ -311,9 +314,10 @@ pub fn build(b: *Build) !void { .root_source_file = FileSource.relative("src/bindgen.zig"), .target = target, .optimize = optimize, + .main_pkg_path = obj.main_pkg_path, }); defer headers_step.dependOn(&headers_obj.step); - try configureObjectStep(b, headers_obj, @TypeOf(target), target, obj.main_pkg_path); + try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target); var headers_build_options = default_build_options; headers_build_options.bindgen = true; headers_obj.addOptions("build_options", default_build_options.step(b)); @@ -321,21 +325,22 @@ pub fn build(b: *Build) !void { } { - const wasm = b.step("bun-wasm", "Build WASM"); - var wasm_step = b.addStaticLibrary(.{ + const wasm_step = b.step("bun-wasm", "Build WASM"); + var wasm = b.addStaticLibrary(.{ .name = "bun-wasm", .root_source_file = FileSource.relative("root_wasm.zig"), .target = target, .optimize = optimize, + .main_pkg_path = obj.main_pkg_path, }); - defer wasm.dependOn(&wasm_step.step); - wasm_step.strip = false; + defer wasm_step.dependOn(&wasm.step); + wasm.strip = false; // wasm_step.link_function_sections = true; // wasm_step.link_emit_relocs = true; // wasm_step.single_threaded = true; - try configureObjectStep(b, wasm_step, @TypeOf(target), target, obj.main_pkg_path.?); + try configureObjectStep(b, wasm, wasm_step, @TypeOf(target), target); var build_opts = default_build_options; - wasm_step.addOptions("build_options", build_opts.step(b)); + wasm.addOptions("build_options", build_opts.step(b)); } { @@ -345,9 +350,10 @@ pub fn build(b: *Build) !void { .root_source_file = FileSource.relative("misctools/http_bench.zig"), .target = target, .optimize = optimize, + .main_pkg_path = obj.main_pkg_path, }); defer headers_step.dependOn(&headers_obj.step); - try configureObjectStep(b, headers_obj, @TypeOf(target), target, obj.main_pkg_path.?); + try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target); headers_obj.addOptions("build_options", default_build_options.step(b)); } @@ -358,9 +364,10 @@ pub fn build(b: *Build) !void { .root_source_file = FileSource.relative("misctools/machbench.zig"), .target = target, .optimize = optimize, + .main_pkg_path = obj.main_pkg_path, }); defer headers_step.dependOn(&headers_obj.step); - try configureObjectStep(b, headers_obj, @TypeOf(target), target, obj.main_pkg_path.?); + try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target); headers_obj.addOptions("build_options", default_build_options.step(b)); } @@ -371,9 +378,10 @@ pub fn build(b: *Build) !void { .root_source_file = FileSource.relative("misctools/fetch.zig"), .target = target, .optimize = optimize, + .main_pkg_path = obj.main_pkg_path, }); defer headers_step.dependOn(&headers_obj.step); - try configureObjectStep(b, headers_obj, @TypeOf(target), target, obj.main_pkg_path.?); + try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target); headers_obj.addOptions("build_options", default_build_options.step(b)); } @@ -384,9 +392,10 @@ pub fn build(b: *Build) !void { .root_source_file = FileSource.relative("src/bench/string-handling.zig"), .target = target, .optimize = optimize, + .main_pkg_path = obj.main_pkg_path, }); defer headers_step.dependOn(&headers_obj.step); - try configureObjectStep(b, headers_obj, @TypeOf(target), target, obj.main_pkg_path.?); + try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target); headers_obj.addOptions("build_options", default_build_options.step(b)); } @@ -397,9 +406,10 @@ pub fn build(b: *Build) !void { .root_source_file = FileSource.relative("src/sha.zig"), .target = target, .optimize = optimize, + .main_pkg_path = obj.main_pkg_path, }); defer headers_step.dependOn(&headers_obj.step); - try configureObjectStep(b, headers_obj, @TypeOf(target), target, obj.main_pkg_path.?); + try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target); headers_obj.addOptions("build_options", default_build_options.step(b)); } @@ -410,9 +420,10 @@ pub fn build(b: *Build) !void { .root_source_file = FileSource.relative("src/sourcemap/vlq_bench.zig"), .target = target, .optimize = optimize, + .main_pkg_path = obj.main_pkg_path, }); defer headers_step.dependOn(&headers_obj.step); - try configureObjectStep(b, headers_obj, @TypeOf(target), target, obj.main_pkg_path.?); + try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target); headers_obj.addOptions("build_options", default_build_options.step(b)); } @@ -423,9 +434,10 @@ pub fn build(b: *Build) !void { .root_source_file = FileSource.relative("misctools/tgz.zig"), .target = target, .optimize = optimize, + .main_pkg_path = obj.main_pkg_path, }); defer headers_step.dependOn(&headers_obj.step); - try configureObjectStep(b, headers_obj, @TypeOf(target), target, obj.main_pkg_path.?); + try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target); headers_obj.addOptions("build_options", default_build_options.step(b)); } @@ -439,16 +451,24 @@ pub fn build(b: *Build) !void { var headers_obj: *CompileStep = b.addTest(.{ .root_source_file = FileSource.relative(test_file orelse "src/main.zig"), .target = target, + .main_pkg_path = obj.main_pkg_path, }); headers_obj.filter = test_filter; if (test_bin_) |test_bin| { headers_obj.name = std.fs.path.basename(test_bin); - // if (std.fs.path.dirname(test_bin)) |dir| headers_obj.emit_bin = .{ - // .emit_to = b.fmt("{s}/{s}", .{ dir, headers_obj.name }), - // }; + if (std.fs.path.dirname(test_bin)) |dir| { + var install = b.addInstallFileWithDir( + headers_obj.getEmittedBin(), + .{.custom = dir}, + headers_obj.name, + ); + install.step.dependOn(&headers_obj.step); + headers_step.dependOn(&install.step); + } + } - try configureObjectStep(b, headers_obj, @TypeOf(target), target, obj.main_pkg_path.?); + try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target); headers_step.dependOn(&headers_obj.step); headers_obj.addOptions("build_options", default_build_options.step(b)); @@ -459,9 +479,7 @@ pub fn build(b: *Build) !void { pub var original_make_fn: ?*const fn (step: *std.build.Step) anyerror!void = null; -pub fn configureObjectStep(b: *std.build.Builder, obj: *CompileStep, comptime Target: type, target: Target, main_pkg_path: ?Build.LazyPath) !void { - obj.main_pkg_path = main_pkg_path; - +pub fn configureObjectStep(b: *std.build.Builder, obj: *CompileStep, obj_step: *std.build.Step, comptime Target: type, target: Target) !void { // obj.setTarget(target); try addInternalPackages(b, obj, std.heap.page_allocator, b.zig_exe, target); @@ -469,11 +487,16 @@ pub fn configureObjectStep(b: *std.build.Builder, obj: *CompileStep, comptime Ta // obj.setBuildMode(optimize); obj.bundle_compiler_rt = false; - // if (obj.emit_bin == .default) - // obj.emit_bin = .{ - // .emit_to = b.fmt("{s}/{s}.o", .{ output_dir, obj.name }), - // }; + if (obj.emit_directory == null) { + var install = b.addInstallFileWithDir( + obj.getEmittedBin(), + .{.custom = output_dir}, + b.fmt("{s}.o", .{obj.name}), + ); + install.step.dependOn(&obj.step); + obj_step.dependOn(&install.step); + } if (target.getOsTag() != .freestanding) obj.linkLibC(); if (target.getOsTag() != .freestanding) obj.bundle_compiler_rt = false; From 147368d34960ac6acbd30da601710712cfb643c5 Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Wed, 23 Aug 2023 01:48:49 +0000 Subject: [PATCH 12/15] fix build script, for real --- build.zig | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/build.zig b/build.zig index 18053d7fdd87ed..58397d90b60b49 100644 --- a/build.zig +++ b/build.zig @@ -1,4 +1,5 @@ const std = @import("std"); +const pathRel = std.fs.path.relative; const Wyhash = @import("./src/wyhash.zig").Wyhash; var is_debug_build = false; fn moduleSource(comptime out: []const u8) FileSource { @@ -96,6 +97,7 @@ const BunBuildOptions = struct { } }; +// relative to the prefix var output_dir: []const u8 = ""; fn panicIfNotFound(comptime filepath: []const u8) []const u8 { var file = std.fs.cwd().openFile(filepath, .{ .optimize = .read_only }) catch |err| { @@ -172,13 +174,12 @@ pub fn build(b: *Build) !void { var triplet = triplet_buf[0 .. osname.len + cpuArchName.len + 1]; if (b.option([]const u8, "output-dir", "target to install to") orelse std.os.getenv("OUTPUT_DIR")) |output_dir_| { - output_dir = b.pathFromRoot(output_dir_); + output_dir = try pathRel(b.allocator, b.install_prefix, output_dir_); } else { const output_dir_base = try std.fmt.bufPrint(&output_dir_buf, "{s}{s}", .{ bin_label, triplet }); - output_dir = b.pathFromRoot(output_dir_base); + output_dir = try pathRel(b.allocator, b.install_prefix, output_dir_base); } - std.fs.cwd().makePath(output_dir) catch {}; is_debug_build = optimize == OptimizeMode.Debug; const bun_executable_name = if (optimize == std.builtin.OptimizeMode.Debug) "bun-debug" else "bun"; const root_src = if (target.getOsTag() == std.Target.Os.Tag.freestanding) @@ -273,11 +274,11 @@ pub fn build(b: *Build) !void { var install = b.addInstallFileWithDir( obj.getEmittedBin(), - .{.custom = output_dir}, + .{ .custom = output_dir }, b.fmt("{s}.o", .{bun_executable_name}), ); install.step.dependOn(&obj.step); - defer obj_step.dependOn(&install.step); + obj_step.dependOn(&install.step); var actual_build_options = default_build_options; if (b.option(bool, "generate-sizes", "Generate sizes of things") orelse false) { @@ -459,13 +460,12 @@ pub fn build(b: *Build) !void { if (std.fs.path.dirname(test_bin)) |dir| { var install = b.addInstallFileWithDir( headers_obj.getEmittedBin(), - .{.custom = dir}, + .{ .custom = try std.fs.path.relative(b.allocator, output_dir, dir) }, headers_obj.name, ); install.step.dependOn(&headers_obj.step); headers_step.dependOn(&install.step); } - } try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target); @@ -490,7 +490,7 @@ pub fn configureObjectStep(b: *std.build.Builder, obj: *CompileStep, obj_step: * if (obj.emit_directory == null) { var install = b.addInstallFileWithDir( obj.getEmittedBin(), - .{.custom = output_dir}, + .{ .custom = output_dir }, b.fmt("{s}.o", .{obj.name}), ); From 1779f89c12b71f027521f077a1d1ecac7be7eff8 Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Wed, 23 Aug 2023 05:22:24 +0000 Subject: [PATCH 13/15] replace 0.11.0-dev.4006+bf827d0b5 to 0.12.0-dev.161+6a5463951 --- .github/workflows/zig-fmt.yml | 2 +- Dockerfile | 2 +- docs/project/development.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/zig-fmt.yml b/.github/workflows/zig-fmt.yml index 1f1c95e364109e..d6f54cf40da744 100644 --- a/.github/workflows/zig-fmt.yml +++ b/.github/workflows/zig-fmt.yml @@ -1,7 +1,7 @@ name: zig-fmt env: - ZIG_VERSION: 0.11.0-dev.4006+bf827d0b5 + ZIG_VERSION: 0.12.0-dev.161+6a5463951 on: pull_request: diff --git a/Dockerfile b/Dockerfile index c568db5add8efd..984da02cbdfdf5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ ARG TRIPLET=${ARCH}-linux-gnu ARG BUILDARCH=amd64 ARG WEBKIT_TAG=2023-aug3-4 ARG ZIG_TAG=jul1 -ARG ZIG_VERSION="0.11.0-dev.4006+bf827d0b5" +ARG ZIG_VERSION="0.12.0-dev.161+6a5463951" ARG WEBKIT_BASENAME="bun-webkit-linux-$BUILDARCH" ARG ZIG_FOLDERNAME=zig-linux-${BUILD_MACHINE_ARCH}-${ZIG_VERSION} diff --git a/docs/project/development.md b/docs/project/development.md index c635595b348bca..ad3f0df0cfb55b 100644 --- a/docs/project/development.md +++ b/docs/project/development.md @@ -112,7 +112,7 @@ Zig can be installed either with our npm package [`@oven/zig`](https://www.npmjs ```bash $ bun install -g @oven/zig -$ zigup 0.11.0-dev.4006+bf827d0b5 +$ zigup 0.12.0-dev.161+6a5463951 ``` {% callout %} From edae96f1d468b02138b26dc1c1595ac3344925df Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Wed, 23 Aug 2023 06:32:13 +0000 Subject: [PATCH 14/15] fix build on macOS, COPYFILE.DATA -> COPYFILE_DATA --- src/bun.js/webcore/blob.zig | 2 +- src/copy_file.zig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bun.js/webcore/blob.zig b/src/bun.js/webcore/blob.zig index c794ab59b11586..c5e893a5aee85e 100644 --- a/src/bun.js/webcore/blob.zig +++ b/src/bun.js/webcore/blob.zig @@ -2361,7 +2361,7 @@ pub const Blob = struct { } pub fn doFCopyFile(this: *CopyFile) anyerror!void { - switch (JSC.Node.Syscall.fcopyfile(this.source_fd, this.destination_fd, os.system.COPYFILE.DATA)) { + switch (JSC.Node.Syscall.fcopyfile(this.source_fd, this.destination_fd, os.system.COPYFILE_DATA)) { .err => |errno| { this.system_error = errno.toSystemError(); diff --git a/src/copy_file.zig b/src/copy_file.zig index 4fbac7855ce038..cbf81e54993989 100644 --- a/src/copy_file.zig +++ b/src/copy_file.zig @@ -24,7 +24,7 @@ const CopyFileError = error{SystemResources} || CopyFileRangeError || os.SendFil // No metadata is transferred over. pub fn copyFile(fd_in: os.fd_t, fd_out: os.fd_t) CopyFileError!void { if (comptime bun.Environment.isMac) { - const rc = os.system.fcopyfile(fd_in, fd_out, null, os.system.COPYFILE.DATA); + const rc = os.system.fcopyfile(fd_in, fd_out, null, os.system.COPYFILE_DATA); switch (os.errno(rc)) { .SUCCESS => return, .INVAL => unreachable, From fce7c8979e6a3a6e022f0792ab99cb8729664105 Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Wed, 23 Aug 2023 07:13:26 +0000 Subject: [PATCH 15/15] fix the last destroy on [*]ptr issue --- src/bun.js/node/fs_events.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bun.js/node/fs_events.zig b/src/bun.js/node/fs_events.zig index 70b41fc335529d..ce158a037ac592 100644 --- a/src/bun.js/node/fs_events.zig +++ b/src/bun.js/node/fs_events.zig @@ -488,7 +488,7 @@ pub const FSEventsLoop = struct { CS.FSEventStreamScheduleWithRunLoop(ref, this.loop, CF.RunLoopDefaultMode.*); if (CS.FSEventStreamStart(ref) == 0) { //clean in case of failure - bun.default_allocator.destroy(paths); + bun.default_allocator.free(paths); CF.Release(cf_paths); CS.FSEventStreamInvalidate(ref); CS.FSEventStreamRelease(ref);