diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2020-02-11 17:49:24 +0300 |
---|---|---|
committer | Shelley Vohr <shelley.vohr@gmail.com> | 2020-02-27 20:44:36 +0300 |
commit | a86cb0e480b0a47eed5cc36366d7b90737d587f4 (patch) | |
tree | 27eb16459e24b83d85ffd6b918958888ed114dda /src/node_contextify.cc | |
parent | 94a471a42241e6c61619c3523fd8d5743223314c (diff) |
vm: lazily initialize primordials for vm contexts
Lazily initialize primordials when cross-context support for
builtins is needed to fix the performance regression in context
creation.
PR-URL: https://github.com/nodejs/node/pull/31738
Fixes: https://github.com/nodejs/node/issues/29842
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: David Carlier <devnexen@gmail.com>
Diffstat (limited to 'src/node_contextify.cc')
-rw-r--r-- | src/node_contextify.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 46a1d7c8ef0..5f289aecb34 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -185,8 +185,11 @@ MaybeLocal<Context> ContextifyContext::CreateV8Context( object_template->SetHandler(config); object_template->SetHandler(indexed_config); - - Local<Context> ctx = NewContext(env->isolate(), object_template); + Local<Context> ctx = Context::New(env->isolate(), nullptr, object_template); + if (ctx.IsEmpty()) return MaybeLocal<Context>(); + // Only partially initialize the context - the primordials are left out + // and only initialized when necessary. + InitializeContextRuntime(ctx); if (ctx.IsEmpty()) { return MaybeLocal<Context>(); |