From 41d5e45f3e54d2e1c87b2c776588698b27fba433 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Sun, 2 Aug 2026 07:56:06 +0000 Subject: [PATCH] Remove dead code from node/crypto C++, js_parser, js_printer, bundler, sql, server Net -687 lines across 39 files. Each item verified to have zero callers/constructors via rg across src/ and build/debug/codegen/, then confirmed by bun bd + rust:check-all. Whole files stubbed (447 -> 11 LOC): sizegen.cpp, ffi-stdatomic.h, JSPrivateKeyObjectConstructor.{h,cpp}, JSPublicKeyObjectConstructor.{h,cpp} (MessagePortChannel stub pattern for the gate harness stash round-trip). C++ node bindings: keyFromPublicString, getKeyObjectHandleFromJwk forward decl, jsVerifyOneShot redundant decl, HTTPParser::lessThan, enum class UpdateResult, two unused extern C decls in JSNodeHTTPServerSocket.cpp. bundler: Linker.resolver (write-only), hashed_filenames + IS_CACHE_ENABLED (const-false guard), InputFileFlags::IS_PLUGIN_FILE, Step::ReadFile, defines::Data, BundleOptions::css_import_behavior(). js_parser: six never-constructed StrictModeFeature variants, FnOnlyDataVisit.{is_inside_async_arrow_fn,should_replace_this_with_class_name_ref, class_name_ref} (write-only; cascades to the struct's 'a lifetime and the shadow_ref arena Cell in visit_class). js_printer: Options.{css_import_behavior,transform_only}, BufferWriter.append_null_byte (never set true). sql/mysql: 28 CommandType variants, 12 StatusFlag variants, Int4 alias. runtime/server: AnyRoute::ref_, ServerWebSocket OPENED_BIT + set_opened. misc: analytics FeaturesFormatter re-export, h2/wire.rs MAX_STREAM_ID, no-iostream-include.test.ts sizegen allowlist. --- src/analytics/lib.rs | 4 +- src/bundler/Graph.rs | 1 - src/bundler/ParseTask.rs | 1 - src/bundler/ThreadPool.rs | 2 +- src/bundler/bundle_v2.rs | 3 - src/bundler/linker.rs | 44 +---- src/bundler/options.rs | 8 - src/bundler/transpiler.rs | 29 +-- src/js_parser/p.rs | 32 +-- src/js_parser/parser.rs | 28 +-- src/js_parser/visit/mod.rs | 40 ++-- src/js_parser/visit/visit_expr.rs | 9 - src/js_printer/lib.rs | 21 -- src/jsc/RuntimeTranspilerStore.rs | 16 +- src/jsc/VirtualMachine.rs | 3 +- .../bindings/node/JSNodeHTTPServerSocket.cpp | 2 - src/jsc/bindings/node/crypto/JSCipher.h | 6 - .../crypto/JSPrivateKeyObjectConstructor.cpp | 42 +--- .../crypto/JSPrivateKeyObjectConstructor.h | 49 +---- .../crypto/JSPublicKeyObjectConstructor.cpp | 42 +--- .../crypto/JSPublicKeyObjectConstructor.h | 49 +---- src/jsc/bindings/node/crypto/JSVerify.cpp | 36 ---- src/jsc/bindings/node/crypto/JSVerify.h | 3 - src/jsc/bindings/node/http/NodeHTTPParser.cpp | 13 -- src/jsc/bindings/node/http/NodeHTTPParser.h | 2 - src/jsc/headergen/sizegen.cpp | 88 +-------- src/runtime/api/JSTranspiler.rs | 4 - src/runtime/api/bun/h2/wire.rs | 3 - src/runtime/ffi/ffi-stdatomic.h | 182 +----------------- src/runtime/jsc_hooks.rs | 7 +- src/runtime/server/ServerWebSocket.rs | 14 +- src/runtime/server/mod.rs | 12 -- src/runtime/server/server_body.rs | 6 +- src/sql/mysql/MySQLTypes.rs | 4 +- src/sql/mysql/StatusFlags.rs | 25 --- src/sql/mysql/protocol/CommandType.rs | 28 --- .../dead-symbols-node-crypto-parser.test.ts | 84 ++++++++ .../source-lints/no-iostream-include.test.ts | 3 - 38 files changed, 126 insertions(+), 819 deletions(-) create mode 100644 test/internal/source-lints/dead-symbols-node-crypto-parser.test.ts diff --git a/src/analytics/lib.rs b/src/analytics/lib.rs index 109e1f86ad48..8f3d657f3192 100644 --- a/src/analytics/lib.rs +++ b/src/analytics/lib.rs @@ -309,9 +309,7 @@ pub mod features { // attached to the single definition. } -pub use features::{ - Formatter as FeaturesFormatter, PACKED_FEATURES_LIST, PackedFeatures, packed_features, -}; +pub use features::{PACKED_FEATURES_LIST, PackedFeatures, packed_features}; /// Enforced at the macro definition site; kept as a `const fn` /// for documentation / debug assertions. diff --git a/src/bundler/Graph.rs b/src/bundler/Graph.rs index 9fed61073036..c7085b7e9859 100644 --- a/src/bundler/Graph.rs +++ b/src/bundler/Graph.rs @@ -143,7 +143,6 @@ bun_collections::multi_array_columns! { bitflags::bitflags! { #[derive(Default, Clone, Copy, PartialEq, Eq)] pub struct InputFileFlags: u8 { - const IS_PLUGIN_FILE = 1 << 0; /// Set when a barrel-eligible file has `export * from` this file. const IS_EXPORT_STAR_TARGET = 1 << 1; } diff --git a/src/bundler/ParseTask.rs b/src/bundler/ParseTask.rs index e0ccd7659e32..7ea94be11609 100644 --- a/src/bundler/ParseTask.rs +++ b/src/bundler/ParseTask.rs @@ -191,7 +191,6 @@ pub(crate) struct ResultError { #[derive(Copy, Clone, Eq, PartialEq)] pub enum Step { Pending, - ReadFile, Parse, Resolve, } diff --git a/src/bundler/ThreadPool.rs b/src/bundler/ThreadPool.rs index c14f003e570a..402492d06395 100644 --- a/src/bundler/ThreadPool.rs +++ b/src/bundler/ThreadPool.rs @@ -4,7 +4,7 @@ //! //! `Worker::create` / `initialize_transpiler` build the per-worker //! `Transpiler` via `Transpiler::for_worker` (per-field deep clone — no -//! bitwise struct copy); the `linker.resolver` backref is wired by +//! bitwise struct copy); the self-referential `linker` backrefs are wired by //! `Transpiler::wire_after_move` once the value is at its final address. use core::mem::{ManuallyDrop, MaybeUninit}; diff --git a/src/bundler/bundle_v2.rs b/src/bundler/bundle_v2.rs index a33cd2c7a0d7..36acfeb6c51e 100644 --- a/src/bundler/bundle_v2.rs +++ b/src/bundler/bundle_v2.rs @@ -4351,8 +4351,6 @@ pub mod bv2_impl { this.free_list.push(code.source_code); std::borrow::Cow::Borrowed(source_code) }; - this.graph.input_files.items_flags_mut()[load.source_index.get() as usize] - .insert(crate::Graph::InputFileFlags::IS_PLUGIN_FILE); let parse_task = load.parse_task_mut(); parse_task.loader = Some(code.loader); parse_task.contents_or_fd = parse_task::ContentsOrFd::Contents(source_code); @@ -7175,7 +7173,6 @@ pub mod bv2_impl { } else { let step_name = match err.step { crate::parse_task::Step::Pending => "pending", - crate::parse_task::Step::ReadFile => "read_file", crate::parse_task::Step::Parse => "parse", crate::parse_task::Step::Resolve => "resolve", }; diff --git a/src/bundler/linker.rs b/src/bundler/linker.rs index ae95b8012f96..21f1dc253536 100644 --- a/src/bundler/linker.rs +++ b/src/bundler/linker.rs @@ -4,7 +4,6 @@ use std::io::Write as _; use bun_ast::Log; use bun_ast::{ImportKind, ImportRecord, ImportRecordFlags, ImportRecordTag}; -use bun_collections::HashMap; use bun_paths::{self, SEP}; // two `fs` shapes are in play here. `bun_resolver::fs` (`Fs`) holds // the singleton `FileSystem` / `DirnameStore`; `bun_paths::fs` (`PFs`) defines @@ -13,8 +12,8 @@ use bun_paths::{self, SEP}; // `import_record.path` via `PFs::Path` so the field assignment unifies. use bun_core::strings; use bun_paths::fs as PFs; +use bun_resolver as resolver; use bun_resolver::fs as Fs; -use bun_resolver::{self as resolver, Resolver}; use bun_sys::Fd; use bun_url::URL; @@ -24,12 +23,6 @@ use crate::transpiler::{ BunPluginTarget, ParseResult, PluginResolver, PluginRunner, ResolveQueue, ResolveResults, }; -type HashedFileNameMap = HashMap; - -// Matches `Transpiler::IS_CACHE_ENABLED`; inlined so `get_hashed_filename` -// doesn't need a `Transpiler` handle. -const IS_CACHE_ENABLED: bool = false; - pub struct Linker { // arena field dropped — global mimalloc (callers pass `bun.default_allocator`) // `Transpiler` owns these values directly and also owns `linker: @@ -41,9 +34,7 @@ pub struct Linker { pub(crate) fs: *mut Fs::FileSystem, pub log: *mut Log, pub(crate) resolve_queue: *mut ResolveQueue, - pub resolver: *mut Resolver<'static>, pub(crate) resolve_results: *mut ResolveResults, - pub(crate) hashed_filenames: HashedFileNameMap, pub plugin_runner: Option<*mut dyn PluginResolver>, } @@ -237,7 +228,6 @@ impl Linker { log: *mut Log, resolve_queue: *mut ResolveQueue, options: *mut BundleOptions<'static>, - resolver: *mut Resolver<'static>, resolve_results: *mut ResolveResults, fs: *mut Fs::FileSystem, ) -> Self { @@ -249,9 +239,7 @@ impl Linker { fs, log, resolve_queue, - resolver, resolve_results, - hashed_filenames: HashedFileNameMap::default(), plugin_runner: None, } } @@ -266,14 +254,12 @@ impl Linker { log: *mut Log, resolve_queue: *mut ResolveQueue, options: *mut BundleOptions<'static>, - resolver: *mut Resolver<'static>, resolve_results: *mut ResolveResults, fs: *mut Fs::FileSystem, ) { self.log = log; self.resolve_queue = resolve_queue; self.options = options; - self.resolver = resolver; self.resolve_results = resolve_results; self.fs = fs; } @@ -318,35 +304,9 @@ impl Linker { file_path: &PFs::Path<'_>, fd: Option, ) -> crate::Result<&'static [u8]> { - if IS_CACHE_ENABLED { - let hashed = bun_wyhash::hash(file_path.text); - if let Some(v) = self.hashed_filenames.get(&hashed) { - return Ok(*v); - } - } - let modkey = self.get_mod_key(file_path, fd)?; - // `ModKey::hash_name` writes into a caller-supplied buffer (1 KiB) - // and returns a borrow of it; `dupe` copies the bytes into the - // process-lifetime interner to satisfy this fn's `'static` return. - // Note: `IS_CACHE_ENABLED` is a hard `const false` (see above), so - // the `hashed_filenames` cache never dedups — every call interns a - // fresh copy for the life of the process. Accepted: the `'static` - // return contract forces a copy anyway, and the alternative (the old - // threadlocal slice return) was unsound. `dupe` also aborts on OOM - // where the old path propagated `?` — consistent with the - // `bun.handleOom` idiom for interner allocations. - // Spec passes `file_path.text` even though the param is named - // `basename`; preserved verbatim. let mut hash_name_buf = [0u8; 1024]; - let hash_name = dupe(modkey.hash_name(file_path.text, &mut hash_name_buf)?); - - if IS_CACHE_ENABLED { - let hashed = bun_wyhash::hash(file_path.text); - self.hashed_filenames.insert(hashed, hash_name); - } - - Ok(hash_name) + Ok(dupe(modkey.hash_name(file_path.text, &mut hash_name_buf)?)) } /// This modifies the Ast in-place! It resolves import records and diff --git a/src/bundler/options.rs b/src/bundler/options.rs index 0470a8e38238..5cd4eb6e6e1b 100644 --- a/src/bundler/options.rs +++ b/src/bundler/options.rs @@ -1529,14 +1529,6 @@ impl<'a> BundleOptions<'a> { b"react-refresh", ]; - #[inline] - pub(crate) fn css_import_behavior(&self) -> api::CssInJsBehavior { - match self.target { - Target::Browser => api::CssInJsBehavior::AutoOnimportcss, - _ => api::CssInJsBehavior::Facade, - } - } - pub(crate) fn load_defines( &mut self, arena: &bun_alloc::Arena, diff --git a/src/bundler/transpiler.rs b/src/bundler/transpiler.rs index cd24d1c280bc..5579791be803 100644 --- a/src/bundler/transpiler.rs +++ b/src/bundler/transpiler.rs @@ -351,7 +351,6 @@ impl<'a> Transpiler<'a> { core::ptr::null_mut(), core::ptr::null_mut(), core::ptr::null_mut(), - core::ptr::null_mut(), from.fs, ), env: from.env, @@ -378,7 +377,6 @@ impl<'a> Transpiler<'a> { log, core::ptr::addr_of_mut!(self.resolve_queue), core::ptr::addr_of_mut!(self.options).cast(), - core::ptr::addr_of_mut!(self.resolver).cast(), core::ptr::addr_of_mut!(*self.resolve_results), self.fs, ); @@ -669,22 +667,15 @@ impl<'a> Transpiler<'a> { /// Initialize `self.linker` with back-pointers into this `Transpiler`, /// optionally auto-configuring JSX from the nearest `tsconfig.json`. pub fn configure_linker_with_auto_jsx(&mut self, auto_jsx: bool) { - // `Linker::init` dropped its `arena` arg (linker.rs:172 - // — global mimalloc). `crate::linker::Linker` stores raw pointers - // so `&mut self.options` etc. coerce directly. Self-reference is - // load-bearing — `linker.link()` reads back through these into the - // owning `Transpiler` — hence raw `*mut`, not `&'a mut` (would alias - // `&mut self` on every call). - // `.cast()` on the `options`/`resolver` pointers erases the - // `<'a>` lifetime parameter — `Linker` stores them as - // `*mut BundleOptions` / `*mut Resolver` with an (implicit) distinct - // lifetime. The linker never - // outlives its owning `Transpiler<'a>`. + // `crate::linker::Linker` stores raw back-pointers into the owning + // `Transpiler`; `linker.link()` reads back through them, so they are + // `*mut` (a `&'a mut` would alias `&mut self` on every call). The + // `.cast()` on `options` erases `<'a>` to the `'static` the field is + // typed at; the linker never outlives its owning `Transpiler<'a>`. self.linker = crate::linker::Linker::init( self.log, core::ptr::addr_of_mut!(self.resolve_queue), core::ptr::addr_of_mut!(self.options).cast(), - core::ptr::addr_of_mut!(self.resolver).cast(), core::ptr::addr_of_mut!(*self.resolve_results), self.fs, ); @@ -1267,10 +1258,7 @@ impl<'a> Transpiler<'a> { // Construct directly into the caller-owned storage instead of building a // stack temporary and returning it. All fallible work is done; every // field below is written exactly once. `Linker::init` gets null - // back-pointers — `core::mem::zeroed()` is NOT a - // valid analogue (`Linker.hashed_filenames: HashMap` carries a `NonNull` - // niche, so all-zeroes is instant UB); the value fields get their proper - // defaults and `configure_linker_with_auto_jsx` overwrites the + // back-pointers; `configure_linker_with_auto_jsx` overwrites the // self-referential pointers before any deref. let p = dst.as_mut_ptr(); // SAFETY: `dst` is an exclusively-borrowed, currently-uninitialised @@ -1300,7 +1288,6 @@ impl<'a> Transpiler<'a> { core::ptr::null_mut(), core::ptr::null_mut(), core::ptr::null_mut(), - core::ptr::null_mut(), fs, )); core::ptr::addr_of_mut!((*p).env).write(env_loader); @@ -2397,12 +2384,10 @@ impl<'a> Transpiler<'a> { let opts = js_printer::Options { bundling: false, require_ref: Some(ast.require_ref), - css_import_behavior: self.options.css_import_behavior(), source_map_handler: source_map_context, minify_whitespace: self.options.minify_whitespace, minify_syntax: self.options.minify_syntax, minify_identifiers: self.options.minify_identifiers, - transform_only: self.options.transform_only, import_meta_ref: ast.import_meta_ref, print_dce_annotations: self.options.emit_dce_annotations, runtime_transpiler_cache, @@ -2476,12 +2461,10 @@ impl<'a> Transpiler<'a> { let opts = js_printer::Options { bundling: false, require_ref: Some(ast.require_ref), - css_import_behavior: self.options.css_import_behavior(), source_map_handler: source_map_context, minify_whitespace: self.options.minify_whitespace, minify_syntax: self.options.minify_syntax, minify_identifiers: self.options.minify_identifiers, - transform_only: self.options.transform_only, module_type: if IS_BUN && self.options.transform_only { // this is for when using `bun build --no-bundle` // it should copy what was passed for the cli diff --git a/src/js_parser/p.rs b/src/js_parser/p.rs index ae8c8539a8db..b44e38097ee4 100644 --- a/src/js_parser/p.rs +++ b/src/js_parser/p.rs @@ -222,7 +222,7 @@ pub struct P<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> { pub(crate) top_level_await_keyword: bun_ast::Range, pub(crate) fn_or_arrow_data_parse: FnOrArrowDataParse, pub(crate) fn_or_arrow_data_visit: FnOrArrowDataVisit, - pub(crate) fn_only_data_visit: FnOnlyDataVisit<'a>, + pub(crate) fn_only_data_visit: FnOnlyDataVisit, pub(crate) allocated_names: List<'a, &'a [u8]>, // allocated_names: ListManaged(string) = ListManaged(string).init(bun.default_allocator), // allocated_names_pool: ?*AllocatedNamesPool.Node = null, @@ -4313,11 +4313,7 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O r: bun_ast::Range, detail: &[u8], ) -> Result<(), crate::Error> { - let can_be_transformed = feature == StrictModeFeature::ForInVarInit; let text: &'a [u8] = match feature { - StrictModeFeature::WithStatement => b"With statements", - StrictModeFeature::DeleteBareName => b"\"delete\" of a bare identifier", - StrictModeFeature::ForInVarInit => b"Variable initializers within for-in loops", StrictModeFeature::EvalOrArguments => bun_alloc::arena_format!( in self.arena, "Declarations with the name \"{}\"", @@ -4332,9 +4328,6 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O ) .into_bump_str() .as_bytes(), - StrictModeFeature::LegacyOctalLiteral => b"Legacy octal literals", - StrictModeFeature::LegacyOctalEscape => b"Legacy octal escape sequences", - StrictModeFeature::IfElseFunctionStmt => b"Function declarations inside if statements", }; let scope = self.current_scope(); @@ -4375,7 +4368,7 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O notes, format_args!("{} cannot be used in strict mode", bstr::BStr::new(text)), ); - } else if !can_be_transformed && self.is_strict_mode_output_format() { + } else if self.is_strict_mode_output_format() { self.log().add_range_error_fmt( Some(self.source), r, @@ -5239,27 +5232,6 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O } pub(crate) fn value_for_this(&mut self, loc: bun_ast::Loc) -> Option { - // Substitute "this" if we're inside a static class property initializer - if self - .fn_only_data_visit - .should_replace_this_with_class_name_ref - { - // class_name_ref is `Option<&'a Cell>` (arena slot owned by the enclosing - // `visit_class` frame); copy the Ref out so the field borrow is released before - // record_usage/new_expr. - if let Some(r) = self.fn_only_data_visit.class_name_ref.map(|c| c.get()) { - self.record_usage(r); - return Some(self.new_expr( - E::Identifier { - ref_: r, - ..Default::default() - }, - loc, - )); - } - } - - // oroigianlly was !=- modepassthrough if !self.fn_only_data_visit.is_this_nested { // In the REPL, top-level `this` must evaluate to the global object // (matching Node's `> this` and `deno repl > this`). The REPL wraps diff --git a/src/js_parser/parser.rs b/src/js_parser/parser.rs index c5f674097102..11abeaf497ac 100644 --- a/src/js_parser/parser.rs +++ b/src/js_parser/parser.rs @@ -1173,14 +1173,8 @@ pub struct ParsedPath<'a> { #[derive(Clone, Copy, PartialEq, Eq)] pub enum StrictModeFeature { - WithStatement, - DeleteBareName, - ForInVarInit, EvalOrArguments, ReservedWord, - LegacyOctalLiteral, - LegacyOctalEscape, - IfElseFunctionStmt, } #[derive(Clone, Copy)] @@ -1386,27 +1380,7 @@ pub struct FnOrArrowDataVisit { /// restored on the call stack around code that parses nested functions (but not /// nested arrow functions). #[derive(Default)] -pub struct FnOnlyDataVisit<'a> { - /// This is a reference to the enclosing class name if there is one. It's used - /// to implement "this" and "super" references. A name is automatically generated - /// if one is missing so this will always be present inside a class body. - /// - /// `&Cell` (not `&mut Ref`): the visit pass needs to - /// both share this slot into nested `fn_only_data_visit` frames *and* read/write - /// it from the enclosing `visit_class` frame. `Cell` gives shared interior - /// mutability for the `Copy` `Ref` payload with zero `unsafe`. - pub(crate) class_name_ref: Option<&'a core::cell::Cell>, - - /// If true, we're inside a static class context where "this" expressions - /// should be replaced with the class name. - pub(crate) should_replace_this_with_class_name_ref: bool, - - /// If we're inside an async arrow function and async functions are not - /// supported, then we will have to convert that arrow function to a generator - /// function. That means references to "arguments" inside the arrow function - /// will have to reference a captured variable instead of the real variable. - pub(crate) is_inside_async_arrow_fn: bool, - +pub struct FnOnlyDataVisit { /// If false, the value for "this" is the top-level module scope "this" value. /// That means it's "undefined" for ECMAScript modules and "exports" for /// CommonJS modules. We track this information so that we can substitute the diff --git a/src/js_parser/visit/mod.rs b/src/js_parser/visit/mod.rs index f9a3fe97bc7f..3ed0911be96c 100644 --- a/src/js_parser/visit/mod.rs +++ b/src/js_parser/visit/mod.rs @@ -77,8 +77,6 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O "only_scan_imports_and_do_not_visit must not run this." ); - // FnOnlyDataVisit holds `Option<&'a Cell>`; save/restore via - // `take` so the old value is moved out before we overwrite the field. let old_fn_or_arrow_data = self.fn_or_arrow_data_visit; let old_fn_only_data = core::mem::take(&mut self.fn_only_data_visit); self.fn_or_arrow_data_visit = FnOrArrowDataVisit { @@ -801,12 +799,6 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O self.enclosing_class_keyword = class.class_keyword; self.vis_scope() .recursive_set_strict_mode(StrictModeKind::ImplicitStrictModeClass); - // `FnOnlyDataVisit::class_name_ref` is `Option<&'a Cell>`, so the - // shadow ref must outlive the parser borrow. Allocate it in the bump arena. - // `Cell` lets us hand out a shared `&'a Cell` to nested frames while - // still reading/writing it here, with no raw-pointer `unsafe`. - let shadow_ref: &'a core::cell::Cell = - core::cell::Cell::from_mut(self.arena.alloc(Ref::NONE)); // Insert a shadowing name that spans the whole class, which matches // JavaScript's semantics. The class body (and extends clause) "captures" the @@ -815,9 +807,8 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O // must be the original value of the name, not the re-assigned value. // Use "const" for this symbol to match JavaScript run-time semantics. You // are not allowed to assign to this symbol (it throws a TypeError). - if let Some(name) = class.class_name { + let mut shadow_ref = if let Some(name) = class.class_name { let name_ref = name.ref_; - shadow_ref.set(name_ref); let original_name: &'a [u8] = self.symbols[name_ref.inner_index() as usize] .original_name .slice(); @@ -831,17 +822,17 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O }, ) .expect("oom"); + name_ref } else { let name_str: &'a [u8] = if default_name_ref.is_empty() { b"_this" } else { b"_default" }; - let new_ref = self.new_symbol(SymbolKind::Constant, name_str); - shadow_ref.set(new_ref); - } + self.new_symbol(SymbolKind::Constant, name_str) + }; - self.record_declared_symbol(shadow_ref.get()); + self.record_declared_symbol(shadow_ref); if let Some(extends) = class.extends.as_mut() { self.visit_expr(extends); @@ -862,10 +853,6 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O self.fn_or_arrow_data_visit = FnOrArrowDataVisit::default(); self.fn_only_data_visit = FnOnlyDataVisit { is_this_nested: true, - class_name_ref: Some(shadow_ref), - - // TODO: down transpilation - should_replace_this_with_class_name_ref: false, ..Default::default() }; // PropertyKind::ClassStaticBlock guarantees `Some`; arena-owned for 'a. @@ -915,11 +902,8 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O // The value of "this" is shadowed inside property values let old_is_this_captured = self.fn_only_data_visit.is_this_nested; - let old_class_name_ref = self.fn_only_data_visit.class_name_ref.take(); self.fn_only_data_visit.is_this_nested = true; - self.fn_only_data_visit.class_name_ref = Some(shadow_ref); // defer p.fn_only_data_visit.is_this_nested = old_is_this_captured; - // defer p.fn_only_data_visit.class_name_ref = old_class_name_ref; // — manual restore at end of loop body; no `continue` after this point. // We need to explicitly assign the name to the property initializer if it @@ -1009,10 +993,9 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O } } - // manual restore for the three `defer`s above + // manual restore for the two `defer`s above self.vis_scope().forbid_arguments = false; self.fn_only_data_visit.is_this_nested = old_is_this_captured; - self.fn_only_data_visit.class_name_ref = old_class_name_ref; } // note: our version assumes useDefineForClassFields is true @@ -1160,24 +1143,23 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O self.enclosing_class_keyword = old_enclosing_class_keyword; } - if self.symbols[shadow_ref.get().inner_index() as usize].use_count_estimate == 0 { + if self.symbols[shadow_ref.inner_index() as usize].use_count_estimate == 0 { // If there was originally no class name but something inside needed one // (e.g. there was a static property initializer that referenced "this"), // store our generated name so the class expression ends up with a name. - shadow_ref.set(Ref::NONE); + shadow_ref = Ref::NONE; } else if class.class_name.is_none() { - let sr = shadow_ref.get(); class.class_name = Some(LocRef { - ref_: sr, + ref_: shadow_ref, loc: name_scope_loc, }); - self.record_declared_symbol(sr); + self.record_declared_symbol(shadow_ref); } // class name scope self.pop_scope(); - shadow_ref.get() + shadow_ref } // Try separating the list for appending, so that it's not a pointer. diff --git a/src/js_parser/visit/visit_expr.rs b/src/js_parser/visit/visit_expr.rs index 0d5c834fde53..5c70d328a80c 100644 --- a/src/js_parser/visit/visit_expr.rs +++ b/src/js_parser/visit/visit_expr.rs @@ -2426,14 +2426,6 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O ..Default::default() }; - // Mark if we're inside an async arrow function. This value should be true - // even if we're inside multiple arrow functions and the closest inclosing - // arrow function isn't async, as long as at least one enclosing arrow - // function within the current enclosing function is async. - let old_inside_async_arrow_fn = p.fn_only_data_visit.is_inside_async_arrow_fn; - p.fn_only_data_visit.is_inside_async_arrow_fn = - e_.is_async || p.fn_only_data_visit.is_inside_async_arrow_fn; - p.push_scope_for_visit_pass(js_ast::scope::Kind::FunctionArgs, expr.loc) .expect("unreachable"); let dupe: &'a mut [Stmt] = p.arena.alloc_slice_copy(e_.body.stmts.slice()); @@ -2499,7 +2491,6 @@ impl<'a, const TYPESCRIPT: bool, const SCAN_ONLY: bool> P<'a, TYPESCRIPT, SCAN_O p.pop_scope(); p.pop_scope(); - p.fn_only_data_visit.is_inside_async_arrow_fn = old_inside_async_arrow_fn; p.fn_or_arrow_data_visit = old_fn_or_arrow_data; // Restore before any further `p.*` call so the stack-local pointer diff --git a/src/js_printer/lib.rs b/src/js_printer/lib.rs index 2a250ef4b84f..07cf2e9d6bf5 100644 --- a/src/js_printer/lib.rs +++ b/src/js_printer/lib.rs @@ -51,8 +51,6 @@ use bun_ast::ImportRecordFlags; use bun_sourcemap as SourceMap; -pub use bun_options_types::schema::api::CssInJsBehavior; - // ────────────────────────────────────────────────────────────────────────── // renamer — defined in `renamer.rs`. The five former leak sites // have been replaced with `bumpalo::Bump`-backed allocation (PORTING.md §Forbidden); @@ -1018,7 +1016,6 @@ pub struct Options<'a> { pub indent: Indentation, // allocator dropped — global mimalloc (this is an AST crate but Options.allocator is the global default) pub source_map_handler: Option>, - pub css_import_behavior: CssInJsBehavior, pub target: bun_ast::Target, pub runtime_transpiler_cache: Option, @@ -1038,7 +1035,6 @@ pub struct Options<'a> { pub minify_syntax: bool, pub print_dce_annotations: bool, - pub transform_only: bool, pub inline_require_and_import_errors: bool, pub has_run_symbol_renamer: bool, @@ -1095,7 +1091,6 @@ impl<'a> Default for Options<'a> { hmr_ref: Ref::NONE, indent: Indentation::default(), source_map_handler: None, - css_import_behavior: CssInJsBehavior::Facade, target: bun_ast::Target::Browser, runtime_transpiler_cache: None, module_info: None, @@ -1109,7 +1104,6 @@ impl<'a> Default for Options<'a> { minify_identifiers: false, minify_syntax: false, print_dce_annotations: true, - transform_only: false, inline_require_and_import_errors: true, has_run_symbol_renamer: false, require_or_import_meta_for_source_callback: RequireOrImportMetaCallback::default(), @@ -6909,8 +6903,6 @@ pub struct BufferWriter { /// reslice on read (`written()` / `written_without_trailing_zero()`). Avoids the O(n) /// `to_vec().into_boxed_slice()` copy the previous port did on every `done()`. pub(crate) written_len: usize, - // `done()` appends a NUL terminator when `append_null_byte` is true. - pub append_null_byte: bool, pub append_newline: bool, } @@ -6932,7 +6924,6 @@ impl BufferWriter { BufferWriter { buffer: MutableString::init_empty(), written_len: 0, - append_null_byte: false, append_newline: false, } } @@ -6946,7 +6937,6 @@ impl BufferWriter { BufferWriter { buffer: MutableString::init(capacity).unwrap_or_else(|_| MutableString::init_empty()), written_len: 0, - append_null_byte: false, append_newline: false, } } @@ -7014,17 +7004,6 @@ impl BufferWriter { self.append_newline = false; self.buffer.append_char(b'\n')?; } - - if self.append_null_byte { - // Append a NUL unless the buffer already ends with one; the NUL is - // *included* in `written` (consumers strip it via - // `written_without_trailing_zero`). - // - // For an *empty* buffer we still append the NUL. - if self.buffer.list.last().copied() != Some(0) { - self.buffer.append_char(0)?; - } - } self.written_len = self.buffer.list.len(); Ok(()) } diff --git a/src/jsc/RuntimeTranspilerStore.rs b/src/jsc/RuntimeTranspilerStore.rs index b025baa3e846..459aba52a9d8 100644 --- a/src/jsc/RuntimeTranspilerStore.rs +++ b/src/jsc/RuntimeTranspilerStore.rs @@ -699,16 +699,6 @@ impl TranspilerJob { ctx.deinit(); } }); - // The bytewise copy left - // `linker.resolver` pointing at `vm.transpiler.resolver` (wrong allocator/log); rewire - // it at the local copy so `print_with_source_map` resolves through the arena-backed - // resolver. - // SAFETY (lifetime erasure): `linker.resolver` is `*mut Resolver<'static>`; the local - // `transpiler.resolver` is `Resolver<'arena>`. The pointer is only dereferenced inside - // `print_with_source_map` below, which completes before `arena` (declared first) drops, - // so widening `'arena → 'static` for the raw-pointer field is sound — same justification - // as the `Transpiler<'_>` cast above. - transpiler.linker.resolver = ptr::addr_of_mut!(transpiler.resolver).cast(); let mut fd: Option = None; let mut package_json: Option<&'static bun_watcher::PackageJSON> = None; @@ -1046,9 +1036,7 @@ impl TranspilerJob { let source_code_printer = tls_get_or_leak(&SOURCE_CODE_PRINTER, || { let writer = BufferWriter::init(); - let mut bp = Box::new(BufferPrinter::init(writer)); - bp.ctx.append_null_byte = false; - bp + Box::new(BufferPrinter::init(writer)) }); // Swap the buffer out and write it back via the @@ -1065,7 +1053,6 @@ impl TranspilerJob { // printer.ctx.buffer.deinit() → Drop let writer = BufferWriter::init(); *source_code_printer = BufferPrinter::init(writer); - source_code_printer.ctx.append_null_byte = false; printer = core::mem::replace( source_code_printer, BufferPrinter::init(BufferWriter::init()), @@ -1156,7 +1143,6 @@ impl TranspilerJob { // printer.ctx.buffer.deinit() → Drop let writer = BufferWriter::init(); *source_code_printer = BufferPrinter::init(writer); - source_code_printer.ctx.append_null_byte = false; } // else: writeback guard already restored `printer` into the thread-local. diff --git a/src/jsc/VirtualMachine.rs b/src/jsc/VirtualMachine.rs index 6f69f5b977f4..97a76e0cb54a 100644 --- a/src/jsc/VirtualMachine.rs +++ b/src/jsc/VirtualMachine.rs @@ -2966,8 +2966,7 @@ fn specifier_cache_resolver_buf() -> *mut bun_paths::PathBuffer { fn ensure_source_code_printer() { if SOURCE_CODE_PRINTER.get().is_none() { let writer = bun_js_printer::BufferWriter::init(); - let mut printer = Box::new(bun_js_printer::BufferPrinter::init(writer)); - printer.ctx.append_null_byte = false; + let printer = Box::new(bun_js_printer::BufferPrinter::init(writer)); SOURCE_CODE_PRINTER.set(NonNull::new(bun_core::heap::into_raw(printer))); } } diff --git a/src/jsc/bindings/node/JSNodeHTTPServerSocket.cpp b/src/jsc/bindings/node/JSNodeHTTPServerSocket.cpp index 36a9d4d9e978..221dcbbbf476 100644 --- a/src/jsc/bindings/node/JSNodeHTTPServerSocket.cpp +++ b/src/jsc/bindings/node/JSNodeHTTPServerSocket.cpp @@ -16,8 +16,6 @@ extern "C" void Bun__NodeHTTPResponse_setClosed(void* zigResponse); extern "C" void Bun__NodeHTTPResponse_markTunneled(void* zigResponse); extern "C" void Bun__NodeHTTPResponse_onClose(void* zigResponse, JSC::EncodedJSValue jsValue); extern "C" void us_socket_free_stream_buffer(us_socket_stream_buffer_t* streamBuffer); -extern "C" uint64_t uws_res_get_remote_address_info(void* res, const char** dest, int* port, bool* is_ipv6); -extern "C" uint64_t uws_res_get_local_address_info(void* res, const char** dest, int* port, bool* is_ipv6); extern "C" EncodedJSValue us_socket_buffered_js_write(void* socket, bool is_ssl, bool ended, us_socket_stream_buffer_t* streamBuffer, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue data, JSC::EncodedJSValue encoding); extern "C" int us_socket_is_ssl_handshake_finished(struct us_socket_t* s); extern "C" int us_socket_ssl_handshake_callback_has_fired(struct us_socket_t* s); diff --git a/src/jsc/bindings/node/crypto/JSCipher.h b/src/jsc/bindings/node/crypto/JSCipher.h index aeda8eebfff2..9a683e4f7114 100644 --- a/src/jsc/bindings/node/crypto/JSCipher.h +++ b/src/jsc/bindings/node/crypto/JSCipher.h @@ -16,12 +16,6 @@ enum class CipherKind { Decipher, }; -enum class UpdateResult { - Success, - ErrorMessageSize, - ErrorState -}; - enum class AuthTagState { AuthTagUnknown, AuthTagKnown, diff --git a/src/jsc/bindings/node/crypto/JSPrivateKeyObjectConstructor.cpp b/src/jsc/bindings/node/crypto/JSPrivateKeyObjectConstructor.cpp index a0d69f850b0a..cf09118113dd 100644 --- a/src/jsc/bindings/node/crypto/JSPrivateKeyObjectConstructor.cpp +++ b/src/jsc/bindings/node/crypto/JSPrivateKeyObjectConstructor.cpp @@ -1,40 +1,2 @@ -#include "JSPrivateKeyObjectConstructor.h" -#include "JSPrivateKeyObject.h" -#include "ErrorCode.h" -#include "JSBufferEncodingType.h" -#include "NodeValidator.h" -#include -#include -#include "CryptoUtil.h" -#include "openssl/dh.h" -#include "openssl/bn.h" -#include "openssl/err.h" -#include "ncrypto.h" - -using namespace JSC; -using namespace WebCore; -using namespace ncrypto; - -namespace Bun { - -const JSC::ClassInfo JSPrivateKeyObjectConstructor::s_info = { "PrivateKeyObject"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPrivateKeyObjectConstructor) }; - -JSC_DEFINE_HOST_FUNCTION(callPrivateKeyObject, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) -{ - VM& vm = lexicalGlobalObject->vm(); - ThrowScope scope = DECLARE_THROW_SCOPE(vm); - throwConstructorCannotBeCalledAsFunctionTypeError(lexicalGlobalObject, scope, "PrivateKeyObject"_s); - return {}; -} - -JSC_DEFINE_HOST_FUNCTION(constructPrivateKeyObject, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) -{ - JSC::VM& vm = lexicalGlobalObject->vm(); - ThrowScope scope = DECLARE_THROW_SCOPE(vm); - - JSValue handleValue = callFrame->argument(0); - // constructing a PrivateKeyObject is impossible - return ERR::INVALID_ARG_TYPE(scope, lexicalGlobalObject, "handle"_s, "object"_s, handleValue); -} - -} // namespace Bun +// Superseded by JSKeyObjectConstructor. Stub kept for the gate harness; see MessagePortChannel.h. +#include "config.h" diff --git a/src/jsc/bindings/node/crypto/JSPrivateKeyObjectConstructor.h b/src/jsc/bindings/node/crypto/JSPrivateKeyObjectConstructor.h index b843e40bca4b..65e5b3aa089c 100644 --- a/src/jsc/bindings/node/crypto/JSPrivateKeyObjectConstructor.h +++ b/src/jsc/bindings/node/crypto/JSPrivateKeyObjectConstructor.h @@ -1,49 +1,2 @@ +// Superseded by JSKeyObjectConstructor. Stub kept for the gate harness; see MessagePortChannel.h. #pragma once - -#include "root.h" -#include - -namespace Bun { - -JSC_DECLARE_HOST_FUNCTION(callPrivateKeyObject); -JSC_DECLARE_HOST_FUNCTION(constructPrivateKeyObject); - -class JSPrivateKeyObjectConstructor final : public JSC::InternalFunction { -public: - using Base = JSC::InternalFunction; - static constexpr unsigned StructureFlags = Base::StructureFlags; - - static JSPrivateKeyObjectConstructor* create(JSC::VM& vm, JSC::Structure* structure, JSC::JSObject* prototype) - { - JSPrivateKeyObjectConstructor* constructor = new (NotNull, JSC::allocateCell(vm)) JSPrivateKeyObjectConstructor(vm, structure); - constructor->finishCreation(vm, prototype); - return constructor; - } - - DECLARE_INFO; - - template - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return &vm.internalFunctionSpace(); - } - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } - -private: - JSPrivateKeyObjectConstructor(JSC::VM& vm, JSC::Structure* structure) - : Base(vm, structure, callPrivateKeyObject, constructPrivateKeyObject) - { - } - - void finishCreation(JSC::VM& vm, JSC::JSObject* prototype) - { - Base::finishCreation(vm, 2, "PrivateKeyObject"_s); - putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); - } -}; - -} // namespace Bun diff --git a/src/jsc/bindings/node/crypto/JSPublicKeyObjectConstructor.cpp b/src/jsc/bindings/node/crypto/JSPublicKeyObjectConstructor.cpp index 161717efdf42..cf09118113dd 100644 --- a/src/jsc/bindings/node/crypto/JSPublicKeyObjectConstructor.cpp +++ b/src/jsc/bindings/node/crypto/JSPublicKeyObjectConstructor.cpp @@ -1,40 +1,2 @@ -#include "JSPublicKeyObjectConstructor.h" -#include "JSPublicKeyObject.h" -#include "ErrorCode.h" -#include "JSBufferEncodingType.h" -#include "NodeValidator.h" -#include -#include -#include "CryptoUtil.h" -#include "openssl/dh.h" -#include "openssl/bn.h" -#include "openssl/err.h" -#include "ncrypto.h" - -using namespace JSC; -using namespace WebCore; -using namespace ncrypto; - -namespace Bun { - -const JSC::ClassInfo JSPublicKeyObjectConstructor::s_info = { "PublicKeyObject"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPublicKeyObjectConstructor) }; - -JSC_DEFINE_HOST_FUNCTION(callPublicKeyObject, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) -{ - VM& vm = lexicalGlobalObject->vm(); - ThrowScope scope = DECLARE_THROW_SCOPE(vm); - throwConstructorCannotBeCalledAsFunctionTypeError(lexicalGlobalObject, scope, "PublicKeyObject"_s); - return {}; -} - -JSC_DEFINE_HOST_FUNCTION(constructPublicKeyObject, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) -{ - JSC::VM& vm = lexicalGlobalObject->vm(); - ThrowScope scope = DECLARE_THROW_SCOPE(vm); - - JSValue handleValue = callFrame->argument(0); - // constructing a PublicKeyObject is impossible - return ERR::INVALID_ARG_TYPE(scope, lexicalGlobalObject, "handle"_s, "object"_s, handleValue); -} - -} // namespace Bun +// Superseded by JSKeyObjectConstructor. Stub kept for the gate harness; see MessagePortChannel.h. +#include "config.h" diff --git a/src/jsc/bindings/node/crypto/JSPublicKeyObjectConstructor.h b/src/jsc/bindings/node/crypto/JSPublicKeyObjectConstructor.h index 27c7da9cc920..65e5b3aa089c 100644 --- a/src/jsc/bindings/node/crypto/JSPublicKeyObjectConstructor.h +++ b/src/jsc/bindings/node/crypto/JSPublicKeyObjectConstructor.h @@ -1,49 +1,2 @@ +// Superseded by JSKeyObjectConstructor. Stub kept for the gate harness; see MessagePortChannel.h. #pragma once - -#include "root.h" -#include - -namespace Bun { - -JSC_DECLARE_HOST_FUNCTION(callPublicKeyObject); -JSC_DECLARE_HOST_FUNCTION(constructPublicKeyObject); - -class JSPublicKeyObjectConstructor final : public JSC::InternalFunction { -public: - using Base = JSC::InternalFunction; - static constexpr unsigned StructureFlags = Base::StructureFlags; - - static JSPublicKeyObjectConstructor* create(JSC::VM& vm, JSC::Structure* structure, JSC::JSObject* prototype) - { - JSPublicKeyObjectConstructor* constructor = new (NotNull, JSC::allocateCell(vm)) JSPublicKeyObjectConstructor(vm, structure); - constructor->finishCreation(vm, prototype); - return constructor; - } - - DECLARE_INFO; - - template - static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return &vm.internalFunctionSpace(); - } - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) - { - return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info()); - } - -private: - JSPublicKeyObjectConstructor(JSC::VM& vm, JSC::Structure* structure) - : Base(vm, structure, callPublicKeyObject, constructPublicKeyObject) - { - } - - void finishCreation(JSC::VM& vm, JSC::JSObject* prototype) - { - Base::finishCreation(vm, 2, "PublicKeyObject"_s); - putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); - } -}; - -} // namespace Bun diff --git a/src/jsc/bindings/node/crypto/JSVerify.cpp b/src/jsc/bindings/node/crypto/JSVerify.cpp index f6be9f92579b..afa925024646 100644 --- a/src/jsc/bindings/node/crypto/JSVerify.cpp +++ b/src/jsc/bindings/node/crypto/JSVerify.cpp @@ -34,7 +34,6 @@ using namespace JSC; JSC_DECLARE_HOST_FUNCTION(jsVerifyProtoFuncInit); JSC_DECLARE_HOST_FUNCTION(jsVerifyProtoFuncUpdate); JSC_DECLARE_HOST_FUNCTION(jsVerifyProtoFuncVerify); -JSC_DECLARE_HOST_FUNCTION(jsVerifyOneShot); // Constructor functions JSC_DECLARE_HOST_FUNCTION(callVerify); @@ -476,39 +475,4 @@ void setupJSVerifyClassStructure(LazyClassStructure::Initializer& init) init.setConstructor(constructor); } -std::optional keyFromPublicString(JSGlobalObject* lexicalGlobalObject, JSC::ThrowScope& scope, const WTF::StringView& keyView) -{ - ncrypto::EVPKeyPointer::PublicKeyEncodingConfig publicConfig; - publicConfig.format = ncrypto::EVPKeyPointer::PKFormatType::PEM; - - UTF8View keyUtf8(keyView); - auto keySpan = keyUtf8.span(); - - ncrypto::Buffer ncryptoBuf { - .data = reinterpret_cast(keySpan.data()), - .len = keySpan.size(), - }; - - ncrypto::ClearErrorOnReturn clearErrorOnReturn; - - auto publicRes = ncrypto::EVPKeyPointer::TryParsePublicKey(publicConfig, ncryptoBuf); - if (publicRes) { - ncrypto::EVPKeyPointer keyPtr(WTF::move(publicRes.value)); - return keyPtr; - } - - if (publicRes.error.value() == ncrypto::EVPKeyPointer::PKParseError::NOT_RECOGNIZED) { - ncrypto::EVPKeyPointer::PrivateKeyEncodingConfig privateConfig; - privateConfig.format = ncrypto::EVPKeyPointer::PKFormatType::PEM; - auto privateRes = ncrypto::EVPKeyPointer::TryParsePrivateKey(privateConfig, ncryptoBuf); - if (privateRes) { - ncrypto::EVPKeyPointer keyPtr(WTF::move(privateRes.value)); - return keyPtr; - } - } - - throwCryptoError(lexicalGlobalObject, scope, publicRes.openssl_error.value_or(0), "Failed to read public key"_s); - return std::nullopt; -} - } // namespace Bun diff --git a/src/jsc/bindings/node/crypto/JSVerify.h b/src/jsc/bindings/node/crypto/JSVerify.h index 1492b202396d..e919cb533558 100644 --- a/src/jsc/bindings/node/crypto/JSVerify.h +++ b/src/jsc/bindings/node/crypto/JSVerify.h @@ -13,9 +13,6 @@ class JSVerify; class JSVerifyPrototype; class JSVerifyConstructor; -// Function to handle JWK format keys -std::optional getKeyObjectHandleFromJwk(JSC::JSGlobalObject* lexicalGlobalObject, JSC::ThrowScope& scope, JSC::JSValue key, bool isPublic); - class JSVerify final : public JSC::JSDestructibleObject { public: using Base = JSC::JSDestructibleObject; diff --git a/src/jsc/bindings/node/http/NodeHTTPParser.cpp b/src/jsc/bindings/node/http/NodeHTTPParser.cpp index 5443c08b2c31..c6e0abf590b5 100644 --- a/src/jsc/bindings/node/http/NodeHTTPParser.cpp +++ b/src/jsc/bindings/node/http/NodeHTTPParser.cpp @@ -316,19 +316,6 @@ JSValue HTTPParser::duration() const return jsNumber(duration); } -bool HTTPParser::lessThan(HTTPParser& other) const -{ - if (m_lastMessageStart == 0 && other.m_lastMessageStart == 0) { - return this < &other; - } else if (m_lastMessageStart == 0) { - return true; - } else if (other.m_lastMessageStart == 0) { - return false; - } - - return m_lastMessageStart < other.m_lastMessageStart; -} - int HTTPParser::onMessageBegin() { JSGlobalObject* globalObject = m_globalObject; diff --git a/src/jsc/bindings/node/http/NodeHTTPParser.h b/src/jsc/bindings/node/http/NodeHTTPParser.h index 41823a1c3428..66b5a7fd8b36 100644 --- a/src/jsc/bindings/node/http/NodeHTTPParser.h +++ b/src/jsc/bindings/node/http/NodeHTTPParser.h @@ -150,8 +150,6 @@ struct HTTPParser { JSC::JSValue getCurrentBuffer(JSC::JSGlobalObject*) const; JSC::JSValue duration() const; - bool lessThan(HTTPParser& other) const; - // llhttp callbacks int onMessageBegin(); int onUrl(const char* at, size_t length); diff --git a/src/jsc/headergen/sizegen.cpp b/src/jsc/headergen/sizegen.cpp index ba47274e95b2..a536757506ed 100644 --- a/src/jsc/headergen/sizegen.cpp +++ b/src/jsc/headergen/sizegen.cpp @@ -1,87 +1 @@ -#include -#include -#include -using namespace std; - -#include "root.h" - -#include "ZigGlobalObject.h" - -#include "Path.h" - -#include "DOMURL.h" - -#include -#include - -int main() { - time_t rawtime; - struct tm *timeinfo; - char buf[80]; - - time(&rawtime); - timeinfo = localtime(&rawtime); - - strftime(buf, 80, "%Y-%m-%d %H:%M:%s", timeinfo); - - cout << "// Auto-generated by src/jsc/headergen/sizegen.cpp at " << buf - << ".\n"; - cout << "// These are the byte sizes for the different object types with " - "bindings in JavaScriptCore.\n"; - cout << "// This allows us to safely return stack allocated C++ types to " - "Zig.\n"; - cout << "// It is only safe to do this when these sizes are correct.\n"; - cout << "// That means:\n"; - cout << "// 1. We can't dynamically link JavaScriptCore\n"; - cout << "// 2. It's important that this is run whenever JavaScriptCore is " - "updated or the bindings on the Zig side change.\n"; - cout << "// Failure to do so will lead to undefined behavior and probably " - "some frustrated people.\n"; - cout << "// --- Regenerate this: --- \n"; - cout << "// 1. \"make headers\"\n"; - cout << "// 2. \"make sizegen\"\n"; - cout << "// 3. \"make headers\"\n"; - cout << "// ------------------------\n"; - cout << "// You can verify the numbers written in this file at runtime via " - "the `extern`d types\n"; - cout << "// Run \"headers\" twice because it uses these values " - "in the output. That's how all the bJSC__.* types are created - from " - "these values. \n"; - int i = 0; - int len = 31 - 3; - for (i = 0; i < len; i++) { - cout << "pub const " << names[i] << " = " << sizes[i] << ";\n"; - cout << "pub const " << names[i] << "_align = " << aligns[i] << ";\n"; - } - cout << "pub const Bun_FFI_PointerOffsetToArgumentsList = " - << JSC::CallFrame::argumentOffset(0) << ";\n"; - cout << "pub const Bun_FFI_PointerOffsetToTypedArrayVector = " - << JSC::JSArrayBufferView::offsetOfVector() << ";\n"; - cout << "pub const Bun_FFI_PointerOffsetToTypedArrayLength = " - << JSC::JSArrayBufferView::offsetOfLength() << ";\n"; - cout << "pub const Bun_CallFrame__codeBlock = "; - - cout << static_cast(JSC::CallFrameSlot::codeBlock) << ";\n"; - cout << "pub const Bun_CallFrame__callee = "; - - cout << static_cast(JSC::CallFrameSlot::callee) << ";\n"; - cout << "pub const Bun_CallFrame__argumentCountIncludingThis = "; - - cout << static_cast(JSC::CallFrameSlot::argumentCountIncludingThis) - << ";\n"; - cout << "pub const Bun_CallFrame__thisArgument = "; - - cout << static_cast(JSC::CallFrameSlot::thisArgument) << ";\n"; - cout << "pub const Bun_CallFrame__firstArgument = "; - - cout << static_cast(JSC::CallFrameSlot::firstArgument) << ";\n"; - - cout << "pub const Bun_CallFrame__size = "; - - cout << sizeof(JSC::CallFrame) << ";\n"; - - cout << "pub const Bun_CallFrame__align = "; - - cout << alignof(JSC::CallFrame) << ";\n"; - return 0; -} \ No newline at end of file +// Dead Zig-era tool. Stub kept for the gate harness; see MessagePortChannel.h. diff --git a/src/runtime/api/JSTranspiler.rs b/src/runtime/api/JSTranspiler.rs index 7eb6c073d526..fa9327d84b0d 100644 --- a/src/runtime/api/JSTranspiler.rs +++ b/src/runtime/api/JSTranspiler.rs @@ -724,10 +724,6 @@ impl<'a> TransformTask<'a> { js_instance: unsafe { bun_ptr::IntrusiveRc::init_ref(transpiler.as_ctx_ptr()) }, }); - // Re-point the linker's resolver backref into the heap-allocated copy. - // Must happen AFTER the move into the Box so the address is stable. - let resolver_ptr: *mut _ = &raw mut transform_task.transpiler.resolver; - transform_task.transpiler.linker.resolver = resolver_ptr; transform_task .transpiler .set_log(&raw mut transform_task.log); diff --git a/src/runtime/api/bun/h2/wire.rs b/src/runtime/api/bun/h2/wire.rs index e842287a9eb5..8dcda6188647 100644 --- a/src/runtime/api/bun/h2/wire.rs +++ b/src/runtime/api/bun/h2/wire.rs @@ -20,9 +20,6 @@ pub const MAX_FRAME_SIZE_UPPER: u32 = 16_777_215; // 2^24 - 1 pub const DEFAULT_WINDOW_SIZE: u32 = 65_535; // 2^16 - 1 pub const MAX_WINDOW_SIZE: u32 = 2_147_483_647; // 2^31 - 1 -/// Highest valid stream identifier (§5.1.1): 2^31 - 1. -pub const MAX_STREAM_ID: u32 = 2_147_483_647; - /// RFC 9113 §6 frame type registry (+ RFC 7838 ALTSVC, RFC 8336 ORIGIN). #[derive(Clone, Copy, PartialEq, Eq, Debug)] #[repr(u8)] diff --git a/src/runtime/ffi/ffi-stdatomic.h b/src/runtime/ffi/ffi-stdatomic.h index 0a86d4d1ee44..53fd6022e1d7 100644 --- a/src/runtime/ffi/ffi-stdatomic.h +++ b/src/runtime/ffi/ffi-stdatomic.h @@ -1,180 +1,2 @@ -/* This file is derived from clang's stdatomic.h */ - -/*===---- stdatomic.h - Standard header for atomic types and operations -----=== - * - * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. - * See https://llvm.org/LICENSE.txt for license information. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - * - *===-----------------------------------------------------------------------=== - */ - -#ifndef _STDATOMIC_H -#define _STDATOMIC_H - -#include -#include -#include - -#define __ATOMIC_RELAXED 0 -#define __ATOMIC_CONSUME 1 -#define __ATOMIC_ACQUIRE 2 -#define __ATOMIC_RELEASE 3 -#define __ATOMIC_ACQ_REL 4 -#define __ATOMIC_SEQ_CST 5 - -/* Memory ordering */ -typedef enum { - memory_order_relaxed = __ATOMIC_RELAXED, - memory_order_consume = __ATOMIC_CONSUME, - memory_order_acquire = __ATOMIC_ACQUIRE, - memory_order_release = __ATOMIC_RELEASE, - memory_order_acq_rel = __ATOMIC_ACQ_REL, - memory_order_seq_cst = __ATOMIC_SEQ_CST, -} memory_order; - -/* Atomic typedefs */ -typedef _Atomic(_Bool) atomic_bool; -typedef _Atomic(char) atomic_char; -typedef _Atomic(signed char) atomic_schar; -typedef _Atomic(unsigned char) atomic_uchar; -typedef _Atomic(short) atomic_short; -typedef _Atomic(unsigned short) atomic_ushort; -typedef _Atomic(int) atomic_int; -typedef _Atomic(unsigned int) atomic_uint; -typedef _Atomic(long) atomic_long; -typedef _Atomic(unsigned long) atomic_ulong; -typedef _Atomic(long long) atomic_llong; -typedef _Atomic(unsigned long long) atomic_ullong; -typedef _Atomic(uint_least16_t) atomic_char16_t; -typedef _Atomic(uint_least32_t) atomic_char32_t; -typedef _Atomic(wchar_t) atomic_wchar_t; -typedef _Atomic(int_least8_t) atomic_int_least8_t; -typedef _Atomic(uint_least8_t) atomic_uint_least8_t; -typedef _Atomic(int_least16_t) atomic_int_least16_t; -typedef _Atomic(uint_least16_t) atomic_uint_least16_t; -typedef _Atomic(int_least32_t) atomic_int_least32_t; -typedef _Atomic(uint_least32_t) atomic_uint_least32_t; -typedef _Atomic(int_least64_t) atomic_int_least64_t; -typedef _Atomic(uint_least64_t) atomic_uint_least64_t; -typedef _Atomic(int_fast8_t) atomic_int_fast8_t; -typedef _Atomic(uint_fast8_t) atomic_uint_fast8_t; -typedef _Atomic(int_fast16_t) atomic_int_fast16_t; -typedef _Atomic(uint_fast16_t) atomic_uint_fast16_t; -typedef _Atomic(int_fast32_t) atomic_int_fast32_t; -typedef _Atomic(uint_fast32_t) atomic_uint_fast32_t; -typedef _Atomic(int_fast64_t) atomic_int_fast64_t; -typedef _Atomic(uint_fast64_t) atomic_uint_fast64_t; -typedef _Atomic(intptr_t) atomic_intptr_t; -typedef _Atomic(uintptr_t) atomic_uintptr_t; -typedef _Atomic(size_t) atomic_size_t; -typedef _Atomic(ptrdiff_t) atomic_ptrdiff_t; -typedef _Atomic(intmax_t) atomic_intmax_t; -typedef _Atomic(uintmax_t) atomic_uintmax_t; - -/* Atomic flag */ -typedef struct { - atomic_bool value; -} atomic_flag; - -#define ATOMIC_FLAG_INIT { 0 } -#define ATOMIC_VAR_INIT(value) (value) - -#define atomic_flag_test_and_set_explicit(object, order) \ - __atomic_test_and_set((void*)(&((object)->value)), order) -#define atomic_flag_test_and_set(object) \ - atomic_flag_test_and_set_explicit(object, __ATOMIC_SEQ_CST) - -#define atomic_flag_clear_explicit(object, order) \ - __atomic_clear((bool*)(&((object)->value)), order) -#define atomic_flag_clear(object) \ - atomic_flag_clear_explicit(object, __ATOMIC_SEQ_CST) - -/* Generic routines */ -#define atomic_init(object, desired) \ - atomic_store_explicit(object, desired, __ATOMIC_RELAXED) - -#define atomic_store_explicit(object, desired, order) \ - ({ \ - __typeof__(object) ptr = (object); \ - __typeof__(*ptr) tmp = (desired); \ - __atomic_store(ptr, &tmp, (order)); \ - }) -#define atomic_store(object, desired) \ - atomic_store_explicit(object, desired, __ATOMIC_SEQ_CST) - -#define atomic_load_explicit(object, order) \ - ({ \ - __typeof__(object) ptr = (object); \ - __typeof__(*ptr) tmp; \ - __atomic_load(ptr, &tmp, (order)); \ - tmp; \ - }) -#define atomic_load(object) atomic_load_explicit(object, __ATOMIC_SEQ_CST) - -#define atomic_exchange_explicit(object, desired, order) \ - ({ \ - __typeof__(object) ptr = (object); \ - __typeof__(*ptr) val = (desired); \ - __typeof__(*ptr) tmp; \ - __atomic_exchange(ptr, &val, &tmp, (order)); \ - tmp; \ - }) -#define atomic_exchange(object, desired) \ - atomic_exchange_explicit(object, desired, __ATOMIC_SEQ_CST) - -#define atomic_compare_exchange_strong_explicit(object, expected, desired, \ - success, failure) \ - ({ \ - __typeof__(object) ptr = (object); \ - __typeof__(*ptr) tmp = desired; \ - __atomic_compare_exchange(ptr, expected, &tmp, 0, success, failure); \ - }) -#define atomic_compare_exchange_strong(object, expected, desired) \ - atomic_compare_exchange_strong_explicit(object, expected, desired, \ - __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) - -#define atomic_compare_exchange_weak_explicit(object, expected, desired, \ - success, failure) \ - ({ \ - __typeof__(object) ptr = (object); \ - __typeof__(*ptr) tmp = desired; \ - __atomic_compare_exchange(ptr, expected, &tmp, 1, success, failure); \ - }) -#define atomic_compare_exchange_weak(object, expected, desired) \ - atomic_compare_exchange_weak_explicit(object, expected, desired, \ - __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) - -#define atomic_fetch_add(object, operand) \ - __atomic_fetch_add(object, operand, __ATOMIC_SEQ_CST) -#define atomic_fetch_add_explicit __atomic_fetch_add - -#define atomic_fetch_sub(object, operand) \ - __atomic_fetch_sub(object, operand, __ATOMIC_SEQ_CST) -#define atomic_fetch_sub_explicit __atomic_fetch_sub - -#define atomic_fetch_or(object, operand) \ - __atomic_fetch_or(object, operand, __ATOMIC_SEQ_CST) -#define atomic_fetch_or_explicit __atomic_fetch_or - -#define atomic_fetch_xor(object, operand) \ - __atomic_fetch_xor(object, operand, __ATOMIC_SEQ_CST) -#define atomic_fetch_xor_explicit __atomic_fetch_xor - -#define atomic_fetch_and(object, operand) \ - __atomic_fetch_and(object, operand, __ATOMIC_SEQ_CST) -#define atomic_fetch_and_explicit __atomic_fetch_and - -extern void atomic_thread_fence(memory_order); -extern void __atomic_thread_fence(memory_order); -#define atomic_thread_fence(order) __atomic_thread_fence(order) -extern void atomic_signal_fence(memory_order); -extern void __atomic_signal_fence(memory_order); -#define atomic_signal_fence(order) __atomic_signal_fence(order) -extern bool __atomic_is_lock_free(size_t size, void* ptr); -#define atomic_is_lock_free(OBJ) __atomic_is_lock_free(sizeof(*(OBJ)), (OBJ)) - -extern bool __atomic_test_and_set(void*, memory_order); -extern void __atomic_clear(bool*, memory_order); - -#endif /* _STDATOMIC_H */ +// Not embedded by ffi_body.rs. Stub kept for the gate harness; see MessagePortChannel.h. +#pragma once diff --git a/src/runtime/jsc_hooks.rs b/src/runtime/jsc_hooks.rs index 221b041af7a9..dea9d33e2a6d 100644 --- a/src/runtime/jsc_hooks.rs +++ b/src/runtime/jsc_hooks.rs @@ -3178,7 +3178,6 @@ fn transpile_source_code_inner( if written_len > 1024 * 1024 * 2 || unsafe { &*jsc_vm }.smol { *printer = bun_js_printer::BufferPrinter::init(bun_js_printer::BufferWriter::init()); - printer.ctx.append_null_byte = false; } // (fd close handled by `_fd_guard` registered above; spec @@ -4441,8 +4440,7 @@ unsafe fn transpile_file( let mut p = cell.get(); if p.is_null() { let writer = bun_js_printer::BufferWriter::init(); - let mut bp = Box::new(bun_js_printer::BufferPrinter::init(writer)); - bp.ctx.append_null_byte = false; + let bp = Box::new(bun_js_printer::BufferPrinter::init(writer)); p = bun_core::heap::into_raw(bp); cell.set(p); } @@ -4630,8 +4628,7 @@ unsafe fn transpile_virtual_module( let mut p = cell.get(); if p.is_null() { let writer = bun_js_printer::BufferWriter::init(); - let mut bp = Box::new(bun_js_printer::BufferPrinter::init(writer)); - bp.ctx.append_null_byte = false; + let bp = Box::new(bun_js_printer::BufferPrinter::init(writer)); p = bun_core::heap::into_raw(bp); cell.set(p); } diff --git a/src/runtime/server/ServerWebSocket.rs b/src/runtime/server/ServerWebSocket.rs index 9ee38f23c592..cf6df63e45ca 100644 --- a/src/runtime/server/ServerWebSocket.rs +++ b/src/runtime/server/ServerWebSocket.rs @@ -40,7 +40,7 @@ pub struct ServerWebSocket { } // We pack the per-socket data into this struct below: -// ssl:1, closed:1, opened:1, binary_type:4, packed_websocket_ptr:57 +// ssl:1, closed:1, :1, binary_type:4, packed_websocket_ptr:57 #[repr(transparent)] #[derive(Copy, Clone, Default)] pub struct Flags(u64); @@ -48,7 +48,6 @@ pub struct Flags(u64); impl Flags { const SSL_BIT: u64 = 1 << 0; const CLOSED_BIT: u64 = 1 << 1; - const OPENED_BIT: u64 = 1 << 2; const BINARY_TYPE_SHIFT: u32 = 3; const BINARY_TYPE_MASK: u64 = 0b1111 << Self::BINARY_TYPE_SHIFT; const PTR_SHIFT: u32 = 7; @@ -79,14 +78,6 @@ impl Flags { } } #[inline] - pub(crate) fn set_opened(&mut self, v: bool) { - if v { - self.0 |= Self::OPENED_BIT; - } else { - self.0 &= !Self::OPENED_BIT; - } - } - #[inline] pub(crate) fn binary_type(self) -> BinaryType { // Stored value was written via `set_binary_type` from a valid // `BinaryType` discriminant (4-bit field, 14 variants). @@ -426,8 +417,6 @@ impl ServerWebSocket { return; } - self.update_flags(|f| f.set_opened(false)); - if on_open_handler.is_empty_or_undefined_or_null() { return; } @@ -450,7 +439,6 @@ impl ServerWebSocket { }; ws.cork(&mut corker, Corker::run); let result = corker.result; - self.update_flags(|f| f.set_opened(true)); if let Some(err_value) = result.to_error() { bun_output::scoped_log!(WebSocketServer, "onOpen exception"); diff --git a/src/runtime/server/mod.rs b/src/runtime/server/mod.rs index 9551413e57ed..c55227b61183 100644 --- a/src/runtime/server/mod.rs +++ b/src/runtime/server/mod.rs @@ -175,18 +175,6 @@ impl AnyRoute { } } - pub fn ref_(&self) { - match self { - AnyRoute::Static(p) => bun_ptr::BackRef::from(*p).ref_(), - AnyRoute::File(p) => bun_ptr::BackRef::from(*p).ref_(), - AnyRoute::Directory(p) => bun_ptr::BackRef::from(*p).ref_(), - AnyRoute::Html(r) => { - // SAFETY: RefPtr keeps the pointee live while held in the route table. - unsafe { bun_ptr::RefCount::::ref_(r.as_ptr()) }; - } - AnyRoute::FrameworkRouter(_) => {} // not reference counted - } - } pub(crate) fn deref_(&self) { match self { // SAFETY: intrusive refcount; ptr was heap-allocated with rc=1. diff --git a/src/runtime/server/server_body.rs b/src/runtime/server/server_body.rs index 36d0aa29b2b6..b94fbd183c18 100644 --- a/src/runtime/server/server_body.rs +++ b/src/runtime/server/server_body.rs @@ -522,9 +522,9 @@ pub mod BunInfo { } // ─── AnyRoute ──────────────────────────────────────────────────────────────── -// NOTE: enum + `memory_cost`/`set_server`/`ref_`/`deref_` live in -// `super` (mod.rs). The `impl` block below adds the JS-facing constructors -// (`from_js`/`from_options`/…) on the same type — same crate, split by file. +// NOTE: enum + `memory_cost`/`deref_` live in `super` (mod.rs). The `impl` +// block below adds the JS-facing constructors (`from_js`/`from_options`/…) on +// the same type — same crate, split by file. pub(super) use super::AnyRoute; impl AnyRoute { diff --git a/src/sql/mysql/MySQLTypes.rs b/src/sql/mysql/MySQLTypes.rs index 19fb96df4957..b6151125f164 100644 --- a/src/sql/mysql/MySQLTypes.rs +++ b/src/sql/mysql/MySQLTypes.rs @@ -107,6 +107,4 @@ impl FieldType { // Callers import `bun_sql_jsc::mysql::mysql_value::Value` directly. -pub(crate) type MySQLInt32 = Int4; -// encode/decode sites must mask/read exactly 3 bytes. Verify all Int3 users do so. -pub(crate) type Int4 = u32; +pub(crate) type MySQLInt32 = u32; diff --git a/src/sql/mysql/StatusFlags.rs b/src/sql/mysql/StatusFlags.rs index e9729f77f076..3a39fa42865c 100644 --- a/src/sql/mysql/StatusFlags.rs +++ b/src/sql/mysql/StatusFlags.rs @@ -4,33 +4,8 @@ use core::fmt; #[repr(u16)] #[derive(Copy, Clone, Eq, PartialEq)] pub enum StatusFlag { - SERVER_STATUS_IN_TRANS = 1, - /// Indicates if autocommit mode is enabled - SERVER_STATUS_AUTOCOMMIT = 2, /// Indicates there are more result sets from this query SERVER_MORE_RESULTS_EXISTS = 8, - /// Query used a suboptimal index - SERVER_STATUS_NO_GOOD_INDEX_USED = 16, - /// Query performed a full table scan with no index - SERVER_STATUS_NO_INDEX_USED = 32, - /// Indicates an open cursor exists - SERVER_STATUS_CURSOR_EXISTS = 64, - /// Last row in result set has been sent - SERVER_STATUS_LAST_ROW_SENT = 128, - /// Database was dropped - SERVER_STATUS_DB_DROPPED = 1 << 8, - /// Backslash escaping is disabled - SERVER_STATUS_NO_BACKSLASH_ESCAPES = 1 << 9, - /// Server's metadata has changed - SERVER_STATUS_METADATA_CHANGED = 1 << 10, - /// Query execution was considered slow - SERVER_QUERY_WAS_SLOW = 1 << 11, - /// Statement has output parameters - SERVER_PS_OUT_PARAMS = 1 << 12, - /// Transaction is in read-only mode - SERVER_STATUS_IN_TRANS_READONLY = 1 << 13, - /// Session state has changed - SERVER_SESSION_STATE_CHANGED = 1 << 14, } #[derive(Copy, Clone, Default)] diff --git a/src/sql/mysql/protocol/CommandType.rs b/src/sql/mysql/protocol/CommandType.rs index efb6b1d429b0..bd1c92570b06 100644 --- a/src/sql/mysql/protocol/CommandType.rs +++ b/src/sql/mysql/protocol/CommandType.rs @@ -2,35 +2,7 @@ #[repr(u8)] #[derive(Copy, Clone, Eq, PartialEq, Debug)] pub enum CommandType { - COM_QUIT = 0x01, - COM_INIT_DB = 0x02, COM_QUERY = 0x03, - COM_FIELD_LIST = 0x04, - COM_CREATE_DB = 0x05, - COM_DROP_DB = 0x06, - COM_REFRESH = 0x07, - COM_SHUTDOWN = 0x08, - COM_STATISTICS = 0x09, - COM_PROCESS_INFO = 0x0a, - COM_CONNECT = 0x0b, - COM_PROCESS_KILL = 0x0c, - COM_DEBUG = 0x0d, - COM_PING = 0x0e, - COM_TIME = 0x0f, - COM_DELAYED_INSERT = 0x10, - COM_CHANGE_USER = 0x11, - COM_BINLOG_DUMP = 0x12, - COM_TABLE_DUMP = 0x13, - COM_CONNECT_OUT = 0x14, - COM_REGISTER_SLAVE = 0x15, COM_STMT_PREPARE = 0x16, COM_STMT_EXECUTE = 0x17, - COM_STMT_SEND_LONG_DATA = 0x18, - COM_STMT_CLOSE = 0x19, - COM_STMT_RESET = 0x1a, - COM_SET_OPTION = 0x1b, - COM_STMT_FETCH = 0x1c, - COM_DAEMON = 0x1d, - COM_BINLOG_DUMP_GTID = 0x1e, - COM_RESET_CONNECTION = 0x1f, } diff --git a/test/internal/source-lints/dead-symbols-node-crypto-parser.test.ts b/test/internal/source-lints/dead-symbols-node-crypto-parser.test.ts new file mode 100644 index 000000000000..f47fbe3eda4c --- /dev/null +++ b/test/internal/source-lints/dead-symbols-node-crypto-parser.test.ts @@ -0,0 +1,84 @@ +// Guards against reintroduction of symbols removed as dead code from +// node/crypto C++ bindings, js_parser, js_printer, bundler, sql, server, and a +// handful of orphan headers. Each entry was verified to have zero callers +// across src/ and build/debug/codegen/ before deletion. This test fails if any +// reappear. +// +// This is a source-tree lint: it reads files from src/ and does not touch the +// built binary, so it belongs in test/internal/source-lints/ per the README. + +import { expect, test } from "bun:test"; +import { readFileSync } from "node:fs"; +import path from "node:path"; + +const repoRoot = path.resolve(import.meta.dir, "..", "..", ".."); + +function src(p: string): string { + return readFileSync(path.join(repoRoot, p), "utf8"); +} + +test("orphan headers and unused C++ crypto constructors do not reappear", () => { + // These files had zero #include references (or, for the constructor pair, + // defined a class never instantiated because JSPrivateKeyObject / + // JSPublicKeyObject use JSKeyObjectConstructor instead). They are now + // empty stubs, so assert on distinctive content rather than existence. + const checks: Array<[string, RegExp]> = [ + ["src/jsc/headergen/sizegen.cpp", /\bJSArrayBufferViewInlines\.h\b/], + ["src/runtime/ffi/ffi-stdatomic.h", /\b_STDATOMIC_H\b/], + ["src/jsc/bindings/node/crypto/JSPrivateKeyObjectConstructor.h", /\bclass JSPrivateKeyObjectConstructor\b/], + ["src/jsc/bindings/node/crypto/JSPrivateKeyObjectConstructor.cpp", /\bcallPrivateKeyObject\b/], + ["src/jsc/bindings/node/crypto/JSPublicKeyObjectConstructor.h", /\bclass JSPublicKeyObjectConstructor\b/], + ["src/jsc/bindings/node/crypto/JSPublicKeyObjectConstructor.cpp", /\bcallPublicKeyObject\b/], + ]; + const resurrected = checks.filter(([file, re]) => re.test(src(file))).map(([file, re]) => `${file}: ${re.source}`); + expect(resurrected).toEqual([]); +}); + +test("dead C++ node binding helpers do not reappear", () => { + const checks: Array<[string, RegExp]> = [ + ["src/jsc/bindings/node/crypto/JSVerify.cpp", /\bkeyFromPublicString\b/], + ["src/jsc/bindings/node/crypto/JSVerify.h", /\bgetKeyObjectHandleFromJwk\b/], + ["src/jsc/bindings/node/crypto/JSCipher.h", /\benum class UpdateResult\b/], + ["src/jsc/bindings/node/http/NodeHTTPParser.h", /\blessThan\b/], + ["src/jsc/bindings/node/http/NodeHTTPParser.cpp", /\bHTTPParser::lessThan\b/], + ["src/jsc/bindings/node/JSNodeHTTPServerSocket.cpp", /\buws_res_get_remote_address_info\b/], + ]; + const resurrected = checks.filter(([file, re]) => re.test(src(file))).map(([file, re]) => `${file}: ${re.source}`); + expect(resurrected).toEqual([]); +}); + +test("dead Rust bundler/parser/printer items do not reappear", () => { + const checks: Array<[string, RegExp]> = [ + // bundler: write-only Linker.resolver field + always-false cache guard + ["src/bundler/linker.rs", /pub resolver:\s*\*mut Resolver/], + ["src/bundler/linker.rs", /\bhashed_filenames\b/], + ["src/bundler/linker.rs", /\bIS_CACHE_ENABLED\b/], + ["src/bundler/Graph.rs", /\bIS_PLUGIN_FILE\b/], + ["src/bundler/ParseTask.rs", /\bReadFile\b/], + // js_parser: never-constructed StrictModeFeature variants + write-only + // FnOnlyDataVisit fields + ["src/js_parser/parser.rs", /\bWithStatement\b/], + ["src/js_parser/parser.rs", /\bLegacyOctalLiteral\b/], + ["src/js_parser/parser.rs", /\bis_inside_async_arrow_fn\b/], + ["src/js_parser/parser.rs", /\bshould_replace_this_with_class_name_ref\b/], + ["src/js_parser/parser.rs", /\bclass_name_ref:\s*Option re.test(src(file))).map(([file, re]) => `${file}: ${re.source}`); + expect(resurrected).toEqual([]); +}); diff --git a/test/internal/source-lints/no-iostream-include.test.ts b/test/internal/source-lints/no-iostream-include.test.ts index 2ef0fa212c33..a7f54a7d5716 100644 --- a/test/internal/source-lints/no-iostream-include.test.ts +++ b/test/internal/source-lints/no-iostream-include.test.ts @@ -23,8 +23,6 @@ test("C++ sources compiled into Bun do not include ", async () => { const repoRoot = path.resolve(import.meta.dir, "..", "..", ".."); const roots = ["src", "packages/bun-uws", "packages/bun-usockets"]; - // sizegen.cpp is a build-time code generator, not linked into the bun binary. - const allowlist = new Set(["src/jsc/headergen/sizegen.cpp"]); const iostreamInclude = /^\s*#\s*include\s*/m; const violations: string[] = []; @@ -35,7 +33,6 @@ test("C++ sources compiled into Bun do not include ", async () => { for await (const rel of glob.scan({ cwd: path.join(repoRoot, root) })) { scanned++; const relFromRepo = path.join(root, rel).replaceAll("\\", "/"); - if (allowlist.has(relFromRepo)) continue; const source = readFileSync(path.join(repoRoot, root, rel), "utf8"); if (iostreamInclude.test(source)) { violations.push(relFromRepo);