diff --git a/bench/snippets/crypto-2190.mjs b/bench/snippets/crypto-2190.mjs index 1ff6536788..6437354e5e 100644 --- a/bench/snippets/crypto-2190.mjs +++ b/bench/snippets/crypto-2190.mjs @@ -12,6 +12,9 @@ const scenarios = [ { alg: "sha1", digest: "base64" }, { alg: "sha256", digest: "hex" }, { alg: "sha256", digest: "base64" }, + { alg: "blake2b512", digest: "hex" }, + { alg: "sha512-224", digest: "hex" }, + { alg: "sha512-256", digest: "hex" }, ]; for (const { alg, digest } of scenarios) { @@ -23,6 +26,10 @@ for (const { alg, digest } of scenarios) { bench(`${alg}-${digest} (Bun.CryptoHasher)`, () => { new Bun.CryptoHasher(alg).update(data).digest(digest); }); + + bench(`${alg}-${digest} (Bun.CryptoHasher.hash)`, () => { + return Bun.CryptoHasher.hash(alg, data, digest); + }); } } diff --git a/src/bun.js/VirtualMachine.zig b/src/bun.js/VirtualMachine.zig index 1e352ff587..a859c208f2 100644 --- a/src/bun.js/VirtualMachine.zig +++ b/src/bun.js/VirtualMachine.zig @@ -1012,6 +1012,9 @@ pub fn initWithModuleGraph( .onDependencyError = ModuleLoader.AsyncModule.Queue.onDependencyError, }; + // Emitting "@__PURE__" comments at runtime is a waste of memory and time. + vm.transpiler.options.emit_dce_annotations = false; + vm.transpiler.resolver.standalone_module_graph = opts.graph.?; // Avoid reading from tsconfig.json & package.json when we're in standalone mode @@ -1125,6 +1128,9 @@ pub fn init(opts: Options) !*VirtualMachine { vm.regular_event_loop.concurrent_tasks = .{}; vm.event_loop = &vm.regular_event_loop; + // Emitting "@__PURE__" comments at runtime is a waste of memory and time. + vm.transpiler.options.emit_dce_annotations = false; + vm.transpiler.macro_context = null; vm.transpiler.resolver.store_fd = opts.store_fd; vm.transpiler.resolver.prefer_module_field = false; @@ -1278,6 +1284,9 @@ pub fn initWorker( default_allocator, ); + // Emitting "@__PURE__" comments at runtime is a waste of memory and time. + vm.transpiler.options.emit_dce_annotations = false; + vm.regular_event_loop.virtual_machine = vm; vm.regular_event_loop.tasks.ensureUnusedCapacity(64) catch unreachable; vm.regular_event_loop.concurrent_tasks = .{}; diff --git a/src/bun.js/bindings/InspectorLifecycleAgent.cpp b/src/bun.js/bindings/InspectorLifecycleAgent.cpp index ceaf52a491..5920cece94 100644 --- a/src/bun.js/bindings/InspectorLifecycleAgent.cpp +++ b/src/bun.js/bindings/InspectorLifecycleAgent.cpp @@ -158,6 +158,7 @@ Protocol::ErrorStringOr InspectorLifecycleAgent::getModuleGraph() esm->addItem(value.toWTFString(global)); RETURN_IF_EXCEPTION(scope, makeUnexpected(ErrorString("Failed to add item to esm array"_s))); } + RETURN_IF_EXCEPTION(scope, makeUnexpected(ErrorString("Failed to iterate over esm map"_s))); } Ref> cjs = JSON::ArrayOf::create(); @@ -169,6 +170,7 @@ Protocol::ErrorStringOr InspectorLifecycleAgent::getModuleGraph() cjs->addItem(value.toWTFString(global)); RETURN_IF_EXCEPTION(scope, makeUnexpected(ErrorString("Failed to add item to cjs array"_s))); } + RETURN_IF_EXCEPTION(scope, makeUnexpected(ErrorString("Failed to iterate over cjs map"_s))); } auto* process = global->processObject(); diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig index 480fd99a25..ad2c2a0b1a 100644 --- a/src/bundler/bundle_v2.zig +++ b/src/bundler/bundle_v2.zig @@ -1854,6 +1854,11 @@ pub const BundleV2 = struct { transpiler.options.banner = config.banner.slice(); transpiler.options.footer = config.footer.slice(); + if (transpiler.options.compile) { + // Emitting DCE annotations is nonsensical in --compile. + transpiler.options.emit_dce_annotations = false; + } + transpiler.configureLinker(); try transpiler.configureDefines(); diff --git a/src/js_printer.zig b/src/js_printer.zig index 0b6faa2198..a0118ea8b2 100644 --- a/src/js_printer.zig +++ b/src/js_printer.zig @@ -1828,8 +1828,9 @@ fn NewPrinter( } pub inline fn printPure(p: *Printer) void { - if (Environment.allow_assert) assert(p.options.print_dce_annotations); - p.printWhitespacer(ws("/* @__PURE__ */ ")); + if (p.options.print_dce_annotations) { + p.printWhitespacer(ws("/* @__PURE__ */ ")); + } } pub fn printStringLiteralEString(p: *Printer, str: *E.String, allow_backtick: bool) void {