-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
src: ensure primordials are initialized exactly once #57519
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #57519 +/- ##
==========================================
- Coverage 90.22% 90.20% -0.02%
==========================================
Files 629 629
Lines 184845 184847 +2
Branches 36205 36209 +4
==========================================
- Hits 166784 166749 -35
- Misses 11016 11055 +39
+ Partials 7045 7043 -2
🚀 New features to boost your workflow:
|
Is there anyway to benchmark this? |
This CHECK https://github.com/nodejs/node/pull/57519/files#diff-5f2fc380364ef43210af4a28c08f9a0c7ec5f85e3ec1f5c1df5e0204eb9dc721R777 ensures that primordials are initialized only once for a given context. This does not run at runtime. Primordials are initialized at |
@nodejs/cpp-reviewers would you mind taking a look at this? Thank you! |
Landed in 8b2098f |
PR-URL: #57519 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Right now
InitializePrimordials
is invoked twice on a context created vianode::NewContext
:InitializeMainContextForSnapshot
invokesInitializePrimordials
.InitializePrimordials
invokesGetPerContextExports
unconditionally.GetPerContextExports
invokesInitializePrimordials
whennode:per_context_binding_exports
private was not set.InitializePrimordials
invokesGetPerContextExports
and initialize primordials for the first time.GetPerContextExports
will be invoked duringnode_mksnapshot
by initializing the principal realm so it is safe to remove invocation ofInitializePrimordials
inInitializeMainContextForSnapshot
.This patch ensures that
InitializePrimordials
is only invoked inGetPerContextExports
and checks that primordials on the private per-context exports object are not initialized before.