summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-03-20 22:52:28 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2019-03-27 10:30:19 -0400
commit9d854fb60cd4a7386a23add2900fa224dcb1e2d5 (patch)
tree8ed62ab706f98641b55eb3f7871c48a62c3d004b /src
parent9f37d3c114b2c4233e58bdce8d82a06cac467738 (diff)
downloadandroid-node-v8-9d854fb60cd4a7386a23add2900fa224dcb1e2d5.tar.gz
android-node-v8-9d854fb60cd4a7386a23add2900fa224dcb1e2d5.tar.bz2
android-node-v8-9d854fb60cd4a7386a23add2900fa224dcb1e2d5.zip
src: move ShouldNotAbortOnUncaughtScope out of Environment
PR-URL: https://github.com/nodejs/node/pull/26824 Refs: https://github.com/nodejs/node/issues/26776 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/env-inl.h20
-rw-r--r--src/env.h22
-rw-r--r--src/module_wrap.cc4
-rw-r--r--src/node_contextify.cc2
4 files changed, 29 insertions, 19 deletions
diff --git a/src/env-inl.h b/src/env-inl.h
index f379660004..69c70804c8 100644
--- a/src/env-inl.h
+++ b/src/env-inl.h
@@ -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;
}
diff --git a/src/env.h b/src/env.h
index 0206330391..55018b6d40 100644
--- a/src/env.h
+++ b/src/env.h
@@ -684,6 +684,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);
diff --git a/src/module_wrap.cc b/src/module_wrap.cc
index ac5d28fb23..56149d0cc7 100644
--- a/src/module_wrap.cc
+++ b/src/module_wrap.cc
@@ -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;
diff --git a/src/node_contextify.cc b/src/node_contextify.cc
index 621fa7eb16..087727d93a 100644
--- a/src/node_contextify.cc
+++ b/src/node_contextify.cc
@@ -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(