Skip to content

Commit f50c9c6

Browse files
joyeecheungtargos
authored andcommitted
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>
1 parent 7e7f077 commit f50c9c6

File tree

4 files changed

+29
-19
lines changed

4 files changed

+29
-19
lines changed

src/env-inl.h

+14-6
Original file line numberDiff line numberDiff line change
@@ -487,24 +487,32 @@ inline uint32_t Environment::get_next_function_id() {
487487
return function_id_counter_++;
488488
}
489489

490-
Environment::ShouldNotAbortOnUncaughtScope::ShouldNotAbortOnUncaughtScope(
490+
ShouldNotAbortOnUncaughtScope::ShouldNotAbortOnUncaughtScope(
491491
Environment* env)
492492
: env_(env) {
493-
env_->should_not_abort_scope_counter_++;
493+
env_->PushShouldNotAbortOnUncaughtScope();
494494
}
495495

496-
Environment::ShouldNotAbortOnUncaughtScope::~ShouldNotAbortOnUncaughtScope() {
496+
ShouldNotAbortOnUncaughtScope::~ShouldNotAbortOnUncaughtScope() {
497497
Close();
498498
}
499499

500-
void Environment::ShouldNotAbortOnUncaughtScope::Close() {
500+
void ShouldNotAbortOnUncaughtScope::Close() {
501501
if (env_ != nullptr) {
502-
env_->should_not_abort_scope_counter_--;
502+
env_->PopShouldNotAbortOnUncaughtScope();
503503
env_ = nullptr;
504504
}
505505
}
506506

507-
bool Environment::inside_should_not_abort_on_uncaught_scope() const {
507+
inline void Environment::PushShouldNotAbortOnUncaughtScope() {
508+
should_not_abort_scope_counter_++;
509+
}
510+
511+
inline void Environment::PopShouldNotAbortOnUncaughtScope() {
512+
should_not_abort_scope_counter_--;
513+
}
514+
515+
inline bool Environment::inside_should_not_abort_on_uncaught_scope() const {
508516
return should_not_abort_scope_counter_ > 0;
509517
}
510518

src/env.h

+12-10
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,16 @@ class TrackingTraceStateObserver :
679679
Environment* env_;
680680
};
681681

682+
class ShouldNotAbortOnUncaughtScope {
683+
public:
684+
explicit inline ShouldNotAbortOnUncaughtScope(Environment* env);
685+
inline void Close();
686+
inline ~ShouldNotAbortOnUncaughtScope();
687+
688+
private:
689+
Environment* env_;
690+
};
691+
682692
class Environment {
683693
public:
684694
Environment(const Environment&) = delete;
@@ -998,16 +1008,8 @@ class Environment {
9981008
// This needs to be available for the JS-land setImmediate().
9991009
void ToggleImmediateRef(bool ref);
10001010

1001-
class ShouldNotAbortOnUncaughtScope {
1002-
public:
1003-
explicit inline ShouldNotAbortOnUncaughtScope(Environment* env);
1004-
inline void Close();
1005-
inline ~ShouldNotAbortOnUncaughtScope();
1006-
1007-
private:
1008-
Environment* env_;
1009-
};
1010-
1011+
inline void PushShouldNotAbortOnUncaughtScope();
1012+
inline void PopShouldNotAbortOnUncaughtScope();
10111013
inline bool inside_should_not_abort_on_uncaught_scope() const;
10121014

10131015
static inline Environment* ForAsyncHooks(AsyncHooks* hooks);

src/module_wrap.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
136136
column_offset = Integer::New(isolate, 0);
137137
}
138138

139-
Environment::ShouldNotAbortOnUncaughtScope no_abort_scope(env);
139+
ShouldNotAbortOnUncaughtScope no_abort_scope(env);
140140
TryCatchScope try_catch(env);
141141
Local<Module> module;
142142

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

283-
Environment::ShouldNotAbortOnUncaughtScope no_abort_scope(env);
283+
ShouldNotAbortOnUncaughtScope no_abort_scope(env);
284284
TryCatchScope try_catch(env);
285285

286286
bool timed_out = false;

src/node_contextify.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
719719
compile_options = ScriptCompiler::kConsumeCodeCache;
720720

721721
TryCatchScope try_catch(env);
722-
Environment::ShouldNotAbortOnUncaughtScope no_abort_scope(env);
722+
ShouldNotAbortOnUncaughtScope no_abort_scope(env);
723723
Context::Scope scope(parsing_context);
724724

725725
MaybeLocal<UnboundScript> v8_script = ScriptCompiler::CompileUnboundScript(

0 commit comments

Comments
 (0)