Repository navigation
Remove dead code from JSDOMWrapper.h and ncrypto.cpp: two preprocessor blocks that never compile - #48067
Remove dead code from JSDOMWrapper.h and ncrypto.cpp: two preprocessor blocks that never compile#48067robobun wants to merge 1 commit into
Conversation
JSDOMWrapper.h: the #ifndef RENAMED_JSDOM_GLOBAL_OBJECT block. The header includes ZigGlobalObject.h, which defines the macro and the alias, before the block. The block also holds the closing brace of namespace WebCore, so a translation unit where it is active does not compile. ZigGlobalObject.h keeps the alias and loses the guard that only this block made necessary. ncrypto.cpp: the EVP_PKEY_CTX_set_dsa_paramgen_q_bits fallback for OpenSSL older than 1.1.1e. BoringSSL reports 1.1.1g and declares the function.
|
Status: ready for review. This pull request has no repro. It deletes 19 lines in 3 files that the preprocessor never keeps: the Checks that were run: Self-review: not run as a separate pass. The diff is 19 deleted lines with no runtime effect. CI: build 138153 finished. All 14 Pull request: #48067 |
|
No actionable comments were generated in the recent review. WalkthroughThe changes make the ChangesJSDOM global object alias
OpenSSL compatibility fallback
Suggested reviewers: Merge Risk:
|
Problem
JSDOMWrapper.hhas an#ifndef RENAMED_JSDOM_GLOBAL_OBJECTblock that no translation unit can compile. The header first includesZigGlobalObject.h, which defines the macro and the same alias. The block also holds the closing brace ofnamespace WebCore: when it is active, clang stops withextraneous closing brace ('}').ncrypto.cppdefinesEVP_PKEY_CTX_set_dsa_paramgen_q_bitsfor OpenSSL older than 1.1.1e. BoringSSL reports 1.1.1g and declares that function.Fix
ZigGlobalObject.hloses the 3 guard lines around its alias: no other file names the macro.ncrypto.cppand of 40 units that readJSDOMWrapper.h(654 MB) differs only in the__LINE__of assertions.bun bd, then 457 tests in 6 files (node-crypto,web-globals,globals,abort,message-channel,broadcast-channel).Behaviour change: none
Background
JSDOMGlobalObjectis the WebCore name for the global object. In Bun it is an alias ofZig::GlobalObject. The macro is a guard from 2022 that let either header declare the alias first.ncryptois the OpenSSL wrapper ofnode:crypto. Bun links BoringSSL on every platform.bun_libuv_sysandbun_uws_sys. Remove libuv on Windows #47776 deletes that code, so they stay out.Downsides
mainin 1,612 files.Notes
Evidence
JSDOMWrapper.h, probe: the header with the block as the preprocessor leaves it when the macro is not defined, compiled with the flags ofBunProcess.cpp. Clang reports 6 errors:'NodeConstants' is not a class, namespace, or enumeration(2),unknown type name 'JSDOMGlobalObject'(2), one mismatch ofScriptExecutionContext *types, andextraneous closing brace ('}').clang -E: 1,140 hand-written sources, each one alone, and 157 generated ones. None has an active line inJSDOMWrapper.h:33-37or inncrypto.cpp:25-34.JSDOMWrapper.h. The 40 compared ones are spread over them (every 13th). With the integers masked on the lines that name one of the three files, the text before and after is byte-identical. Without the mask,Undici.cppdiffers in one line:WTFReportAssertionFailure(".../JSDOMWrapper.h", 64, ...)becomes59.git grep RENAMED_JSDOM_GLOBAL_OBJECTonmainfinds the two headers only.git blamedates both blocks to March 2022.vendor/boringssl/include/openssl/base.hdefinesOPENSSL_VERSION_NUMBER 0x1010107f, andevp.hdeclaresEVP_PKEY_CTX_set_dsa_paramgen_q_bits. The fallback tests< 0x1010105fL.clang-formatreports nothing.bun test test/internal/source-lints/: 194 pass. The threetest-crypto-keygen*dsa*tests of the Node suite skip themselves with BoringSSL, as before.Open pull requests
ncrypto.cpp: 124 in all.git merge-tree) of the 124:mainand with this branch.mainalready and gain no conflicted file.JSDOMWrapper.h, because it renamesZig::GlobalObjecton the alias line of the block.How this run looked for dead code
cargo hawk, the cross-crate analyzer thathawk.tomlis written for (upstreammain, built on the repository's nightly), onx86_64-unknown-linux-gnu,x86_64-pc-windows-msvcandaarch64-apple-darwin. Each run covers the product graph and--workspace --all-targets. An item is dead when every target that compiles it reportshawk::dead_public. Result: 842 items.bun_windows_sys) and code tables. Kept.#ifbranch with no active line in any of the 1,297 preprocessed units was listed with its condition: 2,441 branches. 1,098 depend on the platform or the build flavour, and most of the rest are in third-party sources such as the SQLite amalgamation. Outside third-party code 442 lines remain. Apart from the two blocks here, each is a branch for another build (no AOT, malloc debugging,NAPI_VERBOSE), generated code, or a line that an open pull request deletes or edits.ENABLE(),USE()andHAVE()conditions on a macro that nothing defines (4),#definenames that nothing reads (13), and commented-out code of three lines or more (55 blocks).Found dead in this run, and left alone
uv_tcp_t,uv_fs_poll_tanduv_work_tinsrc/libuv_sys/libuv.rs, with their helper types and layout assertions (96 lines), andWindowsLoop::wake(5 lines). Both Windows targets compile without them.ENABLE(MALLOC_BREAKDOWN)branches ofScriptExecutionContext(Remove dead code from the inspector protocol package, bun_jsc, bun_install, and the Windows named pipe modules #40557). Nothing defines the macro.ENABLE(BINDING_INTEGRITY)blocks (Remove dead code from the JSC, WebCore, and node bindings, uWS/uSockets, SecretsLinux, and seven Rust crates #42431, Remove dead code from the WebCore bindings and 20 Rust crates #40525, Remove dead code from libtcc1.c, four C++ preprocessor conditions, JSPropertyIterator, and hawk.toml #44126).ncrypto.cpp(Remove dead code from SerializedScriptValue, ncrypto, and the WebCore IDL converters #43644).#if OPENSSL_VERSION_MAJOR >= 3around#include <openssl/provider.h>inncrypto.cpp(3 lines). crypto: port OpenSSL's prime search for generatePrime with add #37963 adds two includes directly above it.switchinPrintGeneralName(ncrypto.cpp:742-762) never compiles. Without it,prefixis always null and theelsebranch below it is unreachable, so the cut is a rewrite of that function.E::E*aliases inwindows_errno.rs. The comment above them says why they exist.UV_ENOTSUP,UV_ENODATA,ARES_EDESTRUCTION,Tag::fchownat,LIBUS_QUEUED_INPUT_NONE.WindowsLoop::unrefandwindows_impl::umask. Each has a POSIX twin of the same name.freebsdstub module ofbun_sys.PROPERTY_BITSET_BITS,PIPE_READ_BUFFER_SIZE,MAX_CID_LEN,Kind::ABS,Kind::REL,DiagnosticClass::COUNT.bun_zstd::inflate_embeddedandinflate_embedded_nul. A macro calls them undercfg(bun_codegen_embed).EntryPointinLinkerContext.rs,jsc_abi.pub usenames that no crate imports (bun_aot::diagnostics::log_internal_error,is_colon_tokenandis_not_semicolon_tokeninbun_lint,bun_spawn::Result), andWindowsLoop::wait(the comment above it covers two aliases).wasm32branches in 15 Rust files. No build targets wasm.no test proof · iteration 0 · the description declares no behaviour change, so there is no failing test to prove; the existing suite in CI is the check