Skip to content
Open
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
8 changes: 0 additions & 8 deletions src/bun_core/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5068,14 +5068,6 @@ pub enum TimespecMockMode {
ForceRealTime,
}

/// `bun_core::timespec_mode::Mode` namespace shim —
/// Rust can't do inherent associated types stably, so expose a module
/// instead. Callers write `bun_core::timespec_mode::AllowMockedTime` or use
/// the `Timespec::now_allow_mocked_time()` helper.
pub mod timespec_mode {
pub use super::TimespecMockMode::*;
}

/// Mocked-time storage. The data lives at T0 so `Timespec::now` reads it
/// directly; the test-runner (`useFakeTimers`) writes via `set`/`clear`
/// from `bun_runtime::test_runner::timers::FakeTimers::CurrentTime`.
Expand Down
2 changes: 1 addition & 1 deletion src/bundler/Chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ fn alloc_buf(_arena: DynAlloc, n: usize) -> Result<Vec<u8>, AllocError> {
fn additional_output_file_index(f: &AdditionalFile) -> usize {
match *f {
AdditionalFile::OutputFile(i) => i as usize,
AdditionalFile::SourceIndex(_) => {
AdditionalFile::SourceIndex => {
unreachable!("asset additional_files entry must be .output_file")
}
}
Expand Down
15 changes: 6 additions & 9 deletions src/bundler/OutputFile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub enum Value {
Copy(FileOperation),
Noop,
Buffer { bytes: Box<[u8]> },
Saved(SavedFile),
Saved,
}

impl Value {
Expand Down Expand Up @@ -142,22 +142,19 @@ impl Value {
noop,
)
}
Value::Copy(_) | Value::Saved(_) => {
Value::Copy(_) | Value::Saved => {
bun_core::todo_panic!("to_bun_string_ref: Copy/Saved")
}
}
}
}

#[derive(Default, Clone, Copy)]
pub struct SavedFile {}

pub enum OptionsData {
Buffer {
// arena dropped — global mimalloc.
data: Box<[u8]>,
},
Saved(usize),
Saved,
}

pub struct Options {
Expand Down Expand Up @@ -185,7 +182,7 @@ impl OutputFile {
pub(crate) fn init(options: Options) -> OutputFile {
let size = options.size.unwrap_or(match &options.data {
OptionsData::Buffer { data } => data.len(),
OptionsData::Saved(_) => 0,
OptionsData::Saved => 0,
});
let owned_src_path_text: Box<[u8]> = options.input_path;
// SAFETY: `owned_src_path_text` is a sibling field that outlives `src_path`; the boxed buffer never moves.
Expand All @@ -208,7 +205,7 @@ impl OutputFile {
is_executable: options.is_executable,
value: match options.data {
OptionsData::Buffer { data } => Value::Buffer { bytes: data },
OptionsData::Saved(_) => Value::Saved(SavedFile::default()),
OptionsData::Saved => Value::Saved,
},
side: options.side,
entry_point_index: options.entry_point_index,
Expand All @@ -223,7 +220,7 @@ impl OutputFile {
pub fn write_to_disk(&self, root_dir: Fd) -> Result<(), Error> {
match &self.value {
Value::Noop => {}
Value::Saved(_) => {
Value::Saved => {
// already written to disk
}
Value::Buffer { bytes } => {
Expand Down
28 changes: 9 additions & 19 deletions src/bundler/bundle_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2772,8 +2772,7 @@ pub mod bv2_impl {
let additional_files: &mut bun_alloc::AstVec<crate::AdditionalFile> =
&mut self.graph.input_files.items_additional_files_mut()
[source_index.get() as usize];
additional_files
.push(crate::AdditionalFile::SourceIndex(task.source_index.get()));
additional_files.push(crate::AdditionalFile::SourceIndex);
self.graph.input_files.items_side_effects_mut()[source_index.get() as usize] =
bun_ast::SideEffects::NoSideEffectsPureData;
self.graph.estimated_file_loader_count += 1;
Expand Down Expand Up @@ -2884,8 +2883,7 @@ pub mod bv2_impl {
let additional_files: &mut bun_alloc::AstVec<crate::AdditionalFile> =
&mut self.graph.input_files.items_additional_files_mut()
[source_index.get() as usize];
additional_files
.push(crate::AdditionalFile::SourceIndex(task.source_index.get()));
additional_files.push(crate::AdditionalFile::SourceIndex);
self.graph.input_files.items_side_effects_mut()[source_index.get() as usize] =
bun_ast::SideEffects::NoSideEffectsPureData;
self.graph.estimated_file_loader_count += 1;
Expand Down Expand Up @@ -3751,8 +3749,7 @@ pub mod bv2_impl {
let additional_files: &mut bun_alloc::AstVec<crate::AdditionalFile> =
&mut self.graph.input_files.items_additional_files_mut()
[source_index.get() as usize];
additional_files
.push(crate::AdditionalFile::SourceIndex(task.source_index.get()));
additional_files.push(crate::AdditionalFile::SourceIndex);
self.graph.input_files.items_side_effects_mut()[source_index.get() as usize] =
bun_ast::SideEffects::NoSideEffectsPureData;
self.graph.estimated_file_loader_count += 1;
Expand Down Expand Up @@ -3849,7 +3846,7 @@ pub mod bv2_impl {
let additional_files: &mut bun_alloc::AstVec<crate::AdditionalFile> =
&mut self.graph.input_files.items_additional_files_mut()
[source_index.get() as usize];
additional_files.push(crate::AdditionalFile::SourceIndex(source_index.get()));
additional_files.push(crate::AdditionalFile::SourceIndex);
self.graph.input_files.items_side_effects_mut()[source_index.get() as usize] =
bun_ast::SideEffects::NoSideEffectsPureData;
self.graph.estimated_file_loader_count += 1;
Expand Down Expand Up @@ -4622,8 +4619,7 @@ pub mod bv2_impl {
let additional_files: &mut bun_alloc::AstVec<crate::AdditionalFile> =
&mut this.graph.input_files.items_additional_files_mut()
[source_index.get() as usize];
let _ = additional_files
.push(crate::AdditionalFile::SourceIndex(source_index.get()));
let _ = additional_files.push(crate::AdditionalFile::SourceIndex);
this.graph.input_files.items_side_effects_mut()
[source_index.get() as usize] =
bun_ast::SideEffects::NoSideEffectsPureData;
Expand Down Expand Up @@ -5010,9 +5006,7 @@ pub mod bv2_impl {
crate::AdditionalFile,
> = &mut this.graph.input_files.items_additional_files_mut()
[source_index.get() as usize];
additional_files.push(crate::AdditionalFile::SourceIndex(
task.source_index.get(),
));
additional_files.push(crate::AdditionalFile::SourceIndex);
this.graph.input_files.items_side_effects_mut()
[source_index.get() as usize] =
bun_ast::SideEffects::NoSideEffectsPureData;
Expand Down Expand Up @@ -5394,7 +5388,7 @@ pub mod bv2_impl {
b"metafile.md".as_slice()
}),
output_path: Box::<[u8]>::from(file_path),
data: crate::output_file::OptionsData::Saved(content.len()),
data: crate::output_file::OptionsData::Saved,
output_kind,
is_executable: false,
side: None,
Expand Down Expand Up @@ -6920,9 +6914,7 @@ pub mod bv2_impl {
let additional_files: &mut bun_alloc::AstVec<crate::AdditionalFile> =
&mut self.graph.input_files.items_additional_files_mut()
[importer_source_index as usize];
additional_files.push(crate::AdditionalFile::SourceIndex(
new_task.source_index.get(),
));
additional_files.push(crate::AdditionalFile::SourceIndex);
self.graph.input_files.items_side_effects_mut()
[new_task.source_index.get() as usize] =
bun_ast::SideEffects::NoSideEffectsPureData;
Expand All @@ -6932,12 +6924,10 @@ pub mod bv2_impl {
self.graph.pool().schedule(new_task);
} else {
if loader.should_copy_for_bundling() {
// SAFETY: value_ptr is valid (see above).
let existing_idx = unsafe { *value_ptr };
let additional_files: &mut bun_alloc::AstVec<crate::AdditionalFile> =
&mut self.graph.input_files.items_additional_files_mut()
[importer_source_index as usize];
additional_files.push(crate::AdditionalFile::SourceIndex(existing_idx));
additional_files.push(crate::AdditionalFile::SourceIndex);
self.graph.estimated_file_loader_count += 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/bundler/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ pub use thread_pool::{ThreadPool, Worker};
/// See `transpiler`.
pub use transpiler::Transpiler;
pub enum AdditionalFile {
SourceIndex(u32),
SourceIndex,
OutputFile(u32),
}

Expand Down
14 changes: 7 additions & 7 deletions src/bundler/linker_context/writeOutputFilesToDisk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::linker_context_mod::debug;
use crate::options::{self, Loader, OutputFile, SourceMapOption};
use crate::output_file::{
BakeExtra, Index as OutputFileIndex, IndexOptional, Options as OutputFileInit,
OptionsData as OutputFileData, SavedFile, Value as OutputFileValue,
OptionsData as OutputFileData, Value as OutputFileValue,
};
use crate::{BundleV2, Chunk, cheap_prefix_normalizer};

Expand Down Expand Up @@ -152,7 +152,7 @@ pub(crate) fn write_output_files_to_disk(
input_loader: Loader::File,
output_kind: options::OutputKind::Sourcemap,
size: Some(output_source_map.len()),
data: OutputFileData::Saved(0),
data: OutputFileData::Saved,
side: Some(options::Side::Client),
entry_point_index: None,
is_executable: false,
Expand All @@ -172,7 +172,7 @@ pub(crate) fn write_output_files_to_disk(
};

let _ = output_files.insert_for_chunk(OutputFile::init(OutputFileInit {
data: OutputFileData::Saved(0),
data: OutputFileData::Saved,
hash: None,
loader: chunk.content.loader(),
input_path: Box::default(),
Expand Down Expand Up @@ -348,7 +348,7 @@ pub(crate) fn write_output_files_to_disk(
input_loader: Loader::File,
output_kind: options::OutputKind::Sourcemap,
size: Some(output_source_map.len()),
data: OutputFileData::Saved(0),
data: OutputFileData::Saved,
side: Some(options::Side::Client),
entry_point_index: None,
is_executable: false,
Expand Down Expand Up @@ -476,7 +476,7 @@ pub(crate) fn write_output_files_to_disk(
loader: Loader::File,
size: Some(bytecode.len()),
display_size: bytecode.len() as u32,
data: OutputFileData::Saved(0),
data: OutputFileData::Saved,
side: None,
entry_point_index: None,
is_executable: false,
Expand Down Expand Up @@ -558,7 +558,7 @@ pub(crate) fn write_output_files_to_disk(
size: Some(code_result.buffer.len()),
display_size: display_size as u32,
is_executable: chunk.flags.contains(ChunkFlags::IS_EXECUTABLE),
data: OutputFileData::Saved(0),
data: OutputFileData::Saved,
side: Some(if matches!(chunk.content, Content::Css(_)) {
options::Side::Client
} else {
Expand Down Expand Up @@ -673,7 +673,7 @@ pub(crate) fn write_output_files_to_disk(
let bytes_len = bytes.len();
drop(bytes);
*dest = core::mem::replace(src, OutputFile::zero_value());
dest.value = OutputFileValue::Saved(SavedFile::default());
dest.value = OutputFileValue::Saved;
dest.size = bytes_len;
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/exe_format/macho_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
// Canonical `<mach-o/loader.h>` POD layouts live in `bun_sys::macho` (lower-tier
// crate, also consumed by `crash_handler`). Re-export so `exe_format::macho`
// keeps its existing `macho::segment_command_64` etc. paths.
pub use bun_sys::macho::{
cpu_subtype_t, cpu_type_t, load_command, mach_header_64, segment_command_64, vm_prot_t,
};
pub use bun_sys::macho::{cpu_type_t, mach_header_64, segment_command_64, vm_prot_t};

pub(crate) const CPU_TYPE_ARM64: cpu_type_t = 0x0100_000C;

Expand Down Expand Up @@ -193,7 +191,7 @@ unsafe impl bytemuck::NoUninit for SuperBlob {}
// ── load-command iterator ─────────────────────────────────────────────────
// Canonical impl lives in `bun_sys::macho` (raw-ptr storage; see module-level
// SAFETY note above for why a borrowed `&[u8]` does not work for `macho.rs`).
pub use bun_sys::macho::{LoadCommand, LoadCommandIterator, RawSlice};
pub use bun_sys::macho::LoadCommandIterator;

#[inline]
fn parse_name(name: &[u8; 16]) -> &[u8] {
Expand Down
1 change: 0 additions & 1 deletion src/install/PackageManager/PackageManagerEnqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,6 @@ pub fn enqueue_package_for_download(
}

pub enum DependencyToEnqueue {
Pending(DependencyID),
Resolution {
package_id: PackageID,
resolution: Resolution,
Expand Down
1 change: 0 additions & 1 deletion src/install/auto_installer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,6 @@ impl hooks::AutoInstaller for PackageManager {
package_id,
resolution: resolution_to_hooks(&resolution),
},
enqueue::DependencyToEnqueue::Pending(id) => hooks::EnqueueResult::Pending(id),
enqueue::DependencyToEnqueue::NotFound => hooks::EnqueueResult::NotFound,
enqueue::DependencyToEnqueue::Failure(e) => hooks::EnqueueResult::Failure(e.into()),
}
Expand Down
1 change: 0 additions & 1 deletion src/install_types/resolver_hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,6 @@ pub enum EnqueueResult {
package_id: PackageID,
resolution: Resolution,
},
Pending(DependencyID),
NotFound,
Failure(bun_core::Error),
}
Expand Down
6 changes: 0 additions & 6 deletions src/js/builtins/BunBuiltinNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ using namespace JSC;
macro(_owner) \
macro(_store) \
macro(abort) \
macro(addAbortAlgorithmToSignal) \
macro(arrayBuffer) \
macro(asUint8Array) \
macro(atimeMs) \
Expand All @@ -64,7 +63,6 @@ using namespace JSC;
macro(createCommonJSModule) \
macro(createFIFO) \
macro(createInternalModuleById) \
macro(createUninitializedArrayBuffer) \
macro(ctimeMs) \
macro(data) \
macro(decode) \
Expand Down Expand Up @@ -104,7 +102,6 @@ using namespace JSC;
macro(internalMessage) \
macro(internalModuleRegistry) \
macro(internalRequire) \
macro(isAbortSignal) \
macro(isAbsolute) \
macro(isUncloneable) \
macro(isUntransferable) \
Expand All @@ -117,9 +114,7 @@ using namespace JSC;
macro(loadEsmIntoCjs) \
macro(main) \
macro(makeAbortError) \
macro(makeDOMException) \
macro(makeErrorWithCode) \
macro(makeGetterTypeError) \
macro(maxAge) \
macro(metafileJson) \
macro(method) \
Expand Down Expand Up @@ -155,7 +150,6 @@ using namespace JSC;
macro(readableType) \
macro(redirect) \
macro(relative) \
macro(removeAbortAlgorithmFromSignal) \
macro(require) \
macro(requireESM) \
macro(requireMap) \
Expand Down
Loading
Loading