diff --git a/scripts/build/flags.ts b/scripts/build/flags.ts index 91d2605e38ab..f0ba7dfe1f7b 100644 --- a/scripts/build/flags.ts +++ b/scripts/build/flags.ts @@ -699,16 +699,12 @@ export const defines: Flag[] = [ "_HAS_EXCEPTIONS=0", "LIBUS_USE_OPENSSL=1", "LIBUS_USE_BORINGSSL=1", - "WITH_BORINGSSL=1", "STATICALLY_LINKED_WITH_JavaScriptCore=1", - "STATICALLY_LINKED_WITH_BMALLOC=1", "BUILDING_WITH_CMAKE=1", "JSC_OBJC_API_ENABLED=0", - "BUN_SINGLE_THREADED_PER_VM_ENTRY_SCOPE=1", "NAPI_EXPERIMENTAL=ON", "NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT=1", "NOMINMAX", - "IS_BUILD", "BUILDING_JSCONLY__", ], desc: "Core bun defines (always on)", diff --git a/src/dns/lib.rs b/src/dns/lib.rs index 7cefd2b88f5d..ff2f42fb85f2 100644 --- a/src/dns/lib.rs +++ b/src/dns/lib.rs @@ -175,7 +175,6 @@ pub enum Family { Unspecified, Inet, Inet6, - Unix, } bun_core::comptime_string_map! { @@ -194,7 +193,6 @@ impl Family { Family::Unspecified => 0, Family::Inet => sock::AF_INET, Family::Inet6 => sock::AF_INET6, - Family::Unix => sock::AF_UNIX, } } } diff --git a/src/event_loop/EventLoopTimer.rs b/src/event_loop/EventLoopTimer.rs index 782d971151fe..b482dec5855f 100644 --- a/src/event_loop/EventLoopTimer.rs +++ b/src/event_loop/EventLoopTimer.rs @@ -178,7 +178,6 @@ impl EventLoopTimer { #[repr(u8)] #[derive(Copy, Clone, Eq, PartialEq, strum::IntoStaticStr)] pub enum Tag { - TimerCallback, TimeoutObject, ImmediateObject, StatWatcherScheduler, @@ -221,12 +220,6 @@ impl Tag { } } -pub struct TimerCallback { - pub callback: fn(*mut TimerCallback), - // Opaque user ctx; ownership stays with whoever installs the callback. - pub event_loop_timer: EventLoopTimer, -} - /// Stamp out one `unsafe fn $method(*const EventLoopTimer) -> *mut Self` per /// `(method => field)` pair: each recovers the embedding owner from a pointer /// to the named intrusive [`EventLoopTimer`] slot (typed container_of). @@ -267,8 +260,6 @@ macro_rules! impl_timer_owner { }; } -crate::impl_timer_owner!(TimerCallback; from_timer_ptr => event_loop_timer); - #[repr(u8)] #[derive(Copy, Clone, Eq, PartialEq, Default)] pub enum State { diff --git a/src/install/error.rs b/src/install/error.rs index 11a23ca322e8..ab1c59a3a839 100644 --- a/src/install/error.rs +++ b/src/install/error.rs @@ -8,22 +8,12 @@ pub enum Error { NotDir, #[error("NameTooLong")] NameTooLong, - #[error("FileTooBig")] - FileTooBig, #[error("SymLinkLoop")] SymLinkLoop, - #[error("ProcessFdQuotaExceeded")] - ProcessFdQuotaExceeded, #[error("SystemFdQuotaExceeded")] SystemFdQuotaExceeded, #[error("SystemResources")] SystemResources, - #[error("ReadOnlyFileSystem")] - ReadOnlyFileSystem, - #[error("FileSystem")] - FileSystem, - #[error("FileBusy")] - FileBusy, #[error("DeviceBusy")] DeviceBusy, #[error("TarballHTTP400")] @@ -271,14 +261,9 @@ impl Error { Self::AccessDenied => "AccessDenied", Self::NotDir => "NotDir", Self::NameTooLong => "NameTooLong", - Self::FileTooBig => "FileTooBig", Self::SymLinkLoop => "SymLinkLoop", - Self::ProcessFdQuotaExceeded => "ProcessFdQuotaExceeded", Self::SystemFdQuotaExceeded => "SystemFdQuotaExceeded", Self::SystemResources => "SystemResources", - Self::ReadOnlyFileSystem => "ReadOnlyFileSystem", - Self::FileSystem => "FileSystem", - Self::FileBusy => "FileBusy", Self::DeviceBusy => "DeviceBusy", Self::TarballHTTP400 => "TarballHTTP400", Self::TarballHTTP401 => "TarballHTTP401", diff --git a/src/install/hosted_git_info.rs b/src/install/hosted_git_info.rs index 66e1afac0993..39e96a4f4cce 100644 --- a/src/install/hosted_git_info.rs +++ b/src/install/hosted_git_info.rs @@ -100,8 +100,6 @@ pub enum Representation { Shortcut, /// git+ssh://git@domain/user/project.git#committish Sshurl, - /// ssh://domain/user/project.git#committish - Ssh, /// https://domain/user/project.git#committish Https, /// git://domain/user/project.git#committish diff --git a/src/install/lockfile/bun.lock.rs b/src/install/lockfile/bun.lock.rs index 7a26bc2d3f40..be1254346f20 100644 --- a/src/install/lockfile/bun.lock.rs +++ b/src/install/lockfile/bun.lock.rs @@ -2344,14 +2344,6 @@ pub(crate) fn parse_into_binary_lockfile( ); return Err(ParseError::UnexpectedResolution); } - Err(crate::resolution::FromTextLockfileError::InvalidSemver) => { - log.add_error_fmt( - source, - item_loc(source, key_loc, res_info_idx), - format_args!("Invalid package version: {}", bstr::BStr::new(res_str)), - ); - return Err(ParseError::InvalidSemver); - } }; let mut npm_url_needs_integrity = false; diff --git a/src/install/migration.rs b/src/install/migration.rs index 5d7d326652db..d5e30d86ea78 100644 --- a/src/install/migration.rs +++ b/src/install/migration.rs @@ -161,8 +161,6 @@ pub fn detect_and_load_other_lockfile<'a>( | MigratePnpmLockfileError::PnpmLockfileInvalidSnapshot | MigratePnpmLockfileError::PnpmLockfileInvalidDependency | MigratePnpmLockfileError::PnpmLockfileMissingDependencyVersion - | MigratePnpmLockfileError::PnpmLockfileInvalidOverride - | MigratePnpmLockfileError::PnpmLockfileInvalidPatchedDependency | MigratePnpmLockfileError::PnpmLockfileMissingCatalogEntry | MigratePnpmLockfileError::PnpmLockfileUnresolvableDependency => { // These errors are continuable - log the error but don't exit diff --git a/src/install/pnpm.rs b/src/install/pnpm.rs index 91ba619905ad..ebaa977c6a35 100644 --- a/src/install/pnpm.rs +++ b/src/install/pnpm.rs @@ -124,10 +124,6 @@ pub enum MigratePnpmLockfileError { PnpmLockfileMissingDependencyVersion, #[error("PnpmLockfileInvalidDependency")] PnpmLockfileInvalidDependency, - #[error("PnpmLockfileInvalidOverride")] - PnpmLockfileInvalidOverride, - #[error("PnpmLockfileInvalidPatchedDependency")] - PnpmLockfileInvalidPatchedDependency, #[error("PnpmLockfileMissingCatalogEntry")] PnpmLockfileMissingCatalogEntry, #[error("PnpmLockfileUnresolvableDependency")] diff --git a/src/install/resolution.rs b/src/install/resolution.rs index e80d9c30accb..c3041672be89 100644 --- a/src/install/resolution.rs +++ b/src/install/resolution.rs @@ -1002,8 +1002,6 @@ pub enum FromTextLockfileError { OutOfMemory, #[error("unexpected resolution")] UnexpectedResolution, - #[error("invalid semver")] - InvalidSemver, } bun_core::oom_from_alloc!(FromTextLockfileError); diff --git a/src/install/windows-shim/bun_shim_impl.rs b/src/install/windows-shim/bun_shim_impl.rs index 6e9e49d887f1..b25cfb74cde9 100644 --- a/src/install/windows-shim/bun_shim_impl.rs +++ b/src/install/windows-shim/bun_shim_impl.rs @@ -217,7 +217,6 @@ pub enum FailReason { NoDirname, CouldNotOpenShim, CouldNotReadShim, - InvalidShimDataSize, ShimNotFound, CreateProcessFailed, /// When encountering this outside of standalone mode, you should fallback @@ -239,7 +238,6 @@ impl FailReason { FailReason::ShimNotFound => "could not find bin metadata file", FailReason::CouldNotOpenShim => "could not open bin metadata file", FailReason::CouldNotReadShim => "could not read bin metadata", - FailReason::InvalidShimDataSize => "bin metadata is corrupt (size)", FailReason::InvalidShimValidation => "bin metadata is corrupt (validate)", FailReason::InvalidShimBounds => "bin metadata is corrupt (bounds)", // The difference between these two is that one is with a shebang (#!/usr/bin/env node) and diff --git a/src/js/internal/fixed_queue.ts b/src/js/internal/fixed_queue.ts index cf9a880decfa..2a41bef83812 100644 --- a/src/js/internal/fixed_queue.ts +++ b/src/js/internal/fixed_queue.ts @@ -126,6 +126,5 @@ class FixedQueue { } export default { - FixedCircularBuffer, FixedQueue, }; diff --git a/src/js/internal/http1_server_fallback.ts b/src/js/internal/http1_server_fallback.ts index 32f240d8ac9b..f95a2f4c908a 100644 --- a/src/js/internal/http1_server_fallback.ts +++ b/src/js/internal/http1_server_fallback.ts @@ -469,10 +469,8 @@ function closeAllHttp1Connections(server) { } export default { - createHttp1FallbackResponseHandle, connectionListenerHTTP1, closeIdleHttp1Connections, closeAllHttp1Connections, kHttp1Connections, - kHttp1ActiveRequests, }; diff --git a/src/js/internal/inspector/cdp.ts b/src/js/internal/inspector/cdp.ts index 69729d3845eb..9ac01a8f88e0 100644 --- a/src/js/internal/inspector/cdp.ts +++ b/src/js/internal/inspector/cdp.ts @@ -698,5 +698,4 @@ class InspectorCDPAdapter { export default { InspectorCDPAdapter, - EXECUTION_CONTEXT_ID, }; diff --git a/src/js/internal/promisify.ts b/src/js/internal/promisify.ts index bd6147e53551..65d49bd6bd7f 100644 --- a/src/js/internal/promisify.ts +++ b/src/js/internal/promisify.ts @@ -94,7 +94,6 @@ promisify.custom = kCustomPromisifiedSymbol; } export default { - defineCustomPromisify, defineCustomPromisifyArgs, promisify, }; diff --git a/src/js/internal/repl/node-shims.js b/src/js/internal/repl/node-shims.js index 7551d0b05048..37c57a5937c8 100644 --- a/src/js/internal/repl/node-shims.js +++ b/src/js/internal/repl/node-shims.js @@ -19,8 +19,6 @@ const { // ---- internal/util ---------------------------------------------------- -const { kEmptyObject } = require("internal/shared"); - // Node's real implementation reconstructs the regex in an internal realm so a // tampered `RegExp.prototype[Symbol.replace]` can't observe it. Bun has no // internal realm; the load-time-captured intrinsics close the `[Symbol.*]` @@ -111,16 +109,6 @@ function has() { return true; } -// ---- internal/streams/utils ---------------------------------------------- - -function isWritable(stream) { - return typeof stream?.write === "function"; -} - -// ---- internal/events/abort_listener ---------------------------------------------- - -const { addAbortListener } = require("internal/abort_listener"); - // ---- internal/bootstrap/realm ---------------------------------------------- const BuiltinModule = { @@ -271,10 +259,6 @@ function makeContextifyScript( }); } -function runScriptInThisContext(script, displayErrors, _breakOnFirstLine) { - return script.runInThisContext({ displayErrors }); -} - // ---- internal/modules/cjs/loader (constructible Module shim) ---------------- class CJSModuleShim { @@ -419,8 +403,6 @@ export default { decorateErrorStack, deprecate: util.deprecate, isError, - kEmptyObject, - promisify: util.promisify, // internal/util/colors shouldColorize, // internal/util/debuglog @@ -434,10 +416,6 @@ export default { // internal/process/permission (consumed as a namespace: permission.isEnabled()) isEnabled, has, - // internal/streams/utils - isWritable, - // internal/events/abort_listener - addAbortListener, // internal/bootstrap/realm BuiltinModule, // internal/modules/esm/get_format @@ -452,5 +430,4 @@ export default { makeRequireFunction, // internal/vm makeContextifyScript, - runScriptInThisContext, }; diff --git a/src/js/internal/sql/query.ts b/src/js/internal/sql/query.ts index 258f10f05922..e7452be5fe3b 100644 --- a/src/js/internal/sql/query.ts +++ b/src/js/internal/sql/query.ts @@ -350,7 +350,6 @@ export default { Query, SQLQueryFlags, SQLQueryResultMode, - SQLQueryStatus, symbols: { _resolve, diff --git a/src/js/internal/sql/shared.ts b/src/js/internal/sql/shared.ts index 1bb2e724a6fa..f7548bd6afbb 100644 --- a/src/js/internal/sql/shared.ts +++ b/src/js/internal/sql/shared.ts @@ -2141,11 +2141,8 @@ export interface DatabaseAdapter { } export default { - parseDefinitelySqliteUrl, parseOptions, SQLHelper, - buildDefinedColumnsAndQuery, - normalizeSSLMode, SQLResultArray, SQLArrayParameter, getHelperCommandFromDetect, diff --git a/src/js/internal/sql/sqlite.ts b/src/js/internal/sql/sqlite.ts index f17ae30ec06b..236b2bce4e23 100644 --- a/src/js/internal/sql/sqlite.ts +++ b/src/js/internal/sql/sqlite.ts @@ -568,8 +568,4 @@ class SQLiteAdapter implements DatabaseAdapterputDirect(vm, builtinNames(vm).codePublicName(), code, JSC::PropertyAttribute::DontEnum | 0); if (!detail.isUndefined()) errorInstance->putDirect(vm, vm.propertyNames->detail, detail, JSC::PropertyAttribute::DontEnum | 0); - /* - // TODO: ErrorCaptureStackTrace(warning, ctor || process.emitWarning); - // This doesn't work, getStackTrace does not get any stack frames. - Vector stackTrace; - const size_t framesToSkip = 1; - JSValue caller; - if (ctor.toBoolean(globalObject)) { - caller = ctor; - } else { - auto* globalObject = uncheckedDowncast(lexicalGlobalObject); - auto* process = globalObject->processObject(); - caller = process->get(globalObject, Identifier::fromString(vm, String("emitWarning"_s))); - RETURN_IF_EXCEPTION(scope, {}); - } - vm.interpreter.getStackTrace(errorInstance, stackTrace, framesToSkip, globalObject->stackTraceLimit().value_or(0), caller.isCallable() ? caller.asCell() : nullptr); - errorInstance->putDirect(vm, vm.propertyNames->stack, jsString(vm, Interpreter::stackTraceAsString(vm, stackTrace)), static_cast(PropertyAttribute::DontEnum)); - */ - RELEASE_AND_RETURN(scope, emitWarningErrorInstance(lexicalGlobalObject, errorInstance)); } diff --git a/src/jsc/bindings/BunString.cpp b/src/jsc/bindings/BunString.cpp index ba962bd14c4f..08d00c72f9ad 100644 --- a/src/jsc/bindings/BunString.cpp +++ b/src/jsc/bindings/BunString.cpp @@ -559,27 +559,6 @@ extern "C" JSC::EncodedJSValue BunString__createArray( return JSValue::encode(array); } -extern "C" [[ZIG_EXPORT(nothrow)]] void BunString__toWTFString(BunString* bunString) -{ - WTF::String str; - if (bunString->tag == BunStringTag::ZigString) { - if (Zig::isTaggedExternalPtr(bunString->impl.zig.ptr)) { - str = Zig::toString(bunString->impl.zig); - } else { - str = Zig::toStringCopy(bunString->impl.zig); - } - - } else if (bunString->tag == BunStringTag::StaticZigString) { - str = Zig::toStringStatic(bunString->impl.zig); - } else { - return; - } - - auto impl = str.releaseImpl(); - bunString->impl.wtf = impl.leakRef(); - bunString->tag = BunStringTag::WTFStringImpl; -} - extern "C" BunString URL__getFileURLString(BunString* filePath) { return Bun::toStringRef(WTF::URL::fileURLWithFileSystemPath(filePath->toWTFString()).stringWithoutFragmentIdentifier()); diff --git a/src/jsc/bindings/ErrorStackTrace.cpp b/src/jsc/bindings/ErrorStackTrace.cpp index a8b3c3eca839..7afd14d4b236 100644 --- a/src/jsc/bindings/ErrorStackTrace.cpp +++ b/src/jsc/bindings/ErrorStackTrace.cpp @@ -723,6 +723,7 @@ String functionName(JSC::VM& vm, JSC::JSGlobalObject* lexicalGlobalObject, const } } +// Weak-referenced by JSC::ErrorInstance::finalizeUnconditionally in vendor/WebKit. extern "C" void Bun__errorInstance__finalize(void* bunErrorData) { UNUSED_PARAM(bunErrorData); diff --git a/src/jsc/bindings/ImportMetaObject.cpp b/src/jsc/bindings/ImportMetaObject.cpp index 0912f3ff231c..d7225633712d 100644 --- a/src/jsc/bindings/ImportMetaObject.cpp +++ b/src/jsc/bindings/ImportMetaObject.cpp @@ -56,82 +56,6 @@ namespace Zig { using namespace JSC; using namespace WebCore; -static JSC::EncodedJSValue functionRequireResolve(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame, const WTF::String& fromStr) -{ - auto& vm = JSC::getVM(globalObject); - auto scope = DECLARE_THROW_SCOPE(vm); - - switch (callFrame->argumentCount()) { - case 0: { - // not "requires" because "require" could be confusing - JSC::throwTypeError(globalObject, scope, "require.resolve needs 1 argument (a string)"_s); - scope.release(); - return {}; - } - default: { - JSC::JSValue moduleName = callFrame->argument(0); - - auto doIt = [&](const WTF::String& fromStr) -> JSC::EncodedJSValue { - Zig::GlobalObject* zigGlobalObject = uncheckedDowncast(globalObject); - if (zigGlobalObject->onLoadPlugins.hasVirtualModules()) { - if (auto result = zigGlobalObject->onLoadPlugins.resolveVirtualModule(fromStr, String())) { - if (fromStr == result.value()) - return JSC::JSValue::encode(moduleName); - - return JSC::JSValue::encode(jsString(vm, result.value())); - } - } - - BunString from = Bun::toString(fromStr); - auto result = Bun__resolveSyncWithSource(globalObject, JSC::JSValue::encode(moduleName), &from, false, true); - RETURN_IF_EXCEPTION(scope, {}); - - if (!JSC::JSValue::decode(result).isString()) { - JSC::throwException(globalObject, scope, JSC::JSValue::decode(result)); - return JSC::JSValue::encode(JSValue {}); - } - - scope.release(); - return result; - }; - - if (moduleName.isUndefinedOrNull()) { - JSC::throwTypeError(globalObject, scope, "require.resolve expects a string"_s); - scope.release(); - return {}; - } - - if (callFrame->argumentCount() > 1) { - JSC::JSValue fromValue = callFrame->argument(1); - - // require.resolve also supports a paths array - // we only support a single path - if (!fromValue.isUndefinedOrNull() && fromValue.isObject()) { - auto pathsObject = fromValue.getObject()->getIfPropertyExists(globalObject, builtinNames(vm).pathsPublicName()); - RETURN_IF_EXCEPTION(scope, {}); - if (pathsObject) { - if (pathsObject.isCell() && pathsObject.asCell()->type() == JSC::JSType::ArrayType) { - auto pathsArray = uncheckedDowncast(pathsObject); - if (pathsArray->length() > 0) { - fromValue = pathsArray->getIndex(globalObject, 0); - RETURN_IF_EXCEPTION(scope, {}); - } - } - } - } - - if (fromValue.isString()) { - WTF::String str = fromValue.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, {}); - return doIt(str); - } - } - - return doIt(fromStr); - } - } -} - ImportMetaObject* ImportMetaObject::create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure, const WTF::String& url) { ImportMetaObject* ptr = new (NotNull, JSC::allocateCell(vm)) ImportMetaObject(vm, structure, url); @@ -178,19 +102,6 @@ ImportMetaObject* ImportMetaObject::createFromSpecifier(JSC::JSGlobalObject* glo return create(globalObject, url.string()); } -JSC_DECLARE_HOST_FUNCTION(jsFunctionRequireResolve); -JSC_DEFINE_HOST_FUNCTION(jsFunctionRequireResolve, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) -{ - JSValue thisValue = callFrame->thisValue(); - WTF::String fromStr; - - if (thisValue.isString()) { - fromStr = thisValue.toWTFString(globalObject); - } - - return functionRequireResolve(globalObject, callFrame, fromStr); -} - extern "C" JSC::EncodedJSValue functionImportMeta__resolveSync(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame) { auto* globalObject = uncheckedDowncast(lexicalGlobalObject); diff --git a/src/jsc/bindings/JSBakeResponse.cpp b/src/jsc/bindings/JSBakeResponse.cpp index 19330f92f51b..c3e4f1da651a 100644 --- a/src/jsc/bindings/JSBakeResponse.cpp +++ b/src/jsc/bindings/JSBakeResponse.cpp @@ -174,9 +174,6 @@ void JSBakeResponse::visitChildrenImpl(JSCell* cell, Visitor& visitor) DEFINE_VISIT_CHILDREN(JSBakeResponse); -JSC_DECLARE_HOST_FUNCTION(callBakeResponse); -JSC_DECLARE_HOST_FUNCTION(constructBakeResponse); - class JSBakeResponseConstructor final : public JSC::InternalFunction { public: using Base = JSC::InternalFunction; diff --git a/src/jsc/bindings/NodeFSStatFSBinding.cpp b/src/jsc/bindings/NodeFSStatFSBinding.cpp index 28e867c06a0e..bcfde2fedd39 100644 --- a/src/jsc/bindings/NodeFSStatFSBinding.cpp +++ b/src/jsc/bindings/NodeFSStatFSBinding.cpp @@ -43,16 +43,6 @@ Structure* getStatFSStructure(Zig::GlobalObject* globalObject) return globalObject->m_JSStatFSClassStructure.getInitializedOnMainThread(globalObject); } -template -JSObject* getStatFSPrototype(Zig::GlobalObject* globalObject) -{ - if (isBigInt) { - return globalObject->m_JSStatFSBigIntClassStructure.prototypeInitializedOnMainThread(globalObject); - } - - return globalObject->m_JSStatFSClassStructure.prototypeInitializedOnMainThread(globalObject); -} - template JSObject* getStatFSConstructor(Zig::GlobalObject* globalObject) { diff --git a/src/jsc/bindings/NodeValidator.cpp b/src/jsc/bindings/NodeValidator.cpp index f9e1730f80ce..086ee2cab7ad 100644 --- a/src/jsc/bindings/NodeValidator.cpp +++ b/src/jsc/bindings/NodeValidator.cpp @@ -140,16 +140,6 @@ JSC::EncodedJSValue V::validateNumber(JSC::ThrowScope& scope, JSC::JSGlobalObjec return JSValue::encode(jsUndefined()); } -JSC_DEFINE_HOST_FUNCTION(jsFunction_validateString, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) -{ - auto& vm = JSC::getVM(globalObject); - auto scope = DECLARE_THROW_SCOPE(vm); - - auto value = callFrame->argument(0); - auto name = callFrame->argument(1); - return V::validateString(scope, globalObject, value, name); -} - JSC::EncodedJSValue V::validateString(JSC::ThrowScope& scope, JSC::JSGlobalObject* globalObject, JSValue value, ASCIILiteral name) { if (!value.isString()) { @@ -233,34 +223,6 @@ JSC::EncodedJSValue V::validateFunction(JSC::ThrowScope& scope, JSC::JSGlobalObj return JSValue::encode(jsUndefined()); } -JSC_DEFINE_HOST_FUNCTION(jsFunction_validateFunction, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) -{ - auto& vm = JSC::getVM(globalObject); - auto scope = DECLARE_THROW_SCOPE(vm); - - auto value = callFrame->argument(0); - auto name = callFrame->argument(1); - - if (!value.isCallable()) { - return ERR::INVALID_ARG_TYPE(scope, globalObject, name, "function"_s, value); - } - return JSValue::encode(jsUndefined()); -} - -JSC_DEFINE_HOST_FUNCTION(jsFunction_validateBoolean, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) -{ - auto& vm = JSC::getVM(globalObject); - auto scope = DECLARE_THROW_SCOPE(vm); - - auto value = callFrame->argument(0); - auto name = callFrame->argument(1); - - if (!value.isBoolean()) { - return Bun::ERR::INVALID_ARG_TYPE(scope, globalObject, name, "boolean"_s, value); - } - return JSValue::encode(jsUndefined()); -} - JSC::EncodedJSValue V::validateBoolean(JSC::ThrowScope& scope, JSC::JSGlobalObject* globalObject, JSValue value, ASCIILiteral name) { if (!value.isBoolean()) { diff --git a/src/jsc/bindings/NodeValidator.h b/src/jsc/bindings/NodeValidator.h index 663c06ae263e..da8b717cf2fb 100644 --- a/src/jsc/bindings/NodeValidator.h +++ b/src/jsc/bindings/NodeValidator.h @@ -11,11 +11,8 @@ namespace Bun { JSC_DECLARE_HOST_FUNCTION(jsFunction_validateInteger); JSC_DECLARE_HOST_FUNCTION(jsFunction_validateNumber); -JSC_DECLARE_HOST_FUNCTION(jsFunction_validateString); JSC_DECLARE_HOST_FUNCTION(jsFunction_validateFiniteNumber); JSC_DECLARE_HOST_FUNCTION(jsFunction_checkRangesOrGetDefault); -JSC_DECLARE_HOST_FUNCTION(jsFunction_validateFunction); -JSC_DECLARE_HOST_FUNCTION(jsFunction_validateBoolean); JSC_DECLARE_HOST_FUNCTION(jsFunction_validatePort); JSC_DECLARE_HOST_FUNCTION(jsFunction_validateAbortSignal); JSC_DECLARE_HOST_FUNCTION(jsFunction_validateArray); diff --git a/src/jsc/bindings/dh-primes.h b/src/jsc/bindings/dh-primes.h index deb5c80f5c2c..6198b870c741 100644 --- a/src/jsc/bindings/dh-primes.h +++ b/src/jsc/bindings/dh-primes.h @@ -59,8 +59,6 @@ #include #include -extern "C" int bn_set_words(BIGNUM* bn, const BN_ULONG* words, size_t num); - // Backporting primes that may not be supported in earlier boringssl versions. // Intentionally keeping the existing C-style formatting. diff --git a/src/jsc/bindings/headers-handwritten.h b/src/jsc/bindings/headers-handwritten.h index 801e4b08022d..22a87a41dfcb 100644 --- a/src/jsc/bindings/headers-handwritten.h +++ b/src/jsc/bindings/headers-handwritten.h @@ -307,7 +307,6 @@ 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*); -extern "C" void BunString__toWTFString(BunString*); namespace Bun { JSC::JSString* toJS(JSC::JSGlobalObject*, BunString); diff --git a/src/jsc/bindings/sliceAnsi.cpp b/src/jsc/bindings/sliceAnsi.cpp index ac9296a6fe7c..fd4db0bdb043 100644 --- a/src/jsc/bindings/sliceAnsi.cpp +++ b/src/jsc/bindings/sliceAnsi.cpp @@ -417,14 +417,6 @@ enum class TokenType { Control, }; -struct HyperlinkInfo { - bool isOpen = false; - // closePrefix: the prefix to use when closing this hyperlink - // terminator: the terminator character/sequence - String closePrefix; - String terminator; -}; - // Parse CSI sequence: returns end pointer, or nullptr if not a valid CSI template static const Char* parseCsi(const Char* start, const Char* end, bool& isSgr, bool& isCanonicalSgr) diff --git a/src/jsc/bindings/sqlite/JSSQLStatement.cpp b/src/jsc/bindings/sqlite/JSSQLStatement.cpp index 09cc3b05683e..d132e9008109 100644 --- a/src/jsc/bindings/sqlite/JSSQLStatement.cpp +++ b/src/jsc/bindings/sqlite/JSSQLStatement.cpp @@ -350,7 +350,6 @@ JSC_DECLARE_CUSTOM_GETTER(jsSqlStatementGetColumnNames); JSC_DECLARE_CUSTOM_GETTER(jsSqlStatementGetColumnCount); JSC_DECLARE_CUSTOM_GETTER(jsSqlStatementGetParamCount); JSC_DECLARE_CUSTOM_GETTER(jsSqlStatementGetIsFinalized); -JSC_DECLARE_CUSTOM_GETTER(jsSqlStatementGetHasMultipleStatements); JSC_DECLARE_CUSTOM_GETTER(jsSqlStatementGetColumnTypes); JSC_DECLARE_CUSTOM_GETTER(jsSqlStatementGetColumnDeclaredTypes); diff --git a/src/jsc/bindings/webcore/JSAbortSignal.cpp b/src/jsc/bindings/webcore/JSAbortSignal.cpp index 7636810ac1c1..39cd52b67317 100644 --- a/src/jsc/bindings/webcore/JSAbortSignal.cpp +++ b/src/jsc/bindings/webcore/JSAbortSignal.cpp @@ -129,18 +129,6 @@ template<> void JSAbortSignalDOMConstructor::initializeProperties(VM& vm, JSDOMG putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); putDirect(vm, vm.propertyNames->prototype, JSAbortSignal::prototype(vm, globalObject), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete); reifyStaticProperties(vm, JSAbortSignal::info(), JSAbortSignalConstructorTableValues, *this); - // if (!((&globalObject)->inherits() || (&globalObject)->inherits())) { - // auto propertyName = Identifier::fromString(vm, "timeout"_s); - // VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); - // DeletePropertySlot slot; - // JSObject::deleteProperty(this, &globalObject, propertyName, slot); - // } - // if (!uncheckedDowncast(&globalObject)->scriptExecutionContext()->settingsValues().abortSignalAnyOperationEnabled) { - // auto propertyName = Identifier::fromString(vm, "any"_s); - // VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); - // DeletePropertySlot slot; - // JSObject::deleteProperty(this, &globalObject, propertyName, slot); - // } } /* Hash table for prototype */ diff --git a/src/runtime/bake/BakeGlobalObject.cpp b/src/runtime/bake/BakeGlobalObject.cpp index 140c32c5600d..90e3b4e311f1 100644 --- a/src/runtime/bake/BakeGlobalObject.cpp +++ b/src/runtime/bake/BakeGlobalObject.cpp @@ -263,22 +263,7 @@ extern "C" GlobalObject* BakeCreateProdGlobal(void* console) global->setConsole(console); global->isThreadLocalDefaultGlobalObject = true; - // if (shouldDisableStopIfNecessaryTimer) { vm.heap.disableStopIfNecessaryTimer(); - // } - - // if you process.nextTick on a microtask we need thsi - // TODO: it segfaults! process.nextTick is scoped out for now i guess! - // vm.setOnComputeErrorInfo(computeErrorInfoWrapper); - // vm.setOnEachMicrotaskTick([global](JSC::VM &vm) -> void { - // if (auto nextTickQueue = global->m_nextTickQueue.get()) { - // global->resetOnEachMicrotaskTick(); - // // Bun::JSNextTickQueue *queue = - // // uncheckedDowncast(nextTickQueue); - // // queue->drain(vm, global); - // return; - // } - // }); return global; } diff --git a/src/runtime/dispatch.rs b/src/runtime/dispatch.rs index 7a9f2bb1618d..427595c19251 100644 --- a/src/runtime/dispatch.rs +++ b/src/runtime/dispatch.rs @@ -34,7 +34,7 @@ use bun_event_loop::{Task, task_tag}; use bun_io::posix_event_loop::{FilePoll, Flags as PollFlag, poll_tag}; use bun_event_loop::EventLoopTimer::{ - EventLoopTimer, Tag as EventLoopTimerTag, TimerCallback, Timespec as ElTimespec, + EventLoopTimer, Tag as EventLoopTimerTag, Timespec as ElTimespec, }; use bun_jsc::JSGlobalObject; @@ -1053,13 +1053,6 @@ pub(crate) unsafe fn __bun_fire_timer(t: *mut EventLoopTimer, now: *const ElTime // SAFETY: see TimeoutObject arm. unsafe { TimerObjectInternals::fire(internals, &*now, vm) }; } - // Spec `inline else` fallthrough: `container.callback(container)`. - EventLoopTimerTag::TimerCallback => { - timer_arm!(TimerCallback, event_loop_timer, |c, _now, _vm| ((*c) - .callback)( - c - )) - } EventLoopTimerTag::WTFTimer => { timer_arm!(WTFTimer, event_loop_timer, |c, now, vm| WTFTimer::fire( c, &*now, vm diff --git a/src/sql/mysql/protocol/EOFPacket.rs b/src/sql/mysql/protocol/EOFPacket.rs index fddc79cc3fd0..73c678ebe82f 100644 --- a/src/sql/mysql/protocol/EOFPacket.rs +++ b/src/sql/mysql/protocol/EOFPacket.rs @@ -4,7 +4,6 @@ use super::new_reader::{NewReader, ReaderContext}; pub struct EOFPacket { pub(crate) header: u8, - pub(crate) warnings: u16, pub status_flags: StatusFlags, } @@ -12,7 +11,6 @@ impl Default for EOFPacket { fn default() -> Self { Self { header: 0xfe, - warnings: 0, status_flags: StatusFlags::default(), } } @@ -28,7 +26,7 @@ impl EOFPacket { return Err(AnyMySQLError::InvalidEOFPacket); } - self.warnings = reader.int::()?; + reader.int::()?; // warnings self.status_flags = StatusFlags::from_int(reader.int::()?); Ok(()) } diff --git a/src/sql/mysql/protocol/LocalInfileRequest.rs b/src/sql/mysql/protocol/LocalInfileRequest.rs index 51202efe9b0f..37eb38a46e57 100644 --- a/src/sql/mysql/protocol/LocalInfileRequest.rs +++ b/src/sql/mysql/protocol/LocalInfileRequest.rs @@ -1,24 +1,14 @@ use super::any_mysql_error::Error as AnyMySQLError; use super::new_reader::{NewReader, ReaderContext}; -use crate::shared::Data; +#[derive(Default)] pub struct LocalInfileRequest { - pub filename: Data, // Callers populate this from `PacketHeader.length`, the 3-byte // MySQL packet length (always <= 0xFFFFFF), so `u32` holds it losslessly. + // Caller must set packet_size before decode. pub packet_size: u32, } -impl Default for LocalInfileRequest { - fn default() -> Self { - Self { - filename: Data::Empty, - // Caller must set packet_size before decode. - packet_size: 0, - } - } -} - impl LocalInfileRequest { pub fn decode_internal( &mut self, @@ -32,7 +22,7 @@ impl LocalInfileRequest { let Some(filename_len) = self.packet_size.checked_sub(1) else { return Err(AnyMySQLError::InvalidLocalInfileRequest); }; - self.filename = reader.read(filename_len as usize)?; + reader.read(filename_len as usize)?; // filename Ok(()) } } diff --git a/src/sql/mysql/protocol/OKPacket.rs b/src/sql/mysql/protocol/OKPacket.rs index efb54799d172..2f539999c1c2 100644 --- a/src/sql/mysql/protocol/OKPacket.rs +++ b/src/sql/mysql/protocol/OKPacket.rs @@ -2,16 +2,12 @@ use crate::mysql::StatusFlags; use crate::mysql::protocol::any_mysql_error::Error as AnyMySQLError; use crate::mysql::protocol::new_reader::{NewReader, ReaderContext}; -use crate::shared::Data; pub struct OKPacket { pub header: u8, pub affected_rows: u64, pub last_insert_id: u64, pub status_flags: StatusFlags, - pub warnings: u16, - pub info: Data, - pub session_state_changes: Data, pub packet_size: u32, } @@ -38,12 +34,12 @@ impl OKPacket { // Status flags self.status_flags = StatusFlags::from_int(reader.int::()?); // Warnings - self.warnings = reader.int::()?; + reader.int::()?; // Info (EOF-terminated string) if !reader.peek().is_empty() && (self.packet_size as usize) > read_size { let remaining = (self.packet_size as usize) - read_size; - self.info = reader.read(remaining as _)?; + reader.read(remaining as _)?; } Ok(()) } diff --git a/src/sql/mysql/protocol/StmtPrepareOKPacket.rs b/src/sql/mysql/protocol/StmtPrepareOKPacket.rs index 8b5acfd38674..70f78bfc0107 100644 --- a/src/sql/mysql/protocol/StmtPrepareOKPacket.rs +++ b/src/sql/mysql/protocol/StmtPrepareOKPacket.rs @@ -7,7 +7,6 @@ pub struct StmtPrepareOKPacket { pub statement_id: u32, pub num_columns: u16, pub num_params: u16, - pub warning_count: u16, pub packet_length: u32, } @@ -32,7 +31,7 @@ impl StmtPrepareOKPacket { self.num_params = reader.int::()?; let _ = reader.int::()?; // reserved_1 if self.packet_length >= 12 { - self.warning_count = reader.int::()?; + reader.int::()?; // warning_count } Ok(()) } diff --git a/src/sql_jsc/mysql/MySQLConnection.rs b/src/sql_jsc/mysql/MySQLConnection.rs index 2d51a893b369..b4e94e3ba254 100644 --- a/src/sql_jsc/mysql/MySQLConnection.rs +++ b/src/sql_jsc/mysql/MySQLConnection.rs @@ -780,9 +780,6 @@ impl MySQLConnection { affected_rows: 0, last_insert_id: 0, status_flags: StatusFlags::default(), - warnings: 0, - info: Data::Empty, - session_state_changes: Data::Empty, packet_size: header_length, }; ok.decode_internal(reader)?; @@ -1384,9 +1381,6 @@ impl MySQLConnection { affected_rows: 0, last_insert_id: 0, status_flags: StatusFlags::default(), - warnings: 0, - info: Data::Empty, - session_state_changes: Data::Empty, packet_size: header_length, }; match PacketType(first_byte) { diff --git a/test/internal/source-lints/dead-symbols-install-sql-bindings.test.ts b/test/internal/source-lints/dead-symbols-install-sql-bindings.test.ts new file mode 100644 index 000000000000..d09ead33368d --- /dev/null +++ b/test/internal/source-lints/dead-symbols-install-sql-bindings.test.ts @@ -0,0 +1,146 @@ +// Guards against reintroduction of symbols removed as dead code from +// bun_install, bun_event_loop, bun_dns, the MySQL wire-protocol structs, the +// C++ JSC bindings, the built-in JS internal modules, and the build flags. +// Each entry was verified to have zero references across src/, scripts/, +// test/, and freshly regenerated build/debug/codegen/ output before deletion, +// and the removal was validated by `cargo check` on all 10 CI target triples +// plus a full `bun bd` build. +// +// 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. +// +// The Rust checks read the working tree. The C++/JS checks read the committed +// tree (HEAD) instead: `git stash` round-trips can temporarily restore files a +// branch deletes (see the same note in dead-code-escapes.test.ts), and those +// strays must not fail the lint. CI runs against the committed tree, so HEAD +// is what matters. + +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 headFile(p: string): string { + const r = Bun.spawnSync({ + cmd: ["git", "-C", repoRoot, "show", `HEAD:${p}`], + stdout: "pipe", + stderr: "pipe", + }); + if (r.exitCode !== 0) { + throw new Error(`git show HEAD:${p} failed: ${r.stderr.toString()}`); + } + return r.stdout.toString(); +} + +test("dead Rust symbols (install, event_loop, dns, mysql protocol) do not reappear", () => { + const checks: Array<[string, RegExp]> = [ + // bun_install::Error variants never constructed (bun_runtime has its own + // same-named enum; these five were ported but nothing maps onto them). + ["src/install/error.rs", /^\s*FileTooBig,$/m], + ["src/install/error.rs", /^\s*ProcessFdQuotaExceeded,$/m], + ["src/install/error.rs", /^\s*ReadOnlyFileSystem,$/m], + ["src/install/error.rs", /^\s*FileSystem,$/m], + ["src/install/error.rs", /^\s*FileBusy,$/m], + + // FromTextLockfileError::InvalidSemver was never constructed; its only + // mention was a dead match arm in bun.lock.rs. + ["src/install/resolution.rs", /\bInvalidSemver\b/], + // MigratePnpmLockfileError variants never produced by the migration. + ["src/install/pnpm.rs", /PnpmLockfileInvalidOverride|PnpmLockfileInvalidPatchedDependency/], + // FailReason::InvalidShimDataSize: no size check produces it. + ["src/install/windows-shim/bun_shim_impl.rs", /\bInvalidShimDataSize\b/], + // TimerCallback: a timer owner type nothing ever constructed (its Tag + // variant could never be dispatched). + ["src/event_loop/EventLoopTimer.rs", /\bTimerCallback\b/], + ["src/runtime/dispatch.rs", /\bTimerCallback\b/], + // dns Family::Unix: no string map or numeric decode ever yields it. + ["src/dns/lib.rs", /^\s*Unix,$/m], + // MySQL wire fields that were decoded (or zero-initialized) but never + // read; the byte consumption stays, the stores are gone. + ["src/sql/mysql/protocol/OKPacket.rs", /session_state_changes|pub info:|pub warnings:/], + ["src/sql/mysql/protocol/EOFPacket.rs", /warnings:/], + ["src/sql/mysql/protocol/StmtPrepareOKPacket.rs", /pub warning_count:/], + ["src/sql/mysql/protocol/LocalInfileRequest.rs", /pub filename:|filename: Data::Empty/], + ]; + const resurrected = checks.filter(([file, re]) => re.test(src(file))).map(([file, re]) => `${file}: ${re.source}`); + + // Representation::Ssh: every ssh-flavored protocol maps to Sshurl. Scoped to + // the Representation enum body because WellDefinedProtocol::Ssh (a live + // variant in the same file) would trip a whole-file grep. + const hosted = src("src/install/hosted_git_info.rs"); + const reprStart = hosted.indexOf("pub enum Representation"); + const reprEnd = hosted.indexOf("}", reprStart); + expect(reprStart).toBeGreaterThan(-1); + expect(reprEnd).toBeGreaterThan(reprStart); + const reprBody = hosted.slice(reprStart, reprEnd); + if (/^\s*Ssh,$/m.test(reprBody)) { + resurrected.push("src/install/hosted_git_info.rs: Representation::Ssh"); + } + expect(resurrected).toEqual([]); +}); + +test("dead C++ bindings do not reappear", () => { + const checks: Array<[string, RegExp]> = [ + // Host-function wrappers whose $newCppFunction bindings were removed in an + // earlier sweep; the V::validate* overloads they forwarded to stay live. + ["src/jsc/bindings/NodeValidator.cpp", /jsFunction_validate(String|Function|Boolean)\b/], + // jsFunctionRequireResolve + its only callee functionRequireResolve; the + // live require.resolve path is built elsewhere. + ["src/jsc/bindings/ImportMetaObject.cpp", /RequireResolve\b/], + // extern "C" helpers with no Rust-side import in regenerated cpp.rs. + ["src/jsc/bindings/BunString.cpp", /BunString__toWTFString/], + // Never-instantiated struct (wrapAnsi.cpp's HyperlinkState is the live one). + ["src/jsc/bindings/sliceAnsi.cpp", /struct HyperlinkInfo\b/], + // Template with zero instantiations (the structure accessor pair is live). + ["src/jsc/bindings/NodeFSStatFSBinding.cpp", /getStatFSPrototype\b/], + // Declarations with no definition anywhere. + ["src/jsc/bindings/BunObject.h", /functionBunPeek(Status)?\b/], + ["src/jsc/bindings/JSBakeResponse.cpp", /JSC_DECLARE_HOST_FUNCTION\((call|construct)BakeResponse\)/], + ["src/jsc/bindings/sqlite/JSSQLStatement.cpp", /jsSqlStatementGetHasMultipleStatements/], + ["src/jsc/bindings/dh-primes.h", /bn_set_words/], + // Stale commented-out blocks (2023-2024 era). + ["src/jsc/bindings/BunProcess.cpp", /ErrorCaptureStackTrace\(warning/], + ["src/jsc/bindings/webcore/JSAbortSignal.cpp", /DeletePropertyModeScope/], + ["src/runtime/bake/BakeGlobalObject.cpp", /setOnEachMicrotaskTick/], + ]; + const resurrected = checks + .filter(([file, re]) => re.test(headFile(file))) + .map(([file, re]) => `${file}: ${re.source}`); + expect(resurrected).toEqual([]); +}); + +test("the WebKit weak error finalizer stays defined", () => { + // Bun__errorInstance__finalize has zero in-tree callers but is + // weak-referenced by JSC::ErrorInstance::finalizeUnconditionally in + // vendor/WebKit; removing it breaks the darwin LTO link. + expect(headFile("src/jsc/bindings/ErrorStackTrace.cpp")).toMatch( + /extern "C" void Bun__errorInstance__finalize\(void\*/, + ); +}); + +test("dead built-in JS exports and build defines do not reappear", () => { + const checks: Array<[string, RegExp]> = [ + // repl shim surface no requirer (repl.js, internal/repl/*) ever touched. + ["src/js/internal/repl/node-shims.js", /kEmptyObject|addAbortListener|runScriptInThisContext|isWritable/], + // Export entries no requirer destructures (the backing symbols that are + // still used in-file stay; only the export-default lines are pinned). + ["src/js/internal/fixed_queue.ts", /^\s*FixedCircularBuffer,$/m], + ["src/js/internal/promisify.ts", /^\s*defineCustomPromisify,$/m], + ["src/js/internal/sql/query.ts", /^\s*SQLQueryStatus,$/m], + ["src/js/internal/trace_events.ts", /^\s*setTid,$/m], + ["src/js/internal/inspector/cdp.ts", /^\s*EXECUTION_CONTEXT_ID,$/m], + // Compile defines nothing reads (verified against src/, packages/, and + // the pinned vendor/WebKit checkout; WebKit's bmalloc macro is the + // lowercase STATICALLY_LINKED_WITH_bmalloc). + ["scripts/build/flags.ts", /"IS_BUILD"|"WITH_BORINGSSL=1"|STATICALLY_LINKED_WITH_BMALLOC|PER_VM_ENTRY_SCOPE/], + ]; + const resurrected = checks + .filter(([file, re]) => re.test(headFile(file))) + .map(([file, re]) => `${file}: ${re.source}`); + expect(resurrected).toEqual([]); +});