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