| 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 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2823 return result; | 2793 return result; |
| 2824 } | 2794 } |
| 2825 | 2795 |
| 2826 | 2796 |
| 2827 AllocationResult Heap::AllocateCell(Object* value) { | 2797 AllocationResult Heap::AllocateCell(Object* value) { |
| 2828 int size = Cell::kSize; | 2798 int size = Cell::kSize; |
| 2829 STATIC_ASSERT(Cell::kSize <= Page::kMaxRegularHeapObjectSize); | 2799 STATIC_ASSERT(Cell::kSize <= Page::kMaxRegularHeapObjectSize); |
| 2830 | 2800 |
| 2831 HeapObject* result; | 2801 HeapObject* result; |
| 2832 { | 2802 { |
| 2833 AllocationResult allocation = AllocateRaw(size, CELL_SPACE, CELL_SPACE); | 2803 AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); |
| 2834 if (!allocation.To(&result)) return allocation; | 2804 if (!allocation.To(&result)) return allocation; |
| 2835 } | 2805 } |
| 2836 result->set_map_no_write_barrier(cell_map()); | 2806 result->set_map_no_write_barrier(cell_map()); |
| 2837 Cell::cast(result)->set_value(value); | 2807 Cell::cast(result)->set_value(value); |
| 2838 return result; | 2808 return result; |
| 2839 } | 2809 } |
| 2840 | 2810 |
| 2841 | 2811 |
| 2842 AllocationResult Heap::AllocatePropertyCell() { | 2812 AllocationResult Heap::AllocatePropertyCell() { |
| 2843 int size = PropertyCell::kSize; | 2813 int size = PropertyCell::kSize; |
| (...skipping 1927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4771 PrintF("Heap statistics : "); | 4741 PrintF("Heap statistics : "); |
| 4772 isolate_->memory_allocator()->ReportStatistics(); | 4742 isolate_->memory_allocator()->ReportStatistics(); |
| 4773 PrintF("To space : "); | 4743 PrintF("To space : "); |
| 4774 new_space_.ReportStatistics(); | 4744 new_space_.ReportStatistics(); |
| 4775 PrintF("Old space : "); | 4745 PrintF("Old space : "); |
| 4776 old_space_->ReportStatistics(); | 4746 old_space_->ReportStatistics(); |
| 4777 PrintF("Code space : "); | 4747 PrintF("Code space : "); |
| 4778 code_space_->ReportStatistics(); | 4748 code_space_->ReportStatistics(); |
| 4779 PrintF("Map space : "); | 4749 PrintF("Map space : "); |
| 4780 map_space_->ReportStatistics(); | 4750 map_space_->ReportStatistics(); |
| 4781 PrintF("Cell space : "); | |
| 4782 cell_space_->ReportStatistics(); | |
| 4783 PrintF("Large object space : "); | 4751 PrintF("Large object space : "); |
| 4784 lo_space_->ReportStatistics(); | 4752 lo_space_->ReportStatistics(); |
| 4785 PrintF(">>>>>> ========================================= >>>>>>\n"); | 4753 PrintF(">>>>>> ========================================= >>>>>>\n"); |
| 4786 } | 4754 } |
| 4787 | 4755 |
| 4788 #endif // DEBUG | 4756 #endif // DEBUG |
| 4789 | 4757 |
| 4790 bool Heap::Contains(HeapObject* value) { return Contains(value->address()); } | 4758 bool Heap::Contains(HeapObject* value) { return Contains(value->address()); } |
| 4791 | 4759 |
| 4792 | 4760 |
| 4793 bool Heap::Contains(Address addr) { | 4761 bool Heap::Contains(Address addr) { |
| 4794 if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; | 4762 if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; |
| 4795 return HasBeenSetUp() && | 4763 return HasBeenSetUp() && |
| 4796 (new_space_.ToSpaceContains(addr) || old_space_->Contains(addr) || | 4764 (new_space_.ToSpaceContains(addr) || old_space_->Contains(addr) || |
| 4797 code_space_->Contains(addr) || map_space_->Contains(addr) || | 4765 code_space_->Contains(addr) || map_space_->Contains(addr) || |
| 4798 cell_space_->Contains(addr) || lo_space_->SlowContains(addr)); | 4766 lo_space_->SlowContains(addr)); |
| 4799 } | 4767 } |
| 4800 | 4768 |
| 4801 | 4769 |
| 4802 bool Heap::InSpace(HeapObject* value, AllocationSpace space) { | 4770 bool Heap::InSpace(HeapObject* value, AllocationSpace space) { |
| 4803 return InSpace(value->address(), space); | 4771 return InSpace(value->address(), space); |
| 4804 } | 4772 } |
| 4805 | 4773 |
| 4806 | 4774 |
| 4807 bool Heap::InSpace(Address addr, AllocationSpace space) { | 4775 bool Heap::InSpace(Address addr, AllocationSpace space) { |
| 4808 if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; | 4776 if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; |
| 4809 if (!HasBeenSetUp()) return false; | 4777 if (!HasBeenSetUp()) return false; |
| 4810 | 4778 |
| 4811 switch (space) { | 4779 switch (space) { |
| 4812 case NEW_SPACE: | 4780 case NEW_SPACE: |
| 4813 return new_space_.ToSpaceContains(addr); | 4781 return new_space_.ToSpaceContains(addr); |
| 4814 case OLD_SPACE: | 4782 case OLD_SPACE: |
| 4815 return old_space_->Contains(addr); | 4783 return old_space_->Contains(addr); |
| 4816 case CODE_SPACE: | 4784 case CODE_SPACE: |
| 4817 return code_space_->Contains(addr); | 4785 return code_space_->Contains(addr); |
| 4818 case MAP_SPACE: | 4786 case MAP_SPACE: |
| 4819 return map_space_->Contains(addr); | 4787 return map_space_->Contains(addr); |
| 4820 case CELL_SPACE: | |
| 4821 return cell_space_->Contains(addr); | |
| 4822 case LO_SPACE: | 4788 case LO_SPACE: |
| 4823 return lo_space_->SlowContains(addr); | 4789 return lo_space_->SlowContains(addr); |
| 4824 } | 4790 } |
| 4825 UNREACHABLE(); | 4791 UNREACHABLE(); |
| 4826 return false; | 4792 return false; |
| 4827 } | 4793 } |
| 4828 | 4794 |
| 4829 | 4795 |
| 4830 bool Heap::RootIsImmortalImmovable(int root_index) { | 4796 bool Heap::RootIsImmortalImmovable(int root_index) { |
| 4831 switch (root_index) { | 4797 switch (root_index) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 4858 VerifySmisVisitor smis_visitor; | 4824 VerifySmisVisitor smis_visitor; |
| 4859 IterateSmiRoots(&smis_visitor); | 4825 IterateSmiRoots(&smis_visitor); |
| 4860 | 4826 |
| 4861 new_space_.Verify(); | 4827 new_space_.Verify(); |
| 4862 | 4828 |
| 4863 old_space_->Verify(&visitor); | 4829 old_space_->Verify(&visitor); |
| 4864 map_space_->Verify(&visitor); | 4830 map_space_->Verify(&visitor); |
| 4865 | 4831 |
| 4866 VerifyPointersVisitor no_dirty_regions_visitor; | 4832 VerifyPointersVisitor no_dirty_regions_visitor; |
| 4867 code_space_->Verify(&no_dirty_regions_visitor); | 4833 code_space_->Verify(&no_dirty_regions_visitor); |
| 4868 cell_space_->Verify(&no_dirty_regions_visitor); | |
| 4869 | 4834 |
| 4870 lo_space_->Verify(); | 4835 lo_space_->Verify(); |
| 4871 } | 4836 } |
| 4872 #endif | 4837 #endif |
| 4873 | 4838 |
| 4874 | 4839 |
| 4875 void Heap::ZapFromSpace() { | 4840 void Heap::ZapFromSpace() { |
| 4876 NewSpacePageIterator it(new_space_.FromSpaceStart(), | 4841 NewSpacePageIterator it(new_space_.FromSpaceStart(), |
| 4877 new_space_.FromSpaceEnd()); | 4842 new_space_.FromSpaceEnd()); |
| 4878 while (it.has_next()) { | 4843 while (it.has_next()) { |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5168 *stats->start_marker = HeapStats::kStartMarker; | 5133 *stats->start_marker = HeapStats::kStartMarker; |
| 5169 *stats->end_marker = HeapStats::kEndMarker; | 5134 *stats->end_marker = HeapStats::kEndMarker; |
| 5170 *stats->new_space_size = new_space_.SizeAsInt(); | 5135 *stats->new_space_size = new_space_.SizeAsInt(); |
| 5171 *stats->new_space_capacity = static_cast<int>(new_space_.Capacity()); | 5136 *stats->new_space_capacity = static_cast<int>(new_space_.Capacity()); |
| 5172 *stats->old_space_size = old_space_->SizeOfObjects(); | 5137 *stats->old_space_size = old_space_->SizeOfObjects(); |
| 5173 *stats->old_space_capacity = old_space_->Capacity(); | 5138 *stats->old_space_capacity = old_space_->Capacity(); |
| 5174 *stats->code_space_size = code_space_->SizeOfObjects(); | 5139 *stats->code_space_size = code_space_->SizeOfObjects(); |
| 5175 *stats->code_space_capacity = code_space_->Capacity(); | 5140 *stats->code_space_capacity = code_space_->Capacity(); |
| 5176 *stats->map_space_size = map_space_->SizeOfObjects(); | 5141 *stats->map_space_size = map_space_->SizeOfObjects(); |
| 5177 *stats->map_space_capacity = map_space_->Capacity(); | 5142 *stats->map_space_capacity = map_space_->Capacity(); |
| 5178 *stats->cell_space_size = cell_space_->SizeOfObjects(); | |
| 5179 *stats->cell_space_capacity = cell_space_->Capacity(); | |
| 5180 *stats->lo_space_size = lo_space_->Size(); | 5143 *stats->lo_space_size = lo_space_->Size(); |
| 5181 isolate_->global_handles()->RecordStats(stats); | 5144 isolate_->global_handles()->RecordStats(stats); |
| 5182 *stats->memory_allocator_size = isolate()->memory_allocator()->Size(); | 5145 *stats->memory_allocator_size = isolate()->memory_allocator()->Size(); |
| 5183 *stats->memory_allocator_capacity = | 5146 *stats->memory_allocator_capacity = |
| 5184 isolate()->memory_allocator()->Size() + | 5147 isolate()->memory_allocator()->Size() + |
| 5185 isolate()->memory_allocator()->Available(); | 5148 isolate()->memory_allocator()->Available(); |
| 5186 *stats->os_error = base::OS::GetLastError(); | 5149 *stats->os_error = base::OS::GetLastError(); |
| 5187 isolate()->memory_allocator()->Available(); | 5150 isolate()->memory_allocator()->Available(); |
| 5188 if (take_snapshot) { | 5151 if (take_snapshot) { |
| 5189 HeapIterator iterator(this); | 5152 HeapIterator iterator(this); |
| 5190 for (HeapObject* obj = iterator.next(); obj != NULL; | 5153 for (HeapObject* obj = iterator.next(); obj != NULL; |
| 5191 obj = iterator.next()) { | 5154 obj = iterator.next()) { |
| 5192 InstanceType type = obj->map()->instance_type(); | 5155 InstanceType type = obj->map()->instance_type(); |
| 5193 DCHECK(0 <= type && type <= LAST_TYPE); | 5156 DCHECK(0 <= type && type <= LAST_TYPE); |
| 5194 stats->objects_per_type[type]++; | 5157 stats->objects_per_type[type]++; |
| 5195 stats->size_per_type[type] += obj->Size(); | 5158 stats->size_per_type[type] += obj->Size(); |
| 5196 } | 5159 } |
| 5197 } | 5160 } |
| 5198 } | 5161 } |
| 5199 | 5162 |
| 5200 | 5163 |
| 5201 intptr_t Heap::PromotedSpaceSizeOfObjects() { | 5164 intptr_t Heap::PromotedSpaceSizeOfObjects() { |
| 5202 return old_space_->SizeOfObjects() + code_space_->SizeOfObjects() + | 5165 return old_space_->SizeOfObjects() + code_space_->SizeOfObjects() + |
| 5203 map_space_->SizeOfObjects() + cell_space_->SizeOfObjects() + | 5166 map_space_->SizeOfObjects() + lo_space_->SizeOfObjects(); |
| 5204 lo_space_->SizeOfObjects(); | |
| 5205 } | 5167 } |
| 5206 | 5168 |
| 5207 | 5169 |
| 5208 int64_t Heap::PromotedExternalMemorySize() { | 5170 int64_t Heap::PromotedExternalMemorySize() { |
| 5209 if (amount_of_external_allocated_memory_ <= | 5171 if (amount_of_external_allocated_memory_ <= |
| 5210 amount_of_external_allocated_memory_at_last_global_gc_) | 5172 amount_of_external_allocated_memory_at_last_global_gc_) |
| 5211 return 0; | 5173 return 0; |
| 5212 return amount_of_external_allocated_memory_ - | 5174 return amount_of_external_allocated_memory_ - |
| 5213 amount_of_external_allocated_memory_at_last_global_gc_; | 5175 amount_of_external_allocated_memory_at_last_global_gc_; |
| 5214 } | 5176 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5336 code_space_ = | 5298 code_space_ = |
| 5337 new OldSpace(this, max_old_generation_size_, CODE_SPACE, EXECUTABLE); | 5299 new OldSpace(this, max_old_generation_size_, CODE_SPACE, EXECUTABLE); |
| 5338 if (code_space_ == NULL) return false; | 5300 if (code_space_ == NULL) return false; |
| 5339 if (!code_space_->SetUp()) return false; | 5301 if (!code_space_->SetUp()) return false; |
| 5340 | 5302 |
| 5341 // Initialize map space. | 5303 // Initialize map space. |
| 5342 map_space_ = new MapSpace(this, max_old_generation_size_, MAP_SPACE); | 5304 map_space_ = new MapSpace(this, max_old_generation_size_, MAP_SPACE); |
| 5343 if (map_space_ == NULL) return false; | 5305 if (map_space_ == NULL) return false; |
| 5344 if (!map_space_->SetUp()) return false; | 5306 if (!map_space_->SetUp()) return false; |
| 5345 | 5307 |
| 5346 // Initialize simple cell space. | |
| 5347 cell_space_ = new CellSpace(this, max_old_generation_size_, CELL_SPACE); | |
| 5348 if (cell_space_ == NULL) return false; | |
| 5349 if (!cell_space_->SetUp()) return false; | |
| 5350 | |
| 5351 // The large object code space may contain code or data. We set the memory | 5308 // The large object code space may contain code or data. We set the memory |
| 5352 // to be non-executable here for safety, but this means we need to enable it | 5309 // to be non-executable here for safety, but this means we need to enable it |
| 5353 // explicitly when allocating large code objects. | 5310 // explicitly when allocating large code objects. |
| 5354 lo_space_ = new LargeObjectSpace(this, max_old_generation_size_, LO_SPACE); | 5311 lo_space_ = new LargeObjectSpace(this, max_old_generation_size_, LO_SPACE); |
| 5355 if (lo_space_ == NULL) return false; | 5312 if (lo_space_ == NULL) return false; |
| 5356 if (!lo_space_->SetUp()) return false; | 5313 if (!lo_space_->SetUp()) return false; |
| 5357 | 5314 |
| 5358 // Set up the seed that is used to randomize the string hash function. | 5315 // Set up the seed that is used to randomize the string hash function. |
| 5359 DCHECK(hash_seed() == 0); | 5316 DCHECK(hash_seed() == 0); |
| 5360 if (FLAG_randomize_hashes) { | 5317 if (FLAG_randomize_hashes) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5449 PrintF("maximum_committed_by_heap=%" V8_PTR_PREFIX "d ", | 5406 PrintF("maximum_committed_by_heap=%" V8_PTR_PREFIX "d ", |
| 5450 MaximumCommittedMemory()); | 5407 MaximumCommittedMemory()); |
| 5451 PrintF("maximum_committed_by_new_space=%" V8_PTR_PREFIX "d ", | 5408 PrintF("maximum_committed_by_new_space=%" V8_PTR_PREFIX "d ", |
| 5452 new_space_.MaximumCommittedMemory()); | 5409 new_space_.MaximumCommittedMemory()); |
| 5453 PrintF("maximum_committed_by_old_space=%" V8_PTR_PREFIX "d ", | 5410 PrintF("maximum_committed_by_old_space=%" V8_PTR_PREFIX "d ", |
| 5454 old_space_->MaximumCommittedMemory()); | 5411 old_space_->MaximumCommittedMemory()); |
| 5455 PrintF("maximum_committed_by_code_space=%" V8_PTR_PREFIX "d ", | 5412 PrintF("maximum_committed_by_code_space=%" V8_PTR_PREFIX "d ", |
| 5456 code_space_->MaximumCommittedMemory()); | 5413 code_space_->MaximumCommittedMemory()); |
| 5457 PrintF("maximum_committed_by_map_space=%" V8_PTR_PREFIX "d ", | 5414 PrintF("maximum_committed_by_map_space=%" V8_PTR_PREFIX "d ", |
| 5458 map_space_->MaximumCommittedMemory()); | 5415 map_space_->MaximumCommittedMemory()); |
| 5459 PrintF("maximum_committed_by_cell_space=%" V8_PTR_PREFIX "d ", | |
| 5460 cell_space_->MaximumCommittedMemory()); | |
| 5461 PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ", | 5416 PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ", |
| 5462 lo_space_->MaximumCommittedMemory()); | 5417 lo_space_->MaximumCommittedMemory()); |
| 5463 PrintF("\n\n"); | 5418 PrintF("\n\n"); |
| 5464 } | 5419 } |
| 5465 | 5420 |
| 5466 if (FLAG_verify_predictable) { | 5421 if (FLAG_verify_predictable) { |
| 5467 PrintAlloctionsHash(); | 5422 PrintAlloctionsHash(); |
| 5468 } | 5423 } |
| 5469 | 5424 |
| 5470 TearDownArrayBuffers(); | 5425 TearDownArrayBuffers(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 5488 delete code_space_; | 5443 delete code_space_; |
| 5489 code_space_ = NULL; | 5444 code_space_ = NULL; |
| 5490 } | 5445 } |
| 5491 | 5446 |
| 5492 if (map_space_ != NULL) { | 5447 if (map_space_ != NULL) { |
| 5493 map_space_->TearDown(); | 5448 map_space_->TearDown(); |
| 5494 delete map_space_; | 5449 delete map_space_; |
| 5495 map_space_ = NULL; | 5450 map_space_ = NULL; |
| 5496 } | 5451 } |
| 5497 | 5452 |
| 5498 if (cell_space_ != NULL) { | |
| 5499 cell_space_->TearDown(); | |
| 5500 delete cell_space_; | |
| 5501 cell_space_ = NULL; | |
| 5502 } | |
| 5503 | |
| 5504 if (lo_space_ != NULL) { | 5453 if (lo_space_ != NULL) { |
| 5505 lo_space_->TearDown(); | 5454 lo_space_->TearDown(); |
| 5506 delete lo_space_; | 5455 delete lo_space_; |
| 5507 lo_space_ = NULL; | 5456 lo_space_ = NULL; |
| 5508 } | 5457 } |
| 5509 | 5458 |
| 5510 store_buffer()->TearDown(); | 5459 store_buffer()->TearDown(); |
| 5511 | 5460 |
| 5512 isolate_->memory_allocator()->TearDown(); | 5461 isolate_->memory_allocator()->TearDown(); |
| 5513 } | 5462 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5634 Space* AllSpaces::next() { | 5583 Space* AllSpaces::next() { |
| 5635 switch (counter_++) { | 5584 switch (counter_++) { |
| 5636 case NEW_SPACE: | 5585 case NEW_SPACE: |
| 5637 return heap_->new_space(); | 5586 return heap_->new_space(); |
| 5638 case OLD_SPACE: | 5587 case OLD_SPACE: |
| 5639 return heap_->old_space(); | 5588 return heap_->old_space(); |
| 5640 case CODE_SPACE: | 5589 case CODE_SPACE: |
| 5641 return heap_->code_space(); | 5590 return heap_->code_space(); |
| 5642 case MAP_SPACE: | 5591 case MAP_SPACE: |
| 5643 return heap_->map_space(); | 5592 return heap_->map_space(); |
| 5644 case CELL_SPACE: | |
| 5645 return heap_->cell_space(); | |
| 5646 case LO_SPACE: | 5593 case LO_SPACE: |
| 5647 return heap_->lo_space(); | 5594 return heap_->lo_space(); |
| 5648 default: | 5595 default: |
| 5649 return NULL; | 5596 return NULL; |
| 5650 } | 5597 } |
| 5651 } | 5598 } |
| 5652 | 5599 |
| 5653 | 5600 |
| 5654 PagedSpace* PagedSpaces::next() { | 5601 PagedSpace* PagedSpaces::next() { |
| 5655 switch (counter_++) { | 5602 switch (counter_++) { |
| 5656 case OLD_SPACE: | 5603 case OLD_SPACE: |
| 5657 return heap_->old_space(); | 5604 return heap_->old_space(); |
| 5658 case CODE_SPACE: | 5605 case CODE_SPACE: |
| 5659 return heap_->code_space(); | 5606 return heap_->code_space(); |
| 5660 case MAP_SPACE: | 5607 case MAP_SPACE: |
| 5661 return heap_->map_space(); | 5608 return heap_->map_space(); |
| 5662 case CELL_SPACE: | |
| 5663 return heap_->cell_space(); | |
| 5664 default: | 5609 default: |
| 5665 return NULL; | 5610 return NULL; |
| 5666 } | 5611 } |
| 5667 } | 5612 } |
| 5668 | 5613 |
| 5669 | 5614 |
| 5670 OldSpace* OldSpaces::next() { | 5615 OldSpace* OldSpaces::next() { |
| 5671 switch (counter_++) { | 5616 switch (counter_++) { |
| 5672 case OLD_SPACE: | 5617 case OLD_SPACE: |
| 5673 return heap_->old_space(); | 5618 return heap_->old_space(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5731 break; | 5676 break; |
| 5732 case OLD_SPACE: | 5677 case OLD_SPACE: |
| 5733 iterator_ = new HeapObjectIterator(heap_->old_space(), size_func_); | 5678 iterator_ = new HeapObjectIterator(heap_->old_space(), size_func_); |
| 5734 break; | 5679 break; |
| 5735 case CODE_SPACE: | 5680 case CODE_SPACE: |
| 5736 iterator_ = new HeapObjectIterator(heap_->code_space(), size_func_); | 5681 iterator_ = new HeapObjectIterator(heap_->code_space(), size_func_); |
| 5737 break; | 5682 break; |
| 5738 case MAP_SPACE: | 5683 case MAP_SPACE: |
| 5739 iterator_ = new HeapObjectIterator(heap_->map_space(), size_func_); | 5684 iterator_ = new HeapObjectIterator(heap_->map_space(), size_func_); |
| 5740 break; | 5685 break; |
| 5741 case CELL_SPACE: | |
| 5742 iterator_ = new HeapObjectIterator(heap_->cell_space(), size_func_); | |
| 5743 break; | |
| 5744 case LO_SPACE: | 5686 case LO_SPACE: |
| 5745 iterator_ = new LargeObjectIterator(heap_->lo_space(), size_func_); | 5687 iterator_ = new LargeObjectIterator(heap_->lo_space(), size_func_); |
| 5746 break; | 5688 break; |
| 5747 } | 5689 } |
| 5748 | 5690 |
| 5749 // Return the newly allocated iterator; | 5691 // Return the newly allocated iterator; |
| 5750 DCHECK(iterator_ != NULL); | 5692 DCHECK(iterator_ != NULL); |
| 5751 return iterator_; | 5693 return iterator_; |
| 5752 } | 5694 } |
| 5753 | 5695 |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6365 static_cast<int>(object_sizes_last_time_[index])); | 6307 static_cast<int>(object_sizes_last_time_[index])); |
| 6366 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6308 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 6367 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6309 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 6368 | 6310 |
| 6369 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6311 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 6370 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6312 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 6371 ClearObjectStats(); | 6313 ClearObjectStats(); |
| 6372 } | 6314 } |
| 6373 } | 6315 } |
| 6374 } // namespace v8::internal | 6316 } // namespace v8::internal |
| OLD | NEW |