Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
1 change: 0 additions & 1 deletion src/bun_core/env_var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ pub mod feature_flag {
new_feature_flag!(pub BUN_FEATURE_FLAG_DISABLE_STANDALONE_MADVISE, "BUN_FEATURE_FLAG_DISABLE_STANDALONE_MADVISE", {});
new_feature_flag!(pub BUN_DISABLE_TRANSPILED_SOURCE_CODE_PREVIEW, "BUN_DISABLE_TRANSPILED_SOURCE_CODE_PREVIEW", {});
new_feature_flag!(pub BUN_FEATURE_FLAG_DISABLE_UV_FS_COPYFILE, "BUN_FEATURE_FLAG_DISABLE_UV_FS_COPYFILE", {});
Comment thread
robobun marked this conversation as resolved.
Resolved
new_feature_flag!(pub BUN_DUMP_STATE_ON_CRASH, "BUN_DUMP_STATE_ON_CRASH", {});
new_feature_flag!(pub BUN_ENABLE_EXPERIMENTAL_SHELL_BUILTINS, "BUN_ENABLE_EXPERIMENTAL_SHELL_BUILTINS", {});
new_feature_flag!(pub BUN_FEATURE_FLAG_EXPERIMENTAL_BAKE, "BUN_FEATURE_FLAG_EXPERIMENTAL_BAKE", {});
// Offer "h2" in the fetch() TLS ALPN list and speak HTTP/2 when the
Expand Down
11 changes: 0 additions & 11 deletions src/bun_core/string/immutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,17 +606,6 @@ pub fn split_once<'a>(self_: &'a [u8], delimiter: &[u8]) -> Option<(&'a [u8], &'
Some((&self_[..i], &self_[i + delimiter.len()..]))
Comment thread
robobun marked this conversation as resolved.
Resolved
}

/// `str::rsplit_once` for bytes with a multi-byte delimiter. An empty
/// delimiter never matches.
#[inline]
pub fn rsplit_once<'a>(self_: &'a [u8], delimiter: &[u8]) -> Option<(&'a [u8], &'a [u8])> {
if delimiter.is_empty() {
return None;
}
let i = last_index_of(self_, delimiter)?;
Some((&self_[..i], &self_[i + delimiter.len()..]))
}

pub struct SplitIterator<'a> {
pub(crate) buffer: &'a [u8],
pub(crate) index: Option<usize>,
Expand Down
53 changes: 10 additions & 43 deletions src/jsc/ConsoleObject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5872,42 +5872,6 @@ pub(crate) extern "C" fn Bun__ConsoleObject__timeLog(
let _ = bun_io::Write::flush(&mut writer);
}

/// Stamp out the empty `Bun__ConsoleObject__*` C-ABI hooks that JSC's
/// `ConsoleClient` vtable requires but Bun leaves unimplemented. Two arms cover
/// the two trailing-arg shapes the C++ side declares in
/// `bindings/headers.h:686-694`: `(…, *const u8, usize)` for the title-string
/// hooks and `(…, *mut ScriptArguments)` for the inspector-args hooks.
///
/// Ident concat via `${concat()}` is unstable (`macro_metavar_expr_concat`)
/// and `paste` is not a `bun_jsc` dep, so the full `Bun__ConsoleObject__<name>`
/// export symbol is passed verbatim — same pattern as `export_callbacks!` in
/// `runtime/api/BunObject.rs`.
macro_rules! console_noop_hooks {
(str: $($name:ident),+ $(,)?) => {$(
#[unsafe(no_mangle)]
#[crate::host_call]
pub extern "C" fn $name(
_console: *mut ConsoleObject,
_global: &JSGlobalObject,
_chars: *const u8,
_len: usize,
) {
}
)+};
(args: $($name:ident),+ $(,)?) => {$(
#[unsafe(no_mangle)]
#[crate::host_call]
pub extern "C" fn $name(
_console: *mut ConsoleObject,
_global: &JSGlobalObject,
_args: *mut ScriptArguments,
) {
}
)+};
}

console_noop_hooks!(str: Bun__ConsoleObject__profile, Bun__ConsoleObject__profileEnd);

#[unsafe(no_mangle)]
#[crate::host_call]
pub(crate) extern "C" fn Bun__ConsoleObject__takeHeapSnapshot(
Expand All @@ -5931,13 +5895,16 @@ pub(crate) extern "C" fn Bun__ConsoleObject__takeHeapSnapshot(
}
}

