vm: lazily initialize primordials for vm contexts#31738
Closed
joyeecheung wants to merge 2 commits intonodejs:masterfrom
Closed
vm: lazily initialize primordials for vm contexts#31738joyeecheung wants to merge 2 commits intonodejs:masterfrom
joyeecheung wants to merge 2 commits intonodejs:masterfrom
Conversation
Lazily initialize primordials when cross-context support for builtins is needed to fix the performance regression in context creation.
joyeecheung
commented
Feb 11, 2020
| return InitializePrimordials(context); | ||
| } | ||
|
|
||
| bool InitializePrimordials(Local<Context> context) { |
Member
Author
There was a problem hiding this comment.
This block contains only indentation change
Collaborator
joyeecheung
commented
Feb 11, 2020
src/api/environment.cc
Outdated
| Local<Object> exports = Object::New(isolate); | ||
| if (context->Global()->SetPrivate(context, key, exports).IsNothing()) | ||
| return MaybeLocal<Object>(); | ||
| InitializePrimordials(context); |
Member
Author
There was a problem hiding this comment.
This is only hit for vm contexts and main contexts created without snapshot support so there's no additional cost for the main context built with snapshot support
Member
Author
devsnek
approved these changes
Feb 11, 2020
joyeecheung
commented
Feb 11, 2020
| Local<Object> exports = Object::New(isolate); | ||
| if (context->Global()->SetPrivate(context, key, exports).IsNothing()) | ||
| if (context->Global()->SetPrivate(context, key, exports).IsNothing() || | ||
| !InitializePrimordials(context)) |
Member
Author
There was a problem hiding this comment.
Oops, forgot to handle the return value of InitializePrimordials in the initial commit, fixed.
addaleax
approved these changes
Feb 11, 2020
devnexen
approved these changes
Feb 12, 2020
Member
🙂 |
Collaborator
Member
Author
|
Landed in e6c2277. Thanks! |
Member
|
@joyeecheung if this should go to |
targos
pushed a commit
to targos/node
that referenced
this pull request
Apr 25, 2020
Lazily initialize primordials when cross-context support for builtins is needed to fix the performance regression in context creation. PR-URL: nodejs#31738 Fixes: nodejs#29842 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com>
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.
Lazily initialize primordials when cross-context support for
builtins is needed to fix the performance regression in context
creation.
Fixes: #29842
local benchmark results
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes