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

Side by Side Diff: src/serialize.cc

Issue 60363006: Refactored ObjectSerializer::VisitFoo functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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 | « no previous file | 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 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after
1661 current_contents, kPlain, kStartOfObject, 0); 1661 current_contents, kPlain, kStartOfObject, 0);
1662 bytes_processed_so_far_ += kPointerSize; 1662 bytes_processed_so_far_ += kPointerSize;
1663 current++; 1663 current++;
1664 } 1664 }
1665 } 1665 }
1666 } 1666 }
1667 } 1667 }
1668 1668
1669 1669
1670 void Serializer::ObjectSerializer::VisitEmbeddedPointer(RelocInfo* rinfo) { 1670 void Serializer::ObjectSerializer::VisitEmbeddedPointer(RelocInfo* rinfo) {
1671 Object* current = rinfo->target_object();
1672
1673 int skip = OutputRawData(rinfo->target_address_address(), 1671 int skip = OutputRawData(rinfo->target_address_address(),
1674 kCanReturnSkipInsteadOfSkipping); 1672 kCanReturnSkipInsteadOfSkipping);
1675 HowToCode representation = rinfo->IsCodedSpecially() ? kFromCode : kPlain; 1673 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain;
1676 serializer_->SerializeObject(current, representation, kStartOfObject, skip); 1674 Object* object = rinfo->target_object();
1675 serializer_->SerializeObject(object, how_to_code, kStartOfObject, skip);
1677 bytes_processed_so_far_ += rinfo->target_address_size(); 1676 bytes_processed_so_far_ += rinfo->target_address_size();
1678 } 1677 }
1679 1678
1680 1679
1681 void Serializer::ObjectSerializer::VisitExternalReference(Address* p) { 1680 void Serializer::ObjectSerializer::VisitExternalReference(Address* p) {
1682 Address references_start = reinterpret_cast<Address>(p); 1681 int skip = OutputRawData(reinterpret_cast<Address>(p),
1683 int skip = OutputRawData(references_start, kCanReturnSkipInsteadOfSkipping); 1682 kCanReturnSkipInsteadOfSkipping);
1684
1685 sink_->Put(kExternalReference + kPlain + kStartOfObject, "ExternalRef"); 1683 sink_->Put(kExternalReference + kPlain + kStartOfObject, "ExternalRef");
1686 sink_->PutInt(skip, "SkipB4ExternalRef"); 1684 sink_->PutInt(skip, "SkipB4ExternalRef");
1687 int reference_id = serializer_->EncodeExternalReference(*p); 1685 Address target = *p;
1688 sink_->PutInt(reference_id, "reference id"); 1686 sink_->PutInt(serializer_->EncodeExternalReference(target), "reference id");
1689 bytes_processed_so_far_ += kPointerSize; 1687 bytes_processed_so_far_ += kPointerSize;
1690 } 1688 }
1691 1689
1692 1690
1693 void Serializer::ObjectSerializer::VisitExternalReference(RelocInfo* rinfo) { 1691 void Serializer::ObjectSerializer::VisitExternalReference(RelocInfo* rinfo) {
1694 Address references_start = rinfo->target_address_address(); 1692 int skip = OutputRawData(rinfo->target_address_address(),
1695 int skip = OutputRawData(references_start, kCanReturnSkipInsteadOfSkipping); 1693 kCanReturnSkipInsteadOfSkipping);
1696 1694 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain;
1697 Address current = rinfo->target_reference(); 1695 sink_->Put(kExternalReference + how_to_code + kStartOfObject, "ExternalRef");
1698 int representation = rinfo->IsCodedSpecially() ?
1699 kFromCode + kStartOfObject : kPlain + kStartOfObject;
1700 sink_->Put(kExternalReference + representation, "ExternalRef");
1701 sink_->PutInt(skip, "SkipB4ExternalRef"); 1696 sink_->PutInt(skip, "SkipB4ExternalRef");
1702 int reference_id = serializer_->EncodeExternalReference(current); 1697 Address target = rinfo->target_reference();
1703 sink_->PutInt(reference_id, "reference id"); 1698 sink_->PutInt(serializer_->EncodeExternalReference(target), "reference id");
1704 bytes_processed_so_far_ += rinfo->target_address_size(); 1699 bytes_processed_so_far_ += rinfo->target_address_size();
1705 } 1700 }
1706 1701
1707 1702
1708 void Serializer::ObjectSerializer::VisitRuntimeEntry(RelocInfo* rinfo) { 1703 void Serializer::ObjectSerializer::VisitRuntimeEntry(RelocInfo* rinfo) {
1709 Address target_start = rinfo->target_address_address(); 1704 int skip = OutputRawData(rinfo->target_address_address(),
1710 int skip = OutputRawData(target_start, kCanReturnSkipInsteadOfSkipping); 1705 kCanReturnSkipInsteadOfSkipping);
1706 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain;
1707 sink_->Put(kExternalReference + how_to_code + kStartOfObject, "ExternalRef");
1708 sink_->PutInt(skip, "SkipB4ExternalRef");
1711 Address target = rinfo->target_address(); 1709 Address target = rinfo->target_address();
1712 uint32_t encoding = serializer_->EncodeExternalReference(target); 1710 sink_->PutInt(serializer_->EncodeExternalReference(target), "reference id");
1713 CHECK(target == NULL ? encoding == 0 : encoding != 0);
1714 int representation;
1715 // Can't use a ternary operator because of gcc.
1716 if (rinfo->IsCodedSpecially()) {
1717 representation = kStartOfObject + kFromCode;
1718 } else {
1719 representation = kStartOfObject + kPlain;
1720 }
1721 sink_->Put(kExternalReference + representation, "ExternalReference");
1722 sink_->PutInt(skip, "SkipB4ExternalRef");
1723 sink_->PutInt(encoding, "reference id");
1724 bytes_processed_so_far_ += rinfo->target_address_size(); 1711 bytes_processed_so_far_ += rinfo->target_address_size();
1725 } 1712 }
1726 1713
1727 1714
1728 void Serializer::ObjectSerializer::VisitCodeTarget(RelocInfo* rinfo) { 1715 void Serializer::ObjectSerializer::VisitCodeTarget(RelocInfo* rinfo) {
1729 CHECK(RelocInfo::IsCodeTarget(rinfo->rmode())); 1716 int skip = OutputRawData(rinfo->target_address_address(),
1730 Address target_start = rinfo->target_address_address(); 1717 kCanReturnSkipInsteadOfSkipping);
1731 int skip = OutputRawData(target_start, kCanReturnSkipInsteadOfSkipping); 1718 Code* object = Code::GetCodeFromTargetAddress(rinfo->target_address());
1732 Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); 1719 serializer_->SerializeObject(object, kFromCode, kInnerPointer, skip);
1733 serializer_->SerializeObject(target, kFromCode, kInnerPointer, skip);
1734 bytes_processed_so_far_ += rinfo->target_address_size(); 1720 bytes_processed_so_far_ += rinfo->target_address_size();
1735 } 1721 }
1736 1722
1737 1723
1738 void Serializer::ObjectSerializer::VisitCodeEntry(Address entry_address) { 1724 void Serializer::ObjectSerializer::VisitCodeEntry(Address entry_address) {
1739 Code* target = Code::cast(Code::GetObjectFromEntryAddress(entry_address));
1740 int skip = OutputRawData(entry_address, kCanReturnSkipInsteadOfSkipping); 1725 int skip = OutputRawData(entry_address, kCanReturnSkipInsteadOfSkipping);
1741 serializer_->SerializeObject(target, kPlain, kInnerPointer, skip); 1726 Code* object = Code::cast(Code::GetObjectFromEntryAddress(entry_address));
1727 serializer_->SerializeObject(object, kPlain, kInnerPointer, skip);
1742 bytes_processed_so_far_ += kPointerSize; 1728 bytes_processed_so_far_ += kPointerSize;
1743 } 1729 }
1744 1730
1745 1731
1746 void Serializer::ObjectSerializer::VisitCell(RelocInfo* rinfo) { 1732 void Serializer::ObjectSerializer::VisitCell(RelocInfo* rinfo) {
1747 ASSERT(rinfo->rmode() == RelocInfo::CELL);
1748 Cell* cell = Cell::cast(rinfo->target_cell());
1749 int skip = OutputRawData(rinfo->pc(), kCanReturnSkipInsteadOfSkipping); 1733 int skip = OutputRawData(rinfo->pc(), kCanReturnSkipInsteadOfSkipping);
1750 serializer_->SerializeObject(cell, kPlain, kInnerPointer, skip); 1734 Cell* object = Cell::cast(rinfo->target_cell());
1735 serializer_->SerializeObject(object, kPlain, kInnerPointer, skip);
1751 } 1736 }
1752 1737
1753 1738
1754 void Serializer::ObjectSerializer::VisitExternalAsciiString( 1739 void Serializer::ObjectSerializer::VisitExternalAsciiString(
1755 v8::String::ExternalAsciiStringResource** resource_pointer) { 1740 v8::String::ExternalAsciiStringResource** resource_pointer) {
1756 Address references_start = reinterpret_cast<Address>(resource_pointer); 1741 Address references_start = reinterpret_cast<Address>(resource_pointer);
1757 OutputRawData(references_start); 1742 OutputRawData(references_start);
1758 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { 1743 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
1759 Object* source = 1744 Object* source =
1760 serializer_->isolate()->heap()->natives_source_cache()->get(i); 1745 serializer_->isolate()->heap()->natives_source_cache()->get(i);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1895 1880
1896 bool SnapshotByteSource::AtEOF() { 1881 bool SnapshotByteSource::AtEOF() {
1897 if (0u + length_ - position_ > 2 * sizeof(uint32_t)) return false; 1882 if (0u + length_ - position_ > 2 * sizeof(uint32_t)) return false;
1898 for (int x = position_; x < length_; x++) { 1883 for (int x = position_; x < length_; x++) {
1899 if (data_[x] != SerializerDeserializer::nop()) return false; 1884 if (data_[x] != SerializerDeserializer::nop()) return false;
1900 } 1885 }
1901 return true; 1886 return true;
1902 } 1887 }
1903 1888
1904 } } // namespace v8::internal 1889 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698