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

Side by Side Diff: src/serialize.cc

Issue 18173013: AllocationSite objects weakly linked for traversal (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed final nits Created 7 years, 5 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/serialize.h ('k') | src/x64/lithium-codegen-x64.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 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
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, 64 + entry, "lazy_deopt");
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
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
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::RelinkAllocationSite(AllocationSite* site) {
760 if (isolate_->heap()->allocation_sites_list() == Smi::FromInt(0)) {
761 site->set_weak_next(isolate_->heap()->undefined_value());
762 } else {
763 site->set_weak_next(isolate_->heap()->allocation_sites_list());
764 }
765 isolate_->heap()->set_allocation_sites_list(site);
766 }
767
768
748 // This routine writes the new object into the pointer provided and then 769 // 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. 770 // 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 771 // 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 772 // 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. 773 // time we need to use it to mark the space at the end of a page free.
753 void Deserializer::ReadObject(int space_number, 774 void Deserializer::ReadObject(int space_number,
754 Object** write_back) { 775 Object** write_back) {
755 int size = source_->GetInt() << kObjectAlignmentBits; 776 int size = source_->GetInt() << kObjectAlignmentBits;
756 Address address = Allocate(space_number, size); 777 Address address = Allocate(space_number, size);
757 *write_back = HeapObject::FromAddress(address); 778 HeapObject* obj = HeapObject::FromAddress(address);
779 *write_back = obj;
758 Object** current = reinterpret_cast<Object**>(address); 780 Object** current = reinterpret_cast<Object**>(address);
759 Object** limit = current + (size >> kPointerSizeLog2); 781 Object** limit = current + (size >> kPointerSizeLog2);
760 if (FLAG_log_snapshot_positions) { 782 if (FLAG_log_snapshot_positions) {
761 LOG(isolate_, SnapshotPositionEvent(address, source_->position())); 783 LOG(isolate_, SnapshotPositionEvent(address, source_->position()));
762 } 784 }
763 ReadChunk(current, limit, space_number, address); 785 ReadChunk(current, limit, space_number, address);
786
787 // TODO(mvstanton): consider treating the heap()->allocation_sites_list()
788 // as a (weak) root. If this root is relocated correctly,
789 // RelinkAllocationSite() isn't necessary.
790 if (obj->IsAllocationSite()) {
791 RelinkAllocationSite(AllocationSite::cast(obj));
792 }
793
764 #ifdef DEBUG 794 #ifdef DEBUG
765 bool is_codespace = (space_number == CODE_SPACE); 795 bool is_codespace = (space_number == CODE_SPACE);
766 ASSERT(HeapObject::FromAddress(address)->IsCode() == is_codespace); 796 ASSERT(obj->IsCode() == is_codespace);
767 #endif 797 #endif
768 } 798 }
769 799
770 void Deserializer::ReadChunk(Object** current, 800 void Deserializer::ReadChunk(Object** current,
771 Object** limit, 801 Object** limit,
772 int source_space, 802 int source_space,
773 Address current_object_address) { 803 Address current_object_address) {
774 Isolate* const isolate = isolate_; 804 Isolate* const isolate = isolate_;
775 // Write barrier support costs around 1% in startup time. In fact there 805 // 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, 806 // are no new space objects in current boot snapshots, so it's not needed,
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 1717
1688 bool SnapshotByteSource::AtEOF() { 1718 bool SnapshotByteSource::AtEOF() {
1689 if (0u + length_ - position_ > 2 * sizeof(uint32_t)) return false; 1719 if (0u + length_ - position_ > 2 * sizeof(uint32_t)) return false;
1690 for (int x = position_; x < length_; x++) { 1720 for (int x = position_; x < length_; x++) {
1691 if (data_[x] != SerializerDeserializer::nop()) return false; 1721 if (data_[x] != SerializerDeserializer::nop()) return false;
1692 } 1722 }
1693 return true; 1723 return true;
1694 } 1724 }
1695 1725
1696 } } // namespace v8::internal 1726 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/serialize.h ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698