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, ...@@ -501,13 +501,17 @@ StartupData V8::WarmUpSnapshotDataBlob(StartupData cold_snapshot_blob,
Isolate::Scope isolate_scope(isolate); Isolate::Scope isolate_scope(isolate);
i::Snapshot::Initialize(internal_isolate); i::Snapshot::Initialize(internal_isolate);
Persistent<Context> context; Persistent<Context> context;
bool success;
{ {
HandleScope handle_scope(isolate); HandleScope handle_scope(isolate);
Local<Context> warmup_context = Context::New(isolate); Local<Context> new_context = Context::New(isolate);
if (RunExtraCode(isolate, warmup_context, warmup_source, "<warm-up>")) { success = RunExtraCode(isolate, new_context, warmup_source, "<warm-up>");
Local<Context> fresh_context = Context::New(isolate); }
context.Reset(isolate, fresh_context); 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; i::Snapshot::Metadata metadata;
......
...@@ -27,18 +27,26 @@ void StartupSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code, ...@@ -27,18 +27,26 @@ void StartupSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
WhereToPoint where_to_point, int skip) { WhereToPoint where_to_point, int skip) {
DCHECK(!obj->IsJSFunction()); 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); Code* code = Code::cast(obj);
// If the function code is compiled (either as native code or bytecode), if (code->kind() == Code::FUNCTION) {
// replace it with lazy-compile builtin. Only exception is when we are code->ClearInlineCaches();
// serializing the canonical interpreter-entry-trampoline builtin. code->set_profiler_ticks(0);
if (function_code_handling_ == CLEAR_FUNCTION_CODE &&
(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();
} }
int root_index = root_index_map_.Lookup(obj); 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