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 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
570 "Heap::OldDataSpaceAllocationLimitAddress"); | 570 "Heap::OldDataSpaceAllocationLimitAddress"); |
571 Add(ExternalReference(Runtime::kAllocateInOldDataSpace, isolate).address(), | 571 Add(ExternalReference(Runtime::kAllocateInOldDataSpace, isolate).address(), |
572 UNCLASSIFIED, | 572 UNCLASSIFIED, |
573 61, | 573 61, |
574 "Runtime::AllocateInOldDataSpace"); | 574 "Runtime::AllocateInOldDataSpace"); |
575 Add(ExternalReference::new_space_high_promotion_mode_active_address(isolate). | 575 Add(ExternalReference::new_space_high_promotion_mode_active_address(isolate). |
576 address(), | 576 address(), |
577 UNCLASSIFIED, | 577 UNCLASSIFIED, |
578 62, | 578 62, |
579 "Heap::NewSpaceAllocationLimitAddress"); | 579 "Heap::NewSpaceAllocationLimitAddress"); |
580 Add(ExternalReference::allocation_sites_list_address(isolate).address(), | |
581 UNCLASSIFIED, | |
582 63, | |
583 "Heap::allocation_sites_list_address()"); | |
580 | 584 |
581 // Add a small set of deopt entry addresses to encoder without generating the | 585 // Add a small set of deopt entry addresses to encoder without generating the |
582 // deopt table code, which isn't possible at deserialization time. | 586 // deopt table code, which isn't possible at deserialization time. |
583 HandleScope scope(isolate); | 587 HandleScope scope(isolate); |
584 for (int entry = 0; entry < kDeoptTableSerializeEntryCount; ++entry) { | 588 for (int entry = 0; entry < kDeoptTableSerializeEntryCount; ++entry) { |
585 Address address = Deoptimizer::GetDeoptimizationEntry( | 589 Address address = Deoptimizer::GetDeoptimizationEntry( |
586 isolate, | 590 isolate, |
587 entry, | 591 entry, |
588 Deoptimizer::LAZY, | 592 Deoptimizer::LAZY, |
589 Deoptimizer::CALCULATE_ENTRY_ADDRESS); | 593 Deoptimizer::CALCULATE_ENTRY_ADDRESS); |
590 Add(address, LAZY_DEOPTIMIZATION, 63 + entry, "lazy_deopt"); | 594 Add(address, LAZY_DEOPTIMIZATION, 63 + entry, "lazy_deopt"); |
Michael Starzinger
2013/07/16 18:14:46
These references need to start at 64 now, s/63/64/
mvstanton
2013/07/16 19:34:57
Yikes! thanks! Done.
| |
591 } | 595 } |
592 } | 596 } |
593 | 597 |
594 | 598 |
595 ExternalReferenceEncoder::ExternalReferenceEncoder() | 599 ExternalReferenceEncoder::ExternalReferenceEncoder() |
596 : encodings_(Match), | 600 : encodings_(Match), |
597 isolate_(Isolate::Current()) { | 601 isolate_(Isolate::Current()) { |
598 ExternalReferenceTable* external_references = | 602 ExternalReferenceTable* external_references = |
599 ExternalReferenceTable::instance(isolate_); | 603 ExternalReferenceTable::instance(isolate_); |
600 for (int i = 0; i < external_references->size(); ++i) { | 604 for (int i = 0; i < external_references->size(); ++i) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
683 external_reference_decoder_ = new ExternalReferenceDecoder(); | 687 external_reference_decoder_ = new ExternalReferenceDecoder(); |
684 isolate_->heap()->IterateStrongRoots(this, VISIT_ONLY_STRONG); | 688 isolate_->heap()->IterateStrongRoots(this, VISIT_ONLY_STRONG); |
685 isolate_->heap()->RepairFreeListsAfterBoot(); | 689 isolate_->heap()->RepairFreeListsAfterBoot(); |
686 isolate_->heap()->IterateWeakRoots(this, VISIT_ALL); | 690 isolate_->heap()->IterateWeakRoots(this, VISIT_ALL); |
687 | 691 |
688 isolate_->heap()->set_native_contexts_list( | 692 isolate_->heap()->set_native_contexts_list( |
689 isolate_->heap()->undefined_value()); | 693 isolate_->heap()->undefined_value()); |
690 isolate_->heap()->set_array_buffers_list( | 694 isolate_->heap()->set_array_buffers_list( |
691 isolate_->heap()->undefined_value()); | 695 isolate_->heap()->undefined_value()); |
692 | 696 |
697 // The allocation site list is build during root iteration, but if no sites | |
698 // were encountered then it needs to be initialized to undefined. | |
699 if (isolate_->heap()->allocation_sites_list() == Smi::FromInt(0)) { | |
700 isolate_->heap()->set_allocation_sites_list( | |
701 isolate_->heap()->undefined_value()); | |
702 } | |
703 | |
693 // Update data pointers to the external strings containing natives sources. | 704 // Update data pointers to the external strings containing natives sources. |
694 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { | 705 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { |
695 Object* source = isolate_->heap()->natives_source_cache()->get(i); | 706 Object* source = isolate_->heap()->natives_source_cache()->get(i); |
696 if (!source->IsUndefined()) { | 707 if (!source->IsUndefined()) { |
697 ExternalAsciiString::cast(source)->update_data_cache(); | 708 ExternalAsciiString::cast(source)->update_data_cache(); |
698 } | 709 } |
699 } | 710 } |
700 | 711 |
701 // Issue code events for newly deserialized code objects. | 712 // Issue code events for newly deserialized code objects. |
702 LOG_CODE_EVENT(isolate_, LogCodeObjects()); | 713 LOG_CODE_EVENT(isolate_, LogCodeObjects()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
738 | 749 |
739 // This is called on the roots. It is the driver of the deserialization | 750 // This is called on the roots. It is the driver of the deserialization |
740 // process. It is also called on the body of each function. | 751 // process. It is also called on the body of each function. |
741 void Deserializer::VisitPointers(Object** start, Object** end) { | 752 void Deserializer::VisitPointers(Object** start, Object** end) { |
742 // The space must be new space. Any other space would cause ReadChunk to try | 753 // The space must be new space. Any other space would cause ReadChunk to try |
743 // to update the remembered using NULL as the address. | 754 // to update the remembered using NULL as the address. |
744 ReadChunk(start, end, NEW_SPACE, NULL); | 755 ReadChunk(start, end, NEW_SPACE, NULL); |
745 } | 756 } |
746 | 757 |
747 | 758 |
759 void Deserializer::VisitAllocationSite(HeapObject* obj) { | |
760 AllocationSite* site = AllocationSite::cast(obj); | |
761 if (isolate_->heap()->allocation_sites_list() == Smi::FromInt(0)) { | |
762 site->set_weak_next(isolate_->heap()->undefined_value()); | |
763 } else { | |
764 site->set_weak_next(isolate_->heap()->allocation_sites_list()); | |
765 } | |
766 isolate_->heap()->set_allocation_sites_list(site); | |
767 } | |
768 | |
769 | |
748 // This routine writes the new object into the pointer provided and then | 770 // This routine writes the new object into the pointer provided and then |
749 // returns true if the new object was in young space and false otherwise. | 771 // returns true if the new object was in young space and false otherwise. |
750 // The reason for this strange interface is that otherwise the object is | 772 // The reason for this strange interface is that otherwise the object is |
751 // written very late, which means the FreeSpace map is not set up by the | 773 // written very late, which means the FreeSpace map is not set up by the |
752 // time we need to use it to mark the space at the end of a page free. | 774 // time we need to use it to mark the space at the end of a page free. |
753 void Deserializer::ReadObject(int space_number, | 775 void Deserializer::ReadObject(int space_number, |
754 Object** write_back) { | 776 Object** write_back) { |
755 int size = source_->GetInt() << kObjectAlignmentBits; | 777 int size = source_->GetInt() << kObjectAlignmentBits; |
756 Address address = Allocate(space_number, size); | 778 Address address = Allocate(space_number, size); |
757 *write_back = HeapObject::FromAddress(address); | 779 HeapObject* obj = HeapObject::FromAddress(address); |
780 *write_back = obj; | |
758 Object** current = reinterpret_cast<Object**>(address); | 781 Object** current = reinterpret_cast<Object**>(address); |
759 Object** limit = current + (size >> kPointerSizeLog2); | 782 Object** limit = current + (size >> kPointerSizeLog2); |
760 if (FLAG_log_snapshot_positions) { | 783 if (FLAG_log_snapshot_positions) { |
761 LOG(isolate_, SnapshotPositionEvent(address, source_->position())); | 784 LOG(isolate_, SnapshotPositionEvent(address, source_->position())); |
762 } | 785 } |
763 ReadChunk(current, limit, space_number, address); | 786 ReadChunk(current, limit, space_number, address); |
787 | |
788 if (obj->IsAllocationSite()) { | |
789 VisitAllocationSite(obj); | |
790 } | |
791 | |
764 #ifdef DEBUG | 792 #ifdef DEBUG |
765 bool is_codespace = (space_number == CODE_SPACE); | 793 bool is_codespace = (space_number == CODE_SPACE); |
766 ASSERT(HeapObject::FromAddress(address)->IsCode() == is_codespace); | 794 ASSERT(obj->IsCode() == is_codespace); |
767 #endif | 795 #endif |
768 } | 796 } |
769 | 797 |
770 void Deserializer::ReadChunk(Object** current, | 798 void Deserializer::ReadChunk(Object** current, |
771 Object** limit, | 799 Object** limit, |
772 int source_space, | 800 int source_space, |
773 Address current_object_address) { | 801 Address current_object_address) { |
774 Isolate* const isolate = isolate_; | 802 Isolate* const isolate = isolate_; |
775 // Write barrier support costs around 1% in startup time. In fact there | 803 // Write barrier support costs around 1% in startup time. In fact there |
776 // are no new space objects in current boot snapshots, so it's not needed, | 804 // are no new space objects in current boot snapshots, so it's not needed, |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1552 void Serializer::ObjectSerializer::VisitCodeTarget(RelocInfo* rinfo) { | 1580 void Serializer::ObjectSerializer::VisitCodeTarget(RelocInfo* rinfo) { |
1553 CHECK(RelocInfo::IsCodeTarget(rinfo->rmode())); | 1581 CHECK(RelocInfo::IsCodeTarget(rinfo->rmode())); |
1554 Address target_start = rinfo->target_address_address(); | 1582 Address target_start = rinfo->target_address_address(); |
1555 int skip = OutputRawData(target_start, kCanReturnSkipInsteadOfSkipping); | 1583 int skip = OutputRawData(target_start, kCanReturnSkipInsteadOfSkipping); |
1556 Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); | 1584 Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); |
1557 serializer_->SerializeObject(target, kFromCode, kInnerPointer, skip); | 1585 serializer_->SerializeObject(target, kFromCode, kInnerPointer, skip); |
1558 bytes_processed_so_far_ += rinfo->target_address_size(); | 1586 bytes_processed_so_far_ += rinfo->target_address_size(); |
1559 } | 1587 } |
1560 | 1588 |
1561 | 1589 |
1590 void Serializer::ObjectSerializer::VisitAllocationSite(HeapObject* site) { | |
1591 // Unlink from the allocation site list to avoid storing garbage pointers | |
1592 // in the heap. | |
1593 AllocationSite* real_site = AllocationSite::cast(site); | |
1594 real_site->set_weak_next(serializer_->isolate_->heap()->undefined_value()); | |
1595 ObjectVisitor::VisitAllocationSite(site); | |
1596 } | |
1597 | |
1598 | |
1562 void Serializer::ObjectSerializer::VisitCodeEntry(Address entry_address) { | 1599 void Serializer::ObjectSerializer::VisitCodeEntry(Address entry_address) { |
1563 Code* target = Code::cast(Code::GetObjectFromEntryAddress(entry_address)); | 1600 Code* target = Code::cast(Code::GetObjectFromEntryAddress(entry_address)); |
1564 int skip = OutputRawData(entry_address, kCanReturnSkipInsteadOfSkipping); | 1601 int skip = OutputRawData(entry_address, kCanReturnSkipInsteadOfSkipping); |
1565 serializer_->SerializeObject(target, kPlain, kInnerPointer, skip); | 1602 serializer_->SerializeObject(target, kPlain, kInnerPointer, skip); |
1566 bytes_processed_so_far_ += kPointerSize; | 1603 bytes_processed_so_far_ += kPointerSize; |
1567 } | 1604 } |
1568 | 1605 |
1569 | 1606 |
1570 void Serializer::ObjectSerializer::VisitCell(RelocInfo* rinfo) { | 1607 void Serializer::ObjectSerializer::VisitCell(RelocInfo* rinfo) { |
1571 ASSERT(rinfo->rmode() == RelocInfo::CELL); | 1608 ASSERT(rinfo->rmode() == RelocInfo::CELL); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1687 | 1724 |
1688 bool SnapshotByteSource::AtEOF() { | 1725 bool SnapshotByteSource::AtEOF() { |
1689 if (0u + length_ - position_ > 2 * sizeof(uint32_t)) return false; | 1726 if (0u + length_ - position_ > 2 * sizeof(uint32_t)) return false; |
1690 for (int x = position_; x < length_; x++) { | 1727 for (int x = position_; x < length_; x++) { |
1691 if (data_[x] != SerializerDeserializer::nop()) return false; | 1728 if (data_[x] != SerializerDeserializer::nop()) return false; |
1692 } | 1729 } |
1693 return true; | 1730 return true; |
1694 } | 1731 } |
1695 | 1732 |
1696 } } // namespace v8::internal | 1733 } } // namespace v8::internal |
OLD | NEW |