@@ -555,50 +555,8 @@ Maybe<bool> InitializeContextRuntime(Local<Context> context) {
555
555
Isolate* isolate = context->GetIsolate ();
556
556
HandleScope handle_scope (isolate);
557
557
558
- // Delete `Intl.v8BreakIterator`
559
- // https://github.com/nodejs/node/issues/14909
560
- {
561
- Local<String> intl_string =
562
- FIXED_ONE_BYTE_STRING (isolate, " Intl" );
563
- Local<String> break_iter_string =
564
- FIXED_ONE_BYTE_STRING (isolate, " v8BreakIterator" );
565
-
566
- Local<Value> intl_v;
567
- if (!context->Global ()
568
- ->Get (context, intl_string)
569
- .ToLocal (&intl_v)) {
570
- return Nothing<bool >();
571
- }
572
-
573
- if (intl_v->IsObject () &&
574
- intl_v.As <Object>()
575
- ->Delete (context, break_iter_string)
576
- .IsNothing ()) {
577
- return Nothing<bool >();
578
- }
579
- }
580
-
581
- // Delete `Atomics.wake`
582
- // https://github.com/nodejs/node/issues/21219
583
- {
584
- Local<String> atomics_string =
585
- FIXED_ONE_BYTE_STRING (isolate, " Atomics" );
586
- Local<String> wake_string =
587
- FIXED_ONE_BYTE_STRING (isolate, " wake" );
588
-
589
- Local<Value> atomics_v;
590
- if (!context->Global ()
591
- ->Get (context, atomics_string)
592
- .ToLocal (&atomics_v)) {
593
- return Nothing<bool >();
594
- }
595
-
596
- if (atomics_v->IsObject () &&
597
- atomics_v.As <Object>()
598
- ->Delete (context, wake_string)
599
- .IsNothing ()) {
600
- return Nothing<bool >();
601
- }
558
+ if (per_process::cli_options->disable_proto == " " ) {
559
+ return Just (true );
602
560
}
603
561
604
562
// Remove __proto__
@@ -660,7 +618,32 @@ Maybe<bool> InitializeContextRuntime(Local<Context> context) {
660
618
return Just (true );
661
619
}
662
620
663
- Maybe<bool > InitializeContextForSnapshot (Local<Context> context) {
621
+ Maybe<bool > InitializeBaseContextForSnapshot (Local<Context> context) {
622
+ Isolate* isolate = context->GetIsolate ();
623
+ HandleScope handle_scope (isolate);
624
+
625
+ // Delete `Intl.v8BreakIterator`
626
+ // https://github.com/nodejs/node/issues/14909
627
+ {
628
+ Context::Scope context_scope (context);
629
+ Local<String> intl_string = FIXED_ONE_BYTE_STRING (isolate, " Intl" );
630
+ Local<String> break_iter_string =
631
+ FIXED_ONE_BYTE_STRING (isolate, " v8BreakIterator" );
632
+
633
+ Local<Value> intl_v;
634
+ if (!context->Global ()->Get (context, intl_string).ToLocal (&intl_v)) {
635
+ return Nothing<bool >();
636
+ }
637
+
638
+ if (intl_v->IsObject () &&
639
+ intl_v.As <Object>()->Delete (context, break_iter_string).IsNothing ()) {
640
+ return Nothing<bool >();
641
+ }
642
+ }
643
+ return Just (true );
644
+ }
645
+
646
+ Maybe<bool > InitializeMainContextForSnapshot (Local<Context> context) {
664
647
Isolate* isolate = context->GetIsolate ();
665
648
HandleScope handle_scope (isolate);
666
649
@@ -670,6 +653,9 @@ Maybe<bool> InitializeContextForSnapshot(Local<Context> context) {
670
653
context->SetEmbedderData (ContextEmbedderIndex::kAllowWasmCodeGeneration ,
671
654
True (isolate));
672
655
656
+ if (InitializeBaseContextForSnapshot (context).IsNothing ()) {
657
+ return Nothing<bool >();
658
+ }
673
659
return InitializePrimordials (context);
674
660
}
675
661
@@ -716,8 +702,9 @@ Maybe<bool> InitializePrimordials(Local<Context> context) {
716
702
return Just (true );
717
703
}
718
704
705
+ // This initializes the main context (i.e. vm contexts are not included).
719
706
Maybe<bool > InitializeContext (Local<Context> context) {
720
- if (InitializeContextForSnapshot (context).IsNothing ()) {
707
+ if (InitializeMainContextForSnapshot (context).IsNothing ()) {
721
708
return Nothing<bool >();
722
709
}
723
710
0 commit comments