bootstrap: only use the isolate snapshot when compiling code cache
We do not actually need to deserialize the context and the whole environment to compile the code cache, since code cache are not context-dependent anyway, deserializing just the isolate snapshot is enough. PR-URL: https://github.com/nodejs/node/pull/49288 Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
parent
12354260db
commit
4d0f930183
@ -975,21 +975,8 @@ ExitCode BuildSnapshotWithoutCodeCache(
|
|||||||
ExitCode BuildCodeCacheFromSnapshot(SnapshotData* out,
|
ExitCode BuildCodeCacheFromSnapshot(SnapshotData* out,
|
||||||
const std::vector<std::string>& args,
|
const std::vector<std::string>& args,
|
||||||
const std::vector<std::string>& exec_args) {
|
const std::vector<std::string>& exec_args) {
|
||||||
std::vector<std::string> errors;
|
RAIIIsolate raii_isolate(out);
|
||||||
auto data_wrapper = out->AsEmbedderWrapper();
|
Isolate* isolate = raii_isolate.get();
|
||||||
auto setup = CommonEnvironmentSetup::CreateFromSnapshot(
|
|
||||||
per_process::v8_platform.Platform(),
|
|
||||||
&errors,
|
|
||||||
data_wrapper.get(),
|
|
||||||
args,
|
|
||||||
exec_args);
|
|
||||||
if (!setup) {
|
|
||||||
for (const auto& err : errors)
|
|
||||||
fprintf(stderr, "%s: %s\n", args[0].c_str(), err.c_str());
|
|
||||||
return ExitCode::kBootstrapFailure;
|
|
||||||
}
|
|
||||||
|
|
||||||
Isolate* isolate = setup->isolate();
|
|
||||||
v8::Locker locker(isolate);
|
v8::Locker locker(isolate);
|
||||||
Isolate::Scope isolate_scope(isolate);
|
Isolate::Scope isolate_scope(isolate);
|
||||||
HandleScope handle_scope(isolate);
|
HandleScope handle_scope(isolate);
|
||||||
@ -1002,12 +989,14 @@ ExitCode BuildCodeCacheFromSnapshot(SnapshotData* out,
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Environment* env = setup->env();
|
Local<Context> context = Context::New(isolate);
|
||||||
|
Context::Scope context_scope(context);
|
||||||
|
builtins::BuiltinLoader builtin_loader;
|
||||||
// Regenerate all the code cache.
|
// Regenerate all the code cache.
|
||||||
if (!env->builtin_loader()->CompileAllBuiltins(setup->context())) {
|
if (!builtin_loader.CompileAllBuiltins(context)) {
|
||||||
return ExitCode::kGenericUserError;
|
return ExitCode::kGenericUserError;
|
||||||
}
|
}
|
||||||
env->builtin_loader()->CopyCodeCache(&(out->code_cache));
|
builtin_loader.CopyCodeCache(&(out->code_cache));
|
||||||
if (per_process::enabled_debug_list.enabled(DebugCategory::MKSNAPSHOT)) {
|
if (per_process::enabled_debug_list.enabled(DebugCategory::MKSNAPSHOT)) {
|
||||||
for (const auto& item : out->code_cache) {
|
for (const auto& item : out->code_cache) {
|
||||||
std::string size_str = FormatSize(item.data.length);
|
std::string size_str = FormatSize(item.data.length);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user