| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 597a39b commit cf25a5e
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -993,25 +993,29 @@ ExitCode BuildSnapshotWithoutCodeCache( | |||
| 993 | 993 | } | |
| 994 | 994 | }); | |
| 995 | 995 | ||
| 996 | + Context::Scope context_scope(setup->context()); | ||
| 997 | + Environment* env = setup->env(); | ||
| 998 | + | ||
| 996 | 999 | // Run the custom main script for fully customized snapshots. | |
| 997 | 1000 | if (snapshot_type == SnapshotMetadata::Type::kFullyCustomized) { | |
| 998 | - Context::Scope context_scope(setup->context()); | ||
| 999 | - Environment* env = setup->env(); | ||
| 1000 | 1001 | #if HAVE_INSPECTOR | |
| 1001 | 1002 | env->InitializeInspector({}); | |
| 1002 | 1003 | #endif | |
| 1003 | 1004 | if (LoadEnvironment(env, builder_script_content.value()).IsEmpty()) { | |
| 1004 | 1005 | return ExitCode::kGenericUserError; | |
| 1005 | 1006 | } | |
| 1007 | + } | ||
| 1006 | 1008 | ||
| 1007 | - // FIXME(joyeecheung): right now running the loop in the snapshot | ||
| 1008 | - // builder might introduce inconsistencies in JS land that need to | ||
| 1009 | - // be synchronized again after snapshot restoration. | ||
| 1010 | - ExitCode exit_code = | ||
| 1011 | - SpinEventLoopInternal(env).FromMaybe(ExitCode::kGenericUserError); | ||
| 1012 | - if (exit_code != ExitCode::kNoFailure) { | ||
| 1013 | - return exit_code; | ||
| 1014 | - } | ||
| 1009 | + // Drain the loop and platform tasks before creating a snapshot. This is | ||
| 1010 | + // necessary to ensure that the no roots are held by the the platform | ||
| 1011 | + // tasks, which may reference objects associated with a context. For | ||
| 1012 | + // example, a WeakRef may schedule an per-isolate platform task as a GC | ||
| 1013 | + // root, and referencing an object in a context, causing an assertion in | ||
| 1014 | + // the snapshot creator. | ||
| 1015 | + ExitCode exit_code = | ||
| 1016 | + SpinEventLoopInternal(env).FromMaybe(ExitCode::kGenericUserError); | ||
| 1017 | + if (exit_code != ExitCode::kNoFailure) { | ||
| 1018 | + return exit_code; | ||
| 1015 | 1019 | } | |
| 1016 | 1020 | } | |
| 1017 | 1021 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments