Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/node_contextify.cc')
-rw-r--r--src/node_contextify.cc31
1 files changed, 10 insertions, 21 deletions
diff --git a/src/node_contextify.cc b/src/node_contextify.cc
index bfd45a22862..59a90c88c99 100644
--- a/src/node_contextify.cc
+++ b/src/node_contextify.cc
@@ -239,37 +239,26 @@ class ContextifyContext {
static void RunInDebugContext(const FunctionCallbackInfo<Value>& args) {
- // Ensure that the debug context has an Environment assigned in case
- // a fatal error is raised. The fatal exception handler in node.cc
- // is not equipped to deal with contexts that don't have one and
- // can't easily be taught that due to a deficiency in the V8 API:
- // there is no way for the embedder to tell if the data index is
- // in use.
- struct ScopedEnvironment {
- ScopedEnvironment(Local<Context> context, Environment* env)
- : context_(context) {
- const int index = Environment::kContextEmbedderDataIndex;
- context->SetAlignedPointerInEmbedderData(index, env);
- }
- ~ScopedEnvironment() {
- const int index = Environment::kContextEmbedderDataIndex;
- context_->SetAlignedPointerInEmbedderData(index, nullptr);
- }
- Local<Context> context_;
- };
-
Local<String> script_source(args[0]->ToString(args.GetIsolate()));
if (script_source.IsEmpty())
return; // Exception pending.
Local<Context> debug_context = Debug::GetDebugContext();
+ Environment* env = Environment::GetCurrent(args);
if (debug_context.IsEmpty()) {
// Force-load the debug context.
Debug::GetMirror(args.GetIsolate()->GetCurrentContext(), args[0]);
debug_context = Debug::GetDebugContext();
CHECK(!debug_context.IsEmpty());
+ // Ensure that the debug context has an Environment assigned in case
+ // a fatal error is raised. The fatal exception handler in node.cc
+ // is not equipped to deal with contexts that don't have one and
+ // can't easily be taught that due to a deficiency in the V8 API:
+ // there is no way for the embedder to tell if the data index is
+ // in use.
+ const int index = Environment::kContextEmbedderDataIndex;
+ debug_context->SetAlignedPointerInEmbedderData(index, env);
}
- Environment* env = Environment::GetCurrent(args);
- ScopedEnvironment env_scope(debug_context, env);
+
Context::Scope context_scope(debug_context);
Local<Script> script = Script::Compile(script_source);
if (script.IsEmpty())