Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: runtime/vm/snapshot.cc

Issue 2953753002: Revert "Inline instance object hash code into object header on 64 bit." (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/snapshot.h ('k') | runtime/vm/stub_code_arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/snapshot.h" 5 #include "vm/snapshot.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/bootstrap.h" 8 #include "vm/bootstrap.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 const Object& obj = *objects_[i].obj_; 748 const Object& obj = *objects_[i].obj_;
749 749
750 NoSafepointScope no_safepoint; 750 NoSafepointScope no_safepoint;
751 uword start = reinterpret_cast<uword>(obj.raw()) - kHeapObjectTag; 751 uword start = reinterpret_cast<uword>(obj.raw()) - kHeapObjectTag;
752 uword end = start + obj.raw()->Size(); 752 uword end = start + obj.raw()->Size();
753 753
754 // Write object header with the mark and VM heap bits set. 754 // Write object header with the mark and VM heap bits set.
755 uword marked_tags = obj.raw()->ptr()->tags_; 755 uword marked_tags = obj.raw()->ptr()->tags_;
756 marked_tags = RawObject::VMHeapObjectTag::update(true, marked_tags); 756 marked_tags = RawObject::VMHeapObjectTag::update(true, marked_tags);
757 marked_tags = RawObject::MarkBit::update(true, marked_tags); 757 marked_tags = RawObject::MarkBit::update(true, marked_tags);
758 #if defined(HASH_IN_OBJECT_HEADER)
759 marked_tags |= static_cast<uword>(obj.raw()->ptr()->hash_) << 32;
760 #endif
761 stream->WriteWord(marked_tags); 758 stream->WriteWord(marked_tags);
762 start += sizeof(uword); 759 start += sizeof(uword);
763 for (uword* cursor = reinterpret_cast<uword*>(start); 760 for (uword* cursor = reinterpret_cast<uword*>(start);
764 cursor < reinterpret_cast<uword*>(end); cursor++) { 761 cursor < reinterpret_cast<uword*>(end); cursor++) {
765 stream->WriteWord(*cursor); 762 stream->WriteWord(*cursor);
766 } 763 }
767 } 764 }
768 } 765 }
769 766
770 767
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 { 834 {
838 NoSafepointScope no_safepoint; 835 NoSafepointScope no_safepoint;
839 836
840 uword beginning = reinterpret_cast<uword>(insns.raw_ptr()); 837 uword beginning = reinterpret_cast<uword>(insns.raw_ptr());
841 uword entry = beginning + Instructions::HeaderSize(); 838 uword entry = beginning + Instructions::HeaderSize();
842 839
843 // Write Instructions with the mark and VM heap bits set. 840 // Write Instructions with the mark and VM heap bits set.
844 uword marked_tags = insns.raw_ptr()->tags_; 841 uword marked_tags = insns.raw_ptr()->tags_;
845 marked_tags = RawObject::VMHeapObjectTag::update(true, marked_tags); 842 marked_tags = RawObject::VMHeapObjectTag::update(true, marked_tags);
846 marked_tags = RawObject::MarkBit::update(true, marked_tags); 843 marked_tags = RawObject::MarkBit::update(true, marked_tags);
847 #if defined(HASH_IN_OBJECT_HEADER)
848 // Can't use GetObjectTagsAndHash because the update methods discard the
849 // high bits.
850 marked_tags |= static_cast<uword>(insns.raw_ptr()->hash_) << 32;
851 #endif
852 844
853 WriteWordLiteralText(marked_tags); 845 WriteWordLiteralText(marked_tags);
854 beginning += sizeof(uword); 846 beginning += sizeof(uword);
855 847
856 WriteByteSequence(beginning, entry); 848 WriteByteSequence(beginning, entry);
857 } 849 }
858 850
859 // 2. Write a label at the entry point. 851 // 2. Write a label at the entry point.
860 // Linux's perf uses these labels. 852 // Linux's perf uses these labels.
861 owner = code.owner(); 853 owner = code.owner();
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 payload_size = Utils::RoundUp(payload_size, OS::PreferredCodeAlignment()); 1039 payload_size = Utils::RoundUp(payload_size, OS::PreferredCodeAlignment());
1048 uword end = entry + payload_size; 1040 uword end = entry + payload_size;
1049 1041
1050 ASSERT(Utils::IsAligned(beginning, sizeof(uword))); 1042 ASSERT(Utils::IsAligned(beginning, sizeof(uword)));
1051 ASSERT(Utils::IsAligned(entry, sizeof(uword))); 1043 ASSERT(Utils::IsAligned(entry, sizeof(uword)));
1052 1044
1053 // Write Instructions with the mark and VM heap bits set. 1045 // Write Instructions with the mark and VM heap bits set.
1054 uword marked_tags = insns.raw_ptr()->tags_; 1046 uword marked_tags = insns.raw_ptr()->tags_;
1055 marked_tags = RawObject::VMHeapObjectTag::update(true, marked_tags); 1047 marked_tags = RawObject::VMHeapObjectTag::update(true, marked_tags);
1056 marked_tags = RawObject::MarkBit::update(true, marked_tags); 1048 marked_tags = RawObject::MarkBit::update(true, marked_tags);
1057 #if defined(HASH_IN_OBJECT_HEADER)
1058 // Can't use GetObjectTagsAndHash because the update methods discard the
1059 // high bits.
1060 marked_tags |= static_cast<uword>(insns.raw_ptr()->hash_) << 32;
1061 #endif
1062 1049
1063 instructions_blob_stream_.WriteWord(marked_tags); 1050 instructions_blob_stream_.WriteWord(marked_tags);
1064 beginning += sizeof(uword); 1051 beginning += sizeof(uword);
1065 1052
1066 for (uword* cursor = reinterpret_cast<uword*>(beginning); 1053 for (uword* cursor = reinterpret_cast<uword*>(beginning);
1067 cursor < reinterpret_cast<uword*>(end); cursor++) { 1054 cursor < reinterpret_cast<uword*>(end); cursor++) {
1068 instructions_blob_stream_.WriteWord(*cursor); 1055 instructions_blob_stream_.WriteWord(*cursor);
1069 } 1056 }
1070 } 1057 }
1071 } 1058 }
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 ASSERT(forward_list_ != NULL); 1343 ASSERT(forward_list_ != NULL);
1357 } 1344 }
1358 1345
1359 1346
1360 void SnapshotWriter::WriteObject(RawObject* rawobj) { 1347 void SnapshotWriter::WriteObject(RawObject* rawobj) {
1361 WriteObjectImpl(rawobj, kAsInlinedObject); 1348 WriteObjectImpl(rawobj, kAsInlinedObject);
1362 WriteForwardedObjects(); 1349 WriteForwardedObjects();
1363 } 1350 }
1364 1351
1365 1352
1366 uint32_t SnapshotWriter::GetObjectTags(RawObject* raw) { 1353 uword SnapshotWriter::GetObjectTags(RawObject* raw) {
1367 return raw->ptr()->tags_; 1354 return raw->ptr()->tags_;
1368 } 1355 }
1369 1356
1370 1357
1371 uword SnapshotWriter::GetObjectTagsAndHash(RawObject* raw) {
1372 uword result = raw->ptr()->tags_;
1373 #if defined(HASH_IN_OBJECT_HEADER)
1374 result |= static_cast<uword>(raw->ptr()->hash_) << 32;
1375 #endif
1376 return result;
1377 }
1378
1379
1380 #define VM_OBJECT_CLASS_LIST(V) \ 1358 #define VM_OBJECT_CLASS_LIST(V) \
1381 V(OneByteString) \ 1359 V(OneByteString) \
1382 V(TwoByteString) \ 1360 V(TwoByteString) \
1383 V(Mint) \ 1361 V(Mint) \
1384 V(Bigint) \ 1362 V(Bigint) \
1385 V(Double) \ 1363 V(Double) \
1386 V(ImmutableArray) 1364 V(ImmutableArray)
1387 1365
1388 #define VM_OBJECT_WRITE(clazz) \ 1366 #define VM_OBJECT_WRITE(clazz) \
1389 case clazz::kClassId: { \ 1367 case clazz::kClassId: { \
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1593 1571
1594 void SnapshotWriter::WriteObjectImpl(RawObject* raw, bool as_reference) { 1572 void SnapshotWriter::WriteObjectImpl(RawObject* raw, bool as_reference) {
1595 // First check if object can be written as a simple predefined type. 1573 // First check if object can be written as a simple predefined type.
1596 if (CheckAndWritePredefinedObject(raw)) { 1574 if (CheckAndWritePredefinedObject(raw)) {
1597 return; 1575 return;
1598 } 1576 }
1599 1577
1600 // When we know that we are dealing with leaf or shallow objects we write 1578 // When we know that we are dealing with leaf or shallow objects we write
1601 // these objects inline even when 'as_reference' is true. 1579 // these objects inline even when 'as_reference' is true.
1602 const bool write_as_reference = as_reference && !raw->IsCanonical(); 1580 const bool write_as_reference = as_reference && !raw->IsCanonical();
1603 uintptr_t tags = GetObjectTagsAndHash(raw); 1581 intptr_t tags = raw->ptr()->tags_;
1604 1582
1605 // Add object to the forward ref list and mark it so that future references 1583 // Add object to the forward ref list and mark it so that future references
1606 // to this object in the snapshot will use this object id. Mark the 1584 // to this object in the snapshot will use this object id. Mark the
1607 // serialization state so that we do the right thing when we go through 1585 // serialization state so that we do the right thing when we go through
1608 // the forward list. 1586 // the forward list.
1609 intptr_t class_id = raw->GetClassId(); 1587 intptr_t class_id = raw->GetClassId();
1610 intptr_t object_id; 1588 intptr_t object_id;
1611 if (write_as_reference && IsSplitClassId(class_id)) { 1589 if (write_as_reference && IsSplitClassId(class_id)) {
1612 object_id = forward_list_->AddObject(zone(), raw, kIsNotSerialized); 1590 object_id = forward_list_->AddObject(zone(), raw, kIsNotSerialized);
1613 } else { 1591 } else {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 1648
1671 1649
1672 class WriteInlinedObjectVisitor : public ObjectVisitor { 1650 class WriteInlinedObjectVisitor : public ObjectVisitor {
1673 public: 1651 public:
1674 explicit WriteInlinedObjectVisitor(SnapshotWriter* writer) 1652 explicit WriteInlinedObjectVisitor(SnapshotWriter* writer)
1675 : writer_(writer) {} 1653 : writer_(writer) {}
1676 1654
1677 virtual void VisitObject(RawObject* obj) { 1655 virtual void VisitObject(RawObject* obj) {
1678 intptr_t object_id = writer_->forward_list_->FindObject(obj); 1656 intptr_t object_id = writer_->forward_list_->FindObject(obj);
1679 ASSERT(object_id != kInvalidIndex); 1657 ASSERT(object_id != kInvalidIndex);
1680 intptr_t tags = MessageWriter::GetObjectTagsAndHash(obj); 1658 intptr_t tags = writer_->GetObjectTags(obj);
1681 writer_->WriteMarkedObjectImpl(obj, tags, object_id, kAsInlinedObject); 1659 writer_->WriteMarkedObjectImpl(obj, tags, object_id, kAsInlinedObject);
1682 } 1660 }
1683 1661
1684 private: 1662 private:
1685 SnapshotWriter* writer_; 1663 SnapshotWriter* writer_;
1686 }; 1664 };
1687 1665
1688 1666
1689 void SnapshotWriter::WriteForwardedObjects() { 1667 void SnapshotWriter::WriteForwardedObjects() {
1690 WriteInlinedObjectVisitor visitor(this); 1668 WriteInlinedObjectVisitor visitor(this);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1835 thread()->zone(), 1813 thread()->zone(),
1836 "Illegal argument in isolate message : (object is a closure - %s)", 1814 "Illegal argument in isolate message : (object is a closure - %s)",
1837 errorFunc.ToCString()); 1815 errorFunc.ToCString());
1838 SetWriteException(Exceptions::kArgument, chars); 1816 SetWriteException(Exceptions::kArgument, chars);
1839 return Function::null(); 1817 return Function::null();
1840 } 1818 }
1841 1819
1842 1820
1843 RawClass* SnapshotWriter::GetFunctionOwner(RawFunction* func) { 1821 RawClass* SnapshotWriter::GetFunctionOwner(RawFunction* func) {
1844 RawObject* owner = func->ptr()->owner_; 1822 RawObject* owner = func->ptr()->owner_;
1845 uint32_t tags = GetObjectTags(owner); 1823 uword tags = GetObjectTags(owner);
1846 intptr_t class_id = RawObject::ClassIdTag::decode(tags); 1824 intptr_t class_id = RawObject::ClassIdTag::decode(tags);
1847 if (class_id == kClassCid) { 1825 if (class_id == kClassCid) {
1848 return reinterpret_cast<RawClass*>(owner); 1826 return reinterpret_cast<RawClass*>(owner);
1849 } 1827 }
1850 ASSERT(class_id == kPatchClassCid); 1828 ASSERT(class_id == kPatchClassCid);
1851 return reinterpret_cast<RawPatchClass*>(owner)->ptr()->patched_class_; 1829 return reinterpret_cast<RawPatchClass*>(owner)->ptr()->patched_class_;
1852 } 1830 }
1853 1831
1854 1832
1855 void SnapshotWriter::CheckForNativeFields(RawClass* cls) { 1833 void SnapshotWriter::CheckForNativeFields(RawClass* cls) {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
2066 *buffer_len_ = BytesWritten(); 2044 *buffer_len_ = BytesWritten();
2067 } 2045 }
2068 } else { 2046 } else {
2069 FreeBuffer(); 2047 FreeBuffer();
2070 ThrowException(exception_type(), exception_msg()); 2048 ThrowException(exception_type(), exception_msg());
2071 } 2049 }
2072 } 2050 }
2073 2051
2074 2052
2075 } // namespace dart 2053 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/snapshot.h ('k') | runtime/vm/stub_code_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698