Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions src/bundler/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2072,7 +2072,6 @@ pub enum PlaceholderField {
Target,
}

// Shared body for PathTemplate::needs / PathTemplateConst::needs (D064).
#[inline]
fn path_template_needs(data: &[u8], field: PlaceholderField) -> bool {
let needle: &[u8] = match field {
Expand Down Expand Up @@ -2113,7 +2112,6 @@ pub fn find_unterminated_placeholder(template: &[u8]) -> Option<(usize, &[u8])>
None
}

// Shared body for PathTemplate::print / PathTemplateConst::print (D064).
// Writes raw path bytes via a byte-writer free fn (not `core::fmt::Display`).
fn path_template_print<W: bun_io::Write>(
writer: &mut W,
Expand Down Expand Up @@ -2424,45 +2422,6 @@ impl PlaceholderConst {
};
}

impl PathTemplateConst {
/// Byte-writer form mirroring [`PathTemplate::print`].
/// Kept as an inherent method so callers writing
/// to `Vec<u8>` via `write!(.., "{}", template)` resolve through the
/// blanket [`core::fmt::Display`] impl below.
pub(crate) fn print<W: bun_io::Write>(
&self,
writer: &mut W,
sanitize_parent_dirs: bool,
) -> bun_io::Result<()> {
path_template_print(
writer,
self.data,
self.placeholder.dir,
self.placeholder.name,
self.placeholder.ext,
self.placeholder.hash,
self.placeholder.target,
sanitize_parent_dirs,
)
}
}

impl core::fmt::Display for PathTemplateConst {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut buf = Vec::<u8>::new();
self.print(&mut buf, true).map_err(|_| core::fmt::Error)?;
write!(f, "{}", bstr::BStr::new(&buf))
}
}

impl core::fmt::Display for PathTemplate {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut buf = Vec::<u8>::new();
self.print(&mut buf, true).map_err(|_| core::fmt::Error)?;
write!(f, "{}", bstr::BStr::new(&buf))
}
}

