| Index: src/serialize.cc
|
| ===================================================================
|
| --- src/serialize.cc (revision 9722)
|
| +++ src/serialize.cc (working copy)
|
| @@ -695,7 +695,7 @@
|
| void Deserializer::VisitPointers(Object** start, Object** end) {
|
| // The space must be new space. Any other space would cause ReadChunk to try
|
| // to update the remembered using NULL as the address.
|
| - ReadChunk(start, end, NEW_SPACE, NULL);
|
| + ReadChunk(NULL, start, end, NEW_SPACE, NULL);
|
| }
|
|
|
|
|
| @@ -709,13 +709,14 @@
|
| Object** write_back) {
|
| int size = source_->GetInt() << kObjectAlignmentBits;
|
| Address address = Allocate(space_number, space, size);
|
| - *write_back = HeapObject::FromAddress(address);
|
| + HeapObject* new_object = HeapObject::FromAddress(address);
|
| + *write_back = new_object;
|
| Object** current = reinterpret_cast<Object**>(address);
|
| Object** limit = current + (size >> kPointerSizeLog2);
|
| if (FLAG_log_snapshot_positions) {
|
| LOG(isolate_, SnapshotPositionEvent(address, source_->position()));
|
| }
|
| - ReadChunk(current, limit, space_number, address);
|
| + ReadChunk(new_object, current, limit, space_number, address);
|
| #ifdef DEBUG
|
| bool is_codespace = (space == HEAP->code_space()) ||
|
| ((space == HEAP->lo_space()) && (space_number == kLargeCode));
|
| @@ -750,7 +751,8 @@
|
| static const int kUnknownOffsetFromStart = -1;
|
|
|
|
|
| -void Deserializer::ReadChunk(Object** current,
|
| +void Deserializer::ReadChunk(HeapObject* host,
|
| + Object** current,
|
| Object** limit,
|
| int source_space,
|
| Address address) {
|
| @@ -769,6 +771,7 @@
|
| { \
|
| bool emit_write_barrier = false; \
|
| bool current_was_incremented = false; \
|
| + bool cell_was_written = false; \
|
| int space_number = space_number_if_any == kAnyOldSpace ? \
|
| (data & kSpaceMask) : space_number_if_any; \
|
| if (where == kNewObject && how == kPlain && within == kStartOfObject) {\
|
| @@ -782,13 +785,34 @@
|
| if (where == kNewObject) { \
|
| ASSIGN_DEST_SPACE(space_number) \
|
| ReadObject(space_number, dest_space, &new_object); \
|
| - } else if (where == kRootArray) { \
|
| - int root_id = source_->GetInt(); \
|
| - new_object = isolate->heap()->roots_array_start()[root_id]; \
|
| - } else if (where == kPartialSnapshotCache) { \
|
| - int cache_index = source_->GetInt(); \
|
| - new_object = isolate->serialize_partial_snapshot_cache() \
|
| - [cache_index]; \
|
| + } else if (where == kRootArray || where == kPartialSnapshotCache) { \
|
| + if (where == kRootArray) { \
|
| + int root_id = source_->GetInt(); \
|
| + new_object = isolate->heap()->roots_array_start()[root_id]; \
|
| + } else { \
|
| + ASSERT(where == kPartialSnapshotCache); \
|
| + int cache_index = source_->GetInt(); \
|
| + new_object = isolate->serialize_partial_snapshot_cache() \
|
| + [cache_index]; \
|
| + } \
|
| + if (how != kFromCode) { \
|
| + cell_was_written = true; \
|
| + if (within == kFirstInstruction) { \
|
| + Code* new_code_object = reinterpret_cast<Code*>(new_object); \
|
| + new_object = reinterpret_cast<Object*>( \
|
| + new_code_object->instruction_start()); \
|
| + *current = new_object; \
|
| + isolate->heap()->incremental_marking()->RecordWriteOfCodeEntry(\
|
| + reinterpret_cast<JSFunction*>(host), \
|
| + current, \
|
| + new_code_object); \
|
| + } else { \
|
| + ASSERT(within == kStartOfObject); \
|
| + *current = new_object; \
|
| + isolate->heap()->incremental_marking()->RecordWrite( \
|
| + host, current, new_object); \
|
| + } \
|
| + } \
|
| } else if (where == kExternalReference) { \
|
| int reference_id = source_->GetInt(); \
|
| Address address = external_reference_decoder_-> \
|
| @@ -828,7 +852,7 @@
|
| current_was_incremented = true; \
|
| } \
|
| } else { \
|
| - *current = new_object; \
|
| + if (!cell_was_written) *current = new_object; \
|
| } \
|
| } \
|
| if (emit_write_barrier) { \
|
| @@ -932,6 +956,8 @@
|
| break;
|
| }
|
|
|
| + STATIC_ASSERT(kRootArrayNumberOfConstantEncodings ==
|
| + Heap::kOldSpaceRoots);
|
| STATIC_ASSERT(kMaxRepeats == 12);
|
| FOUR_CASES(kConstantRepeat)
|
| FOUR_CASES(kConstantRepeat + 4)
|
| @@ -1425,11 +1451,19 @@
|
| if (current < end) OutputRawData(reinterpret_cast<Address>(current));
|
|
|
| while (current < end && !(*current)->IsSmi()) {
|
| + HeapObject* current_contents = HeapObject::cast(*current);
|
| + int root_index = serializer_->RootIndex(current_contents);
|
| + // Repeats are not subject to the write barrier so there are only some
|
| + // objects that can be used in a repeat encoding. These are the early
|
| + // ones in the root array that are on the first page and never in new
|
| + // space.
|
| if (current != start &&
|
| - current[0] == current[-1] &&
|
| - !HEAP->InNewSpace(*current)) {
|
| + root_index != kInvalidRootIndex &&
|
| + root_index < kRootArrayNumberOfConstantEncodings &&
|
| + current_contents == current[-1] &&
|
| + !HEAP->InNewSpace(current_contents)) {
|
| int repeat_count = 1;
|
| - while (current < end - 1 && current[repeat_count] == current[0]) {
|
| + while (current < end - 1 && current[repeat_count] == current_contents) {
|
| repeat_count++;
|
| }
|
| current += repeat_count;
|
| @@ -1441,7 +1475,7 @@
|
| sink_->Put(CodeForRepeats(repeat_count), "SerializeRepeats");
|
| }
|
| } else {
|
| - serializer_->SerializeObject(*current, kPlain, kStartOfObject);
|
| + serializer_->SerializeObject(current_contents, kPlain, kStartOfObject);
|
| bytes_processed_so_far_ += kPointerSize;
|
| current++;
|
| }
|
|
|