@@ -549,50 +549,8 @@ Maybe<bool> InitializeContextRuntime(Local<Context> context) {
549549 Isolate* isolate = context->GetIsolate ();
550550 HandleScope handle_scope (isolate);
551551
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 );
596554 }
597555
598556 // Remove __proto__
@@ -654,7 +612,32 @@ Maybe<bool> InitializeContextRuntime(Local<Context> context) {
654612 return Just (true );
655613}
656614
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) {
658641 Isolate* isolate = context->GetIsolate ();
659642 HandleScope handle_scope (isolate);
660643
@@ -664,6 +647,9 @@ Maybe<bool> InitializeContextForSnapshot(Local<Context> context) {
664647 context->SetEmbedderData (ContextEmbedderIndex::kAllowWasmCodeGeneration ,
665648 True (isolate));
666649
650+ if (InitializeBaseContextForSnapshot (context).IsNothing ()) {
651+ return Nothing<bool >();
652+ }
667653 return InitializePrimordials (context);
668654}
669655
@@ -710,8 +696,9 @@ Maybe<bool> InitializePrimordials(Local<Context> context) {
710696 return Just (true );
711697}
712698
699+ // This initializes the main context (i.e. vm contexts are not included).
713700Maybe<bool > InitializeContext (Local<Context> context) {
714- if (InitializeContextForSnapshot (context).IsNothing ()) {
701+ if (InitializeMainContextForSnapshot (context).IsNothing ()) {
715702 return Nothing<bool >();
716703 }
717704
0 commit comments