diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index c16d56c47e..4d9b2b296a 100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -488,7 +488,7 @@ DEFINE_BOOL(trace_stub_failures, false,
DEFINE_BOOL(serialize_toplevel, true, "enable caching of toplevel scripts")
DEFINE_BOOL(serialize_inner, false, "enable caching of inner functions")
-DEFINE_BOOL(trace_code_serializer, false, "print code serializer trace")
+DEFINE_BOOL(trace_serializer, false, "print code serializer trace")
// compiler.cc
DEFINE_INT(min_preparse_length, 1024,
diff --git a/src/serialize.cc b/src/serialize.cc
index fab9775577..e6aae7fe8d 100644
--- a/src/serialize.cc
+++ b/src/serialize.cc
@@ -794,10 +794,24 @@ HeapObject* Deserializer::ProcessNewObjectFromSerializedCode(HeapObject* obj) {
}
-Object* Deserializer::ProcessBackRefInSerializedCode(Object* obj) {
- if (obj->IsInternalizedString()) {
- return String::cast(obj)->GetForwardedInternalizedString();
+HeapObject* Deserializer::GetBackReferencedObject(int space) {
+ HeapObject* obj;
+ if (space == LO_SPACE) {
+ uint32_t index = source_->GetInt();
+ obj = deserialized_large_objects_[index];
+ } else {
+ BackReference back_reference(source_->GetInt());
+ DCHECK(space < kNumberOfPreallocatedSpaces);
+ uint32_t chunk_index = back_reference.chunk_index();
+ DCHECK_LE(chunk_index, current_chunk_[space]);
+ uint32_t chunk_offset = back_reference.chunk_offset();
+ obj = HeapObject::FromAddress(reservations_[space][chunk_index].start +
+ chunk_offset);
}
+ if (deserializing_user_code() && obj->IsInternalizedString()) {
+ obj = String::cast(obj)->GetForwardedInternalizedString();
+ }
+ hot_objects_.Add(obj);
return obj;
}
@@ -904,7 +918,7 @@ void Deserializer::ReadData(Object** current, Object** limit, int source_space,
source_space != CODE_SPACE &&
source_space != OLD_DATA_SPACE);
while (current < limit) {
- int data = source_->Get();
+ byte data = source_->Get();
switch (data) {
#define CASE_STATEMENT(where, how, within, space_number) \
case where + how + within + space_number: \
@@ -945,9 +959,6 @@ void Deserializer::ReadData(Object** current, Object** limit, int source_space,
} else if (where == kBackref) { \
emit_write_barrier = (space_number == NEW_SPACE); \
new_object = GetBackReferencedObject(data & kSpaceMask); \
- if (deserializing_user_code()) { \
- new_object = ProcessBackRefInSerializedCode(new_object); \
- } \
} else if (where == kBuiltin) { \
DCHECK(deserializing_user_code()); \
int builtin_id = source_->GetInt(); \
@@ -968,9 +979,6 @@ void Deserializer::ReadData(Object** current, Object** limit, int source_space,
reinterpret_cast
(current) + skip); \
emit_write_barrier = (space_number == NEW_SPACE); \
new_object = GetBackReferencedObject(data & kSpaceMask); \
- if (deserializing_user_code()) { \
- new_object = ProcessBackRefInSerializedCode(new_object); \
- } \
} \
if (within == kInnerPointer) { \
if (space_number != CODE_SPACE || new_object->IsCode()) { \
@@ -1111,7 +1119,7 @@ void Deserializer::ReadData(Object** current, Object** limit, int source_space,
break;
}
- case kRepeat: {
+ case kVariableRepeat: {
int repeats = source_->GetInt();
Object* object = current[-1];
DCHECK(!isolate->heap()->InNewSpace(object));
@@ -1122,11 +1130,13 @@ void Deserializer::ReadData(Object** current, Object** limit, int source_space,
STATIC_ASSERT(kRootArrayNumberOfConstantEncodings ==
Heap::kOldSpaceRoots);
- STATIC_ASSERT(kMaxRepeats == 13);
- case kConstantRepeat:
- FOUR_CASES(kConstantRepeat + 1)
- FOUR_CASES(kConstantRepeat + 5)
- FOUR_CASES(kConstantRepeat + 9) {
+ STATIC_ASSERT(kMaxFixedRepeats == 15);
+ FOUR_CASES(kFixedRepeat)
+ FOUR_CASES(kFixedRepeat + 4)
+ FOUR_CASES(kFixedRepeat + 8)
+ case kFixedRepeat + 12:
+ case kFixedRepeat + 13:
+ case kFixedRepeat + 14: {
int repeats = RepeatsForCode(data);
Object* object = current[-1];
DCHECK(!isolate->heap()->InNewSpace(object));
@@ -1261,6 +1271,27 @@ void Deserializer::ReadData(Object** current, Object** limit, int source_space,
break;
}
+ FOUR_CASES(kHotObjectWithSkip)
+ FOUR_CASES(kHotObjectWithSkip + 4) {
+ int skip = source_->GetInt();
+ current = reinterpret_cast