@@ -549,50 +549,8 @@ Maybe<bool> InitializeContextRuntime(Local<Context> context) {
549
549
Isolate* isolate = context->GetIsolate ();
550
550
HandleScope handle_scope (isolate);
551
551
552
- // Delete `Intl.v8BreakIterator`
553
- // https://github.com/nodejs/node/issues/14909
554
- {
555
- Local<String> intl_string =
556
- FIXED_ONE_BYTE_STRING (isolate, " Intl" );
557
- Local<String> break_iter_string =
558
- FIXED_ONE_BYTE_STRING (isolate, " v8BreakIterator" );
559
-
560
- Local<Value> intl_v;
561
- if (!context->Global ()
562
- ->Get (context, intl_string)
563
- .ToLocal (&intl_v)) {
564
- return Nothing<bool >();
565
- }
566
-
567
- if (intl_v->IsObject () &&
568
- intl_v.As <Object>()
569
- ->Delete (context, break_iter_string)
570
- .IsNothing ()) {
571
- return Nothing<bool >();
572
- }
573
- }
574
-
575
- // Delete `Atomics.wake`
576
- // https://github.com/nodejs/node/issues/21219
577
- {
578
- Local<String> atomics_string =
579
- FIXED_ONE_BYTE_STRING (isolate, " Atomics" );
580
- Local<String> wake_string =
581
- FIXED_ONE_BYTE_STRING (isolate, " wake" );
582
-
583
- Local<Value> atomics_v;
584
- if (!context->Global ()
585
- ->Get (context, atomics_string)
586
- .ToLocal (&atomics_v)) {
587
- return Nothing<bool >();
588
- }
589
-
590
- if (atomics_v->IsObject () &&
591
- atomics_v.As <Object>()
592
- ->Delete (context, wake_string)
593
- .IsNothing ()) {
594
- return Nothing<bool >();
595
- }
552
+ if (per_process::cli_options->disable_proto == " " ) {
553
+ return Just (true );
596
554
}
597
555
598
556
// Remove __proto__
@@ -654,7 +612,32 @@ Maybe<bool> InitializeContextRuntime(Local<Context> context) {
654
612
return Just (true );
655
613
}
656
614
657
- Maybe<bool > InitializeContextForSnapshot (Local<Context> context) {
615
+ Maybe<bool > InitializeBaseContextForSnapshot (Local<Context> context) {
616
+ Isolate* isolate = context->GetIsolate ();
617
+ HandleScope handle_scope (isolate);
618
+
619
+ // Delete `Intl.v8BreakIterator`
620
+ // https://github.com/nodejs/node/issues/14909
621
+ {
622
+ Context::Scope context_scope (context);
623
+ Local<String> intl_string = FIXED_ONE_BYTE_STRING (isolate, " Intl" );
624
+ Local<String> break_iter_string =
625
+ FIXED_ONE_BYTE_STRING (isolate, " v8BreakIterator" );
626
+
627
+ Local<Value> intl_v;
628
+ if (!context->Global ()->Get (context, intl_string).ToLocal (&intl_v)) {
629
+ return Nothing<bool >();
630
+ }
631
+
632
+ if (intl_v->IsObject () &&
633
+ intl_v.As <Object>()->Delete (context, break_iter_string).IsNothing ()) {
634
+ return Nothing<bool >();
635
+ }
636
+ }
637
+ return Just (true );
638
+ }
639
+
640
+ Maybe<bool > InitializeMainContextForSnapshot (Local<Context> context) {
658
641
Isolate* isolate = context->GetIsolate ();
659
642
HandleScope handle_scope (isolate);
660
643
@@ -664,6 +647,9 @@ Maybe<bool> InitializeContextForSnapshot(Local<Context> context) {
664
647
context->SetEmbedderData (ContextEmbedderIndex::kAllowWasmCodeGeneration ,
665
648
True (isolate));
666
649
650
+ if (InitializeBaseContextForSnapshot (context).IsNothing ()) {
651
+ return Nothing<bool >();
652
+ }
667
653
return InitializePrimordials (context);
668
654
}
669
655
@@ -710,8 +696,9 @@ Maybe<bool> InitializePrimordials(Local<Context> context) {
710
696
return Just (true );
711
697
}
712
698
699
+ // This initializes the main context (i.e. vm contexts are not included).
713
700
Maybe<bool > InitializeContext (Local<Context> context) {
714
- if (InitializeContextForSnapshot (context).IsNothing ()) {
701
+ if (InitializeMainContextForSnapshot (context).IsNothing ()) {
715
702
return Nothing<bool >();
716
703
}
717
704
0 commit comments