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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_pointer_space_(NULL), | 87 old_pointer_space_(NULL), |
88 old_data_space_(NULL), | 88 old_data_space_(NULL), |
89 code_space_(NULL), | 89 code_space_(NULL), |
90 map_space_(NULL), | 90 map_space_(NULL), |
91 cell_space_(NULL), | 91 cell_space_(NULL), |
92 property_cell_space_(NULL), | |
93 lo_space_(NULL), | 92 lo_space_(NULL), |
94 gc_state_(NOT_IN_GC), | 93 gc_state_(NOT_IN_GC), |
95 gc_post_processing_depth_(0), | 94 gc_post_processing_depth_(0), |
96 allocations_count_(0), | 95 allocations_count_(0), |
97 raw_allocations_hash_(0), | 96 raw_allocations_hash_(0), |
98 dump_allocations_hash_countdown_(FLAG_dump_allocations_digest_at_alloc), | 97 dump_allocations_hash_countdown_(FLAG_dump_allocations_digest_at_alloc), |
99 ms_count_(0), | 98 ms_count_(0), |
100 gc_count_(0), | 99 gc_count_(0), |
101 remembered_unmapped_pages_index_(0), | 100 remembered_unmapped_pages_index_(0), |
102 unflattened_strings_length_(0), | 101 unflattened_strings_length_(0), |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 167 |
169 ClearObjectStats(true); | 168 ClearObjectStats(true); |
170 } | 169 } |
171 | 170 |
172 | 171 |
173 intptr_t Heap::Capacity() { | 172 intptr_t Heap::Capacity() { |
174 if (!HasBeenSetUp()) return 0; | 173 if (!HasBeenSetUp()) return 0; |
175 | 174 |
176 return new_space_.Capacity() + old_pointer_space_->Capacity() + | 175 return new_space_.Capacity() + old_pointer_space_->Capacity() + |
177 old_data_space_->Capacity() + code_space_->Capacity() + | 176 old_data_space_->Capacity() + code_space_->Capacity() + |
178 map_space_->Capacity() + cell_space_->Capacity() + | 177 map_space_->Capacity() + cell_space_->Capacity(); |
179 property_cell_space_->Capacity(); | |
180 } | 178 } |
181 | 179 |
182 | 180 |
183 intptr_t Heap::CommittedOldGenerationMemory() { | 181 intptr_t Heap::CommittedOldGenerationMemory() { |
184 if (!HasBeenSetUp()) return 0; | 182 if (!HasBeenSetUp()) return 0; |
185 | 183 |
186 return old_pointer_space_->CommittedMemory() + | 184 return old_pointer_space_->CommittedMemory() + |
187 old_data_space_->CommittedMemory() + code_space_->CommittedMemory() + | 185 old_data_space_->CommittedMemory() + code_space_->CommittedMemory() + |
188 map_space_->CommittedMemory() + cell_space_->CommittedMemory() + | 186 map_space_->CommittedMemory() + cell_space_->CommittedMemory() + |
189 property_cell_space_->CommittedMemory() + lo_space_->Size(); | 187 lo_space_->Size(); |
190 } | 188 } |
191 | 189 |
192 | 190 |
193 intptr_t Heap::CommittedMemory() { | 191 intptr_t Heap::CommittedMemory() { |
194 if (!HasBeenSetUp()) return 0; | 192 if (!HasBeenSetUp()) return 0; |
195 | 193 |
196 return new_space_.CommittedMemory() + CommittedOldGenerationMemory(); | 194 return new_space_.CommittedMemory() + CommittedOldGenerationMemory(); |
197 } | 195 } |
198 | 196 |
199 | 197 |
200 size_t Heap::CommittedPhysicalMemory() { | 198 size_t Heap::CommittedPhysicalMemory() { |
201 if (!HasBeenSetUp()) return 0; | 199 if (!HasBeenSetUp()) return 0; |
202 | 200 |
203 return new_space_.CommittedPhysicalMemory() + | 201 return new_space_.CommittedPhysicalMemory() + |
204 old_pointer_space_->CommittedPhysicalMemory() + | 202 old_pointer_space_->CommittedPhysicalMemory() + |
205 old_data_space_->CommittedPhysicalMemory() + | 203 old_data_space_->CommittedPhysicalMemory() + |
206 code_space_->CommittedPhysicalMemory() + | 204 code_space_->CommittedPhysicalMemory() + |
207 map_space_->CommittedPhysicalMemory() + | 205 map_space_->CommittedPhysicalMemory() + |
208 cell_space_->CommittedPhysicalMemory() + | 206 cell_space_->CommittedPhysicalMemory() + |
209 property_cell_space_->CommittedPhysicalMemory() + | |
210 lo_space_->CommittedPhysicalMemory(); | 207 lo_space_->CommittedPhysicalMemory(); |
211 } | 208 } |
212 | 209 |
213 | 210 |
214 intptr_t Heap::CommittedMemoryExecutable() { | 211 intptr_t Heap::CommittedMemoryExecutable() { |
215 if (!HasBeenSetUp()) return 0; | 212 if (!HasBeenSetUp()) return 0; |
216 | 213 |
217 return isolate()->memory_allocator()->SizeExecutable(); | 214 return isolate()->memory_allocator()->SizeExecutable(); |
218 } | 215 } |
219 | 216 |
220 | 217 |
221 void Heap::UpdateMaximumCommitted() { | 218 void Heap::UpdateMaximumCommitted() { |
222 if (!HasBeenSetUp()) return; | 219 if (!HasBeenSetUp()) return; |
223 | 220 |
224 intptr_t current_committed_memory = CommittedMemory(); | 221 intptr_t current_committed_memory = CommittedMemory(); |
225 if (current_committed_memory > maximum_committed_) { | 222 if (current_committed_memory > maximum_committed_) { |
226 maximum_committed_ = current_committed_memory; | 223 maximum_committed_ = current_committed_memory; |
227 } | 224 } |
228 } | 225 } |
229 | 226 |
230 | 227 |
231 intptr_t Heap::Available() { | 228 intptr_t Heap::Available() { |
232 if (!HasBeenSetUp()) return 0; | 229 if (!HasBeenSetUp()) return 0; |
233 | 230 |
234 return new_space_.Available() + old_pointer_space_->Available() + | 231 return new_space_.Available() + old_pointer_space_->Available() + |
235 old_data_space_->Available() + code_space_->Available() + | 232 old_data_space_->Available() + code_space_->Available() + |
236 map_space_->Available() + cell_space_->Available() + | 233 map_space_->Available() + cell_space_->Available(); |
237 property_cell_space_->Available(); | |
238 } | 234 } |
239 | 235 |
240 | 236 |
241 bool Heap::HasBeenSetUp() { | 237 bool Heap::HasBeenSetUp() { |
242 return old_pointer_space_ != NULL && old_data_space_ != NULL && | 238 return old_pointer_space_ != NULL && old_data_space_ != NULL && |
243 code_space_ != NULL && map_space_ != NULL && cell_space_ != NULL && | 239 code_space_ != NULL && map_space_ != NULL && cell_space_ != NULL && |
244 property_cell_space_ != NULL && lo_space_ != NULL; | 240 lo_space_ != NULL; |
245 } | 241 } |
246 | 242 |
247 | 243 |
248 int Heap::GcSafeSizeOfOldObject(HeapObject* object) { | 244 int Heap::GcSafeSizeOfOldObject(HeapObject* object) { |
249 if (IntrusiveMarking::IsMarked(object)) { | 245 if (IntrusiveMarking::IsMarked(object)) { |
250 return IntrusiveMarking::SizeOfMarkedObject(object); | 246 return IntrusiveMarking::SizeOfMarkedObject(object); |
251 } | 247 } |
252 return object->SizeFromMap(object->map()); | 248 return object->SizeFromMap(object->map()); |
253 } | 249 } |
254 | 250 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 ", committed: %6" V8_PTR_PREFIX "d KB\n", | 370 ", committed: %6" V8_PTR_PREFIX "d KB\n", |
375 map_space_->SizeOfObjects() / KB, map_space_->Available() / KB, | 371 map_space_->SizeOfObjects() / KB, map_space_->Available() / KB, |
376 map_space_->CommittedMemory() / KB); | 372 map_space_->CommittedMemory() / KB); |
377 PrintPID("Cell space, used: %6" V8_PTR_PREFIX | 373 PrintPID("Cell space, used: %6" V8_PTR_PREFIX |
378 "d KB" | 374 "d KB" |
379 ", available: %6" V8_PTR_PREFIX | 375 ", available: %6" V8_PTR_PREFIX |
380 "d KB" | 376 "d KB" |
381 ", committed: %6" V8_PTR_PREFIX "d KB\n", | 377 ", committed: %6" V8_PTR_PREFIX "d KB\n", |
382 cell_space_->SizeOfObjects() / KB, cell_space_->Available() / KB, | 378 cell_space_->SizeOfObjects() / KB, cell_space_->Available() / KB, |
383 cell_space_->CommittedMemory() / KB); | 379 cell_space_->CommittedMemory() / KB); |
384 PrintPID("PropertyCell space, used: %6" V8_PTR_PREFIX | |
385 "d KB" | |
386 ", available: %6" V8_PTR_PREFIX | |
387 "d KB" | |
388 ", committed: %6" V8_PTR_PREFIX "d KB\n", | |
389 property_cell_space_->SizeOfObjects() / KB, | |
390 property_cell_space_->Available() / KB, | |
391 property_cell_space_->CommittedMemory() / KB); | |
392 PrintPID("Large object space, used: %6" V8_PTR_PREFIX | 380 PrintPID("Large object space, used: %6" V8_PTR_PREFIX |
393 "d KB" | 381 "d KB" |
394 ", available: %6" V8_PTR_PREFIX | 382 ", available: %6" V8_PTR_PREFIX |
395 "d KB" | 383 "d KB" |
396 ", committed: %6" V8_PTR_PREFIX "d KB\n", | 384 ", committed: %6" V8_PTR_PREFIX "d KB\n", |
397 lo_space_->SizeOfObjects() / KB, lo_space_->Available() / KB, | 385 lo_space_->SizeOfObjects() / KB, lo_space_->Available() / KB, |
398 lo_space_->CommittedMemory() / KB); | 386 lo_space_->CommittedMemory() / KB); |
399 PrintPID("All spaces, used: %6" V8_PTR_PREFIX | 387 PrintPID("All spaces, used: %6" V8_PTR_PREFIX |
400 "d KB" | 388 "d KB" |
401 ", available: %6" V8_PTR_PREFIX | 389 ", available: %6" V8_PTR_PREFIX |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 static_cast<int>((old_data_space()->CommittedMemory() * 100.0) / | 658 static_cast<int>((old_data_space()->CommittedMemory() * 100.0) / |
671 CommittedMemory())); | 659 CommittedMemory())); |
672 isolate_->counters()->heap_fraction_code_space()->AddSample( | 660 isolate_->counters()->heap_fraction_code_space()->AddSample( |
673 static_cast<int>((code_space()->CommittedMemory() * 100.0) / | 661 static_cast<int>((code_space()->CommittedMemory() * 100.0) / |
674 CommittedMemory())); | 662 CommittedMemory())); |
675 isolate_->counters()->heap_fraction_map_space()->AddSample(static_cast<int>( | 663 isolate_->counters()->heap_fraction_map_space()->AddSample(static_cast<int>( |
676 (map_space()->CommittedMemory() * 100.0) / CommittedMemory())); | 664 (map_space()->CommittedMemory() * 100.0) / CommittedMemory())); |
677 isolate_->counters()->heap_fraction_cell_space()->AddSample( | 665 isolate_->counters()->heap_fraction_cell_space()->AddSample( |
678 static_cast<int>((cell_space()->CommittedMemory() * 100.0) / | 666 static_cast<int>((cell_space()->CommittedMemory() * 100.0) / |
679 CommittedMemory())); | 667 CommittedMemory())); |
680 isolate_->counters()->heap_fraction_property_cell_space()->AddSample( | |
681 static_cast<int>((property_cell_space()->CommittedMemory() * 100.0) / | |
682 CommittedMemory())); | |
683 isolate_->counters()->heap_fraction_lo_space()->AddSample(static_cast<int>( | 668 isolate_->counters()->heap_fraction_lo_space()->AddSample(static_cast<int>( |
684 (lo_space()->CommittedMemory() * 100.0) / CommittedMemory())); | 669 (lo_space()->CommittedMemory() * 100.0) / CommittedMemory())); |
685 | 670 |
686 isolate_->counters()->heap_sample_total_committed()->AddSample( | 671 isolate_->counters()->heap_sample_total_committed()->AddSample( |
687 static_cast<int>(CommittedMemory() / KB)); | 672 static_cast<int>(CommittedMemory() / KB)); |
688 isolate_->counters()->heap_sample_total_used()->AddSample( | 673 isolate_->counters()->heap_sample_total_used()->AddSample( |
689 static_cast<int>(SizeOfObjects() / KB)); | 674 static_cast<int>(SizeOfObjects() / KB)); |
690 isolate_->counters()->heap_sample_map_space_committed()->AddSample( | 675 isolate_->counters()->heap_sample_map_space_committed()->AddSample( |
691 static_cast<int>(map_space()->CommittedMemory() / KB)); | 676 static_cast<int>(map_space()->CommittedMemory() / KB)); |
692 isolate_->counters()->heap_sample_cell_space_committed()->AddSample( | 677 isolate_->counters()->heap_sample_cell_space_committed()->AddSample( |
693 static_cast<int>(cell_space()->CommittedMemory() / KB)); | 678 static_cast<int>(cell_space()->CommittedMemory() / KB)); |
694 isolate_->counters() | |
695 ->heap_sample_property_cell_space_committed() | |
696 ->AddSample( | |
697 static_cast<int>(property_cell_space()->CommittedMemory() / KB)); | |
698 isolate_->counters()->heap_sample_code_space_committed()->AddSample( | 679 isolate_->counters()->heap_sample_code_space_committed()->AddSample( |
699 static_cast<int>(code_space()->CommittedMemory() / KB)); | 680 static_cast<int>(code_space()->CommittedMemory() / KB)); |
700 | 681 |
701 isolate_->counters()->heap_sample_maximum_committed()->AddSample( | 682 isolate_->counters()->heap_sample_maximum_committed()->AddSample( |
702 static_cast<int>(MaximumCommittedMemory() / KB)); | 683 static_cast<int>(MaximumCommittedMemory() / KB)); |
703 } | 684 } |
704 | 685 |
705 #define UPDATE_COUNTERS_FOR_SPACE(space) \ | 686 #define UPDATE_COUNTERS_FOR_SPACE(space) \ |
706 isolate_->counters()->space##_bytes_available()->Set( \ | 687 isolate_->counters()->space##_bytes_available()->Set( \ |
707 static_cast<int>(space()->Available())); \ | 688 static_cast<int>(space()->Available())); \ |
(...skipping 11 matching lines...) Expand all Loading... |
719 #define UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(space) \ | 700 #define UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(space) \ |
720 UPDATE_COUNTERS_FOR_SPACE(space) \ | 701 UPDATE_COUNTERS_FOR_SPACE(space) \ |
721 UPDATE_FRAGMENTATION_FOR_SPACE(space) | 702 UPDATE_FRAGMENTATION_FOR_SPACE(space) |
722 | 703 |
723 UPDATE_COUNTERS_FOR_SPACE(new_space) | 704 UPDATE_COUNTERS_FOR_SPACE(new_space) |
724 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(old_pointer_space) | 705 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(old_pointer_space) |
725 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(old_data_space) | 706 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(old_data_space) |
726 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(code_space) | 707 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(code_space) |
727 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(map_space) | 708 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(map_space) |
728 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(cell_space) | 709 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(cell_space) |
729 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(property_cell_space) | |
730 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(lo_space) | 710 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(lo_space) |
731 #undef UPDATE_COUNTERS_FOR_SPACE | 711 #undef UPDATE_COUNTERS_FOR_SPACE |
732 #undef UPDATE_FRAGMENTATION_FOR_SPACE | 712 #undef UPDATE_FRAGMENTATION_FOR_SPACE |
733 #undef UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE | 713 #undef UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE |
734 | 714 |
735 #ifdef DEBUG | 715 #ifdef DEBUG |
736 ReportStatisticsAfterGC(); | 716 ReportStatisticsAfterGC(); |
737 #endif // DEBUG | 717 #endif // DEBUG |
738 | 718 |
739 // Remember the last top pointer so that we can later find out | 719 // Remember the last top pointer so that we can later find out |
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1595 HeapObjectIterator cell_iterator(cell_space_); | 1575 HeapObjectIterator cell_iterator(cell_space_); |
1596 for (HeapObject* heap_object = cell_iterator.Next(); heap_object != NULL; | 1576 for (HeapObject* heap_object = cell_iterator.Next(); heap_object != NULL; |
1597 heap_object = cell_iterator.Next()) { | 1577 heap_object = cell_iterator.Next()) { |
1598 if (heap_object->IsCell()) { | 1578 if (heap_object->IsCell()) { |
1599 Cell* cell = Cell::cast(heap_object); | 1579 Cell* cell = Cell::cast(heap_object); |
1600 Address value_address = cell->ValueAddress(); | 1580 Address value_address = cell->ValueAddress(); |
1601 scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(value_address)); | 1581 scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(value_address)); |
1602 } | 1582 } |
1603 } | 1583 } |
1604 | 1584 |
1605 // Copy objects reachable from global property cells by scavenging global | |
1606 // property cell values directly. | |
1607 HeapObjectIterator js_global_property_cell_iterator(property_cell_space_); | |
1608 for (HeapObject* heap_object = js_global_property_cell_iterator.Next(); | |
1609 heap_object != NULL; | |
1610 heap_object = js_global_property_cell_iterator.Next()) { | |
1611 if (heap_object->IsPropertyCell()) { | |
1612 PropertyCell* cell = PropertyCell::cast(heap_object); | |
1613 Address value_address = cell->ValueAddress(); | |
1614 scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(value_address)); | |
1615 } | |
1616 } | |
1617 | |
1618 // Copy objects reachable from the encountered weak collections list. | 1585 // Copy objects reachable from the encountered weak collections list. |
1619 scavenge_visitor.VisitPointer(&encountered_weak_collections_); | 1586 scavenge_visitor.VisitPointer(&encountered_weak_collections_); |
1620 // Copy objects reachable from the encountered weak cells. | 1587 // Copy objects reachable from the encountered weak cells. |
1621 scavenge_visitor.VisitPointer(&encountered_weak_cells_); | 1588 scavenge_visitor.VisitPointer(&encountered_weak_cells_); |
1622 | 1589 |
1623 // Copy objects reachable from the code flushing candidates list. | 1590 // Copy objects reachable from the code flushing candidates list. |
1624 MarkCompactCollector* collector = mark_compact_collector(); | 1591 MarkCompactCollector* collector = mark_compact_collector(); |
1625 if (collector->is_code_flushing_enabled()) { | 1592 if (collector->is_code_flushing_enabled()) { |
1626 collector->code_flusher()->IteratePointersToFromSpace(&scavenge_visitor); | 1593 collector->code_flusher()->IteratePointersToFromSpace(&scavenge_visitor); |
1627 } | 1594 } |
(...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2877 return result; | 2844 return result; |
2878 } | 2845 } |
2879 | 2846 |
2880 | 2847 |
2881 AllocationResult Heap::AllocatePropertyCell() { | 2848 AllocationResult Heap::AllocatePropertyCell() { |
2882 int size = PropertyCell::kSize; | 2849 int size = PropertyCell::kSize; |
2883 STATIC_ASSERT(PropertyCell::kSize <= Page::kMaxRegularHeapObjectSize); | 2850 STATIC_ASSERT(PropertyCell::kSize <= Page::kMaxRegularHeapObjectSize); |
2884 | 2851 |
2885 HeapObject* result; | 2852 HeapObject* result; |
2886 AllocationResult allocation = | 2853 AllocationResult allocation = |
2887 AllocateRaw(size, PROPERTY_CELL_SPACE, PROPERTY_CELL_SPACE); | 2854 AllocateRaw(size, OLD_POINTER_SPACE, OLD_POINTER_SPACE); |
2888 if (!allocation.To(&result)) return allocation; | 2855 if (!allocation.To(&result)) return allocation; |
2889 | 2856 |
2890 result->set_map_no_write_barrier(global_property_cell_map()); | 2857 result->set_map_no_write_barrier(global_property_cell_map()); |
2891 PropertyCell* cell = PropertyCell::cast(result); | 2858 PropertyCell* cell = PropertyCell::cast(result); |
2892 cell->set_dependent_code(DependentCode::cast(empty_fixed_array()), | 2859 cell->set_dependent_code(DependentCode::cast(empty_fixed_array()), |
2893 SKIP_WRITE_BARRIER); | 2860 SKIP_WRITE_BARRIER); |
2894 cell->set_value(the_hole_value()); | 2861 cell->set_value(the_hole_value()); |
2895 return result; | 2862 return result; |
2896 } | 2863 } |
2897 | 2864 |
(...skipping 1900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4798 PrintF("Old pointer space : "); | 4765 PrintF("Old pointer space : "); |
4799 old_pointer_space_->ReportStatistics(); | 4766 old_pointer_space_->ReportStatistics(); |
4800 PrintF("Old data space : "); | 4767 PrintF("Old data space : "); |
4801 old_data_space_->ReportStatistics(); | 4768 old_data_space_->ReportStatistics(); |
4802 PrintF("Code space : "); | 4769 PrintF("Code space : "); |
4803 code_space_->ReportStatistics(); | 4770 code_space_->ReportStatistics(); |
4804 PrintF("Map space : "); | 4771 PrintF("Map space : "); |
4805 map_space_->ReportStatistics(); | 4772 map_space_->ReportStatistics(); |
4806 PrintF("Cell space : "); | 4773 PrintF("Cell space : "); |
4807 cell_space_->ReportStatistics(); | 4774 cell_space_->ReportStatistics(); |
4808 PrintF("PropertyCell space : "); | |
4809 property_cell_space_->ReportStatistics(); | |
4810 PrintF("Large object space : "); | 4775 PrintF("Large object space : "); |
4811 lo_space_->ReportStatistics(); | 4776 lo_space_->ReportStatistics(); |
4812 PrintF(">>>>>> ========================================= >>>>>>\n"); | 4777 PrintF(">>>>>> ========================================= >>>>>>\n"); |
4813 } | 4778 } |
4814 | 4779 |
4815 #endif // DEBUG | 4780 #endif // DEBUG |
4816 | 4781 |
4817 bool Heap::Contains(HeapObject* value) { return Contains(value->address()); } | 4782 bool Heap::Contains(HeapObject* value) { return Contains(value->address()); } |
4818 | 4783 |
4819 | 4784 |
4820 bool Heap::Contains(Address addr) { | 4785 bool Heap::Contains(Address addr) { |
4821 if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; | 4786 if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; |
4822 return HasBeenSetUp() && | 4787 return HasBeenSetUp() && |
4823 (new_space_.ToSpaceContains(addr) || | 4788 (new_space_.ToSpaceContains(addr) || |
4824 old_pointer_space_->Contains(addr) || | 4789 old_pointer_space_->Contains(addr) || |
4825 old_data_space_->Contains(addr) || code_space_->Contains(addr) || | 4790 old_data_space_->Contains(addr) || code_space_->Contains(addr) || |
4826 map_space_->Contains(addr) || cell_space_->Contains(addr) || | 4791 map_space_->Contains(addr) || cell_space_->Contains(addr) || |
4827 property_cell_space_->Contains(addr) || | |
4828 lo_space_->SlowContains(addr)); | 4792 lo_space_->SlowContains(addr)); |
4829 } | 4793 } |
4830 | 4794 |
4831 | 4795 |
4832 bool Heap::InSpace(HeapObject* value, AllocationSpace space) { | 4796 bool Heap::InSpace(HeapObject* value, AllocationSpace space) { |
4833 return InSpace(value->address(), space); | 4797 return InSpace(value->address(), space); |
4834 } | 4798 } |
4835 | 4799 |
4836 | 4800 |
4837 bool Heap::InSpace(Address addr, AllocationSpace space) { | 4801 bool Heap::InSpace(Address addr, AllocationSpace space) { |
4838 if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; | 4802 if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; |
4839 if (!HasBeenSetUp()) return false; | 4803 if (!HasBeenSetUp()) return false; |
4840 | 4804 |
4841 switch (space) { | 4805 switch (space) { |
4842 case NEW_SPACE: | 4806 case NEW_SPACE: |
4843 return new_space_.ToSpaceContains(addr); | 4807 return new_space_.ToSpaceContains(addr); |
4844 case OLD_POINTER_SPACE: | 4808 case OLD_POINTER_SPACE: |
4845 return old_pointer_space_->Contains(addr); | 4809 return old_pointer_space_->Contains(addr); |
4846 case OLD_DATA_SPACE: | 4810 case OLD_DATA_SPACE: |
4847 return old_data_space_->Contains(addr); | 4811 return old_data_space_->Contains(addr); |
4848 case CODE_SPACE: | 4812 case CODE_SPACE: |
4849 return code_space_->Contains(addr); | 4813 return code_space_->Contains(addr); |
4850 case MAP_SPACE: | 4814 case MAP_SPACE: |
4851 return map_space_->Contains(addr); | 4815 return map_space_->Contains(addr); |
4852 case CELL_SPACE: | 4816 case CELL_SPACE: |
4853 return cell_space_->Contains(addr); | 4817 return cell_space_->Contains(addr); |
4854 case PROPERTY_CELL_SPACE: | |
4855 return property_cell_space_->Contains(addr); | |
4856 case LO_SPACE: | 4818 case LO_SPACE: |
4857 return lo_space_->SlowContains(addr); | 4819 return lo_space_->SlowContains(addr); |
4858 } | 4820 } |
4859 UNREACHABLE(); | 4821 UNREACHABLE(); |
4860 return false; | 4822 return false; |
4861 } | 4823 } |
4862 | 4824 |
4863 | 4825 |
4864 bool Heap::RootIsImmortalImmovable(int root_index) { | 4826 bool Heap::RootIsImmortalImmovable(int root_index) { |
4865 switch (root_index) { | 4827 switch (root_index) { |
(...skipping 28 matching lines...) Expand all Loading... |
4894 | 4856 |
4895 new_space_.Verify(); | 4857 new_space_.Verify(); |
4896 | 4858 |
4897 old_pointer_space_->Verify(&visitor); | 4859 old_pointer_space_->Verify(&visitor); |
4898 map_space_->Verify(&visitor); | 4860 map_space_->Verify(&visitor); |
4899 | 4861 |
4900 VerifyPointersVisitor no_dirty_regions_visitor; | 4862 VerifyPointersVisitor no_dirty_regions_visitor; |
4901 old_data_space_->Verify(&no_dirty_regions_visitor); | 4863 old_data_space_->Verify(&no_dirty_regions_visitor); |
4902 code_space_->Verify(&no_dirty_regions_visitor); | 4864 code_space_->Verify(&no_dirty_regions_visitor); |
4903 cell_space_->Verify(&no_dirty_regions_visitor); | 4865 cell_space_->Verify(&no_dirty_regions_visitor); |
4904 property_cell_space_->Verify(&no_dirty_regions_visitor); | |
4905 | 4866 |
4906 lo_space_->Verify(); | 4867 lo_space_->Verify(); |
4907 } | 4868 } |
4908 #endif | 4869 #endif |
4909 | 4870 |
4910 | 4871 |
4911 void Heap::ZapFromSpace() { | 4872 void Heap::ZapFromSpace() { |
4912 NewSpacePageIterator it(new_space_.FromSpaceStart(), | 4873 NewSpacePageIterator it(new_space_.FromSpaceStart(), |
4913 new_space_.FromSpaceEnd()); | 4874 new_space_.FromSpaceEnd()); |
4914 while (it.has_next()) { | 4875 while (it.has_next()) { |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5219 *stats->old_pointer_space_size = old_pointer_space_->SizeOfObjects(); | 5180 *stats->old_pointer_space_size = old_pointer_space_->SizeOfObjects(); |
5220 *stats->old_pointer_space_capacity = old_pointer_space_->Capacity(); | 5181 *stats->old_pointer_space_capacity = old_pointer_space_->Capacity(); |
5221 *stats->old_data_space_size = old_data_space_->SizeOfObjects(); | 5182 *stats->old_data_space_size = old_data_space_->SizeOfObjects(); |
5222 *stats->old_data_space_capacity = old_data_space_->Capacity(); | 5183 *stats->old_data_space_capacity = old_data_space_->Capacity(); |
5223 *stats->code_space_size = code_space_->SizeOfObjects(); | 5184 *stats->code_space_size = code_space_->SizeOfObjects(); |
5224 *stats->code_space_capacity = code_space_->Capacity(); | 5185 *stats->code_space_capacity = code_space_->Capacity(); |
5225 *stats->map_space_size = map_space_->SizeOfObjects(); | 5186 *stats->map_space_size = map_space_->SizeOfObjects(); |
5226 *stats->map_space_capacity = map_space_->Capacity(); | 5187 *stats->map_space_capacity = map_space_->Capacity(); |
5227 *stats->cell_space_size = cell_space_->SizeOfObjects(); | 5188 *stats->cell_space_size = cell_space_->SizeOfObjects(); |
5228 *stats->cell_space_capacity = cell_space_->Capacity(); | 5189 *stats->cell_space_capacity = cell_space_->Capacity(); |
5229 *stats->property_cell_space_size = property_cell_space_->SizeOfObjects(); | |
5230 *stats->property_cell_space_capacity = property_cell_space_->Capacity(); | |
5231 *stats->lo_space_size = lo_space_->Size(); | 5190 *stats->lo_space_size = lo_space_->Size(); |
5232 isolate_->global_handles()->RecordStats(stats); | 5191 isolate_->global_handles()->RecordStats(stats); |
5233 *stats->memory_allocator_size = isolate()->memory_allocator()->Size(); | 5192 *stats->memory_allocator_size = isolate()->memory_allocator()->Size(); |
5234 *stats->memory_allocator_capacity = | 5193 *stats->memory_allocator_capacity = |
5235 isolate()->memory_allocator()->Size() + | 5194 isolate()->memory_allocator()->Size() + |
5236 isolate()->memory_allocator()->Available(); | 5195 isolate()->memory_allocator()->Available(); |
5237 *stats->os_error = base::OS::GetLastError(); | 5196 *stats->os_error = base::OS::GetLastError(); |
5238 isolate()->memory_allocator()->Available(); | 5197 isolate()->memory_allocator()->Available(); |
5239 if (take_snapshot) { | 5198 if (take_snapshot) { |
5240 HeapIterator iterator(this); | 5199 HeapIterator iterator(this); |
5241 for (HeapObject* obj = iterator.next(); obj != NULL; | 5200 for (HeapObject* obj = iterator.next(); obj != NULL; |
5242 obj = iterator.next()) { | 5201 obj = iterator.next()) { |
5243 InstanceType type = obj->map()->instance_type(); | 5202 InstanceType type = obj->map()->instance_type(); |
5244 DCHECK(0 <= type && type <= LAST_TYPE); | 5203 DCHECK(0 <= type && type <= LAST_TYPE); |
5245 stats->objects_per_type[type]++; | 5204 stats->objects_per_type[type]++; |
5246 stats->size_per_type[type] += obj->Size(); | 5205 stats->size_per_type[type] += obj->Size(); |
5247 } | 5206 } |
5248 } | 5207 } |
5249 } | 5208 } |
5250 | 5209 |
5251 | 5210 |
5252 intptr_t Heap::PromotedSpaceSizeOfObjects() { | 5211 intptr_t Heap::PromotedSpaceSizeOfObjects() { |
5253 return old_pointer_space_->SizeOfObjects() + | 5212 return old_pointer_space_->SizeOfObjects() + |
5254 old_data_space_->SizeOfObjects() + code_space_->SizeOfObjects() + | 5213 old_data_space_->SizeOfObjects() + code_space_->SizeOfObjects() + |
5255 map_space_->SizeOfObjects() + cell_space_->SizeOfObjects() + | 5214 map_space_->SizeOfObjects() + cell_space_->SizeOfObjects() + |
5256 property_cell_space_->SizeOfObjects() + lo_space_->SizeOfObjects(); | 5215 lo_space_->SizeOfObjects(); |
5257 } | 5216 } |
5258 | 5217 |
5259 | 5218 |
5260 int64_t Heap::PromotedExternalMemorySize() { | 5219 int64_t Heap::PromotedExternalMemorySize() { |
5261 if (amount_of_external_allocated_memory_ <= | 5220 if (amount_of_external_allocated_memory_ <= |
5262 amount_of_external_allocated_memory_at_last_global_gc_) | 5221 amount_of_external_allocated_memory_at_last_global_gc_) |
5263 return 0; | 5222 return 0; |
5264 return amount_of_external_allocated_memory_ - | 5223 return amount_of_external_allocated_memory_ - |
5265 amount_of_external_allocated_memory_at_last_global_gc_; | 5224 amount_of_external_allocated_memory_at_last_global_gc_; |
5266 } | 5225 } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5399 // Initialize map space. | 5358 // Initialize map space. |
5400 map_space_ = new MapSpace(this, max_old_generation_size_, MAP_SPACE); | 5359 map_space_ = new MapSpace(this, max_old_generation_size_, MAP_SPACE); |
5401 if (map_space_ == NULL) return false; | 5360 if (map_space_ == NULL) return false; |
5402 if (!map_space_->SetUp()) return false; | 5361 if (!map_space_->SetUp()) return false; |
5403 | 5362 |
5404 // Initialize simple cell space. | 5363 // Initialize simple cell space. |
5405 cell_space_ = new CellSpace(this, max_old_generation_size_, CELL_SPACE); | 5364 cell_space_ = new CellSpace(this, max_old_generation_size_, CELL_SPACE); |
5406 if (cell_space_ == NULL) return false; | 5365 if (cell_space_ == NULL) return false; |
5407 if (!cell_space_->SetUp()) return false; | 5366 if (!cell_space_->SetUp()) return false; |
5408 | 5367 |
5409 // Initialize global property cell space. | |
5410 property_cell_space_ = new PropertyCellSpace(this, max_old_generation_size_, | |
5411 PROPERTY_CELL_SPACE); | |
5412 if (property_cell_space_ == NULL) return false; | |
5413 if (!property_cell_space_->SetUp()) return false; | |
5414 | |
5415 // The large object code space may contain code or data. We set the memory | 5368 // The large object code space may contain code or data. We set the memory |
5416 // to be non-executable here for safety, but this means we need to enable it | 5369 // to be non-executable here for safety, but this means we need to enable it |
5417 // explicitly when allocating large code objects. | 5370 // explicitly when allocating large code objects. |
5418 lo_space_ = new LargeObjectSpace(this, max_old_generation_size_, LO_SPACE); | 5371 lo_space_ = new LargeObjectSpace(this, max_old_generation_size_, LO_SPACE); |
5419 if (lo_space_ == NULL) return false; | 5372 if (lo_space_ == NULL) return false; |
5420 if (!lo_space_->SetUp()) return false; | 5373 if (!lo_space_->SetUp()) return false; |
5421 | 5374 |
5422 // Set up the seed that is used to randomize the string hash function. | 5375 // Set up the seed that is used to randomize the string hash function. |
5423 DCHECK(hash_seed() == 0); | 5376 DCHECK(hash_seed() == 0); |
5424 if (FLAG_randomize_hashes) { | 5377 if (FLAG_randomize_hashes) { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5519 PrintF("maximum_committed_by_old_data_space=%" V8_PTR_PREFIX "d ", | 5472 PrintF("maximum_committed_by_old_data_space=%" V8_PTR_PREFIX "d ", |
5520 old_pointer_space_->MaximumCommittedMemory()); | 5473 old_pointer_space_->MaximumCommittedMemory()); |
5521 PrintF("maximum_committed_by_old_data_space=%" V8_PTR_PREFIX "d ", | 5474 PrintF("maximum_committed_by_old_data_space=%" V8_PTR_PREFIX "d ", |
5522 old_pointer_space_->MaximumCommittedMemory()); | 5475 old_pointer_space_->MaximumCommittedMemory()); |
5523 PrintF("maximum_committed_by_code_space=%" V8_PTR_PREFIX "d ", | 5476 PrintF("maximum_committed_by_code_space=%" V8_PTR_PREFIX "d ", |
5524 code_space_->MaximumCommittedMemory()); | 5477 code_space_->MaximumCommittedMemory()); |
5525 PrintF("maximum_committed_by_map_space=%" V8_PTR_PREFIX "d ", | 5478 PrintF("maximum_committed_by_map_space=%" V8_PTR_PREFIX "d ", |
5526 map_space_->MaximumCommittedMemory()); | 5479 map_space_->MaximumCommittedMemory()); |
5527 PrintF("maximum_committed_by_cell_space=%" V8_PTR_PREFIX "d ", | 5480 PrintF("maximum_committed_by_cell_space=%" V8_PTR_PREFIX "d ", |
5528 cell_space_->MaximumCommittedMemory()); | 5481 cell_space_->MaximumCommittedMemory()); |
5529 PrintF("maximum_committed_by_property_space=%" V8_PTR_PREFIX "d ", | |
5530 property_cell_space_->MaximumCommittedMemory()); | |
5531 PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ", | 5482 PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ", |
5532 lo_space_->MaximumCommittedMemory()); | 5483 lo_space_->MaximumCommittedMemory()); |
5533 PrintF("\n\n"); | 5484 PrintF("\n\n"); |
5534 } | 5485 } |
5535 | 5486 |
5536 if (FLAG_verify_predictable) { | 5487 if (FLAG_verify_predictable) { |
5537 PrintAlloctionsHash(); | 5488 PrintAlloctionsHash(); |
5538 } | 5489 } |
5539 | 5490 |
5540 TearDownArrayBuffers(); | 5491 TearDownArrayBuffers(); |
(...skipping 29 matching lines...) Expand all Loading... |
5570 delete map_space_; | 5521 delete map_space_; |
5571 map_space_ = NULL; | 5522 map_space_ = NULL; |
5572 } | 5523 } |
5573 | 5524 |
5574 if (cell_space_ != NULL) { | 5525 if (cell_space_ != NULL) { |
5575 cell_space_->TearDown(); | 5526 cell_space_->TearDown(); |
5576 delete cell_space_; | 5527 delete cell_space_; |
5577 cell_space_ = NULL; | 5528 cell_space_ = NULL; |
5578 } | 5529 } |
5579 | 5530 |
5580 if (property_cell_space_ != NULL) { | |
5581 property_cell_space_->TearDown(); | |
5582 delete property_cell_space_; | |
5583 property_cell_space_ = NULL; | |
5584 } | |
5585 | |
5586 if (lo_space_ != NULL) { | 5531 if (lo_space_ != NULL) { |
5587 lo_space_->TearDown(); | 5532 lo_space_->TearDown(); |
5588 delete lo_space_; | 5533 delete lo_space_; |
5589 lo_space_ = NULL; | 5534 lo_space_ = NULL; |
5590 } | 5535 } |
5591 | 5536 |
5592 store_buffer()->TearDown(); | 5537 store_buffer()->TearDown(); |
5593 | 5538 |
5594 isolate_->memory_allocator()->TearDown(); | 5539 isolate_->memory_allocator()->TearDown(); |
5595 } | 5540 } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5701 case OLD_POINTER_SPACE: | 5646 case OLD_POINTER_SPACE: |
5702 return heap_->old_pointer_space(); | 5647 return heap_->old_pointer_space(); |
5703 case OLD_DATA_SPACE: | 5648 case OLD_DATA_SPACE: |
5704 return heap_->old_data_space(); | 5649 return heap_->old_data_space(); |
5705 case CODE_SPACE: | 5650 case CODE_SPACE: |
5706 return heap_->code_space(); | 5651 return heap_->code_space(); |
5707 case MAP_SPACE: | 5652 case MAP_SPACE: |
5708 return heap_->map_space(); | 5653 return heap_->map_space(); |
5709 case CELL_SPACE: | 5654 case CELL_SPACE: |
5710 return heap_->cell_space(); | 5655 return heap_->cell_space(); |
5711 case PROPERTY_CELL_SPACE: | |
5712 return heap_->property_cell_space(); | |
5713 case LO_SPACE: | 5656 case LO_SPACE: |
5714 return heap_->lo_space(); | 5657 return heap_->lo_space(); |
5715 default: | 5658 default: |
5716 return NULL; | 5659 return NULL; |
5717 } | 5660 } |
5718 } | 5661 } |
5719 | 5662 |
5720 | 5663 |
5721 PagedSpace* PagedSpaces::next() { | 5664 PagedSpace* PagedSpaces::next() { |
5722 switch (counter_++) { | 5665 switch (counter_++) { |
5723 case OLD_POINTER_SPACE: | 5666 case OLD_POINTER_SPACE: |
5724 return heap_->old_pointer_space(); | 5667 return heap_->old_pointer_space(); |
5725 case OLD_DATA_SPACE: | 5668 case OLD_DATA_SPACE: |
5726 return heap_->old_data_space(); | 5669 return heap_->old_data_space(); |
5727 case CODE_SPACE: | 5670 case CODE_SPACE: |
5728 return heap_->code_space(); | 5671 return heap_->code_space(); |
5729 case MAP_SPACE: | 5672 case MAP_SPACE: |
5730 return heap_->map_space(); | 5673 return heap_->map_space(); |
5731 case CELL_SPACE: | 5674 case CELL_SPACE: |
5732 return heap_->cell_space(); | 5675 return heap_->cell_space(); |
5733 case PROPERTY_CELL_SPACE: | |
5734 return heap_->property_cell_space(); | |
5735 default: | 5676 default: |
5736 return NULL; | 5677 return NULL; |
5737 } | 5678 } |
5738 } | 5679 } |
5739 | 5680 |
5740 | 5681 |
5741 OldSpace* OldSpaces::next() { | 5682 OldSpace* OldSpaces::next() { |
5742 switch (counter_++) { | 5683 switch (counter_++) { |
5743 case OLD_POINTER_SPACE: | 5684 case OLD_POINTER_SPACE: |
5744 return heap_->old_pointer_space(); | 5685 return heap_->old_pointer_space(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5811 break; | 5752 break; |
5812 case CODE_SPACE: | 5753 case CODE_SPACE: |
5813 iterator_ = new HeapObjectIterator(heap_->code_space(), size_func_); | 5754 iterator_ = new HeapObjectIterator(heap_->code_space(), size_func_); |
5814 break; | 5755 break; |
5815 case MAP_SPACE: | 5756 case MAP_SPACE: |
5816 iterator_ = new HeapObjectIterator(heap_->map_space(), size_func_); | 5757 iterator_ = new HeapObjectIterator(heap_->map_space(), size_func_); |
5817 break; | 5758 break; |
5818 case CELL_SPACE: | 5759 case CELL_SPACE: |
5819 iterator_ = new HeapObjectIterator(heap_->cell_space(), size_func_); | 5760 iterator_ = new HeapObjectIterator(heap_->cell_space(), size_func_); |
5820 break; | 5761 break; |
5821 case PROPERTY_CELL_SPACE: | |
5822 iterator_ = | |
5823 new HeapObjectIterator(heap_->property_cell_space(), size_func_); | |
5824 break; | |
5825 case LO_SPACE: | 5762 case LO_SPACE: |
5826 iterator_ = new LargeObjectIterator(heap_->lo_space(), size_func_); | 5763 iterator_ = new LargeObjectIterator(heap_->lo_space(), size_func_); |
5827 break; | 5764 break; |
5828 } | 5765 } |
5829 | 5766 |
5830 // Return the newly allocated iterator; | 5767 // Return the newly allocated iterator; |
5831 DCHECK(iterator_ != NULL); | 5768 DCHECK(iterator_ != NULL); |
5832 return iterator_; | 5769 return iterator_; |
5833 } | 5770 } |
5834 | 5771 |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6446 static_cast<int>(object_sizes_last_time_[index])); | 6383 static_cast<int>(object_sizes_last_time_[index])); |
6447 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6384 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
6448 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6385 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
6449 | 6386 |
6450 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6387 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
6451 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6388 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
6452 ClearObjectStats(); | 6389 ClearObjectStats(); |
6453 } | 6390 } |
6454 } | 6391 } |
6455 } // namespace v8::internal | 6392 } // namespace v8::internal |
OLD | NEW |