console_noop_hooks!(
args:
Bun__ConsoleObject__timeStamp,
Bun__ConsoleObject__record,
Bun__ConsoleObject__recordEnd,
Bun__ConsoleObject__screenshot,
);
/// `console.timeStamp()` is a no-op: JSC's `ConsoleClient` requires the hook,
/// Bun leaves it unimplemented.
Comment thread
robobun marked this conversation as resolved.
Resolved
#[unsafe(no_mangle)]
#[crate::host_call]
pub(crate) extern "C" fn Bun__ConsoleObject__timeStamp(
_console: *mut ConsoleObject,
_global: &JSGlobalObject,
_args: *mut ScriptArguments,
) {
}

#[unsafe(no_mangle)]
#[crate::host_call]
Expand Down
24 changes: 0 additions & 24 deletions src/jsc/FetchHeaders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ unsafe extern "C" {
arg3: *const EncodedSlice,
arg4: u32,
) -> *mut FetchHeaders;
fn WebCore__FetchHeaders__createValue(
arg0: *const JSGlobalObject,
arg1: *mut StringPointer,
arg2: *mut StringPointer,
arg3: *const EncodedSlice,
arg4: u32,
) -> JSValue;
// safe: `FetchHeaders` is an `opaque_ffi!` ZST handle; `&mut` is ABI-identical
// to a non-null `*mut` and the C++ refcount decrement is interior to the cell.
safe fn WebCore__FetchHeaders__deref(arg0: &mut FetchHeaders);
Expand Down Expand Up @@ -148,23 +141,6 @@ impl FetchHeaders {
})
}

/// Like [`create`](Self::create) but wrapped as a JS `Headers`. The C++
/// side returns the wrapper even after `fill` threw, so the exception state
/// is checked explicitly.
pub fn from(
global: &JSGlobalObject,
names: *mut StringPointer,
values: *mut StringPointer,
buf: &EncodedSlice,
count_: u32,
) -> JsResult<JSValue> {
// SAFETY: forwarding caller-provided buffers to C++; `global` is an opaque ZST handle
// passed by address only.
crate::call_check_slow(global, || unsafe {
WebCore__FetchHeaders__createValue(global, names, values, buf, count_)
})
}

pub fn is_empty(&mut self) -> bool {
WebCore__FetchHeaders__isEmpty(self)
}
Expand Down
14 changes: 2 additions & 12 deletions src/jsc/JSGlobalObject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use crate::bun_string_jsc::{ErrorKind, error_instance};
use crate::error_code::ErrorBuilder;
use crate::virtual_machine::VirtualMachine;
use crate::{
CommonStrings, DOMExceptionCode, ErrorableString, Exception, JSValue, JsError, JsResult,
MAX_SAFE_INTEGER, MIN_SAFE_INTEGER, VM,
CommonStrings, DOMExceptionCode, ErrorableString, JSValue, JsError, JsResult, MAX_SAFE_INTEGER,
MIN_SAFE_INTEGER, VM,
};
use bun_core::EncodedSlice;
use bun_core::StringView;
Expand Down Expand Up @@ -1431,16 +1431,6 @@ extern "C" fn Zig__GlobalObject__resolve(
}
}

#[unsafe(no_mangle)]
unsafe extern "C" fn Zig__GlobalObject__reportUncaughtException(
global: *const JSGlobalObject,
exception: *mut Exception,
) -> JSValue {
crate::mark_binding();
// SAFETY: C++ passes valid non-null pointers.
unsafe { VirtualMachine::report_uncaught_exception(&*global, &*exception) }
}

