OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 survived_last_scavenge_(0), | 80 survived_last_scavenge_(0), |
81 sweep_generation_(0), | 81 sweep_generation_(0), |
82 always_allocate_scope_depth_(0), | 82 always_allocate_scope_depth_(0), |
83 contexts_disposed_(0), | 83 contexts_disposed_(0), |
84 global_ic_age_(0), | 84 global_ic_age_(0), |
85 scan_on_scavenge_pages_(0), | 85 scan_on_scavenge_pages_(0), |
86 new_space_(this), | 86 new_space_(this), |
87 old_space_(NULL), | 87 old_space_(NULL), |
88 code_space_(NULL), | 88 code_space_(NULL), |
89 map_space_(NULL), | 89 map_space_(NULL), |
90 cell_space_(NULL), | |
91 lo_space_(NULL), | 90 lo_space_(NULL), |
92 gc_state_(NOT_IN_GC), | 91 gc_state_(NOT_IN_GC), |
93 gc_post_processing_depth_(0), | 92 gc_post_processing_depth_(0), |
94 allocations_count_(0), | 93 allocations_count_(0), |
95 raw_allocations_hash_(0), | 94 raw_allocations_hash_(0), |
96 dump_allocations_hash_countdown_(FLAG_dump_allocations_digest_at_alloc), | 95 dump_allocations_hash_countdown_(FLAG_dump_allocations_digest_at_alloc), |
97 ms_count_(0), | 96 ms_count_(0), |
98 gc_count_(0), | 97 gc_count_(0), |
99 remembered_unmapped_pages_index_(0), | 98 remembered_unmapped_pages_index_(0), |
100 unflattened_strings_length_(0), | 99 unflattened_strings_length_(0), |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 RememberUnmappedPage(NULL, false); | 164 RememberUnmappedPage(NULL, false); |
166 | 165 |
167 ClearObjectStats(true); | 166 ClearObjectStats(true); |
168 } | 167 } |
169 | 168 |
170 | 169 |
171 intptr_t Heap::Capacity() { | 170 intptr_t Heap::Capacity() { |
172 if (!HasBeenSetUp()) return 0; | 171 if (!HasBeenSetUp()) return 0; |
173 | 172 |
174 return new_space_.Capacity() + old_space_->Capacity() + | 173 return new_space_.Capacity() + old_space_->Capacity() + |
175 code_space_->Capacity() + map_space_->Capacity() + | 174 code_space_->Capacity() + map_space_->Capacity(); |
176 cell_space_->Capacity(); | |
177 } | 175 } |
178 | 176 |
179 | 177 |
180 intptr_t Heap::CommittedOldGenerationMemory() { | 178 intptr_t Heap::CommittedOldGenerationMemory() { |
181 if (!HasBeenSetUp()) return 0; | 179 if (!HasBeenSetUp()) return 0; |
182 | 180 |
183 return old_space_->CommittedMemory() + code_space_->CommittedMemory() + | 181 return old_space_->CommittedMemory() + code_space_->CommittedMemory() + |
184 map_space_->CommittedMemory() + cell_space_->CommittedMemory() + | 182 map_space_->CommittedMemory() + lo_space_->Size(); |
185 lo_space_->Size(); | |
186 } | 183 } |
187 | 184 |
188 | 185 |
189 intptr_t Heap::CommittedMemory() { | 186 intptr_t Heap::CommittedMemory() { |
190 if (!HasBeenSetUp()) return 0; | 187 if (!HasBeenSetUp()) return 0; |
191 | 188 |
192 return new_space_.CommittedMemory() + CommittedOldGenerationMemory(); | 189 return new_space_.CommittedMemory() + CommittedOldGenerationMemory(); |
193 } | 190 } |
194 | 191 |
195 | 192 |
196 size_t Heap::CommittedPhysicalMemory() { | 193 size_t Heap::CommittedPhysicalMemory() { |
197 if (!HasBeenSetUp()) return 0; | 194 if (!HasBeenSetUp()) return 0; |
198 | 195 |
199 return new_space_.CommittedPhysicalMemory() + | 196 return new_space_.CommittedPhysicalMemory() + |
200 old_space_->CommittedPhysicalMemory() + | 197 old_space_->CommittedPhysicalMemory() + |
201 code_space_->CommittedPhysicalMemory() + | 198 code_space_->CommittedPhysicalMemory() + |
202 map_space_->CommittedPhysicalMemory() + | 199 map_space_->CommittedPhysicalMemory() + |
203 cell_space_->CommittedPhysicalMemory() + | |
204 lo_space_->CommittedPhysicalMemory(); | 200 lo_space_->CommittedPhysicalMemory(); |
205 } | 201 } |
206 | 202 |
207 | 203 |
208 intptr_t Heap::CommittedMemoryExecutable() { | 204 intptr_t Heap::CommittedMemoryExecutable() { |
209 if (!HasBeenSetUp()) return 0; | 205 if (!HasBeenSetUp()) return 0; |
210 | 206 |
211 return isolate()->memory_allocator()->SizeExecutable(); | 207 return isolate()->memory_allocator()->SizeExecutable(); |
212 } | 208 } |
213 | 209 |
214 | 210 |
215 void Heap::UpdateMaximumCommitted() { | 211 void Heap::UpdateMaximumCommitted() { |
216 if (!HasBeenSetUp()) return; | 212 if (!HasBeenSetUp()) return; |
217 | 213 |
218 intptr_t current_committed_memory = CommittedMemory(); | 214 intptr_t current_committed_memory = CommittedMemory(); |
219 if (current_committed_memory > maximum_committed_) { | 215 if (current_committed_memory > maximum_committed_) { |
220 maximum_committed_ = current_committed_memory; | 216 maximum_committed_ = current_committed_memory; |
221 } | 217 } |
222 } | 218 } |
223 | 219 |
224 | 220 |
225 intptr_t Heap::Available() { | 221 intptr_t Heap::Available() { |
226 if (!HasBeenSetUp()) return 0; | 222 if (!HasBeenSetUp()) return 0; |
227 | 223 |
228 return new_space_.Available() + old_space_->Available() + | 224 return new_space_.Available() + old_space_->Available() + |
229 code_space_->Available() + map_space_->Available() + | 225 code_space_->Available() + map_space_->Available(); |
230 cell_space_->Available(); | |
231 } | 226 } |
232 | 227 |
233 | 228 |
234 bool Heap::HasBeenSetUp() { | 229 bool Heap::HasBeenSetUp() { |
235 return old_space_ != NULL && code_space_ != NULL && map_space_ != NULL && | 230 return old_space_ != NULL && code_space_ != NULL && map_space_ != NULL && |
236 cell_space_ != NULL && lo_space_ != NULL; | 231 lo_space_ != NULL; |
237 } | 232 } |
238 | 233 |
239 | 234 |
240 int Heap::GcSafeSizeOfOldObject(HeapObject* object) { | 235 int Heap::GcSafeSizeOfOldObject(HeapObject* object) { |
241 if (IntrusiveMarking::IsMarked(object)) { | 236 if (IntrusiveMarking::IsMarked(object)) { |
242 return IntrusiveMarking::SizeOfMarkedObject(object); | 237 return IntrusiveMarking::SizeOfMarkedObject(object); |
243 } | 238 } |
244 return object->SizeFromMap(object->map()); | 239 return object->SizeFromMap(object->map()); |
245 } | 240 } |
246 | 241 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 ", committed: %6" V8_PTR_PREFIX "d KB\n", | 345 ", committed: %6" V8_PTR_PREFIX "d KB\n", |
351 code_space_->SizeOfObjects() / KB, code_space_->Available() / KB, | 346 code_space_->SizeOfObjects() / KB, code_space_->Available() / KB, |
352 code_space_->CommittedMemory() / KB); | 347 code_space_->CommittedMemory() / KB); |
353 PrintPID("Map space, used: %6" V8_PTR_PREFIX | 348 PrintPID("Map space, used: %6" V8_PTR_PREFIX |
354 "d KB" | 349 "d KB" |
355 ", available: %6" V8_PTR_PREFIX | 350 ", available: %6" V8_PTR_PREFIX |
356 "d KB" | 351 "d KB" |
357 ", committed: %6" V8_PTR_PREFIX "d KB\n", | 352 ", committed: %6" V8_PTR_PREFIX "d KB\n", |
358 map_space_->SizeOfObjects() / KB, map_space_->Available() / KB, | 353 map_space_->SizeOfObjects() / KB, map_space_->Available() / KB, |
359 map_space_->CommittedMemory() / KB); | 354 map_space_->CommittedMemory() / KB); |
360 PrintPID("Cell space, used: %6" V8_PTR_PREFIX | |
361 "d KB" | |
362 ", available: %6" V8_PTR_PREFIX | |
363 "d KB" | |
364 ", committed: %6" V8_PTR_PREFIX "d KB\n", | |
365 cell_space_->SizeOfObjects() / KB, cell_space_->Available() / KB, | |
366 cell_space_->CommittedMemory() / KB); | |
367 PrintPID("Large object space, used: %6" V8_PTR_PREFIX | 355 PrintPID("Large object space, used: %6" V8_PTR_PREFIX |
368 "d KB" | 356 "d KB" |
369 ", available: %6" V8_PTR_PREFIX | 357 ", available: %6" V8_PTR_PREFIX |
370 "d KB" | 358 "d KB" |
371 ", committed: %6" V8_PTR_PREFIX "d KB\n", | 359 ", committed: %6" V8_PTR_PREFIX "d KB\n", |
372 lo_space_->SizeOfObjects() / KB, lo_space_->Available() / KB, | 360 lo_space_->SizeOfObjects() / KB, lo_space_->Available() / KB, |
373 lo_space_->CommittedMemory() / KB); | 361 lo_space_->CommittedMemory() / KB); |
374 PrintPID("All spaces, used: %6" V8_PTR_PREFIX | 362 PrintPID("All spaces, used: %6" V8_PTR_PREFIX |
375 "d KB" | 363 "d KB" |
376 ", available: %6" V8_PTR_PREFIX | 364 ", available: %6" V8_PTR_PREFIX |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 | 627 |
640 isolate_->counters()->heap_fraction_new_space()->AddSample(static_cast<int>( | 628 isolate_->counters()->heap_fraction_new_space()->AddSample(static_cast<int>( |
641 (new_space()->CommittedMemory() * 100.0) / CommittedMemory())); | 629 (new_space()->CommittedMemory() * 100.0) / CommittedMemory())); |
642 isolate_->counters()->heap_fraction_old_space()->AddSample(static_cast<int>( | 630 isolate_->counters()->heap_fraction_old_space()->AddSample(static_cast<int>( |
643 (old_space()->CommittedMemory() * 100.0) / CommittedMemory())); | 631 (old_space()->CommittedMemory() * 100.0) / CommittedMemory())); |
644 isolate_->counters()->heap_fraction_code_space()->AddSample( | 632 isolate_->counters()->heap_fraction_code_space()->AddSample( |
645 static_cast<int>((code_space()->CommittedMemory() * 100.0) / | 633 static_cast<int>((code_space()->CommittedMemory() * 100.0) / |
646 CommittedMemory())); | 634 CommittedMemory())); |
647 isolate_->counters()->heap_fraction_map_space()->AddSample(static_cast<int>( | 635 isolate_->counters()->heap_fraction_map_space()->AddSample(static_cast<int>( |
648 (map_space()->CommittedMemory() * 100.0) / CommittedMemory())); | 636 (map_space()->CommittedMemory() * 100.0) / CommittedMemory())); |
649 isolate_->counters()->heap_fraction_cell_space()->AddSample( | |
650 static_cast<int>((cell_space()->CommittedMemory() * 100.0) / | |
651 CommittedMemory())); | |
652 isolate_->counters()->heap_fraction_lo_space()->AddSample(static_cast<int>( | 637 isolate_->counters()->heap_fraction_lo_space()->AddSample(static_cast<int>( |
653 (lo_space()->CommittedMemory() * 100.0) / CommittedMemory())); | 638 (lo_space()->CommittedMemory() * 100.0) / CommittedMemory())); |
654 | 639 |
655 isolate_->counters()->heap_sample_total_committed()->AddSample( | 640 isolate_->counters()->heap_sample_total_committed()->AddSample( |
656 static_cast<int>(CommittedMemory() / KB)); | 641 static_cast<int>(CommittedMemory() / KB)); |
657 isolate_->counters()->heap_sample_total_used()->AddSample( | 642 isolate_->counters()->heap_sample_total_used()->AddSample( |
658 static_cast<int>(SizeOfObjects() / KB)); | 643 static_cast<int>(SizeOfObjects() / KB)); |
659 isolate_->counters()->heap_sample_map_space_committed()->AddSample( | 644 isolate_->counters()->heap_sample_map_space_committed()->AddSample( |
660 static_cast<int>(map_space()->CommittedMemory() / KB)); | 645 static_cast<int>(map_space()->CommittedMemory() / KB)); |
661 isolate_->counters()->heap_sample_cell_space_committed()->AddSample( | |
662 static_cast<int>(cell_space()->CommittedMemory() / KB)); | |
663 isolate_->counters()->heap_sample_code_space_committed()->AddSample( | 646 isolate_->counters()->heap_sample_code_space_committed()->AddSample( |
664 static_cast<int>(code_space()->CommittedMemory() / KB)); | 647 static_cast<int>(code_space()->CommittedMemory() / KB)); |
665 | 648 |
666 isolate_->counters()->heap_sample_maximum_committed()->AddSample( | 649 isolate_->counters()->heap_sample_maximum_committed()->AddSample( |
667 static_cast<int>(MaximumCommittedMemory() / KB)); | 650 static_cast<int>(MaximumCommittedMemory() / KB)); |
668 } | 651 } |
669 | 652 |
670 #define UPDATE_COUNTERS_FOR_SPACE(space) \ | 653 #define UPDATE_COUNTERS_FOR_SPACE(space) \ |
671 isolate_->counters()->space##_bytes_available()->Set( \ | 654 isolate_->counters()->space##_bytes_available()->Set( \ |
672 static_cast<int>(space()->Available())); \ | 655 static_cast<int>(space()->Available())); \ |
673 isolate_->counters()->space##_bytes_committed()->Set( \ | 656 isolate_->counters()->space##_bytes_committed()->Set( \ |
674 static_cast<int>(space()->CommittedMemory())); \ | 657 static_cast<int>(space()->CommittedMemory())); \ |
675 isolate_->counters()->space##_bytes_used()->Set( \ | 658 isolate_->counters()->space##_bytes_used()->Set( \ |
676 static_cast<int>(space()->SizeOfObjects())); | 659 static_cast<int>(space()->SizeOfObjects())); |
677 #define UPDATE_FRAGMENTATION_FOR_SPACE(space) \ | 660 #define UPDATE_FRAGMENTATION_FOR_SPACE(space) \ |
678 if (space()->CommittedMemory() > 0) { \ | 661 if (space()->CommittedMemory() > 0) { \ |
679 isolate_->counters()->external_fragmentation_##space()->AddSample( \ | 662 isolate_->counters()->external_fragmentation_##space()->AddSample( \ |
680 static_cast<int>(100 - \ | 663 static_cast<int>(100 - \ |
681 (space()->SizeOfObjects() * 100.0) / \ | 664 (space()->SizeOfObjects() * 100.0) / \ |
682 space()->CommittedMemory())); \ | 665 space()->CommittedMemory())); \ |
683 } | 666 } |
684 #define UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(space) \ | 667 #define UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(space) \ |
685 UPDATE_COUNTERS_FOR_SPACE(space) \ | 668 UPDATE_COUNTERS_FOR_SPACE(space) \ |
686 UPDATE_FRAGMENTATION_FOR_SPACE(space) | 669 UPDATE_FRAGMENTATION_FOR_SPACE(space) |
687 | 670 |
688 UPDATE_COUNTERS_FOR_SPACE(new_space) | 671 UPDATE_COUNTERS_FOR_SPACE(new_space) |
689 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(old_space) | 672 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(old_space) |
690 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(code_space) | 673 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(code_space) |
691 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(map_space) | 674 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(map_space) |
692 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(cell_space) | |
693 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(lo_space) | 675 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(lo_space) |
694 #undef UPDATE_COUNTERS_FOR_SPACE | 676 #undef UPDATE_COUNTERS_FOR_SPACE |
695 #undef UPDATE_FRAGMENTATION_FOR_SPACE | 677 #undef UPDATE_FRAGMENTATION_FOR_SPACE |
696 #undef UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE | 678 #undef UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE |
697 | 679 |
698 #ifdef DEBUG | 680 #ifdef DEBUG |
699 ReportStatisticsAfterGC(); | 681 ReportStatisticsAfterGC(); |
700 #endif // DEBUG | 682 #endif // DEBUG |
701 | 683 |
702 // Remember the last top pointer so that we can later find out | 684 // Remember the last top pointer so that we can later find out |
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 // Copy roots. | 1529 // Copy roots. |
1548 IterateRoots(&scavenge_visitor, VISIT_ALL_IN_SCAVENGE); | 1530 IterateRoots(&scavenge_visitor, VISIT_ALL_IN_SCAVENGE); |
1549 | 1531 |
1550 // Copy objects reachable from the old generation. | 1532 // Copy objects reachable from the old generation. |
1551 { | 1533 { |
1552 StoreBufferRebuildScope scope(this, store_buffer(), | 1534 StoreBufferRebuildScope scope(this, store_buffer(), |
1553 &ScavengeStoreBufferCallback); | 1535 &ScavengeStoreBufferCallback); |
1554 store_buffer()->IteratePointersToNewSpace(&ScavengeObject); | 1536 store_buffer()->IteratePointersToNewSpace(&ScavengeObject); |
1555 } | 1537 } |
1556 | 1538 |
1557 // Copy objects reachable from simple cells by scavenging cell values | |
1558 // directly. | |
1559 HeapObjectIterator cell_iterator(cell_space_); | |
1560 for (HeapObject* heap_object = cell_iterator.Next(); heap_object != NULL; | |
1561 heap_object = cell_iterator.Next()) { | |
1562 if (heap_object->IsCell()) { | |
1563 Cell* cell = Cell::cast(heap_object); | |
1564 Address value_address = cell->ValueAddress(); | |
1565 scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(value_address)); | |
1566 } | |
1567 } | |
1568 | |
1569 // Copy objects reachable from the encountered weak collections list. | 1539 // Copy objects reachable from the encountered weak collections list. |
1570 scavenge_visitor.VisitPointer(&encountered_weak_collections_); | 1540 scavenge_visitor.VisitPointer(&encountered_weak_collections_); |
1571 // Copy objects reachable from the encountered weak cells. | 1541 // Copy objects reachable from the encountered weak cells. |
1572 scavenge_visitor.VisitPointer(&encountered_weak_cells_); | 1542 scavenge_visitor.VisitPointer(&encountered_weak_cells_); |
1573 | 1543 |
1574 // Copy objects reachable from the code flushing candidates list. | 1544 // Copy objects reachable from the code flushing candidates list. |
1575 MarkCompactCollector* collector = mark_compact_collector(); | 1545 MarkCompactCollector* collector = mark_compact_collector(); |
1576 if (collector->is_code_flushing_enabled()) { | 1546 if (collector->is_code_flushing_enabled()) { |
1577 collector->code_flusher()->IteratePointersToFromSpace(&scavenge_visitor); | 1547 collector->code_flusher()->IteratePointersToFromSpace(&scavenge_visitor); |
1578 } | 1548 } |
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2822 return result; | 2792 return result; |
2823 } | 2793 } |
2824 | 2794 |
2825 | 2795 |
2826 AllocationResult Heap::AllocateCell(Object* value) { | 2796 AllocationResult Heap::AllocateCell(Object* value) { |
2827 int size = Cell::kSize; | 2797 int size = Cell::kSize; |
2828 STATIC_ASSERT(Cell::kSize <= Page::kMaxRegularHeapObjectSize); | 2798 STATIC_ASSERT(Cell::kSize <= Page::kMaxRegularHeapObjectSize); |
2829 | 2799 |
2830 HeapObject* result; | 2800 HeapObject* result; |
2831 { | 2801 { |
2832 AllocationResult allocation = AllocateRaw(size, CELL_SPACE, CELL_SPACE); | 2802 AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); |
2833 if (!allocation.To(&result)) return allocation; | 2803 if (!allocation.To(&result)) return allocation; |
2834 } | 2804 } |
2835 result->set_map_no_write_barrier(cell_map()); | 2805 result->set_map_no_write_barrier(cell_map()); |
2836 Cell::cast(result)->set_value(value); | 2806 Cell::cast(result)->set_value(value); |
2837 return result; | 2807 return result; |
2838 } | 2808 } |
2839 | 2809 |
2840 | 2810 |
2841 AllocationResult Heap::AllocatePropertyCell() { | 2811 AllocationResult Heap::AllocatePropertyCell() { |
2842 int size = PropertyCell::kSize; | 2812 int size = PropertyCell::kSize; |
(...skipping 1927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4770 PrintF("Heap statistics : "); | 4740 PrintF("Heap statistics : "); |
4771 isolate_->memory_allocator()->ReportStatistics(); | 4741 isolate_->memory_allocator()->ReportStatistics(); |
4772 PrintF("To space : "); | 4742 PrintF("To space : "); |
4773 new_space_.ReportStatistics(); | 4743 new_space_.ReportStatistics(); |
4774 PrintF("Old space : "); | 4744 PrintF("Old space : "); |
4775 old_space_->ReportStatistics(); | 4745 old_space_->ReportStatistics(); |
4776 PrintF("Code space : "); | 4746 PrintF("Code space : "); |
4777 code_space_->ReportStatistics(); | 4747 code_space_->ReportStatistics(); |
4778 PrintF("Map space : "); | 4748 PrintF("Map space : "); |
4779 map_space_->ReportStatistics(); | 4749 map_space_->ReportStatistics(); |
4780 PrintF("Cell space : "); | |
4781 cell_space_->ReportStatistics(); | |
4782 PrintF("Large object space : "); | 4750 PrintF("Large object space : "); |
4783 lo_space_->ReportStatistics(); | 4751 lo_space_->ReportStatistics(); |
4784 PrintF(">>>>>> ========================================= >>>>>>\n"); | 4752 PrintF(">>>>>> ========================================= >>>>>>\n"); |
4785 } | 4753 } |
4786 | 4754 |
4787 #endif // DEBUG | 4755 #endif // DEBUG |
4788 | 4756 |
4789 bool Heap::Contains(HeapObject* value) { return Contains(value->address()); } | 4757 bool Heap::Contains(HeapObject* value) { return Contains(value->address()); } |
4790 | 4758 |
4791 | 4759 |
4792 bool Heap::Contains(Address addr) { | 4760 bool Heap::Contains(Address addr) { |
4793 if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; | 4761 if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; |
4794 return HasBeenSetUp() && | 4762 return HasBeenSetUp() && |
4795 (new_space_.ToSpaceContains(addr) || old_space_->Contains(addr) || | 4763 (new_space_.ToSpaceContains(addr) || old_space_->Contains(addr) || |
4796 code_space_->Contains(addr) || map_space_->Contains(addr) || | 4764 code_space_->Contains(addr) || map_space_->Contains(addr) || |
4797 cell_space_->Contains(addr) || lo_space_->SlowContains(addr)); | 4765 lo_space_->SlowContains(addr)); |
4798 } | 4766 } |
4799 | 4767 |
4800 | 4768 |
4801 bool Heap::InSpace(HeapObject* value, AllocationSpace space) { | 4769 bool Heap::InSpace(HeapObject* value, AllocationSpace space) { |
4802 return InSpace(value->address(), space); | 4770 return InSpace(value->address(), space); |
4803 } | 4771 } |
4804 | 4772 |
4805 | 4773 |
4806 bool Heap::InSpace(Address addr, AllocationSpace space) { | 4774 bool Heap::InSpace(Address addr, AllocationSpace space) { |
4807 if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; | 4775 if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; |
4808 if (!HasBeenSetUp()) return false; | 4776 if (!HasBeenSetUp()) return false; |
4809 | 4777 |
4810 switch (space) { | 4778 switch (space) { |
4811 case NEW_SPACE: | 4779 case NEW_SPACE: |
4812 return new_space_.ToSpaceContains(addr); | 4780 return new_space_.ToSpaceContains(addr); |
4813 case OLD_SPACE: | 4781 case OLD_SPACE: |
4814 return old_space_->Contains(addr); | 4782 return old_space_->Contains(addr); |
4815 case CODE_SPACE: | 4783 case CODE_SPACE: |
4816 return code_space_->Contains(addr); | 4784 return code_space_->Contains(addr); |
4817 case MAP_SPACE: | 4785 case MAP_SPACE: |
4818 return map_space_->Contains(addr); | 4786 return map_space_->Contains(addr); |
4819 case CELL_SPACE: | |
4820 return cell_space_->Contains(addr); | |
4821 case LO_SPACE: | 4787 case LO_SPACE: |
4822 return lo_space_->SlowContains(addr); | 4788 return lo_space_->SlowContains(addr); |
4823 } | 4789 } |
4824 UNREACHABLE(); | 4790 UNREACHABLE(); |
4825 return false; | 4791 return false; |
4826 } | 4792 } |
4827 | 4793 |
4828 | 4794 |
4829 bool Heap::RootIsImmortalImmovable(int root_index) { | 4795 bool Heap::RootIsImmortalImmovable(int root_index) { |
4830 switch (root_index) { | 4796 switch (root_index) { |
(...skipping 26 matching lines...) Expand all Loading... |
4857 VerifySmisVisitor smis_visitor; | 4823 VerifySmisVisitor smis_visitor; |
4858 IterateSmiRoots(&smis_visitor); | 4824 IterateSmiRoots(&smis_visitor); |
4859 | 4825 |
4860 new_space_.Verify(); | 4826 new_space_.Verify(); |
4861 | 4827 |
4862 old_space_->Verify(&visitor); | 4828 old_space_->Verify(&visitor); |
4863 map_space_->Verify(&visitor); | 4829 map_space_->Verify(&visitor); |
4864 | 4830 |
4865 VerifyPointersVisitor no_dirty_regions_visitor; | 4831 VerifyPointersVisitor no_dirty_regions_visitor; |
4866 code_space_->Verify(&no_dirty_regions_visitor); | 4832 code_space_->Verify(&no_dirty_regions_visitor); |
4867 cell_space_->Verify(&no_dirty_regions_visitor); | |
4868 | 4833 |
4869 lo_space_->Verify(); | 4834 lo_space_->Verify(); |
4870 } | 4835 } |
4871 #endif | 4836 #endif |
4872 | 4837 |
4873 | 4838 |
4874 void Heap::ZapFromSpace() { | 4839 void Heap::ZapFromSpace() { |
4875 NewSpacePageIterator it(new_space_.FromSpaceStart(), | 4840 NewSpacePageIterator it(new_space_.FromSpaceStart(), |
4876 new_space_.FromSpaceEnd()); | 4841 new_space_.FromSpaceEnd()); |
4877 while (it.has_next()) { | 4842 while (it.has_next()) { |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5167 *stats->start_marker = HeapStats::kStartMarker; | 5132 *stats->start_marker = HeapStats::kStartMarker; |
5168 *stats->end_marker = HeapStats::kEndMarker; | 5133 *stats->end_marker = HeapStats::kEndMarker; |
5169 *stats->new_space_size = new_space_.SizeAsInt(); | 5134 *stats->new_space_size = new_space_.SizeAsInt(); |
5170 *stats->new_space_capacity = static_cast<int>(new_space_.Capacity()); | 5135 *stats->new_space_capacity = static_cast<int>(new_space_.Capacity()); |
5171 *stats->old_space_size = old_space_->SizeOfObjects(); | 5136 *stats->old_space_size = old_space_->SizeOfObjects(); |
5172 *stats->old_space_capacity = old_space_->Capacity(); | 5137 *stats->old_space_capacity = old_space_->Capacity(); |
5173 *stats->code_space_size = code_space_->SizeOfObjects(); | 5138 *stats->code_space_size = code_space_->SizeOfObjects(); |
5174 *stats->code_space_capacity = code_space_->Capacity(); | 5139 *stats->code_space_capacity = code_space_->Capacity(); |
5175 *stats->map_space_size = map_space_->SizeOfObjects(); | 5140 *stats->map_space_size = map_space_->SizeOfObjects(); |
5176 *stats->map_space_capacity = map_space_->Capacity(); | 5141 *stats->map_space_capacity = map_space_->Capacity(); |
5177 *stats->cell_space_size = cell_space_->SizeOfObjects(); | |
5178 *stats->cell_space_capacity = cell_space_->Capacity(); | |
5179 *stats->lo_space_size = lo_space_->Size(); | 5142 *stats->lo_space_size = lo_space_->Size(); |
5180 isolate_->global_handles()->RecordStats(stats); | 5143 isolate_->global_handles()->RecordStats(stats); |
5181 *stats->memory_allocator_size = isolate()->memory_allocator()->Size(); | 5144 *stats->memory_allocator_size = isolate()->memory_allocator()->Size(); |
5182 *stats->memory_allocator_capacity = | 5145 *stats->memory_allocator_capacity = |
5183 isolate()->memory_allocator()->Size() + | 5146 isolate()->memory_allocator()->Size() + |
5184 isolate()->memory_allocator()->Available(); | 5147 isolate()->memory_allocator()->Available(); |
5185 *stats->os_error = base::OS::GetLastError(); | 5148 *stats->os_error = base::OS::GetLastError(); |
5186 isolate()->memory_allocator()->Available(); | 5149 isolate()->memory_allocator()->Available(); |
5187 if (take_snapshot) { | 5150 if (take_snapshot) { |
5188 HeapIterator iterator(this); | 5151 HeapIterator iterator(this); |
5189 for (HeapObject* obj = iterator.next(); obj != NULL; | 5152 for (HeapObject* obj = iterator.next(); obj != NULL; |
5190 obj = iterator.next()) { | 5153 obj = iterator.next()) { |
5191 InstanceType type = obj->map()->instance_type(); | 5154 InstanceType type = obj->map()->instance_type(); |
5192 DCHECK(0 <= type && type <= LAST_TYPE); | 5155 DCHECK(0 <= type && type <= LAST_TYPE); |
5193 stats->objects_per_type[type]++; | 5156 stats->objects_per_type[type]++; |
5194 stats->size_per_type[type] += obj->Size(); | 5157 stats->size_per_type[type] += obj->Size(); |
5195 } | 5158 } |
5196 } | 5159 } |
5197 } | 5160 } |
5198 | 5161 |
5199 | 5162 |
5200 intptr_t Heap::PromotedSpaceSizeOfObjects() { | 5163 intptr_t Heap::PromotedSpaceSizeOfObjects() { |
5201 return old_space_->SizeOfObjects() + code_space_->SizeOfObjects() + | 5164 return old_space_->SizeOfObjects() + code_space_->SizeOfObjects() + |
5202 map_space_->SizeOfObjects() + cell_space_->SizeOfObjects() + | 5165 map_space_->SizeOfObjects() + lo_space_->SizeOfObjects(); |
5203 lo_space_->SizeOfObjects(); | |
5204 } | 5166 } |
5205 | 5167 |
5206 | 5168 |
5207 int64_t Heap::PromotedExternalMemorySize() { | 5169 int64_t Heap::PromotedExternalMemorySize() { |
5208 if (amount_of_external_allocated_memory_ <= | 5170 if (amount_of_external_allocated_memory_ <= |
5209 amount_of_external_allocated_memory_at_last_global_gc_) | 5171 amount_of_external_allocated_memory_at_last_global_gc_) |
5210 return 0; | 5172 return 0; |
5211 return amount_of_external_allocated_memory_ - | 5173 return amount_of_external_allocated_memory_ - |
5212 amount_of_external_allocated_memory_at_last_global_gc_; | 5174 amount_of_external_allocated_memory_at_last_global_gc_; |
5213 } | 5175 } |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5335 code_space_ = | 5297 code_space_ = |
5336 new OldSpace(this, max_old_generation_size_, CODE_SPACE, EXECUTABLE); | 5298 new OldSpace(this, max_old_generation_size_, CODE_SPACE, EXECUTABLE); |
5337 if (code_space_ == NULL) return false; | 5299 if (code_space_ == NULL) return false; |
5338 if (!code_space_->SetUp()) return false; | 5300 if (!code_space_->SetUp()) return false; |
5339 | 5301 |
5340 // Initialize map space. | 5302 // Initialize map space. |
5341 map_space_ = new MapSpace(this, max_old_generation_size_, MAP_SPACE); | 5303 map_space_ = new MapSpace(this, max_old_generation_size_, MAP_SPACE); |
5342 if (map_space_ == NULL) return false; | 5304 if (map_space_ == NULL) return false; |
5343 if (!map_space_->SetUp()) return false; | 5305 if (!map_space_->SetUp()) return false; |
5344 | 5306 |
5345 // Initialize simple cell space. | |
5346 cell_space_ = new CellSpace(this, max_old_generation_size_, CELL_SPACE); | |
5347 if (cell_space_ == NULL) return false; | |
5348 if (!cell_space_->SetUp()) return false; | |
5349 | |
5350 // The large object code space may contain code or data. We set the memory | 5307 // The large object code space may contain code or data. We set the memory |
5351 // to be non-executable here for safety, but this means we need to enable it | 5308 // to be non-executable here for safety, but this means we need to enable it |
5352 // explicitly when allocating large code objects. | 5309 // explicitly when allocating large code objects. |
5353 lo_space_ = new LargeObjectSpace(this, max_old_generation_size_, LO_SPACE); | 5310 lo_space_ = new LargeObjectSpace(this, max_old_generation_size_, LO_SPACE); |
5354 if (lo_space_ == NULL) return false; | 5311 if (lo_space_ == NULL) return false; |
5355 if (!lo_space_->SetUp()) return false; | 5312 if (!lo_space_->SetUp()) return false; |
5356 | 5313 |
5357 // Set up the seed that is used to randomize the string hash function. | 5314 // Set up the seed that is used to randomize the string hash function. |
5358 DCHECK(hash_seed() == 0); | 5315 DCHECK(hash_seed() == 0); |
5359 if (FLAG_randomize_hashes) { | 5316 if (FLAG_randomize_hashes) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5448 PrintF("maximum_committed_by_heap=%" V8_PTR_PREFIX "d ", | 5405 PrintF("maximum_committed_by_heap=%" V8_PTR_PREFIX "d ", |
5449 MaximumCommittedMemory()); | 5406 MaximumCommittedMemory()); |
5450 PrintF("maximum_committed_by_new_space=%" V8_PTR_PREFIX "d ", | 5407 PrintF("maximum_committed_by_new_space=%" V8_PTR_PREFIX "d ", |
5451 new_space_.MaximumCommittedMemory()); | 5408 new_space_.MaximumCommittedMemory()); |
5452 PrintF("maximum_committed_by_old_space=%" V8_PTR_PREFIX "d ", | 5409 PrintF("maximum_committed_by_old_space=%" V8_PTR_PREFIX "d ", |
5453 old_space_->MaximumCommittedMemory()); | 5410 old_space_->MaximumCommittedMemory()); |
5454 PrintF("maximum_committed_by_code_space=%" V8_PTR_PREFIX "d ", | 5411 PrintF("maximum_committed_by_code_space=%" V8_PTR_PREFIX "d ", |
5455 code_space_->MaximumCommittedMemory()); | 5412 code_space_->MaximumCommittedMemory()); |
5456 PrintF("maximum_committed_by_map_space=%" V8_PTR_PREFIX "d ", | 5413 PrintF("maximum_committed_by_map_space=%" V8_PTR_PREFIX "d ", |
5457 map_space_->MaximumCommittedMemory()); | 5414 map_space_->MaximumCommittedMemory()); |
5458 PrintF("maximum_committed_by_cell_space=%" V8_PTR_PREFIX "d ", | |
5459 cell_space_->MaximumCommittedMemory()); | |
5460 PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ", | 5415 PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ", |
5461 lo_space_->MaximumCommittedMemory()); | 5416 lo_space_->MaximumCommittedMemory()); |
5462 PrintF("\n\n"); | 5417 PrintF("\n\n"); |
5463 } | 5418 } |
5464 | 5419 |
5465 if (FLAG_verify_predictable) { | 5420 if (FLAG_verify_predictable) { |
5466 PrintAlloctionsHash(); | 5421 PrintAlloctionsHash(); |
5467 } | 5422 } |
5468 | 5423 |
5469 TearDownArrayBuffers(); | 5424 TearDownArrayBuffers(); |
(...skipping 17 matching lines...) Expand all Loading... |
5487 delete code_space_; | 5442 delete code_space_; |
5488 code_space_ = NULL; | 5443 code_space_ = NULL; |
5489 } | 5444 } |
5490 | 5445 |
5491 if (map_space_ != NULL) { | 5446 if (map_space_ != NULL) { |
5492 map_space_->TearDown(); | 5447 map_space_->TearDown(); |
5493 delete map_space_; | 5448 delete map_space_; |
5494 map_space_ = NULL; | 5449 map_space_ = NULL; |
5495 } | 5450 } |
5496 | 5451 |
5497 if (cell_space_ != NULL) { | |
5498 cell_space_->TearDown(); | |
5499 delete cell_space_; | |
5500 cell_space_ = NULL; | |
5501 } | |
5502 | |
5503 if (lo_space_ != NULL) { | 5452 if (lo_space_ != NULL) { |
5504 lo_space_->TearDown(); | 5453 lo_space_->TearDown(); |
5505 delete lo_space_; | 5454 delete lo_space_; |
5506 lo_space_ = NULL; | 5455 lo_space_ = NULL; |
5507 } | 5456 } |
5508 | 5457 |
5509 store_buffer()->TearDown(); | 5458 store_buffer()->TearDown(); |
5510 | 5459 |
5511 isolate_->memory_allocator()->TearDown(); | 5460 isolate_->memory_allocator()->TearDown(); |
5512 } | 5461 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5633 Space* AllSpaces::next() { | 5582 Space* AllSpaces::next() { |
5634 switch (counter_++) { | 5583 switch (counter_++) { |
5635 case NEW_SPACE: | 5584 case NEW_SPACE: |
5636 return heap_->new_space(); | 5585 return heap_->new_space(); |
5637 case OLD_SPACE: | 5586 case OLD_SPACE: |
5638 return heap_->old_space(); | 5587 return heap_->old_space(); |
5639 case CODE_SPACE: | 5588 case CODE_SPACE: |
5640 return heap_->code_space(); | 5589 return heap_->code_space(); |
5641 case MAP_SPACE: | 5590 case MAP_SPACE: |
5642 return heap_->map_space(); | 5591 return heap_->map_space(); |
5643 case CELL_SPACE: | |
5644 return heap_->cell_space(); | |
5645 case LO_SPACE: | 5592 case LO_SPACE: |
5646 return heap_->lo_space(); | 5593 return heap_->lo_space(); |
5647 default: | 5594 default: |
5648 return NULL; | 5595 return NULL; |
5649 } | 5596 } |
5650 } | 5597 } |
5651 | 5598 |
5652 | 5599 |
5653 PagedSpace* PagedSpaces::next() { | 5600 PagedSpace* PagedSpaces::next() { |
5654 switch (counter_++) { | 5601 switch (counter_++) { |
5655 case OLD_SPACE: | 5602 case OLD_SPACE: |
5656 return heap_->old_space(); | 5603 return heap_->old_space(); |
5657 case CODE_SPACE: | 5604 case CODE_SPACE: |
5658 return heap_->code_space(); | 5605 return heap_->code_space(); |
5659 case MAP_SPACE: | 5606 case MAP_SPACE: |
5660 return heap_->map_space(); | 5607 return heap_->map_space(); |
5661 case CELL_SPACE: | |
5662 return heap_->cell_space(); | |
5663 default: | 5608 default: |
5664 return NULL; | 5609 return NULL; |
5665 } | 5610 } |
5666 } | 5611 } |
5667 | 5612 |
5668 | 5613 |
5669 OldSpace* OldSpaces::next() { | 5614 OldSpace* OldSpaces::next() { |
5670 switch (counter_++) { | 5615 switch (counter_++) { |
5671 case OLD_SPACE: | 5616 case OLD_SPACE: |
5672 return heap_->old_space(); | 5617 return heap_->old_space(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5730 break; | 5675 break; |
5731 case OLD_SPACE: | 5676 case OLD_SPACE: |
5732 iterator_ = new HeapObjectIterator(heap_->old_space(), size_func_); | 5677 iterator_ = new HeapObjectIterator(heap_->old_space(), size_func_); |
5733 break; | 5678 break; |
5734 case CODE_SPACE: | 5679 case CODE_SPACE: |
5735 iterator_ = new HeapObjectIterator(heap_->code_space(), size_func_); | 5680 iterator_ = new HeapObjectIterator(heap_->code_space(), size_func_); |
5736 break; | 5681 break; |
5737 case MAP_SPACE: | 5682 case MAP_SPACE: |
5738 iterator_ = new HeapObjectIterator(heap_->map_space(), size_func_); | 5683 iterator_ = new HeapObjectIterator(heap_->map_space(), size_func_); |
5739 break; | 5684 break; |
5740 case CELL_SPACE: | |
5741 iterator_ = new HeapObjectIterator(heap_->cell_space(), size_func_); | |
5742 break; | |
5743 case LO_SPACE: | 5685 case LO_SPACE: |
5744 iterator_ = new LargeObjectIterator(heap_->lo_space(), size_func_); | 5686 iterator_ = new LargeObjectIterator(heap_->lo_space(), size_func_); |
5745 break; | 5687 break; |
5746 } | 5688 } |
5747 | 5689 |
5748 // Return the newly allocated iterator; | 5690 // Return the newly allocated iterator; |
5749 DCHECK(iterator_ != NULL); | 5691 DCHECK(iterator_ != NULL); |
5750 return iterator_; | 5692 return iterator_; |
5751 } | 5693 } |
5752 | 5694 |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6364 static_cast<int>(object_sizes_last_time_[index])); | 6306 static_cast<int>(object_sizes_last_time_[index])); |
6365 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6307 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
6366 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6308 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
6367 | 6309 |
6368 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6310 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
6369 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6311 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
6370 ClearObjectStats(); | 6312 ClearObjectStats(); |
6371 } | 6313 } |
6372 } | 6314 } |
6373 } // namespace v8::internal | 6315 } // namespace v8::internal |
OLD | NEW |