OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/snapshot/serialize.h" | 5 #include "src/snapshot/serialize.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 // process. It is also called on the body of each function. | 629 // process. It is also called on the body of each function. |
630 void Deserializer::VisitPointers(Object** start, Object** end) { | 630 void Deserializer::VisitPointers(Object** start, Object** end) { |
631 // The space must be new space. Any other space would cause ReadChunk to try | 631 // The space must be new space. Any other space would cause ReadChunk to try |
632 // to update the remembered using NULL as the address. | 632 // to update the remembered using NULL as the address. |
633 ReadData(start, end, NEW_SPACE, NULL); | 633 ReadData(start, end, NEW_SPACE, NULL); |
634 } | 634 } |
635 | 635 |
636 | 636 |
637 void Deserializer::DeserializeDeferredObjects() { | 637 void Deserializer::DeserializeDeferredObjects() { |
638 for (int code = source_.Get(); code != kSynchronize; code = source_.Get()) { | 638 for (int code = source_.Get(); code != kSynchronize; code = source_.Get()) { |
639 int space = code & kSpaceMask; | 639 switch (code) { |
640 DCHECK(space <= kNumberOfSpaces); | 640 case kAlignmentPrefix: |
641 DCHECK(code - space == kNewObject); | 641 case kAlignmentPrefix + 1: |
642 HeapObject* object = GetBackReferencedObject(space); | 642 case kAlignmentPrefix + 2: |
643 int size = source_.GetInt() << kPointerSizeLog2; | 643 SetAlignment(code); |
644 Address obj_address = object->address(); | 644 break; |
645 Object** start = reinterpret_cast<Object**>(obj_address + kPointerSize); | 645 default: { |
646 Object** end = reinterpret_cast<Object**>(obj_address + size); | 646 int space = code & kSpaceMask; |
647 bool filled = ReadData(start, end, space, obj_address); | 647 DCHECK(space <= kNumberOfSpaces); |
648 CHECK(filled); | 648 DCHECK(code - space == kNewObject); |
649 DCHECK(CanBeDeferred(object)); | 649 HeapObject* object = GetBackReferencedObject(space); |
650 PostProcessNewObject(object, space); | 650 int size = source_.GetInt() << kPointerSizeLog2; |
| 651 Address obj_address = object->address(); |
| 652 Object** start = reinterpret_cast<Object**>(obj_address + kPointerSize); |
| 653 Object** end = reinterpret_cast<Object**>(obj_address + size); |
| 654 bool filled = ReadData(start, end, space, obj_address); |
| 655 CHECK(filled); |
| 656 DCHECK(CanBeDeferred(object)); |
| 657 PostProcessNewObject(object, space); |
| 658 } |
| 659 } |
651 } | 660 } |
652 } | 661 } |
653 | 662 |
654 | 663 |
655 // Used to insert a deserialized internalized string into the string table. | 664 // Used to insert a deserialized internalized string into the string table. |
656 class StringTableInsertionKey : public HashTableKey { | 665 class StringTableInsertionKey : public HashTableKey { |
657 public: | 666 public: |
658 explicit StringTableInsertionKey(String* string) | 667 explicit StringTableInsertionKey(String* string) |
659 : string_(string), hash_(HashForObject(string)) { | 668 : string_(string), hash_(HashForObject(string)) { |
660 DCHECK(string->IsInternalizedString()); | 669 DCHECK(string->IsInternalizedString()); |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 case kVariableRepeat: { | 1190 case kVariableRepeat: { |
1182 int repeats = source_.GetInt(); | 1191 int repeats = source_.GetInt(); |
1183 Object* object = current[-1]; | 1192 Object* object = current[-1]; |
1184 DCHECK(!isolate->heap()->InNewSpace(object)); | 1193 DCHECK(!isolate->heap()->InNewSpace(object)); |
1185 for (int i = 0; i < repeats; i++) UnalignedCopy(current++, &object); | 1194 for (int i = 0; i < repeats; i++) UnalignedCopy(current++, &object); |
1186 break; | 1195 break; |
1187 } | 1196 } |
1188 | 1197 |
1189 case kAlignmentPrefix: | 1198 case kAlignmentPrefix: |
1190 case kAlignmentPrefix + 1: | 1199 case kAlignmentPrefix + 1: |
1191 case kAlignmentPrefix + 2: { | 1200 case kAlignmentPrefix + 2: |
1192 DCHECK_EQ(kWordAligned, next_alignment_); | 1201 SetAlignment(data); |
1193 next_alignment_ = | |
1194 static_cast<AllocationAlignment>(data - (kAlignmentPrefix - 1)); | |
1195 break; | 1202 break; |
1196 } | |
1197 | 1203 |
1198 STATIC_ASSERT(kNumberOfRootArrayConstants == Heap::kOldSpaceRoots); | 1204 STATIC_ASSERT(kNumberOfRootArrayConstants == Heap::kOldSpaceRoots); |
1199 STATIC_ASSERT(kNumberOfRootArrayConstants == 32); | 1205 STATIC_ASSERT(kNumberOfRootArrayConstants == 32); |
1200 SIXTEEN_CASES(kRootArrayConstantsWithSkip) | 1206 SIXTEEN_CASES(kRootArrayConstantsWithSkip) |
1201 SIXTEEN_CASES(kRootArrayConstantsWithSkip + 16) { | 1207 SIXTEEN_CASES(kRootArrayConstantsWithSkip + 16) { |
1202 int skip = source_.GetInt(); | 1208 int skip = source_.GetInt(); |
1203 current = reinterpret_cast<Object**>( | 1209 current = reinterpret_cast<Object**>( |
1204 reinterpret_cast<intptr_t>(current) + skip); | 1210 reinterpret_cast<intptr_t>(current) + skip); |
1205 // Fall through. | 1211 // Fall through. |
1206 } | 1212 } |
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2050 } | 2056 } |
2051 | 2057 |
2052 int size = object_->Size(); | 2058 int size = object_->Size(); |
2053 Map* map = object_->map(); | 2059 Map* map = object_->map(); |
2054 BackReference reference = serializer_->back_reference_map()->Lookup(object_); | 2060 BackReference reference = serializer_->back_reference_map()->Lookup(object_); |
2055 | 2061 |
2056 // Serialize the rest of the object. | 2062 // Serialize the rest of the object. |
2057 CHECK_EQ(0, bytes_processed_so_far_); | 2063 CHECK_EQ(0, bytes_processed_so_far_); |
2058 bytes_processed_so_far_ = kPointerSize; | 2064 bytes_processed_so_far_ = kPointerSize; |
2059 | 2065 |
| 2066 serializer_->PutAlignmentPrefix(object_); |
2060 sink_->Put(kNewObject + reference.space(), "deferred object"); | 2067 sink_->Put(kNewObject + reference.space(), "deferred object"); |
2061 serializer_->PutBackReference(object_, reference); | 2068 serializer_->PutBackReference(object_, reference); |
2062 sink_->PutInt(size >> kPointerSizeLog2, "deferred object size"); | 2069 sink_->PutInt(size >> kPointerSizeLog2, "deferred object size"); |
2063 | 2070 |
2064 UnlinkWeakCellScope unlink_weak_cell(object_); | 2071 UnlinkWeakCellScope unlink_weak_cell(object_); |
2065 | 2072 |
2066 object_->IterateBody(map->instance_type(), size, this); | 2073 object_->IterateBody(map->instance_type(), size, this); |
2067 OutputRawData(object_->address() + size); | 2074 OutputRawData(object_->address() + size); |
2068 } | 2075 } |
2069 | 2076 |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2849 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2856 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
2850 SanityCheckResult r = scd->SanityCheck(isolate, source); | 2857 SanityCheckResult r = scd->SanityCheck(isolate, source); |
2851 if (r == CHECK_SUCCESS) return scd; | 2858 if (r == CHECK_SUCCESS) return scd; |
2852 cached_data->Reject(); | 2859 cached_data->Reject(); |
2853 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2860 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
2854 delete scd; | 2861 delete scd; |
2855 return NULL; | 2862 return NULL; |
2856 } | 2863 } |
2857 } // namespace internal | 2864 } // namespace internal |
2858 } // namespace v8 | 2865 } // namespace v8 |
OLD | NEW |