1010namespace node {
1111namespace builtins {
1212
13+ using v8::Boolean;
1314using v8::Context;
1415using v8::EscapableHandleScope;
16+ using v8::Exception;
1517using v8::Function;
1618using v8::FunctionCallbackInfo;
1719using v8::IntegrityLevel;
1820using v8::Isolate;
1921using v8::Local;
2022using v8::MaybeLocal;
2123using v8::Name;
24+ using v8::NewStringType;
2225using v8::None;
2326using v8::Object;
2427using v8::ObjectTemplate;
@@ -28,6 +31,7 @@ using v8::ScriptOrigin;
2831using v8::Set;
2932using v8::SideEffectType;
3033using v8::String;
34+ using v8::TryCatch;
3135using v8::Undefined;
3236using v8::Value;
3337
@@ -200,11 +204,11 @@ MaybeLocal<String> BuiltinLoader::LoadBuiltinSource(Isolate* isolate,
200204 uv_strerror (r),
201205 filename);
202206 Local<String> message = OneByteString (isolate, buf);
203- isolate->ThrowException (v8:: Exception::Error (message));
207+ isolate->ThrowException (Exception::Error (message));
204208 return MaybeLocal<String>();
205209 }
206210 return String::NewFromUtf8 (
207- isolate, contents.c_str (), v8:: NewStringType::kNormal , contents.length ());
211+ isolate, contents.c_str (), NewStringType::kNormal , contents.length ());
208212#endif // NODE_BUILTIN_MODULES_PATH
209213}
210214
@@ -528,7 +532,7 @@ bool BuiltinLoader::CompileAllBuiltinsAndCopyCodeCache(
528532 to_eager_compile_.emplace (id);
529533 }
530534
531- v8:: TryCatch bootstrapCatch (context->GetIsolate ());
535+ TryCatch bootstrapCatch (context->GetIsolate ());
532536 auto fn = LookupAndCompile (context, id.data (), nullptr );
533537 if (bootstrapCatch.HasCaught ()) {
534538 per_process::Debug (DebugCategory::CODE_CACHE,
@@ -581,18 +585,15 @@ void BuiltinLoader::GetBuiltinCategories(
581585 Local<Value> can_be_required_js;
582586
583587 if (!ToV8Value (context, builtin_categories.cannot_be_required )
584- .ToLocal (&cannot_be_required_js))
585- return ;
586- if (result
588+ .ToLocal (&cannot_be_required_js) ||
589+ result
587590 ->Set (context,
588591 FIXED_ONE_BYTE_STRING (isolate, " cannotBeRequired" ),
589592 cannot_be_required_js)
590- .IsNothing ())
591- return ;
592- if (!ToV8Value (context, builtin_categories.can_be_required )
593- .ToLocal (&can_be_required_js))
594- return ;
595- if (result
593+ .IsNothing () ||
594+ !ToV8Value (context, builtin_categories.can_be_required )
595+ .ToLocal (&can_be_required_js) ||
596+ result
596597 ->Set (context,
597598 FIXED_ONE_BYTE_STRING (isolate, " canBeRequired" ),
598599 can_be_required_js)
@@ -612,34 +613,22 @@ void BuiltinLoader::GetCacheUsage(const FunctionCallbackInfo<Value>& args) {
612613 Local<Value> builtins_without_cache_js;
613614 Local<Value> builtins_in_snapshot_js;
614615 if (!ToV8Value (context, realm->builtins_with_cache )
615- .ToLocal (&builtins_with_cache_js)) {
616- return ;
617- }
618- if (result
616+ .ToLocal (&builtins_with_cache_js) ||
617+ result
619618 ->Set (context,
620619 FIXED_ONE_BYTE_STRING (isolate, " compiledWithCache" ),
621620 builtins_with_cache_js)
622- .IsNothing ()) {
623- return ;
624- }
625-
626- if (!ToV8Value (context, realm->builtins_without_cache )
627- .ToLocal (&builtins_without_cache_js)) {
628- return ;
629- }
630- if (result
621+ .IsNothing () ||
622+ !ToV8Value (context, realm->builtins_without_cache )
623+ .ToLocal (&builtins_without_cache_js) ||
624+ result
631625 ->Set (context,
632626 FIXED_ONE_BYTE_STRING (isolate, " compiledWithoutCache" ),
633627 builtins_without_cache_js)
634- .IsNothing ()) {
635- return ;
636- }
637-
638- if (!ToV8Value (context, realm->builtins_in_snapshot )
639- .ToLocal (&builtins_in_snapshot_js)) {
640- return ;
641- }
642- if (result
628+ .IsNothing () ||
629+ !ToV8Value (context, realm->builtins_in_snapshot )
630+ .ToLocal (&builtins_in_snapshot_js) ||
631+ result
643632 ->Set (context,
644633 FIXED_ONE_BYTE_STRING (isolate, " compiledInSnapshot" ),
645634 builtins_in_snapshot_js)
@@ -656,8 +645,10 @@ void BuiltinLoader::BuiltinIdsGetter(Local<Name> property,
656645 Isolate* isolate = env->isolate ();
657646
658647 auto ids = env->builtin_loader ()->GetBuiltinIds ();
659- info.GetReturnValue ().Set (
660- ToV8Value (isolate->GetCurrentContext (), ids).ToLocalChecked ());
648+ Local<Value> ret;
649+ if (ToV8Value (isolate->GetCurrentContext (), ids).ToLocal (&ret)) {
650+ info.GetReturnValue ().Set (ret);
651+ }
661652}
662653
663654void BuiltinLoader::ConfigStringGetter (
@@ -693,7 +684,7 @@ void BuiltinLoader::CompileFunction(const FunctionCallbackInfo<Value>& args) {
693684void BuiltinLoader::HasCachedBuiltins (const FunctionCallbackInfo<Value>& args) {
694685 auto instance = Environment::GetCurrent (args)->builtin_loader ();
695686 RwLock::ScopedReadLock lock (instance->code_cache_ ->mutex );
696- args.GetReturnValue ().Set (v8:: Boolean::New (
687+ args.GetReturnValue ().Set (Boolean::New (
697688 args.GetIsolate (), instance->code_cache_ ->has_code_cache ));
698689}
699690
0 commit comments