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