#[unsafe(no_mangle)]
extern "C" fn Zig__GlobalObject__onCrash() {
crate::mark_binding();
Expand Down
6 changes: 0 additions & 6 deletions src/jsc/VM.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,6 @@ impl VM {
JSC__VM__terminationException(self)
}

/// Has termination been requested on this VM (worker.terminate(), or
/// teardown's forbidExecution)? JS thread.
pub fn has_termination_request(&self) -> bool {
crate::cpp::JSC__VM__hasTerminationRequest(self)
}

#[track_caller]
pub fn throw_error(&self, global_object: &JSGlobalObject, value: JSValue) -> JsError {
crate::validation_scope!(scope, global_object);
Expand Down
10 changes: 0 additions & 10 deletions src/jsc/VirtualMachine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5434,16 +5434,6 @@ impl VirtualMachine {
false
}

/// Reports an uncaught exception through the owning VM's handler; returns `undefined`.
pub(crate) fn report_uncaught_exception(
global_object: &JSGlobalObject,
exception: &Exception,
) -> JSValue {
let jsc_vm = global_object.bun_vm().as_mut();
let _ = jsc_vm.uncaught_exception(global_object, exception.value(), false);
JSValue::UNDEFINED
}

/// Note: takes a runtime bool + concrete writer.
pub(crate) fn print_stack_trace(
writer: &mut bun_core::io::Writer,
Expand Down
5 changes: 0 additions & 5 deletions src/jsc/array_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -999,11 +999,6 @@ impl MarkedArrayBuffer {
// `no_mangle` dropped: 0 C++ refs (phase_c_exports.rs mention is a comment).
pub use bun_alloc::c_thunks::mi_free_bytes as MarkedArrayBuffer_deallocator;

// LAYERING: `BlobArrayBuffer_deallocator` releases a
// `Blob::Store` ref. `Store` is a `bun_runtime` type, so the `#[no_mangle]`
// export lives next to it at `bun_runtime::webcore::blob::Store` — `bun_jsc`
// cannot own this symbol without a dep cycle. C++ links by name only.

// ──────────────────────────────────────────────────────────────────────────
// Free functions
// ──────────────────────────────────────────────────────────────────────────
Expand Down
12 changes: 0 additions & 12 deletions src/jsc/bindings/DOMFormData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,6 @@ Ref<DOMFormData> DOMFormData::create(ScriptExecutionContext* context, const Stri
return newFormData;
}

String DOMFormData::toURLEncodedString()
{
WTF::URLParser::URLEncodedForm form;
form.reserveInitialCapacity(m_items.size());
for (auto& item : m_items) {
if (auto value = std::get_if<String>(&item.data))
form.append({ item.name, *value });
}

return WTF::URLParser::serialize(form);
}

extern "C" void DOMFormData__forEach(DOMFormData* form, void* context, void (*callback)(void* context, EncodedSlice*, void*, EncodedSlice*, uint8_t))
{
for (auto& item : form->items()) {
Expand Down
2 changes: 0 additions & 2 deletions src/jsc/bindings/DOMFormData.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ class DOMFormData : public RefCounted<DOMFormData>, public ContextDestructionObs
size_t count() const { return m_items.size(); }
size_t memoryCost() const;

String toURLEncodedString();

class Iterator {
public:
explicit Iterator(DOMFormData&);
Expand Down
2 changes: 0 additions & 2 deletions src/jsc/bindings/JSCommonJSModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,6 @@ JSC_DEFINE_CUSTOM_SETTER(setterPath,
return true;
}

extern "C" JSC::EncodedJSValue Resolver__propForRequireMainPaths(JSGlobalObject*);

JSC_DEFINE_CUSTOM_GETTER(getterPaths, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName))
{
auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
Expand Down
9 changes: 0 additions & 9 deletions src/jsc/bindings/NapiRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,4 @@ void NapiRef::unref()
}
}

void NapiRef::clear()
{
NAPI_LOG("ref clear %p", this);
finalizer.call(env.ptr(), nativeObject);
globalObject.clear();
weakValueRef.clear();
strongRef.clear();
}

}
2 changes: 0 additions & 2 deletions src/jsc/bindings/ZigGlobalObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@

using namespace Bun;

BUN_DECLARE_HOST_FUNCTION(Bun__NodeUtil__jsParseArgs);

JSC_DECLARE_HOST_FUNCTION(jsFunctionMakeAbortError);

using JSGlobalObject = JSC::JSGlobalObject;
Expand Down
47 changes: 0 additions & 47 deletions src/jsc/bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2610,28 +2610,6 @@ WebCore::FetchHeaders* WebCore__FetchHeaders__createValueNotJS(JSC::JSGlobalObje
return headers;
}

JSC::EncodedJSValue WebCore__FetchHeaders__createValue(JSC::JSGlobalObject* arg0, StringPointer* arg1, StringPointer* arg2, const EncodedSlice* arg3, uint32_t count)
{
auto throwScope = DECLARE_THROW_SCOPE(arg0->vm());
Vector<KeyValuePair<String, String>> pairs;
pairs.reserveCapacity(count);
EncodedSlice buf = *arg3;
for (uint32_t i = 0; i < count; i++) {
WTF::String name = Zig::toStringCopy(buf, arg1[i]);
WTF::String value = Zig::toStringCopy(buf, arg2[i]);
pairs.unsafeAppendWithoutCapacityCheck(KeyValuePair<String, String>(name, value));
}

Ref<WebCore::FetchHeaders> headers = WebCore::FetchHeaders::create();
WebCore::propagateException(*arg0, throwScope, headers->fill(WebCore::FetchHeaders::Init(WTF::move(pairs))));

JSValue value = WebCore::toJSNewlyCreated(arg0, static_cast<Zig::GlobalObject*>(arg0), WTF::move(headers));

JSFetchHeaders* fetchHeaders = uncheckedDowncast<JSFetchHeaders>(value);
fetchHeaders->computeMemoryCost();
return JSC::JSValue::encode(fetchHeaders);
}

void WebCore__FetchHeaders__get_(WebCore::FetchHeaders* headers, const EncodedSlice* arg1, EncodedSlice* arg2, JSC::JSGlobalObject* global)
{
auto throwScope = DECLARE_THROW_SCOPE(global->vm());
Expand Down Expand Up @@ -5152,12 +5130,6 @@ bool JSC__VM__isTerminationException(JSC::VM* vm, JSC::Exception* exception)
return vm->isTerminationException(exception);
}

[[ZIG_EXPORT(nothrow)]]
bool JSC__VM__hasTerminationRequest(JSC::VM* vm)
{
return vm->hasTerminationRequest();
}

// The one crossing from the loop-level stop into the exception currency: a nested wait/drain inside a
// host function learned of a stop and must hand a JsError to its caller, so it throws the VM's
// TerminationException for real -- what VMTraps::handleTraps(NeedTermination) does. Always leaves it
Expand Down Expand Up @@ -6387,16 +6359,6 @@ CPP_DECL size_t WebCore__DOMFormData__count(WebCore::DOMFormData* arg0)
return arg0->count();
}

extern "C" void DOMFormData__toQueryString(
DOMFormData* formData,
void* ctx,
void (*callback)(void* ctx, EncodedSlice* encoded))
{
auto str = formData->toURLEncodedString();
EncodedSlice encoded = toEncodedSlice(str);
callback(ctx, &encoded);
}

CPP_DECL JSC::EncodedJSValue WebCore__DOMFormData__createFromURLQuery(JSC::JSGlobalObject* arg0, const EncodedSlice* arg1)
{
Zig::GlobalObject* globalObject = static_cast<Zig::GlobalObject*>(arg0);
Expand Down Expand Up @@ -6646,15 +6608,6 @@ CPP_DECL [[ZIG_EXPORT(nothrow)]] void JSC__SourceProvider__deref(JSC::SourceProv
provider->deref();
}

CPP_DECL bool Bun__CallFrame__isFromBunMain(JSC::CallFrame* callFrame, JSC::VM* vm)
{
auto source = callFrame->callerSourceOrigin(*vm);

if (source.isNull())
return false;
return source.string() == "builtin://bun/main"_s;
}

CPP_DECL void Bun__CallFrame__getCallerSrcLoc(JSC::CallFrame* callFrame, JSC::JSGlobalObject* globalObject, BunString* outSourceURL, unsigned int* outLine, unsigned int* outColumn)
{
auto& vm = JSC::getVM(globalObject);
Expand Down
7 changes: 0 additions & 7 deletions src/jsc/bindings/headers.h

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

1 change: 0 additions & 1 deletion src/jsc/bindings/napi.h
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,6 @@ class NapiRef {
public:
void ref();
void unref();
void clear();

NapiRef(Ref<NapiEnv>&& env, uint32_t count, Bun::NapiFinalizer finalizer)
: env(env)
Expand Down
2 changes: 1 addition & 1 deletion src/jsc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! Those targets live in `bun_runtime`, which depends on this crate —
//! re-exporting them here would create a cycle. Callers reference
//! `bun_runtime::{webcore,api,node}` directly; lower-tier consumers that
//! constructed those types (e.g. `output_file_jsc`, `BlobArrayBuffer_deallocator`)
//! constructed those types (e.g. `output_file_jsc`)
//! have been moved up into `bun_runtime`, and the few that only need an opaque
//! borrow (e.g. `DOMFormData::for_each`) are generic over the caller's `Blob`.

Expand Down
7 changes: 0 additions & 7 deletions src/jsc/resolver_jsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ fn node_module_paths_for_js(global: &JSGlobalObject, frame: &CallFrame) -> JsRes
Ok(node_module_paths_js_value(&in_str, global, false))
}

#[unsafe(no_mangle)]
extern "C" fn Resolver__propForRequireMainPaths(global: &JSGlobalObject) -> JSValue {
crate::mark_binding!();

node_module_paths_js_value(&BunString::static_("."), global, false)
}

// C++ callers pass a borrowed `const BunString*` (`Bun::toString`).
#[unsafe(export_name = "Resolver__nodeModulePathsJSValue")]
extern "C" fn node_module_paths_js_value(
Expand Down
Loading
Loading