diff --git a/src/ast/transpiler_cache.rs b/src/ast/transpiler_cache.rs index 9d7bab38d65f..30da9841bdd9 100644 --- a/src/ast/transpiler_cache.rs +++ b/src/ast/transpiler_cache.rs @@ -53,16 +53,15 @@ bun_dispatch::link_interface! { pub TranspilerCacheImpl[Jsc] { fn get(source: &Source, parser_options: NonNull<()>, used_jsx: bool) -> bool; fn put(output_code: &[u8], sourcemap: &[u8], esm_record: &[u8]); - fn is_disabled() -> bool; } } impl RuntimeTranspilerCache { /// Build the dispatch handle for the set-once `r#impl` slot. /// - /// Centralises the raw-pointer obligation so the three public entry + /// Centralises the raw-pointer obligation so the two public entry /// points below stay safe. - /// `this` is always derived from a live `&self` / `&mut self` in those + /// `this` is always derived from a live `&mut self` in those /// callers and the returned `Copy` handle is consumed immediately, so /// the `link_interface!` liveness contract (owner valid for every /// dispatch through the handle) is upheld. @@ -70,8 +69,7 @@ impl RuntimeTranspilerCache { fn handle(kind: TranspilerCacheImplKind, this: *mut Self) -> TranspilerCacheImpl { // SAFETY: `this` is non-null, aligned, and live for the immediate // dispatch at every call site (`get`/`put`: `&mut self`-derived with - // write provenance; `is_disabled`: `&self`-derived, impl ignores - // `this`). See `link_interface!` `new()` contract. + // write provenance). See `link_interface!` `new()` contract. unsafe { TranspilerCacheImpl::new(kind, this) } } diff --git a/src/bun_alloc/lib.rs b/src/bun_alloc/lib.rs index d99683419c75..eca0308a58a2 100644 --- a/src/bun_alloc/lib.rs +++ b/src/bun_alloc/lib.rs @@ -1031,12 +1031,8 @@ impl WTFStringImplStruct { // `AtomicU32`; see doc comment above. unsafe { AtomicU32::from_ptr(self.m_ref_count.as_ptr()) } } - /// Inline port of `WTF::StringImpl::ref()` (StringImpl.h:1181). - /// - /// Cross-language LTO does not inline the `Bun__WTFStringImpl__ref` C++ - /// shim into Rust callers (2151 out-of-line `callq` sites in the release - /// binary), so the one-instruction body is reimplemented here. - /// `Relaxed` matches WebKit's + /// Inline port of `WTF::StringImpl::ref()` (StringImpl.h:1181); `Relaxed` + /// matches WebKit's /// `m_refCount.fetch_add(s_refCountIncrement, std::memory_order_relaxed)`. #[inline] pub fn r#ref(&self) { @@ -1136,9 +1132,6 @@ unsafe extern "C" { // `destroy` path crosses FFI. `*const` + `unsafe`: it frees the // allocation backing the pointer. pub fn Bun__WTFStringImpl__destroy(this: *const WTFStringImplStruct); - // Rust no longer calls these. - pub safe fn Bun__WTFStringImpl__ref(this: &WTFStringImplStruct); - pub fn Bun__WTFStringImpl__deref(this: *const WTFStringImplStruct); safe fn WTFStringImpl__isThreadSafe(this: &WTFStringImplStruct) -> bool; safe fn Bun__WTFStringImpl__ensureHash(this: &WTFStringImplStruct); } diff --git a/src/bun_core/lib.rs b/src/bun_core/lib.rs index 7a6664d9e134..a8b3a75b0a41 100644 --- a/src/bun_core/lib.rs +++ b/src/bun_core/lib.rs @@ -589,10 +589,6 @@ impl OutputSink { bun_dispatch::link_interface! { pub ErrnoNames[Sys] { fn name(errno: i32) -> Option<&'static str>; - fn max_dense() -> u32; - // Raw Win32 `GetLastError()` code → `SystemErrno` tag name. - // Always `None` on non-Windows. - fn win32_name(code: u32) -> Option<&'static str>; } } diff --git a/src/bun_core/string/mod.rs b/src/bun_core/string/mod.rs index 2e7a65b21b08..7bfa9619e373 100644 --- a/src/bun_core/string/mod.rs +++ b/src/bun_core/string/mod.rs @@ -1707,8 +1707,6 @@ pub enum ZigStringSlice { Owned(Vec), /// Backed by a WTFStringImpl ref; Drop derefs it. Stored as raw ptr to /// avoid wtf-module cycle; `wtf::to_latin1_slice` constructs this. - /// `*const` because we only ever hand it back to `Bun__WTFStringImpl__deref` - /// (which takes `*const`); refcount mutation happens on the C++ side. WTF { string_impl: *const wtf::WTFStringImplStruct, bytes: RawSlice, diff --git a/src/bun_core/util.rs b/src/bun_core/util.rs index 1e90288ed229..7e072399a23f 100644 --- a/src/bun_core/util.rs +++ b/src/bun_core/util.rs @@ -5311,8 +5311,6 @@ pub mod perf { unsafe extern "C" { /// No preconditions; returns 0/1 based on tracefs availability. pub safe fn Bun__linux_trace_init() -> core::ffi::c_int; - /// No preconditions. - pub safe fn Bun__linux_trace_close(); pub fn Bun__linux_trace_emit( event_name: *const core::ffi::c_char, duration_ns: i64, diff --git a/src/codegen/generate-jssink.ts b/src/codegen/generate-jssink.ts index 5555d32e7e59..00383910c32a 100644 --- a/src/codegen/generate-jssink.ts +++ b/src/codegen/generate-jssink.ts @@ -176,8 +176,6 @@ function header() { void finishCreation(JSC::VM&); }; -JSC_DECLARE_CUSTOM_GETTER(function${name}__getter); - `; } @@ -368,13 +366,6 @@ JSC_DEFINE_HOST_FUNCTION(${name}__unref, (JSC::JSGlobalObject * lexicalGlobalObj } -JSC_DEFINE_CUSTOM_GETTER(function${name}__getter, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) -{ - Zig::GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); - - return JSC::JSValue::encode(globalObject->${name}()); -} - size_t ${className}::estimatedSize(JSCell* cell, JSC::VM& vm) { return Base::estimatedSize(cell, vm) + ${className}::memoryCost(uncheckedDowncast<${className}>(cell)->wrapped()); } diff --git a/src/errno/lib.rs b/src/errno/lib.rs index 09e327f8bf72..dd53c1fc800a 100644 --- a/src/errno/lib.rs +++ b/src/errno/lib.rs @@ -375,41 +375,11 @@ fn system_errno_name(errno: i32) -> Option<&'static str> { } } -/// Length of the dense `0..MAX` prefix of `SystemErrno` (on Windows, the -/// dense head before the sparse UV_* range). Exposed so bun_core can pre-seed its -/// interned `ERRNO_MAP` without a second hand-written per-OS length table. -#[inline] -const fn system_errno_max_dense() -> u32 { - SystemErrno::MAX as u32 -} - -/// Raw Win32 `GetLastError()` code → `SystemErrno` tag name, via the -/// `Win32Error` mapping table. Restores `error.code` fidelity (ENOENT, -/// EACCES, ...) for `?`-propagated `std::io::Error`s on Windows. Exists on all -/// platforms because the `ErrnoNames` link-interface is platform-independent; -/// always `None` off Windows. -#[inline] -fn win32_errno_name(code: u32) -> Option<&'static str> { - #[cfg(windows)] - { - let code = u16::try_from(code).ok()?; - SystemErrno::init_win32_error(windows_errno::Win32Error::from_raw(code)) - .map(<&'static str>::from) - } - #[cfg(not(windows))] - { - let _ = code; - None - } -} - // Wire the above into bun_core's `ErrnoNames` hook. `()` owner — pure -// stateless functions; the handle is the const `ErrnoNames::SYS`. +// stateless function; the handle is the const `ErrnoNames::SYS`. bun_core::link_impl_ErrnoNames! { Sys for () => |_this| { name(errno) => system_errno_name(errno), - max_dense() => system_errno_max_dense(), - win32_name(code) => win32_errno_name(code), } } @@ -450,7 +420,7 @@ mod errno_name_tests { fn errno_table_full_range() { // Slot 0 is the SUCCESS hole. assert_eq!(system_errno_name(0), None); - let max = system_errno_max_dense(); + let max = SystemErrno::MAX as u32; for i in 1..max { let name = system_errno_name(i as i32).expect("dense slot"); assert_eq!( @@ -482,25 +452,18 @@ mod errno_name_tests { assert_eq!(system_errno_name(97), Some("EINTEGRITY")); } - /// `win32_errno_name` translation contract: known `GetLastError()` codes - /// map to POSIX names on Windows, unmapped/out-of-range codes are `None`, - /// and the helper is a constant `None` off Windows. + #[cfg(windows)] #[test] fn win32_errno_names() { - #[cfg(windows)] - { - // ERROR_FILE_NOT_FOUND / ERROR_ACCESS_DENIED. - assert_eq!(win32_errno_name(2), Some("ENOENT")); - assert_eq!(win32_errno_name(5), Some("EPERM")); - // Unmapped Win32 code and the `u16::try_from` overflow fallback. - assert_eq!(win32_errno_name(0), None); - assert_eq!(win32_errno_name(u32::MAX), None); - } - #[cfg(not(windows))] - { - assert_eq!(win32_errno_name(2), None); - assert_eq!(win32_errno_name(u32::MAX), None); - } + let name = |code: u16| { + SystemErrno::init_win32_error(windows_errno::Win32Error::from_raw(code)) + .map(<&'static str>::from) + }; + // ERROR_FILE_NOT_FOUND / ERROR_ACCESS_DENIED. + assert_eq!(name(2), Some("ENOENT")); + assert_eq!(name(5), Some("EPERM")); + assert_eq!(name(0), None); + assert_eq!(name(u16::MAX), None); } #[test] diff --git a/src/errno/windows_errno.rs b/src/errno/windows_errno.rs index a0f2dd6254ca..497836febdd8 100644 --- a/src/errno/windows_errno.rs +++ b/src/errno/windows_errno.rs @@ -617,6 +617,8 @@ impl SystemErrnoInit for Win32Error { } impl SystemErrno { + /// Length of the dense head of the enum; the sparse `UV_*` range follows. + #[cfg(test)] pub(crate) const MAX: usize = 138; /// Windows' libuv-mapped errno set spells this `ENOTSUP`; alias the POSIX diff --git a/src/event_loop/lib.rs b/src/event_loop/lib.rs index 08a31e32cfb4..939751fe8169 100644 --- a/src/event_loop/lib.rs +++ b/src/event_loop/lib.rs @@ -47,17 +47,12 @@ pub use any_event_loop::{ bun_dispatch::link_interface! { pub JsEventLoop[Jsc] { fn iteration_number() -> u64; - fn file_polls() -> *mut bun_io::file_poll::Store; - fn put_file_poll(poll: *mut bun_io::FilePoll, was_ever_registered: bool); fn uws_loop() -> *mut bun_uws::Loop; - fn pipe_read_buffer() -> *mut [u8]; fn tick(); fn auto_tick(); fn auto_tick_active(); fn global_object() -> *mut (); fn bun_vm() -> *mut (); - fn stdout() -> *mut (); - fn stderr() -> *mut (); fn enter(); fn exit(); fn enqueue_task(task: Task); diff --git a/src/http_jsc/websocket_client.rs b/src/http_jsc/websocket_client.rs index 11e08e93961c..fa4a309c3db9 100644 --- a/src/http_jsc/websocket_client.rs +++ b/src/http_jsc/websocket_client.rs @@ -18,7 +18,7 @@ use bun_collections::linear_fifo::DynamicBuffer; use bun_core::{ZigString, strings}; use bun_http::websocket::{Opcode, WebsocketHeader}; use bun_io::KeepAlive; -use bun_jsc::{self as jsc, GlobalRef, JSGlobalObject, JSValue}; +use bun_jsc::{self as jsc, GlobalRef, JSGlobalObject}; use bun_ptr::{AsCtxPtr, ThisPtr}; use bun_uws::{self as uws, NewSocketHandler, SslCtx, us_bun_verify_error_t}; use bun_uws_sys::us_socket_t; @@ -1357,43 +1357,6 @@ impl WebSocket { !tcp.is_closed() && !tcp.is_shutdown() } - // `extern "C"` entrypoint; `this_ptr` is non-null by C++ contract (see SAFETY comments below). - #[allow(clippy::not_unsafe_ptr_arg_deref)] - pub(crate) extern "C" fn write_blob(this_ptr: *mut Self, blob_value: JSValue, op: u8) { - // See write_binary_data() — tunnel.write() can re-enter fail(). - // SAFETY: called from C++ with a valid `heap::alloc` pointer; ScopedRef - // bumps the intrusive refcount and derefs on Drop (after `this`'s last - // use, since `this` is declared after the guard). - let _guard = unsafe { bun_ptr::ScopedRef::new(this_ptr) }; - // SAFETY: called from C++ with a valid pointer; guarded above. - let this = unsafe { &*this_ptr }; - - if !this.has_tcp() || op > 0xF { - this.dispatch_abrupt_close(ErrorCode::Ended); - return; - } - - // Cast the JSValue to a Blob. - // `bun_jsc::webcore::Blob` is an opaque C-ABI shim (real - // layout lives in `bun_runtime::webcore::Blob`, a higher-tier crate). - // `from_js`/`shared_view` trampoline through extern fns to avoid the - // dep cycle — see `bun_jsc::webcore::Blob` impl block. - let Some(blob) = blob_value.as_::() else { - this.dispatch_abrupt_close(ErrorCode::Ended); - return; - }; - let opcode = Opcode::from_raw(op); - // SAFETY: `as_` returned a live `*mut Blob` owned by the JS heap; - // the JSValue is rooted by the caller for the duration of this call. - let data = unsafe { (*blob).shared_view() }; - if data.is_empty() { - let _ = this.send_data(Copy::Bytes(&[]), !this.has_backpressure(), opcode); - return; - } - - this.send_frame(Copy::Bytes(data), data.len(), opcode); - } - // `extern "C"` entrypoint; pointers are valid by C++ contract (see SAFETY comments below). #[allow(clippy::not_unsafe_ptr_arg_deref)] pub(crate) extern "C" fn write_string(this_ptr: *mut Self, str_: *const ZigString, op: u8) { @@ -1854,7 +1817,6 @@ macro_rules! export_websocket_client { init_with_tunnel = $init_with_tunnel:ident, memory_cost = $memory_cost:ident, write_binary_data = $write_binary_data:ident, - write_blob = $write_blob:ident, write_string = $write_string:ident $(,)? ) => { #[unsafe(no_mangle)] @@ -1925,10 +1887,6 @@ macro_rules! export_websocket_client { WebSocket::<$ssl>::write_binary_data(this, ptr, len, op) } #[unsafe(no_mangle)] - pub extern "C" fn $write_blob(this: *mut WebSocket<$ssl>, blob_value: JSValue, op: u8) { - WebSocket::<$ssl>::write_blob(this, blob_value, op) - } - #[unsafe(no_mangle)] pub extern "C" fn $write_string( this: *mut WebSocket<$ssl>, str_: *const ZigString, @@ -1949,7 +1907,6 @@ export_websocket_client!( init_with_tunnel = Bun__WebSocketClient__initWithTunnel, memory_cost = Bun__WebSocketClient__memoryCost, write_binary_data = Bun__WebSocketClient__writeBinaryData, - write_blob = Bun__WebSocketClient__writeBlob, write_string = Bun__WebSocketClient__writeString, ); export_websocket_client!( @@ -1962,7 +1919,6 @@ export_websocket_client!( init_with_tunnel = Bun__WebSocketClientTLS__initWithTunnel, memory_cost = Bun__WebSocketClientTLS__memoryCost, write_binary_data = Bun__WebSocketClientTLS__writeBinaryData, - write_blob = Bun__WebSocketClientTLS__writeBlob, write_string = Bun__WebSocketClientTLS__writeString, ); diff --git a/src/js/internal/repl/node-inspect.js b/src/js/internal/repl/node-inspect.js index 7e7a9c635599..763d21a0f012 100644 --- a/src/js/internal/repl/node-inspect.js +++ b/src/js/internal/repl/node-inspect.js @@ -1,8 +1,8 @@ // Shim for Node's `internal/util/inspect` as consumed by the ported // node:repl / internal/readline stack. getStringWidth/stripVTControlCharacters // go straight to the native bindings so `require("node:readline")` does not -// pull in the 99 KB internal/util/inspect; inspect/format load it lazily on -// first access (REPL output / completion rendering). +// pull in the 99 KB internal/util/inspect; inspect loads it lazily on first +// access (REPL output / completion rendering). const stripANSI = Bun.stripANSI; const nativeStringWidth = $newCppFunction("stringWidth.cpp", "jsFunctionBunStringWidth", 1); @@ -31,10 +31,4 @@ export default { get inspect() { return load().inspect; }, - get format() { - return load().format; - }, - get formatWithOptions() { - return load().formatWithOptions; - }, }; diff --git a/src/js/internal/repl/node-shims.js b/src/js/internal/repl/node-shims.js index 2744fee8d3e2..41ba036fb007 100644 --- a/src/js/internal/repl/node-shims.js +++ b/src/js/internal/repl/node-shims.js @@ -116,15 +116,6 @@ const BuiltinModule = { // Bare names; completion.js prefixes them with "node:" itself. return ["test"]; }, - exists(id) { - return Module.isBuiltin(id); - }, - canBeRequiredByUsers(id) { - return Module.isBuiltin(id); - }, - canBeRequiredWithoutScheme(id) { - return Module.isBuiltin(id) && Module.isBuiltin("node:" + id); - }, }; // ---- internal/modules/esm/get_format ---------------------------------------------- @@ -388,8 +379,6 @@ export default { // internalBinding('util') constants: { ALL_PROPERTIES, - ONLY_ENUMERABLE, - SKIP_STRINGS, SKIP_SYMBOLS, }, getOwnNonIndexProperties, diff --git a/src/jsc/ConsoleObject.rs b/src/jsc/ConsoleObject.rs index a9270cf88662..c21724aab064 100644 --- a/src/jsc/ConsoleObject.rs +++ b/src/jsc/ConsoleObject.rs @@ -5957,42 +5957,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__` -/// 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( @@ -6016,13 +5980,14 @@ pub(crate) extern "C" fn Bun__ConsoleObject__takeHeapSnapshot( } } -console_noop_hooks!( - args: - Bun__ConsoleObject__timeStamp, - Bun__ConsoleObject__record, - Bun__ConsoleObject__recordEnd, - Bun__ConsoleObject__screenshot, -); +#[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] diff --git a/src/jsc/FetchHeaders.rs b/src/jsc/FetchHeaders.rs index 5f019f49bd6e..c812b634f381 100644 --- a/src/jsc/FetchHeaders.rs +++ b/src/jsc/FetchHeaders.rs @@ -47,13 +47,6 @@ unsafe extern "C" { arg3: *const ZigString, arg4: u32, ) -> *mut FetchHeaders; - fn WebCore__FetchHeaders__createValue( - arg0: *const JSGlobalObject, - arg1: *mut StringPointer, - arg2: *mut StringPointer, - arg3: *const ZigString, - 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); @@ -147,18 +140,6 @@ impl FetchHeaders { NonNull::new(p) } - pub fn from( - global: &JSGlobalObject, - names: *mut StringPointer, - values: *mut StringPointer, - buf: &ZigString, - count_: u32, - ) -> JSValue { - // SAFETY: forwarding caller-provided buffers to C++; `global` is an opaque ZST handle - // passed by address only. - unsafe { WebCore__FetchHeaders__createValue(global, names, values, buf, count_) } - } - pub fn is_empty(&mut self) -> bool { WebCore__FetchHeaders__isEmpty(self) } diff --git a/src/jsc/JSBigInt.rs b/src/jsc/JSBigInt.rs index bc614d35ab00..18d207cfc60a 100644 --- a/src/jsc/JSBigInt.rs +++ b/src/jsc/JSBigInt.rs @@ -12,8 +12,6 @@ unsafe extern "C" { // safe: `JSValue` is a by-value tagged i64; returns a nullable GC-cell // pointer the caller checks before deref. safe fn JSC__JSBigInt__fromJS(value: JSValue) -> *mut JSBigInt; - safe fn JSC__JSBigInt__orderDouble(this: &JSBigInt, num: f64) -> i8; - safe fn JSC__JSBigInt__orderUint64(this: &JSBigInt, num: u64) -> i8; safe fn JSC__JSBigInt__orderInt64(this: &JSBigInt, num: i64) -> i8; safe fn JSC__JSBigInt__toInt64(this: &JSBigInt) -> i64; safe fn JSC__JSBigInt__toString(this: &JSBigInt, global: &JSGlobalObject) -> BunString; @@ -24,21 +22,6 @@ pub trait BigIntOrderable: Copy { fn raw_order(self, this: &JSBigInt) -> i8; } -impl BigIntOrderable for f64 { - #[inline] - fn raw_order(self, this: &JSBigInt) -> i8 { - debug_assert!(!self.is_nan()); - JSC__JSBigInt__orderDouble(this, self) - } -} - -impl BigIntOrderable for u64 { - #[inline] - fn raw_order(self, this: &JSBigInt) -> i8 { - JSC__JSBigInt__orderUint64(this, self) - } -} - impl BigIntOrderable for i64 { #[inline] fn raw_order(self, this: &JSBigInt) -> i8 { diff --git a/src/jsc/JSCScheduler.rs b/src/jsc/JSCScheduler.rs index 05d553ac6ddb..4d43123fca07 100644 --- a/src/jsc/JSCScheduler.rs +++ b/src/jsc/JSCScheduler.rs @@ -72,17 +72,3 @@ unsafe extern "C" fn Bun__queueJSCDeferredWorkTaskConcurrently( unsafe { JSCDeferredWorkTask::destroy(task) }; } } - -/// # Safety -/// `paused` must point to a live `bool`; C++ writes `true` through it from a -/// callback inside `tick()`. -#[unsafe(no_mangle)] -unsafe extern "C" fn Bun__tickWhilePaused(paused: *mut bool) { - crate::mark_binding!(); - // SAFETY: see fn contract. - unsafe { - VirtualMachine::get() - .event_loop_mut() - .tick_while_paused(paused.cast_const()); - } -} diff --git a/src/jsc/JSValue.rs b/src/jsc/JSValue.rs index ed019c91c606..788960d72792 100644 --- a/src/jsc/JSValue.rs +++ b/src/jsc/JSValue.rs @@ -425,7 +425,7 @@ impl JSValue { /// `jsType()` — only valid when `is_cell()`. Reads the JSCell type byte. /// - /// Source-inlined body of `JSC__JSValue__jsType` (bindings.cpp:2755) so the + /// Inlined in Rust (rather than an FFI shim into bindings.cpp) so the /// 2-insn fast path survives no-LTO targets (e.g. aarch64-musl, where /// cross-language LTO is disabled — config.ts:631). With the FFI shim the /// call cannot inline into Rust callers and shows up as a separate symbol; diff --git a/src/jsc/RuntimeTranspilerCache.rs b/src/jsc/RuntimeTranspilerCache.rs index 3373c1402e99..d56016f18ca2 100644 --- a/src/jsc/RuntimeTranspilerCache.rs +++ b/src/jsc/RuntimeTranspilerCache.rs @@ -1074,6 +1074,5 @@ bun_ast::link_impl_TranspilerCacheImpl! { bun_core::scoped_log!(cache, "put() = {}", err.name()); } }, - is_disabled() => RuntimeTranspilerCache::is_disabled(), } } diff --git a/src/jsc/ZigException.rs b/src/jsc/ZigException.rs index 7852d6f5d457..d4484ee13dee 100644 --- a/src/jsc/ZigException.rs +++ b/src/jsc/ZigException.rs @@ -79,11 +79,6 @@ impl ZigException { } } - // `ZigException__fromException` is declared in headers.h but has no C++ - // body (bindings.cpp dropped it; the only producer is - // `JSC__JSValue__toZigException` which writes through an out-param), so - // there is intentionally no `from_exception` here. - pub(crate) fn add_to_error_list( &mut self, error_list: &mut Vec, diff --git a/src/jsc/array_buffer.rs b/src/jsc/array_buffer.rs index e21dff3f6457..44a9ab25dca3 100644 --- a/src/jsc/array_buffer.rs +++ b/src/jsc/array_buffer.rs @@ -964,11 +964,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 // ────────────────────────────────────────────────────────────────────────── diff --git a/src/jsc/bindings/BunDebugger.cpp b/src/jsc/bindings/BunDebugger.cpp index 4dc13cd2a11a..b287323c2bde 100644 --- a/src/jsc/bindings/BunDebugger.cpp +++ b/src/jsc/bindings/BunDebugger.cpp @@ -22,8 +22,6 @@ #include "InspectorBunFrontendDevServerAgent.h" #include "InspectorHTTPServerAgent.h" -extern "C" void Bun__tickWhilePaused(bool*); - namespace Bun { using namespace JSC; using namespace WebCore; @@ -630,7 +628,6 @@ extern "C" unsigned int Bun__createJSDebugger(Zig::GlobalObject* globalObject) return static_cast(globalObject->scriptExecutionContext()->identifier()); } -extern "C" void Bun__tickWhilePaused(bool*); extern "C" void Bun__ensureDebugger(ScriptExecutionContextIdentifier scriptId, bool pauseOnStart) { diff --git a/src/jsc/bindings/BunString.cpp b/src/jsc/bindings/BunString.cpp index 282d142f820f..c52d14c4699a 100644 --- a/src/jsc/bindings/BunString.cpp +++ b/src/jsc/bindings/BunString.cpp @@ -45,14 +45,6 @@ using namespace JSC; extern "C" BunString BunString__fromBytes(const char* bytes, size_t length); -extern "C" [[ZIG_EXPORT(nothrow)]] void Bun__WTFStringImpl__deref(WTF::StringImpl* impl) -{ - impl->deref(); -} -extern "C" [[ZIG_EXPORT(nothrow)]] void Bun__WTFStringImpl__ref(WTF::StringImpl* impl) -{ - impl->ref(); -} // Cold path for the Rust-side inlined `deref()`: caller has already brought // the refcount to zero via `fetch_sub`, so this is destroy-only. extern "C" [[ZIG_EXPORT(nothrow)]] void Bun__WTFStringImpl__destroy(WTF::StringImpl* impl) diff --git a/src/jsc/bindings/JSBigIntBinding.cpp b/src/jsc/bindings/JSBigIntBinding.cpp index 18ab3b569c29..e1c69d7ad7c6 100644 --- a/src/jsc/bindings/JSBigIntBinding.cpp +++ b/src/jsc/bindings/JSBigIntBinding.cpp @@ -16,39 +16,6 @@ extern "C" JSBigInt* JSC__JSBigInt__fromJS(EncodedJSValue encodedValue) return nullptr; } -extern "C" int8_t JSC__JSBigInt__orderDouble(JSBigInt* bigInt, double num) -{ - ASSERT(!std::isnan(num)); - JSBigInt::ComparisonResult result = JSBigInt::compareToDouble(bigInt, num); - - switch (result) { - case JSBigInt::ComparisonResult::Equal: - return 0; - case JSBigInt::ComparisonResult::GreaterThan: - return 1; - case JSBigInt::ComparisonResult::LessThan: - return -1; - case JSBigInt::ComparisonResult::Undefined: - UNREACHABLE(); - } -} - -extern "C" int8_t JSC__JSBigInt__orderUint64(JSBigInt* bigInt, uint64_t num) -{ - JSBigInt::ComparisonResult result = JSBigInt::compare(bigInt, num); - - switch (result) { - case JSBigInt::ComparisonResult::Equal: - return 0; - case JSBigInt::ComparisonResult::GreaterThan: - return 1; - case JSBigInt::ComparisonResult::LessThan: - return -1; - case JSBigInt::ComparisonResult::Undefined: - UNREACHABLE(); - } -} - extern "C" int8_t JSC__JSBigInt__orderInt64(JSBigInt* bigInt, int64_t num) { JSBigInt::ComparisonResult result = JSBigInt::compare(bigInt, num); diff --git a/src/jsc/bindings/JSEnvironmentVariableMap.cpp b/src/jsc/bindings/JSEnvironmentVariableMap.cpp index 108048b74051..9d1b007ad2f4 100644 --- a/src/jsc/bindings/JSEnvironmentVariableMap.cpp +++ b/src/jsc/bindings/JSEnvironmentVariableMap.cpp @@ -341,7 +341,6 @@ bool JSEnvironmentVariableMap::deleteProperty(JSCell* cell, JSGlobalObject* glob extern "C" int Bun__getTLSRejectUnauthorizedValue(); extern "C" int Bun__setTLSRejectUnauthorizedValue(int value); -extern "C" int Bun__getVerboseFetchValue(); extern "C" int Bun__setVerboseFetchValue(int value); ALWAYS_INLINE static Identifier NODE_TLS_REJECT_UNAUTHORIZED_PRIVATE_PROPERTY(VM& vm) diff --git a/src/jsc/bindings/ScriptExecutionContext.h b/src/jsc/bindings/ScriptExecutionContext.h index 25e3e4fb25dc..2ae60cd73e20 100644 --- a/src/jsc/bindings/ScriptExecutionContext.h +++ b/src/jsc/bindings/ScriptExecutionContext.h @@ -4,7 +4,6 @@ struct BunVmHandleRef; #include "SharedEnvStore.h" -#include #include #include #include @@ -126,14 +125,6 @@ class ScriptExecutionContext : public CanMakeWeakPtr, pu void postTask(EventLoopTask* task); void postTaskAfterYield(Function&& lambda); - template - void postCrossThreadTask(Arguments&&... arguments) - { - postTask([crossThreadTask = createCrossThreadTask(arguments...)](ScriptExecutionContext&) mutable { - crossThreadTask.performTask(); - }); - } - JSC::VM& vm() { return *m_vm; } ScriptExecutionContextIdentifier identifier() const { return m_identifier; } diff --git a/src/jsc/bindings/ZigGlobalObject.cpp b/src/jsc/bindings/ZigGlobalObject.cpp index 3022c09cafe3..725e4e171b45 100644 --- a/src/jsc/bindings/ZigGlobalObject.cpp +++ b/src/jsc/bindings/ZigGlobalObject.cpp @@ -234,7 +234,6 @@ using namespace Bun; -BUN_DECLARE_HOST_FUNCTION(Bun__NodeUtil__jsParseArgs); BUN_DECLARE_HOST_FUNCTION(BUN__HTTP2__getUnpackedSettings); BUN_DECLARE_HOST_FUNCTION(BUN__HTTP2_getPackedSettings); BUN_DECLARE_HOST_FUNCTION(BUN__HTTP2_assertSettings); @@ -2888,26 +2887,6 @@ void GlobalObject::finishCreation(VM& vm) ASSERT(classInfo()); } -JSC_DEFINE_CUSTOM_GETTER(JSDOMFileConstructor_getter, (JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, PropertyName)) -{ - Zig::GlobalObject* bunGlobalObject = uncheckedDowncast(globalObject); - return JSValue::encode( - bunGlobalObject->JSDOMFileConstructor()); -} - -JSC_DEFINE_CUSTOM_SETTER(JSDOMFileConstructor_setter, - (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, - JSC::EncodedJSValue value, JSC::PropertyName property)) -{ - if (JSValue::decode(thisValue) != globalObject) { - return false; - } - - auto& vm = JSC::getVM(globalObject); - globalObject->putDirect(vm, property, JSValue::decode(value), 0); - return true; -} - // `console.Console` or `import { Console } from 'console';` JSC_DEFINE_CUSTOM_GETTER(getConsoleConstructor, (JSGlobalObject * globalObject, EncodedJSValue thisValue, PropertyName property)) { @@ -3074,18 +3053,6 @@ EncodedJSValue GlobalObject::assignToStream(JSValue stream, JSValue controller) return JSC::JSValue::encode(result); } -JSC::JSObject* GlobalObject::navigatorObject() -{ - return this->m_navigatorObject.get(this); -} - -JSC_DEFINE_CUSTOM_GETTER(functionLazyNavigatorGetter, - (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, - JSC::PropertyName)) -{ - return JSC::JSValue::encode(static_cast(globalObject)->navigatorObject()); -} - JSC::GCClient::IsoSubspace* GlobalObject::subspaceForImpl(JSC::VM& vm) { return WebCore::subspaceForImpl( @@ -3101,11 +3068,6 @@ BUN_DECLARE_HOST_FUNCTION(WebCore__alert); BUN_DECLARE_HOST_FUNCTION(WebCore__prompt); BUN_DECLARE_HOST_FUNCTION(WebCore__confirm); -JSValue GlobalObject_getPerformanceObject(VM& vm, JSObject* globalObject) -{ - return uncheckedDowncast(globalObject)->performanceObject(); -} - JSValue GlobalObject_getGlobalThis(VM& vm, JSObject* globalObject) { return uncheckedDowncast(globalObject)->globalThis(); @@ -4183,17 +4145,6 @@ napi_env GlobalObject::makeNapiEnvForFFI() return &out.leakRef(); } -bool GlobalObject::hasNapiFinalizers() const -{ - for (const auto& env : m_napiEnvs) { - if (env->hasFinalizers()) { - return true; - } - } - - return false; -} - // `bun test --isolate`: the old global is about to be gcUnprotect()'d and // collected, but its NapiEnvs may outlive it — GC-enqueued NapiFinalizerTasks // hold Ref and run on the event loop while loading the *next* file. diff --git a/src/jsc/bindings/ZigGlobalObject.h b/src/jsc/bindings/ZigGlobalObject.h index 35a8a4f69ec6..06a76037591e 100644 --- a/src/jsc/bindings/ZigGlobalObject.h +++ b/src/jsc/bindings/ZigGlobalObject.h @@ -213,7 +213,6 @@ class GlobalObject : public Bun::GlobalScope { JSC::Structure* NapiClassStructure() const { return m_NapiClassStructure.getInitializedOnMainThread(this); } JSC::Structure* FileSinkStructure() const { return m_JSFileSinkClassStructure.getInitializedOnMainThread(this); } - JSC::JSObject* FileSink() const { return m_JSFileSinkClassStructure.constructorInitializedOnMainThread(this); } JSC::JSValue FileSinkPrototype() const { return m_JSFileSinkClassStructure.prototypeInitializedOnMainThread(this); } JSC::JSValue JSReadableFileSinkControllerPrototype() const { return m_JSFileSinkControllerPrototype.getInitializedOnMainThread(this); } @@ -235,30 +234,24 @@ class GlobalObject : public Bun::GlobalScope { JSC::JSValue JSReadableArrayBufferSinkControllerPrototype() const { return m_JSArrayBufferControllerPrototype.getInitializedOnMainThread(this); } JSC::Structure* HTTPResponseSinkStructure() const { return m_JSHTTPResponseSinkClassStructure.getInitializedOnMainThread(this); } - JSC::JSObject* HTTPResponseSink() { return m_JSHTTPResponseSinkClassStructure.constructorInitializedOnMainThread(this); } JSC::JSValue HTTPResponseSinkPrototype() const { return m_JSHTTPResponseSinkClassStructure.prototypeInitializedOnMainThread(this); } JSC::Structure* JSReadableHTTPResponseSinkController() { return m_JSHTTPResponseController.getInitializedOnMainThread(this); } JSC::Structure* HTTPSResponseSinkStructure() const { return m_JSHTTPSResponseSinkClassStructure.getInitializedOnMainThread(this); } - JSC::JSObject* HTTPSResponseSink() { return m_JSHTTPSResponseSinkClassStructure.constructorInitializedOnMainThread(this); } JSC::JSValue HTTPSResponseSinkPrototype() const { return m_JSHTTPSResponseSinkClassStructure.prototypeInitializedOnMainThread(this); } JSC::JSValue JSReadableHTTPSResponseSinkControllerPrototype() const { return m_JSHTTPSResponseControllerPrototype.getInitializedOnMainThread(this); } JSC::Structure* NetworkSinkStructure() const { return m_JSNetworkSinkClassStructure.getInitializedOnMainThread(this); } - JSC::JSObject* NetworkSink() { return m_JSNetworkSinkClassStructure.constructorInitializedOnMainThread(this); } JSC::JSValue NetworkSinkPrototype() const { return m_JSNetworkSinkClassStructure.prototypeInitializedOnMainThread(this); } JSC::Structure* H3ResponseSinkStructure() const { return m_JSH3ResponseSinkClassStructure.getInitializedOnMainThread(this); } - JSC::JSObject* H3ResponseSink() { return m_JSH3ResponseSinkClassStructure.constructorInitializedOnMainThread(this); } JSC::JSValue H3ResponseSinkPrototype() const { return m_JSH3ResponseSinkClassStructure.prototypeInitializedOnMainThread(this); } JSC::Structure* FetchRequestBodySinkStructure() const { return m_JSFetchRequestBodySinkClassStructure.getInitializedOnMainThread(this); } - JSC::JSObject* FetchRequestBodySink() { return m_JSFetchRequestBodySinkClassStructure.constructorInitializedOnMainThread(this); } JSC::JSValue FetchRequestBodySinkPrototype() const { return m_JSFetchRequestBodySinkClassStructure.prototypeInitializedOnMainThread(this); } JSC::JSValue JSReadableNetworkSinkControllerPrototype() const { return m_JSFetchTaskletChunkedRequestControllerPrototype.getInitializedOnMainThread(this); } JSC::Structure* HTMLRewriterSinkStructure() const { return m_JSHTMLRewriterSinkClassStructure.getInitializedOnMainThread(this); } - JSC::JSObject* HTMLRewriterSink() { return m_JSHTMLRewriterSinkClassStructure.constructorInitializedOnMainThread(this); } JSC::JSValue HTMLRewriterSinkPrototype() const { return m_JSHTMLRewriterSinkClassStructure.prototypeInitializedOnMainThread(this); } JSC::Structure* JSBufferListStructure() const { return m_JSBufferListClassStructure.getInitializedOnMainThread(this); } @@ -277,11 +270,9 @@ class GlobalObject : public Bun::GlobalScope { JSC::Structure* NodeVMSourceTextModuleStructure() const { return m_NodeVMSourceTextModuleClassStructure.getInitializedOnMainThread(this); } JSC::JSObject* NodeVMSourceTextModule() const { return m_NodeVMSourceTextModuleClassStructure.constructorInitializedOnMainThread(this); } - JSC::JSValue NodeVMSourceTextModulePrototype() const { return m_NodeVMSourceTextModuleClassStructure.prototypeInitializedOnMainThread(this); } JSC::Structure* NodeVMSyntheticModuleStructure() const { return m_NodeVMSyntheticModuleClassStructure.getInitializedOnMainThread(this); } JSC::JSObject* NodeVMSyntheticModule() const { return m_NodeVMSyntheticModuleClassStructure.constructorInitializedOnMainThread(this); } - JSC::JSValue NodeVMSyntheticModulePrototype() const { return m_NodeVMSyntheticModuleClassStructure.prototypeInitializedOnMainThread(this); } WebCore::JSStreamsRuntime* streamsRuntime() { return &m_streamsRuntime; } JSC::JSMap* requireMap() const { return m_requireMap.getInitializedOnMainThread(this); } @@ -291,8 +282,6 @@ class GlobalObject : public Bun::GlobalScope { JSC::Structure* callSiteStructure() const { return m_callSiteStructure.getInitializedOnMainThread(this); } - JSC::JSObject* performanceObject() const { return m_performanceObject.getInitializedOnMainThread(this); } - JSC::JSFunction* performMicrotaskVariadicFunction() const { return m_performMicrotaskVariadicFunction.getInitializedOnMainThread(this); } JSC::Structure* utilInspectOptionsStructure() const { return m_utilInspectOptionsStructure.getInitializedOnMainThread(this); } @@ -753,7 +742,6 @@ class GlobalObject : public Bun::GlobalScope { return m_memoryFootprintStructure.getInitializedOnMainThread(this); } - JSObject* navigatorObject(); JSFunction* nativeMicrotaskTrampoline() const { return m_nativeMicrotaskTrampoline.getInitializedOnMainThread(this); } String agentClusterID() const; @@ -842,7 +830,6 @@ class GlobalObject : public Bun::GlobalScope { WTF::Vector> m_napiEnvs; Ref makeNapiEnv(const napi_module&); napi_env makeNapiEnvForFFI(); - bool hasNapiFinalizers() const; void adoptNapiEnvsForTestIsolation(GlobalObject* oldGlobal); private: diff --git a/src/jsc/bindings/bindings.cpp b/src/jsc/bindings/bindings.cpp index c084a885ee86..536b13037078 100644 --- a/src/jsc/bindings/bindings.cpp +++ b/src/jsc/bindings/bindings.cpp @@ -1925,8 +1925,9 @@ std::optional specialObjectsDequal(JSC::JSGlobalObject* globalObject, Mark return std::nullopt; } -// The other combinations are instantiated by their uses in this file. This one is -// only reached from `Bun.deepEquals(a, b, true, true)` in BunObject.cpp. +// The other combinations are instantiated by their uses in this file. These two are +// only reached from `Bun.deepEquals(a, b)` / `Bun.deepEquals(a, b, true, true)` in BunObject.cpp. +template bool Bun__deepEquals(JSC::JSGlobalObject*, JSValue, JSValue, MarkedArgumentBuffer&, Vector, 16>&, ThrowScope&, bool); template bool Bun__deepEquals(JSC::JSGlobalObject*, JSValue, JSValue, MarkedArgumentBuffer&, Vector, 16>&, ThrowScope&, bool); /** @@ -2397,28 +2398,6 @@ WebCore::FetchHeaders* WebCore__FetchHeaders__createValueNotJS(JSC::JSGlobalObje return headers; } -JSC::EncodedJSValue WebCore__FetchHeaders__createValue(JSC::JSGlobalObject* arg0, StringPointer* arg1, StringPointer* arg2, const ZigString* arg3, uint32_t count) -{ - auto throwScope = DECLARE_THROW_SCOPE(arg0->vm()); - Vector> pairs; - pairs.reserveCapacity(count); - ZigString 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(name, value)); - } - - Ref headers = WebCore::FetchHeaders::create(); - WebCore::propagateException(*arg0, throwScope, headers->fill(WebCore::FetchHeaders::Init(WTF::move(pairs)))); - - JSValue value = WebCore::toJSNewlyCreated(arg0, static_cast(arg0), WTF::move(headers)); - - JSFetchHeaders* fetchHeaders = uncheckedDowncast(value); - fetchHeaders->computeMemoryCost(); - return JSC::JSValue::encode(fetchHeaders); -} - void WebCore__FetchHeaders__get_(WebCore::FetchHeaders* headers, const ZigString* arg1, ZigString* arg2, JSC::JSGlobalObject* global) { auto throwScope = DECLARE_THROW_SCOPE(global->vm()); @@ -2455,18 +2434,6 @@ WebCore::DOMURL* WebCore__DOMURL__cast_(JSC::EncodedJSValue JSValue0, JSC::VM* v return WebCoreCast(JSValue0); } -[[ZIG_EXPORT(nothrow)]] void WebCore__DOMURL__href_(WebCore::DOMURL* domURL, ZigString* arg1) -{ - const WTF::URL& href = domURL->href(); - *arg1 = Zig::toZigString(href.string()); -} -[[ZIG_EXPORT(nothrow)]] void WebCore__DOMURL__pathname_(WebCore::DOMURL* domURL, ZigString* arg1) -{ - const WTF::URL& href = domURL->href(); - const WTF::StringView& pathname = href.path(); - *arg1 = Zig::toZigString(pathname); -} - BunString WebCore__DOMURL__fileSystemPath(WebCore::DOMURL* arg0, int* errorCode) { const WTF::URL& url = arg0->href(); @@ -2847,57 +2814,6 @@ void JSC__JSObject__putRecord(JSC::JSObject* object, JSC::JSGlobalObject* global object->putDirect(global->vm(), ident, descriptor.value()); scope.release(); } -void JSC__JSValue__putRecord(JSC::EncodedJSValue objectValue, JSC::JSGlobalObject* global, ZigString* key, - ZigString* values, size_t valuesLen) -{ - JSC::JSValue objValue = JSC::JSValue::decode(objectValue); - JSC::JSObject* object = objValue.asCell()->getObject(); - auto scope = DECLARE_THROW_SCOPE(global->vm()); - auto ident = Zig::toIdentifier(*key, global); - JSC::PropertyDescriptor descriptor; - - descriptor.setEnumerable(1); - descriptor.setConfigurable(1); - descriptor.setWritable(1); - - if (valuesLen == 1) { - descriptor.setValue(JSC::jsString(global->vm(), Zig::toString(values[0]))); - } else { - - // Pre-convert all strings to JSValues before entering ObjectInitializationScope, - // since jsString() allocates GC cells which is not allowed inside the scope. - MarkedArgumentBuffer strings; - for (size_t i = 0; i < valuesLen; ++i) { - strings.append(JSC::jsString(global->vm(), Zig::toString(values[i]))); - } - - JSC::JSArray* array = nullptr; - { - JSC::ObjectInitializationScope initializationScope(global->vm()); - if ((array = JSC::JSArray::tryCreateUninitializedRestricted( - initializationScope, nullptr, - global->arrayStructureForIndexingTypeDuringAllocation(JSC::ArrayWithContiguous), - valuesLen))) { - - for (size_t i = 0; i < valuesLen; ++i) { - array->initializeIndexWithoutBarrier( - initializationScope, i, strings.at(i)); - } - } - } - - if (!array) { - JSC::throwOutOfMemoryError(global, scope); - return; - } - - descriptor.setValue(array); - } - - object->methodTable()->defineOwnProperty(object, global, ident, descriptor, true); - object->putDirect(global->vm(), ident, descriptor.value()); - scope.release(); -} JSC::JSPromise* JSC__JSValue__asInternalPromise(JSC::EncodedJSValue JSValue0) { @@ -2911,19 +2827,6 @@ JSC::JSPromise* JSC__JSValue__asPromise(JSC::EncodedJSValue JSValue0) return dynamicDowncast(value); } -JSC::EncodedJSValue JSC__JSValue__createInternalPromise(JSC::JSGlobalObject* globalObject) -{ - auto& vm = JSC::getVM(globalObject); - return JSC::JSValue::encode(JSC::JSPromise::create(vm, globalObject->promiseStructure())); -} - -void JSC__JSFunction__optimizeSoon(JSC::EncodedJSValue JSValue0) -{ - JSC::JSValue value = JSC::JSValue::decode(JSValue0); - - JSC::optimizeNextInvocation(value); -} - bool JSC__JSFunction__getSourceCode(JSC::EncodedJSValue JSValue0, ZigString* outSourceCode) { JSC::JSValue value = JSC::JSValue::decode(JSValue0); @@ -2966,16 +2869,6 @@ void JSC__JSValue__jsonStringifyFast(JSC::EncodedJSValue JSValue0, JSC::JSGlobal RETURN_IF_EXCEPTION(scope, ); *arg3 = Bun::toStringRef(str); } -unsigned char JSC__JSValue__jsType(JSC::EncodedJSValue JSValue0) -{ - JSC::JSValue jsValue = JSC::JSValue::decode(JSValue0); - // if the value is NOT a cell - // asCell will return an invalid pointer rather than a nullptr - if (jsValue.isCell()) - return jsValue.asCell()->type(); - - return 0; -} CPP_DECL JSC::JSString* JSC__jsTypeStringForValue(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value) { @@ -2983,14 +2876,6 @@ CPP_DECL JSC::JSString* JSC__jsTypeStringForValue(JSC::JSGlobalObject* globalObj return jsTypeStringForValue(globalObject, jsValue); } -JSC::EncodedJSValue JSC__JSPromise__asValue(JSC::JSPromise* arg0, JSC::JSGlobalObject* arg1) -{ - JSValue value = arg0; - ASSERT_WITH_MESSAGE(!value.isEmpty(), "JSPromise.asValue() called on a empty JSValue"); - ASSERT_WITH_MESSAGE(value.inherits(), "JSPromise::asValue() called on a non-promise object"); - return JSC::JSValue::encode(value); -} - JSC::JSPromise* JSC__JSPromise__create(JSC::JSGlobalObject* arg0) { return JSC::JSPromise::create(arg0->vm(), arg0->promiseStructure()); @@ -3007,28 +2892,6 @@ void JSC__JSValue___then(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1 } } -JSC::EncodedJSValue JSC__JSGlobalObject__getCachedObject(JSC::JSGlobalObject* globalObject, const ZigString* arg1) -{ - auto& vm = JSC::getVM(globalObject); - auto scope = DECLARE_THROW_SCOPE(vm); - WTF::String string = Zig::toString(*arg1); - auto symbol = vm.privateSymbolRegistry().symbolForKey(string); - JSC::Identifier ident = JSC::Identifier::fromUid(symbol); - JSC::JSValue result = globalObject->getIfPropertyExists(globalObject, ident); - RETURN_IF_EXCEPTION(scope, {}); - return JSC::JSValue::encode(result); -} - -JSC::EncodedJSValue JSC__JSGlobalObject__putCachedObject(JSC::JSGlobalObject* globalObject, const ZigString* arg1, JSC::EncodedJSValue JSValue2) -{ - auto& vm = JSC::getVM(globalObject); - WTF::String string = Zig::toString(*arg1); - auto symbol = vm.privateSymbolRegistry().symbolForKey(string); - JSC::Identifier ident = JSC::Identifier::fromUid(symbol); - globalObject->putDirect(vm, ident, JSC::JSValue::decode(JSValue2), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::DontEnum); - return JSValue2; -} - void JSC__JSGlobalObject__deleteModuleRegistryEntry(JSC::JSGlobalObject* global, ZigString* arg1) { const JSC::Identifier identifier = Zig::toIdentifier(*arg1, global); @@ -3075,11 +2938,6 @@ bool JSC__JSValue__isSameValue(JSC::EncodedJSValue JSValue0, JSC::EncodedJSValue return JSC::sameValue(globalObject, left, right); } -bool JSC__JSValue__deepEquals(JSC::EncodedJSValue JSValue0, JSC::EncodedJSValue JSValue1, JSC::JSGlobalObject* globalObject) -{ - return deepEqualsWrapperImpl(JSValue0, JSValue1, globalObject); -} - bool JSC__JSValue__jestDeepEquals(JSC::EncodedJSValue JSValue0, JSC::EncodedJSValue JSValue1, JSC::JSGlobalObject* globalObject) { return deepEqualsWrapperImpl(JSValue0, JSValue1, globalObject); @@ -3201,12 +3059,6 @@ extern "C" JSC::EncodedJSValue Bun__JSValue__call(JSC::JSGlobalObject* globalObj return JSC::JSValue::encode(result); } -// CPP_DECL size_t JSC__PropertyNameArray__length(JSC__PropertyNameArray* arg0); -// CPP_DECL const JSC__PropertyName* -// JSC__PropertyNameArray__next(JSC__PropertyNameArray* arg0, size_t arg1); -// CPP_DECL void JSC__PropertyNameArray__release(JSC__PropertyNameArray* arg0); -size_t JSC__JSObject__getArrayLength(JSC::JSObject* arg0) { return arg0->getArrayLength(); } - JSC::EncodedJSValue JSC__JSObject__getIndex(JSC::EncodedJSValue jsValue, JSC::JSGlobalObject* globalObject, uint32_t index) { @@ -3226,32 +3078,10 @@ JSC::EncodedJSValue JSC__JSValue__getDirectIndex(JSC::EncodedJSValue jsValue, JS return JSC::JSValue::encode(object->getDirectIndex(arg1, arg3)); } -JSC::EncodedJSValue JSC__JSObject__getDirect(JSC::JSObject* arg0, JSC::JSGlobalObject* arg1, - const ZigString* arg2) -{ - return JSC::JSValue::encode(arg0->getDirect(arg1->vm(), Zig::toIdentifier(*arg2, arg1))); -} -void JSC__JSObject__putDirect(JSC::JSObject* arg0, JSC::JSGlobalObject* arg1, const ZigString* key, - JSC::EncodedJSValue value) -{ - auto prop = Zig::toIdentifier(*key, arg1); - - arg0->putDirect(arg1->vm(), prop, JSC::JSValue::decode(value)); -} - #pragma mark - JSC::JSCell -JSC::JSObject* JSC__JSCell__getObject(JSC::JSCell* arg0) -{ - return arg0->getObject(); -} unsigned char JSC__JSCell__getType(JSC::JSCell* arg0) { return arg0->type(); } -JSC::JSObject* JSC__JSCell__toObject(JSC::JSCell* cell, JSC::JSGlobalObject* globalObject) -{ - return cell->toObject(globalObject); -} - #pragma mark - JSC::JSString void JSC__JSString__toZigString(JSC::JSString* arg0, JSC::JSGlobalObject* arg1, ZigString* arg2) @@ -3265,11 +3095,6 @@ void JSC__JSString__toZigString(JSC::JSString* arg0, JSC::JSGlobalObject* arg1, bool JSC__JSString__is8Bit(const JSC::JSString* arg0) { return arg0->is8Bit(); }; size_t JSC__JSString__length(const JSC::JSString* arg0) { return arg0->length(); } -JSC::JSObject* JSC__JSString__toObject(JSC::JSString* arg0, JSC::JSGlobalObject* arg1) -{ - return arg0->toObject(arg1); -} - #pragma mark - JSC::JSModuleLoader // JSC::EncodedJSValue @@ -3287,73 +3112,6 @@ extern "C" JSC::JSPromise* JSModuleLoader__import(JSC::JSGlobalObject* globalObj return promise; } -JSC::EncodedJSValue JSC__JSModuleLoader__evaluate(JSC::JSGlobalObject* globalObject, const unsigned char* arg1, - size_t arg2, const unsigned char* originUrlPtr, size_t originURLLen, const unsigned char* referrerUrlPtr, size_t referrerUrlLen, - JSC::EncodedJSValue JSValue5, JSC::EncodedJSValue* arg6) -{ - WTF::String src = WTF::String::fromUTF8(std::span { arg1, arg2 }).isolatedCopy(); - WTF::URL origin = WTF::URL::fileURLWithFileSystemPath(WTF::String::fromUTF8(std::span { originUrlPtr, originURLLen })).isolatedCopy(); - WTF::URL referrer = WTF::URL::fileURLWithFileSystemPath(WTF::String::fromUTF8(std::span { referrerUrlPtr, referrerUrlLen })).isolatedCopy(); - - auto& vm = JSC::getVM(globalObject); - - JSC::SourceCode sourceCode = JSC::makeSource( - src, JSC::SourceOrigin { origin }, JSC::SourceTaintedOrigin::Untainted, origin.fileSystemPath(), - WTF::TextPosition(), JSC::SourceProviderSourceType::Module); - globalObject->moduleLoader()->provideFetch(globalObject, JSC::Identifier::fromString(vm, origin.fileSystemPath()), JSC::ScriptFetchParameters::Type::JavaScript, WTF::move(sourceCode)); - auto* promise = JSC::importModule(globalObject, JSC::Identifier::fromString(vm, origin.fileSystemPath()), JSC::Identifier::fromString(vm, referrer.fileSystemPath()), nullptr, nullptr); - - auto scope = DECLARE_THROW_SCOPE(vm); - - if (scope.exception()) [[unlikely]] { - promise->rejectWithCaughtException(vm, scope); - } - - auto status = promise->status(); - - if (status == JSC::JSPromise::Status::Fulfilled) { - return JSC::JSValue::encode(promise->result()); - } else if (status == JSC::JSPromise::Status::Rejected) { - *arg6 = JSC::JSValue::encode(promise->result()); - return JSC::JSValue::encode(JSC::jsUndefined()); - } else { - return JSC::JSValue::encode(promise); - } -} - -JSC::EncodedJSValue JSC__JSValue__createRangeError(const ZigString* message, const ZigString* arg1, - JSC::JSGlobalObject* globalObject) -{ - auto& vm = JSC::getVM(globalObject); - ZigString code = *arg1; - JSC::JSObject* rangeError = Zig::getRangeErrorInstance(message, globalObject).asCell()->getObject(); - - if (code.len > 0) { - auto clientData = WebCore::clientData(vm); - JSC::JSValue codeValue = Zig::toJSString(code, globalObject); - rangeError->putDirect(vm, clientData->builtinNames().codePublicName(), codeValue, - JSC::PropertyAttribute::ReadOnly | 0); - } - - return JSC::JSValue::encode(rangeError); -} - -JSC::EncodedJSValue JSC__JSValue__createTypeError(const ZigString* message, const ZigString* arg1, - JSC::JSGlobalObject* globalObject) -{ - auto& vm = JSC::getVM(globalObject); - ZigString code = *arg1; - JSC::JSObject* typeError = Zig::getTypeErrorInstance(message, globalObject).asCell()->getObject(); - - if (code.len > 0) { - auto clientData = WebCore::clientData(vm); - JSC::JSValue codeValue = Zig::toJSString(code, globalObject); - typeError->putDirect(vm, clientData->builtinNames().codePublicName(), codeValue, 0); - } - - return JSC::JSValue::encode(typeError); -} - JSC::EncodedJSValue JSC__JSValue__fromEntries(JSC::JSGlobalObject* globalObject, ZigString* keys, ZigString* values, size_t initialCapacity, bool clone) { @@ -3641,31 +3399,6 @@ JSC::EncodedJSValue JSC__JSGlobalObject__createAggregateErrorWithArray(JSC::JSGl return JSC::JSValue::encode(JSC::createAggregateError(vm, errorStructure, array, messageString, cause, nullptr, JSC::TypeNothing, false)); } -JSC::EncodedJSValue ZigString__toAtomicValue(const ZigString* arg0, JSC::JSGlobalObject* arg1) -{ - if (arg0->len == 0) { - return JSC::JSValue::encode(JSC::jsEmptyString(arg1->vm())); - } - - if (isTaggedUTF16Ptr(arg0->ptr)) { - if (auto impl = WTF::AtomStringImpl::lookUp(std::span { reinterpret_cast(untag(arg0->ptr)), arg0->len })) { - return JSC::JSValue::encode(JSC::jsString(arg1->vm(), WTF::String(WTF::move(impl)))); - } - } else { - if (auto impl = WTF::AtomStringImpl::lookUp(std::span { untag(arg0->ptr), arg0->len })) { - return JSC::JSValue::encode(JSC::jsString(arg1->vm(), WTF::String(WTF::move(impl)))); - } - } - - return JSC::JSValue::encode(JSC::jsString(arg1->vm(), makeAtomString(Zig::toStringCopy(*arg0)))); -} - -JSC::EncodedJSValue ZigString__to16BitValue(const ZigString* arg0, JSC::JSGlobalObject* arg1) -{ - auto str = WTF::String::fromUTF8(std::span { arg0->ptr, arg0->len }); - return JSC::JSValue::encode(JSC::jsString(arg1->vm(), str)); -} - JSC::EncodedJSValue ZigString__toExternalU16(const uint16_t* arg0, size_t len, JSC::JSGlobalObject* global) { if (len == 0) { @@ -3743,18 +3476,6 @@ JSC::EncodedJSValue ZigString__external(const ZigString* arg0, JSC::JSGlobalObje } } -JSC::EncodedJSValue ZigString__toExternalValueWithCallback(const ZigString* arg0, JSC::JSGlobalObject* arg1, void (*ArgFn2)(void* arg2, void* arg0, size_t arg1)) -{ - - ZigString str - = *arg0; - if (Zig::isTaggedUTF16Ptr(str.ptr)) { - return JSC::JSValue::encode(JSC::jsOwnedString(arg1->vm(), WTF::String(ExternalStringImpl::create({ reinterpret_cast(Zig::untag(str.ptr)), str.len }, nullptr, ArgFn2)))); - } else { - return JSC::JSValue::encode(JSC::jsOwnedString(arg1->vm(), WTF::String(ExternalStringImpl::create({ reinterpret_cast(Zig::untag(str.ptr)), str.len }, nullptr, ArgFn2)))); - } -} - JSC::EncodedJSValue ZigString__toErrorInstance(const ZigString* str, JSC::JSGlobalObject* globalObject) { return JSC::JSValue::encode(Zig::getErrorInstance(str, globalObject)); @@ -3910,12 +3631,6 @@ JSC::JSPromise* JSC__JSPromise__rejectedPromise(JSC::JSGlobalObject* arg0, JSC:: arg0->resolve(arg1, arg1->vm(), JSC::JSValue::decode(JSValue2)); } -// This implementation closely mimics the one in JSC::JSPromise::resolve -void JSC__JSPromise__resolveOnNextTick(JSC::JSPromise* promise, JSC::JSGlobalObject* lexicalGlobalObject, JSC::EncodedJSValue encoedValue) -{ - return JSC__JSPromise__resolve(promise, lexicalGlobalObject, encoedValue); -} - bool JSC__JSValue__isAnyError(JSC::EncodedJSValue JSValue0) { JSC::JSValue value = JSC::JSValue::decode(JSValue0); @@ -3930,46 +3645,6 @@ bool JSC__JSValue__isAnyError(JSC::EncodedJSValue JSValue0) return type == JSC::ErrorInstanceType; } -// This implementation closely mimics the one in JSC::JSPromise::reject -void JSC__JSPromise__rejectOnNextTickWithHandled(JSC::JSPromise* promise, JSC::JSGlobalObject* lexicalGlobalObject, - JSC::EncodedJSValue encoedValue, bool handled) -{ - JSC::JSValue value = JSC::JSValue::decode(encoedValue); - - auto& vm = JSC::getVM(lexicalGlobalObject); - auto scope = DECLARE_THROW_SCOPE(vm); - uint16_t flags = promise->flags(); - if (!(flags & JSC::JSPromise::isFirstResolvingFunctionCalledFlag)) { - if (handled) { - flags |= JSC::JSPromise::isHandledFlag; - } - - promise->setFlags(static_cast(flags | JSC::JSPromise::isFirstResolvingFunctionCalledFlag)); - auto* globalObject = uncheckedDowncast(promise->globalObject()); - auto rejectPromiseFunction = globalObject->rejectPromiseFunction(); - - auto asyncContext = globalObject->m_asyncContextData.get()->getInternalField(0); - -#if ASSERT_ENABLED - ASSERT_WITH_MESSAGE(rejectPromiseFunction, "Invalid microtask callback"); - ASSERT_WITH_MESSAGE(!value.isEmpty(), "Invalid microtask value"); -#endif - - if (asyncContext.isEmpty()) { - asyncContext = jsUndefined(); - } - - if (value.isEmpty()) { - value = jsUndefined(); - } - - // BunPerformMicrotaskJob: rejectPromiseFunction, asyncContext, promise, value - JSC::QueuedTask task { nullptr, JSC::InternalMicrotask::BunPerformMicrotaskJob, 0, globalObject, rejectPromiseFunction, globalObject->m_asyncContextData.get()->getInternalField(0), promise, value }; - globalObject->vm().queueMicrotask(WTF::move(task)); - RETURN_IF_EXCEPTION(scope, ); - } -} - JSC::JSPromise* JSC__JSPromise__resolvedPromise(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue JSValue1) { auto& vm = JSC::getVM(globalObject); @@ -4012,10 +3687,6 @@ JSC::JSPromise* JSC__JSPromise__resolvedPromise(JSC::JSGlobalObject* globalObjec return 255; } } -[[ZIG_EXPORT(nothrow)]] bool JSC__JSPromise__isHandled(const JSC::JSPromise* arg0) -{ - return arg0->isHandled(); -} [[ZIG_EXPORT(nothrow)]] void JSC__JSPromise__setHandled(JSC::JSPromise* promise) { promise->markAsHandled(); @@ -4023,85 +3694,12 @@ JSC::JSPromise* JSC__JSPromise__resolvedPromise(JSC::JSGlobalObject* globalObjec #pragma mark - JSC::JSInternalPromise (now aliased to JSPromise) -JSC::JSPromise* JSC__JSInternalPromise__create(JSC::JSGlobalObject* globalObject) -{ - auto& vm = JSC::getVM(globalObject); - return JSC::JSPromise::create(vm, globalObject->promiseStructure()); -} - -[[ZIG_EXPORT(check_slow)]] -void JSC__JSInternalPromise__reject(JSC::JSPromise* arg0, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue JSValue2) -{ - JSValue value = JSC::JSValue::decode(JSValue2); - auto& vm = JSC::getVM(globalObject); - JSC::Exception* exception = nullptr; - if (!value.inherits()) { - exception = JSC::Exception::create(vm, value, JSC::Exception::StackCaptureAction::CaptureStack); - } else { - exception = uncheckedDowncast(value); - } - - arg0->reject(vm, exception); -} -void JSC__JSInternalPromise__rejectAsHandled(JSC::JSPromise* arg0, - JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2) -{ - auto& vm = JSC::getVM(arg1); - arg0->rejectAsHandled(vm, JSC::JSValue::decode(JSValue2)); -} -void JSC__JSInternalPromise__rejectAsHandledException(JSC::JSPromise* arg0, - JSC::JSGlobalObject* arg1, - JSC::Exception* arg2) -{ - auto& vm = JSC::getVM(arg1); - arg0->rejectAsHandled(vm, arg2); -} - -JSC::JSPromise* JSC__JSInternalPromise__rejectedPromise(JSC::JSGlobalObject* arg0, - JSC::EncodedJSValue JSValue1) -{ - return JSC::JSPromise::rejectedPromise(arg0, JSC::JSValue::decode(JSValue1)); -} - -[[ZIG_EXPORT(check_slow)]] -void JSC__JSInternalPromise__resolve(JSC::JSPromise* arg0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2) -{ - arg0->resolve(arg1, arg1->vm(), JSC::JSValue::decode(JSValue2)); -} - JSC::JSPromise* JSC__JSInternalPromise__resolvedPromise(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1) { return JSC::JSPromise::resolvedPromise(arg0, JSC::JSValue::decode(JSValue1)); } -JSC::EncodedJSValue JSC__JSInternalPromise__result(const JSC::JSPromise* arg0) -{ - return JSC::JSValue::encode(arg0->result()); -} -uint32_t JSC__JSInternalPromise__status(const JSC::JSPromise* arg0) -{ - switch (arg0->status()) { - case JSC::JSPromise::Status::Pending: - return 0; - case JSC::JSPromise::Status::Fulfilled: - return 1; - case JSC::JSPromise::Status::Rejected: - return 2; - default: - return 255; - } -} -bool JSC__JSInternalPromise__isHandled(const JSC::JSPromise* arg0) -{ - return arg0->isHandled(); -} -void JSC__JSInternalPromise__setHandled(JSC::JSPromise* promise, JSC::VM* arg1) -{ - UNUSED_PARAM(arg1); - promise->markAsHandled(); -} - #pragma mark - JSC::JSGlobalObject JSC::EncodedJSValue JSC__JSGlobalObject__generateHeapSnapshot(JSC::JSGlobalObject* globalObject) @@ -4141,10 +3739,6 @@ JSC::JSString* JSC__JSValue__asString(JSC::EncodedJSValue JSValue0) return JSC::asString(value); }; -bool JSC__JSValue__eqlCell(JSC::EncodedJSValue JSValue0, JSC::JSCell* arg1) -{ - return JSC::JSValue::decode(JSValue0) == arg1; -}; bool JSC__JSValue__eqlValue(JSC::EncodedJSValue JSValue0, JSC::EncodedJSValue JSValue1) { return JSC::JSValue::decode(JSValue0) == JSC::JSValue::decode(JSValue1); @@ -4242,16 +3836,6 @@ bool JSC__JSValue__isClass(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* ar } return false; } -[[ZIG_EXPORT(nothrow)]] bool JSC__JSValue__isCell(JSC::EncodedJSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isCell(); } -[[ZIG_EXPORT(nothrow)]] bool JSC__JSValue__isCustomGetterSetter(JSC::EncodedJSValue JSValue0) -{ - return JSC::JSValue::decode(JSValue0).isCustomGetterSetter(); -} -bool JSC__JSValue__isError(JSC::EncodedJSValue JSValue0) -{ - JSC::JSObject* obj = JSC::JSValue::decode(JSValue0).getObject(); - return obj != nullptr && obj->isErrorInstance(); -} bool JSC__JSValue__isAggregateError(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* global) { @@ -4285,31 +3869,10 @@ void JSC__JSValue__forEach(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* ar { return JSC::JSValue::decode(JSValue0).isCallable(); } -[[ZIG_EXPORT(nothrow)]] bool JSC__JSValue__isGetterSetter(JSC::EncodedJSValue JSValue0) -{ - return JSC::JSValue::decode(JSValue0).isGetterSetter(); -} [[ZIG_EXPORT(nothrow)]] bool JSC__JSValue__isHeapBigInt(JSC::EncodedJSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isHeapBigInt(); } -[[ZIG_EXPORT(nothrow)]] bool JSC__JSValue__isInt32(JSC::EncodedJSValue JSValue0) -{ - return JSC::JSValue::decode(JSValue0).isInt32(); -} -[[ZIG_EXPORT(nothrow)]] bool JSC__JSValue__isInt32AsAnyInt(JSC::EncodedJSValue JSValue0) -{ - return JSC::JSValue::decode(JSValue0).isInt32AsAnyInt(); -} -[[ZIG_EXPORT(nothrow)]] bool JSC__JSValue__isNull(JSC::EncodedJSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isNull(); } -[[ZIG_EXPORT(nothrow)]] bool JSC__JSValue__isNumber(JSC::EncodedJSValue JSValue0) -{ - return JSC::JSValue::decode(JSValue0).isNumber(); -} -[[ZIG_EXPORT(nothrow)]] bool JSC__JSValue__isObject(JSC::EncodedJSValue JSValue0) -{ - return JSValue0 != 0 && JSC::JSValue::decode(JSValue0).isObject(); -} [[ZIG_EXPORT(nothrow)]] bool JSC__JSValue__isPrimitive(JSC::EncodedJSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isPrimitive(); @@ -4322,43 +3885,15 @@ void JSC__JSValue__forEach(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* ar { return JSC::JSValue::decode(JSValue0).isUInt32AsAnyInt(); } -[[ZIG_EXPORT(nothrow)]] bool JSC__JSValue__isUndefined(JSC::EncodedJSValue JSValue0) -{ - return JSC::JSValue::decode(JSValue0).isUndefined(); -} -[[ZIG_EXPORT(nothrow)]] bool JSC__JSValue__isUndefinedOrNull(JSC::EncodedJSValue JSValue0) -{ - return JSC::JSValue::decode(JSValue0).isUndefinedOrNull(); -} [[ZIG_EXPORT(nothrow)]] JSC::EncodedJSValue JSC__JSValue__jsEmptyString(JSC::JSGlobalObject* arg0) { return JSC::JSValue::encode(JSC::jsEmptyString(arg0->vm())); } -[[ZIG_EXPORT(nothrow)]] JSC::EncodedJSValue JSC__JSValue__jsNumberFromChar(unsigned char arg0) -{ - return JSC::JSValue::encode(JSC::jsNumber(arg0)); -} __attribute__((__always_inline__)) JSC::EncodedJSValue JSC__JSValue__jsNumberFromDouble(double arg0) { return JSC::JSValue::encode(JSC::jsNumber(arg0)); } -JSC::EncodedJSValue JSC__JSValue__jsNumberFromInt32(int32_t arg0) -{ - return JSC::JSValue::encode(JSC::jsNumber(arg0)); -} -JSC::EncodedJSValue JSC__JSValue__jsNumberFromInt64(int64_t arg0) -{ - return JSC::JSValue::encode(JSC::jsNumber(arg0)); -} -[[ZIG_EXPORT(nothrow)]] JSC::EncodedJSValue JSC__JSValue__jsNumberFromU16(uint16_t arg0) -{ - return JSC::JSValue::encode(JSC::jsNumber(arg0)); -} -JSC::EncodedJSValue JSC__JSValue__jsNumberFromUint64(uint64_t arg0) -{ - return JSC::JSValue::encode(JSC::jsNumber(arg0)); -} [[ZIG_EXPORT(nothrow)]] int64_t JSC__JSValue__toInt64(JSC::EncodedJSValue val) { @@ -4526,7 +4061,7 @@ JSC::EncodedJSValue JSC__JSValue__createObject2(JSC::JSGlobalObject* globalObjec // Returns empty for exception, returns deleted if not found. // Be careful when handling the return value. -// Cannot handle numeric index property names! If it is possible that this will be a integer index, use JSC__JSValue__getPropertyValue instead +// Cannot handle numeric index property names! [[ZIG_EXPORT(zero_is_throw)]] JSC::EncodedJSValue JSC__JSValue__getIfPropertyExistsImpl(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* globalObject, const unsigned char* arg1, size_t arg2) @@ -4549,43 +4084,6 @@ JSC::EncodedJSValue JSC__JSValue__createObject2(JSC::JSGlobalObject* globalObjec return JSC::JSValue::encode(Bun::getIfPropertyExistsPrototypePollutionMitigationUnsafe(vm, globalObject, object, property)); } -// Returns empty for exception, returns deleted if not found. -// Be careful when handling the return value. -// Can handle numeric index property names safely. If you know that the property name is not an integer index, use JSC__JSValue__getIfPropertyExistsImpl instead. -JSC::EncodedJSValue JSC__JSValue__getPropertyValue(JSC::EncodedJSValue encodedValue, - JSC::JSGlobalObject* globalObject, - const unsigned char* propertyName, uint32_t propertyNameLength) -{ - - ASSERT_NO_PENDING_EXCEPTION(globalObject); - JSValue value = JSC::JSValue::decode(encodedValue); - ASSERT_WITH_MESSAGE(!value.isEmpty(), "getPropertyValue() must not be called on empty value"); - - auto& vm = JSC::getVM(globalObject); - JSC::JSObject* object = value.getObject(); - if (!object) [[unlikely]] { - return JSValue::encode(JSValue::decode(JSC::JSValue::ValueDeleted)); - } - - // Since Identifier might not ref the string, we need to ensure it doesn't get deref'd until this function returns - const auto propertyString = String(StringImpl::createWithoutCopying({ propertyName, propertyNameLength })); - const auto identifier = JSC::Identifier::fromString(vm, propertyString); - const auto property = JSC::PropertyName(identifier); - - auto scope = DECLARE_THROW_SCOPE(vm); - PropertySlot slot(object, PropertySlot::InternalMethodType::Get); - if (!object->getPropertySlot(globalObject, property, slot)) { - RETURN_IF_EXCEPTION(scope, {}); - return JSValue::encode(JSValue::decode(JSC::JSValue::ValueDeleted)); - } - RETURN_IF_EXCEPTION(scope, {}); - - JSValue result = slot.getValue(globalObject, property); - RETURN_IF_EXCEPTION(scope, {}); - - return JSValue::encode(result); -} - extern "C" JSC::EncodedJSValue JSC__JSValue__getOwn(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* globalObject, BunString* propertyName) { ASSERT_NO_PENDING_EXCEPTION(globalObject); @@ -4768,23 +4266,6 @@ JSC::EncodedJSValue JSC__JSValue__symbolFor(JSC::JSGlobalObject* globalObject, Z return JSC::JSValue::encode(JSC::Symbol::create(vm, vm.symbolRegistry().symbolForKey(string))); } -bool JSC__JSValue__symbolKeyFor(JSC::EncodedJSValue symbolValue_, JSC::JSGlobalObject* arg1, ZigString* arg2) -{ - JSC::JSValue symbolValue = JSC::JSValue::decode(symbolValue_); - JSC::VM& vm = arg1->vm(); - - if (!symbolValue.isSymbol()) - return false; - - JSC::PrivateName privateName = JSC::asSymbol(symbolValue)->privateName(); - SymbolImpl& uid = privateName.uid(); - if (!uid.symbolRegistry()) - return false; - - *arg2 = Zig::toZigString(JSC::jsString(vm, String { uid }), arg1); - return true; -} - int32_t JSC__JSValue__toInt32(JSC::EncodedJSValue JSValue0) { return JSC::JSValue::decode(JSValue0).asInt32(); @@ -4834,11 +4315,6 @@ JSC::EncodedJSValue JSC__JSValue__getErrorsProperty(JSC::EncodedJSValue JSValue0 return JSC::JSValue::encode(obj->getDirect(global->vm(), global->vm().propertyNames->errors)); } -[[ZIG_EXPORT(nothrow)]] JSC::EncodedJSValue JSC__JSValue__jsTDZValue() -{ - return JSC::JSValue::encode(JSC::jsTDZValue()); -}; - JSC::JSObject* JSC__JSValue__toObject(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1) { JSC::JSValue value = JSC::JSValue::decode(JSValue0); @@ -5058,24 +4534,6 @@ size_t JSC__VM__runGC(JSC::VM* vm, bool sync) return vm->heap.sizeAfterLastFullCollection(); } -[[ZIG_EXPORT(nothrow)]] bool JSC__VM__isJITEnabled() -{ - return JSC::Options::useJIT(); -} - -void JSC__VM__clearExecutionTimeLimit(JSC::VM* vm) -{ - JSC::JSLockHolder locker(vm); - if (vm->watchdog()) - vm->watchdog()->setTimeLimit(JSC::Watchdog::noTimeLimit); -} -void JSC__VM__setExecutionTimeLimit(JSC::VM* vm, double limit) -{ - JSC::JSLockHolder locker(vm); - JSC::Watchdog& watchdog = vm->ensureWatchdog(); - watchdog.setTimeLimit(WTF::Seconds { limit }); -} - bool JSC__JSValue__isTerminationException(JSC::EncodedJSValue JSValue0) { JSC::Exception* exception = dynamicDowncast(JSC::JSValue::decode(JSValue0)); @@ -5119,20 +4577,6 @@ void JSC__JSString__iterator(JSC::JSString* arg0, JSC::JSGlobalObject* arg1, voi arg0->value(iter); } -void JSC__VM__deleteAllCode(JSC::VM* arg1, JSC::JSGlobalObject* globalObject) -{ - JSC::JSLockHolder locker(globalObject->vm()); - - arg1->drainMicrotasks(); - { - auto* moduleLoader = globalObject->moduleLoader(); - WTF::Locker cellLocker { moduleLoader->cellLock() }; - moduleLoader->clearAll(); - } - arg1->deleteAllCode(JSC::DeleteAllCodeEffort::PreventCollectionAndDeleteAllCode); - arg1->heap.reportAbandonedObjectGraph(); -} - void JSC__VM__reportExtraMemory(JSC::VM* arg0, size_t arg1) { arg0->heap.deprecatedReportExtraMemory(arg1); @@ -5148,11 +4592,6 @@ bool JSC__VM__executionForbidden(JSC::VM* arg0) return (*arg0).executionForbidden(); } -bool JSC__VM__isEntered(JSC::VM* arg0) -{ - return (*arg0).isEntered(); -} - [[ZIG_EXPORT(nothrow)]] bool JSC__VM__isTerminationException(JSC::VM* vm, JSC::Exception* exception) { @@ -5202,14 +4641,6 @@ void JSC__VM__notifyNeedDebuggerBreak(JSC::VM* arg0) { (*arg0).notifyNeedDebuggerBreak(); } -void JSC__VM__notifyNeedShellTimeoutCheck(JSC::VM* arg0) -{ - (*arg0).notifyNeedShellTimeoutCheck(); -} -void JSC__VM__notifyNeedWatchdogCheck(JSC::VM* arg0) -{ - (*arg0).notifyNeedWatchdogCheck(); -} void JSC__VM__throwError(JSC::VM* vm_, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue encodedValue) { @@ -5379,13 +4810,6 @@ static inline const JSC::Identifier& builtinNameMap(JSC::VM& vm, unsigned char n } } -JSC::EncodedJSValue JSC__JSValue__fastGetDirect_(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* globalObject, unsigned char arg2) -{ - JSC::JSValue value = JSC::JSValue::decode(JSValue0); - ASSERT(value.isCell()); - return JSValue::encode(value.getObject()->getDirect(globalObject->vm(), PropertyName(builtinNameMap(globalObject->vm(), arg2)))); -} - // Returns empty for exception, returns deleted if not found. // Be careful when handling the return value. JSC::EncodedJSValue JSC__JSValue__fastGet(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* globalObject, unsigned char arg2) @@ -6279,12 +5703,6 @@ CPP_DECL [[ZIG_EXPORT(zero_is_throw)]] JSC::EncodedJSValue JSC__JSMap__get(JSC:: return JSC::JSValue::encode(value); } -CPP_DECL [[ZIG_EXPORT(check_slow)]] bool JSC__JSMap__has(JSC::JSMap* map, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2) -{ - const JSC::JSValue value = JSC::JSValue::decode(JSValue2); - return map->has(arg1, value); -} - CPP_DECL [[ZIG_EXPORT(check_slow)]] bool JSC__JSMap__remove(JSC::JSMap* map, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2) { const JSC::JSValue value = JSC::JSValue::decode(JSValue2); @@ -6314,11 +5732,6 @@ CPP_DECL void JSC__VM__enableControlFlowProfiler(JSC::VM* vm) vm->enableControlFlowProfiler(); } -CPP_DECL void JSC__VM__performOpportunisticallyScheduledTasks(JSC::VM* vm, double until) -{ - vm->performOpportunisticallyScheduledTasks(ApproximateTime::now() + Seconds(until), {}); -} - extern "C" EncodedJSValue JSC__createError(JSC::JSGlobalObject* globalObject, const BunString* str) { return JSValue::encode(JSC::createError(globalObject, str->toWTFString(BunString::ZeroCopy))); @@ -6329,11 +5742,6 @@ extern "C" EncodedJSValue JSC__createTypeError(JSC::JSGlobalObject* globalObject return JSValue::encode(JSC::createTypeError(globalObject, str->toWTFString(BunString::ZeroCopy))); } -extern "C" EncodedJSValue JSC__createRangeError(JSC::JSGlobalObject* globalObject, const BunString* str) -{ - return JSValue::encode(JSC::createRangeError(globalObject, str->toWTFString(BunString::ZeroCopy))); -} - extern "C" EncodedJSValue ExpectMatcherUtils__getSingleton(JSC::JSGlobalObject* globalObject_) { Zig::GlobalObject* globalObject = static_cast(globalObject_); @@ -6492,15 +5900,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); diff --git a/src/jsc/bindings/headers-handwritten.h b/src/jsc/bindings/headers-handwritten.h index 67e94e8c3deb..26e920be506f 100644 --- a/src/jsc/bindings/headers-handwritten.h +++ b/src/jsc/bindings/headers-handwritten.h @@ -303,8 +303,6 @@ typedef struct JSC::JSUint8Array JSC::JSUint8Array; #ifdef __cplusplus -extern "C" void Bun__WTFStringImpl__deref(WTF::StringImpl* impl); -extern "C" void Bun__WTFStringImpl__ref(WTF::StringImpl* impl); extern "C" void Bun__WTFStringImpl__destroy(WTF::StringImpl* impl); extern "C" bool BunString__fromJS(JSC::JSGlobalObject*, JSC::EncodedJSValue, BunString*); extern "C" JSC::EncodedJSValue BunString__toJS(JSC::JSGlobalObject*, const BunString*); diff --git a/src/jsc/bindings/headers.h b/src/jsc/bindings/headers.h index 208be793da65..d08eb7e869d9 100644 --- a/src/jsc/bindings/headers.h +++ b/src/jsc/bindings/headers.h @@ -45,25 +45,18 @@ class DOMURL; #pragma mark - JSC::JSObject CPP_DECL JSC::EncodedJSValue JSC__JSObject__create(JSC::JSGlobalObject* arg0, size_t arg1, void* arg2, void(* ArgFn3)(void* arg0, JSC::JSObject* arg1, JSC::JSGlobalObject* arg2)); -CPP_DECL size_t JSC__JSObject__getArrayLength(JSC::JSObject* arg0); -CPP_DECL JSC::EncodedJSValue JSC__JSObject__getDirect(JSC::JSObject* arg0, JSC::JSGlobalObject* arg1, const ZigString* arg2); CPP_DECL JSC::EncodedJSValue JSC__JSObject__getIndex(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, uint32_t arg2); CPP_DECL void JSC__JSObject__putRecord(JSC::JSObject* arg0, JSC::JSGlobalObject* arg1, ZigString* arg2, ZigString* arg3, size_t arg4); CPP_DECL JSC::EncodedJSValue ZigString__external(const ZigString* arg0, JSC::JSGlobalObject* arg1, void* arg2, void(* ArgFn3)(void* arg0, void* arg1, size_t arg2)); -CPP_DECL JSC::EncodedJSValue ZigString__to16BitValue(const ZigString* arg0, JSC::JSGlobalObject* arg1); -CPP_DECL JSC::EncodedJSValue ZigString__toAtomicValue(const ZigString* arg0, JSC::JSGlobalObject* arg1); CPP_DECL JSC::EncodedJSValue ZigString__toErrorInstance(const ZigString* arg0, JSC::JSGlobalObject* arg1); CPP_DECL JSC::EncodedJSValue ZigString__toExternalU16(const uint16_t* arg0, size_t arg1, JSC::JSGlobalObject* arg2); CPP_DECL JSC::EncodedJSValue ZigString__toExternalValue(const ZigString* arg0, JSC::JSGlobalObject* arg1); -CPP_DECL JSC::EncodedJSValue ZigString__toExternalValueWithCallback(const ZigString* arg0, JSC::JSGlobalObject* arg1, void(* ArgFn2)(void* arg0, void* arg1, size_t arg2)); CPP_DECL JSC::EncodedJSValue ZigString__toRangeErrorInstance(const ZigString* arg0, JSC::JSGlobalObject* arg1); CPP_DECL JSC::EncodedJSValue ZigString__toSyntaxErrorInstance(const ZigString* arg0, JSC::JSGlobalObject* arg1); CPP_DECL JSC::EncodedJSValue ZigString__toTypeErrorInstance(const ZigString* arg0, JSC::JSGlobalObject* arg1); CPP_DECL JSC::EncodedJSValue ZigString__toValueGC(const ZigString* arg0, JSC::JSGlobalObject* arg1); CPP_DECL WebCore::DOMURL* WebCore__DOMURL__cast_(JSC::EncodedJSValue JSValue0, JSC::VM* arg1); CPP_DECL BunString WebCore__DOMURL__fileSystemPath(WebCore::DOMURL* arg0, int* errorCode); -CPP_DECL void WebCore__DOMURL__href_(WebCore::DOMURL* arg0, ZigString* arg1); -CPP_DECL void WebCore__DOMURL__pathname_(WebCore::DOMURL* arg0, ZigString* arg1); #pragma mark - WebCore::DOMFormData @@ -72,7 +65,6 @@ CPP_DECL void WebCore__DOMFormData__appendBlob(WebCore::DOMFormData* arg0, JSC:: CPP_DECL size_t WebCore__DOMFormData__count(WebCore::DOMFormData* arg0); CPP_DECL JSC::EncodedJSValue WebCore__DOMFormData__create(JSC::JSGlobalObject* arg0); CPP_DECL JSC::EncodedJSValue WebCore__DOMFormData__createFromURLQuery(JSC::JSGlobalObject* arg0, ZigString* arg1); -CPP_DECL WebCore::DOMFormData* _fromJS(JSC::EncodedJSValue JSValue0); #pragma mark - WebCore::FetchHeaders @@ -85,7 +77,6 @@ CPP_DECL WebCore::FetchHeaders* WebCore__FetchHeaders__createFromJS(JSC::JSGloba CPP_DECL WebCore::FetchHeaders* WebCore__FetchHeaders__createFromPicoHeaders_(const void* arg0); CPP_DECL WebCore::FetchHeaders* WebCore__FetchHeaders__createFromUWS(void* arg1); CPP_DECL WebCore::FetchHeaders* WebCore__FetchHeaders__createFromH3(void* arg1); -CPP_DECL JSC::EncodedJSValue WebCore__FetchHeaders__createValue(JSC::JSGlobalObject* arg0, StringPointer* arg1, StringPointer* arg2, const ZigString* arg3, uint32_t arg4); CPP_DECL void WebCore__FetchHeaders__deref(WebCore::FetchHeaders* arg0); CPP_DECL void WebCore__FetchHeaders__fastGet_(WebCore::FetchHeaders* arg0, unsigned char arg1, ZigString* arg2); CPP_DECL bool WebCore__FetchHeaders__fastHas_(WebCore::FetchHeaders* arg0, unsigned char arg1); @@ -99,21 +90,17 @@ CPP_DECL JSC::EncodedJSValue SystemError__toTypeErrorInstance(const SystemError* #pragma mark - JSC::JSCell -CPP_DECL JSC::JSObject* JSC__JSCell__getObject(JSC::JSCell* arg0); CPP_DECL unsigned char JSC__JSCell__getType(JSC::JSCell* arg0); -CPP_DECL JSC::JSObject* JSC__JSCell__toObject(JSC::JSCell* cell, JSC::JSGlobalObject* globalObject); #pragma mark - JSC::JSString CPP_DECL bool JSC__JSString__is8Bit(const JSC::JSString* arg0); CPP_DECL void JSC__JSString__iterator(JSC::JSString* arg0, JSC::JSGlobalObject* arg1, void* arg2); CPP_DECL size_t JSC__JSString__length(const JSC::JSString* arg0); -CPP_DECL JSC::JSObject* JSC__JSString__toObject(JSC::JSString* arg0, JSC::JSGlobalObject* arg1); CPP_DECL void JSC__JSString__toZigString(JSC::JSString* arg0, JSC::JSGlobalObject* arg1, ZigString* arg2); #pragma mark - JSC::JSModuleLoader -CPP_DECL JSC::EncodedJSValue JSC__JSModuleLoader__evaluate(JSC::JSGlobalObject* arg0, const unsigned char* arg1, size_t arg2, const unsigned char* arg3, size_t arg4, const unsigned char* arg5, size_t arg6, JSC::EncodedJSValue JSValue7, JSC::EncodedJSValue* arg8); CPP_DECL JSC::JSPromise* JSC__JSModuleLoader__loadAndEvaluateModule(JSC::JSGlobalObject* arg0, const BunString* arg1); #pragma mark - WebCore::AbortSignal @@ -130,14 +117,11 @@ CPP_DECL void WebCore__AbortSignal__unref(WebCore::AbortSignal* arg0); #pragma mark - JSC::JSPromise -CPP_DECL JSC::EncodedJSValue JSC__JSPromise__asValue(JSC::JSPromise* arg0, JSC::JSGlobalObject* arg1); CPP_DECL JSC::JSPromise* JSC__JSPromise__create(JSC::JSGlobalObject* arg0); -CPP_DECL bool JSC__JSPromise__isHandled(const JSC::JSPromise* arg0); CPP_DECL void JSC__JSPromise__reject(JSC::JSPromise* arg0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2); CPP_DECL void JSC__JSPromise__rejectAsHandled(JSC::JSPromise* arg0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2); CPP_DECL JSC::JSPromise* JSC__JSPromise__rejectedPromise(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1); CPP_DECL JSC::EncodedJSValue JSC__JSPromise__rejectedPromiseValue(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1); -CPP_DECL void JSC__JSPromise__rejectOnNextTickWithHandled(JSC::JSPromise* arg0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2, bool arg3); CPP_DECL void JSC__JSPromise__resolve(JSC::JSPromise* arg0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2); CPP_DECL JSC::JSPromise* JSC__JSPromise__resolvedPromise(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1); CPP_DECL JSC::EncodedJSValue JSC__JSPromise__resolvedPromiseValue(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1); @@ -147,21 +131,7 @@ CPP_DECL uint32_t JSC__JSPromise__status(const JSC::JSPromise* arg0); #pragma mark - JSC::JSInternalPromise (now aliased to JSPromise) -CPP_DECL JSC::JSPromise* JSC__JSInternalPromise__create(JSC::JSGlobalObject* arg0); -CPP_DECL bool JSC__JSInternalPromise__isHandled(const JSC::JSPromise* arg0); -CPP_DECL void JSC__JSInternalPromise__reject(JSC::JSPromise* arg0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2); -CPP_DECL void JSC__JSInternalPromise__rejectAsHandled(JSC::JSPromise* arg0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2); -CPP_DECL void JSC__JSInternalPromise__rejectAsHandledException(JSC::JSPromise* arg0, JSC::JSGlobalObject* arg1, JSC::Exception* arg2); -CPP_DECL JSC::JSPromise* JSC__JSInternalPromise__rejectedPromise(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1); -CPP_DECL void JSC__JSInternalPromise__resolve(JSC::JSPromise* arg0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2); CPP_DECL JSC::JSPromise* JSC__JSInternalPromise__resolvedPromise(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1); -CPP_DECL JSC::EncodedJSValue JSC__JSInternalPromise__result(const JSC::JSPromise* arg0); -CPP_DECL void JSC__JSInternalPromise__setHandled(JSC::JSPromise* arg0, JSC::VM* arg1); -CPP_DECL uint32_t JSC__JSInternalPromise__status(const JSC::JSPromise* arg0); - -#pragma mark - JSC::JSFunction - -CPP_DECL void JSC__JSFunction__optimizeSoon(JSC::EncodedJSValue JSValue0); #pragma mark - REPL Functions @@ -173,12 +143,9 @@ CPP_DECL JSC::EncodedJSValue Bun__REPL__formatValue(JSC::JSGlobalObject* globalO CPP_DECL VirtualMachine* JSC__JSGlobalObject__bunVM(JSC::JSGlobalObject* arg0); CPP_DECL JSC::EncodedJSValue JSC__JSGlobalObject__createAggregateError(JSC::JSGlobalObject* arg0, const JSC::JSValue* arg1, size_t arg2, const ZigString* arg3); -CPP_DECL void JSC__JSGlobalObject__createSyntheticModule_(JSC::JSGlobalObject* arg0, ZigString* arg1, size_t arg2, JSC::EncodedJSValue* arg3, size_t arg4); CPP_DECL void JSC__JSGlobalObject__deleteModuleRegistryEntry(JSC::JSGlobalObject* arg0, ZigString* arg1); CPP_DECL JSC::EncodedJSValue JSC__JSGlobalObject__generateHeapSnapshot(JSC::JSGlobalObject* arg0); -CPP_DECL JSC::EncodedJSValue JSC__JSGlobalObject__getCachedObject(JSC::JSGlobalObject* arg0, const ZigString* arg1); CPP_DECL void JSC__JSGlobalObject__handleRejectedPromises(JSC::JSGlobalObject* arg0); -CPP_DECL JSC::EncodedJSValue JSC__JSGlobalObject__putCachedObject(JSC::JSGlobalObject* arg0, const ZigString* arg1, JSC::EncodedJSValue JSValue2); CPP_DECL void JSC__JSGlobalObject__addGc(JSC::JSGlobalObject* globalObject); CPP_DECL double JSC__JSGlobalObject__jsDateNow(JSC::JSGlobalObject* globalObject); CPP_DECL void JSC__JSGlobalObject__queueMicrotaskJob(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1, JSC::EncodedJSValue JSValue2, JSC::EncodedJSValue JSValue3); @@ -189,14 +156,12 @@ CPP_DECL JSC::VM* JSC__JSGlobalObject__vm(JSC::JSGlobalObject* arg0); CPP_DECL JSC::EncodedJSValue JSC__JSMap__create(JSC::JSGlobalObject* arg0); CPP_DECL JSC::EncodedJSValue JSC__JSMap__get(JSC::JSMap* arg0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2); -CPP_DECL bool JSC__JSMap__has(JSC::JSMap* arg0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2); CPP_DECL bool JSC__JSMap__remove(JSC::JSMap* arg0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2); CPP_DECL void JSC__JSMap__set(JSC::JSMap* arg0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2, JSC::EncodedJSValue JSValue3); CPP_DECL uint32_t JSC__JSMap__size(JSC::JSMap* arg0, JSC::JSGlobalObject* arg1); #pragma mark - JSC::JSValue -CPP_DECL void JSC__JSValue__then(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2, SYSV_ABI JSC::EncodedJSValue(* ArgFn3)(JSC::JSGlobalObject* arg0, JSC::CallFrame* arg1), SYSV_ABI JSC::EncodedJSValue(* ArgFn4)(JSC::JSGlobalObject* arg0, JSC::CallFrame* arg1)); CPP_DECL bool JSC__JSValue__asArrayBuffer(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, Bun__ArrayBuffer* arg2); CPP_DECL unsigned char JSC__JSValue__asBigIntCompare(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2); CPP_DECL JSC::JSPromise* JSC__JSValue__asInternalPromise(JSC::EncodedJSValue JSValue0); @@ -206,18 +171,11 @@ CPP_DECL int32_t JSC__JSValue__coerceToInt32(JSC::EncodedJSValue JSValue0, JSC:: CPP_DECL int64_t JSC__JSValue__coerceToInt64(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1); CPP_DECL JSC::EncodedJSValue JSC__JSValue__createEmptyArray(JSC::JSGlobalObject* arg0, size_t arg1); CPP_DECL JSC::EncodedJSValue JSC__JSValue__createEmptyObject(JSC::JSGlobalObject* arg0, size_t arg1); -CPP_DECL JSC::EncodedJSValue JSC__JSValue__createInternalPromise(JSC::JSGlobalObject* arg0); CPP_DECL JSC::EncodedJSValue JSC__JSValue__createObject2(JSC::JSGlobalObject* arg0, const ZigString* arg1, const ZigString* arg2, JSC::EncodedJSValue JSValue3, JSC::EncodedJSValue JSValue4); -CPP_DECL JSC::EncodedJSValue JSC__JSValue__createRangeError(const ZigString* arg0, const ZigString* arg1, JSC::JSGlobalObject* arg2); CPP_DECL JSC::EncodedJSValue JSC__JSValue__createRopeString(JSC::EncodedJSValue JSValue0, JSC::EncodedJSValue JSValue1, JSC::JSGlobalObject* arg2); -CPP_DECL JSC::EncodedJSValue JSC__JSValue__createStringArray(JSC::JSGlobalObject* arg0, const ZigString* arg1, size_t arg2, bool arg3); -CPP_DECL JSC::EncodedJSValue JSC__JSValue__createTypeError(const ZigString* arg0, const ZigString* arg1, JSC::JSGlobalObject* arg2); CPP_DECL JSC::EncodedJSValue JSC__JSValue__createUninitializedUint8Array(JSC::JSGlobalObject* arg0, size_t arg1); -CPP_DECL bool JSC__JSValue__deepEquals(JSC::EncodedJSValue JSValue0, JSC::EncodedJSValue JSValue1, JSC::JSGlobalObject* arg2); -CPP_DECL bool JSC__JSValue__eqlCell(JSC::EncodedJSValue JSValue0, JSC::JSCell* arg1); CPP_DECL bool JSC__JSValue__eqlValue(JSC::EncodedJSValue JSValue0, JSC::EncodedJSValue JSValue1); CPP_DECL JSC::EncodedJSValue JSC__JSValue__fastGet(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, unsigned char arg2); -CPP_DECL JSC::EncodedJSValue JSC__JSValue__fastGetDirect_(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, unsigned char arg2); CPP_DECL void JSC__JSValue__forEach(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, void* arg2, void(* ArgFn3)(JSC::VM* arg0, JSC::JSGlobalObject* arg1, void* arg2, JSC::EncodedJSValue JSValue3)); CPP_DECL void JSC__JSValue__forEachProperty(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, void* arg2, void(* ArgFn3)(JSC::JSGlobalObject* arg0, void* arg1, ZigString* arg2, JSC::EncodedJSValue JSValue3, bool arg4, bool arg5)); CPP_DECL void JSC__JSValue__forEachPropertyOrdered(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, void* arg2, void(* ArgFn3)(JSC::JSGlobalObject* arg0, void* arg1, ZigString* arg2, JSC::EncodedJSValue JSValue3, bool arg4, bool arg5)); @@ -234,7 +192,6 @@ CPP_DECL void JSC__JSValue__getNameProperty(JSC::EncodedJSValue JSValue0, JSC::J CPP_DECL JSC::EncodedJSValue JSC__JSValue__getPrototype(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1); CPP_DECL void JSC__JSValue__getSymbolDescription(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, ZigString* arg2); CPP_DECL double JSC__JSValue__getUnixTimestamp(JSC::EncodedJSValue JSValue0); -CPP_DECL bool JSC__JSValue__hasOwnProperty(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, ZigString arg2); CPP_DECL bool JSC__JSValue__isAggregateError(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1); CPP_DECL bool JSC__JSValue__isAnyError(JSC::EncodedJSValue JSValue0); CPP_DECL bool JSC__JSValue__isAnyInt(JSC::EncodedJSValue JSValue0); @@ -243,17 +200,10 @@ CPP_DECL bool JSC__JSValue__isBigInt32(JSC::EncodedJSValue JSValue0); CPP_DECL bool JSC__JSValue__isCallable(JSC::EncodedJSValue JSValue0); CPP_DECL bool JSC__JSValue__isClass(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1); CPP_DECL bool JSC__JSValue__isConstructor(JSC::EncodedJSValue JSValue0); -CPP_DECL bool JSC__JSValue__isCustomGetterSetter(JSC::EncodedJSValue JSValue0); -CPP_DECL bool JSC__JSValue__isError(JSC::EncodedJSValue JSValue0); CPP_DECL bool JSC__JSValue__isException(JSC::EncodedJSValue JSValue0, JSC::VM* arg1); -CPP_DECL bool JSC__JSValue__isGetterSetter(JSC::EncodedJSValue JSValue0); CPP_DECL bool JSC__JSValue__isHeapBigInt(JSC::EncodedJSValue JSValue0); CPP_DECL bool JSC__JSValue__isInstanceOf(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2); -CPP_DECL bool JSC__JSValue__isInt32(JSC::EncodedJSValue JSValue0); -CPP_DECL bool JSC__JSValue__isInt32AsAnyInt(JSC::EncodedJSValue JSValue0); CPP_DECL bool JSC__JSValue__isIterable(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1); -CPP_DECL bool JSC__JSValue__isNumber(JSC::EncodedJSValue JSValue0); -CPP_DECL bool JSC__JSValue__isObject(JSC::EncodedJSValue JSValue0); CPP_DECL bool JSC__JSValue__isPrimitive(JSC::EncodedJSValue JSValue0); CPP_DECL bool JSC__JSValue__isSameValue(JSC::EncodedJSValue JSValue0, JSC::EncodedJSValue JSValue1, JSC::JSGlobalObject* arg2); CPP_DECL bool JSC__JSValue__isSymbol(JSC::EncodedJSValue JSValue0); @@ -262,32 +212,24 @@ CPP_DECL bool JSC__JSValue__isUInt32AsAnyInt(JSC::EncodedJSValue JSValue0); CPP_DECL bool JSC__JSValue__jestDeepEquals(JSC::EncodedJSValue JSValue0, JSC::EncodedJSValue JSValue1, JSC::JSGlobalObject* arg2); CPP_DECL bool JSC__JSValue__jestDeepMatch(JSC::EncodedJSValue JSValue0, JSC::EncodedJSValue JSValue1, JSC::JSGlobalObject* arg2, bool arg3); CPP_DECL bool JSC__JSValue__jestStrictDeepEquals(JSC::EncodedJSValue JSValue0, JSC::EncodedJSValue JSValue1, JSC::JSGlobalObject* arg2); -CPP_DECL JSC::EncodedJSValue JSC__JSValue__jsNumberFromChar(unsigned char arg0); CPP_DECL JSC::EncodedJSValue JSC__JSValue__jsNumberFromDouble(double arg0); -CPP_DECL JSC::EncodedJSValue JSC__JSValue__jsNumberFromInt64(int64_t arg0); -CPP_DECL JSC::EncodedJSValue JSC__JSValue__jsNumberFromU16(uint16_t arg0); CPP_DECL void JSC__JSValue__jsonStringify(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, uint32_t arg2, BunString* arg3); CPP_DECL void JSC__JSValue__jsonStringifyFast(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, BunString* arg3); -CPP_DECL JSC::EncodedJSValue JSC__JSValue__jsTDZValue(); -CPP_DECL unsigned char JSC__JSValue__jsType(JSC::EncodedJSValue JSValue0); CPP_DECL JSC::EncodedJSValue JSC__JSValue__keys(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue arg1); CPP_DECL JSC::EncodedJSValue JSC__JSValue__values(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue arg1); CPP_DECL void JSC__JSValue__push(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2); CPP_DECL void JSC__JSValue__put(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, const ZigString* arg2, JSC::EncodedJSValue JSValue3); CPP_DECL void JSC__JSValue__putNonEnumerable(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, const ZigString* arg2, JSC::EncodedJSValue JSValue3); CPP_DECL void JSC__JSValue__putIndex(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, uint32_t arg2, JSC::EncodedJSValue JSValue3); -CPP_DECL void JSC__JSValue__putRecord(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, ZigString* arg2, ZigString* arg3, size_t arg4); CPP_DECL bool JSC__JSValue__strictDeepEquals(JSC::EncodedJSValue JSValue0, JSC::EncodedJSValue JSValue1, JSC::JSGlobalObject* arg2); CPP_DECL bool JSC__JSValue__stringIncludes(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2); CPP_DECL JSC::EncodedJSValue JSC__JSValue__symbolFor(JSC::JSGlobalObject* arg0, ZigString* arg1); -CPP_DECL bool JSC__JSValue__symbolKeyFor(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, ZigString* arg2); CPP_DECL bool JSC__JSValue__toBoolean(JSC::EncodedJSValue JSValue0); CPP_DECL JSC::EncodedJSValue JSC__JSValue__toError_(JSC::EncodedJSValue JSValue0); CPP_DECL int32_t JSC__JSValue__toInt32(JSC::EncodedJSValue JSValue0); CPP_DECL int64_t JSC__JSValue__toInt64(JSC::EncodedJSValue JSValue0); CPP_DECL bool JSC__JSValue__toMatch(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2); CPP_DECL JSC::JSObject* JSC__JSValue__toObject(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1); -CPP_DECL JSC::JSString* JSC__JSValue__toString(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1); CPP_DECL JSC::JSString* JSC__JSValue__toStringOrNull(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1); CPP_DECL uint64_t JSC__JSValue__toUInt64NoTruncate(JSC::EncodedJSValue JSValue0); CPP_DECL void JSC__JSValue__toZigException(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObject* arg1, ZigException* arg2); @@ -296,27 +238,19 @@ CPP_DECL void JSC__JSValue__toZigString(JSC::EncodedJSValue JSValue0, ZigString* #pragma mark - JSC::VM CPP_DECL size_t JSC__VM__blockBytesAllocated(JSC::VM* arg0); -CPP_DECL void JSC__VM__clearExecutionTimeLimit(JSC::VM* arg0); CPP_DECL void JSC__VM__collectAsync(JSC::VM* arg0); -CPP_DECL JSC::VM* JSC__VM__create(unsigned char HeapType0); -CPP_DECL void JSC__VM__deleteAllCode(JSC::VM* arg0, JSC::JSGlobalObject* arg1); CPP_DECL void JSC__VM__drainMicrotasks(JSC::VM* arg0); CPP_DECL bool JSC__VM__executionForbidden(JSC::VM* arg0); CPP_DECL size_t JSC__VM__externalMemorySize(JSC::VM* arg0); CPP_DECL size_t JSC__VM__heapSize(JSC::VM* arg0); CPP_DECL void JSC__VM__holdAPILock(JSC::VM* arg0, void* arg1, void(* ArgFn2)(void* arg0)); -CPP_DECL bool JSC__VM__isEntered(JSC::VM* arg0); -CPP_DECL bool JSC__VM__isJITEnabled(); CPP_DECL void JSC__VM__notifyNeedDebuggerBreak(JSC::VM* arg0); -CPP_DECL void JSC__VM__notifyNeedShellTimeoutCheck(JSC::VM* arg0); CPP_DECL void JSC__VM__notifyNeedTermination(JSC::VM* arg0); CPP_DECL void JSC__VM__ensureTerminationExceptionPending(JSC::VM* arg0); -CPP_DECL void JSC__VM__notifyNeedWatchdogCheck(JSC::VM* arg0); CPP_DECL void JSC__VM__releaseWeakRefs(JSC::VM* arg0); CPP_DECL size_t JSC__VM__runGC(JSC::VM* arg0, bool arg1); CPP_DECL void JSC__VM__enableControlFlowProfiler(JSC::VM* arg0); CPP_DECL void JSC__VM__setExecutionForbidden(JSC::VM* arg0, bool arg1); -CPP_DECL void JSC__VM__setExecutionTimeLimit(JSC::VM* arg0, double arg1); CPP_DECL void JSC__VM__shrinkFootprint(JSC::VM* arg0); CPP_DECL void JSC__VM__throwError(JSC::VM* arg0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2); CPP_DECL void JSC__VM__throwError(JSC::VM* arg0, JSC::JSGlobalObject* arg1, JSC::EncodedJSValue JSValue2); @@ -325,7 +259,6 @@ CPP_DECL void FFI__ptr__put(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSVal #ifdef __cplusplus -extern "C" JSC::EncodedJSValue SYSV_ABI FFI__ptr__fastpath(JSC::JSGlobalObject* arg0, void* arg1, JSC::JSUint8Array* arg2); extern "C" JSC::EncodedJSValue SYSV_ABI FFI__ptr__slowpath(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1, JSC::EncodedJSValue* arg2, size_t arg3); #endif @@ -333,7 +266,6 @@ CPP_DECL void Reader__u8__put(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSV #ifdef __cplusplus -extern "C" JSC::EncodedJSValue SYSV_ABI Reader__u8__fastpath(JSC::JSGlobalObject* arg0, void* arg1, int64_t arg2, int32_t arg3); extern "C" JSC::EncodedJSValue SYSV_ABI Reader__u8__slowpath(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1, JSC::EncodedJSValue* arg2, size_t arg3); #endif @@ -341,7 +273,6 @@ CPP_DECL void Reader__u16__put(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JS #ifdef __cplusplus -extern "C" JSC::EncodedJSValue SYSV_ABI Reader__u16__fastpath(JSC::JSGlobalObject* arg0, void* arg1, int64_t arg2, int32_t arg3); extern "C" JSC::EncodedJSValue SYSV_ABI Reader__u16__slowpath(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1, JSC::EncodedJSValue* arg2, size_t arg3); #endif @@ -349,7 +280,6 @@ CPP_DECL void Reader__u32__put(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JS #ifdef __cplusplus -extern "C" JSC::EncodedJSValue SYSV_ABI Reader__u32__fastpath(JSC::JSGlobalObject* arg0, void* arg1, int64_t arg2, int32_t arg3); extern "C" JSC::EncodedJSValue SYSV_ABI Reader__u32__slowpath(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1, JSC::EncodedJSValue* arg2, size_t arg3); #endif @@ -357,7 +287,6 @@ CPP_DECL void Reader__ptr__put(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JS #ifdef __cplusplus -extern "C" JSC::EncodedJSValue SYSV_ABI Reader__ptr__fastpath(JSC::JSGlobalObject* arg0, void* arg1, int64_t arg2, int32_t arg3); extern "C" JSC::EncodedJSValue SYSV_ABI Reader__ptr__slowpath(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1, JSC::EncodedJSValue* arg2, size_t arg3); #endif @@ -365,7 +294,6 @@ CPP_DECL void Reader__i8__put(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSV #ifdef __cplusplus -extern "C" JSC::EncodedJSValue SYSV_ABI Reader__i8__fastpath(JSC::JSGlobalObject* arg0, void* arg1, int64_t arg2, int32_t arg3); extern "C" JSC::EncodedJSValue SYSV_ABI Reader__i8__slowpath(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1, JSC::EncodedJSValue* arg2, size_t arg3); #endif @@ -373,7 +301,6 @@ CPP_DECL void Reader__i16__put(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JS #ifdef __cplusplus -extern "C" JSC::EncodedJSValue SYSV_ABI Reader__i16__fastpath(JSC::JSGlobalObject* arg0, void* arg1, int64_t arg2, int32_t arg3); extern "C" JSC::EncodedJSValue SYSV_ABI Reader__i16__slowpath(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1, JSC::EncodedJSValue* arg2, size_t arg3); #endif @@ -381,7 +308,6 @@ CPP_DECL void Reader__i32__put(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JS #ifdef __cplusplus -extern "C" JSC::EncodedJSValue SYSV_ABI Reader__i32__fastpath(JSC::JSGlobalObject* arg0, void* arg1, int64_t arg2, int32_t arg3); extern "C" JSC::EncodedJSValue SYSV_ABI Reader__i32__slowpath(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1, JSC::EncodedJSValue* arg2, size_t arg3); #endif @@ -389,7 +315,6 @@ CPP_DECL void Reader__f32__put(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JS #ifdef __cplusplus -extern "C" JSC::EncodedJSValue SYSV_ABI Reader__f32__fastpath(JSC::JSGlobalObject* arg0, void* arg1, int64_t arg2, int32_t arg3); extern "C" JSC::EncodedJSValue SYSV_ABI Reader__f32__slowpath(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1, JSC::EncodedJSValue* arg2, size_t arg3); #endif @@ -397,7 +322,6 @@ CPP_DECL void Reader__f64__put(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JS #ifdef __cplusplus -extern "C" JSC::EncodedJSValue SYSV_ABI Reader__f64__fastpath(JSC::JSGlobalObject* arg0, void* arg1, int64_t arg2, int32_t arg3); extern "C" JSC::EncodedJSValue SYSV_ABI Reader__f64__slowpath(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1, JSC::EncodedJSValue* arg2, size_t arg3); #endif @@ -405,7 +329,6 @@ CPP_DECL void Reader__i64__put(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JS #ifdef __cplusplus -extern "C" JSC::EncodedJSValue SYSV_ABI Reader__i64__fastpath(JSC::JSGlobalObject* arg0, void* arg1, int64_t arg2, int32_t arg3); extern "C" JSC::EncodedJSValue SYSV_ABI Reader__i64__slowpath(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1, JSC::EncodedJSValue* arg2, size_t arg3); #endif @@ -413,7 +336,6 @@ CPP_DECL void Reader__u64__put(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JS #ifdef __cplusplus -extern "C" JSC::EncodedJSValue SYSV_ABI Reader__u64__fastpath(JSC::JSGlobalObject* arg0, void* arg1, int64_t arg2, int32_t arg3); extern "C" JSC::EncodedJSValue SYSV_ABI Reader__u64__slowpath(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1, JSC::EncodedJSValue* arg2, size_t arg3); #endif @@ -421,7 +343,6 @@ CPP_DECL void Reader__intptr__put(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue #ifdef __cplusplus -extern "C" JSC::EncodedJSValue SYSV_ABI Reader__intptr__fastpath(JSC::JSGlobalObject* arg0, void* arg1, int64_t arg2, int32_t arg3); extern "C" JSC::EncodedJSValue SYSV_ABI Reader__intptr__slowpath(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1, JSC::EncodedJSValue* arg2, size_t arg3); #endif @@ -434,9 +355,7 @@ CPP_DECL bool Zig__GlobalObject__resetModuleRegistryMap(JSC::JSGlobalObject* arg #ifdef __cplusplus -ZIG_DECL void Zig__GlobalObject__fetch(ErrorableResolvedSource* arg0, JSC::JSGlobalObject* arg1, BunString* arg2, BunString* arg3); ZIG_DECL void Zig__GlobalObject__onCrash(); -ZIG_DECL JSC::EncodedJSValue Zig__GlobalObject__promiseRejectionTracker(JSC::JSGlobalObject* arg0, JSC::JSPromise* arg1, uint32_t JSPromiseRejectionOperation2); ZIG_DECL JSC::EncodedJSValue Zig__GlobalObject__reportUncaughtException(JSC::JSGlobalObject* arg0, JSC::Exception* arg1); ZIG_DECL void Zig__GlobalObject__resolve(ErrorableString* arg0, JSC::JSGlobalObject* arg1, BunString* arg2, BunString* arg3, BunString* arg4); @@ -686,7 +605,6 @@ ZIG_DECL JSC::EncodedJSValue Bun__Process__setCwd(JSC::JSGlobalObject* arg0, Zig ZIG_DECL JSC::EncodedJSValue Bun__Process__getEval(JSC::JSGlobalObject* arg0); #endif -CPP_DECL ZigException ZigException__fromException(JSC::Exception* arg0); #pragma mark - Bun::ConsoleObject @@ -696,11 +614,6 @@ CPP_DECL ZigException ZigException__fromException(JSC::Exception* arg0); extern "C" SYSV_ABI void Bun__ConsoleObject__count(void* arg0, JSC::JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3); extern "C" SYSV_ABI void Bun__ConsoleObject__countReset(void* arg0, JSC::JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3); extern "C" SYSV_ABI void Bun__ConsoleObject__messageWithTypeAndLevel(void* arg0, uint32_t MessageType1, uint32_t MessageLevel2, JSC::JSGlobalObject* arg3, JSC::EncodedJSValue* arg4, size_t arg5); -extern "C" SYSV_ABI void Bun__ConsoleObject__profile(void* arg0, JSC::JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3); -extern "C" SYSV_ABI void Bun__ConsoleObject__profileEnd(void* arg0, JSC::JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3); -extern "C" SYSV_ABI void Bun__ConsoleObject__record(void* arg0, JSC::JSGlobalObject* arg1, ScriptArguments* arg2); -extern "C" SYSV_ABI void Bun__ConsoleObject__recordEnd(void* arg0, JSC::JSGlobalObject* arg1, ScriptArguments* arg2); -extern "C" SYSV_ABI void Bun__ConsoleObject__screenshot(void* arg0, JSC::JSGlobalObject* arg1, ScriptArguments* arg2); extern "C" SYSV_ABI void Bun__ConsoleObject__takeHeapSnapshot(void* arg0, JSC::JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3); extern "C" SYSV_ABI void Bun__ConsoleObject__time(void* arg0, JSC::JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3); extern "C" SYSV_ABI void Bun__ConsoleObject__timeEnd(void* arg0, JSC::JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3); @@ -717,7 +630,6 @@ extern "C" SYSV_ABI void Bun__ConsoleObject__timeStamp(void* arg0, JSC::JSGlobal ZIG_DECL JSC::EncodedJSValue Bun__Timer__clearImmediate(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1); ZIG_DECL JSC::EncodedJSValue Bun__Timer__clearInterval(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1); ZIG_DECL JSC::EncodedJSValue Bun__Timer__clearTimeout(JSC::JSGlobalObject* arg0, JSC::EncodedJSValue JSValue1); -ZIG_DECL int32_t Bun__Timer__getNextID(); ZIG_DECL JSC::EncodedJSValue Bun__Timer__setInterval(JSC::JSGlobalObject* globalThis, JSC::EncodedJSValue callback, JSC::EncodedJSValue arguments, JSC::EncodedJSValue countdown); ZIG_DECL JSC::EncodedJSValue Bun__Timer__setTimeout(JSC::JSGlobalObject* globalThis, JSC::EncodedJSValue callback, JSC::EncodedJSValue arguments, JSC::EncodedJSValue countdown); ZIG_DECL JSC::EncodedJSValue Bun__Timer__sleep(JSC::JSGlobalObject* globalThis, JSC::EncodedJSValue promise, JSC::EncodedJSValue countdown); diff --git a/src/jsc/bindings/helpers.h b/src/jsc/bindings/helpers.h index ac788968f214..7900d719d265 100644 --- a/src/jsc/bindings/helpers.h +++ b/src/jsc/bindings/helpers.h @@ -235,11 +235,6 @@ static void appendToBuilder(ZigString str, WTF::StringBuilder& builder) builder.append({ untag(str.ptr), str.len }); } -static const JSC::JSString* toJSString(ZigString str, JSC::JSGlobalObject* global) -{ - return JSC::jsOwnedString(global->vm(), toString(str)); -} - static JSC::JSString* toJSStringGC(ZigString str, JSC::JSGlobalObject* global) { return JSC::jsString(global->vm(), toStringCopy(str)); diff --git a/src/jsc/bindings/linux_perf_tracing.cpp b/src/jsc/bindings/linux_perf_tracing.cpp index 07187ca171fc..e15d06332111 100644 --- a/src/jsc/bindings/linux_perf_tracing.cpp +++ b/src/jsc/bindings/linux_perf_tracing.cpp @@ -39,15 +39,6 @@ int Bun__linux_trace_init() return (trace_fd != -1) ? 1 : 0; } -// Close the trace file descriptor -void Bun__linux_trace_close() -{ - if (trace_fd != -1) { - close(trace_fd); - trace_fd = -1; - } -} - // Write a trace event to the trace marker // Format: "C|PID|EventName|DurationInNs" int Bun__linux_trace_emit(const char* event_name, int64_t duration_ns) diff --git a/src/jsc/bindings/napi.h b/src/jsc/bindings/napi.h index 05b95066da16..d39824af3c13 100644 --- a/src/jsc/bindings/napi.h +++ b/src/jsc/bindings/napi.h @@ -318,11 +318,6 @@ struct NapiEnv : public WTF::RefCounted { return *m_finalizers.add({ callback, hint, data }).iterator; } - bool hasFinalizers() const - { - return !m_finalizers.isEmpty(); - } - /// Will abort the process if a duplicate entry would be added. /// This matches Node.js behavior which always crashes on duplicates. void addCleanupHook(void (*function)(void*), void* data) @@ -408,11 +403,6 @@ struct NapiEnv : public WTF::RefCounted { } } - bool isVMTerminating() const - { - return this->vm().hasTerminationRequest(); - } - void doFinalizer(napi_finalize finalize_cb, void* data, void* finalize_hint) { if (!finalize_cb) { diff --git a/src/jsc/bun_string_jsc.rs b/src/jsc/bun_string_jsc.rs index 7edd84e60e58..2067a1685f05 100644 --- a/src/jsc/bun_string_jsc.rs +++ b/src/jsc/bun_string_jsc.rs @@ -26,7 +26,6 @@ unsafe extern "C" { ) -> JSValue; safe fn JSC__createError(global: &JSGlobalObject, str_: &String) -> JSValue; safe fn JSC__createTypeError(global: &JSGlobalObject, str_: &String) -> JSValue; - safe fn JSC__createRangeError(global: &JSGlobalObject, str_: &String) -> JSValue; } // ── bun.String methods ────────────────────────────────────────────────────── @@ -49,12 +48,6 @@ pub(crate) fn to_type_error_instance(this: &String, global_object: &JSGlobalObje result } -pub(crate) fn to_range_error_instance(this: &String, global_object: &JSGlobalObject) -> JSValue { - let result = JSC__createRangeError(global_object, this); - this.deref(); - result -} - #[inline] #[track_caller] pub fn from_js(value: JSValue, global_object: &JSGlobalObject) -> JsResult { diff --git a/src/jsc/event_loop.rs b/src/jsc/event_loop.rs index aa9643fe10ef..295d71a91b49 100644 --- a/src/jsc/event_loop.rs +++ b/src/jsc/event_loop.rs @@ -315,14 +315,6 @@ impl EventLoop { result } - /// SAFETY: returns `&mut` into VM-owned scratch; two calls alias the same - /// buffer. Caller must not hold another live `&mut` to it. - pub unsafe fn pipe_read_buffer(&mut self) -> &mut [u8] { - // SAFETY: vm() is the live owning VM; rare_data() lazily inits the - // per-VM scratch buffer. Caller contract (see doc): no concurrent &mut. - unsafe { &mut (*self.vm()).rare_data().pipe_read_buffer()[..] } - } - pub fn drain_microtasks_with_global( &mut self, global_object: &JSGlobalObject, @@ -1079,19 +1071,6 @@ impl EventLoop { } impl EventLoop { - /// # Safety - /// `done` must point to a live `bool`; C++ writes `true` through it from a - /// callback inside `tick()`, so it cannot be a Rust `&mut` (would alias). - pub unsafe fn tick_while_paused(&mut self, done: *const bool) { - // SAFETY: see fn contract — `done` is a live FFI bool written by C++. - while !unsafe { done.read_volatile() } { - self.vm_ref() - .platform_loop_opt() - .expect("event_loop_handle") - .tick(); - } - } - /// Prefer `runCallbackWithResult` unless you really need to make sure that microtasks are drained. pub fn run_callback_with_result_and_forcefully_drain_microtasks( &mut self, @@ -1301,43 +1280,12 @@ bun_event_loop::link_impl_JsEventLoop! { // Windows that and `VM::uws_loop()` (= `uws::Loop::get()`) are different // code paths. Route through `usockets_loop()`. iteration_number() => (&*(*this).usockets_loop()).iteration_number(), - // Return raw to avoid asserting uniqueness — multiple handles may name the - // same VM. - file_polls() => core::ptr::from_mut( - (*this) - .vm_ref() - .as_mut() - .rare_data() - .file_polls - .get_or_insert_with(|| Box::new(Async::file_poll::Store::init())) - .as_mut(), - ), - put_file_poll(poll, was_ever_registered) => { - // `Store::put` only needs the VM as an opaque `EventLoopCtx`; reach it - // via the JS-ctx hook so we don't form a competing `&mut VirtualMachine` - // while holding the store. - let store = core::ptr::from_mut( - (*this) - .vm_ref() - .as_mut() - .rare_data() - .file_polls - .get_or_insert_with(|| Box::new(Async::file_poll::Store::init())) - .as_mut(), - ); - let ctx = Async::posix_event_loop::get_vm_ctx(Async::AllocatorType::Js); - // `poll` is a live hive-slot pointer (vtable contract) — non-null. - (*store).put(core::ptr::NonNull::new_unchecked(poll), ctx, was_ever_registered); - }, uws_loop() => (*this).usockets_loop(), - pipe_read_buffer() => core::ptr::from_mut::<[u8]>((*this).pipe_read_buffer()), tick() => (*this).tick(), auto_tick() => (*this).auto_tick(), auto_tick_active() => (*this).auto_tick_active(), global_object() => (*this).global.map_or(core::ptr::null_mut(), |p| p.as_ptr().cast()), bun_vm() => (*this).virtual_machine.map_or(core::ptr::null_mut(), |p| p.as_ptr().cast()), - stdout() => (*this).vm_ref().as_mut().rare_data().stdout().cast(), - stderr() => (*this).vm_ref().as_mut().rare_data().stderr().cast(), enter() => (*this).enter(), exit() => (*this).exit(), enqueue_task(task) => (*this).enqueue_task(task), diff --git a/src/jsc/lib.rs b/src/jsc/lib.rs index b59ace1f259f..b61e3aabe95e 100644 --- a/src/jsc/lib.rs +++ b/src/jsc/lib.rs @@ -7,9 +7,9 @@ //! 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`) -//! 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`. +//! 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`. #![allow(deprecated, non_snake_case)] #![allow(unexpected_cfgs)] @@ -1502,7 +1502,6 @@ pub trait StringJsc { fn to_js_by_parse_json(&mut self, global: &JSGlobalObject) -> JsResult; fn to_error_instance(&self, global: &JSGlobalObject) -> JSValue; fn to_type_error_instance(&self, global: &JSGlobalObject) -> JSValue; - fn to_range_error_instance(&self, global: &JSGlobalObject) -> JSValue; } impl StringJsc for bun_core::String { fn from_js(value: JSValue, global: &JSGlobalObject) -> JsResult { @@ -1523,9 +1522,6 @@ impl StringJsc for bun_core::String { fn to_type_error_instance(&self, global: &JSGlobalObject) -> JSValue { bun_string_jsc::to_type_error_instance(self, global) } - fn to_range_error_instance(&self, global: &JSGlobalObject) -> JSValue { - bun_string_jsc::to_range_error_instance(self, global) - } } /// Extension trait providing JSC-aware methods on diff --git a/src/jsc/virtual_machine_exports.rs b/src/jsc/virtual_machine_exports.rs index c81f5f148d68..4f5e5621e72f 100644 --- a/src/jsc/virtual_machine_exports.rs +++ b/src/jsc/virtual_machine_exports.rs @@ -249,17 +249,6 @@ pub fn set_verbose_fetch_value(value: i32) { })); } -// HOST_EXPORT(Bun__getVerboseFetchValue, c) -pub fn get_verbose_fetch_value() -> i32 { - use bun_http::HTTPVerboseLevel; - // SAFETY: VM singleton is process-lifetime. - match VirtualMachine::get().get_verbose_fetch() { - HTTPVerboseLevel::None => 0, - HTTPVerboseLevel::Headers => 1, - HTTPVerboseLevel::Curl => 2, - } -} - // `Bun__addBakeSourceProviderSourceMap` / `Bun__addDevServerSourceProvider` / // `Bun__removeDevServerSourceProvider` live in // `bun_runtime::bake::source_provider_exports` (their callers are bake's C++ diff --git a/src/runtime/jsc_hooks.rs b/src/runtime/jsc_hooks.rs index 60b81f6a0412..24b9a9ff3963 100644 --- a/src/runtime/jsc_hooks.rs +++ b/src/runtime/jsc_hooks.rs @@ -164,7 +164,7 @@ pub(crate) fn runtime_state() -> *mut RuntimeState { /// Note: `bun_jsc::VirtualMachine.timer` is a `()` placeholder; /// the real `All` lives in [`RuntimeState::timer`] until that slot widens. /// Null only before [`init_runtime_state`] has run (e.g. `bun_jsc` unit tests -/// with no high tier, or `Bun__Timer__getNextID` racing init). +/// with no high tier). /// /// Returns `*mut` (NOT `&mut`) so callers that are themselves fields of `All` /// (`DateHeaderTimer`, `EventLoopDelayMonitor`, `FakeTimers`) can dereference diff --git a/src/runtime/node/util/parse_args.rs b/src/runtime/node/util/parse_args.rs index b9c575cf0cf4..beed585a7689 100644 --- a/src/runtime/node/util/parse_args.rs +++ b/src/runtime/node/util/parse_args.rs @@ -903,7 +903,7 @@ impl<'a> ParseArgsState<'a> { } } -#[bun_jsc::host_fn(export = "Bun__NodeUtil__jsParseArgs")] +#[bun_jsc::host_fn] pub(crate) fn parse_args(global: &JSGlobalObject, callframe: &CallFrame) -> JsResult { MarkedArgumentBuffer::new(|default_roots| parse_args_impl(global, callframe, default_roots)) } diff --git a/src/runtime/test_runner/jest.classes.ts b/src/runtime/test_runner/jest.classes.ts index cb7c7b8d5735..d7705c5886cd 100644 --- a/src/runtime/test_runner/jest.classes.ts +++ b/src/runtime/test_runner/jest.classes.ts @@ -5,7 +5,6 @@ export default [ name: "ExpectAnything", construct: false, noConstructor: true, - call: true, finalize: true, JSType: "0b11101110", configurable: false, @@ -16,7 +15,6 @@ export default [ name: "ExpectAny", construct: false, noConstructor: true, - call: true, finalize: true, JSType: "0b11101110", values: ["constructorValue"], @@ -28,7 +26,6 @@ export default [ name: "ExpectCloseTo", construct: false, noConstructor: true, - call: true, finalize: true, JSType: "0b11101110", values: ["numberValue", "digitsValue"], @@ -40,7 +37,6 @@ export default [ name: "ExpectObjectContaining", construct: false, noConstructor: true, - call: true, finalize: true, JSType: "0b11101110", values: ["objectValue"], @@ -52,7 +48,6 @@ export default [ name: "ExpectStringContaining", construct: false, noConstructor: true, - call: true, finalize: true, JSType: "0b11101110", values: ["stringValue"], @@ -64,7 +59,6 @@ export default [ name: "ExpectStringMatching", construct: false, noConstructor: true, - call: true, finalize: true, JSType: "0b11101110", values: ["testValue"], @@ -76,7 +70,6 @@ export default [ name: "ExpectArrayContaining", construct: false, noConstructor: true, - call: true, finalize: true, JSType: "0b11101110", values: ["arrayValue"], diff --git a/src/runtime/timer/Timer.rs b/src/runtime/timer/Timer.rs index 99d3b90ed1a1..cf263e4c16e5 100644 --- a/src/runtime/timer/Timer.rs +++ b/src/runtime/timer/Timer.rs @@ -19,26 +19,13 @@ use super::{ All, CountdownOverflowBehavior, DateHeaderTimer, EventLoopTimer, EventLoopTimerState, EventLoopTimerTag, ImmediateObject, Kind, TimeoutObject, TimeoutWarning, TimerObjectInternals, }; -use crate::jsc_hooks::{timer_all, timer_all_mut}; +use crate::jsc_hooks::timer_all_mut; // ════════════════════════════════════════════════════════════════════════════ // JS-facing surface on `super::All` // ════════════════════════════════════════════════════════════════════════════ impl All { - #[unsafe(no_mangle)] - pub(crate) extern "C" fn Bun__Timer__getNextID() -> i32 { - let all = timer_all(); - if all.is_null() { - return 0; - } - // SAFETY: `all` is the live per-thread `All`; single-threaded JS heap. - unsafe { - (*all).last_id = (*all).last_id.wrapping_add(1); - (*all).last_id - } - } - /// # Safety /// `vm` must point to the live per-thread `VirtualMachine`. // Forwards `vm` to `DateHeaderTimer::enable` without dereferencing it here; @@ -499,17 +486,6 @@ impl DateHeaderTimer { // C-ABI export thunks // ════════════════════════════════════════════════════════════════════════════ -// HOST_EXPORT(Bun__internal_drainTimers, c) -pub fn drain_timers_export(vm: *mut VirtualMachine) { - let all = timer_all(); - if all.is_null() { - return; - } - // SAFETY: `all` is the live per-thread `All`; `vm` is the erased VM pointer - // (mod.rs::All::drain_timers takes `*mut ()`). - unsafe { (*all).drain_timers(vm.cast::<()>()) }; -} - // `generate-host-exports.ts` // scrapes the `// HOST_EXPORT` markers below and emits the seven thunks into // `generated_host_exports.rs`, each routing through `host_fn::host_fn_result`. diff --git a/src/runtime/webcore/blob/Store.rs b/src/runtime/webcore/blob/Store.rs index 35c6943d07d0..e71719ee1e6d 100644 --- a/src/runtime/webcore/blob/Store.rs +++ b/src/runtime/webcore/blob/Store.rs @@ -535,17 +535,3 @@ impl BytesExt for Bytes { } } } - -/// JSC `ArrayBuffer` external -/// deallocator callback for buffers backed by a `Blob.Store`. C++ stashes a -/// `*mut Store` as the deallocator context; this releases that ref. -#[unsafe(no_mangle)] -pub(crate) extern "C" fn BlobArrayBuffer_deallocator( - _bytes: *mut core::ffi::c_void, - blob: *mut core::ffi::c_void, -) { - // SAFETY: `blob` is the non-null `*mut Store` C++ stashed as deallocator - // context (originating from `heap::alloc` / `StoreRef::into_raw`); it - // owns one outstanding reference being released here. - unsafe { Store::deref(NonNull::new_unchecked(blob.cast::())) }; -} diff --git a/src/sql_jsc/postgres/PostgresSQLConnection.rs b/src/sql_jsc/postgres/PostgresSQLConnection.rs index 79acc2828f2f..f511148715ed 100644 --- a/src/sql_jsc/postgres/PostgresSQLConnection.rs +++ b/src/sql_jsc/postgres/PostgresSQLConnection.rs @@ -1054,8 +1054,7 @@ impl PostgresSQLConnection { } } -// The attribute emits the JSC-callconv shim under the exported symbol. -#[bun_jsc::host_fn(export = "PostgresSQLConnection__createInstance")] +#[bun_jsc::host_fn] pub(crate) fn call(global_object: &JSGlobalObject, callframe: &CallFrame) -> JsResult { // `bun_vm()` → `&'static VirtualMachine` (per-thread singleton); `as_mut()` // is the canonical safe escape hatch (one audited unsafe in bun_jsc) for diff --git a/test/internal/source-lints/dead-symbols-ffi-shims-dispatch.test.ts b/test/internal/source-lints/dead-symbols-ffi-shims-dispatch.test.ts new file mode 100644 index 000000000000..dc19a0d5b79c --- /dev/null +++ b/test/internal/source-lints/dead-symbols-ffi-shims-dispatch.test.ts @@ -0,0 +1,258 @@ +// Guards against reintroduction of symbols removed as dead code from the +// Rust <-> C++ FFI shim layer (bindings.cpp / headers.h), the +// `bun_dispatch::link_interface!` tables, a handful of `#[no_mangle]` Rust +// exports nothing in C++ calls any more, and two codegen surfaces +// (generate-jssink.ts, jest.classes.ts) that emitted functions nothing +// referenced. +// +// Every function below was reported unreferenced by relinking the debug +// binary with `--gc-sections --print-gc-sections`, then confirmed to have no +// textual reference (other than its own declaration/definition and generated +// wrappers) across src/, packages/, scripts/ and build/debug/codegen/, so that +// code only live on another platform was left alone. The removal was +// validated by a full `bun bd` build and `bun run rust:check-all`. +// +// 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"); +} + +function resurrected(checks: Array<[string, RegExp]>): string[] { + const cache = new Map(); + const read = (p: string) => { + let s = cache.get(p); + if (s === undefined) { + s = src(p); + cache.set(p, s); + } + return s; + }; + return checks.filter(([file, re]) => re.test(read(file))).map(([file, re]) => `${file}: ${re.source}`); +} + +test("C-ABI shims in bindings.cpp that no Rust code calls stay deleted", () => { + const bindings = "src/jsc/bindings/bindings.cpp"; + const headers = "src/jsc/bindings/headers.h"; + const names = [ + // JSValue predicates / constructors: the Rust JSValue type implements + // these inline; the shims (and their cppbind wrappers) had no callers. + "JSC__JSValue__isCell", + "JSC__JSValue__isNull", + "JSC__JSValue__isUndefined", + "JSC__JSValue__isUndefinedOrNull", + "JSC__JSValue__isNumber", + "JSC__JSValue__isObject", + "JSC__JSValue__isInt32", + "JSC__JSValue__isInt32AsAnyInt", + "JSC__JSValue__isError", + "JSC__JSValue__isGetterSetter", + "JSC__JSValue__isCustomGetterSetter", + "JSC__JSValue__eqlCell", + "JSC__JSValue__deepEquals", + "JSC__JSValue__jsNumberFromChar", + "JSC__JSValue__jsNumberFromU16", + "JSC__JSValue__jsNumberFromInt32", + "JSC__JSValue__jsNumberFromInt64", + "JSC__JSValue__jsNumberFromUint64", + "JSC__JSValue__jsTDZValue", + "JSC__JSValue__jsType", + "JSC__JSValue__createInternalPromise", + "JSC__JSValue__createRangeError", + "JSC__JSValue__createTypeError", + "JSC__JSValue__fastGetDirect_", + "JSC__JSValue__getPropertyValue", + "JSC__JSValue__putRecord", + "JSC__JSValue__symbolKeyFor", + // JSInternalPromise was aliased to JSPromise; only resolvedPromise is used. + "JSC__JSInternalPromise__create", + "JSC__JSInternalPromise__isHandled", + "JSC__JSInternalPromise__reject", + "JSC__JSInternalPromise__rejectAsHandled", + "JSC__JSInternalPromise__rejectAsHandledException", + "JSC__JSInternalPromise__rejectedPromise", + "JSC__JSInternalPromise__resolve", + "JSC__JSInternalPromise__result", + "JSC__JSInternalPromise__setHandled", + "JSC__JSInternalPromise__status", + "JSC__JSPromise__asValue", + "JSC__JSPromise__isHandled", + "JSC__JSPromise__resolveOnNextTick", + "JSC__JSPromise__rejectOnNextTickWithHandled", + // Object / cell / string / module-loader helpers. + "JSC__JSObject__getArrayLength", + "JSC__JSObject__getDirect", + "JSC__JSObject__putDirect", + "JSC__JSCell__getObject", + "JSC__JSCell__toObject", + "JSC__JSString__toObject", + "JSC__JSFunction__optimizeSoon", + "JSC__JSGlobalObject__getCachedObject", + "JSC__JSGlobalObject__putCachedObject", + "JSC__JSMap__has", + "JSC__JSModuleLoader__evaluate", + "JSC__createRangeError", + // VM: execution time limits, watchdog / shell-timeout traps, JIT query. + "JSC__VM__clearExecutionTimeLimit", + "JSC__VM__setExecutionTimeLimit", + "JSC__VM__deleteAllCode", + "JSC__VM__isEntered", + "JSC__VM__isJITEnabled", + "JSC__VM__notifyNeedShellTimeoutCheck", + "JSC__VM__notifyNeedWatchdogCheck", + "JSC__VM__performOpportunisticallyScheduledTasks", + // ZigString / DOMURL / FetchHeaders conversions superseded by BunString. + "ZigString__to16BitValue", + "ZigString__toAtomicValue", + "ZigString__toExternalValueWithCallback", + "WebCore__DOMURL__href_", + "WebCore__DOMURL__pathname_", + "WebCore__FetchHeaders__createValue", + "Bun__CallFrame__isFromBunMain", + ]; + const checks: Array<[string, RegExp]> = names.flatMap(name => { + const re = new RegExp(`\\b${name}\\s*\\(`); + return [ + [bindings, re], + [headers, re], + ] as Array<[string, RegExp]>; + }); + // Only these shims used it. + checks.push(["src/jsc/bindings/helpers.h", /\btoJSString\(/]); + // Rust callers of the two shims above that were themselves unreferenced. + checks.push(["src/jsc/bun_string_jsc.rs", /JSC__createRangeError|fn to_range_error_instance/]); + checks.push(["src/jsc/FetchHeaders.rs", /WebCore__FetchHeaders__createValue\b/]); + expect(resurrected(checks)).toEqual([]); +}); + +test("declarations in headers.h for functions that no longer exist stay deleted", () => { + const headers = "src/jsc/bindings/headers.h"; + const checks: Array<[string, RegExp]> = [ + // The DOMJIT fast paths were removed long ago; only the slow paths exist. + [headers, /__fastpath\b/], + [headers, /\bJSC__JSGlobalObject__createSyntheticModule_\b/], + [headers, /\bJSC__JSValue__then\b/], + [headers, /\bJSC__JSValue__createStringArray\b/], + [headers, /\bJSC__JSValue__hasOwnProperty\b/], + [headers, /\bJSC__JSValue__toString\b/], + [headers, /\bJSC__VM__create\b/], + [headers, /\bZigException__fromException\b/], + [headers, /\bZig__GlobalObject__fetch\b/], + [headers, /\bZig__GlobalObject__promiseRejectionTracker\b/], + [headers, /\b_fromJS\b/], + ]; + expect(resurrected(checks)).toEqual([]); +}); + +test("Rust exports nothing in C++ calls stay deleted", () => { + const checks: Array<[string, RegExp]> = [ + // ConsoleObject.cpp only forwards timeStamp; the other no-op hooks had no + // C++ caller. + [ + "src/jsc/ConsoleObject.rs", + /console_noop_hooks|Bun__ConsoleObject__(profile|profileEnd|record|recordEnd|screenshot)\b/, + ], + ["src/jsc/bindings/headers.h", /Bun__ConsoleObject__(profile|profileEnd|record|recordEnd|screenshot)\b/], + ["src/jsc/bindings/headers.h", /\bBun__Timer__getNextID\b/], + ["src/runtime/timer/Timer.rs", /\bBun__Timer__getNextID\b|\bBun__internal_drainTimers\b|fn drain_timers_export\b/], + // BunDebugger.cpp's runWhilePaused blocks on a condition variable now. + ["src/jsc/JSCScheduler.rs", /\bBun__tickWhilePaused\b/], + ["src/jsc/event_loop.rs", /fn tick_while_paused\b|fn pipe_read_buffer\b/], + ["src/jsc/bindings/BunDebugger.cpp", /\bBun__tickWhilePaused\b/], + ["src/jsc/virtual_machine_exports.rs", /\bBun__getVerboseFetchValue\b|fn get_verbose_fetch_value\b/], + ["src/jsc/bindings/JSEnvironmentVariableMap.cpp", /\bBun__getVerboseFetchValue\b/], + // ref/deref are inlined in Rust; only the destroy slow path crosses FFI. + ["src/jsc/bindings/BunString.cpp", /\bBun__WTFStringImpl__(ref|deref)\b/], + ["src/jsc/bindings/headers-handwritten.h", /\bBun__WTFStringImpl__(ref|deref)\b/], + ["src/bun_alloc/lib.rs", /\bBun__WTFStringImpl__(ref|deref)\b/], + // Blob.rs has blob_store_array_buffer_deallocator; this was the Zig-era twin. + ["src/runtime/webcore/blob/Store.rs", /\bBlobArrayBuffer_deallocator\b/], + // WebSocket.cpp sends blobs through writeBinaryData. + ["src/http_jsc/websocket_client.rs", /\bwrite_blob\b|__writeBlob\b/], + ["src/bun_core/util.rs", /\bBun__linux_trace_close\b/], + ["src/jsc/bindings/linux_perf_tracing.cpp", /\bBun__linux_trace_close\b/], + // Exported names no C++ declared a caller for; both functions are reached + // through Rust tables instead. + ["src/runtime/node/util/parse_args.rs", /\bBun__NodeUtil__jsParseArgs\b/], + ["src/jsc/bindings/ZigGlobalObject.cpp", /\bBun__NodeUtil__jsParseArgs\b/], + ["src/sql_jsc/postgres/PostgresSQLConnection.rs", /\bPostgresSQLConnection__createInstance\b/], + // Only i64 comparisons are performed against BigInts. + ["src/jsc/JSBigInt.rs", /\bJSC__JSBigInt__order(Double|Uint64)\b|BigIntOrderable for (f64|u64)\b/], + ["src/jsc/bindings/JSBigIntBinding.cpp", /\bJSC__JSBigInt__order(Double|Uint64)\b/], + ]; + expect(resurrected(checks)).toEqual([]); +}); + +test("link_interface! methods nothing dispatched through stay deleted", () => { + const checks: Array<[string, RegExp]> = [ + ["src/event_loop/lib.rs", /^\s*fn (file_polls|put_file_poll|pipe_read_buffer|stdout|stderr)\(/m], + ["src/jsc/event_loop.rs", /^\s*(file_polls|put_file_poll|pipe_read_buffer|stdout|stderr)\(.*=>/m], + ["src/bun_core/lib.rs", /^\s*fn (max_dense|win32_name)\(/m], + ["src/errno/lib.rs", /\bwin32_errno_name\b|\bsystem_errno_max_dense\b|^\s*(max_dense|win32_name)\(.*=>/m], + ["src/ast/transpiler_cache.rs", /^\s*fn is_disabled\(/m], + ["src/jsc/RuntimeTranspilerCache.rs", /^\s*is_disabled\(\)\s*=>/m], + ]; + expect(resurrected(checks)).toEqual([]); +}); + +test("dead C++ helpers on the global object stay deleted", () => { + const cpp = "src/jsc/bindings/ZigGlobalObject.cpp"; + const h = "src/jsc/bindings/ZigGlobalObject.h"; + const checks: Array<[string, RegExp]> = [ + // `navigator` / `performance` / `File` are installed from the LUT and the + // lazy-property tables directly. + [cpp, /\bJSDOMFileConstructor_(getter|setter)\b/], + [cpp, /\bfunctionLazyNavigatorGetter\b|GlobalObject::navigatorObject\b/], + [cpp, /\bGlobalObject_getPerformanceObject\b/], + [cpp, /GlobalObject::hasNapiFinalizers\b/], + [h, /\bnavigatorObject\(\)/], + [h, /\bperformanceObject\(\)/], + [h, /\bhasNapiFinalizers\(\)/], + ["src/jsc/bindings/napi.h", /\bhasFinalizers\(\)/], + ["src/jsc/bindings/napi.h", /\bisVMTerminating\(\)/], + ["src/jsc/bindings/ScriptExecutionContext.h", /\bpostCrossThreadTask\b/], + // Constructor accessors whose only reader was the generated per-sink + // getter below; Bun.ArrayBufferSink keeps its own. + [ + h, + /JSObject\* (FileSink|HTTPResponseSink|HTTPSResponseSink|NetworkSink|H3ResponseSink|FetchRequestBodySink|HTMLRewriterSink)\(\)/, + ], + [h, /\bNodeVM(SourceText|Synthetic)ModulePrototype\(\)/], + ]; + expect(resurrected(checks)).toEqual([]); +}); + +test("REPL shim exports nothing destructures stay deleted", () => { + const checks: Array<[string, RegExp]> = [ + // Consumers read .inspect, getStringWidth and stripVTControlCharacters only. + ["src/js/internal/repl/node-inspect.js", /get format(WithOptions)?\(\)/], + // completion.js only calls BuiltinModule.getSchemeOnlyModuleNames() and + // destructures constants.{ALL_PROPERTIES, SKIP_SYMBOLS}. + ["src/js/internal/repl/node-shims.js", /^\s*(exists|canBeRequiredByUsers|canBeRequiredWithoutScheme)\(id\)/m], + ["src/js/internal/repl/node-shims.js", /constants: \{[^}]*\b(ONLY_ENUMERABLE|SKIP_STRINGS)\b/], + ]; + expect(resurrected(checks)).toEqual([]); +}); + +test("codegen no longer emits functions nothing references", () => { + const checks: Array<[string, RegExp]> = [ + // function__getter was declared and defined for every sink and + // installed for none of them. + ["src/codegen/generate-jssink.ts", /__getter\b/], + ]; + expect(resurrected(checks)).toEqual([]); + + // The asymmetric matcher classes have no constructor object, so the + // `Class__call` thunk `call: true` generated for them was never + // wired up; the matchers are reached through Expect's static methods. + const jest = src("src/runtime/test_runner/jest.classes.ts"); + const callable = [...jest.matchAll(/name: "(\w+)",[^}]*?\n\s*call: true,/g)].map(m => m[1]).sort(); + expect(callable).toEqual(["Expect", "ExpectTypeOf"]); +});