| Index: src/snapshot/serialize.cc
|
| diff --git a/src/snapshot/serialize.cc b/src/snapshot/serialize.cc
|
| index 38297646302b3c16224df2615e2e38352dd5d2d2..3cb8552dbf655764c744769ab30e55cfc96533cd 100644
|
| --- a/src/snapshot/serialize.cc
|
| +++ b/src/snapshot/serialize.cc
|
| @@ -1680,9 +1680,10 @@ bool Serializer::SerializeKnownObject(HeapObject* obj, HowToCode how_to_code,
|
| return false;
|
| }
|
|
|
| -
|
| StartupSerializer::StartupSerializer(Isolate* isolate, SnapshotByteSink* sink)
|
| - : Serializer(isolate, sink), root_index_wave_front_(0) {
|
| + : Serializer(isolate, sink),
|
| + root_index_wave_front_(0),
|
| + serializing_builtins_(false) {
|
| // Clear the cache of objects used by the partial snapshot. After the
|
| // strong roots have been serialized we can create a partial snapshot
|
| // which will repopulate the cache with objects needed by that partial
|
| @@ -1696,6 +1697,19 @@ void StartupSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
|
| WhereToPoint where_to_point, int skip) {
|
| DCHECK(!obj->IsJSFunction());
|
|
|
| + 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();
|
| + }
|
| +
|
| int root_index = root_index_map_.Lookup(obj);
|
| // We can only encode roots as such if it has already been serialized.
|
| // That applies to root indices below the wave front.
|
| @@ -1705,10 +1719,6 @@ void StartupSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
|
| return;
|
| }
|
|
|
| - if (obj->IsCode() && Code::cast(obj)->kind() == Code::FUNCTION) {
|
| - obj = isolate()->builtins()->builtin(Builtins::kCompileLazy);
|
| - }
|
| -
|
| if (SerializeKnownObject(obj, how_to_code, where_to_point, skip)) return;
|
|
|
| FlushSkip(skip);
|
| @@ -1733,6 +1743,11 @@ void StartupSerializer::SerializeWeakReferencesAndDeferred() {
|
| Pad();
|
| }
|
|
|
| +void StartupSerializer::Synchronize(VisitorSynchronization::SyncTag tag) {
|
| + // We expect the builtins tag after builtins have been serialized.
|
| + DCHECK(!serializing_builtins_ || tag == VisitorSynchronization::kBuiltins);
|
| + serializing_builtins_ = (tag == VisitorSynchronization::kHandleScope);
|
| +}
|
|
|
| void Serializer::PutRoot(int root_index,
|
| HeapObject* object,
|
|
|