summaryrefslogtreecommitdiff
path: root/src/env.cc
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-09-12 15:01:50 +0200
committerAnna Henningsen <anna@addaleax.net>2018-09-17 17:20:27 +0200
commit4286dcf17f062034117043a2640b620210b61f57 (patch)
treede227e8bb7bee72778a2e7bd98f08991839bf866 /src/env.cc
parentc33e27dc3caf5a5b7954706fe6ecde1e4f82534d (diff)
downloadnode-new-4286dcf17f062034117043a2640b620210b61f57.tar.gz
src: refactor `Environment::GetCurrent()` usage
Make `Environment::GetCurrent()` return `nullptr` if the current `Context` is not a Node.js context, and for the relevant usage of this function, either: - Switch to the better `GetCurrent(args)` variant - Turn functions in to no-ops where it makes sense - Make it a `CHECK`, i.e. an API requirement, where it make sense - Leave a `TODO` comment for verifying what, if anything, is to be done PR-URL: https://github.com/nodejs/node/pull/22819 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'src/env.cc')
-rw-r--r--src/env.cc13
1 files changed, 2 insertions, 11 deletions
diff --git a/src/env.cc b/src/env.cc
index 0b0664b286..a8c2ab6327 100644
--- a/src/env.cc
+++ b/src/env.cc
@@ -491,18 +491,9 @@ void Environment::EnvPromiseHook(v8::PromiseHookType type,
v8::Local<v8::Value> parent) {
Local<v8::Context> context = promise->CreationContext();
- // Grow the embedder data if necessary to make sure we are not out of bounds
- // when reading the magic number.
- context->SetAlignedPointerInEmbedderData(
- ContextEmbedderIndex::kContextTagBoundary, nullptr);
- int* magicNumberPtr = reinterpret_cast<int*>(
- context->GetAlignedPointerFromEmbedderData(
- ContextEmbedderIndex::kContextTag));
- if (magicNumberPtr != Environment::kNodeContextTagPtr) {
- return;
- }
-
Environment* env = Environment::GetCurrent(context);
+ if (env == nullptr) return;
+
for (const PromiseHookCallback& hook : env->promise_hooks_) {
hook.cb_(type, promise, parent, hook.arg_);
}