Remove dead code from C++ bindings, bindgen glue, ast, and orphaned scripts

Merged
RO
3mo ago
+21-2204

What does this PR do?

Reopens #37149 against current main, as requested there. It deletes dead code whose last references are already gone. Every removed symbol was verified again on current main: zero references across src/, scripts/, packages/, and freshly regenerated codegen output.

C++ (src/jsc/bindings):

  • ncrypto.cpp/h: 33 uncalled methods from the ncrypto port (bytesToKey, FIPS toggles, secure-heap helpers, X509 time/usages getters, unused AES CTR/GCM/KW factories, BIO/Bignum constructors), the 5 named Digest factories orphaned by the bytesToKey removal (only Digest::FromName has callers), and the DataPointer secure_ field plus constructor parameters that SecureAlloc was the sole producer for
  • DOMJIT IDL helper headers (DOMJITIDLTypeFilter.h, DOMJITIDLType.h, DOMJITIDLConvert.h, DOMJITHelpers.h/.cpp): zero instantiations of any template they define; include sites now pull FrameTracers.h directly where JITOperationPrologueCallFrameTracer is used
  • 13 empty stub files (MessagePortChannel*, MessagePortIdentifier.h, BroadcastChannelRegistry.h, JSDOMConvertSerializedScriptValue.h, JSDOMBuiltinConstructorBase.*) kept by an earlier cleanup only for its own verification mechanics
  • ZigGlobalObject: 19 accessors with zero callers (8 *SinkPrototype() getters, worldIsNormal, bunStdin/bunStderr/bunStdout, KeyObjectStructure, JSBufferStructure, JSCryptoKeyStructure, builtinInternalFunctions, performMicrotaskVariadicFunction, globalProxyStructure), the backing fields and initLater closures this orphaned, and jsFunctionPerformMicrotaskVariadic
  • BunString isCrossThreadShareable, NodeValidator validateArrayBufferView, JSDOMConvertBase convertResult, JSDOMConvertSequences reserveEstimated, EventNames isGamepadEventType (declaration with no definition), ExceptionDetails EnumTraits, ResourceTiming overrideInitiatorType, WebSocket hasNativeCallbacks, PerformanceObserverCallback hasCallback (never-invoked virtual pair), ScriptExecutionContext isDocument/isWorkerGlobalScope
  • io_darwin.cpp: io_darwin_close_machport (both cfg arms); unlike its siblings it has no Rust-side declaration and no caller anywhere
  • WorkerMessagingProxy.cpp gains a direct #include <JavaScriptCore/JSPromise.h>. It got the header transitively through a unified-source neighbor that this PR deletes.

Rust:

  • jsc/bindgen.rs: BindgenOptionalRepr trait, BindgenOptionalCustom, BindgenExternalShared and their impls; the bindgen codegen emitters never name them. Also the Optional::adopt helper and ExternalSharedOptional<T> (bun_core/external_shared.rs plus its two re-exports) that this orphaned.
  • ast/binding.rs: BindingInit trait and Binding::init; all construction goes through Binding::alloc or literal struct init. Two doc comments that pointed at Binding::init are updated.
  • ast/runtime.rs: write-only ImportsIteratorEntry.value field and two commented-out leftover fields
  • runtime/webcore.rs: two unused flat re-exports
  • ini/lib.rs: commented-out Zig code from the port

Scripts (invoker .github/workflows/labeled.yml.disabled was deleted in #36778, or superseded):

  • label-issue.ts, read-issue.ts, handle-crash-patterns.ts, is-outdated.ts, associate-issue-with-sentry.ts
  • nav2readme.ts (imports docs/nav, deleted in #24201; cannot run)
  • buildkite-slow-tests.js (superseded by ci:slowest and update-test-durations)
  • check-node.sh, check-node-all.sh (superseded by bun run node:test)

Differences from #37149: the port resolves one conflict in ZigGlobalObject.h (main replaced JSDOMStructureMap m_structures with the m_domStructures array; m_worldIsNormal is still dead and stays deleted), adds the WorkerMessagingProxy include, and drops the dead-symbols source-lint test per test/internal/source-lints/CLAUDE.md.

Rebase notes (ab559668d2): main moved the ZigGlobalObject lazy-property registration from per-field initLater calls into OBJECT_OFFSETOF tables. The rebase re-applies the deletions in that shape: the table entries for m_cachedGlobalProxyStructure, m_JSCryptoKey, and m_performMicrotaskVariadicFunction are removed with their fields. One deletion from #37149 is dropped: m_bunStdin/m_bunStderr/m_bunStdout are live again (BunObject.cpp reads the fields directly), so the fields and their initializers stay. Only their unused accessor methods remain deleted.

Rebase notes (72ec6e2594): parallel dead-code sweeps on main deleted neighbors of lines this PR deletes. Resolved by checking each symbol on current main: BIOPointer::NewFile and X509View::enumUsages still have zero callers, so their removal stands, next to main's removal of NewFp, ifRsa, and ifEc. The performMicrotaskVariadicFunction() accessor removal stands next to main's removal of performanceObject().

How did you verify your code works?

  • Full debug build (bun bd) on this branch at current main (6948a122ca)
  • Repo-wide greps on current main for each removed symbol, the deleted script names, and the deleted header names return only the deletion sites
  • bun bd test test/js/node/crypto/crypto.key-objects.test.ts: 95 pass, 0 fail
  • bun bd test test/js/web/workers/worker.test.ts: 4 debug-ASAN timeout failures, identical on a main debug build, release bun passes 37/37

This PR adds no test files on purpose. Every hunk deletes unreferenced code or keeps behavior identical (the ini hunk keeps the same expression and drops commented-out code, the iterator hunk drops a write-only field, the codegen hunk swaps deleted includes for FrameTracers.h). No test can distinguish the tree before and after this change, and test/internal/source-lints/CLAUDE.md forbids dead-symbol pin tests. The build is the check.