fix(perf_hooks): globalThis.performance === the named import (#1327)#1443
Merged
Conversation
…on) (#1327) Node guarantees globalThis.performance === require('perf_hooks').performance. Perry resolved the named import to a fresh perf_hooks namespace per read and the global was a separate (empty) path, so identity never held and globalThis.performance.now was undefined. Add a per-thread cached performance namespace singleton (perf_hooks.rs, GC-rooted via scan_perf_entries_roots_mut). The node:perf_hooks named import returns it; populate_global_this_builtins binds globalThis.performance to the same object; codegen routes globalThis.performance reads through the global field (is_global_this_builtin_name) while keeping typeof === "object". Flips node-suite/perf_hooks/global/performance-identity to PASS.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Node guarantees
globalThis.performance === require('perf_hooks').performance(node:perf_hooks gap #1327, umbrella #793). In Perry the named import resolved to a fresh perf_hooks namespace per read, andglobalThis.performancewas a separate (unpopulated) path — so identity never held andglobalThis.performance.nowwasundefined.Fix introduces a single source of truth:
perf_hooks.rs): a per-thread cachedperformancenamespace singleton (performance_namespace()), GC-rooted inscan_perf_entries_roots_mutso identity survives evacuation.native_module.rs):perf_hooks.performancereturns the singleton (constantsstays a fresh namespace).global_this.rs):populate_global_this_builtinsbindsglobalThis.performanceto the same singleton.helpers.rs):performancejoinsis_global_this_builtin_namesoglobalThis.performancevalue-reads route to the global field, and the function-name exclusion keepstypeof === "object".Test
Flips
test-parity/node-suite/perf_hooks/global/performance-identityto PASS:Regression sweep (all clean / pre-existing-only): perf_hooks node-suite (56 pass),
globalfilter (3 pass),test_gapcross-section (36 pass; the 1 fail is the pre-existing trackedtest_gap_class_advancedstatic-block gap). Every parity test prints via the globalconsole, exercising global init.Closes #1327.