-
Notifications
You must be signed in to change notification settings - Fork 5k
Remove dead code from C++ bindings (ErrorCode, JSX509CertificateConstructor, JSDOMWrapperCache) and bun_core #36500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Jarred-Sumner
merged 7 commits into
main
from
claude/farm/3d8a05c5/dead-code-bindings-errorcode-buncore
Jul 31, 2026
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5c32d39
Remove dead code from C++ bindings, ErrorCode, bun_core
robobun 8cb0f4a
[autofix.ci] apply automated fixes
autofix-ci[bot] 9629caf
Drop explanatory comment above the w! re-export
robobun 75589a0
Make generateHeapSnapshotV8 file-static to match generateHeapProfile
robobun a6f58e6
JSDOMWrapperCache.h: fix getDOMPrototype fwd-decl param, drop undefin…
robobun ddeb313
ci: retrigger
robobun 9dec341
Delete test/internal/source-lints/dead-symbols-errorcode-x509-buncore…
Jarred-Sumner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
test/internal/source-lints/dead-symbols-errorcode-x509-buncore.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| // Guards against reintroduction of symbols removed as dead code from the | ||
| // top-level C++ bindings and bun_core. Each entry was verified to have zero | ||
| // callers across src/ and build/debug/codegen/ before deletion; this test | ||
| // fails if any reappear. | ||
| // | ||
| // This is a source-tree lint: it reads files from src/ and does not touch the | ||
| // built binary, so it belongs in test/internal/source-lints/ per the README. | ||
|
|
||
| import { expect, test } from "bun:test"; | ||
| import { existsSync, readFileSync } from "node:fs"; | ||
| import path from "node:path"; | ||
|
|
||
| const repoRoot = path.resolve(import.meta.dir, "..", "..", ".."); | ||
|
|
||
| function src(p: string): string { | ||
| return readFileSync(path.join(repoRoot, p), "utf8"); | ||
| } | ||
|
|
||
| test("empty JSX509CertificateConstructor.{h,cpp} and BunHeapProfiler.h do not reappear", () => { | ||
| // JSX509CertificateConstructor.{h,cpp} contained only includes and an empty | ||
| // `namespace Bun { }` block; the real constructor class is defined inline in | ||
| // JSX509Certificate.cpp. BunHeapProfiler.h was only included by its own .cpp; | ||
| // generateHeapProfile is now file-static. | ||
| const deleted = [ | ||
| "src/jsc/bindings/JSX509CertificateConstructor.h", | ||
| "src/jsc/bindings/JSX509CertificateConstructor.cpp", | ||
| "src/jsc/bindings/BunHeapProfiler.h", | ||
| ]; | ||
| const resurrected = deleted.filter(p => existsSync(path.join(repoRoot, p))); | ||
| expect(resurrected).toEqual([]); | ||
| }); | ||
|
|
||
| test("dead Bun::ERR:: throw wrappers and binding declarations do not reappear", () => { | ||
| const checks: Array<[string, RegExp]> = [ | ||
| // Bun::ERR:: wrappers with zero C++ callers (the corresponding ErrorCode | ||
| // enum values remain; only these convenience throw functions are dead). | ||
| ["src/jsc/bindings/ErrorCode.h", /EncodedJSValue CRYPTO_TIMING_SAFE_EQUAL_LENGTH\(/], | ||
| ["src/jsc/bindings/ErrorCode.h", /EncodedJSValue KEY_GENERATION_JOB_FAILED\(/], | ||
| ["src/jsc/bindings/ErrorCode.h", /EncodedJSValue CLOSED_MESSAGE_PORT\(/], | ||
| ["src/jsc/bindings/ErrorCode.h", /CRYPTO_INVALID_KEYTYPE\(JSC::ThrowScope&, JSC::JSGlobalObject\*\);/], | ||
| ["src/jsc/bindings/ErrorCode.cpp", /EncodedJSValue CRYPTO_TIMING_SAFE_EQUAL_LENGTH\(/], | ||
| ["src/jsc/bindings/ErrorCode.cpp", /EncodedJSValue KEY_GENERATION_JOB_FAILED\(/], | ||
| ["src/jsc/bindings/ErrorCode.cpp", /EncodedJSValue CLOSED_MESSAGE_PORT\(/], | ||
| [ | ||
| "src/jsc/bindings/ErrorCode.cpp", | ||
| /CRYPTO_INVALID_KEYTYPE\(JSC::ThrowScope& throwScope, JSC::JSGlobalObject\* globalObject\)\n/, | ||
| ], | ||
| // Forward-declared template that was never defined or instantiated. | ||
| ["src/jsc/bindings/JSDOMWrapperCache.h", /deprecatedGetDOMStructure/], | ||
| ["src/jsc/bindings/JSDOMWrapperCache.h", /getOrCreateWrapper/], | ||
| // Static factory methods declared but never defined (would link-error if called). | ||
| ["src/jsc/bindings/ModuleLoader.h", /createWithInitialValues/], | ||
| ["src/jsc/bindings/JSNextTickQueue.h", /createWithInitialValues/], | ||
| ["src/jsc/bindings/JSMockFunction.h", /createWithInitialValues/], | ||
| // Constructor declared but never defined. | ||
| ["src/jsc/bindings/AsymmetricKeyValue.h", /AsymmetricKeyValue\(EVP_PKEY\* key, bool owned\);/], | ||
| // Free function with zero callers; ZigGlobalObject::JSBufferList() is used directly. | ||
| ["src/jsc/bindings/JSBufferList.h", /getBufferList/], | ||
| ["src/jsc/bindings/JSBufferList.cpp", /getBufferList/], | ||
| ]; | ||
| const resurrected = checks.filter(([file, re]) => re.test(src(file))).map(([file, re]) => `${file}: ${re.source}`); | ||
| expect(resurrected).toEqual([]); | ||
| }); | ||
|
|
||
| test("bun_core dead helpers do not reappear", () => { | ||
| const checks: Array<[string, RegExp]> = [ | ||
| // *const-out variant of container_of with zero callers; the *mut-out | ||
| // container_of covers every call site. | ||
| ["src/bun_core/lib.rs", /pub const unsafe fn container_of_const\b/], | ||
| ["src/ptr/lib.rs", /\bcontainer_of_const\b/], | ||
| // #[macro_export] literal! macro with zero invocations; callers use byte | ||
| // literals or w!() directly. | ||
| ["src/bun_core/string/immutable/unicode.rs", /macro_rules! literal \{/], | ||
| ["src/bun_core/string/mod.rs", /pub use crate::\{literal,/], | ||
| // From<Arc<SSLConfig>> for SharedPtr: Arc<SSLConfig> is never constructed | ||
| // outside ssl_config.rs; construction sites use SharedPtr::new or the | ||
| // tuple constructor directly. | ||
| ["src/http/ssl_config.rs", /impl From<Arc<SSLConfig>> for SharedPtr/], | ||
| ]; | ||
| const resurrected = checks.filter(([file, re]) => re.test(src(file))).map(([file, re]) => `${file}: ${re.source}`); | ||
| expect(resurrected).toEqual([]); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.