From e2526382c16ed0bdd611f83237acc3eaeeec5afa Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Sun, 2 Aug 2026 16:13:04 +0000 Subject: [PATCH 01/11] Remove dead code from webcore C++, highway_strings, inspector agents, InlineBlob, Ipc.ts C++ bindings: - Delete TextCodecASCIIFastPath.h (78 lines, never #included) - Delete webcore/Node.h (108 lines, WebCore::Node never instantiated or subclassed) and its two #include sites - Delete stub headers JSDOMWindow.h, JSServiceWorker.h, JSWindowProxy.h and their #include sites - highway_strings.cpp: remove ScanCharFrequencyImpl, HWY_EXPORT, and highway_char_frequency (no Rust caller since #35002) - TextCodecWrapper.cpp: remove Bun__isEncodingSupported and Bun__getCanonicalEncodingName (no Rust caller since #35002) - StrongRef: remove Bun__StrongRef__get, Bun__StrongRef__clear, StrongRootBlock::clearValue (Rust reads the slot directly) - InspectorLifecycleAgent: remove Bun__LifecycleAgentReportReload wrapper and reportReload() method (no Rust caller) - InspectorBunFrontendDevServerAgent: remove notifyClientErrorReported/notifyGraphUpdate wrappers, their class methods, and the stale mismatched-prefix extern block in the header - JSS3File.cpp: remove file-scope static customHasInstance (never wired to a method table; StructureFlags has no ImplementsHasInstance) C++ commented-out code (>6 months stale per git blame): - JSTextEncoder.cpp: disabled DOMJIT declarations, signatures, hash-table entries and JSC_DEFINE_JIT_OPERATION bodies - JSURLSearchParams/JSErrorEvent/JSDOMException: BINDING_INTEGRITY vtable-check scaffolding - JSPerformance/JSDOMURL/JSWorkerOptions: JSDOMWindowBase-gated property-deletion paths - JSEventListener: beforeunload return-value handling (helper definition and call site) - PerformanceUserTiming: restrictedMarkFunctions lookup in convertMarkToTimestamp Rust: - Blob.rs: remove struct Inline and its impls (every reference in Body.rs/RequestContext.rs is commented out; Any enum has no Inline variant) - Body.rs, RequestContext.rs: remove the commented-out InlineBlob match arms that referenced it - S3File.rs: remove has_instance and the JSS3File__hasInstance export (its only C++ caller is the removed customHasInstance) - streams.rs: remove BufferAction::get (zero callers) - FileReader.rs: remove unused TAG const src/js (>6 months stale per git blame): - builtins/Ipc.ts: remove 131-line commented-out handleConversion map - internal/fs/streams.ts: remove commented-out fastPath._getFd block - node/worker_threads.ts: remove commented-out type imports Verified: rg across src/ and build/debug/codegen/ shows zero remaining references for every removed symbol; bun bd and rust:check-all (all targets) pass. --- src/js/builtins/Ipc.ts | 131 ------------------ src/js/internal/fs/streams.ts | 13 -- src/js/node/worker_threads.ts | 2 - .../InspectorBunFrontendDevServerAgent.cpp | 26 ---- .../InspectorBunFrontendDevServerAgent.h | 16 --- src/jsc/bindings/InspectorLifecycleAgent.cpp | 13 -- src/jsc/bindings/InspectorLifecycleAgent.h | 1 - src/jsc/bindings/JSS3File.cpp | 9 -- src/jsc/bindings/StrongRef.cpp | 10 -- src/jsc/bindings/StrongRef.h | 2 - src/jsc/bindings/StrongRootBlock.h | 9 -- src/jsc/bindings/TextCodecASCIIFastPath.h | 78 ----------- src/jsc/bindings/TextCodecWrapper.cpp | 26 ---- src/jsc/bindings/WebCoreOpaqueRoot.h | 2 - src/jsc/bindings/highway_strings.cpp | 78 ----------- src/jsc/bindings/webcore/EventTargetHeaders.h | 1 - src/jsc/bindings/webcore/JSDOMException.cpp | 30 ---- src/jsc/bindings/webcore/JSDOMURL.cpp | 12 -- src/jsc/bindings/webcore/JSDOMWindow.h | 1 - src/jsc/bindings/webcore/JSErrorEvent.cpp | 29 ---- src/jsc/bindings/webcore/JSEventListener.cpp | 23 --- .../bindings/webcore/JSEventTargetCustom.cpp | 5 - src/jsc/bindings/webcore/JSMessageEvent.cpp | 2 - .../bindings/webcore/JSMessageEventCustom.cpp | 3 - src/jsc/bindings/webcore/JSPerformance.cpp | 17 --- src/jsc/bindings/webcore/JSServiceWorker.h | 1 - src/jsc/bindings/webcore/JSTextEncoder.cpp | 83 ----------- .../bindings/webcore/JSURLSearchParams.cpp | 30 ---- src/jsc/bindings/webcore/JSWindowProxy.h | 1 - src/jsc/bindings/webcore/JSWorkerOptions.cpp | 24 ---- src/jsc/bindings/webcore/Node.h | 108 --------------- .../webcore/PerformanceUserTiming.cpp | 19 --- src/runtime/server/RequestContext.rs | 1 - src/runtime/webcore/Blob.rs | 49 ------- src/runtime/webcore/Body.rs | 23 +-- src/runtime/webcore/FileReader.rs | 1 - src/runtime/webcore/S3File.rs | 17 --- src/runtime/webcore/streams.rs | 4 - ...dead-symbols-webcore-inline-extern.test.ts | 81 +++++++++++ 39 files changed, 82 insertions(+), 899 deletions(-) delete mode 100644 src/jsc/bindings/TextCodecASCIIFastPath.h delete mode 100644 src/jsc/bindings/webcore/JSDOMWindow.h delete mode 100644 src/jsc/bindings/webcore/JSServiceWorker.h delete mode 100644 src/jsc/bindings/webcore/JSWindowProxy.h delete mode 100644 src/jsc/bindings/webcore/Node.h create mode 100644 test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts diff --git a/src/js/builtins/Ipc.ts b/src/js/builtins/Ipc.ts index cd593aec91c9..00ce544b6e94 100644 --- a/src/js/builtins/Ipc.ts +++ b/src/js/builtins/Ipc.ts @@ -1,134 +1,3 @@ -// for net.Server, get ._handle - -// const handleConversion = { -// "net.Server": { -// simultaneousAccepts: true, - -// send(message, server, options) { -// return server._handle; -// }, - -// got(message, handle, emit) { -// const server = new net.Server(); -// server.listen(handle, () => { -// emit(server); -// }); -// }, -// }, - -// "net.Socket": { -// send(message, socket, options) { -// if (!socket._handle) return; - -// // If the socket was created by net.Server -// if (socket.server) { -// // The worker should keep track of the socket -// message.key = socket.server._connectionKey; - -// const firstTime = !this[kChannelHandle].sockets.send[message.key]; -// const socketList = getSocketList("send", this, message.key); - -// // The server should no longer expose a .connection property -// // and when asked to close it should query the socket status from -// // the workers -// if (firstTime) socket.server._setupWorker(socketList); - -// // Act like socket is detached -// if (!options.keepOpen) socket.server._connections--; -// } - -// const handle = socket._handle; - -// // Remove handle from socket object, it will be closed when the socket -// // will be sent -// if (!options.keepOpen) { -// handle.onread = nop; -// socket._handle = null; -// socket.setTimeout(0); - -// if (freeParser === undefined) freeParser = require("_http_common").freeParser; -// if (HTTPParser === undefined) HTTPParser = require("_http_common").HTTPParser; - -// // In case of an HTTP connection socket, release the associated -// // resources -// if (socket.parser && socket.parser instanceof HTTPParser) { -// freeParser(socket.parser, null, socket); -// if (socket._httpMessage) socket._httpMessage.detachSocket(socket); -// } -// } - -// return handle; -// }, - -// postSend(message, handle, options, callback, target) { -// // Store the handle after successfully sending it, so it can be closed -// // when the NODE_HANDLE_ACK is received. If the handle could not be sent, -// // just close it. -// if (handle && !options.keepOpen) { -// if (target) { -// // There can only be one _pendingMessage as passing handles are -// // processed one at a time: handles are stored in _handleQueue while -// // waiting for the NODE_HANDLE_ACK of the current passing handle. -// assert(!target._pendingMessage); -// target._pendingMessage = { callback, message, handle, options, retransmissions: 0 }; -// } else { -// handle.close(); -// } -// } -// // NOTE that another function will call _pendingMessage.handle.close() and set _pendingMessage to null -// }, - -// got(message, handle, emit) { -// const socket = new net.Socket({ -// handle: handle, -// readable: true, -// writable: true, -// }); - -// // If the socket was created by net.Server we will track the socket -// if (message.key) { -// // Add socket to connections list -// const socketList = getSocketList("got", this, message.key); -// socketList.add({ -// socket: socket, -// }); -// } - -// emit(socket); -// }, -// }, - -// "dgram.Native": { -// simultaneousAccepts: false, - -// send(message, handle, options) { -// return handle; -// }, - -// got(message, handle, emit) { -// emit(handle); -// }, -// }, - -// "dgram.Socket": { -// simultaneousAccepts: false, - -// send(message, socket, options) { -// message.dgramType = socket.type; - -// return socket[kStateSymbol].handle; -// }, - -// got(message, handle, emit) { -// const socket = new dgram.Socket(message.dgramType); - -// socket.bind(handle, () => { -// emit(socket); -// }); -// }, -// }, -// }; - // have to use jsdoc type definitions because bundle-functions is based on regex /** * @typedef {Object} Serialized diff --git a/src/js/internal/fs/streams.ts b/src/js/internal/fs/streams.ts index 44e8d040fd7b..6216e649ae65 100644 --- a/src/js/internal/fs/streams.ts +++ b/src/js/internal/fs/streams.ts @@ -251,19 +251,6 @@ function streamConstruct(this: FSStream, callback: (e?: any) => void) { this.open(); } else { if (fastPath) { - // // there is a chance that this fd is not actually correct but it will be a number - // if (fastPath !== true) { - // // @ts-expect-error undocumented. to make this public please make it a - // // getter. couldn't figure that out sorry - // this.fd = fastPath._getFd(); - // } else { - // if (fs.open !== open || fs.write !== write || fs.fsync !== fsync || fs.close !== close) { - // this[kWriteStreamFastPath] = undefined; - // break fast; - // } - // // @ts-expect-error - // this.fd = (this[kWriteStreamFastPath] = Bun.file(this.path).writer())._getFd(); - // } callback(); this.emit("open", this.fd); this.emit("ready"); diff --git a/src/js/node/worker_threads.ts b/src/js/node/worker_threads.ts index 921df1a621d2..f8b269dd56ae 100644 --- a/src/js/node/worker_threads.ts +++ b/src/js/node/worker_threads.ts @@ -1,5 +1,3 @@ -// import type { Readable, Writable } from "node:stream"; -// import type { WorkerOptions } from "node:worker_threads"; declare const self: typeof globalThis; type WebWorker = InstanceType; diff --git a/src/jsc/bindings/InspectorBunFrontendDevServerAgent.cpp b/src/jsc/bindings/InspectorBunFrontendDevServerAgent.cpp index dabee36f67bd..a5ccb7aa8cd4 100644 --- a/src/jsc/bindings/InspectorBunFrontendDevServerAgent.cpp +++ b/src/jsc/bindings/InspectorBunFrontendDevServerAgent.cpp @@ -109,22 +109,6 @@ void InspectorBunFrontendDevServerAgent::clientNavigated(int devServerId, int co m_frontendDispatcher->clientNavigated(devServerId, connectionId, url, WTF::move(routeBundleId)); } -void InspectorBunFrontendDevServerAgent::clientErrorReported(int devServerId, const String& clientErrorPayloadBase64) -{ - if (!m_enabled || !m_frontendDispatcher) - return; - - m_frontendDispatcher->clientErrorReported(devServerId, clientErrorPayloadBase64); -} - -void InspectorBunFrontendDevServerAgent::graphUpdate(int devServerId, const String& visualizerPayloadBase64) -{ - if (!m_enabled || !m_frontendDispatcher) - return; - - // m_frontendDispatcher->graphUpdate(devServerId, visualizerPayloadBase64); -} - void InspectorBunFrontendDevServerAgent::consoleLog(int devServerId, char kind, const String& data) { if (!m_enabled || !m_frontendDispatcher) @@ -177,16 +161,6 @@ void InspectorBunFrontendDevServerAgent__notifyClientNavigated(InspectorBunFront agent->clientNavigated(devServerId, connectionId, url->toWTFString(), optionalRouteBundleId); } -void InspectorBunFrontendDevServerAgent__notifyClientErrorReported(InspectorBunFrontendDevServerAgent* agent, int devServerId, BunString* clientErrorPayloadBase64) -{ - agent->clientErrorReported(devServerId, clientErrorPayloadBase64->toWTFString()); -} - -void InspectorBunFrontendDevServerAgent__notifyGraphUpdate(InspectorBunFrontendDevServerAgent* agent, int devServerId, BunString* visualizerPayloadBase64) -{ - agent->graphUpdate(devServerId, visualizerPayloadBase64->toWTFString()); -} - void InspectorBunFrontendDevServerAgent__notifyConsoleLog(InspectorBunFrontendDevServerAgent* agent, int devServerId, char kind, BunString* data) { agent->consoleLog(devServerId, kind, data->toWTFString()); diff --git a/src/jsc/bindings/InspectorBunFrontendDevServerAgent.h b/src/jsc/bindings/InspectorBunFrontendDevServerAgent.h index 6c150df6bcce..1db64afd1028 100644 --- a/src/jsc/bindings/InspectorBunFrontendDevServerAgent.h +++ b/src/jsc/bindings/InspectorBunFrontendDevServerAgent.h @@ -39,28 +39,12 @@ class InspectorBunFrontendDevServerAgent final : public InspectorAgentBase, publ void bundleComplete(int devServerId, double durationMs); void bundleFailed(int devServerId, const String& buildErrorsPayloadBase64); void clientNavigated(int devServerId, int connectionId, const String& url, std::optional routeBundleId); - void clientErrorReported(int devServerId, const String& clientErrorPayloadBase64); - void graphUpdate(int devServerId, const String& visualizerPayloadBase64); void consoleLog(int devServerId, char kind, const String& data); private: - // JSC::JSGlobalObject& m_globalobject; std::unique_ptr m_frontendDispatcher; Ref m_backendDispatcher; bool m_enabled { false }; }; -// C API for the Rust side to call -extern "C" { -void BunFrontendDevServerAgent__notifyClientConnected(InspectorBunFrontendDevServerAgent* agent, int connectionId); -void BunFrontendDevServerAgent__notifyClientDisconnected(InspectorBunFrontendDevServerAgent* agent, int connectionId); -void BunFrontendDevServerAgent__notifyBundleStart(InspectorBunFrontendDevServerAgent* agent, const BunString* triggerFiles, size_t triggerFilesLen, int buildId); -void BunFrontendDevServerAgent__notifyBundleComplete(InspectorBunFrontendDevServerAgent* agent, double durationMs, int buildId); -void BunFrontendDevServerAgent__notifyBundleFailed(InspectorBunFrontendDevServerAgent* agent, const BunString* buildErrorsPayloadBase64, int buildId); -void BunFrontendDevServerAgent__notifyClientNavigated(InspectorBunFrontendDevServerAgent* agent, int connectionId, const BunString* url, int routeBundleId); -void BunFrontendDevServerAgent__notifyClientErrorReported(InspectorBunFrontendDevServerAgent* agent, const BunString* clientErrorPayloadBase64); -void BunFrontendDevServerAgent__notifyGraphUpdate(InspectorBunFrontendDevServerAgent* agent, const BunString* visualizerPayloadBase64); -void BunFrontendDevServerAgent__notifyConsoleLog(InspectorBunFrontendDevServerAgent* agent, int devServerId, char kind, const BunString* data); -} - } // namespace Inspector diff --git a/src/jsc/bindings/InspectorLifecycleAgent.cpp b/src/jsc/bindings/InspectorLifecycleAgent.cpp index 4b6bf8862536..8a4f4394aa71 100644 --- a/src/jsc/bindings/InspectorLifecycleAgent.cpp +++ b/src/jsc/bindings/InspectorLifecycleAgent.cpp @@ -31,11 +31,6 @@ extern "C" { void Bun__LifecycleAgentEnable(Inspector::InspectorLifecycleAgent* agent); void Bun__LifecycleAgentDisable(Inspector::InspectorLifecycleAgent* agent); -void Bun__LifecycleAgentReportReload(Inspector::InspectorLifecycleAgent* agent) -{ - agent->reportReload(); -} - void Bun__LifecycleAgentReportError(Inspector::InspectorLifecycleAgent* agent, ZigException* exception) { ASSERT(exception); @@ -89,14 +84,6 @@ Protocol::ErrorStringOr InspectorLifecycleAgent::disable() return {}; } -void InspectorLifecycleAgent::reportReload() -{ - if (!m_enabled) - return; - - m_frontendDispatcher->reload(); -} - void InspectorLifecycleAgent::reportError(ZigException& exception) { if (!m_enabled) diff --git a/src/jsc/bindings/InspectorLifecycleAgent.h b/src/jsc/bindings/InspectorLifecycleAgent.h index d598e7013b6f..2ba0e9c53287 100644 --- a/src/jsc/bindings/InspectorLifecycleAgent.h +++ b/src/jsc/bindings/InspectorLifecycleAgent.h @@ -35,7 +35,6 @@ class InspectorLifecycleAgent final : public InspectorAgentBase, public Inspecto virtual CommandResultOf> /* esm */, Ref> /* cjs */, String /* cwd */, String /* main */, Ref> /* argv */> getModuleGraph() final; // Public API - void reportReload(); void reportError(ZigException&); Protocol::ErrorStringOr preventExit(); Protocol::ErrorStringOr stopPreventingExit(); diff --git a/src/jsc/bindings/JSS3File.cpp b/src/jsc/bindings/JSS3File.cpp index aecfc1de9248..e0f70dc40626 100644 --- a/src/jsc/bindings/JSS3File.cpp +++ b/src/jsc/bindings/JSS3File.cpp @@ -26,7 +26,6 @@ SYSV_ABI void* JSS3File__construct(JSC::JSGlobalObject*, JSC::CallFrame* callfra SYSV_ABI EncodedJSValue JSS3File__presign(void* ptr, JSC::JSGlobalObject*, JSC::CallFrame* callframe); SYSV_ABI EncodedJSValue JSS3File__stat(void* ptr, JSC::JSGlobalObject*, JSC::CallFrame* callframe); SYSV_ABI EncodedJSValue JSS3File__bucket(void* ptr, JSC::JSGlobalObject*); -SYSV_ABI bool JSS3File__hasInstance(EncodedJSValue, JSC::JSGlobalObject*, EncodedJSValue); } // Forward declarations @@ -150,14 +149,6 @@ JSC::Structure* JSS3File::createStructure(JSC::JSGlobalObject* globalObject) return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(static_cast(0b11101110), StructureFlags), info(), NonArray); } -static bool customHasInstance(JSObject* object, JSGlobalObject* globalObject, JSValue value) -{ - if (!value.isObject()) - return false; - - return JSS3File__hasInstance(JSValue::encode(object), globalObject, JSValue::encode(value)); -} - Structure* createJSS3FileStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject) { return JSS3File::createStructure(globalObject); diff --git a/src/jsc/bindings/StrongRef.cpp b/src/jsc/bindings/StrongRef.cpp index fb024c6ae2f1..5744b2593472 100644 --- a/src/jsc/bindings/StrongRef.cpp +++ b/src/jsc/bindings/StrongRef.cpp @@ -57,21 +57,11 @@ extern "C" StrongRefImpl* Bun__StrongRef__new(JSC::JSGlobalObject* globalObject, return encodeStrongRef(block, index); } -extern "C" JSC::EncodedJSValue Bun__StrongRef__get(StrongRefImpl* _Nonnull ref) -{ - return JSC::JSValue::encode(decodeStrongRefBlock(ref)->read(decodeStrongRefIndex(ref))); -} - extern "C" void Bun__StrongRef__set(StrongRefImpl* _Nonnull ref, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue encodedValue) { decodeStrongRefBlock(ref)->write(JSC::getVM(globalObject), decodeStrongRefIndex(ref), JSC::JSValue::decode(encodedValue)); } -extern "C" void Bun__StrongRef__clear(StrongRefImpl* _Nonnull ref) -{ - decodeStrongRefBlock(ref)->clearValue(decodeStrongRefIndex(ref)); -} - // The Rust caller (Strong.rs Impl::destroy) skips this call once // VirtualMachine.is_shutting_down is true, so the block cell is guaranteed // live here: destructOnExit / WebWorker__teardownJSCVM set that flag before diff --git a/src/jsc/bindings/StrongRef.h b/src/jsc/bindings/StrongRef.h index e218cce46a89..26143c1a5bad 100644 --- a/src/jsc/bindings/StrongRef.h +++ b/src/jsc/bindings/StrongRef.h @@ -9,9 +9,7 @@ struct StrongRefImpl; extern "C" void Bun__StrongRef__delete(Bun::StrongRefImpl* _Nonnull ref); extern "C" Bun::StrongRefImpl* Bun__StrongRef__new(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue encodedValue); -extern "C" JSC::EncodedJSValue Bun__StrongRef__get(Bun::StrongRefImpl* _Nonnull ref); extern "C" void Bun__StrongRef__set(Bun::StrongRefImpl* _Nonnull ref, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue encodedValue); -extern "C" void Bun__StrongRef__clear(Bun::StrongRefImpl* _Nonnull ref); namespace Bun { diff --git a/src/jsc/bindings/StrongRootBlock.h b/src/jsc/bindings/StrongRootBlock.h index 20f927b36007..c14db345fcec 100644 --- a/src/jsc/bindings/StrongRootBlock.h +++ b/src/jsc/bindings/StrongRootBlock.h @@ -82,15 +82,6 @@ class StrongRootBlock final : public JSC::JSCell { bool isFull() const { return m_occupiedCount == capacity; } - // Clear the stored value but keep the slot occupied so a later write() - // reuses it without touching the bitset (Bun__StrongRef__clear). - void clearValue(unsigned index) - { - ASSERT(index < capacity); - ASSERT(m_occupied.get(index)); - m_slots[index].clear(); - } - // Returns the lowest free slot index, or `capacity` if full. unsigned findFreeSlot() const { diff --git a/src/jsc/bindings/TextCodecASCIIFastPath.h b/src/jsc/bindings/TextCodecASCIIFastPath.h deleted file mode 100644 index 3fa7708be504..000000000000 --- a/src/jsc/bindings/TextCodecASCIIFastPath.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2011 Apple Inc. All rights reserved. - * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -#include -#include - -namespace PAL { - -template struct UCharByteFiller; -template<> struct UCharByteFiller<4> { - static void copy(std::span destination, std::span source) - { - memcpySpan(destination, source.first(4)); - } - - static void copy(std::span destination, std::span source) - { - destination[0] = source[0]; - destination[1] = source[1]; - destination[2] = source[2]; - destination[3] = source[3]; - } -}; -template<> struct UCharByteFiller<8> { - static void copy(std::span destination, std::span source) - { - memcpySpan(destination, source.first(8)); - } - - static void copy(std::span destination, std::span source) - { - destination[0] = source[0]; - destination[1] = source[1]; - destination[2] = source[2]; - destination[3] = source[3]; - destination[4] = source[4]; - destination[5] = source[5]; - destination[6] = source[6]; - destination[7] = source[7]; - } -}; - -inline void copyASCIIMachineWord(std::span destination, std::span source) -{ - UCharByteFiller::copy(destination, source); -} - -inline void copyASCIIMachineWord(std::span destination, std::span source) -{ - UCharByteFiller::copy(destination, source); -} - -} // namespace PAL diff --git a/src/jsc/bindings/TextCodecWrapper.cpp b/src/jsc/bindings/TextCodecWrapper.cpp index 810abbe47416..5aa1bf360c7d 100644 --- a/src/jsc/bindings/TextCodecWrapper.cpp +++ b/src/jsc/bindings/TextCodecWrapper.cpp @@ -79,30 +79,4 @@ void Bun__stripBOMFromTextCodec(void* codecPtr) } } -// Check if an encoding is supported -bool Bun__isEncodingSupported(const char* encodingName, size_t encodingNameLen) -{ - std::span span(encodingName, encodingNameLen); - StringView encodingView(span); - TextEncoding encoding(encodingView); - return encoding.isValid(); -} - -// Get canonical encoding name -const char* Bun__getCanonicalEncodingName(const char* encodingName, size_t encodingNameLen, size_t* outLen) -{ - std::span span(encodingName, encodingNameLen); - StringView encodingView(span); - TextEncoding encoding(encodingView); - - if (!encoding.isValid()) { - *outLen = 0; - return nullptr; - } - - const char* name = encoding.name(); - *outLen = strlen(name); - return name; -} - } // extern "C" diff --git a/src/jsc/bindings/WebCoreOpaqueRoot.h b/src/jsc/bindings/WebCoreOpaqueRoot.h index 96b98a0a775b..009f79f6939d 100644 --- a/src/jsc/bindings/WebCoreOpaqueRoot.h +++ b/src/jsc/bindings/WebCoreOpaqueRoot.h @@ -26,8 +26,6 @@ #pragma once -#include "Node.h" - namespace WebCore { class WebCoreOpaqueRoot { diff --git a/src/jsc/bindings/highway_strings.cpp b/src/jsc/bindings/highway_strings.cpp index b815c2b084fc..bbd77b4effb5 100644 --- a/src/jsc/bindings/highway_strings.cpp +++ b/src/jsc/bindings/highway_strings.cpp @@ -536,77 +536,6 @@ size_t HtmlEscapeExtraLen16Impl(const uint16_t* HWY_RESTRICT text, size_t text_l return extra; } -// Implementation for scanCharFrequency (Unchanged from previous correct version) -void ScanCharFrequencyImpl(const uint8_t* HWY_RESTRICT text, size_t text_len, int32_t* HWY_RESTRICT freqs, int32_t delta) -{ - if (text_len == 0 || delta == 0) return; - D8 d; - const size_t N = hn::Lanes(d); - - const auto vec_a = hn::Set(d, 'a'); - const auto vec_z = hn::Set(d, 'z'); - const auto vec_A = hn::Set(d, 'A'); - const auto vec_Z = hn::Set(d, 'Z'); - const auto vec_0 = hn::Set(d, '0'); - const auto vec_9 = hn::Set(d, '9'); - const auto vec_underscore = hn::Set(d, '_'); - const auto vec_dollar = hn::Set(d, '$'); - - const auto vec_offset_a = hn::Set(d, 'a'); - const auto vec_offset_A = hn::Set(d, 'A'); - const auto vec_offset_0 = hn::Set(d, '0'); - - size_t i = 0; - size_t simd_text_len = text_len - (text_len % N); - for (; i < simd_text_len; i += N) { - const auto text_vec = hn::LoadU(d, text + i); - const auto mask_az = hn::And(hn::Ge(text_vec, vec_a), hn::Le(text_vec, vec_z)); - const auto mask_AZ = hn::And(hn::Ge(text_vec, vec_A), hn::Le(text_vec, vec_Z)); - const auto mask_09 = hn::And(hn::Ge(text_vec, vec_0), hn::Le(text_vec, vec_9)); - const auto mask_underscore = hn::Eq(text_vec, vec_underscore); - const auto mask_dollar = hn::Eq(text_vec, vec_dollar); - auto valid_mask = hn::Or(mask_az, hn::Or(mask_AZ, hn::Or(mask_09, hn::Or(mask_underscore, mask_dollar)))); - if (hn::AllFalse(d, valid_mask)) continue; - - const auto idx_az = hn::Sub(text_vec, vec_offset_a); - const auto idx_AZ = hn::Add(hn::Sub(text_vec, vec_offset_A), hn::Set(d, uint8_t { 26 })); - const auto idx_09 = hn::Add(hn::Sub(text_vec, vec_offset_0), hn::Set(d, uint8_t { 52 })); - - auto indices_vec = hn::Zero(d); - indices_vec = hn::IfThenElse(mask_az, idx_az, indices_vec); - indices_vec = hn::IfThenElse(mask_AZ, idx_AZ, indices_vec); - indices_vec = hn::IfThenElse(mask_09, idx_09, indices_vec); - indices_vec = hn::IfThenElse(mask_underscore, hn::Set(d, uint8_t { 62 }), indices_vec); - indices_vec = hn::IfThenElse(mask_dollar, hn::Set(d, uint8_t { 63 }), indices_vec); - - alignas(HWY_ALIGNMENT) uint8_t indices_array[HWY_MAX_LANES_D(D8)]; - alignas(HWY_ALIGNMENT) uint8_t valid_bits_array[(HWY_MAX_LANES_D(D8) + 7) / 8]; - hn::Store(indices_vec, d, indices_array); - hn::StoreMaskBits(d, valid_mask, valid_bits_array); - - for (size_t j = 0; j < N; ++j) { - if ((valid_bits_array[j / 8] >> (j % 8)) & 1) { - assert(indices_array[j] < 64); - freqs[indices_array[j]] += delta; - } - } - } - - for (; i < text_len; ++i) { - const uint8_t c = text[i]; - if (c >= 'a' && c <= 'z') - freqs[c - 'a'] += delta; - else if (c >= 'A' && c <= 'Z') - freqs[c - 'A' + 26] += delta; - else if (c >= '0' && c <= '9') - freqs[c - '0' + 52] += delta; - else if (c == '_') - freqs[62] += delta; - else if (c == '$') - freqs[63] += delta; - } -} - // Implementation for finding interesting characters in string literals size_t IndexOfInterestingCharacterInStringLiteralImpl(const uint8_t* HWY_RESTRICT text, size_t text_len, uint8_t quote) { @@ -2167,7 +2096,6 @@ HWY_EXPORT(MemMemImpl); HWY_EXPORT(MemRMemImpl); HWY_EXPORT(MemMem16Impl); HWY_EXPORT(MemRMem16Impl); -HWY_EXPORT(ScanCharFrequencyImpl); HWY_EXPORT(VisibleLatin1WidthExcludeANSIImpl); HWY_EXPORT(VisibleLatin1WidthImpl); HWY_EXPORT(VisibleUTF16WidthImpl); @@ -2253,12 +2181,6 @@ size_t highway_index_of_any_char(const uint8_t* HWY_RESTRICT text, size_t text_l return HWY_DYNAMIC_DISPATCH(IndexOfAnyCharImpl)(text, text_len, chars, chars_len); } -void highway_char_frequency(const uint8_t* HWY_RESTRICT text, size_t text_len, - int32_t* freqs, int32_t delta) -{ - HWY_DYNAMIC_DISPATCH(ScanCharFrequencyImpl)(text, text_len, freqs, delta); -} - size_t highway_index_of_char(const uint8_t* HWY_RESTRICT haystack, size_t haystack_len, uint8_t needle) { diff --git a/src/jsc/bindings/webcore/EventTargetHeaders.h b/src/jsc/bindings/webcore/EventTargetHeaders.h index 1ec0139cabca..dda35f971db7 100644 --- a/src/jsc/bindings/webcore/EventTargetHeaders.h +++ b/src/jsc/bindings/webcore/EventTargetHeaders.h @@ -35,7 +35,6 @@ #include "JSBroadcastChannel.h" #include "MessagePort.h" #include "JSMessagePort.h" -#include "Node.h" #include "WebSocket.h" #include "JSWebSocket.h" #include "Worker.h" diff --git a/src/jsc/bindings/webcore/JSDOMException.cpp b/src/jsc/bindings/webcore/JSDOMException.cpp index cb704818619f..6be9398307ab 100644 --- a/src/jsc/bindings/webcore/JSDOMException.cpp +++ b/src/jsc/bindings/webcore/JSDOMException.cpp @@ -348,38 +348,8 @@ void JSDOMExceptionOwner::finalize(JSC::Handle handle, void* conte uncacheWrapper(world, &jsDOMException->wrapped(), jsDOMException); } -// #if ENABLE(BINDING_INTEGRITY) -// #if PLATFORM(WIN) -// #pragma warning(disable : 4483) -// extern "C" { -// extern void (*const __identifier("??_7DOMException@WebCore@@6B@")[])(); -// } -// #else -// extern "C" { -// extern void* _ZTVN7WebCore12DOMExceptionE[]; -// } -// #endif -// #endif - JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject* globalObject, Ref&& impl) { - - // if constexpr (std::is_polymorphic_v) { - // #if ENABLE(BINDING_INTEGRITY) - // // const void* actualVTablePointer = getVTablePointer(impl.ptr()); - // #if PLATFORM(WIN) - // void* expectedVTablePointer = __identifier("??_7DOMException@WebCore@@6B@"); - // #else - // // void* expectedVTablePointer = &_ZTVN7WebCore12DOMExceptionE[2]; - // #endif - - // // If you hit this assertion you either have a use after free bug, or - // // DOMException has subclasses. If DOMException has subclasses that get passed - // // to toJS() we currently require DOMException you to opt out of binding hardening - // // by adding the SkipVTableValidation attribute to the interface IDL definition - // // RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); - // #endif - // } return createWrapper(globalObject, WTF::move(impl)); } diff --git a/src/jsc/bindings/webcore/JSDOMURL.cpp b/src/jsc/bindings/webcore/JSDOMURL.cpp index 0aa9dadf4566..151b59d1639f 100644 --- a/src/jsc/bindings/webcore/JSDOMURL.cpp +++ b/src/jsc/bindings/webcore/JSDOMURL.cpp @@ -190,18 +190,6 @@ template<> void JSDOMURLDOMConstructor::initializeProperties(VM& vm, JSDOMGlobal putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); putDirect(vm, vm.propertyNames->prototype, JSDOMURL::prototype(vm, globalObject), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete); reifyStaticProperties(vm, JSDOMURL::info(), JSDOMURLConstructorTableValues, *this); - // if (!((&globalObject)->inherits() || (&globalObject)->inherits() || (&globalObject)->inherits())) { - // auto propertyName = Identifier::fromString(vm, "createObjectURL"_s); - // VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); - // DeletePropertySlot slot; - // JSObject::deleteProperty(this, &globalObject, propertyName, slot); - // } - // if (!((&globalObject)->inherits() || (&globalObject)->inherits() || (&globalObject)->inherits())) { - // auto propertyName = Identifier::fromString(vm, "revokeObjectURL"_s); - // VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); - // DeletePropertySlot slot; - // JSObject::deleteProperty(this, &globalObject, propertyName, slot); - // } } /* Hash table for prototype */ diff --git a/src/jsc/bindings/webcore/JSDOMWindow.h b/src/jsc/bindings/webcore/JSDOMWindow.h deleted file mode 100644 index 380273258f0d..000000000000 --- a/src/jsc/bindings/webcore/JSDOMWindow.h +++ /dev/null @@ -1 +0,0 @@ -// this is a stub header file diff --git a/src/jsc/bindings/webcore/JSErrorEvent.cpp b/src/jsc/bindings/webcore/JSErrorEvent.cpp index eae14507d0c4..c92e6d47ca36 100644 --- a/src/jsc/bindings/webcore/JSErrorEvent.cpp +++ b/src/jsc/bindings/webcore/JSErrorEvent.cpp @@ -412,37 +412,8 @@ void JSErrorEvent::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) Base::analyzeHeap(cell, analyzer); } -// #if ENABLE(BINDING_INTEGRITY) -// #if PLATFORM(WIN) -// #pragma warning(disable : 4483) -// extern "C" { -// extern void (*const __identifier("??_7ErrorEvent@WebCore@@6B@")[])(); -// } -// #else -// extern "C" { -// extern void* _ZTVN7WebCore10ErrorEventE[]; -// } -// #endif -// #endif - JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject* globalObject, Ref&& impl) { - - // if constexpr (std::is_polymorphic_v) { - // #if ENABLE(BINDING_INTEGRITY) - // // const void* actualVTablePointer = getVTablePointer(impl.ptr()); - // #if PLATFORM(WIN) - // void* expectedVTablePointer = __identifier("??_7ErrorEvent@WebCore@@6B@"); - // #else - // // void* expectedVTablePointer = &_ZTVN7WebCore10ErrorEventE[2]; - // #endif - - // // If you hit this assertion you either have a use after free bug, or - // // ErrorEvent has subclasses. If ErrorEvent has subclasses that get passed - // // to toJS() we currently require ErrorEvent you to opt out of binding hardening - // // by adding the SkipVTableValidation attribute to the interface IDL definition - // // RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); - // #endif return createWrapper(globalObject, WTF::move(impl)); } diff --git a/src/jsc/bindings/webcore/JSEventListener.cpp b/src/jsc/bindings/webcore/JSEventListener.cpp index e1d7f4eb3eb7..095ae5257e35 100644 --- a/src/jsc/bindings/webcore/JSEventListener.cpp +++ b/src/jsc/bindings/webcore/JSEventListener.cpp @@ -115,16 +115,6 @@ inline void JSEventListener::visitJSFunctionImpl(Visitor& visitor) void JSEventListener::visitJSFunction(AbstractSlotVisitor& visitor) { visitJSFunctionImpl(visitor); } void JSEventListener::visitJSFunction(SlotVisitor& visitor) { visitJSFunctionImpl(visitor); } -// static void handleBeforeUnloadEventReturnValue(BeforeUnloadEvent& event, const String& returnValue) -// { -// if (returnValue.isNull()) -// return; - -// event.preventDefault(); -// if (event.returnValue().isEmpty()) -// event.setReturnValue(returnValue); -// } - JSC_DEFINE_HOST_FUNCTION(jsFunctionEmitUncaughtException, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame* callFrame)) { auto exception = callFrame->argument(0); @@ -292,19 +282,6 @@ void JSEventListener::handleEvent(ScriptExecutionContext& scriptExecutionContext // Do return value handling for event handlers (https://html.spec.whatwg.org/#the-event-handler-processing-algorithm). - // if (event.type() == eventNames().beforeunloadEvent) { - // // This is a OnBeforeUnloadEventHandler, and therefore the return value must be coerced into a String. - // if (is(event)) { - // String resultStr = convert>(*lexicalGlobalObject, retval); - // if (scope.exception()) [[unlikely]] { - // if (handleExceptionIfNeeded(scope.exception())) - // return; - // } - // handleBeforeUnloadEventReturnValue(downcast(event), resultStr); - // } - // return; - // } - if (retval.isFalse()) event.preventDefault(); } diff --git a/src/jsc/bindings/webcore/JSEventTargetCustom.cpp b/src/jsc/bindings/webcore/JSEventTargetCustom.cpp index 2dc97930715d..5cc9953b067a 100644 --- a/src/jsc/bindings/webcore/JSEventTargetCustom.cpp +++ b/src/jsc/bindings/webcore/JSEventTargetCustom.cpp @@ -28,14 +28,9 @@ // #include "DOMWindow.h" #include "EventTarget.h" -// #include "EventTargetHeaders.h" #include "EventTargetInterfaces.h" -// #include "JSDOMWindow.h" #include "JSDOMWrapperCache.h" #include "JSEventListener.h" -// #include "JSWindowProxy.h" -// #include "JSWorkerGlobalScope.h" -// #include "WorkerGlobalScope.h" #include "BunWorkerGlobalScope.h" #if ENABLE(OFFSCREEN_CANVAS) diff --git a/src/jsc/bindings/webcore/JSMessageEvent.cpp b/src/jsc/bindings/webcore/JSMessageEvent.cpp index 9d2dddf18e27..19bb33fc6390 100644 --- a/src/jsc/bindings/webcore/JSMessageEvent.cpp +++ b/src/jsc/bindings/webcore/JSMessageEvent.cpp @@ -41,9 +41,7 @@ #include "JSDOMOperation.h" #include "JSDOMWrapperCache.h" #include "JSMessagePort.h" -#include "JSServiceWorker.h" #include -#include "JSWindowProxy.h" #include "ScriptExecutionContext.h" #include "WebCoreJSClientData.h" diff --git a/src/jsc/bindings/webcore/JSMessageEventCustom.cpp b/src/jsc/bindings/webcore/JSMessageEventCustom.cpp index 71917f1aada2..cfc8b6019385 100644 --- a/src/jsc/bindings/webcore/JSMessageEventCustom.cpp +++ b/src/jsc/bindings/webcore/JSMessageEventCustom.cpp @@ -32,12 +32,9 @@ #include "config.h" #include "JSMessageEvent.h" -// #include "JSBlob.h" #include "JSDOMBinding.h" #include "JSDOMConvert.h" -#include "JSDOMWindow.h" #include "JSEventTarget.h" -// #include "JSMessagePort.h" #include #include #include "blob.h" diff --git a/src/jsc/bindings/webcore/JSPerformance.cpp b/src/jsc/bindings/webcore/JSPerformance.cpp index 75a6c55a7669..7954200dda92 100644 --- a/src/jsc/bindings/webcore/JSPerformance.cpp +++ b/src/jsc/bindings/webcore/JSPerformance.cpp @@ -229,23 +229,6 @@ void JSPerformancePrototype::finishCreation(VM& vm) { Base::finishCreation(vm); reifyStaticProperties(vm, JSPerformance::info(), JSPerformancePrototypeTableValues, *this); - // bool hasDisabledRuntimeProperties = false; - // if (!(globalObject())->inherits()) { - // hasDisabledRuntimeProperties = true; - // auto propertyName = Identifier::fromString(vm, "navigation"_s); - // VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); - // DeletePropertySlot slot; - // JSObject::deleteProperty(this, globalObject(), propertyName, slot); - // } - // if (!(globalObject())->inherits()) { - // hasDisabledRuntimeProperties = true; - // auto propertyName = Identifier::fromString(vm, "timing"_s); - // VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); - // DeletePropertySlot slot; - // JSObject::deleteProperty(this, globalObject(), propertyName, slot); - // } - // if (hasDisabledRuntimeProperties && structure()->isDictionary()) - // flattenDictionaryObject(vm); JSC_TO_STRING_TAG_WITHOUT_TRANSITION(); } diff --git a/src/jsc/bindings/webcore/JSServiceWorker.h b/src/jsc/bindings/webcore/JSServiceWorker.h deleted file mode 100644 index 22bde8d06703..000000000000 --- a/src/jsc/bindings/webcore/JSServiceWorker.h +++ /dev/null @@ -1 +0,0 @@ -// stub diff --git a/src/jsc/bindings/webcore/JSTextEncoder.cpp b/src/jsc/bindings/webcore/JSTextEncoder.cpp index 3ff9eca470d5..3056cf0f2c0e 100644 --- a/src/jsc/bindings/webcore/JSTextEncoder.cpp +++ b/src/jsc/bindings/webcore/JSTextEncoder.cpp @@ -73,11 +73,6 @@ extern "C" size_t TextEncoder__encodeInto8(const Latin1Character* stringPtr, siz extern "C" size_t TextEncoder__encodeInto16(const char16_t* stringPtr, size_t stringLen, void* ptr, size_t len); extern "C" JSC::EncodedJSValue TextEncoder__encodeRopeString(JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSString* str); -// extern "C" { -// static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(jsTextEncoderEncodeWithoutTypeCheck, JSC::EncodedJSValue, (JSC::JSGlobalObject*, JSTextEncoder*, DOMJIT::IDLJSArgumentType)); -// static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(jsTextEncoderPrototypeFunction_encodeIntoWithoutTypeCheck, JSC::EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, JSTextEncoder* castedThis, DOMJIT::IDLJSArgumentType source, DOMJIT::IDLJSArgumentType destination)); -// } - template<> TextEncoder::EncodeIntoResult convertDictionary(JSGlobalObject& lexicalGlobalObject, JSValue value) { auto& vm = JSC::getVM(&lexicalGlobalObject); @@ -214,93 +209,15 @@ template<> void JSTextEncoderDOMConstructor::initializeProperties(VM& vm, JSDOMG putDirect(vm, vm.propertyNames->prototype, JSTextEncoder::prototype(vm, globalObject), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete); } -// static const JSC::DOMJIT::Signature DOMJITSignatureForJSTextEncoderEncodeWithoutTypeCheck( -// jsTextEncoderEncodeWithoutTypeCheck, -// JSTextEncoder::info(), -// // https://github.com/oven-sh/bun/issues/9226 -// // It's not totally clear what the correct side effects are for this function, so we just make it conservative for now. -// JSC::DOMJIT::Effect {}, -// DOMJIT::IDLResultTypeFilter::value, -// DOMJIT::IDLArgumentTypeFilter::value); - -// static const JSC::DOMJIT::Signature DOMJITSignatureForJSTextEncoderEncodeIntoWithoutTypeCheck( -// jsTextEncoderPrototypeFunction_encodeIntoWithoutTypeCheck, -// JSTextEncoder::info(), - -// JSC::DOMJIT::Effect {}, -// // JSC::DOMJIT::Effect::forReadWriteKinds(encodeIntoRead, encodeIntoWrite), -// DOMJIT::IDLResultTypeFilter::value, -// DOMJIT::IDLArgumentTypeFilter::value, -// DOMJIT::IDLArgumentTypeFilter::value); - /* Hash table for prototype */ static const HashTableValue JSTextEncoderPrototypeTableValues[] = { { "constructor"_s, static_cast(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { HashTableValue::GetterSetterType, jsTextEncoderConstructor, 0 } }, { "encoding"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { HashTableValue::GetterSetterType, jsTextEncoder_encoding, 0 } }, - // { "encode"_s, static_cast(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction), NoIntrinsic, { HashTableValue::DOMJITFunctionType, jsTextEncoderPrototypeFunction_encode, &DOMJITSignatureForJSTextEncoderEncodeWithoutTypeCheck } }, - // { "encodeInto"_s, static_cast(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction), NoIntrinsic, { HashTableValue::DOMJITFunctionType, jsTextEncoderPrototypeFunction_encodeInto, &DOMJITSignatureForJSTextEncoderEncodeIntoWithoutTypeCheck } }, { "encode"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsTextEncoderPrototypeFunction_encode, 1 } }, { "encodeInto"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, jsTextEncoderPrototypeFunction_encodeInto, 2 } }, }; -// JSC_DEFINE_JIT_OPERATION(jsTextEncoderEncodeWithoutTypeCheck, JSC::EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, JSTextEncoder* castedThis, DOMJIT::IDLJSArgumentType input)) -// { -// auto& vm = JSC::getVM(lexicalGlobalObject); -// IGNORE_WARNINGS_BEGIN("frame-address") -// CallFrame* callFrame = DECLARE_CALL_FRAME(vm); -// IGNORE_WARNINGS_END -// JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); -// auto throwScope = DECLARE_THROW_SCOPE(vm); -// JSC::EncodedJSValue res; -// String str; -// if (input->is8Bit()) { -// if (input->isRope()) { -// GCDeferralContext gcDeferralContext(vm); -// auto encodedValue = TextEncoder__encodeRopeString(lexicalGlobalObject, input); -// if (!JSC::JSValue::decode(encodedValue).isUndefined()) { -// RELEASE_AND_RETURN(throwScope, { encodedValue }); -// } -// } - -// str = input->value(lexicalGlobalObject); -// res = TextEncoder__encode8(lexicalGlobalObject, str.span8().data(), str.length()); -// } else { -// str = input->value(lexicalGlobalObject); -// res = TextEncoder__encode16(lexicalGlobalObject, str.span16().data(), str.length()); -// } - -// if (JSC::JSValue::decode(res).isObject() && JSC::JSValue::decode(res).getObject()->isErrorInstance()) [[unlikely]] { -// throwScope.throwException(lexicalGlobalObject, JSC::JSValue::decode(res)); -// return { encodedJSValue() }; -// } - -// RELEASE_AND_RETURN(throwScope, { res }); -// } - -// JSC_DEFINE_JIT_OPERATION(jsTextEncoderPrototypeFunction_encodeIntoWithoutTypeCheck, JSC::EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, JSTextEncoder* castedThis, DOMJIT::IDLJSArgumentType sourceStr, DOMJIT::IDLJSArgumentType destination)) -// { -// auto& vm = JSC::getVM(lexicalGlobalObject); -// IGNORE_WARNINGS_BEGIN("frame-address") -// CallFrame* callFrame = DECLARE_CALL_FRAME(vm); -// IGNORE_WARNINGS_END -// JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); -// String source = sourceStr->value(lexicalGlobalObject); -// size_t res = 0; -// if (!source.is8Bit()) { -// res = TextEncoder__encodeInto16(source.span16().data(), source.length(), destination->vector(), destination->byteLength()); -// } else { -// res = TextEncoder__encodeInto8(source.span8().data(), source.length(), destination->vector(), destination->byteLength()); -// } - -// Bun::GlobalScope* globalScope = reinterpret_cast(lexicalGlobalObject); -// auto* result = JSC::constructEmptyObject(vm, globalScope->encodeIntoObjectStructure()); -// result->putDirectOffset(vm, 0, JSC::jsNumber(static_cast(res))); -// result->putDirectOffset(vm, 1, JSC::jsNumber(static_cast(res >> 32))); - -// return { JSValue::encode(result) }; -// } - const ClassInfo JSTextEncoderPrototype::s_info = { "TextEncoder"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTextEncoderPrototype) }; void JSTextEncoderPrototype::finishCreation(VM& vm) diff --git a/src/jsc/bindings/webcore/JSURLSearchParams.cpp b/src/jsc/bindings/webcore/JSURLSearchParams.cpp index 283be1fcab04..99aa77f0fab6 100644 --- a/src/jsc/bindings/webcore/JSURLSearchParams.cpp +++ b/src/jsc/bindings/webcore/JSURLSearchParams.cpp @@ -648,38 +648,8 @@ void JSURLSearchParamsOwner::finalize(JSC::Handle handle, void* co uncacheWrapper(world, &jsURLSearchParams->wrapped(), jsURLSearchParams); } -// #if ENABLE(BINDING_INTEGRITY) -// #if PLATFORM(WIN) -// #pragma warning(disable : 4483) -// extern "C" { -// extern void (*const __identifier("??_7URLSearchParams@WebCore@@6B@")[])(); -// } -// #else -// extern "C" { -// extern void* _ZTVN7WebCore15URLSearchParamsE[]; -// } -// #endif -// #endif - JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject* globalObject, Ref&& impl) { - - // if constexpr (std::is_polymorphic_v) { - // #if ENABLE(BINDING_INTEGRITY) - // // const void* actualVTablePointer = getVTablePointer(impl.ptr()); - // #if PLATFORM(WIN) - // void* expectedVTablePointer = __identifier("??_7URLSearchParams@WebCore@@6B@"); - // #else - // // void* expectedVTablePointer = &_ZTVN7WebCore15URLSearchParamsE[2]; - // #endif - - // // If you hit this assertion you either have a use after free bug, or - // // URLSearchParams has subclasses. If URLSearchParams has subclasses that get passed - // // to toJS() we currently require URLSearchParams you to opt out of binding hardening - // // by adding the SkipVTableValidation attribute to the interface IDL definition - // // RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); - // #endif - // } return createWrapper(globalObject, WTF::move(impl)); } diff --git a/src/jsc/bindings/webcore/JSWindowProxy.h b/src/jsc/bindings/webcore/JSWindowProxy.h deleted file mode 100644 index 22bde8d06703..000000000000 --- a/src/jsc/bindings/webcore/JSWindowProxy.h +++ /dev/null @@ -1 +0,0 @@ -// stub diff --git a/src/jsc/bindings/webcore/JSWorkerOptions.cpp b/src/jsc/bindings/webcore/JSWorkerOptions.cpp index 06c798962976..0a26de4c355f 100644 --- a/src/jsc/bindings/webcore/JSWorkerOptions.cpp +++ b/src/jsc/bindings/webcore/JSWorkerOptions.cpp @@ -41,18 +41,6 @@ template<> WorkerOptions convertDictionary(JSGlobalObject& lexica return {}; } WorkerOptions result; - // JSValue credentialsValue; - // if (isNullOrUndefined) - // credentialsValue = jsUndefined(); - // else { - // credentialsValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "credentials"_s)); - // RETURN_IF_EXCEPTION(throwScope, {}); - // } - // if (!credentialsValue.isUndefined()) { - // result.credentials = convert>(lexicalGlobalObject, credentialsValue); - // RETURN_IF_EXCEPTION(throwScope, {}); - // } else - // result.credentials = FetchRequestCredentials::SameOrigin; JSValue nameValue; if (isNullOrUndefined) nameValue = jsUndefined(); @@ -65,18 +53,6 @@ template<> WorkerOptions convertDictionary(JSGlobalObject& lexica RETURN_IF_EXCEPTION(throwScope, {}); } else result.name = emptyString(); - // JSValue typeValue; - // if (isNullOrUndefined) - // typeValue = jsUndefined(); - // else { - // typeValue = object->get(&lexicalGlobalObject, vm.propertyNames->type); - // RETURN_IF_EXCEPTION(throwScope, { }); - // } - // if (!typeValue.isUndefined()) { - // result.type = convert>(lexicalGlobalObject, typeValue); - // RETURN_IF_EXCEPTION(throwScope, { }); - // } else - // result.type = WorkerType::Classic; return result; } diff --git a/src/jsc/bindings/webcore/Node.h b/src/jsc/bindings/webcore/Node.h deleted file mode 100644 index 5c8aed686dde..000000000000 --- a/src/jsc/bindings/webcore/Node.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 1999 Lars Knoll (knoll@kde.org) - * (C) 1999 Antti Koivisto (koivisto@kde.org) - * (C) 2001 Dirk Mueller (mueller@kde.org) - * Copyright (C) 2004-2020 Apple Inc. All rights reserved. - * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#pragma once - -#include "root.h" - -#include "EventTarget.h" -#include "ExceptionOr.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "EventTargetConcrete.h" - -namespace WebCore { - -// The full Node type is way too much stuff -// this ones just a baby -class Node : public RefPtr, CanMakeWeakPtr, public EventTarget { - WTF_MAKE_TZONE_ALLOCATED(Node); - - static constexpr uint32_t s_refCountIncrement = 2; - static constexpr uint32_t s_refCountMask = ~static_cast(1); - -public: - void defaultEventHandler(Event&) - { - // do nothing - } - - void handleEvent(ScriptExecutionContext&, Event&) - { - } - - bool hasEventTargetData() - { - return true; - } - - void ref() const; - void deref() const; - bool hasOneRef() const; - unsigned refCount() const; - - void removedLastRef() {} - - mutable uint32_t m_refCountAndParentBit { s_refCountIncrement }; - // mutable OptionSet m_nodeFlags; -}; - -ALWAYS_INLINE void Node::ref() const -{ - - m_refCountAndParentBit += s_refCountIncrement; -} - -ALWAYS_INLINE void Node::deref() const -{ - - auto updatedRefCount = m_refCountAndParentBit - s_refCountIncrement; - if (!updatedRefCount) { - // Don't update m_refCountAndParentBit to avoid double destruction through use of Ref/RefPtr. - // (This is a security mitigation in case of programmer error. It will ASSERT in debug builds.) - - const_cast(*this).removedLastRef(); - return; - } - m_refCountAndParentBit = updatedRefCount; -} - -ALWAYS_INLINE bool Node::hasOneRef() const -{ - - return refCount() == 1; -} - -ALWAYS_INLINE unsigned Node::refCount() const -{ - return m_refCountAndParentBit / s_refCountIncrement; -} - -} diff --git a/src/jsc/bindings/webcore/PerformanceUserTiming.cpp b/src/jsc/bindings/webcore/PerformanceUserTiming.cpp index 90939c5d24af..9505ef73101c 100644 --- a/src/jsc/bindings/webcore/PerformanceUserTiming.cpp +++ b/src/jsc/bindings/webcore/PerformanceUserTiming.cpp @@ -149,25 +149,6 @@ ExceptionOr PerformanceUserTiming::convertMarkToTimestamp(const std::var ExceptionOr PerformanceUserTiming::convertMarkToTimestamp(const String& mark) const { - // if (!isMainThread()) { - // if (restrictedMarkFunctions.contains(mark)) - // return Exception { TypeError }; - // } else { - // if (auto function = restrictedMarkFunctions.tryGet(mark)) { - // if (*function == &PerformanceTiming::navigationStart) - // return 0.0; - - // // PerformanceTiming should always be non-null for the Document ScriptExecutionContext. - // ASSERT(m_performance.timing()); - // auto timing = m_performance.timing(); - // auto startTime = timing->navigationStart(); - // auto endTime = ((*timing).*(*function))(); - // if (!endTime) - // return Exception { InvalidAccessError }; - // return endTime - startTime; - // } - // } - auto iterator = m_marksMap.find(mark); if (iterator != m_marksMap.end()) return iterator->value.last()->startTime(); diff --git a/src/runtime/server/RequestContext.rs b/src/runtime/server/RequestContext.rs index 845980f5cb61..47cd4388b0d7 100644 --- a/src/runtime/server/RequestContext.rs +++ b/src/runtime/server/RequestContext.rs @@ -3121,7 +3121,6 @@ where this.run_error_handler(js_err); return; } - // .InlineBlob, Body::Value::WTFStringImpl(_) | Body::Value::InternalBlob(_) | Body::Value::Blob(_) => { // toBlobIfPossible checks for WTFString needing a conversion. this.blob = value.use_as_any_blob_allow_non_utf8_string(); diff --git a/src/runtime/webcore/Blob.rs b/src/runtime/webcore/Blob.rs index 8fe5edb2375a..766209cc0917 100644 --- a/src/runtime/webcore/Blob.rs +++ b/src/runtime/webcore/Blob.rs @@ -6852,55 +6852,6 @@ impl Internal { } } -// ────────────────────────────────────────────────────────────────────────── -// Inline (InlineBlob) -// ────────────────────────────────────────────────────────────────────────── - -/// A blob which stores all the data in the same space as a real Blob -/// This is an optimization for small Response and Request bodies -#[repr(C, packed)] -pub struct Inline { - pub(crate) bytes: [u8; Inline::AVAILABLE_BYTES], - pub(crate) len: u8, - pub(crate) was_string: bool, -} - -impl Inline { - const REAL_BLOB_SIZE: usize = core::mem::size_of::(); - // Inherent assoc types are nightly-only; - // the int-size alias is hoisted to module-level `InlineIntSize` above. - pub(crate) const AVAILABLE_BYTES: usize = - Self::REAL_BLOB_SIZE - core::mem::size_of::() - 1 - 1; - - pub fn concat(first: &[u8], second: &[u8]) -> Inline { - let total = first.len() + second.len(); - debug_assert!(total <= Self::AVAILABLE_BYTES); - - let mut inline_blob = Inline::default(); - let bytes_slice = &mut inline_blob.bytes[..total]; - - if !first.is_empty() { - bytes_slice[..first.len()].copy_from_slice(first); - } - if !second.is_empty() { - bytes_slice[first.len()..][..second.len()].copy_from_slice(second); - } - - inline_blob.len = total as u8; - inline_blob - } -} - -impl Default for Inline { - fn default() -> Self { - Self { - bytes: [0; Self::AVAILABLE_BYTES], - len: 0, - was_string: false, - } - } -} - // ────────────────────────────────────────────────────────────────────────── // JSDOMFile__hasInstance / FileOpener / FileCloser // ────────────────────────────────────────────────────────────────────────── diff --git a/src/runtime/webcore/Body.rs b/src/runtime/webcore/Body.rs index 201e73b7c338..0b06bb05ab56 100644 --- a/src/runtime/webcore/Body.rs +++ b/src/runtime/webcore/Body.rs @@ -509,8 +509,6 @@ pub enum Value { /// Single-use Blob /// Avoids a heap allocation. InternalBlob(InternalBlob), - /// Single-use Blob that stores the bytes in the Value itself. - // InlineBlob(InlineBlob), Locked(PendingValue), Used, Empty, @@ -544,7 +542,6 @@ pub enum Tag { Blob, WTFStringImpl, InternalBlob, - // InlineBlob, Locked, Used, Empty, @@ -714,7 +711,6 @@ impl Value { AnyBlob::Blob(b) => Value::Blob(b), AnyBlob::InternalBlob(b) => Value::InternalBlob(b), AnyBlob::WTFStringImpl(s) => Value::WTFStringImpl(s), - // AnyBlob::InlineBlob(b) => Value::InlineBlob(b), }; } } @@ -725,7 +721,6 @@ impl Value { Value::InternalBlob(b) => b.slice_const().len() as blob::SizeType, Value::WTFStringImpl(s) => wtf_impl(s).utf8_byte_length() as blob::SizeType, Value::Locked(l) => l.size_hint(), - // Value::InlineBlob(b) => b.slice_const().len() as blob::SizeType, _ => 0, } } @@ -738,7 +733,6 @@ impl Value { // ByteStream buffer, separately accounted), so reporting the // content-length here mis-trains JSC's GC live-size estimate. Value::Locked(_) => 0, - // Value::InlineBlob(b) => b.slice_const().len(), _ => 0, } } @@ -749,7 +743,6 @@ impl Value { Value::WTFStringImpl(s) => wtf_impl(s).byte_slice().len(), // See memory_cost(): size_hint is anticipated, not allocated. Value::Locked(_) => 0, - // Value::InlineBlob(b) => b.slice_const().len(), _ => 0, } } @@ -1097,7 +1090,7 @@ impl Value { // These ones must use promise.wrap() to handle exceptions thrown while calling .toJS() on the value. // These exceptions can happen if the String is too long, ArrayBuffer is too large, JSON parse error, etc. Action::GetText => match new { - Value::WTFStringImpl(_) | Value::InternalBlob(_) /* | Value::InlineBlob(_) */ => { + Value::WTFStringImpl(_) | Value::InternalBlob(_) => { let mut blob = new.use_as_any_blob_allow_non_utf8_string(); let result = promise.wrap(global, |g| blob.to_string_transfer(g)); blob.detach(); @@ -1223,17 +1216,6 @@ impl Value { wtf_ref.deref(); new_blob } - // Value::InlineBlob(_) => { - // let cloned = self.InlineBlob.bytes; - // // keep same behavior as InternalBlob but clone the data - // let new_blob = Blob::create( - // &cloned[0..self.InlineBlob.len], - // VirtualMachine::get().global, - // false, - // ); - // *self = Value::Used; - // new_blob - // } // `Blob::default()` leaves `global_this` null which matches the // don't-care contract here. _ => Blob::default(), @@ -1292,7 +1274,6 @@ impl Value { break 'brk AnyBlob::WTFStringImpl(str); } } - // Value::InlineBlob(b) => AnyBlob::InlineBlob(b), Value::Locked(l) => l .to_any_blob_allow_promise() .unwrap_or(AnyBlob::Blob(Blob::default())), @@ -1315,7 +1296,6 @@ impl Value { let _ = core::mem::ManuallyDrop::new(core::mem::replace(self, Value::Used)); AnyBlob::WTFStringImpl(s) } - // Value::InlineBlob(b) => AnyBlob::InlineBlob(b), Value::Locked(l) => l .to_any_blob_allow_promise() .unwrap_or(AnyBlob::Blob(Blob::default())), @@ -2316,7 +2296,6 @@ impl<'a> ValueBufferer<'a> { (self.on_finished_buffering)(self.ctx, b"", Some(err_copy), false); return Ok(()); } - // Value::InlineBlob(_) | Value::WTFStringImpl(_) | Value::InternalBlob(_) | Value::Blob(_) => { // toBlobIfPossible checks for WTFString needing a conversion. let mut input = value.use_as_any_blob_allow_non_utf8_string(); diff --git a/src/runtime/webcore/FileReader.rs b/src/runtime/webcore/FileReader.rs index 0b884c2cd046..dd67f4686080 100644 --- a/src/runtime/webcore/FileReader.rs +++ b/src/runtime/webcore/FileReader.rs @@ -101,7 +101,6 @@ impl Default for FileReader { } pub type IOReader = BufferedReader; -pub const TAG: readable_stream::Tag = readable_stream::Tag::File; #[derive(strum::IntoStaticStr)] pub enum ReadDuringJSOnPullResult { diff --git a/src/runtime/webcore/S3File.rs b/src/runtime/webcore/S3File.rs index e1b904f8fbca..47d1a6c6bf3a 100644 --- a/src/runtime/webcore/S3File.rs +++ b/src/runtime/webcore/S3File.rs @@ -884,32 +884,15 @@ fn construct(global: &JSGlobalObject, callframe: &CallFrame) -> *mut Blob { } } -fn has_instance(_: JSValue, _global: &JSGlobalObject, value: JSValue) -> bool { - bun_jsc::mark_binding(); - let Some(blob) = value.as_class_ref::() else { - return false; - }; - blob.is_s3() -} - // Symbols exported with C linkage and JSC calling convention. // JSS3File__presign -> raw shim wrapping get_presign_url (method-with-context) // JSS3File__construct -> construct -// JSS3File__hasInstance -> has_instance // JSS3File__bucket -> get_bucket // JSS3File__stat -> raw shim wrapping get_stat (method-with-context) pub(crate) mod exports { use super::*; - /// `customHasInstance` hook (JSC calling convention, `(EncodedJSValue, - /// *JSGlobalObject, EncodedJSValue) -> bool`). - #[unsafe(no_mangle)] - #[bun_jsc::host_call] - fn JSS3File__hasInstance(this: JSValue, global: &JSGlobalObject, value: JSValue) -> bool { - super::has_instance(this, global, value) - } - /// Bare ctor, not routed through `toJSHostFn` (returns a nullable /// `*mut Blob`, not `JSValue`). #[unsafe(no_mangle)] diff --git a/src/runtime/webcore/streams.rs b/src/runtime/webcore/streams.rs index a26a8e0305a0..c862ce377382 100644 --- a/src/runtime/webcore/streams.rs +++ b/src/runtime/webcore/streams.rs @@ -2604,10 +2604,6 @@ impl BufferAction { self.promise.value() } - pub fn get(&self) -> *mut JSPromise { - std::ptr::from_mut(self.promise.get()) - } - pub(crate) fn swap(&mut self) -> *mut JSPromise { std::ptr::from_mut(self.promise.swap()) } diff --git a/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts b/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts new file mode 100644 index 000000000000..9468d52dddcb --- /dev/null +++ b/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts @@ -0,0 +1,81 @@ +// Guards against reintroduction of symbols removed as dead code. Each symbol +// was verified to have zero callers across src/ and build/debug/codegen/ +// before deletion; `bun bd` and `rust:check-all` (all targets) pass without +// them. Only checks files that are modified (not deleted) so readFileSync +// never sees ENOENT. + +import { expect, test } from "bun:test"; +import { existsSync, readFileSync } from "node:fs"; +import path from "node:path"; + +const repoRoot = path.resolve(import.meta.dir, "..", "..", ".."); +const src = (p: string) => readFileSync(path.join(repoRoot, p), "utf8"); +const exists = (p: string) => existsSync(path.join(repoRoot, p)); + +test("deleted webcore/bindings header files do not reappear", () => { + const deleted = [ + "src/jsc/bindings/TextCodecASCIIFastPath.h", + "src/jsc/bindings/webcore/Node.h", + "src/jsc/bindings/webcore/JSDOMWindow.h", + "src/jsc/bindings/webcore/JSServiceWorker.h", + "src/jsc/bindings/webcore/JSWindowProxy.h", + ]; + const found = deleted.filter(exists); + expect(found).toEqual([]); +}); + +test("dead extern C wrappers and cascaded methods do not reappear", () => { + const checks: Array<[string, RegExp]> = [ + ["src/jsc/bindings/StrongRef.cpp", /Bun__StrongRef__get|Bun__StrongRef__clear/], + ["src/jsc/bindings/StrongRef.h", /Bun__StrongRef__get|Bun__StrongRef__clear/], + ["src/jsc/bindings/StrongRootBlock.h", /void clearValue\(/], + ["src/jsc/bindings/TextCodecWrapper.cpp", /Bun__isEncodingSupported|Bun__getCanonicalEncodingName/], + ["src/jsc/bindings/InspectorLifecycleAgent.cpp", /Bun__LifecycleAgentReportReload|::reportReload\b/], + ["src/jsc/bindings/InspectorLifecycleAgent.h", /void reportReload\(/], + ["src/jsc/bindings/InspectorBunFrontendDevServerAgent.cpp", /notifyClientErrorReported|notifyGraphUpdate/], + ["src/jsc/bindings/InspectorBunFrontendDevServerAgent.h", /clientErrorReported|graphUpdate|BunFrontendDevServerAgent__notify/], + ["src/jsc/bindings/highway_strings.cpp", /ScanCharFrequencyImpl|highway_char_frequency/], + ["src/jsc/bindings/JSS3File.cpp", /JSS3File__hasInstance|customHasInstance/], + ]; + const found = checks.filter(([f, re]) => re.test(src(f))).map(([f, re]) => `${f}: ${re.source}`); + expect(found).toEqual([]); +}); + +test("commented-out DOMJIT/BINDING_INTEGRITY blocks in webcore do not reappear", () => { + const checks: Array<[string, RegExp]> = [ + ["src/jsc/bindings/webcore/JSTextEncoder.cpp", /jsTextEncoderEncodeWithoutTypeCheck|DOMJITSignatureForJSTextEncoder/], + ["src/jsc/bindings/webcore/JSURLSearchParams.cpp", /BINDING_INTEGRITY|_ZTVN7WebCore15URLSearchParamsE/], + ["src/jsc/bindings/webcore/JSErrorEvent.cpp", /BINDING_INTEGRITY|_ZTVN7WebCore10ErrorEventE/], + ["src/jsc/bindings/webcore/JSDOMException.cpp", /BINDING_INTEGRITY|_ZTVN7WebCore12DOMExceptionE/], + ["src/jsc/bindings/webcore/JSPerformance.cpp", /hasDisabledRuntimeProperties/], + ["src/jsc/bindings/webcore/JSDOMURL.cpp", /\/\/.*createObjectURL.*DeletePropertyMode/s], + ["src/jsc/bindings/webcore/JSWorkerOptions.cpp", /credentialsValue|\bWorkerType::Classic\b/], + ["src/jsc/bindings/webcore/JSEventListener.cpp", /handleBeforeUnloadEventReturnValue/], + ["src/jsc/bindings/webcore/PerformanceUserTiming.cpp", /restrictedMarkFunctions\.tryGet/], + ]; + const found = checks.filter(([f, re]) => re.test(src(f))).map(([f, re]) => `${f}: ${re.source}`); + expect(found).toEqual([]); +}); + +test("dead InlineBlob struct and S3File hasInstance do not reappear", () => { + const checks: Array<[string, RegExp]> = [ + ["src/runtime/webcore/Blob.rs", /pub struct Inline \{|impl Inline \{/], + ["src/runtime/webcore/Body.rs", /InlineBlob/], + ["src/runtime/server/RequestContext.rs", /\.InlineBlob,/], + ["src/runtime/webcore/S3File.rs", /JSS3File__hasInstance|fn has_instance\b/], + ["src/runtime/webcore/streams.rs", /pub fn get\(&self\) -> \*mut JSPromise/], + ["src/runtime/webcore/FileReader.rs", /pub const TAG: readable_stream::Tag/], + ]; + const found = checks.filter(([f, re]) => re.test(src(f))).map(([f, re]) => `${f}: ${re.source}`); + expect(found).toEqual([]); +}); + +test("commented-out handleConversion/fs-stream blocks in src/js do not reappear", () => { + const checks: Array<[string, RegExp]> = [ + ["src/js/builtins/Ipc.ts", /const handleConversion = \{/], + ["src/js/internal/fs/streams.ts", /\/\/.*fastPath\._getFd\(\)/], + ["src/js/node/worker_threads.ts", /^\/\/ import type/m], + ]; + const found = checks.filter(([f, re]) => re.test(src(f))).map(([f, re]) => `${f}: ${re.source}`); + expect(found).toEqual([]); +}); From 7d92edf57b81a3eac7c1bf7a4d04de034340775a Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Sun, 2 Aug 2026 16:15:46 +0000 Subject: [PATCH 02/11] [autofix.ci] apply automated fixes --- .../dead-symbols-webcore-inline-extern.test.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts b/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts index 9468d52dddcb..1bef4f7b5561 100644 --- a/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts +++ b/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts @@ -33,7 +33,10 @@ test("dead extern C wrappers and cascaded methods do not reappear", () => { ["src/jsc/bindings/InspectorLifecycleAgent.cpp", /Bun__LifecycleAgentReportReload|::reportReload\b/], ["src/jsc/bindings/InspectorLifecycleAgent.h", /void reportReload\(/], ["src/jsc/bindings/InspectorBunFrontendDevServerAgent.cpp", /notifyClientErrorReported|notifyGraphUpdate/], - ["src/jsc/bindings/InspectorBunFrontendDevServerAgent.h", /clientErrorReported|graphUpdate|BunFrontendDevServerAgent__notify/], + [ + "src/jsc/bindings/InspectorBunFrontendDevServerAgent.h", + /clientErrorReported|graphUpdate|BunFrontendDevServerAgent__notify/, + ], ["src/jsc/bindings/highway_strings.cpp", /ScanCharFrequencyImpl|highway_char_frequency/], ["src/jsc/bindings/JSS3File.cpp", /JSS3File__hasInstance|customHasInstance/], ]; @@ -43,7 +46,10 @@ test("dead extern C wrappers and cascaded methods do not reappear", () => { test("commented-out DOMJIT/BINDING_INTEGRITY blocks in webcore do not reappear", () => { const checks: Array<[string, RegExp]> = [ - ["src/jsc/bindings/webcore/JSTextEncoder.cpp", /jsTextEncoderEncodeWithoutTypeCheck|DOMJITSignatureForJSTextEncoder/], + [ + "src/jsc/bindings/webcore/JSTextEncoder.cpp", + /jsTextEncoderEncodeWithoutTypeCheck|DOMJITSignatureForJSTextEncoder/, + ], ["src/jsc/bindings/webcore/JSURLSearchParams.cpp", /BINDING_INTEGRITY|_ZTVN7WebCore15URLSearchParamsE/], ["src/jsc/bindings/webcore/JSErrorEvent.cpp", /BINDING_INTEGRITY|_ZTVN7WebCore10ErrorEventE/], ["src/jsc/bindings/webcore/JSDOMException.cpp", /BINDING_INTEGRITY|_ZTVN7WebCore12DOMExceptionE/], From 65c85f121b621b3bf075850c8aaea6090cebd61c Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Sun, 2 Aug 2026 16:21:29 +0000 Subject: [PATCH 03/11] source-lints: tighten JSDOMURL dead-symbol regex Replace the /s-flagged multi-line pattern with a single-token anchor (JSDedicatedWorkerGlobalScope) that appeared only in the removed block, so an unrelated // comment elsewhere in the file can never match. --- .../source-lints/dead-symbols-webcore-inline-extern.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts b/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts index 1bef4f7b5561..38dedba51b7d 100644 --- a/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts +++ b/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts @@ -54,7 +54,7 @@ test("commented-out DOMJIT/BINDING_INTEGRITY blocks in webcore do not reappear", ["src/jsc/bindings/webcore/JSErrorEvent.cpp", /BINDING_INTEGRITY|_ZTVN7WebCore10ErrorEventE/], ["src/jsc/bindings/webcore/JSDOMException.cpp", /BINDING_INTEGRITY|_ZTVN7WebCore12DOMExceptionE/], ["src/jsc/bindings/webcore/JSPerformance.cpp", /hasDisabledRuntimeProperties/], - ["src/jsc/bindings/webcore/JSDOMURL.cpp", /\/\/.*createObjectURL.*DeletePropertyMode/s], + ["src/jsc/bindings/webcore/JSDOMURL.cpp", /JSDedicatedWorkerGlobalScope/], ["src/jsc/bindings/webcore/JSWorkerOptions.cpp", /credentialsValue|\bWorkerType::Classic\b/], ["src/jsc/bindings/webcore/JSEventListener.cpp", /handleBeforeUnloadEventReturnValue/], ["src/jsc/bindings/webcore/PerformanceUserTiming.cpp", /restrictedMarkFunctions\.tryGet/], From 44717d9b53ccdb672bcdbf4f6c4a5c796833569d Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Sun, 2 Aug 2026 16:31:07 +0000 Subject: [PATCH 04/11] source-lints: guard #include sites instead of worktree existence The verification harness's stash-based src/ revert does not reliably re-delete whole files (same limitation noted on the MessagePortChannel*.h stubs), so asserting worktree absence with existsSync fails the with-fix run. Check the #include lines in surviving files instead, which the harness applies as ordinary content edits. --- ...dead-symbols-webcore-inline-extern.test.ts | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts b/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts index 38dedba51b7d..8a8311de1231 100644 --- a/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts +++ b/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts @@ -5,22 +5,26 @@ // never sees ENOENT. import { expect, test } from "bun:test"; -import { existsSync, readFileSync } from "node:fs"; +import { readFileSync } from "node:fs"; import path from "node:path"; const repoRoot = path.resolve(import.meta.dir, "..", "..", ".."); const src = (p: string) => readFileSync(path.join(repoRoot, p), "utf8"); -const exists = (p: string) => existsSync(path.join(repoRoot, p)); -test("deleted webcore/bindings header files do not reappear", () => { - const deleted = [ - "src/jsc/bindings/TextCodecASCIIFastPath.h", - "src/jsc/bindings/webcore/Node.h", - "src/jsc/bindings/webcore/JSDOMWindow.h", - "src/jsc/bindings/webcore/JSServiceWorker.h", - "src/jsc/bindings/webcore/JSWindowProxy.h", +// The headers Node.h / JSDOMWindow.h / JSServiceWorker.h / JSWindowProxy.h / +// TextCodecASCIIFastPath.h were deleted. The verification harness's stash +// round-trip does not reliably re-delete whole files (see the comment on the +// MessagePortChannel*.h stubs), so guard the #include sites in surviving files +// instead of asserting worktree absence. +test("#includes of deleted webcore/bindings headers do not reappear", () => { + const checks: Array<[string, RegExp]> = [ + ["src/jsc/bindings/WebCoreOpaqueRoot.h", /#include "Node\.h"/], + ["src/jsc/bindings/webcore/EventTargetHeaders.h", /#include "Node\.h"/], + ["src/jsc/bindings/webcore/JSMessageEventCustom.cpp", /#include "JSDOMWindow\.h"/], + ["src/jsc/bindings/webcore/JSMessageEvent.cpp", /#include "JSServiceWorker\.h"|#include "JSWindowProxy\.h"/], + ["src/jsc/bindings/webcore/JSEventTargetCustom.cpp", /JSDOMWindow\.h|JSWindowProxy\.h/], ]; - const found = deleted.filter(exists); + const found = checks.filter(([f, re]) => re.test(src(f))).map(([f, re]) => `${f}: ${re.source}`); expect(found).toEqual([]); }); From 4b9495de88efc6df695dfecf0bb5f3fcf7b224ad Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Sun, 2 Aug 2026 16:39:58 +0000 Subject: [PATCH 05/11] Complete dead-code cascades in PerformanceUserTiming, StrongRootBlock, JSTextEncoder PerformanceUserTiming: the restrictedMarkFunctions map, NavigationTimingFunction typedef, and isRestrictedMarkName() had zero callers (the only consumer was the commented-out convertMarkToTimestamp block already removed). Drops the now-unused PerformanceTiming.h and SortedArrayMap.h includes with them. StrongRootBlock: read(unsigned) was only called from Bun__StrongRef__get (removed earlier); same cascade as clearValue(). JSTextEncoder: the DOMJIT*/DFGAbstractHeap includes and using-directive existed only for the commented-out JSC_DEFINE_JIT_OPERATION bodies. --- src/jsc/bindings/StrongRootBlock.h | 6 --- src/jsc/bindings/webcore/JSTextEncoder.cpp | 10 ----- .../webcore/PerformanceUserTiming.cpp | 37 ------------------- .../bindings/webcore/PerformanceUserTiming.h | 2 - ...dead-symbols-webcore-inline-extern.test.ts | 6 ++- 5 files changed, 4 insertions(+), 57 deletions(-) diff --git a/src/jsc/bindings/StrongRootBlock.h b/src/jsc/bindings/StrongRootBlock.h index c14db345fcec..33e91b7f269f 100644 --- a/src/jsc/bindings/StrongRootBlock.h +++ b/src/jsc/bindings/StrongRootBlock.h @@ -65,12 +65,6 @@ class StrongRootBlock final : public JSC::JSCell { m_slots[index].set(vm, this, value); } - JSC::JSValue read(unsigned index) const - { - ASSERT(index < capacity); - return m_slots[index].get(); - } - bool clear(unsigned index) { ASSERT(index < capacity); diff --git a/src/jsc/bindings/webcore/JSTextEncoder.cpp b/src/jsc/bindings/webcore/JSTextEncoder.cpp index 3056cf0f2c0e..a82a257a86c9 100644 --- a/src/jsc/bindings/webcore/JSTextEncoder.cpp +++ b/src/jsc/bindings/webcore/JSTextEncoder.cpp @@ -52,20 +52,10 @@ #include "JSDOMGlobalObjectInlines.h" #include "JSDOMOperation.h" #include "JSDOMWrapperCache.h" -// #include "ScriptExecutionContext.h" -// #include "WebCoreJSClientData.h" - -#include -#include "DOMJITIDLConvert.h" -#include "DOMJITIDLType.h" -#include "DOMJITIDLTypeFilter.h" -#include "DOMJITHelpers.h" -#include #include "BunClientData.h" namespace WebCore { using namespace JSC; -using namespace JSC::DOMJIT; extern "C" JSC::EncodedJSValue TextEncoder__encode8(JSC::JSGlobalObject* global, const Latin1Character* stringPtr, size_t stringLen); extern "C" JSC::EncodedJSValue TextEncoder__encode16(JSC::JSGlobalObject* global, const char16_t* stringPtr, size_t stringLen); diff --git a/src/jsc/bindings/webcore/PerformanceUserTiming.cpp b/src/jsc/bindings/webcore/PerformanceUserTiming.cpp index 9505ef73101c..3bca2b85001f 100644 --- a/src/jsc/bindings/webcore/PerformanceUserTiming.cpp +++ b/src/jsc/bindings/webcore/PerformanceUserTiming.cpp @@ -27,51 +27,14 @@ #include "config.h" #include "PerformanceUserTiming.h" -// #include "Document.h" -// #include "FrameDestructionObserverInlines.h" -// #include "InspectorInstrumetation.h" #include "MessagePort.h" #include "PerformanceMarkOptions.h" #include "PerformanceMeasureOptions.h" -#include "PerformanceTiming.h" #include "SerializedScriptValue.h" -// #include "WorkerOrWorkletGlobalScope.h" #include -#include namespace WebCore { -using NavigationTimingFunction = unsigned long long (PerformanceTiming::*)() const; - -static constexpr SortedArrayMap restrictedMarkFunctions { std::to_array>({ - { "connectEnd"_s, &PerformanceTiming::connectEnd }, - { "connectStart"_s, &PerformanceTiming::connectStart }, - { "domComplete"_s, &PerformanceTiming::domComplete }, - { "domContentLoadedEventEnd"_s, &PerformanceTiming::domContentLoadedEventEnd }, - { "domContentLoadedEventStart"_s, &PerformanceTiming::domContentLoadedEventStart }, - { "domInteractive"_s, &PerformanceTiming::domInteractive }, - { "domLoading"_s, &PerformanceTiming::domLoading }, - { "domainLookupEnd"_s, &PerformanceTiming::domainLookupEnd }, - { "domainLookupStart"_s, &PerformanceTiming::domainLookupStart }, - { "fetchStart"_s, &PerformanceTiming::fetchStart }, - { "loadEventEnd"_s, &PerformanceTiming::loadEventEnd }, - { "loadEventStart"_s, &PerformanceTiming::loadEventStart }, - { "navigationStart"_s, &PerformanceTiming::navigationStart }, - { "redirectEnd"_s, &PerformanceTiming::redirectEnd }, - { "redirectStart"_s, &PerformanceTiming::redirectStart }, - { "requestStart"_s, &PerformanceTiming::requestStart }, - { "responseEnd"_s, &PerformanceTiming::responseEnd }, - { "responseStart"_s, &PerformanceTiming::responseStart }, - { "secureConnectionStart"_s, &PerformanceTiming::secureConnectionStart }, - { "unloadEventEnd"_s, &PerformanceTiming::unloadEventEnd }, - { "unloadEventStart"_s, &PerformanceTiming::unloadEventStart }, -}) }; - -bool PerformanceUserTiming::isRestrictedMarkName(const String& markName) -{ - return restrictedMarkFunctions.contains(markName); -} - PerformanceUserTiming::PerformanceUserTiming(Performance& performance) : m_performance(performance) { diff --git a/src/jsc/bindings/webcore/PerformanceUserTiming.h b/src/jsc/bindings/webcore/PerformanceUserTiming.h index 4973c1f05d31..f99913bc52c1 100644 --- a/src/jsc/bindings/webcore/PerformanceUserTiming.h +++ b/src/jsc/bindings/webcore/PerformanceUserTiming.h @@ -60,8 +60,6 @@ class PerformanceUserTiming { Vector> getMarks(const String& name) const; Vector> getMeasures(const String& name) const; - static bool isRestrictedMarkName(const String& markName); - size_t memoryCost() const; private: diff --git a/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts b/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts index 8a8311de1231..8ac5d4c497a4 100644 --- a/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts +++ b/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts @@ -32,7 +32,7 @@ test("dead extern C wrappers and cascaded methods do not reappear", () => { const checks: Array<[string, RegExp]> = [ ["src/jsc/bindings/StrongRef.cpp", /Bun__StrongRef__get|Bun__StrongRef__clear/], ["src/jsc/bindings/StrongRef.h", /Bun__StrongRef__get|Bun__StrongRef__clear/], - ["src/jsc/bindings/StrongRootBlock.h", /void clearValue\(/], + ["src/jsc/bindings/StrongRootBlock.h", /void clearValue\(|JSValue read\(unsigned/], ["src/jsc/bindings/TextCodecWrapper.cpp", /Bun__isEncodingSupported|Bun__getCanonicalEncodingName/], ["src/jsc/bindings/InspectorLifecycleAgent.cpp", /Bun__LifecycleAgentReportReload|::reportReload\b/], ["src/jsc/bindings/InspectorLifecycleAgent.h", /void reportReload\(/], @@ -61,7 +61,9 @@ test("commented-out DOMJIT/BINDING_INTEGRITY blocks in webcore do not reappear", ["src/jsc/bindings/webcore/JSDOMURL.cpp", /JSDedicatedWorkerGlobalScope/], ["src/jsc/bindings/webcore/JSWorkerOptions.cpp", /credentialsValue|\bWorkerType::Classic\b/], ["src/jsc/bindings/webcore/JSEventListener.cpp", /handleBeforeUnloadEventReturnValue/], - ["src/jsc/bindings/webcore/PerformanceUserTiming.cpp", /restrictedMarkFunctions\.tryGet/], + ["src/jsc/bindings/webcore/PerformanceUserTiming.cpp", /restrictedMarkFunctions|isRestrictedMarkName|NavigationTimingFunction/], + ["src/jsc/bindings/webcore/PerformanceUserTiming.h", /isRestrictedMarkName/], + ["src/jsc/bindings/webcore/JSTextEncoder.cpp", /DOMJITIDL|DOMJITHelpers|DFGAbstractHeap|namespace JSC::DOMJIT/], ]; const found = checks.filter(([f, re]) => re.test(src(f))).map(([f, re]) => `${f}: ${re.source}`); expect(found).toEqual([]); From ed63b16d648c51fc2d4a44815493f8d837335822 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Sun, 2 Aug 2026 16:42:15 +0000 Subject: [PATCH 06/11] [autofix.ci] apply automated fixes --- .../source-lints/dead-symbols-webcore-inline-extern.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts b/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts index 8ac5d4c497a4..eb55b722af44 100644 --- a/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts +++ b/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts @@ -61,7 +61,10 @@ test("commented-out DOMJIT/BINDING_INTEGRITY blocks in webcore do not reappear", ["src/jsc/bindings/webcore/JSDOMURL.cpp", /JSDedicatedWorkerGlobalScope/], ["src/jsc/bindings/webcore/JSWorkerOptions.cpp", /credentialsValue|\bWorkerType::Classic\b/], ["src/jsc/bindings/webcore/JSEventListener.cpp", /handleBeforeUnloadEventReturnValue/], - ["src/jsc/bindings/webcore/PerformanceUserTiming.cpp", /restrictedMarkFunctions|isRestrictedMarkName|NavigationTimingFunction/], + [ + "src/jsc/bindings/webcore/PerformanceUserTiming.cpp", + /restrictedMarkFunctions|isRestrictedMarkName|NavigationTimingFunction/, + ], ["src/jsc/bindings/webcore/PerformanceUserTiming.h", /isRestrictedMarkName/], ["src/jsc/bindings/webcore/JSTextEncoder.cpp", /DOMJITIDL|DOMJITHelpers|DFGAbstractHeap|namespace JSC::DOMJIT/], ]; From e8b189ff430fc2c39c0171e41bbdcbe6ea2c79e1 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Sun, 2 Aug 2026 16:47:55 +0000 Subject: [PATCH 07/11] source-lints: match quoted header name in JSEventTargetCustom guard Narrow the pattern to the quoted include form so a prose comment mentioning the header name cannot false-positive. The removed lines in this file were commented-out includes, so the quoted form still catches both live and commented #include directives. --- .../source-lints/dead-symbols-webcore-inline-extern.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts b/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts index eb55b722af44..bcfd3c4c7b86 100644 --- a/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts +++ b/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts @@ -22,7 +22,7 @@ test("#includes of deleted webcore/bindings headers do not reappear", () => { ["src/jsc/bindings/webcore/EventTargetHeaders.h", /#include "Node\.h"/], ["src/jsc/bindings/webcore/JSMessageEventCustom.cpp", /#include "JSDOMWindow\.h"/], ["src/jsc/bindings/webcore/JSMessageEvent.cpp", /#include "JSServiceWorker\.h"|#include "JSWindowProxy\.h"/], - ["src/jsc/bindings/webcore/JSEventTargetCustom.cpp", /JSDOMWindow\.h|JSWindowProxy\.h/], + ["src/jsc/bindings/webcore/JSEventTargetCustom.cpp", /"JSDOMWindow\.h"|"JSWindowProxy\.h"/], ]; const found = checks.filter(([f, re]) => re.test(src(f))).map(([f, re]) => `${f}: ${re.source}`); expect(found).toEqual([]); From a9daf04d0f9ec9afb89540d123abfda39297ccea Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Sun, 2 Aug 2026 17:11:26 +0000 Subject: [PATCH 08/11] Complete remaining same-class cascades from review JSS3File: BUN__createJSS3File has zero callers (born dead in #36588; only BUN__createJSS3FileUnsafely is wired to Rust). Remove it, constructS3File, the JSS3File__construct extern decl, and the Rust construct/construct_internal chain plus its now-unused PathLikeExt import. InspectorBunFrontendDevServerAgent.cpp: drop orphaned m_globalobject initializer comment and redundant UNUSED_PARAM (parameter is used). RequestContext.rs: drop stale TODO referencing the deleted InlineBlob type. Remove commented-out #include "JSDOMWindow.h" from the 5 remaining sibling files (DOMWrapperWorld, JSDOMWrapper, JSErrorHandler, JSDOMPromise, JSDOMPromiseDeferred). source-lints: add \b anchor so BunFrontendDevServerAgent__notify doesn't match the live InspectorBunFrontendDevServerAgent__notify* wrappers; broaden RequestContext/S3File guards to cover the new deletions. --- src/jsc/bindings/DOMWrapperWorld.cpp | 2 -- .../InspectorBunFrontendDevServerAgent.cpp | 2 -- src/jsc/bindings/JSDOMWrapper.cpp | 7 ---- src/jsc/bindings/JSS3File.cpp | 17 --------- src/jsc/bindings/JSS3File.h | 2 -- src/jsc/bindings/webcore/JSDOMPromise.cpp | 2 -- .../bindings/webcore/JSDOMPromiseDeferred.cpp | 4 --- src/jsc/bindings/webcore/JSErrorHandler.cpp | 3 -- src/runtime/server/RequestContext.rs | 2 -- src/runtime/webcore/S3File.rs | 35 ------------------- ...dead-symbols-webcore-inline-extern.test.ts | 11 +++--- 11 files changed, 6 insertions(+), 81 deletions(-) diff --git a/src/jsc/bindings/DOMWrapperWorld.cpp b/src/jsc/bindings/DOMWrapperWorld.cpp index 765c6b7f641f..7de46ddf9d78 100644 --- a/src/jsc/bindings/DOMWrapperWorld.cpp +++ b/src/jsc/bindings/DOMWrapperWorld.cpp @@ -22,9 +22,7 @@ #include "DOMWrapperWorld.h" -// #include "JSDOMWindow.h" #include "WebCoreJSClientData.h" -// #include "WindowProxy.h" #include "ZigGlobalObject.h" #include diff --git a/src/jsc/bindings/InspectorBunFrontendDevServerAgent.cpp b/src/jsc/bindings/InspectorBunFrontendDevServerAgent.cpp index a5ccb7aa8cd4..6b00f9ca088b 100644 --- a/src/jsc/bindings/InspectorBunFrontendDevServerAgent.cpp +++ b/src/jsc/bindings/InspectorBunFrontendDevServerAgent.cpp @@ -21,12 +21,10 @@ WTF_MAKE_TZONE_ALLOCATED_IMPL(InspectorBunFrontendDevServerAgent); InspectorBunFrontendDevServerAgent::InspectorBunFrontendDevServerAgent(JSC::JSGlobalObject& globalObject) : InspectorAgentBase("BunFrontendDevServer"_s) - // , m_globalobject(globalObject) , m_backendDispatcher(BunFrontendDevServerBackendDispatcher::create(globalObject.inspectorController().backendDispatcher(), this)) , m_frontendDispatcher(makeUnique(const_cast(globalObject.inspectorController().frontendRouter()))) , m_enabled(false) { - UNUSED_PARAM(globalObject); } InspectorBunFrontendDevServerAgent::~InspectorBunFrontendDevServerAgent() = default; diff --git a/src/jsc/bindings/JSDOMWrapper.cpp b/src/jsc/bindings/JSDOMWrapper.cpp index 2530679c7ac2..110c44ee963d 100644 --- a/src/jsc/bindings/JSDOMWrapper.cpp +++ b/src/jsc/bindings/JSDOMWrapper.cpp @@ -28,13 +28,6 @@ #include "BunBuiltinNames.h" -// #include "DOMWindow.h" -// #include "DOMWrapperWorld.h" -// #include "JSDOMWindow.h" -// #include "JSRemoteDOMWindow.h" -// #include "SerializedScriptValue.h" -// #include - namespace WebCore { STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(JSDOMObject); diff --git a/src/jsc/bindings/JSS3File.cpp b/src/jsc/bindings/JSS3File.cpp index e0f70dc40626..b9c2be8c22a6 100644 --- a/src/jsc/bindings/JSS3File.cpp +++ b/src/jsc/bindings/JSS3File.cpp @@ -22,7 +22,6 @@ using namespace WebCore; // External C functions declarations extern "C" { -SYSV_ABI void* JSS3File__construct(JSC::JSGlobalObject*, JSC::CallFrame* callframe); SYSV_ABI EncodedJSValue JSS3File__presign(void* ptr, JSC::JSGlobalObject*, JSC::CallFrame* callframe); SYSV_ABI EncodedJSValue JSS3File__stat(void* ptr, JSC::JSGlobalObject*, JSC::CallFrame* callframe); SYSV_ABI EncodedJSValue JSS3File__bucket(void* ptr, JSC::JSGlobalObject*); @@ -128,17 +127,6 @@ JSValue constructS3FileInternal(JSC::JSGlobalObject* lexicalGlobalObject, void* return JSS3File::create(vm, globalObject, structure, ptr); } -JSValue constructS3File(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callframe) -{ - auto& vm = JSC::getVM(globalObject); - auto scope = DECLARE_THROW_SCOPE(vm); - void* ptr = JSS3File__construct(globalObject, callframe); - RETURN_IF_EXCEPTION(scope, {}); - ASSERT(ptr); - - return constructS3FileInternal(globalObject, ptr); -} - JSC::Structure* JSS3File::createStructure(JSC::JSGlobalObject* globalObject) { auto& vm = JSC::getVM(globalObject); @@ -183,11 +171,6 @@ const JSC::ClassInfo JSS3FilePrototype::s_info = { "S3File"_s, &Base::s_info, nu const JSC::ClassInfo JSS3File::s_info = { "S3File"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSS3File) }; extern "C" { -SYSV_ABI EncodedJSValue BUN__createJSS3File(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callframe) -{ - return JSValue::encode(constructS3File(globalObject, callframe)); -}; - SYSV_ABI EncodedJSValue BUN__createJSS3FileUnsafely(JSC::JSGlobalObject* globalObject, void* ptr) { return JSValue::encode(constructS3FileInternal(globalObject, ptr)); diff --git a/src/jsc/bindings/JSS3File.h b/src/jsc/bindings/JSS3File.h index 8ba8c2839d8b..9ee69917de4d 100644 --- a/src/jsc/bindings/JSS3File.h +++ b/src/jsc/bindings/JSS3File.h @@ -34,8 +34,6 @@ class JSS3File : public WebCore::JSBlob { static JSC::Structure* createStructure(JSC::JSGlobalObject* globalObject); }; -// Constructor helper -JSValue constructS3File(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callframe); Structure* createJSS3FileStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject); } // namespace Bun diff --git a/src/jsc/bindings/webcore/JSDOMPromise.cpp b/src/jsc/bindings/webcore/JSDOMPromise.cpp index 8e9d17bbc12b..9d091eb0e37a 100644 --- a/src/jsc/bindings/webcore/JSDOMPromise.cpp +++ b/src/jsc/bindings/webcore/JSDOMPromise.cpp @@ -26,8 +26,6 @@ #include "config.h" #include "JSDOMPromise.h" -// #include "DOMWindow.h" -// #include "JSDOMWindow.h" #include #include #include diff --git a/src/jsc/bindings/webcore/JSDOMPromiseDeferred.cpp b/src/jsc/bindings/webcore/JSDOMPromiseDeferred.cpp index a220c05fd81c..7844e7e0c968 100644 --- a/src/jsc/bindings/webcore/JSDOMPromiseDeferred.cpp +++ b/src/jsc/bindings/webcore/JSDOMPromiseDeferred.cpp @@ -27,12 +27,8 @@ #include "JSDOMPromiseDeferred.h" // #include "DOMWindow.h" -// #include "EventLoop.h" #include "JSDOMExceptionHandling.h" #include "JSDOMPromise.h" -// #include "JSDOMWindow.h" -// #include "ScriptController.h" -// #include "WorkerGlobalScope.h" #include #include #include diff --git a/src/jsc/bindings/webcore/JSErrorHandler.cpp b/src/jsc/bindings/webcore/JSErrorHandler.cpp index f3cd0e9e01fb..5c79d2ac7366 100644 --- a/src/jsc/bindings/webcore/JSErrorHandler.cpp +++ b/src/jsc/bindings/webcore/JSErrorHandler.cpp @@ -37,10 +37,7 @@ #include "Event.h" #include "JSDOMConvertNumbers.h" #include "JSDOMConvertStrings.h" -// #include "JSDOMWindow.h" #include "JSEvent.h" -// #include "JSExecState.h" -// #include "JSExecStateInstrumentation.h" #include #include diff --git a/src/runtime/server/RequestContext.rs b/src/runtime/server/RequestContext.rs index 47cd4388b0d7..6eb3e3281ba7 100644 --- a/src/runtime/server/RequestContext.rs +++ b/src/runtime/server/RequestContext.rs @@ -4149,8 +4149,6 @@ where let total = bytes.len() + chunk.len(); 'getter: { - // TODO: small-body fast path via InlineBlob is not - // implemented; always build an InternalBlob. // Vec aborts on OOM (repo-wide abort-on-OOM policy). bytes.reserve_exact(total.saturating_sub(bytes.len())); bytes.extend_from_slice(chunk); diff --git a/src/runtime/webcore/S3File.rs b/src/runtime/webcore/S3File.rs index 47d1a6c6bf3a..dacd4b33fd1b 100644 --- a/src/runtime/webcore/S3File.rs +++ b/src/runtime/webcore/S3File.rs @@ -1,4 +1,3 @@ -use crate::node::types::PathLikeExt as _; use crate::node::{PathLike, PathOrBlob}; use crate::webcore::blob::store::{S3Ext as _, StoreExt as _, StoreRef}; use crate::webcore::blob::{self, Blob, BlobExt}; @@ -859,48 +858,14 @@ pub(crate) fn to_js_unchecked(global: &JSGlobalObject, this: *mut Blob) -> JSVal BUN__createJSS3FileUnsafely(global, this.cast::()) } -fn construct_internal(global: &JSGlobalObject, callframe: &CallFrame) -> JsResult<*mut Blob> { - // SAFETY: bun_vm() returns the live VM raw ptr. - let vm = global.bun_vm(); - let mut args = bun_jsc::call_frame::ArgumentsSlice::init(vm, callframe.arguments()); - - let Some(path) = PathLike::from_js(global, &mut args)? else { - return Err(global.throw_invalid_arguments(format_args!("Expected file path string"))); - }; - construct_s3_file_internal(global, path, args.next_eat()) -} - -// Hand-written ABI shim: returns `*mut Blob` (codegen constructor contract), -// which `#[bun_jsc::host_fn]` does not model; the exported symbol name is wired below. -fn construct(global: &JSGlobalObject, callframe: &CallFrame) -> *mut Blob { - match construct_internal(global, callframe) { - Ok(b) => b, - Err(JsError::Thrown) => core::ptr::null_mut(), - Err(JsError::OutOfMemory) => { - let _ = global.throw_out_of_memory_value(); - core::ptr::null_mut() - } - Err(JsError::Terminated) => core::ptr::null_mut(), - } -} - // Symbols exported with C linkage and JSC calling convention. // JSS3File__presign -> raw shim wrapping get_presign_url (method-with-context) -// JSS3File__construct -> construct // JSS3File__bucket -> get_bucket // JSS3File__stat -> raw shim wrapping get_stat (method-with-context) pub(crate) mod exports { use super::*; - /// Bare ctor, not routed through `toJSHostFn` (returns a nullable - /// `*mut Blob`, not `JSValue`). - #[unsafe(no_mangle)] - #[bun_jsc::host_call] - fn JSS3File__construct(global: &JSGlobalObject, callframe: &CallFrame) -> *mut Blob { - super::construct(global, callframe) - } - /// Getter (JSC calling convention; takes `*Blob, *JSGlobalObject`, /// returns JSValue). #[unsafe(no_mangle)] diff --git a/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts b/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts index bcfd3c4c7b86..ccfbe89dd3ff 100644 --- a/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts +++ b/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts @@ -36,13 +36,14 @@ test("dead extern C wrappers and cascaded methods do not reappear", () => { ["src/jsc/bindings/TextCodecWrapper.cpp", /Bun__isEncodingSupported|Bun__getCanonicalEncodingName/], ["src/jsc/bindings/InspectorLifecycleAgent.cpp", /Bun__LifecycleAgentReportReload|::reportReload\b/], ["src/jsc/bindings/InspectorLifecycleAgent.h", /void reportReload\(/], - ["src/jsc/bindings/InspectorBunFrontendDevServerAgent.cpp", /notifyClientErrorReported|notifyGraphUpdate/], + ["src/jsc/bindings/InspectorBunFrontendDevServerAgent.cpp", /notifyClientErrorReported|notifyGraphUpdate|m_globalobject/], [ "src/jsc/bindings/InspectorBunFrontendDevServerAgent.h", - /clientErrorReported|graphUpdate|BunFrontendDevServerAgent__notify/, + /clientErrorReported|graphUpdate|\bBunFrontendDevServerAgent__notify/, ], ["src/jsc/bindings/highway_strings.cpp", /ScanCharFrequencyImpl|highway_char_frequency/], - ["src/jsc/bindings/JSS3File.cpp", /JSS3File__hasInstance|customHasInstance/], + ["src/jsc/bindings/JSS3File.cpp", /JSS3File__hasInstance|customHasInstance|BUN__createJSS3File\b|\bconstructS3File\b/], + ["src/jsc/bindings/JSS3File.h", /\bconstructS3File\b/], ]; const found = checks.filter(([f, re]) => re.test(src(f))).map(([f, re]) => `${f}: ${re.source}`); expect(found).toEqual([]); @@ -76,8 +77,8 @@ test("dead InlineBlob struct and S3File hasInstance do not reappear", () => { const checks: Array<[string, RegExp]> = [ ["src/runtime/webcore/Blob.rs", /pub struct Inline \{|impl Inline \{/], ["src/runtime/webcore/Body.rs", /InlineBlob/], - ["src/runtime/server/RequestContext.rs", /\.InlineBlob,/], - ["src/runtime/webcore/S3File.rs", /JSS3File__hasInstance|fn has_instance\b/], + ["src/runtime/server/RequestContext.rs", /InlineBlob/], + ["src/runtime/webcore/S3File.rs", /JSS3File__hasInstance|fn has_instance\b|JSS3File__construct|fn construct_internal\b/], ["src/runtime/webcore/streams.rs", /pub fn get\(&self\) -> \*mut JSPromise/], ["src/runtime/webcore/FileReader.rs", /pub const TAG: readable_stream::Tag/], ]; From 831f86735adccccea595e074f277027bbd2408fe Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Sun, 2 Aug 2026 17:13:44 +0000 Subject: [PATCH 09/11] [autofix.ci] apply automated fixes --- .../dead-symbols-webcore-inline-extern.test.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts b/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts index ccfbe89dd3ff..8c35c27a5079 100644 --- a/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts +++ b/test/internal/source-lints/dead-symbols-webcore-inline-extern.test.ts @@ -36,13 +36,19 @@ test("dead extern C wrappers and cascaded methods do not reappear", () => { ["src/jsc/bindings/TextCodecWrapper.cpp", /Bun__isEncodingSupported|Bun__getCanonicalEncodingName/], ["src/jsc/bindings/InspectorLifecycleAgent.cpp", /Bun__LifecycleAgentReportReload|::reportReload\b/], ["src/jsc/bindings/InspectorLifecycleAgent.h", /void reportReload\(/], - ["src/jsc/bindings/InspectorBunFrontendDevServerAgent.cpp", /notifyClientErrorReported|notifyGraphUpdate|m_globalobject/], + [ + "src/jsc/bindings/InspectorBunFrontendDevServerAgent.cpp", + /notifyClientErrorReported|notifyGraphUpdate|m_globalobject/, + ], [ "src/jsc/bindings/InspectorBunFrontendDevServerAgent.h", /clientErrorReported|graphUpdate|\bBunFrontendDevServerAgent__notify/, ], ["src/jsc/bindings/highway_strings.cpp", /ScanCharFrequencyImpl|highway_char_frequency/], - ["src/jsc/bindings/JSS3File.cpp", /JSS3File__hasInstance|customHasInstance|BUN__createJSS3File\b|\bconstructS3File\b/], + [ + "src/jsc/bindings/JSS3File.cpp", + /JSS3File__hasInstance|customHasInstance|BUN__createJSS3File\b|\bconstructS3File\b/, + ], ["src/jsc/bindings/JSS3File.h", /\bconstructS3File\b/], ]; const found = checks.filter(([f, re]) => re.test(src(f))).map(([f, re]) => `${f}: ${re.source}`); @@ -78,7 +84,10 @@ test("dead InlineBlob struct and S3File hasInstance do not reappear", () => { ["src/runtime/webcore/Blob.rs", /pub struct Inline \{|impl Inline \{/], ["src/runtime/webcore/Body.rs", /InlineBlob/], ["src/runtime/server/RequestContext.rs", /InlineBlob/], - ["src/runtime/webcore/S3File.rs", /JSS3File__hasInstance|fn has_instance\b|JSS3File__construct|fn construct_internal\b/], + [ + "src/runtime/webcore/S3File.rs", + /JSS3File__hasInstance|fn has_instance\b|JSS3File__construct|fn construct_internal\b/, + ], ["src/runtime/webcore/streams.rs", /pub fn get\(&self\) -> \*mut JSPromise/], ["src/runtime/webcore/FileReader.rs", /pub const TAG: readable_stream::Tag/], ]; From c441847a7de577ada8f5da7fd1923f0cbc2a9910 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Sun, 2 Aug 2026 17:31:58 +0000 Subject: [PATCH 10/11] ci: retrigger From e434f18b3c9d5e4d5d51b2b322cabc7b7148ff22 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Sun, 2 Aug 2026 17:35:27 +0000 Subject: [PATCH 11/11] Remove orphaned commented-out includes paired with removed bodies JSWorkerOptions.cpp: JSFetchRequestCredentials.h / JSWorkerType.h (paired with the removed credentials/type parsing blocks). JSEventListener.cpp: BeforeUnloadEvent.h and adjacent commented-out includes (paired with the removed handleBeforeUnloadEventReturnValue helper). --- src/jsc/bindings/webcore/JSEventListener.cpp | 4 ---- src/jsc/bindings/webcore/JSWorkerOptions.cpp | 2 -- 2 files changed, 6 deletions(-) diff --git a/src/jsc/bindings/webcore/JSEventListener.cpp b/src/jsc/bindings/webcore/JSEventListener.cpp index 095ae5257e35..14f9964887c9 100644 --- a/src/jsc/bindings/webcore/JSEventListener.cpp +++ b/src/jsc/bindings/webcore/JSEventListener.cpp @@ -21,11 +21,7 @@ #include "JSEventListener.h" #include "BunProcess.h" -// #include "BeforeUnloadEvent.h" -// #include "ContentSecurityPolicy.h" #include "EventNames.h" -// #include "Frame.h" -// #include "HTMLElement.h" #include "JSDOMConvertNullable.h" #include "JSDOMConvertStrings.h" #include "JSDOMGlobalObject.h" diff --git a/src/jsc/bindings/webcore/JSWorkerOptions.cpp b/src/jsc/bindings/webcore/JSWorkerOptions.cpp index 0a26de4c355f..8a8dd0ccf6de 100644 --- a/src/jsc/bindings/webcore/JSWorkerOptions.cpp +++ b/src/jsc/bindings/webcore/JSWorkerOptions.cpp @@ -23,8 +23,6 @@ #include "JSDOMConvertEnumeration.h" #include "JSDOMConvertStrings.h" -// #include "JSFetchRequestCredentials.h" -// #include "JSWorkerType.h" #include namespace WebCore {