From 12ce234059fdb37b7ddbf2276727a5bf4737be0e Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Fri, 30 Oct 2026 03:48:07 +0000 Subject: [PATCH 1/6] Remove dead code from the zsh completions, the SQLite lazy loader, and the C++ bindings Delete code that nothing references: - _set_remove and __bun_dynamic_comp in completions/bun.zsh. - The lazy-loader entries of sqlite3_bind_blob, sqlite3_bind_text and sqlite3_bind_text16. The bindings call the 64 variants only. - The Bun::vm(Zig::GlobalObject*) overload. Each call passes a JSC::VM& or a JSC::JSGlobalObject*. - JSFFIFunction::symbolFromDynamicLibrary, which is written and never read. - 19 #include lines that repeat an earlier #include of the same header. - Commented-out code in EventNames.h and JSEventTargetCustom.cpp. - The bun_sha alias of bun_sha_hmac in bun_install. --- completions/bun.zsh | 21 ------------------- src/install/lib.rs | 1 - src/jsc/bindings/BunProcess.cpp | 4 ---- src/jsc/bindings/JSFFIFunction.cpp | 1 - src/jsc/bindings/JSFFIFunction.h | 1 - src/jsc/bindings/ZigGlobalObject.h | 5 ----- src/jsc/bindings/bun-spawn.cpp | 2 -- src/jsc/bindings/c-bindings.cpp | 4 ---- .../node/crypto/DiffieHellmanFunctions.h | 1 - src/jsc/bindings/node/crypto/JSHash.cpp | 1 - src/jsc/bindings/node/crypto/JSHmac.cpp | 1 - src/jsc/bindings/sqlite/lazy_sqlite3.h | 12 ----------- src/jsc/bindings/webcore/EventNames.h | 2 -- src/jsc/bindings/webcore/JSAbortSignal.cpp | 1 - src/jsc/bindings/webcore/JSDOMURL.cpp | 1 - .../bindings/webcore/JSEventTargetCustom.cpp | 4 ---- src/jsc/bindings/webcore/JSWebSocket.cpp | 4 ---- 17 files changed, 66 deletions(-) diff --git a/completions/bun.zsh b/completions/bun.zsh index 54c8034a6776..41c02771eb3e 100644 --- a/completions/bun.zsh +++ b/completions/bun.zsh @@ -1477,10 +1477,6 @@ _bun_test_param_script_completion() { _alternative "files:file:_files -g '*(_|.)(test|spec).(js|ts|jsx|tsx)'" } -_set_remove() { - comm -23 <(echo $1 | sort | tr " " "\n") <(echo $2 | sort | tr " " "\n") 2>/dev/null -} - _bun_add_param_package_completion() { IFS=$'\n' inexact=($(history -n bun | grep -E "^bun add " | cut -c 9- | uniq)) @@ -1510,23 +1506,6 @@ _bun_add_param_package_completion() { } -__bun_dynamic_comp() { - local comp="" - - for arg in scripts; do - local line - while read -r line; do - local name="$line" - local desc="$line" - name="${name%$'\t'*}" - desc="${desc/*$'\t'/}" - echo - done <<<"$arg" - done - - return $comp -} - if ! command -v compinit >/dev/null; then autoload -U compinit && compinit fi diff --git a/src/install/lib.rs b/src/install/lib.rs index 77515fd8a567..7f3b230c155e 100644 --- a/src/install/lib.rs +++ b/src/install/lib.rs @@ -8,7 +8,6 @@ // Self-alias so Phase-A drafts written against `bun_install::…` resolve // without rewriting every `use` (e.g. yarn.rs, extract_tarball.rs, // lifecycle_script_runner.rs). -extern crate bun_sha_hmac as bun_sha; extern crate self as bun_install; // `bun_output::declare_scope!` / `scoped_log!` — the macros live at // `bun_core` crate root (#[macro_export]); alias the crate so the diff --git a/src/jsc/bindings/BunProcess.cpp b/src/jsc/bindings/BunProcess.cpp index cf0a7fbc404a..a1d2c2d12ca0 100644 --- a/src/jsc/bindings/BunProcess.cpp +++ b/src/jsc/bindings/BunProcess.cpp @@ -129,14 +129,10 @@ typedef int mode_t; #endif #if defined(__linux__) || defined(__FreeBSD__) -#include #include -#include -#include #endif #if defined(__FreeBSD__) -#include #include #include #endif diff --git a/src/jsc/bindings/JSFFIFunction.cpp b/src/jsc/bindings/JSFFIFunction.cpp index 0b6655927235..51a77b41d4c9 100644 --- a/src/jsc/bindings/JSFFIFunction.cpp +++ b/src/jsc/bindings/JSFFIFunction.cpp @@ -79,7 +79,6 @@ extern "C" JSC::EncodedJSValue Bun__CreateFFIFunctionValue(Zig::GlobalObject* gl // We should also consider a separate JSFunction type for our usage to not have this branch in the first place... // `functionPointer` is the wrapper with the JSC host function ABI. "ptr" is the C function that it calls. function->putDirect(vm, JSC::Identifier::fromString(vm, String("ptr"_s)), JSC::jsNumber(static_cast(reinterpret_cast(symbolFromDynamicLibrary))), JSC::PropertyAttribute::ReadOnly | 0); - function->symbolFromDynamicLibrary = symbolFromDynamicLibrary; return JSC::JSValue::encode(function); } diff --git a/src/jsc/bindings/JSFFIFunction.h b/src/jsc/bindings/JSFFIFunction.h index 8a54bb73c6df..1210b078b6e9 100644 --- a/src/jsc/bindings/JSFFIFunction.h +++ b/src/jsc/bindings/JSFFIFunction.h @@ -81,7 +81,6 @@ class JSFFIFunction final : public JSC::JSFunction { static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES trampoline(JSGlobalObject* globalObject, CallFrame* callFrame); void* dataPtr; - void* symbolFromDynamicLibrary { nullptr }; private: JSFFIFunction(VM&, NativeExecutable*, JSGlobalObject*, Structure*, CFFIFunction&&); diff --git a/src/jsc/bindings/ZigGlobalObject.h b/src/jsc/bindings/ZigGlobalObject.h index 3c6d866e54b1..07038c8fe385 100644 --- a/src/jsc/bindings/ZigGlobalObject.h +++ b/src/jsc/bindings/ZigGlobalObject.h @@ -748,11 +748,6 @@ namespace Bun { void putDirectNamed(JSC::VM&, JSC::JSObject*, ASCIILiteral name, JSC::JSValue); -ALWAYS_INLINE void* vm(Zig::GlobalObject* globalObject) -{ - return globalObject->bunVM(); -} - ALWAYS_INLINE void* vm(JSC::VM& vm) { return WebCore::clientData(vm)->bunVM; diff --git a/src/jsc/bindings/bun-spawn.cpp b/src/jsc/bindings/bun-spawn.cpp index 74caf0341111..eaf0a9145c20 100644 --- a/src/jsc/bindings/bun-spawn.cpp +++ b/src/jsc/bindings/bun-spawn.cpp @@ -10,8 +10,6 @@ #include #include #include -#include -#include #include #include diff --git a/src/jsc/bindings/c-bindings.cpp b/src/jsc/bindings/c-bindings.cpp index a5dc3ac28b1f..c5ca484c2358 100644 --- a/src/jsc/bindings/c-bindings.cpp +++ b/src/jsc/bindings/c-bindings.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -304,7 +303,6 @@ extern "C" ssize_t bun_close_range(unsigned int start, unsigned int end, unsigne } #if CPU(X86_64) || CPU(ARM64) -#include #include #ifndef SYS_SECCOMP @@ -1333,8 +1331,6 @@ extern "C" int ffi_fileno(FILE* file) // Handle signals in bun.spawnSync. // If we receive a signal, we want to forward the signal to the child process. #if OS(LINUX) || OS(DARWIN) || OS(FREEBSD) -#include -#include #include // The handler below can run on any thread while the spawning thread stores the pid. diff --git a/src/jsc/bindings/node/crypto/DiffieHellmanFunctions.h b/src/jsc/bindings/node/crypto/DiffieHellmanFunctions.h index 47feefb9167f..2b727217d48c 100644 --- a/src/jsc/bindings/node/crypto/DiffieHellmanFunctions.h +++ b/src/jsc/bindings/node/crypto/DiffieHellmanFunctions.h @@ -6,7 +6,6 @@ #include "JSBufferEncodingType.h" #include #include -#include "JSBufferEncodingType.h" #include "ncrypto.h" #include "CryptoUtil.h" #include "JSBuffer.h" diff --git a/src/jsc/bindings/node/crypto/JSHash.cpp b/src/jsc/bindings/node/crypto/JSHash.cpp index 791eca6e0991..407e5455987e 100644 --- a/src/jsc/bindings/node/crypto/JSHash.cpp +++ b/src/jsc/bindings/node/crypto/JSHash.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include "NodeValidator.h" #include diff --git a/src/jsc/bindings/node/crypto/JSHmac.cpp b/src/jsc/bindings/node/crypto/JSHmac.cpp index 8702236f011d..14054e34f205 100644 --- a/src/jsc/bindings/node/crypto/JSHmac.cpp +++ b/src/jsc/bindings/node/crypto/JSHmac.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include "NodeValidator.h" #include #include "KeyObject.h" diff --git a/src/jsc/bindings/sqlite/lazy_sqlite3.h b/src/jsc/bindings/sqlite/lazy_sqlite3.h index f9c964ac80f4..57bf9f9cde7e 100644 --- a/src/jsc/bindings/sqlite/lazy_sqlite3.h +++ b/src/jsc/bindings/sqlite/lazy_sqlite3.h @@ -18,13 +18,10 @@ struct sqlite3_session; struct sqlite3_changeset_iter; } -typedef int (*lazy_sqlite3_bind_blob_type)(sqlite3_stmt*, int, const void*, int n, void (*)(void*)); typedef int (*lazy_sqlite3_bind_blob64_type)(sqlite3_stmt*, int, const void*, sqlite3_uint64, void (*)(void*)); typedef int (*lazy_sqlite3_bind_double_type)(sqlite3_stmt*, int, double); typedef int (*lazy_sqlite3_bind_int64_type)(sqlite3_stmt*, int, sqlite3_int64); typedef int (*lazy_sqlite3_bind_null_type)(sqlite3_stmt*, int); -typedef int (*lazy_sqlite3_bind_text_type)(sqlite3_stmt*, int, const char*, int, void (*)(void*)); -typedef int (*lazy_sqlite3_bind_text16_type)(sqlite3_stmt*, int, const void*, int, void (*)(void*)); typedef int (*lazy_sqlite3_bind_text64_type)(sqlite3_stmt*, int, const char*, sqlite3_uint64, void (*)(void*), unsigned char encoding); typedef int (*lazy_sqlite3_bind_parameter_count_type)(sqlite3_stmt*); typedef int (*lazy_sqlite3_bind_parameter_index_type)(sqlite3_stmt*, const char* zName); @@ -123,15 +120,12 @@ typedef int (*lazy_sqlite3changeset_apply_type)(sqlite3*, int nChangeset, void* // every TU that includes this header (JSSQLStatement.cpp + NodeSqlite.cpp), // so bun:sqlite's Database.setCustomSQLite() also affects node:sqlite and // exactly one dlopen happens per process. -inline lazy_sqlite3_bind_blob_type lazy_sqlite3_bind_blob; inline lazy_sqlite3_bind_blob64_type lazy_sqlite3_bind_blob64; inline lazy_sqlite3_bind_double_type lazy_sqlite3_bind_double; inline lazy_sqlite3_bind_int64_type lazy_sqlite3_bind_int64; inline lazy_sqlite3_bind_null_type lazy_sqlite3_bind_null; inline lazy_sqlite3_bind_parameter_count_type lazy_sqlite3_bind_parameter_count; inline lazy_sqlite3_bind_parameter_index_type lazy_sqlite3_bind_parameter_index; -inline lazy_sqlite3_bind_text_type lazy_sqlite3_bind_text; -inline lazy_sqlite3_bind_text16_type lazy_sqlite3_bind_text16; inline lazy_sqlite3_bind_text64_type lazy_sqlite3_bind_text64; inline lazy_sqlite3_changes_type lazy_sqlite3_changes; inline lazy_sqlite3_changes64_type lazy_sqlite3_changes64; @@ -219,15 +213,12 @@ inline lazy_sqlite3session_changeset_type lazy_sqlite3session_changeset; inline lazy_sqlite3session_patchset_type lazy_sqlite3session_patchset; inline lazy_sqlite3changeset_apply_type lazy_sqlite3changeset_apply; -#define sqlite3_bind_blob lazy_sqlite3_bind_blob #define sqlite3_bind_blob64 lazy_sqlite3_bind_blob64 #define sqlite3_bind_double lazy_sqlite3_bind_double #define sqlite3_bind_int64 lazy_sqlite3_bind_int64 #define sqlite3_bind_null lazy_sqlite3_bind_null #define sqlite3_bind_parameter_count lazy_sqlite3_bind_parameter_count #define sqlite3_bind_parameter_index lazy_sqlite3_bind_parameter_index -#define sqlite3_bind_text lazy_sqlite3_bind_text -#define sqlite3_bind_text16 lazy_sqlite3_bind_text16 #define sqlite3_bind_text64 lazy_sqlite3_bind_text64 #define sqlite3_changes lazy_sqlite3_changes #define sqlite3_changes64 lazy_sqlite3_changes64 @@ -372,15 +363,12 @@ inline int lazyLoadSQLiteUnlocked(WTF::String* errorMessage = nullptr) unloadSQLiteHandleUnlocked(); return -1; } - lazy_sqlite3_bind_blob = (lazy_sqlite3_bind_blob_type)dlsym(sqlite3_handle, "sqlite3_bind_blob"); lazy_sqlite3_bind_blob64 = (lazy_sqlite3_bind_blob64_type)dlsym(sqlite3_handle, "sqlite3_bind_blob64"); lazy_sqlite3_bind_double = (lazy_sqlite3_bind_double_type)dlsym(sqlite3_handle, "sqlite3_bind_double"); lazy_sqlite3_bind_int64 = (lazy_sqlite3_bind_int64_type)dlsym(sqlite3_handle, "sqlite3_bind_int64"); lazy_sqlite3_bind_null = (lazy_sqlite3_bind_null_type)dlsym(sqlite3_handle, "sqlite3_bind_null"); lazy_sqlite3_bind_parameter_count = (lazy_sqlite3_bind_parameter_count_type)dlsym(sqlite3_handle, "sqlite3_bind_parameter_count"); lazy_sqlite3_bind_parameter_index = (lazy_sqlite3_bind_parameter_index_type)dlsym(sqlite3_handle, "sqlite3_bind_parameter_index"); - lazy_sqlite3_bind_text = (lazy_sqlite3_bind_text_type)dlsym(sqlite3_handle, "sqlite3_bind_text"); - lazy_sqlite3_bind_text16 = (lazy_sqlite3_bind_text16_type)dlsym(sqlite3_handle, "sqlite3_bind_text16"); lazy_sqlite3_bind_text64 = (lazy_sqlite3_bind_text64_type)dlsym(sqlite3_handle, "sqlite3_bind_text64"); lazy_sqlite3_changes = (lazy_sqlite3_changes_type)dlsym(sqlite3_handle, "sqlite3_changes"); lazy_sqlite3_changes64 = (lazy_sqlite3_changes64_type)dlsym(sqlite3_handle, "sqlite3_changes64"); diff --git a/src/jsc/bindings/webcore/EventNames.h b/src/jsc/bindings/webcore/EventNames.h index 7103843faf61..bcf6f34d2211 100644 --- a/src/jsc/bindings/webcore/EventNames.h +++ b/src/jsc/bindings/webcore/EventNames.h @@ -21,7 +21,6 @@ #pragma once -// #include "ThreadGlobalData.h" #include "EventTarget.h" #include @@ -70,7 +69,6 @@ struct EventNames { private: EventNames(); // Private to prevent accidental call to EventNames() instead of eventNames(). - // friend class ThreadGlobalData; // Allow ThreadGlobalData to create the per-thread EventNames object. [[maybe_unused]] int dummy; // Needed to make initialization macro work. }; diff --git a/src/jsc/bindings/webcore/JSAbortSignal.cpp b/src/jsc/bindings/webcore/JSAbortSignal.cpp index 5996ca205c02..9cf8002a9843 100644 --- a/src/jsc/bindings/webcore/JSAbortSignal.cpp +++ b/src/jsc/bindings/webcore/JSAbortSignal.cpp @@ -25,7 +25,6 @@ #include "ExtendedDOMClientIsoSubspaces.h" #include "ExtendedDOMIsoSubspaces.h" #include "IDLTypes.h" -#include "JSAbortSignal.h" #include "JSDOMAttribute.h" #include "JSDOMBinding.h" #include "JSDOMConstructorNotConstructable.h" diff --git a/src/jsc/bindings/webcore/JSDOMURL.cpp b/src/jsc/bindings/webcore/JSDOMURL.cpp index 0c3ede088fda..51530c1b3ed9 100644 --- a/src/jsc/bindings/webcore/JSDOMURL.cpp +++ b/src/jsc/bindings/webcore/JSDOMURL.cpp @@ -38,7 +38,6 @@ #include "JSDOMGlobalObject.h" #include "JSDOMGlobalObjectInlines.h" #include "JSDOMOperation.h" -#include "JSDOMURL.h" #include "JSDOMWrapperCache.h" #include "JSURLSearchParams.h" #include "ScriptExecutionContext.h" diff --git a/src/jsc/bindings/webcore/JSEventTargetCustom.cpp b/src/jsc/bindings/webcore/JSEventTargetCustom.cpp index 3f5c855680d3..48fc569ddb92 100644 --- a/src/jsc/bindings/webcore/JSEventTargetCustom.cpp +++ b/src/jsc/bindings/webcore/JSEventTargetCustom.cpp @@ -47,10 +47,6 @@ JSValue toJSNewlyCreated(JSGlobalObject*, JSDOMGlobalObject* globalObject, Ref()) - // return &uncheckedDowncast(asObject(value))->wrapped(); - // if (value.inherits()) - // return &uncheckedDowncast(asObject(value))->wrapped(); if (value.inherits()) return uncheckedDowncast(asObject(value))->globalEventScope.ptr(); if (value.inherits()) diff --git a/src/jsc/bindings/webcore/JSWebSocket.cpp b/src/jsc/bindings/webcore/JSWebSocket.cpp index 4f1f560b9333..aff90e456509 100644 --- a/src/jsc/bindings/webcore/JSWebSocket.cpp +++ b/src/jsc/bindings/webcore/JSWebSocket.cpp @@ -44,9 +44,6 @@ #include "JSDOMGlobalObjectInlines.h" #include "JSDOMIterator.h" #include "JSDOMOperation.h" -#include "JSDOMExceptionHandling.h" -#include "JSDOMGlobalObjectInlines.h" -#include "JSDOMOperation.h" #include "JSDOMWrapperCache.h" #include "JSEventListener.h" #include "ScriptExecutionContext.h" @@ -61,7 +58,6 @@ #include #include #include -#include "IDLTypes.h" #include "FetchHeaders.h" #include "HTTPParsers.h" #include "JSFetchHeaders.h" From 7b5eb29e22d932955eda8e2a6437a5b932ce6c51 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Fri, 30 Oct 2026 03:39:23 +0000 Subject: [PATCH 2/6] Remove what #45631 left unused in the builtins codegen, built-in JS, and bindgen #45631 added these without a reader, or removed their last reader: - signatureOfBindgen, parseBufferAccessors, jsonSerializationUses and unplacedPath in src/codegen/builtins. - Bun::Bindgen::ArgumentInFrame. - $Node.PreallocatedEvents and the emitEventWithArgs re-export of internal/trace_events. - The notImplementedIssueFn build-time macro. - A second include of wtf/WTFConfig.h in c-bindings.cpp. --- src/codegen/builtins/collect-bindgen.ts | 18 ------------------ src/codegen/builtins/collect-registrations.ts | 4 ---- src/codegen/replacements.ts | 5 ----- src/js/builtins.d.ts | 2 -- src/js/internal/streams/readable.ts | 13 ------------- src/js/internal/trace_events.ts | 2 -- src/jsc/bindings/Bindgen/IDLConvert.h | 14 -------------- src/jsc/bindings/c-bindings.cpp | 3 --- 8 files changed, 61 deletions(-) diff --git a/src/codegen/builtins/collect-bindgen.ts b/src/codegen/builtins/collect-bindgen.ts index 6834ccdb1308..8c9b41961e23 100644 --- a/src/codegen/builtins/collect-bindgen.ts +++ b/src/codegen/builtins/collect-bindgen.ts @@ -46,7 +46,6 @@ import { type DispatchDeclaration, type MemberDeclaration, type Problems, - type SignatureDeclaration, type SourcedDeclaration, } from "./declarations.ts"; import * as b from "./lib.ts"; @@ -56,7 +55,6 @@ import { maximumDirectParameterCount, realmParameter, type BuiltinPath, - type CallMode, type Capability, type DirectEntrySpec, type DirectForm, @@ -93,8 +91,6 @@ interface Joins { nativeBindings: ReadonlySet; } -const unplacedPath: BuiltinPath = "%Unplaced%"; - const externalStateHeap: Heap = "ExternalState"; const externalState: readonly Heap[] = [externalStateHeap]; @@ -114,8 +110,6 @@ const usesOfGetterWithoutWrapper: readonly UseSpec[] = [b.readsContents(), b.wri const usesThatReachResult: readonly UseSpec[] = [b.returned, heldValuesAnswered]; -const jsonSerializationUses: readonly UseSpec[] = [b.runsTransitively("OwnKeys", "OwnValues", "ToJSON", "ToPrimitive")]; - /** The thunk of a member takes the cell of its receiver behind the realm. */ const receiverParameter: DirectParameterSpec = { value: "Receiver", cppType: "JSC::JSCell*" }; @@ -420,18 +414,6 @@ function createField( }; } -export function signatureOfBindgen( - signature: Signature, - mode: CallMode, - receiver: ParameterType | null, -): SignatureDeclaration { - const field = createField(signature, createReceiver(signature, receiver, null), signature.returns.resultType); - const [declared] = b - .fn(unplacedPath, field) - .flatMap(declaration => (declaration.declares === "Member" ? declaration.signatures : [])); - return { ...declared, mode }; -} - // The object that is made of a dictionary has a property for each member that is there, in their order, and the file that declares the dictionary declares the layout. function findLayoutOfResult({ returns }: Signature, fn: FunctionDefinition): DictionaryType | null { if (!(returns instanceof DictionaryType) || returns.origin?.stem !== fn.origin?.stem) return null; diff --git a/src/codegen/builtins/collect-registrations.ts b/src/codegen/builtins/collect-registrations.ts index 9cd4f78af871..13fcc81b3844 100644 --- a/src/codegen/builtins/collect-registrations.ts +++ b/src/codegen/builtins/collect-registrations.ts @@ -158,10 +158,6 @@ function listAccessors(text: string, file: string, problems: Problems): ListedAc return resolveAliases(parseListedLines(text, report), report); } -export function parseBufferAccessors(text: string, file: string, problems: Problems): BufferAccessor[] { - return listAccessors(text, file, problems).map(({ accessor }) => accessor); -} - function movedTypeOf({ numberKind, byteCount }: BufferAccessor): b.TableType { const bitCount = 8 * byteCount; switch (numberKind) { diff --git a/src/codegen/replacements.ts b/src/codegen/replacements.ts index 398149b137ee..430e196696b9 100644 --- a/src/codegen/replacements.ts +++ b/src/codegen/replacements.ts @@ -46,11 +46,6 @@ export const globalReplacements: ReplacementRule[] = [ from: /\bnotImplementedIssue\(\s*([0-9]+)\s*,\s*((?:"[^"]*"|'[^']+'))\s*\)/g, toRaw: "__intrinsic__makeTypeError(`${$2} is not implemented yet. See https://github.com/oven-sh/bun/issues/$1`)", }, - { - from: /\bnotImplementedIssueFn\(\s*([0-9]+)\s*,\s*((?:"[^"]*"|'[^']+'))\s*\)/g, - toRaw: - "() => void __intrinsic__throwTypeError(`${$2} is not implemented yet. See https://github.com/oven-sh/bun/issues/$1`)", - }, ]; // This is a list of globals we should access using @ notation diff --git a/src/js/builtins.d.ts b/src/js/builtins.d.ts index c6f2aff28d89..22a4e6b92173 100644 --- a/src/js/builtins.d.ts +++ b/src/js/builtins.d.ts @@ -445,8 +445,6 @@ declare const $LoaderLabelToId: Record; // not a builtin, but a build-time macro of our own /** Returns a not implemented error that points to a github issue. */ declare function notImplementedIssue(issueNumber: number, description: string): Error; -/** Return a function that throws a not implemented error that points to a github issue */ -declare function notImplementedIssueFn(issueNumber: number, description: string): (...args: any[]) => never; declare type JSCSourceCodeObject = unique symbol; diff --git a/src/js/internal/streams/readable.ts b/src/js/internal/streams/readable.ts index aae844c591de..7ad053cf3047 100644 --- a/src/js/internal/streams/readable.ts +++ b/src/js/internal/streams/readable.ts @@ -169,19 +169,6 @@ ReadableState.prototype[kOnConstructed] = function onConstructed(this: ReadableS } }; -declare global { - namespace $Node { - interface PreallocatedEvents { - close: Listener | Listener[] | undefined; - error: Listener | Listener[] | undefined; - data: Listener | Listener[] | undefined; - end: Listener | Listener[] | undefined; - readable: Listener | Listener[] | undefined; - resume?: Listener | Listener[] | undefined; - } - } -} - function preallocatedEvents(): $Node.Events { return { close: undefined, diff --git a/src/js/internal/trace_events.ts b/src/js/internal/trace_events.ts index 4c078c2f26ac..2ad7ffdd5dc6 100644 --- a/src/js/internal/trace_events.ts +++ b/src/js/internal/trace_events.ts @@ -9,7 +9,6 @@ const { getTid, isCategoryGroupEnabled, emitEvent, - emitEventWithArgs, } = require("internal/trace_event_recorder"); // Live one-byte views handed out by getCategoryEnabledBuffer(); byte 0 is 1 // while the category is enabled. @@ -819,7 +818,6 @@ export default { isTraceCategoryEnabled, isCategoryGroupEnabled, emitEvent, - emitEventWithArgs, trace, initFromCli, setFilePattern, diff --git a/src/jsc/bindings/Bindgen/IDLConvert.h b/src/jsc/bindings/Bindgen/IDLConvert.h index d7ecb1f996bf..15538d1c4265 100644 --- a/src/jsc/bindings/Bindgen/IDLConvert.h +++ b/src/jsc/bindings/Bindgen/IDLConvert.h @@ -119,20 +119,6 @@ ALWAYS_INLINE JSC::JSValue stringOfStringObject(JSC::JSGlobalObject& globalObjec return value; } -// An argument of a function whose body is C++ (`cppSymbol`). -class ArgumentInFrame { -public: - ALWAYS_INLINE ArgumentInFrame(JSC::JSValue value) - : m_value(value) - { - } - - ALWAYS_INLINE JSC::JSValue value() const { return m_value; } - -private: - JSC::JSValue m_value; -}; - // What an inline C++ body (`cppInlineBody`) is handed by the generated host function: `at(n)` reads the argument from the frame of the caller where the body asks for it, and answers undefined for one that is left out. class ArgumentsInFrame { public: diff --git a/src/jsc/bindings/c-bindings.cpp b/src/jsc/bindings/c-bindings.cpp index c5ca484c2358..2f49eadc2aa1 100644 --- a/src/jsc/bindings/c-bindings.cpp +++ b/src/jsc/bindings/c-bindings.cpp @@ -28,9 +28,6 @@ #include #include #include -#if ENABLE(AOT_GUARDED_PAGES) -#include -#endif #endif #else #include From 3cbe3a5782030c533b280541649800c3cbab4660 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Sat, 31 Oct 2026 05:49:02 +0000 Subject: [PATCH 3/6] Remove what #45631 left unused in the aot diagnostics and the ahead-of-time node:http texts - `bun_aot::diagnostics::log_internal_error` and its re-export. Nothing calls it. - `$Node.OutgoingMessageConstructor` and `$Node.ClientRequestConstructor` in `src/js/ahead-of-time/node`. Nothing names these type declarations. --- src/aot/diagnostics.rs | 2 +- src/aot/diagnostics/sink.rs | 5 ----- src/js/ahead-of-time/node/_http_client.ts | 2 -- src/js/ahead-of-time/node/_http_outgoing.ts | 14 -------------- 4 files changed, 1 insertion(+), 22 deletions(-) diff --git a/src/aot/diagnostics.rs b/src/aot/diagnostics.rs index 501a379665dc..d3425016a238 100644 --- a/src/aot/diagnostics.rs +++ b/src/aot/diagnostics.rs @@ -23,8 +23,8 @@ use rustc_hash::FxHashMap; use self::int32_flows::Int32FlowKey; pub use self::shared::{InternalError, Severity}; +pub use self::sink::log_diagnostic; pub(crate) use self::sink::log_diagnostic_at; -pub use self::sink::{log_diagnostic, log_internal_error}; pub(crate) use self::spans::range_of_node; use crate::diagnostic_codes::Code; use crate::ir::generated::TypeSiteKind; diff --git a/src/aot/diagnostics/sink.rs b/src/aot/diagnostics/sink.rs index 348b248cf52c..d1681fd6dc16 100644 --- a/src/aot/diagnostics/sink.rs +++ b/src/aot/diagnostics/sink.rs @@ -255,11 +255,6 @@ pub(crate) fn log_diagnostic_at( write_message(log, to_log_message(&reported, severity)); } -/// For an error found after the diagnostics of the build were written. -pub fn log_internal_error(log: &mut Log, error: InternalError) { - write_internal_errors(log, vec![error]); -} - pub(super) fn write_message(log: &mut Log, message: Msg) { match message.kind { Kind::Err => log.errors += 1, diff --git a/src/js/ahead-of-time/node/_http_client.ts b/src/js/ahead-of-time/node/_http_client.ts index 394856f05dbe..cf8861487bc6 100644 --- a/src/js/ahead-of-time/node/_http_client.ts +++ b/src/js/ahead-of-time/node/_http_client.ts @@ -267,8 +267,6 @@ declare global { [kClientRequestStatistics]?: object; } - type ClientRequestConstructor = typeof ClientRequest; - interface IncomingMessage { /** Of a response: the domain that was active when its request was made. */ domain?: Domain; diff --git a/src/js/ahead-of-time/node/_http_outgoing.ts b/src/js/ahead-of-time/node/_http_outgoing.ts index 040d7409d1e7..06e67f781ca3 100644 --- a/src/js/ahead-of-time/node/_http_outgoing.ts +++ b/src/js/ahead-of-time/node/_http_outgoing.ts @@ -258,20 +258,6 @@ declare global { interface Writable { write(chunk: unknown, encoding: string | null | undefined, callback: ErrorCallback | null | undefined): boolean; } - - interface OutgoingMessageConstructor { - new (options?: OutgoingMessageOptions): OutgoingMessage; - (this: OutgoingMessage, options?: OutgoingMessageOptions): void; - /** The form of `ServerResponse` for a request of the native listener. */ - ( - this: OutgoingMessage, - marker: typeof kHandle, - highWaterMark: number | undefined, - rejectNonStandardBodyWrites: boolean | undefined, - keepAliveTimeout: number, - ): void; - prototype: any; - } } } From 0a562a7756f04db3952a36594d4faff07b50b0a7 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Sun, 1 Nov 2026 18:42:34 +0000 Subject: [PATCH 4/6] Keep signatureOfBindgen in the builtins codegen Open pull request #47635 merges with main and changes a line in the body of `signatureOfBindgen`. The removal of that function made the two conflict. Put the function back, with `unplacedPath` and the two type imports that only it uses. The function still has no caller. --- src/codegen/builtins/collect-bindgen.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/codegen/builtins/collect-bindgen.ts b/src/codegen/builtins/collect-bindgen.ts index 58fbb8a0c005..64b8368960a9 100644 --- a/src/codegen/builtins/collect-bindgen.ts +++ b/src/codegen/builtins/collect-bindgen.ts @@ -46,6 +46,7 @@ import { type DispatchDeclaration, type MemberDeclaration, type Problems, + type SignatureDeclaration, type SourcedDeclaration, } from "./declarations.ts"; import * as b from "./lib.ts"; @@ -55,6 +56,7 @@ import { maximumDirectParameterCount, realmParameter, type BuiltinPath, + type CallMode, type Capability, type DirectEntrySpec, type DirectForm, @@ -91,6 +93,8 @@ interface Joins { nativeBindings: ReadonlySet; } +const unplacedPath: BuiltinPath = "%Unplaced%"; + const externalStateHeap: Heap = "ExternalState"; const externalState: readonly Heap[] = [externalStateHeap]; @@ -414,6 +418,18 @@ function createField( }; } +export function signatureOfBindgen( + signature: Signature, + mode: CallMode, + receiver: ParameterType | null, +): SignatureDeclaration { + const field = createField(signature, createReceiver(signature, receiver, null), signature.returns.resultType); + const [declared] = b + .fn(unplacedPath, field) + .flatMap(declaration => (declaration.declares === "Member" ? declaration.signatures : [])); + return { ...declared, mode }; +} + // The object that is made of a dictionary has a property for each member that is there, in their order, and the file that declares the dictionary declares the layout. function findLayoutOfResult({ returns }: Signature, fn: FunctionDefinition): DictionaryType | null { if (!(returns instanceof DictionaryType) || returns.origin?.stem !== fn.origin?.stem) return null; From 7ddc45d5228a7b61b4c23bf2a2e4c90debc10901 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Tue, 10 Nov 2026 08:58:50 +0000 Subject: [PATCH 5/6] Keep the notImplementedIssueFn macro Open pull request #48356 calls `notImplementedIssueFn` twice in src/js/builtins/BundlerPlugin.ts at its head. Put the rule of src/codegen/replacements.ts and the declaration of src/js/builtins.d.ts back. No source on main calls the macro. --- src/codegen/replacements.ts | 5 +++++ src/js/builtins.d.ts | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/codegen/replacements.ts b/src/codegen/replacements.ts index ccef47e9b05e..456bbec7b895 100644 --- a/src/codegen/replacements.ts +++ b/src/codegen/replacements.ts @@ -48,6 +48,11 @@ export const globalReplacements: ReplacementRule[] = [ from: /\bnotImplementedIssue\(\s*([0-9]+)\s*,\s*((?:"[^"]*"|'[^']+'))\s*\)/g, toRaw: "__intrinsic__makeTypeError(`${$2} is not implemented yet. See https://github.com/oven-sh/bun/issues/$1`)", }, + { + from: /\bnotImplementedIssueFn\(\s*([0-9]+)\s*,\s*((?:"[^"]*"|'[^']+'))\s*\)/g, + toRaw: + "() => void __intrinsic__throwTypeError(`${$2} is not implemented yet. See https://github.com/oven-sh/bun/issues/$1`)", + }, ]; // This is a list of globals we should access using @ notation diff --git a/src/js/builtins.d.ts b/src/js/builtins.d.ts index 77178c9cd645..c3b1c99164f8 100644 --- a/src/js/builtins.d.ts +++ b/src/js/builtins.d.ts @@ -557,6 +557,8 @@ declare const $LoaderLabelToId: Record; // not a builtin, but a build-time macro of our own /** Returns a not implemented error that points to a github issue. */ declare function notImplementedIssue(issueNumber: number, description: string): Error; +/** Return a function that throws a not implemented error that points to a github issue */ +declare function notImplementedIssueFn(issueNumber: number, description: string): (...args: any[]) => never; declare type JSCSourceCodeObject = unique symbol; From 7d1f6ecb656a5116fe41b91f53cc3e363d5bfc4c Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Tue, 10 Nov 2026 09:01:36 +0000 Subject: [PATCH 6/6] Keep the two $Node constructor types of the ahead-of-time node:http texts #48120 changed the body of `$Node.OutgoingMessageConstructor` and kept the interface. So the owners of these texts maintain the declarations, and a sweep does not remove them. `$Node.ClientRequestConstructor` is the same kind of declaration. Both still have no user. --- src/js/ahead-of-time/node/_http_client.ts | 2 ++ src/js/ahead-of-time/node/_http_outgoing.ts | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/js/ahead-of-time/node/_http_client.ts b/src/js/ahead-of-time/node/_http_client.ts index d1bb9e63ceaf..ffd13c00d3af 100644 --- a/src/js/ahead-of-time/node/_http_client.ts +++ b/src/js/ahead-of-time/node/_http_client.ts @@ -263,6 +263,8 @@ declare global { [kClientRequestStatistics]?: object; } + type ClientRequestConstructor = typeof ClientRequest; + interface IncomingMessage { /** Of a response: the domain that was active when its request was made. */ domain?: Domain; diff --git a/src/js/ahead-of-time/node/_http_outgoing.ts b/src/js/ahead-of-time/node/_http_outgoing.ts index d2e62dad6482..0d83c8b2ff98 100644 --- a/src/js/ahead-of-time/node/_http_outgoing.ts +++ b/src/js/ahead-of-time/node/_http_outgoing.ts @@ -264,6 +264,12 @@ declare global { interface Writable { write(chunk: unknown, encoding: string | null | undefined, callback: ErrorCallback | null | undefined): boolean; } + + interface OutgoingMessageConstructor { + new (options?: OutgoingMessageOptions): OutgoingMessage; + (this: OutgoingMessage, options?: OutgoingMessageOptions): void; + prototype: any; + } } }