| OLD | NEW |
| 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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 Add(stub_cache->map_reference(StubCache::kSecondary).address(), | 290 Add(stub_cache->map_reference(StubCache::kSecondary).address(), |
| 291 STUB_CACHE_TABLE, | 291 STUB_CACHE_TABLE, |
| 292 6, | 292 6, |
| 293 "StubCache::secondary_->map"); | 293 "StubCache::secondary_->map"); |
| 294 | 294 |
| 295 // Runtime entries | 295 // Runtime entries |
| 296 Add(ExternalReference::perform_gc_function(isolate).address(), | 296 Add(ExternalReference::perform_gc_function(isolate).address(), |
| 297 RUNTIME_ENTRY, | 297 RUNTIME_ENTRY, |
| 298 1, | 298 1, |
| 299 "Runtime::PerformGC"); | 299 "Runtime::PerformGC"); |
| 300 Add(ExternalReference::fill_heap_number_with_random_function( | |
| 301 isolate).address(), | |
| 302 RUNTIME_ENTRY, | |
| 303 2, | |
| 304 "V8::FillHeapNumberWithRandom"); | |
| 305 Add(ExternalReference::random_uint32_function(isolate).address(), | 300 Add(ExternalReference::random_uint32_function(isolate).address(), |
| 306 RUNTIME_ENTRY, | 301 RUNTIME_ENTRY, |
| 307 3, | 302 3, |
| 308 "V8::Random"); | 303 "V8::Random"); |
| 309 Add(ExternalReference::delete_handle_scope_extensions(isolate).address(), | 304 Add(ExternalReference::delete_handle_scope_extensions(isolate).address(), |
| 310 RUNTIME_ENTRY, | 305 RUNTIME_ENTRY, |
| 311 4, | 306 4, |
| 312 "HandleScope::DeleteExtensions"); | 307 "HandleScope::DeleteExtensions"); |
| 313 Add(ExternalReference:: | 308 Add(ExternalReference:: |
| 314 incremental_marking_record_write_function(isolate).address(), | 309 incremental_marking_record_write_function(isolate).address(), |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 "Runtime::AllocateInOldDataSpace"); | 561 "Runtime::AllocateInOldDataSpace"); |
| 567 Add(ExternalReference::new_space_high_promotion_mode_active_address(isolate). | 562 Add(ExternalReference::new_space_high_promotion_mode_active_address(isolate). |
| 568 address(), | 563 address(), |
| 569 UNCLASSIFIED, | 564 UNCLASSIFIED, |
| 570 60, | 565 60, |
| 571 "Heap::NewSpaceAllocationLimitAddress"); | 566 "Heap::NewSpaceAllocationLimitAddress"); |
| 572 Add(ExternalReference::allocation_sites_list_address(isolate).address(), | 567 Add(ExternalReference::allocation_sites_list_address(isolate).address(), |
| 573 UNCLASSIFIED, | 568 UNCLASSIFIED, |
| 574 61, | 569 61, |
| 575 "Heap::allocation_sites_list_address()"); | 570 "Heap::allocation_sites_list_address()"); |
| 576 Add(ExternalReference::record_object_allocation_function(isolate).address(), | 571 Add(ExternalReference::address_of_uint32_bias().address(), |
| 577 UNCLASSIFIED, | 572 UNCLASSIFIED, |
| 578 62, | 573 62, |
| 579 "HeapProfiler::RecordObjectAllocationFromMasm"); | |
| 580 Add(ExternalReference::address_of_uint32_bias().address(), | |
| 581 UNCLASSIFIED, | |
| 582 63, | |
| 583 "uint32_bias"); | 574 "uint32_bias"); |
| 584 Add(ExternalReference::get_mark_code_as_executed_function(isolate).address(), | 575 Add(ExternalReference::get_mark_code_as_executed_function(isolate).address(), |
| 585 UNCLASSIFIED, | 576 UNCLASSIFIED, |
| 586 64, | 577 63, |
| 587 "Code::MarkCodeAsExecuted"); | 578 "Code::MarkCodeAsExecuted"); |
| 588 | 579 |
| 589 // Add a small set of deopt entry addresses to encoder without generating the | 580 // Add a small set of deopt entry addresses to encoder without generating the |
| 590 // deopt table code, which isn't possible at deserialization time. | 581 // deopt table code, which isn't possible at deserialization time. |
| 591 HandleScope scope(isolate); | 582 HandleScope scope(isolate); |
| 592 for (int entry = 0; entry < kDeoptTableSerializeEntryCount; ++entry) { | 583 for (int entry = 0; entry < kDeoptTableSerializeEntryCount; ++entry) { |
| 593 Address address = Deoptimizer::GetDeoptimizationEntry( | 584 Address address = Deoptimizer::GetDeoptimizationEntry( |
| 594 isolate, | 585 isolate, |
| 595 entry, | 586 entry, |
| 596 Deoptimizer::LAZY, | 587 Deoptimizer::LAZY, |
| (...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1661 current_contents, kPlain, kStartOfObject, 0); | 1652 current_contents, kPlain, kStartOfObject, 0); |
| 1662 bytes_processed_so_far_ += kPointerSize; | 1653 bytes_processed_so_far_ += kPointerSize; |
| 1663 current++; | 1654 current++; |
| 1664 } | 1655 } |
| 1665 } | 1656 } |
| 1666 } | 1657 } |
| 1667 } | 1658 } |
| 1668 | 1659 |
| 1669 | 1660 |
| 1670 void Serializer::ObjectSerializer::VisitEmbeddedPointer(RelocInfo* rinfo) { | 1661 void Serializer::ObjectSerializer::VisitEmbeddedPointer(RelocInfo* rinfo) { |
| 1671 Object* current = rinfo->target_object(); | |
| 1672 | |
| 1673 int skip = OutputRawData(rinfo->target_address_address(), | 1662 int skip = OutputRawData(rinfo->target_address_address(), |
| 1674 kCanReturnSkipInsteadOfSkipping); | 1663 kCanReturnSkipInsteadOfSkipping); |
| 1675 HowToCode representation = rinfo->IsCodedSpecially() ? kFromCode : kPlain; | 1664 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain; |
| 1676 serializer_->SerializeObject(current, representation, kStartOfObject, skip); | 1665 Object* object = rinfo->target_object(); |
| 1666 serializer_->SerializeObject(object, how_to_code, kStartOfObject, skip); |
| 1677 bytes_processed_so_far_ += rinfo->target_address_size(); | 1667 bytes_processed_so_far_ += rinfo->target_address_size(); |
| 1678 } | 1668 } |
| 1679 | 1669 |
| 1680 | 1670 |
| 1681 void Serializer::ObjectSerializer::VisitExternalReference(Address* p) { | 1671 void Serializer::ObjectSerializer::VisitExternalReference(Address* p) { |
| 1682 Address references_start = reinterpret_cast<Address>(p); | 1672 int skip = OutputRawData(reinterpret_cast<Address>(p), |
| 1683 int skip = OutputRawData(references_start, kCanReturnSkipInsteadOfSkipping); | 1673 kCanReturnSkipInsteadOfSkipping); |
| 1684 | |
| 1685 sink_->Put(kExternalReference + kPlain + kStartOfObject, "ExternalRef"); | 1674 sink_->Put(kExternalReference + kPlain + kStartOfObject, "ExternalRef"); |
| 1686 sink_->PutInt(skip, "SkipB4ExternalRef"); | 1675 sink_->PutInt(skip, "SkipB4ExternalRef"); |
| 1687 int reference_id = serializer_->EncodeExternalReference(*p); | 1676 Address target = *p; |
| 1688 sink_->PutInt(reference_id, "reference id"); | 1677 sink_->PutInt(serializer_->EncodeExternalReference(target), "reference id"); |
| 1689 bytes_processed_so_far_ += kPointerSize; | 1678 bytes_processed_so_far_ += kPointerSize; |
| 1690 } | 1679 } |
| 1691 | 1680 |
| 1692 | 1681 |
| 1693 void Serializer::ObjectSerializer::VisitExternalReference(RelocInfo* rinfo) { | 1682 void Serializer::ObjectSerializer::VisitExternalReference(RelocInfo* rinfo) { |
| 1694 Address references_start = rinfo->target_address_address(); | 1683 int skip = OutputRawData(rinfo->target_address_address(), |
| 1695 int skip = OutputRawData(references_start, kCanReturnSkipInsteadOfSkipping); | 1684 kCanReturnSkipInsteadOfSkipping); |
| 1696 | 1685 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain; |
| 1697 Address current = rinfo->target_reference(); | 1686 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"); | 1687 sink_->PutInt(skip, "SkipB4ExternalRef"); |
| 1702 int reference_id = serializer_->EncodeExternalReference(current); | 1688 Address target = rinfo->target_reference(); |
| 1703 sink_->PutInt(reference_id, "reference id"); | 1689 sink_->PutInt(serializer_->EncodeExternalReference(target), "reference id"); |
| 1704 bytes_processed_so_far_ += rinfo->target_address_size(); | 1690 bytes_processed_so_far_ += rinfo->target_address_size(); |
| 1705 } | 1691 } |
| 1706 | 1692 |
| 1707 | 1693 |
| 1708 void Serializer::ObjectSerializer::VisitRuntimeEntry(RelocInfo* rinfo) { | 1694 void Serializer::ObjectSerializer::VisitRuntimeEntry(RelocInfo* rinfo) { |
| 1709 Address target_start = rinfo->target_address_address(); | 1695 int skip = OutputRawData(rinfo->target_address_address(), |
| 1710 int skip = OutputRawData(target_start, kCanReturnSkipInsteadOfSkipping); | 1696 kCanReturnSkipInsteadOfSkipping); |
| 1697 HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain; |
| 1698 sink_->Put(kExternalReference + how_to_code + kStartOfObject, "ExternalRef"); |
| 1699 sink_->PutInt(skip, "SkipB4ExternalRef"); |
| 1711 Address target = rinfo->target_address(); | 1700 Address target = rinfo->target_address(); |
| 1712 uint32_t encoding = serializer_->EncodeExternalReference(target); | 1701 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(); | 1702 bytes_processed_so_far_ += rinfo->target_address_size(); |
| 1725 } | 1703 } |
| 1726 | 1704 |
| 1727 | 1705 |
| 1728 void Serializer::ObjectSerializer::VisitCodeTarget(RelocInfo* rinfo) { | 1706 void Serializer::ObjectSerializer::VisitCodeTarget(RelocInfo* rinfo) { |
| 1729 CHECK(RelocInfo::IsCodeTarget(rinfo->rmode())); | 1707 int skip = OutputRawData(rinfo->target_address_address(), |
| 1730 Address target_start = rinfo->target_address_address(); | 1708 kCanReturnSkipInsteadOfSkipping); |
| 1731 int skip = OutputRawData(target_start, kCanReturnSkipInsteadOfSkipping); | 1709 Code* object = Code::GetCodeFromTargetAddress(rinfo->target_address()); |
| 1732 Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); | 1710 serializer_->SerializeObject(object, kFromCode, kInnerPointer, skip); |
| 1733 serializer_->SerializeObject(target, kFromCode, kInnerPointer, skip); | |
| 1734 bytes_processed_so_far_ += rinfo->target_address_size(); | 1711 bytes_processed_so_far_ += rinfo->target_address_size(); |
| 1735 } | 1712 } |
| 1736 | 1713 |
| 1737 | 1714 |
| 1738 void Serializer::ObjectSerializer::VisitCodeEntry(Address entry_address) { | 1715 void Serializer::ObjectSerializer::VisitCodeEntry(Address entry_address) { |
| 1739 Code* target = Code::cast(Code::GetObjectFromEntryAddress(entry_address)); | |
| 1740 int skip = OutputRawData(entry_address, kCanReturnSkipInsteadOfSkipping); | 1716 int skip = OutputRawData(entry_address, kCanReturnSkipInsteadOfSkipping); |
| 1741 serializer_->SerializeObject(target, kPlain, kInnerPointer, skip); | 1717 Code* object = Code::cast(Code::GetObjectFromEntryAddress(entry_address)); |
| 1718 serializer_->SerializeObject(object, kPlain, kInnerPointer, skip); |
| 1742 bytes_processed_so_far_ += kPointerSize; | 1719 bytes_processed_so_far_ += kPointerSize; |
| 1743 } | 1720 } |
| 1744 | 1721 |
| 1745 | 1722 |
| 1746 void Serializer::ObjectSerializer::VisitCell(RelocInfo* rinfo) { | 1723 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); | 1724 int skip = OutputRawData(rinfo->pc(), kCanReturnSkipInsteadOfSkipping); |
| 1750 serializer_->SerializeObject(cell, kPlain, kInnerPointer, skip); | 1725 Cell* object = Cell::cast(rinfo->target_cell()); |
| 1726 serializer_->SerializeObject(object, kPlain, kInnerPointer, skip); |
| 1751 } | 1727 } |
| 1752 | 1728 |
| 1753 | 1729 |
| 1754 void Serializer::ObjectSerializer::VisitExternalAsciiString( | 1730 void Serializer::ObjectSerializer::VisitExternalAsciiString( |
| 1755 v8::String::ExternalAsciiStringResource** resource_pointer) { | 1731 v8::String::ExternalAsciiStringResource** resource_pointer) { |
| 1756 Address references_start = reinterpret_cast<Address>(resource_pointer); | 1732 Address references_start = reinterpret_cast<Address>(resource_pointer); |
| 1757 OutputRawData(references_start); | 1733 OutputRawData(references_start); |
| 1758 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { | 1734 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { |
| 1759 Object* source = | 1735 Object* source = |
| 1760 serializer_->isolate()->heap()->natives_source_cache()->get(i); | 1736 serializer_->isolate()->heap()->natives_source_cache()->get(i); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1895 | 1871 |
| 1896 bool SnapshotByteSource::AtEOF() { | 1872 bool SnapshotByteSource::AtEOF() { |
| 1897 if (0u + length_ - position_ > 2 * sizeof(uint32_t)) return false; | 1873 if (0u + length_ - position_ > 2 * sizeof(uint32_t)) return false; |
| 1898 for (int x = position_; x < length_; x++) { | 1874 for (int x = position_; x < length_; x++) { |
| 1899 if (data_[x] != SerializerDeserializer::nop()) return false; | 1875 if (data_[x] != SerializerDeserializer::nop()) return false; |
| 1900 } | 1876 } |
| 1901 return true; | 1877 return true; |
| 1902 } | 1878 } |
| 1903 | 1879 |
| 1904 } } // namespace v8::internal | 1880 } } // namespace v8::internal |
| OLD | NEW |