mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
* Fix crash in CJS * Add std.heap.ArenaAllocator * Use our arena allocator * Reduce JS parser memory usage and make HMR faster * Write some comments * fix test failure & clean up this code * Update javascript.zig * make arena usage safer --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
46 lines
1.4 KiB
Zig
46 lines
1.4 KiB
Zig
const std = @import("std");
|
|
|
|
const panicky = @import("./panic_handler.zig");
|
|
const MainPanicHandler = panicky.NewPanicHandler(std.builtin.default_panic);
|
|
|
|
pub const io_mode = .blocking;
|
|
|
|
pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, addr: ?usize) noreturn {
|
|
MainPanicHandler.handle_panic(msg, error_return_trace, addr);
|
|
}
|
|
|
|
const CrashReporter = @import("./crash_reporter.zig");
|
|
|
|
pub fn main() void {
|
|
const bun = @import("root").bun;
|
|
const Output = bun.Output;
|
|
const Environment = bun.Environment;
|
|
|
|
if (comptime Environment.isRelease)
|
|
CrashReporter.start() catch unreachable;
|
|
|
|
bun.start_time = std.time.nanoTimestamp();
|
|
|
|
// The memory allocator makes a massive difference.
|
|
// std.heap.raw_c_allocator and default_allocator perform similarly.
|
|
// std.heap.GeneralPurposeAllocator makes this about 3x _slower_ than esbuild.
|
|
// var root_alloc = @import("root").bun.ArenaAllocator.init(std.heap.raw_c_allocator);
|
|
// var root_alloc_ = &root_alloc.allocator;
|
|
|
|
var stdout = std.io.getStdOut();
|
|
// var stdout = std.io.bufferedWriter(stdout_file.writer());
|
|
var stderr = std.io.getStdErr();
|
|
var output_source = Output.Source.init(stdout, stderr);
|
|
|
|
Output.Source.set(&output_source);
|
|
defer Output.flush();
|
|
|
|
bun.CLI.Cli.start(bun.default_allocator, stdout, stderr, MainPanicHandler);
|
|
}
|
|
|
|
test "panic" {
|
|
panic("woah", null);
|
|
}
|
|
|
|
pub const build_options = @import("build_options");
|