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
@@ -200,11 +204,11 @@ MaybeLocal<String> BuiltinLoader::LoadBuiltinSource(Isolate* isolate,
200
204
uv_strerror (r),
201
205
filename);
202
206
Local<String> message = OneByteString (isolate, buf);
203
- isolate->ThrowException (v8:: Exception::Error (message));
207
+ isolate->ThrowException (Exception::Error (message));
204
208
return MaybeLocal<String>();
205
209
}
206
210
return String::NewFromUtf8 (
207
- isolate, contents.c_str (), v8:: NewStringType::kNormal , contents.length ());
211
+ isolate, contents.c_str (), NewStringType::kNormal , contents.length ());
208
212
#endif // NODE_BUILTIN_MODULES_PATH
209
213
}
210
214
@@ -528,7 +532,7 @@ bool BuiltinLoader::CompileAllBuiltinsAndCopyCodeCache(
528
532
to_eager_compile_.emplace (id);
529
533
}
530
534
531
- v8:: TryCatch bootstrapCatch (context->GetIsolate ());
535
+ TryCatch bootstrapCatch (context->GetIsolate ());
532
536
auto fn = LookupAndCompile (context, id.data (), nullptr );
533
537
if (bootstrapCatch.HasCaught ()) {
534
538
per_process::Debug (DebugCategory::CODE_CACHE,
@@ -581,18 +585,15 @@ void BuiltinLoader::GetBuiltinCategories(
581
585
Local<Value> can_be_required_js;
582
586
583
587
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
587
590
->Set (context,
588
591
FIXED_ONE_BYTE_STRING (isolate, " cannotBeRequired" ),
589
592
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
596
597
->Set (context,
597
598
FIXED_ONE_BYTE_STRING (isolate, " canBeRequired" ),
598
599
can_be_required_js)
@@ -612,34 +613,22 @@ void BuiltinLoader::GetCacheUsage(const FunctionCallbackInfo<Value>& args) {
612
613
Local<Value> builtins_without_cache_js;
613
614
Local<Value> builtins_in_snapshot_js;
614
615
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
619
618
->Set (context,
620
619
FIXED_ONE_BYTE_STRING (isolate, " compiledWithCache" ),
621
620
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
631
625
->Set (context,
632
626
FIXED_ONE_BYTE_STRING (isolate, " compiledWithoutCache" ),
633
627
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
643
632
->Set (context,
644
633
FIXED_ONE_BYTE_STRING (isolate, " compiledInSnapshot" ),
645
634
builtins_in_snapshot_js)
@@ -656,8 +645,10 @@ void BuiltinLoader::BuiltinIdsGetter(Local<Name> property,
656
645
Isolate* isolate = env->isolate ();
657
646
658
647
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
+ }
661
652
}
662
653
663
654
void BuiltinLoader::ConfigStringGetter (
@@ -693,7 +684,7 @@ void BuiltinLoader::CompileFunction(const FunctionCallbackInfo<Value>& args) {
693
684
void BuiltinLoader::HasCachedBuiltins (const FunctionCallbackInfo<Value>& args) {
694
685
auto instance = Environment::GetCurrent (args)->builtin_loader ();
695
686
RwLock::ScopedReadLock lock (instance->code_cache_ ->mutex );
696
- args.GetReturnValue ().Set (v8:: Boolean::New (
687
+ args.GetReturnValue ().Set (Boolean::New (
697
688
args.GetIsolate (), instance->code_cache_ ->has_code_cache ));
698
689
}
699
690
0 commit comments