10
10
namespace node {
11
11
namespace builtins {
12
12
13
+ using v8::Boolean ;
13
14
using v8::Context;
14
15
using v8::EscapableHandleScope;
16
+ using v8::Exception;
15
17
using v8::Function;
16
18
using v8::FunctionCallbackInfo;
17
19
using v8::IntegrityLevel;
18
20
using v8::Isolate;
19
21
using v8::Local;
20
22
using v8::MaybeLocal;
21
23
using v8::Name;
24
+ using v8::NewStringType;
22
25
using v8::None;
23
26
using v8::Object;
24
27
using v8::ObjectTemplate;
@@ -28,6 +31,7 @@ using v8::ScriptOrigin;
28
31
using v8::Set;
29
32
using v8::SideEffectType;
30
33
using v8::String;
34
+ using v8::TryCatch;
31
35
using v8::Undefined;
32
36
using v8::Value;
33
37
@@ -201,11 +205,11 @@ MaybeLocal<String> BuiltinLoader::LoadBuiltinSource(Isolate* isolate,
201
205
uv_strerror (r),
202
206
filename);
203
207
Local<String> message = OneByteString (isolate, buf);
204
- isolate->ThrowException (v8:: Exception::Error (message));
208
+ isolate->ThrowException (Exception::Error (message));
205
209
return MaybeLocal<String>();
206
210
}
207
211
return String::NewFromUtf8 (
208
- isolate, contents.c_str (), v8:: NewStringType::kNormal , contents.length ());
212
+ isolate, contents.c_str (), NewStringType::kNormal , contents.length ());
209
213
#endif // NODE_BUILTIN_MODULES_PATH
210
214
}
211
215
@@ -529,7 +533,7 @@ bool BuiltinLoader::CompileAllBuiltinsAndCopyCodeCache(
529
533
to_eager_compile_.emplace (id);
530
534
}
531
535
532
- v8:: TryCatch bootstrapCatch (context->GetIsolate ());
536
+ TryCatch bootstrapCatch (context->GetIsolate ());
533
537
auto fn = LookupAndCompile (context, id.data (), nullptr );
534
538
if (bootstrapCatch.HasCaught ()) {
535
539
per_process::Debug (DebugCategory::CODE_CACHE,
@@ -582,18 +586,15 @@ void BuiltinLoader::GetBuiltinCategories(
582
586
Local<Value> can_be_required_js;
583
587
584
588
if (!ToV8Value (context, builtin_categories.cannot_be_required )
585
- .ToLocal (&cannot_be_required_js))
586
- return ;
587
- if (result
589
+ .ToLocal (&cannot_be_required_js) ||
590
+ result
588
591
->Set (context,
589
592
FIXED_ONE_BYTE_STRING (isolate, " cannotBeRequired" ),
590
593
cannot_be_required_js)
591
- .IsNothing ())
592
- return ;
593
- if (!ToV8Value (context, builtin_categories.can_be_required )
594
- .ToLocal (&can_be_required_js))
595
- return ;
596
- if (result
594
+ .IsNothing () ||
595
+ !ToV8Value (context, builtin_categories.can_be_required )
596
+ .ToLocal (&can_be_required_js) ||
597
+ result
597
598
->Set (context,
598
599
FIXED_ONE_BYTE_STRING (isolate, " canBeRequired" ),
599
600
can_be_required_js)
@@ -613,34 +614,22 @@ void BuiltinLoader::GetCacheUsage(const FunctionCallbackInfo<Value>& args) {
613
614
Local<Value> builtins_without_cache_js;
614
615
Local<Value> builtins_in_snapshot_js;
615
616
if (!ToV8Value (context, realm->builtins_with_cache )
616
- .ToLocal (&builtins_with_cache_js)) {
617
- return ;
618
- }
619
- if (result
617
+ .ToLocal (&builtins_with_cache_js) ||
618
+ result
620
619
->Set (context,
621
620
FIXED_ONE_BYTE_STRING (isolate, " compiledWithCache" ),
622
621
builtins_with_cache_js)
623
- .IsNothing ()) {
624
- return ;
625
- }
626
-
627
- if (!ToV8Value (context, realm->builtins_without_cache )
628
- .ToLocal (&builtins_without_cache_js)) {
629
- return ;
630
- }
631
- if (result
622
+ .IsNothing () ||
623
+ !ToV8Value (context, realm->builtins_without_cache )
624
+ .ToLocal (&builtins_without_cache_js) ||
625
+ result
632
626
->Set (context,
633
627
FIXED_ONE_BYTE_STRING (isolate, " compiledWithoutCache" ),
634
628
builtins_without_cache_js)
635
- .IsNothing ()) {
636
- return ;
637
- }
638
-
639
- if (!ToV8Value (context, realm->builtins_in_snapshot )
640
- .ToLocal (&builtins_in_snapshot_js)) {
641
- return ;
642
- }
643
- if (result
629
+ .IsNothing () ||
630
+ !ToV8Value (context, realm->builtins_in_snapshot )
631
+ .ToLocal (&builtins_in_snapshot_js) ||
632
+ result
644
633
->Set (context,
645
634
FIXED_ONE_BYTE_STRING (isolate, " compiledInSnapshot" ),
646
635
builtins_in_snapshot_js)
@@ -657,8 +646,10 @@ void BuiltinLoader::BuiltinIdsGetter(Local<Name> property,
657
646
Isolate* isolate = env->isolate ();
658
647
659
648
auto ids = env->builtin_loader ()->GetBuiltinIds ();
660
- info.GetReturnValue ().Set (
661
- ToV8Value (isolate->GetCurrentContext (), ids).ToLocalChecked ());
649
+ Local<Value> ret;
650
+ if (ToV8Value (isolate->GetCurrentContext (), ids).ToLocal (&ret)) {
651
+ info.GetReturnValue ().Set (ret);
652
+ }
662
653
}
663
654
664
655
void BuiltinLoader::ConfigStringGetter (
@@ -694,7 +685,7 @@ void BuiltinLoader::CompileFunction(const FunctionCallbackInfo<Value>& args) {
694
685
void BuiltinLoader::HasCachedBuiltins (const FunctionCallbackInfo<Value>& args) {
695
686
auto instance = Environment::GetCurrent (args)->builtin_loader ();
696
687
RwLock::ScopedReadLock lock (instance->code_cache_ ->mutex );
697
- args.GetReturnValue ().Set (v8:: Boolean::New (
688
+ args.GetReturnValue ().Set (Boolean::New (
698
689
args.GetIsolate (), instance->code_cache_ ->has_code_cache ));
699
690
}
700
691
0 commit comments