| 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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 // process. It is also called on the body of each function. | 653 // process. It is also called on the body of each function. |
| 654 void Deserializer::VisitPointers(Object** start, Object** end) { | 654 void Deserializer::VisitPointers(Object** start, Object** end) { |
| 655 // The space must be new space. Any other space would cause ReadChunk to try | 655 // The space must be new space. Any other space would cause ReadChunk to try |
| 656 // to update the remembered using NULL as the address. | 656 // to update the remembered using NULL as the address. |
| 657 ReadData(start, end, NEW_SPACE, NULL); | 657 ReadData(start, end, NEW_SPACE, NULL); |
| 658 } | 658 } |
| 659 | 659 |
| 660 | 660 |
| 661 void Deserializer::DeserializeDeferredObjects() { | 661 void Deserializer::DeserializeDeferredObjects() { |
| 662 for (int code = source_.Get(); code != kSynchronize; code = source_.Get()) { | 662 for (int code = source_.Get(); code != kSynchronize; code = source_.Get()) { |
| 663 int space = code & kSpaceMask; | 663 switch (code) { |
| 664 DCHECK(space <= kNumberOfSpaces); | 664 case kAlignmentPrefix: |
| 665 DCHECK(code - space == kNewObject); | 665 case kAlignmentPrefix + 1: |
| 666 HeapObject* object = GetBackReferencedObject(space); | 666 case kAlignmentPrefix + 2: |
| 667 int size = source_.GetInt() << kPointerSizeLog2; | 667 SetAlignment(code); |
| 668 Address obj_address = object->address(); | 668 break; |
| 669 Object** start = reinterpret_cast<Object**>(obj_address + kPointerSize); | 669 default: { |
| 670 Object** end = reinterpret_cast<Object**>(obj_address + size); | 670 int space = code & kSpaceMask; |
| 671 bool filled = ReadData(start, end, space, obj_address); | 671 DCHECK(space <= kNumberOfSpaces); |
| 672 CHECK(filled); | 672 DCHECK(code - space == kNewObject); |
| 673 DCHECK(CanBeDeferred(object)); | 673 HeapObject* object = GetBackReferencedObject(space); |
| 674 PostProcessNewObject(object, space); | 674 int size = source_.GetInt() << kPointerSizeLog2; |
| 675 Address obj_address = object->address(); |
| 676 Object** start = reinterpret_cast<Object**>(obj_address + kPointerSize); |
| 677 Object** end = reinterpret_cast<Object**>(obj_address + size); |
| 678 bool filled = ReadData(start, end, space, obj_address); |
| 679 CHECK(filled); |
| 680 DCHECK(CanBeDeferred(object)); |
| 681 PostProcessNewObject(object, space); |
| 682 } |
| 683 } |
| 675 } | 684 } |
| 676 } | 685 } |
| 677 | 686 |
| 678 | 687 |
| 679 // Used to insert a deserialized internalized string into the string table. | 688 // Used to insert a deserialized internalized string into the string table. |
| 680 class StringTableInsertionKey : public HashTableKey { | 689 class StringTableInsertionKey : public HashTableKey { |
| 681 public: | 690 public: |
| 682 explicit StringTableInsertionKey(String* string) | 691 explicit StringTableInsertionKey(String* string) |
| 683 : string_(string), hash_(HashForObject(string)) { | 692 : string_(string), hash_(HashForObject(string)) { |
| 684 DCHECK(string->IsInternalizedString()); | 693 DCHECK(string->IsInternalizedString()); |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1205 case kVariableRepeat: { | 1214 case kVariableRepeat: { |
| 1206 int repeats = source_.GetInt(); | 1215 int repeats = source_.GetInt(); |
| 1207 Object* object = current[-1]; | 1216 Object* object = current[-1]; |
| 1208 DCHECK(!isolate->heap()->InNewSpace(object)); | 1217 DCHECK(!isolate->heap()->InNewSpace(object)); |
| 1209 for (int i = 0; i < repeats; i++) UnalignedCopy(current++, &object); | 1218 for (int i = 0; i < repeats; i++) UnalignedCopy(current++, &object); |
| 1210 break; | 1219 break; |
| 1211 } | 1220 } |
| 1212 | 1221 |
| 1213 case kAlignmentPrefix: | 1222 case kAlignmentPrefix: |
| 1214 case kAlignmentPrefix + 1: | 1223 case kAlignmentPrefix + 1: |
| 1215 case kAlignmentPrefix + 2: { | 1224 case kAlignmentPrefix + 2: |
| 1216 DCHECK_EQ(kWordAligned, next_alignment_); | 1225 SetAlignment(data); |
| 1217 next_alignment_ = | |
| 1218 static_cast<AllocationAlignment>(data - (kAlignmentPrefix - 1)); | |
| 1219 break; | 1226 break; |
| 1220 } | |
| 1221 | 1227 |
| 1222 STATIC_ASSERT(kNumberOfRootArrayConstants == Heap::kOldSpaceRoots); | 1228 STATIC_ASSERT(kNumberOfRootArrayConstants == Heap::kOldSpaceRoots); |
| 1223 STATIC_ASSERT(kNumberOfRootArrayConstants == 32); | 1229 STATIC_ASSERT(kNumberOfRootArrayConstants == 32); |
| 1224 SIXTEEN_CASES(kRootArrayConstantsWithSkip) | 1230 SIXTEEN_CASES(kRootArrayConstantsWithSkip) |
| 1225 SIXTEEN_CASES(kRootArrayConstantsWithSkip + 16) { | 1231 SIXTEEN_CASES(kRootArrayConstantsWithSkip + 16) { |
| 1226 int skip = source_.GetInt(); | 1232 int skip = source_.GetInt(); |
| 1227 current = reinterpret_cast<Object**>( | 1233 current = reinterpret_cast<Object**>( |
| 1228 reinterpret_cast<intptr_t>(current) + skip); | 1234 reinterpret_cast<intptr_t>(current) + skip); |
| 1229 // Fall through. | 1235 // Fall through. |
| 1230 } | 1236 } |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2075 } | 2081 } |
| 2076 | 2082 |
| 2077 int size = object_->Size(); | 2083 int size = object_->Size(); |
| 2078 Map* map = object_->map(); | 2084 Map* map = object_->map(); |
| 2079 BackReference reference = serializer_->back_reference_map()->Lookup(object_); | 2085 BackReference reference = serializer_->back_reference_map()->Lookup(object_); |
| 2080 | 2086 |
| 2081 // Serialize the rest of the object. | 2087 // Serialize the rest of the object. |
| 2082 CHECK_EQ(0, bytes_processed_so_far_); | 2088 CHECK_EQ(0, bytes_processed_so_far_); |
| 2083 bytes_processed_so_far_ = kPointerSize; | 2089 bytes_processed_so_far_ = kPointerSize; |
| 2084 | 2090 |
| 2091 serializer_->PutAlignmentPrefix(object_); |
| 2085 sink_->Put(kNewObject + reference.space(), "deferred object"); | 2092 sink_->Put(kNewObject + reference.space(), "deferred object"); |
| 2086 serializer_->PutBackReference(object_, reference); | 2093 serializer_->PutBackReference(object_, reference); |
| 2087 sink_->PutInt(size >> kPointerSizeLog2, "deferred object size"); | 2094 sink_->PutInt(size >> kPointerSizeLog2, "deferred object size"); |
| 2088 | 2095 |
| 2089 UnlinkWeakCellScope unlink_weak_cell(object_); | 2096 UnlinkWeakCellScope unlink_weak_cell(object_); |
| 2090 | 2097 |
| 2091 object_->IterateBody(map->instance_type(), size, this); | 2098 object_->IterateBody(map->instance_type(), size, this); |
| 2092 OutputRawData(object_->address() + size); | 2099 OutputRawData(object_->address() + size); |
| 2093 } | 2100 } |
| 2094 | 2101 |
| (...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2881 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2888 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
| 2882 SanityCheckResult r = scd->SanityCheck(isolate, source); | 2889 SanityCheckResult r = scd->SanityCheck(isolate, source); |
| 2883 if (r == CHECK_SUCCESS) return scd; | 2890 if (r == CHECK_SUCCESS) return scd; |
| 2884 cached_data->Reject(); | 2891 cached_data->Reject(); |
| 2885 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2892 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
| 2886 delete scd; | 2893 delete scd; |
| 2887 return NULL; | 2894 return NULL; |
| 2888 } | 2895 } |
| 2889 } // namespace internal | 2896 } // namespace internal |
| 2890 } // namespace v8 | 2897 } // namespace v8 |
| OLD | NEW |