impl From<PathTemplateConst> for PathTemplate {
fn from(c: PathTemplateConst) -> Self {
PathTemplate {
Expand Down
2 changes: 0 additions & 2 deletions src/install/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,6 @@ impl bun_collections::PriorityCompare<DependencyID> for PriorityQueueContext {
// Min-heap keyed by `PriorityQueueContext::less_than` (string-order of dep names).
pub(crate) type PriorityQueue = bun_collections::PriorityQueue<DependencyID, PriorityQueueContext>;

// `inherent_associated_types` is unstable, so callers use `Bin::PriorityQueueContext`.

// https://github.com/npm/npm-normalize-package-bin/blob/574e6d7cd21b2f3dee28a216ec2053c2551f7af9/lib/index.js#L38
fn normalized_bin_name(name: &[u8]) -> &[u8] {
let name = match name
Expand Down
41 changes: 1 addition & 40 deletions src/jsc/DeprecatedStrong.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@ use core::ptr::NonNull;

use crate::JSValue;

// Refcount contract (load-bearing): `ref()`/`unref()` calls must be balanced
// in pairs; Drop is the release for the `init()` protect. In debug builds a
// final `unref()` (ref_count 1 → 0) additionally frees the canary, zeroes
// `raw`, and clears `_safety` so a subsequent Drop is a no-op. Release builds
// have no ref_count, so an unref-used-as-release followed by Drop would
// double-unprotect — callers must never use `unref()` as the release.
// (Audited 2026-06: the only user is test_runner/Collection.rs, which uses
// `init` + Drop and never calls `ref`/`unref`.)

#[cfg(debug_assertions)]
macro_rules! enable_safety {
() => {
Expand All @@ -40,7 +31,6 @@ struct SafetyData {
// so freeing does NOT run DeprecatedStrong::drop on the sentinel value; the
// pointer is stored cast to the inner type for ergonomic field access.
ptr: NonNull<DeprecatedStrong>,
ref_count: u32,
}

pub struct DeprecatedStrong {
Expand All @@ -63,7 +53,6 @@ impl DeprecatedStrong {
_safety: None,
})))
.cast::<DeprecatedStrong>(),
ref_count: 1,
});
#[cfg(not(debug_assertions))]
let _safety: Safety = ();
Expand All @@ -76,45 +65,17 @@ impl DeprecatedStrong {
pub fn get(&self) -> JSValue {
self.raw
}

pub fn unref(&mut self) {
self.raw.unprotect();
#[cfg(debug_assertions)]
if let Some(_safety) = &mut self._safety {
if _safety.ref_count == 1 {
// SAFETY: ptr was produced by heap::alloc in `init` and not yet freed.
unsafe {
debug_assert!((*_safety.ptr.as_ptr()).raw.encoded() == 0xAEBCFA);
(*_safety.ptr.as_ptr()).raw = JSValue::from_encoded(0xFFFFFF);
// Free without running Drop on the sentinel (ManuallyDrop is repr(transparent)).
drop(bun_core::heap::take(
_safety
.ptr
.as_ptr()
.cast::<ManuallyDrop<DeprecatedStrong>>(),
));
}
// Neutralize so Drop is a no-op (see top-of-file refcount contract).
self._safety = None;
self.raw = JSValue::ZERO;
return;
}
_safety.ref_count -= 1;
}
}
}
Comment thread
robobun marked this conversation as resolved.

impl Drop for DeprecatedStrong {
fn drop(&mut self) {
self.raw.unprotect();
#[cfg(debug_assertions)]
if let Some(_safety) = &mut self._safety {
// SAFETY: ptr was produced by heap::alloc in `init` and has not been freed
// (ref_count == 1 asserted below).
// SAFETY: ptr was produced by heap::alloc in `init` and has not been freed.
unsafe {
debug_assert!((*_safety.ptr.as_ptr()).raw.encoded() == 0xAEBCFA);
(*_safety.ptr.as_ptr()).raw = JSValue::from_encoded(0xFFFFFF);
debug_assert!(_safety.ref_count == 1);
// Free without running Drop on the sentinel (ManuallyDrop is repr(transparent)).
drop(bun_core::heap::take(
_safety
Expand Down
7 changes: 0 additions & 7 deletions src/jsc/bindings/URLSearchParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@

namespace WebCore {

extern "C" JSC::EncodedJSValue URLSearchParams__create(JSDOMGlobalObject* globalObject, const ZigString* input)
{
String str = Zig::toString(*input);
auto result = URLSearchParams::create(str, nullptr);
return JSC::JSValue::encode(WebCore::toJSNewlyCreated(globalObject, globalObject, WTF::move(result)));
}

extern "C" WebCore::URLSearchParams* URLSearchParams__fromJS(JSC::EncodedJSValue value)
{
return WebCoreCast<WebCore::JSURLSearchParams, WebCore::URLSearchParams>(value);
Expand Down
4 changes: 0 additions & 4 deletions src/jsc/bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3024,10 +3024,6 @@ void JSC__JSString__toZigString(JSC::JSString* arg0, JSC::JSGlobalObject* arg1,
// We don't need to assert here because ->value returns a reference to the same string as the one owned by the JSString.
}

bool JSC__JSString__eql(const JSC::JSString* arg0, JSC::JSGlobalObject* obj, JSC::JSString* arg2)
{
return arg0->equal(obj, arg2);
}
bool JSC__JSString__is8Bit(const JSC::JSString* arg0) { return arg0->is8Bit(); };
size_t JSC__JSString__length(const JSC::JSString* arg0) { return arg0->length(); }

Expand Down
1 change: 0 additions & 1 deletion src/jsc/bindings/headers.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions src/libarchive/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,10 +522,6 @@ pub mod lib {
.expect("archive_read_new returned null"),
)
}
#[inline]
pub fn as_ptr(&self) -> *mut Archive {
self.0.as_ptr()
}
}
impl core::ops::Deref for ReadArchive {
type Target = Archive;
Expand Down Expand Up @@ -554,10 +550,6 @@ pub mod lib {
.expect("archive_write_new returned null"),
)
}
#[inline]
pub fn as_ptr(&self) -> *mut Archive {
self.0.as_ptr()
}
}
impl core::ops::Deref for WriteArchive {
type Target = Archive;
Expand All @@ -583,10 +575,6 @@ pub mod lib {
pub fn new() -> Self {
Self(core::ptr::NonNull::new(Entry::new()).expect("archive_entry_new returned null"))
}
#[inline]
pub fn as_ptr(&self) -> *mut Entry {
self.0.as_ptr()
}
}
impl core::ops::Deref for OwnedEntry {
type Target = Entry;
Expand Down
3 changes: 0 additions & 3 deletions src/resolver/dir_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ pub type Index = IndexType;
// only inside `dir_info_uncached` while filling a freshly-`put` slot, before
// any handle to that slot escapes. All access is additionally serialized under
// the resolver mutex.
//
// `as_ptr()` exposes the raw `*mut` for the few callers that still need it
// (the `dir_info_uncached` fill path and `MatchResult.dir_info` round-trip).
// ─────────────────────────────────────────────────────────────────────────────

/// Non-owning, `Copy` handle to a `DirInfo` slot in the BSSMap singleton.
Expand Down
9 changes: 0 additions & 9 deletions src/resolver/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,15 +701,6 @@ impl bun_dotenv::DirEntryProbe for DirEntry {
}
}

// pub fn statBatch(fs: *FileSystemEntry, paths: []string) ![]?Stat {
// }
// pub fn stat(fs: *FileSystemEntry, path: string) !Stat {
// }
// pub fn readFile(fs: *FileSystemEntry, path: string) ?string {
// }
// pub fn readDir(fs: *FileSystemEntry, path: string) ?[]string {
// }

#[derive(Default, Clone, Copy)]
pub struct ModKey {
pub(crate) size: u64,
Expand Down
3 changes: 0 additions & 3 deletions src/runtime/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,6 @@ pub enum Error {
StandaloneGraph(#[from] bun_standalone_graph::Error),
#[error(transparent)]
TerminalInit(crate::api::bun_terminal_body::InitError),
#[error(transparent)]
DirIterator(#[from] crate::node::dir_iterator::IteratorError),
#[error("JSError")]
Js(bun_jsc::JsError),
}
Expand Down Expand Up @@ -826,7 +824,6 @@ impl Error {
Self::Sourcemap(e) => e.name(),
Self::StandaloneGraph(e) => e.name(),
Self::TerminalInit(e) => <&'static str>::from(e),
Self::DirIterator(e) => <&'static str>::from(e),
Self::Js(bun_jsc::JsError::OutOfMemory) => "OutOfMemory",
Self::Js(_) => "JSError",
}
Expand Down
11 changes: 0 additions & 11 deletions src/runtime/node/dir_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@ use bun_sys::{self as sys, Fd, Tag};
// `bun_sys::EntryKind` (and as `crate::node::types::DirentKind`).
use bun_sys::EntryKind;

#[derive(thiserror::Error, strum::IntoStaticStr, Debug, Clone, Copy, PartialEq, Eq)]
pub enum IteratorError {
#[error("AccessDenied")]
AccessDenied,
#[error("SystemResources")]
SystemResources,
/// posix.UnexpectedError
#[error("Unexpected")]
Unexpected,
}

pub struct IteratorResult {
/// `RawSlice` invariant: borrows the iterator's `getdents` buffer
/// (streaming-iterator contract — invalidated on next `next()` call).
Expand Down
11 changes: 0 additions & 11 deletions src/runtime/node/node_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4527,12 +4527,6 @@ pub enum StatOrNotFound {
NotFound,
}
impl StatOrNotFound {
pub fn to_js(&mut self, global_object: &JSGlobalObject) -> JsResult<JSValue> {
match self {
StatOrNotFound::Stats(s) => s.to_js_newly_created(global_object),
StatOrNotFound::NotFound => Ok(JSValue::UNDEFINED),
}
}
pub(crate) fn to_js_newly_created(&self, global_object: &JSGlobalObject) -> JsResult<JSValue> {
match self {
StatOrNotFound::Stats(s) => s.to_js_newly_created(global_object),
Expand All @@ -4558,11 +4552,6 @@ impl StringOrUndefined {

/// For use in `Return`'s definitions to act as `void` while returning `null` to JavaScript
pub struct Null;
impl Null {
pub fn to_js(&self, _: &JSGlobalObject) -> JSValue {
JSValue::NULL
}
}

pub mod ret {
use super::*;
Expand Down
4 changes: 0 additions & 4 deletions src/runtime/node/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1359,10 +1359,6 @@ pub struct VectorArrayBuffer {
}

impl VectorArrayBuffer {
pub fn to_js(&self, _: &JSGlobalObject) -> JSValue {
self.value
}

/// Release the per-element roots and pins taken by `from_js(.., pin: true)`.
/// Must run on the JS thread, exactly once, after the I/O completes.
pub(crate) fn release(&mut self) {
Expand Down
3 changes: 0 additions & 3 deletions src/runtime/server/RequestContext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3161,7 +3161,6 @@ where
this.run_error_handler(js_err);
return;
}
// .InlineBlob,
Body::Value::WTFStringImpl(_) | Body::Value::InternalBlob(_) | Body::Value::Blob(_) => {
// toBlobIfPossible checks for WTFString needing a conversion.
this.blob = value.use_as_any_blob_allow_non_utf8_string();
Expand Down Expand Up @@ -4089,8 +4088,6 @@ where

let total = bytes.len() + chunk.len();
'getter: {
// TODO: small-body fast path via InlineBlob is not
// implemented; always build an InternalBlob.
// Vec aborts on OOM (repo-wide abort-on-OOM policy).
bytes.reserve_exact(total.saturating_sub(bytes.len()));
bytes.extend_from_slice(chunk);
Expand Down
49 changes: 0 additions & 49 deletions src/runtime/webcore/Blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6869,55 +6869,6 @@ impl Internal {
}
}

// ──────────────────────────────────────────────────────────────────────────
// Inline (InlineBlob)
// ──────────────────────────────────────────────────────────────────────────

/// A blob which stores all the data in the same space as a real Blob
/// This is an optimization for small Response and Request bodies
#[repr(C, packed)]
pub struct Inline {
pub(crate) bytes: [u8; Inline::AVAILABLE_BYTES],
pub(crate) len: u8,
pub(crate) was_string: bool,
}

impl Inline {
const REAL_BLOB_SIZE: usize = core::mem::size_of::<Blob>();
// Inherent assoc types are nightly-only;
// the int-size alias is hoisted to module-level `InlineIntSize` above.
pub(crate) const AVAILABLE_BYTES: usize =
Self::REAL_BLOB_SIZE - core::mem::size_of::<u8>() - 1 - 1;

pub fn concat(first: &[u8], second: &[u8]) -> Inline {
let total = first.len() + second.len();
debug_assert!(total <= Self::AVAILABLE_BYTES);

let mut inline_blob = Inline::default();
let bytes_slice = &mut inline_blob.bytes[..total];

if !first.is_empty() {
bytes_slice[..first.len()].copy_from_slice(first);
}
if !second.is_empty() {
bytes_slice[first.len()..][..second.len()].copy_from_slice(second);
}

inline_blob.len = total as u8;
inline_blob
}
}

impl Default for Inline {
fn default() -> Self {
Self {
bytes: [0; Self::AVAILABLE_BYTES],
len: 0,
was_string: false,
}
}
}

// ──────────────────────────────────────────────────────────────────────────
// JSDOMFile__hasInstance / FileOpener / FileCloser
// ──────────────────────────────────────────────────────────────────────────
Expand Down
Loading
Loading