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

Side by Side Diff: src/serialize.cc

Issue 190883002: Update serializer to be able to deal with ool constant pool. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 // code object. 1137 // code object.
1138 CASE_STATEMENT(kNewObject, kPlain, kInnerPointer, CODE_SPACE) 1138 CASE_STATEMENT(kNewObject, kPlain, kInnerPointer, CODE_SPACE)
1139 CASE_BODY(kNewObject, kPlain, kInnerPointer, CODE_SPACE) 1139 CASE_BODY(kNewObject, kPlain, kInnerPointer, CODE_SPACE)
1140 // Deserialize a new code object and write a pointer to its first 1140 // Deserialize a new code object and write a pointer to its first
1141 // instruction to the current code object. 1141 // instruction to the current code object.
1142 ALL_SPACES(kNewObject, kFromCode, kInnerPointer) 1142 ALL_SPACES(kNewObject, kFromCode, kInnerPointer)
1143 // Find a recently deserialized object using its offset from the current 1143 // Find a recently deserialized object using its offset from the current
1144 // allocation point and write a pointer to it to the current object. 1144 // allocation point and write a pointer to it to the current object.
1145 ALL_SPACES(kBackref, kPlain, kStartOfObject) 1145 ALL_SPACES(kBackref, kPlain, kStartOfObject)
1146 ALL_SPACES(kBackrefWithSkip, kPlain, kStartOfObject) 1146 ALL_SPACES(kBackrefWithSkip, kPlain, kStartOfObject)
1147 #if V8_TARGET_ARCH_MIPS 1147 #if defined(V8_TARGET_ARCH_MIPS) || V8_OOL_CONSTANT_POOL
1148 // Deserialize a new object from pointer found in code and write 1148 // Deserialize a new object from pointer found in code and write
1149 // a pointer to it to the current object. Required only for MIPS, and 1149 // a pointer to it to the current object. Required only for MIPS or ARM
1150 // omitted on the other architectures because it is fully unrolled and 1150 // with ool constant pool, and omitted on the other architectures because
1151 // would cause bloat. 1151 // it is fully unrolled and would cause bloat.
1152 ALL_SPACES(kNewObject, kFromCode, kStartOfObject) 1152 ALL_SPACES(kNewObject, kFromCode, kStartOfObject)
1153 // Find a recently deserialized code object using its offset from the 1153 // Find a recently deserialized code object using its offset from the
1154 // current allocation point and write a pointer to it to the current 1154 // current allocation point and write a pointer to it to the current
1155 // object. Required only for MIPS. 1155 // object. Required only for MIPS or ARM with ool constant pool.
1156 ALL_SPACES(kBackref, kFromCode, kStartOfObject) 1156 ALL_SPACES(kBackref, kFromCode, kStartOfObject)
1157 ALL_SPACES(kBackrefWithSkip, kFromCode, kStartOfObject) 1157 ALL_SPACES(kBackrefWithSkip, kFromCode, kStartOfObject)
1158 #endif 1158 #endif
1159 // Find a recently deserialized code object using its offset from the 1159 // Find a recently deserialized code object using its offset from the
1160 // current allocation point and write a pointer to its first instruction 1160 // current allocation point and write a pointer to its first instruction
1161 // to the current code object or the instruction pointer in a function 1161 // to the current code object or the instruction pointer in a function
1162 // object. 1162 // object.
1163 ALL_SPACES(kBackref, kFromCode, kInnerPointer) 1163 ALL_SPACES(kBackref, kFromCode, kInnerPointer)
1164 ALL_SPACES(kBackrefWithSkip, kFromCode, kInnerPointer) 1164 ALL_SPACES(kBackrefWithSkip, kFromCode, kInnerPointer)
1165 ALL_SPACES(kBackref, kPlain, kInnerPointer) 1165 ALL_SPACES(kBackref, kPlain, kInnerPointer)
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 return length; 1366 return length;
1367 } 1367 }
1368 1368
1369 1369
1370 int Serializer::RootIndex(HeapObject* heap_object, HowToCode from) { 1370 int Serializer::RootIndex(HeapObject* heap_object, HowToCode from) {
1371 Heap* heap = isolate()->heap(); 1371 Heap* heap = isolate()->heap();
1372 if (heap->InNewSpace(heap_object)) return kInvalidRootIndex; 1372 if (heap->InNewSpace(heap_object)) return kInvalidRootIndex;
1373 for (int i = 0; i < root_index_wave_front_; i++) { 1373 for (int i = 0; i < root_index_wave_front_; i++) {
1374 Object* root = heap->roots_array_start()[i]; 1374 Object* root = heap->roots_array_start()[i];
1375 if (!root->IsSmi() && root == heap_object) { 1375 if (!root->IsSmi() && root == heap_object) {
1376 #if V8_TARGET_ARCH_MIPS 1376 #if defined(V8_TARGET_ARCH_MIPS) || V8_OOL_CONSTANT_POOL
1377 if (from == kFromCode) { 1377 if (from == kFromCode) {
1378 // In order to avoid code bloat in the deserializer we don't have 1378 // In order to avoid code bloat in the deserializer we don't have
1379 // support for the encoding that specifies a particular root should 1379 // support for the encoding that specifies a particular root should
1380 // be written into the lui/ori instructions on MIPS. Therefore we 1380 // be written from within code.
1381 // should not generate such serialization data for MIPS.
1382 return kInvalidRootIndex; 1381 return kInvalidRootIndex;
1383 } 1382 }
1384 #endif 1383 #endif
1385 return i; 1384 return i;
1386 } 1385 }
1387 } 1386 }
1388 return kInvalidRootIndex; 1387 return kInvalidRootIndex;
1389 } 1388 }
1390 1389
1391 1390
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 current_contents, kPlain, kStartOfObject, 0); 1623 current_contents, kPlain, kStartOfObject, 0);
1625 bytes_processed_so_far_ += kPointerSize; 1624 bytes_processed_so_far_ += kPointerSize;
1626 current++; 1625 current++;
1627 } 1626 }
1628 } 1627 }
1629 } 1628 }
1630 } 1629 }
1631 1630
1632 1631
1633 void Serializer::ObjectSerializer::VisitEmbeddedPointer(RelocInfo* rinfo) { 1632 void Serializer::ObjectSerializer::VisitEmbeddedPointer(RelocInfo* rinfo) {
1633 // Out-of-line constant pool entries will be visited by the ConstantPoolArray.
1634 if (FLAG_enable_ool_constant_pool && rinfo->IsInConstantPool()) return;
1635
1634 int skip = OutputRawData(rinfo->target_address_address(), 1636 int skip = OutputRawData(rinfo->target_address_address(),
1635 kCanReturnSkipInsteadOfSkipping); 1637 kCanReturnSkipInsteadOfSkipping);
1636 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain; 1638 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain;
1637 Object* object = rinfo->target_object(); 1639 Object* object = rinfo->target_object();
1638 serializer_->SerializeObject(object, how_to_code, kStartOfObject, skip); 1640 serializer_->SerializeObject(object, how_to_code, kStartOfObject, skip);
1639 bytes_processed_so_far_ += rinfo->target_address_size(); 1641 bytes_processed_so_far_ += rinfo->target_address_size();
1640 } 1642 }
1641 1643
1642 1644
1643 void Serializer::ObjectSerializer::VisitExternalReference(Address* p) { 1645 void Serializer::ObjectSerializer::VisitExternalReference(Address* p) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1680 int skip = OutputRawData(target_address_pointer, 1682 int skip = OutputRawData(target_address_pointer,
1681 kCanReturnSkipInsteadOfSkipping); 1683 kCanReturnSkipInsteadOfSkipping);
1682 Code* object = Code::GetCodeFromTargetAddress( 1684 Code* object = Code::GetCodeFromTargetAddress(
1683 Memory::Address_at(target_address_pointer)); 1685 Memory::Address_at(target_address_pointer));
1684 serializer_->SerializeObject(object, kFromCode, kInnerPointer, skip); 1686 serializer_->SerializeObject(object, kFromCode, kInnerPointer, skip);
1685 bytes_processed_so_far_ += kPointerSize; 1687 bytes_processed_so_far_ += kPointerSize;
1686 } 1688 }
1687 1689
1688 1690
1689 void Serializer::ObjectSerializer::VisitCodeTarget(RelocInfo* rinfo) { 1691 void Serializer::ObjectSerializer::VisitCodeTarget(RelocInfo* rinfo) {
1692 // Out-of-line constant pool entries will be visited by the ConstantPoolArray.
1693 if (FLAG_enable_ool_constant_pool && rinfo->IsInConstantPool()) return;
1694
1690 int skip = OutputRawData(rinfo->target_address_address(), 1695 int skip = OutputRawData(rinfo->target_address_address(),
1691 kCanReturnSkipInsteadOfSkipping); 1696 kCanReturnSkipInsteadOfSkipping);
1692 Code* object = Code::GetCodeFromTargetAddress(rinfo->target_address()); 1697 Code* object = Code::GetCodeFromTargetAddress(rinfo->target_address());
1693 serializer_->SerializeObject(object, kFromCode, kInnerPointer, skip); 1698 serializer_->SerializeObject(object, kFromCode, kInnerPointer, skip);
1694 bytes_processed_so_far_ += rinfo->target_address_size(); 1699 bytes_processed_so_far_ += rinfo->target_address_size();
1695 } 1700 }
1696 1701
1697 1702
1698 void Serializer::ObjectSerializer::VisitCodeEntry(Address entry_address) { 1703 void Serializer::ObjectSerializer::VisitCodeEntry(Address entry_address) {
1699 int skip = OutputRawData(entry_address, kCanReturnSkipInsteadOfSkipping); 1704 int skip = OutputRawData(entry_address, kCanReturnSkipInsteadOfSkipping);
1700 Code* object = Code::cast(Code::GetObjectFromEntryAddress(entry_address)); 1705 Code* object = Code::cast(Code::GetObjectFromEntryAddress(entry_address));
1701 serializer_->SerializeObject(object, kPlain, kInnerPointer, skip); 1706 serializer_->SerializeObject(object, kPlain, kInnerPointer, skip);
1702 bytes_processed_so_far_ += kPointerSize; 1707 bytes_processed_so_far_ += kPointerSize;
1703 } 1708 }
1704 1709
1705 1710
1706 void Serializer::ObjectSerializer::VisitCell(RelocInfo* rinfo) { 1711 void Serializer::ObjectSerializer::VisitCell(RelocInfo* rinfo) {
1712 // Out-of-line constant pool entries will be visited by the ConstantPoolArray.
1713 if (FLAG_enable_ool_constant_pool && rinfo->IsInConstantPool()) return;
1714
1707 int skip = OutputRawData(rinfo->pc(), kCanReturnSkipInsteadOfSkipping); 1715 int skip = OutputRawData(rinfo->pc(), kCanReturnSkipInsteadOfSkipping);
1708 Cell* object = Cell::cast(rinfo->target_cell()); 1716 Cell* object = Cell::cast(rinfo->target_cell());
1709 serializer_->SerializeObject(object, kPlain, kInnerPointer, skip); 1717 serializer_->SerializeObject(object, kPlain, kInnerPointer, skip);
1710 } 1718 }
1711 1719
1712 1720
1713 void Serializer::ObjectSerializer::VisitExternalAsciiString( 1721 void Serializer::ObjectSerializer::VisitExternalAsciiString(
1714 v8::String::ExternalAsciiStringResource** resource_pointer) { 1722 v8::String::ExternalAsciiStringResource** resource_pointer) {
1715 Address references_start = reinterpret_cast<Address>(resource_pointer); 1723 Address references_start = reinterpret_cast<Address>(resource_pointer);
1716 OutputRawData(references_start); 1724 OutputRawData(references_start);
(...skipping 25 matching lines...) Expand all
1742 } 1750 }
1743 1751
1744 1752
1745 static void WipeOutRelocations(Code* code) { 1753 static void WipeOutRelocations(Code* code) {
1746 int mode_mask = 1754 int mode_mask =
1747 RelocInfo::kCodeTargetMask | 1755 RelocInfo::kCodeTargetMask |
1748 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | 1756 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
1749 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | 1757 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) |
1750 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY); 1758 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY);
1751 for (RelocIterator it(code, mode_mask); !it.done(); it.next()) { 1759 for (RelocIterator it(code, mode_mask); !it.done(); it.next()) {
1752 it.rinfo()->WipeOut(); 1760 if (!(FLAG_enable_ool_constant_pool && it.rinfo()->IsInConstantPool())) {
1761 it.rinfo()->WipeOut();
1762 }
1753 } 1763 }
1754 } 1764 }
1755 1765
1756 1766
1757 int Serializer::ObjectSerializer::OutputRawData( 1767 int Serializer::ObjectSerializer::OutputRawData(
1758 Address up_to, Serializer::ObjectSerializer::ReturnSkip return_skip) { 1768 Address up_to, Serializer::ObjectSerializer::ReturnSkip return_skip) {
1759 Address object_start = object_->address(); 1769 Address object_start = object_->address();
1760 int base = bytes_processed_so_far_; 1770 int base = bytes_processed_so_far_;
1761 int up_to_offset = static_cast<int>(up_to - object_start); 1771 int up_to_offset = static_cast<int>(up_to - object_start);
1762 int to_skip = up_to_offset - bytes_processed_so_far_; 1772 int to_skip = up_to_offset - bytes_processed_so_far_;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 1864
1855 bool SnapshotByteSource::AtEOF() { 1865 bool SnapshotByteSource::AtEOF() {
1856 if (0u + length_ - position_ > 2 * sizeof(uint32_t)) return false; 1866 if (0u + length_ - position_ > 2 * sizeof(uint32_t)) return false;
1857 for (int x = position_; x < length_; x++) { 1867 for (int x = position_; x < length_; x++) {
1858 if (data_[x] != SerializerDeserializer::nop()) return false; 1868 if (data_[x] != SerializerDeserializer::nop()) return false;
1859 } 1869 }
1860 return true; 1870 return true;
1861 } 1871 }
1862 1872
1863 } } // namespace v8::internal 1873 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698