Skip to content
Permalink
Browse files

src: move ShouldNotAbortOnUncaughtScope out of Environment

PR-URL: #26824
Refs: #26776
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information...
joyeecheung authored and targos committed Mar 20, 2019
1 parent 7e7f077 commit f50c9c6ae2836a76f0c6642005e61dd8bbdbf85f
Showing with 29 additions and 19 deletions.
  1. +14 −6 src/env-inl.h
  2. +12 −10 src/env.h
  3. +2 −2 src/module_wrap.cc
  4. +1 −1 src/node_contextify.cc
@@ -487,24 +487,32 @@ inline uint32_t Environment::get_next_function_id() {
return function_id_counter_++;
}

Environment::ShouldNotAbortOnUncaughtScope::ShouldNotAbortOnUncaughtScope(
ShouldNotAbortOnUncaughtScope::ShouldNotAbortOnUncaughtScope(
Environment* env)
: env_(env) {
env_->should_not_abort_scope_counter_++;
env_->PushShouldNotAbortOnUncaughtScope();
}

Environment::ShouldNotAbortOnUncaughtScope::~ShouldNotAbortOnUncaughtScope() {
ShouldNotAbortOnUncaughtScope::~ShouldNotAbortOnUncaughtScope() {
Close();
}

void Environment::ShouldNotAbortOnUncaughtScope::Close() {
void ShouldNotAbortOnUncaughtScope::Close() {
if (env_ != nullptr) {
env_->should_not_abort_scope_counter_--;
env_->PopShouldNotAbortOnUncaughtScope();
env_ = nullptr;
}
}

bool Environment::inside_should_not_abort_on_uncaught_scope() const {
inline void Environment::PushShouldNotAbortOnUncaughtScope() {
should_not_abort_scope_counter_++;
}

inline void Environment::PopShouldNotAbortOnUncaughtScope() {
should_not_abort_scope_counter_--;
}

inline bool Environment::inside_should_not_abort_on_uncaught_scope() const {
return should_not_abort_scope_counter_ > 0;
}

@@ -679,6 +679,16 @@ class TrackingTraceStateObserver :
Environment* env_;
};

class ShouldNotAbortOnUncaughtScope {
public:
explicit inline ShouldNotAbortOnUncaughtScope(Environment* env);
inline void Close();
inline ~ShouldNotAbortOnUncaughtScope();

private:
Environment* env_;
};

class Environment {
public:
Environment(const Environment&) = delete;
@@ -998,16 +1008,8 @@ class Environment {
// This needs to be available for the JS-land setImmediate().
void ToggleImmediateRef(bool ref);

class ShouldNotAbortOnUncaughtScope {
public:
explicit inline ShouldNotAbortOnUncaughtScope(Environment* env);
inline void Close();
inline ~ShouldNotAbortOnUncaughtScope();

private:
Environment* env_;
};

inline void PushShouldNotAbortOnUncaughtScope();
inline void PopShouldNotAbortOnUncaughtScope();
inline bool inside_should_not_abort_on_uncaught_scope() const;

static inline Environment* ForAsyncHooks(AsyncHooks* hooks);
@@ -136,7 +136,7 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
column_offset = Integer::New(isolate, 0);
}

Environment::ShouldNotAbortOnUncaughtScope no_abort_scope(env);
ShouldNotAbortOnUncaughtScope no_abort_scope(env);
TryCatchScope try_catch(env);
Local<Module> module;

@@ -280,7 +280,7 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo<Value>& args) {
CHECK(args[1]->IsBoolean());
bool break_on_sigint = args[1]->IsTrue();

Environment::ShouldNotAbortOnUncaughtScope no_abort_scope(env);
ShouldNotAbortOnUncaughtScope no_abort_scope(env);
TryCatchScope try_catch(env);

bool timed_out = false;
@@ -719,7 +719,7 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
compile_options = ScriptCompiler::kConsumeCodeCache;

TryCatchScope try_catch(env);
Environment::ShouldNotAbortOnUncaughtScope no_abort_scope(env);
ShouldNotAbortOnUncaughtScope no_abort_scope(env);
Context::Scope scope(parsing_context);

MaybeLocal<UnboundScript> v8_script = ScriptCompiler::CompileUnboundScript(

0 comments on commit f50c9c6

Please sign in to comment.
You can’t perform that action at this time.