Commit 18cdb9cd authored by yangguo's avatar yangguo Committed by Commit bot

[serializer] tweak startup serializer for warming up.

Code that we want to keep after warming up may have context-dependent
inline caches. Clear these to avoid running into IC misses after
deserialization.

R=vogelheim@chromium.org
BUG=v8:4836
LOG=N

Review URL: https://codereview.chromium.org/1811263002

Cr-Commit-Position: refs/heads/master@{#34945}
parent 47f64a76
......@@ -501,13 +501,17 @@ StartupData V8::WarmUpSnapshotDataBlob(StartupData cold_snapshot_blob,
Isolate::Scope isolate_scope(isolate);
i::Snapshot::Initialize(internal_isolate);
Persistent<Context> context;
bool success;
{
HandleScope handle_scope(isolate);
Local<Context> warmup_context = Context::New(isolate);
if (RunExtraCode(isolate, warmup_context, warmup_source, "<warm-up>")) {
Local<Context> fresh_context = Context::New(isolate);
context.Reset(isolate, fresh_context);
}
Local<Context> new_context = Context::New(isolate);
success = RunExtraCode(isolate, new_context, warmup_source, "<warm-up>");
}
if (success) {
HandleScope handle_scope(isolate);
isolate->ContextDisposedNotification(false);
Local<Context> new_context = Context::New(isolate);
context.Reset(isolate, new_context);
}
i::Snapshot::Metadata metadata;
......
......@@ -27,18 +27,26 @@ void StartupSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
WhereToPoint where_to_point, int skip) {
DCHECK(!obj->IsJSFunction());
if (obj->IsCode()) {
if (function_code_handling_ == CLEAR_FUNCTION_CODE) {
if (obj->IsCode()) {
Code* code = Code::cast(obj);
// If the function code is compiled (either as native code or bytecode),
// replace it with lazy-compile builtin. Only exception is when we are
// serializing the canonical interpreter-entry-trampoline builtin.
if (code->kind() == Code::FUNCTION ||
(!serializing_builtins_ && code->is_interpreter_entry_trampoline())) {
obj = isolate()->builtins()->builtin(Builtins::kCompileLazy);
}
} else if (obj->IsBytecodeArray()) {
obj = isolate()->heap()->undefined_value();
}
} else if (obj->IsCode()) {
DCHECK_EQ(KEEP_FUNCTION_CODE, function_code_handling_);
Code* code = Code::cast(obj);
// If the function code is compiled (either as native code or bytecode),
// replace it with lazy-compile builtin. Only exception is when we are
// serializing the canonical interpreter-entry-trampoline builtin.
if (function_code_handling_ == CLEAR_FUNCTION_CODE &&
(code->kind() == Code::FUNCTION ||
(!serializing_builtins_ && code->is_interpreter_entry_trampoline()))) {
obj = isolate()->builtins()->builtin(Builtins::kCompileLazy);
if (code->kind() == Code::FUNCTION) {
code->ClearInlineCaches();
code->set_profiler_ticks(0);
}
} else if (obj->IsBytecodeArray()) {
obj = isolate()->heap()->undefined_value();
}
int root_index = root_index_map_.Lookup(obj);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment