| 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/v8.h" | 5 #include "src/v8.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 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 // This routine writes the new object into the pointer provided and then | 785 // This routine writes the new object into the pointer provided and then |
| 786 // returns true if the new object was in young space and false otherwise. | 786 // returns true if the new object was in young space and false otherwise. |
| 787 // The reason for this strange interface is that otherwise the object is | 787 // The reason for this strange interface is that otherwise the object is |
| 788 // written very late, which means the FreeSpace map is not set up by the | 788 // written very late, which means the FreeSpace map is not set up by the |
| 789 // time we need to use it to mark the space at the end of a page free. | 789 // time we need to use it to mark the space at the end of a page free. |
| 790 void Deserializer::ReadObject(int space_number, Object** write_back) { | 790 void Deserializer::ReadObject(int space_number, Object** write_back) { |
| 791 Address address; | 791 Address address; |
| 792 HeapObject* obj; | 792 HeapObject* obj; |
| 793 int next_int = source_.GetInt(); | 793 int next_int = source_.GetInt(); |
| 794 | 794 |
| 795 bool double_align = false; | |
| 796 #ifndef V8_HOST_ARCH_64_BIT | |
| 797 double_align = next_int == kDoubleAlignmentSentinel; | |
| 798 if (double_align) next_int = source_.GetInt(); | |
| 799 #endif | |
| 800 | |
| 801 DCHECK_NE(kDoubleAlignmentSentinel, next_int); | 795 DCHECK_NE(kDoubleAlignmentSentinel, next_int); |
| 802 int size = next_int << kObjectAlignmentBits; | 796 int size = next_int << kObjectAlignmentBits; |
| 803 int reserved_size = size + (double_align ? kPointerSize : 0); | 797 address = Allocate(space_number, size); |
| 804 address = Allocate(space_number, reserved_size); | |
| 805 obj = HeapObject::FromAddress(address); | 798 obj = HeapObject::FromAddress(address); |
| 806 if (double_align) { | |
| 807 obj = isolate_->heap()->DoubleAlignForDeserialization(obj, reserved_size); | |
| 808 address = obj->address(); | |
| 809 } | |
| 810 | 799 |
| 811 isolate_->heap()->OnAllocationEvent(obj, size); | 800 isolate_->heap()->OnAllocationEvent(obj, size); |
| 812 Object** current = reinterpret_cast<Object**>(address); | 801 Object** current = reinterpret_cast<Object**>(address); |
| 813 Object** limit = current + (size >> kPointerSizeLog2); | 802 Object** limit = current + (size >> kPointerSizeLog2); |
| 814 if (FLAG_log_snapshot_positions) { | 803 if (FLAG_log_snapshot_positions) { |
| 815 LOG(isolate_, SnapshotPositionEvent(address, source_.position())); | 804 LOG(isolate_, SnapshotPositionEvent(address, source_.position())); |
| 816 } | 805 } |
| 817 | 806 |
| 818 if (ReadData(current, limit, space_number, address)) { | 807 if (ReadData(current, limit, space_number, address)) { |
| 819 // Only post process if object content has not been deferred. | 808 // Only post process if object content has not been deferred. |
| (...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1675 sink_->Put(kNewObject + reference_representation_ + space, | 1664 sink_->Put(kNewObject + reference_representation_ + space, |
| 1676 "NewLargeObject"); | 1665 "NewLargeObject"); |
| 1677 sink_->PutInt(size >> kObjectAlignmentBits, "ObjectSizeInWords"); | 1666 sink_->PutInt(size >> kObjectAlignmentBits, "ObjectSizeInWords"); |
| 1678 if (object_->IsCode()) { | 1667 if (object_->IsCode()) { |
| 1679 sink_->Put(EXECUTABLE, "executable large object"); | 1668 sink_->Put(EXECUTABLE, "executable large object"); |
| 1680 } else { | 1669 } else { |
| 1681 sink_->Put(NOT_EXECUTABLE, "not executable large object"); | 1670 sink_->Put(NOT_EXECUTABLE, "not executable large object"); |
| 1682 } | 1671 } |
| 1683 back_reference = serializer_->AllocateLargeObject(size); | 1672 back_reference = serializer_->AllocateLargeObject(size); |
| 1684 } else { | 1673 } else { |
| 1685 bool needs_double_align = false; | 1674 back_reference = serializer_->Allocate(space, size); |
| 1686 if (object_->NeedsToEnsureDoubleAlignment()) { | |
| 1687 // Add wriggle room for double alignment padding. | |
| 1688 back_reference = serializer_->Allocate(space, size + kPointerSize); | |
| 1689 needs_double_align = true; | |
| 1690 } else { | |
| 1691 back_reference = serializer_->Allocate(space, size); | |
| 1692 } | |
| 1693 sink_->Put(kNewObject + reference_representation_ + space, "NewObject"); | 1675 sink_->Put(kNewObject + reference_representation_ + space, "NewObject"); |
| 1694 if (needs_double_align) | |
| 1695 sink_->PutInt(kDoubleAlignmentSentinel, "DoubleAlignSentinel"); | |
| 1696 int encoded_size = size >> kObjectAlignmentBits; | 1676 int encoded_size = size >> kObjectAlignmentBits; |
| 1697 DCHECK_NE(kDoubleAlignmentSentinel, encoded_size); | 1677 DCHECK_NE(kDoubleAlignmentSentinel, encoded_size); |
| 1698 sink_->PutInt(encoded_size, "ObjectSizeInWords"); | 1678 sink_->PutInt(encoded_size, "ObjectSizeInWords"); |
| 1699 } | 1679 } |
| 1700 | 1680 |
| 1701 // Mark this object as already serialized. | 1681 // Mark this object as already serialized. |
| 1702 serializer_->back_reference_map()->Add(object_, back_reference); | 1682 serializer_->back_reference_map()->Add(object_, back_reference); |
| 1703 | 1683 |
| 1704 // Serialize the map (first word of the object). | 1684 // Serialize the map (first word of the object). |
| 1705 serializer_->SerializeObject(map, kPlain, kStartOfObject, 0); | 1685 serializer_->SerializeObject(map, kPlain, kStartOfObject, 0); |
| (...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2627 DisallowHeapAllocation no_gc; | 2607 DisallowHeapAllocation no_gc; |
| 2628 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2608 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
| 2629 SanityCheckResult r = scd->SanityCheck(isolate, source); | 2609 SanityCheckResult r = scd->SanityCheck(isolate, source); |
| 2630 if (r == CHECK_SUCCESS) return scd; | 2610 if (r == CHECK_SUCCESS) return scd; |
| 2631 cached_data->Reject(); | 2611 cached_data->Reject(); |
| 2632 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2612 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
| 2633 delete scd; | 2613 delete scd; |
| 2634 return NULL; | 2614 return NULL; |
| 2635 } | 2615 } |
| 2636 } } // namespace v8::internal | 2616 } } // namespace v8::internal |
| OLD | NEW |