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

Side by Side Diff: src/heap/heap.cc

Issue 1016803002: Remove PropertyCell space (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/heap-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 cell_space_(NULL),
91 property_cell_space_(NULL),
92 lo_space_(NULL), 91 lo_space_(NULL),
93 gc_state_(NOT_IN_GC), 92 gc_state_(NOT_IN_GC),
94 gc_post_processing_depth_(0), 93 gc_post_processing_depth_(0),
95 allocations_count_(0), 94 allocations_count_(0),
96 raw_allocations_hash_(0), 95 raw_allocations_hash_(0),
97 dump_allocations_hash_countdown_(FLAG_dump_allocations_digest_at_alloc), 96 dump_allocations_hash_countdown_(FLAG_dump_allocations_digest_at_alloc),
98 ms_count_(0), 97 ms_count_(0),
99 gc_count_(0), 98 gc_count_(0),
100 remembered_unmapped_pages_index_(0), 99 remembered_unmapped_pages_index_(0),
101 unflattened_strings_length_(0), 100 unflattened_strings_length_(0),
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 166
168 ClearObjectStats(true); 167 ClearObjectStats(true);
169 } 168 }
170 169
171 170
172 intptr_t Heap::Capacity() { 171 intptr_t Heap::Capacity() {
173 if (!HasBeenSetUp()) return 0; 172 if (!HasBeenSetUp()) return 0;
174 173
175 return new_space_.Capacity() + old_space_->Capacity() + 174 return new_space_.Capacity() + old_space_->Capacity() +
176 code_space_->Capacity() + map_space_->Capacity() + 175 code_space_->Capacity() + map_space_->Capacity() +
177 cell_space_->Capacity() + property_cell_space_->Capacity(); 176 cell_space_->Capacity();
178 } 177 }
179 178
180 179
181 intptr_t Heap::CommittedOldGenerationMemory() { 180 intptr_t Heap::CommittedOldGenerationMemory() {
182 if (!HasBeenSetUp()) return 0; 181 if (!HasBeenSetUp()) return 0;
183 182
184 return old_space_->CommittedMemory() + code_space_->CommittedMemory() + 183 return old_space_->CommittedMemory() + code_space_->CommittedMemory() +
185 map_space_->CommittedMemory() + cell_space_->CommittedMemory() + 184 map_space_->CommittedMemory() + cell_space_->CommittedMemory() +
186 property_cell_space_->CommittedMemory() + lo_space_->Size(); 185 lo_space_->Size();
187 } 186 }
188 187
189 188
190 intptr_t Heap::CommittedMemory() { 189 intptr_t Heap::CommittedMemory() {
191 if (!HasBeenSetUp()) return 0; 190 if (!HasBeenSetUp()) return 0;
192 191
193 return new_space_.CommittedMemory() + CommittedOldGenerationMemory(); 192 return new_space_.CommittedMemory() + CommittedOldGenerationMemory();
194 } 193 }
195 194
196 195
197 size_t Heap::CommittedPhysicalMemory() { 196 size_t Heap::CommittedPhysicalMemory() {
198 if (!HasBeenSetUp()) return 0; 197 if (!HasBeenSetUp()) return 0;
199 198
200 return new_space_.CommittedPhysicalMemory() + 199 return new_space_.CommittedPhysicalMemory() +
201 old_space_->CommittedPhysicalMemory() + 200 old_space_->CommittedPhysicalMemory() +
202 code_space_->CommittedPhysicalMemory() + 201 code_space_->CommittedPhysicalMemory() +
203 map_space_->CommittedPhysicalMemory() + 202 map_space_->CommittedPhysicalMemory() +
204 cell_space_->CommittedPhysicalMemory() + 203 cell_space_->CommittedPhysicalMemory() +
205 property_cell_space_->CommittedPhysicalMemory() +
206 lo_space_->CommittedPhysicalMemory(); 204 lo_space_->CommittedPhysicalMemory();
207 } 205 }
208 206
209 207
210 intptr_t Heap::CommittedMemoryExecutable() { 208 intptr_t Heap::CommittedMemoryExecutable() {
211 if (!HasBeenSetUp()) return 0; 209 if (!HasBeenSetUp()) return 0;
212 210
213 return isolate()->memory_allocator()->SizeExecutable(); 211 return isolate()->memory_allocator()->SizeExecutable();
214 } 212 }
215 213
216 214
217 void Heap::UpdateMaximumCommitted() { 215 void Heap::UpdateMaximumCommitted() {
218 if (!HasBeenSetUp()) return; 216 if (!HasBeenSetUp()) return;
219 217
220 intptr_t current_committed_memory = CommittedMemory(); 218 intptr_t current_committed_memory = CommittedMemory();
221 if (current_committed_memory > maximum_committed_) { 219 if (current_committed_memory > maximum_committed_) {
222 maximum_committed_ = current_committed_memory; 220 maximum_committed_ = current_committed_memory;
223 } 221 }
224 } 222 }
225 223
226 224
227 intptr_t Heap::Available() { 225 intptr_t Heap::Available() {
228 if (!HasBeenSetUp()) return 0; 226 if (!HasBeenSetUp()) return 0;
229 227
230 return new_space_.Available() + old_space_->Available() + 228 return new_space_.Available() + old_space_->Available() +
231 code_space_->Available() + map_space_->Available() + 229 code_space_->Available() + map_space_->Available() +
232 cell_space_->Available() + property_cell_space_->Available(); 230 cell_space_->Available();
233 } 231 }
234 232
235 233
236 bool Heap::HasBeenSetUp() { 234 bool Heap::HasBeenSetUp() {
237 return old_space_ != NULL && code_space_ != NULL && map_space_ != NULL && 235 return old_space_ != NULL && code_space_ != NULL && map_space_ != NULL &&
238 cell_space_ != NULL && property_cell_space_ != NULL && 236 cell_space_ != NULL && lo_space_ != NULL;
239 lo_space_ != NULL;
240 } 237 }
241 238
242 239
243 int Heap::GcSafeSizeOfOldObject(HeapObject* object) { 240 int Heap::GcSafeSizeOfOldObject(HeapObject* object) {
244 if (IntrusiveMarking::IsMarked(object)) { 241 if (IntrusiveMarking::IsMarked(object)) {
245 return IntrusiveMarking::SizeOfMarkedObject(object); 242 return IntrusiveMarking::SizeOfMarkedObject(object);
246 } 243 }
247 return object->SizeFromMap(object->map()); 244 return object->SizeFromMap(object->map());
248 } 245 }
249 246
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 ", committed: %6" V8_PTR_PREFIX "d KB\n", 357 ", committed: %6" V8_PTR_PREFIX "d KB\n",
361 map_space_->SizeOfObjects() / KB, map_space_->Available() / KB, 358 map_space_->SizeOfObjects() / KB, map_space_->Available() / KB,
362 map_space_->CommittedMemory() / KB); 359 map_space_->CommittedMemory() / KB);
363 PrintPID("Cell space, used: %6" V8_PTR_PREFIX 360 PrintPID("Cell space, used: %6" V8_PTR_PREFIX
364 "d KB" 361 "d KB"
365 ", available: %6" V8_PTR_PREFIX 362 ", available: %6" V8_PTR_PREFIX
366 "d KB" 363 "d KB"
367 ", committed: %6" V8_PTR_PREFIX "d KB\n", 364 ", committed: %6" V8_PTR_PREFIX "d KB\n",
368 cell_space_->SizeOfObjects() / KB, cell_space_->Available() / KB, 365 cell_space_->SizeOfObjects() / KB, cell_space_->Available() / KB,
369 cell_space_->CommittedMemory() / KB); 366 cell_space_->CommittedMemory() / KB);
370 PrintPID("PropertyCell space, used: %6" V8_PTR_PREFIX
371 "d KB"
372 ", available: %6" V8_PTR_PREFIX
373 "d KB"
374 ", committed: %6" V8_PTR_PREFIX "d KB\n",
375 property_cell_space_->SizeOfObjects() / KB,
376 property_cell_space_->Available() / KB,
377 property_cell_space_->CommittedMemory() / KB);
378 PrintPID("Large object space, used: %6" V8_PTR_PREFIX 367 PrintPID("Large object space, used: %6" V8_PTR_PREFIX
379 "d KB" 368 "d KB"
380 ", available: %6" V8_PTR_PREFIX 369 ", available: %6" V8_PTR_PREFIX
381 "d KB" 370 "d KB"
382 ", committed: %6" V8_PTR_PREFIX "d KB\n", 371 ", committed: %6" V8_PTR_PREFIX "d KB\n",
383 lo_space_->SizeOfObjects() / KB, lo_space_->Available() / KB, 372 lo_space_->SizeOfObjects() / KB, lo_space_->Available() / KB,
384 lo_space_->CommittedMemory() / KB); 373 lo_space_->CommittedMemory() / KB);
385 PrintPID("All spaces, used: %6" V8_PTR_PREFIX 374 PrintPID("All spaces, used: %6" V8_PTR_PREFIX
386 "d KB" 375 "d KB"
387 ", available: %6" V8_PTR_PREFIX 376 ", available: %6" V8_PTR_PREFIX
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 isolate_->counters()->heap_fraction_old_space()->AddSample(static_cast<int>( 641 isolate_->counters()->heap_fraction_old_space()->AddSample(static_cast<int>(
653 (old_space()->CommittedMemory() * 100.0) / CommittedMemory())); 642 (old_space()->CommittedMemory() * 100.0) / CommittedMemory()));
654 isolate_->counters()->heap_fraction_code_space()->AddSample( 643 isolate_->counters()->heap_fraction_code_space()->AddSample(
655 static_cast<int>((code_space()->CommittedMemory() * 100.0) / 644 static_cast<int>((code_space()->CommittedMemory() * 100.0) /
656 CommittedMemory())); 645 CommittedMemory()));
657 isolate_->counters()->heap_fraction_map_space()->AddSample(static_cast<int>( 646 isolate_->counters()->heap_fraction_map_space()->AddSample(static_cast<int>(
658 (map_space()->CommittedMemory() * 100.0) / CommittedMemory())); 647 (map_space()->CommittedMemory() * 100.0) / CommittedMemory()));
659 isolate_->counters()->heap_fraction_cell_space()->AddSample( 648 isolate_->counters()->heap_fraction_cell_space()->AddSample(
660 static_cast<int>((cell_space()->CommittedMemory() * 100.0) / 649 static_cast<int>((cell_space()->CommittedMemory() * 100.0) /
661 CommittedMemory())); 650 CommittedMemory()));
662 isolate_->counters()->heap_fraction_property_cell_space()->AddSample(
663 static_cast<int>((property_cell_space()->CommittedMemory() * 100.0) /
664 CommittedMemory()));
665 isolate_->counters()->heap_fraction_lo_space()->AddSample(static_cast<int>( 651 isolate_->counters()->heap_fraction_lo_space()->AddSample(static_cast<int>(
666 (lo_space()->CommittedMemory() * 100.0) / CommittedMemory())); 652 (lo_space()->CommittedMemory() * 100.0) / CommittedMemory()));
667 653
668 isolate_->counters()->heap_sample_total_committed()->AddSample( 654 isolate_->counters()->heap_sample_total_committed()->AddSample(
669 static_cast<int>(CommittedMemory() / KB)); 655 static_cast<int>(CommittedMemory() / KB));
670 isolate_->counters()->heap_sample_total_used()->AddSample( 656 isolate_->counters()->heap_sample_total_used()->AddSample(
671 static_cast<int>(SizeOfObjects() / KB)); 657 static_cast<int>(SizeOfObjects() / KB));
672 isolate_->counters()->heap_sample_map_space_committed()->AddSample( 658 isolate_->counters()->heap_sample_map_space_committed()->AddSample(
673 static_cast<int>(map_space()->CommittedMemory() / KB)); 659 static_cast<int>(map_space()->CommittedMemory() / KB));
674 isolate_->counters()->heap_sample_cell_space_committed()->AddSample( 660 isolate_->counters()->heap_sample_cell_space_committed()->AddSample(
675 static_cast<int>(cell_space()->CommittedMemory() / KB)); 661 static_cast<int>(cell_space()->CommittedMemory() / KB));
676 isolate_->counters()
677 ->heap_sample_property_cell_space_committed()
678 ->AddSample(
679 static_cast<int>(property_cell_space()->CommittedMemory() / KB));
680 isolate_->counters()->heap_sample_code_space_committed()->AddSample( 662 isolate_->counters()->heap_sample_code_space_committed()->AddSample(
681 static_cast<int>(code_space()->CommittedMemory() / KB)); 663 static_cast<int>(code_space()->CommittedMemory() / KB));
682 664
683 isolate_->counters()->heap_sample_maximum_committed()->AddSample( 665 isolate_->counters()->heap_sample_maximum_committed()->AddSample(
684 static_cast<int>(MaximumCommittedMemory() / KB)); 666 static_cast<int>(MaximumCommittedMemory() / KB));
685 } 667 }
686 668
687 #define UPDATE_COUNTERS_FOR_SPACE(space) \ 669 #define UPDATE_COUNTERS_FOR_SPACE(space) \
688 isolate_->counters()->space##_bytes_available()->Set( \ 670 isolate_->counters()->space##_bytes_available()->Set( \
689 static_cast<int>(space()->Available())); \ 671 static_cast<int>(space()->Available())); \
(...skipping 10 matching lines...) Expand all
700 } 682 }
701 #define UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(space) \ 683 #define UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(space) \
702 UPDATE_COUNTERS_FOR_SPACE(space) \ 684 UPDATE_COUNTERS_FOR_SPACE(space) \
703 UPDATE_FRAGMENTATION_FOR_SPACE(space) 685 UPDATE_FRAGMENTATION_FOR_SPACE(space)
704 686
705 UPDATE_COUNTERS_FOR_SPACE(new_space) 687 UPDATE_COUNTERS_FOR_SPACE(new_space)
706 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(old_space) 688 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(old_space)
707 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(code_space) 689 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(code_space)
708 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(map_space) 690 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(map_space)
709 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(cell_space) 691 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(cell_space)
710 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(property_cell_space)
711 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(lo_space) 692 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(lo_space)
712 #undef UPDATE_COUNTERS_FOR_SPACE 693 #undef UPDATE_COUNTERS_FOR_SPACE
713 #undef UPDATE_FRAGMENTATION_FOR_SPACE 694 #undef UPDATE_FRAGMENTATION_FOR_SPACE
714 #undef UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE 695 #undef UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE
715 696
716 #ifdef DEBUG 697 #ifdef DEBUG
717 ReportStatisticsAfterGC(); 698 ReportStatisticsAfterGC();
718 #endif // DEBUG 699 #endif // DEBUG
719 700
720 // Remember the last top pointer so that we can later find out 701 // Remember the last top pointer so that we can later find out
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 HeapObjectIterator cell_iterator(cell_space_); 1552 HeapObjectIterator cell_iterator(cell_space_);
1572 for (HeapObject* heap_object = cell_iterator.Next(); heap_object != NULL; 1553 for (HeapObject* heap_object = cell_iterator.Next(); heap_object != NULL;
1573 heap_object = cell_iterator.Next()) { 1554 heap_object = cell_iterator.Next()) {
1574 if (heap_object->IsCell()) { 1555 if (heap_object->IsCell()) {
1575 Cell* cell = Cell::cast(heap_object); 1556 Cell* cell = Cell::cast(heap_object);
1576 Address value_address = cell->ValueAddress(); 1557 Address value_address = cell->ValueAddress();
1577 scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(value_address)); 1558 scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(value_address));
1578 } 1559 }
1579 } 1560 }
1580 1561
1581 // Copy objects reachable from global property cells by scavenging global
1582 // property cell values directly.
1583 HeapObjectIterator js_global_property_cell_iterator(property_cell_space_);
1584 for (HeapObject* heap_object = js_global_property_cell_iterator.Next();
1585 heap_object != NULL;
1586 heap_object = js_global_property_cell_iterator.Next()) {
1587 if (heap_object->IsPropertyCell()) {
1588 PropertyCell* cell = PropertyCell::cast(heap_object);
1589 Address value_address = cell->ValueAddress();
1590 scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(value_address));
1591 }
1592 }
1593
1594 // Copy objects reachable from the encountered weak collections list. 1562 // Copy objects reachable from the encountered weak collections list.
1595 scavenge_visitor.VisitPointer(&encountered_weak_collections_); 1563 scavenge_visitor.VisitPointer(&encountered_weak_collections_);
1596 // Copy objects reachable from the encountered weak cells. 1564 // Copy objects reachable from the encountered weak cells.
1597 scavenge_visitor.VisitPointer(&encountered_weak_cells_); 1565 scavenge_visitor.VisitPointer(&encountered_weak_cells_);
1598 1566
1599 // Copy objects reachable from the code flushing candidates list. 1567 // Copy objects reachable from the code flushing candidates list.
1600 MarkCompactCollector* collector = mark_compact_collector(); 1568 MarkCompactCollector* collector = mark_compact_collector();
1601 if (collector->is_code_flushing_enabled()) { 1569 if (collector->is_code_flushing_enabled()) {
1602 collector->code_flusher()->IteratePointersToFromSpace(&scavenge_visitor); 1570 collector->code_flusher()->IteratePointersToFromSpace(&scavenge_visitor);
1603 } 1571 }
(...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after
2846 Cell::cast(result)->set_value(value); 2814 Cell::cast(result)->set_value(value);
2847 return result; 2815 return result;
2848 } 2816 }
2849 2817
2850 2818
2851 AllocationResult Heap::AllocatePropertyCell() { 2819 AllocationResult Heap::AllocatePropertyCell() {
2852 int size = PropertyCell::kSize; 2820 int size = PropertyCell::kSize;
2853 STATIC_ASSERT(PropertyCell::kSize <= Page::kMaxRegularHeapObjectSize); 2821 STATIC_ASSERT(PropertyCell::kSize <= Page::kMaxRegularHeapObjectSize);
2854 2822
2855 HeapObject* result; 2823 HeapObject* result;
2856 AllocationResult allocation = 2824 AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE);
2857 AllocateRaw(size, PROPERTY_CELL_SPACE, PROPERTY_CELL_SPACE);
2858 if (!allocation.To(&result)) return allocation; 2825 if (!allocation.To(&result)) return allocation;
2859 2826
2860 result->set_map_no_write_barrier(global_property_cell_map()); 2827 result->set_map_no_write_barrier(global_property_cell_map());
2861 PropertyCell* cell = PropertyCell::cast(result); 2828 PropertyCell* cell = PropertyCell::cast(result);
2862 cell->set_dependent_code(DependentCode::cast(empty_fixed_array()), 2829 cell->set_dependent_code(DependentCode::cast(empty_fixed_array()),
2863 SKIP_WRITE_BARRIER); 2830 SKIP_WRITE_BARRIER);
2864 cell->set_value(the_hole_value()); 2831 cell->set_value(the_hole_value());
2865 return result; 2832 return result;
2866 } 2833 }
2867 2834
(...skipping 1891 matching lines...) Expand 10 before | Expand all | Expand 10 after
4759 PrintF("To space : "); 4726 PrintF("To space : ");
4760 new_space_.ReportStatistics(); 4727 new_space_.ReportStatistics();
4761 PrintF("Old space : "); 4728 PrintF("Old space : ");
4762 old_space_->ReportStatistics(); 4729 old_space_->ReportStatistics();
4763 PrintF("Code space : "); 4730 PrintF("Code space : ");
4764 code_space_->ReportStatistics(); 4731 code_space_->ReportStatistics();
4765 PrintF("Map space : "); 4732 PrintF("Map space : ");
4766 map_space_->ReportStatistics(); 4733 map_space_->ReportStatistics();
4767 PrintF("Cell space : "); 4734 PrintF("Cell space : ");
4768 cell_space_->ReportStatistics(); 4735 cell_space_->ReportStatistics();
4769 PrintF("PropertyCell space : ");
4770 property_cell_space_->ReportStatistics();
4771 PrintF("Large object space : "); 4736 PrintF("Large object space : ");
4772 lo_space_->ReportStatistics(); 4737 lo_space_->ReportStatistics();
4773 PrintF(">>>>>> ========================================= >>>>>>\n"); 4738 PrintF(">>>>>> ========================================= >>>>>>\n");
4774 } 4739 }
4775 4740
4776 #endif // DEBUG 4741 #endif // DEBUG
4777 4742
4778 bool Heap::Contains(HeapObject* value) { return Contains(value->address()); } 4743 bool Heap::Contains(HeapObject* value) { return Contains(value->address()); }
4779 4744
4780 4745
4781 bool Heap::Contains(Address addr) { 4746 bool Heap::Contains(Address addr) {
4782 if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; 4747 if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false;
4783 return HasBeenSetUp() && 4748 return HasBeenSetUp() &&
4784 (new_space_.ToSpaceContains(addr) || old_space_->Contains(addr) || 4749 (new_space_.ToSpaceContains(addr) || old_space_->Contains(addr) ||
4785 code_space_->Contains(addr) || map_space_->Contains(addr) || 4750 code_space_->Contains(addr) || map_space_->Contains(addr) ||
4786 cell_space_->Contains(addr) || property_cell_space_->Contains(addr) || 4751 cell_space_->Contains(addr) || lo_space_->SlowContains(addr));
4787 lo_space_->SlowContains(addr));
4788 } 4752 }
4789 4753
4790 4754
4791 bool Heap::InSpace(HeapObject* value, AllocationSpace space) { 4755 bool Heap::InSpace(HeapObject* value, AllocationSpace space) {
4792 return InSpace(value->address(), space); 4756 return InSpace(value->address(), space);
4793 } 4757 }
4794 4758
4795 4759
4796 bool Heap::InSpace(Address addr, AllocationSpace space) { 4760 bool Heap::InSpace(Address addr, AllocationSpace space) {
4797 if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; 4761 if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false;
4798 if (!HasBeenSetUp()) return false; 4762 if (!HasBeenSetUp()) return false;
4799 4763
4800 switch (space) { 4764 switch (space) {
4801 case NEW_SPACE: 4765 case NEW_SPACE:
4802 return new_space_.ToSpaceContains(addr); 4766 return new_space_.ToSpaceContains(addr);
4803 case OLD_SPACE: 4767 case OLD_SPACE:
4804 return old_space_->Contains(addr); 4768 return old_space_->Contains(addr);
4805 case CODE_SPACE: 4769 case CODE_SPACE:
4806 return code_space_->Contains(addr); 4770 return code_space_->Contains(addr);
4807 case MAP_SPACE: 4771 case MAP_SPACE:
4808 return map_space_->Contains(addr); 4772 return map_space_->Contains(addr);
4809 case CELL_SPACE: 4773 case CELL_SPACE:
4810 return cell_space_->Contains(addr); 4774 return cell_space_->Contains(addr);
4811 case PROPERTY_CELL_SPACE:
4812 return property_cell_space_->Contains(addr);
4813 case LO_SPACE: 4775 case LO_SPACE:
4814 return lo_space_->SlowContains(addr); 4776 return lo_space_->SlowContains(addr);
4815 } 4777 }
4816 UNREACHABLE(); 4778 UNREACHABLE();
4817 return false; 4779 return false;
4818 } 4780 }
4819 4781
4820 4782
4821 bool Heap::RootIsImmortalImmovable(int root_index) { 4783 bool Heap::RootIsImmortalImmovable(int root_index) {
4822 switch (root_index) { 4784 switch (root_index) {
(...skipping 27 matching lines...) Expand all
4850 IterateSmiRoots(&smis_visitor); 4812 IterateSmiRoots(&smis_visitor);
4851 4813
4852 new_space_.Verify(); 4814 new_space_.Verify();
4853 4815
4854 old_space_->Verify(&visitor); 4816 old_space_->Verify(&visitor);
4855 map_space_->Verify(&visitor); 4817 map_space_->Verify(&visitor);
4856 4818
4857 VerifyPointersVisitor no_dirty_regions_visitor; 4819 VerifyPointersVisitor no_dirty_regions_visitor;
4858 code_space_->Verify(&no_dirty_regions_visitor); 4820 code_space_->Verify(&no_dirty_regions_visitor);
4859 cell_space_->Verify(&no_dirty_regions_visitor); 4821 cell_space_->Verify(&no_dirty_regions_visitor);
4860 property_cell_space_->Verify(&no_dirty_regions_visitor);
4861 4822
4862 lo_space_->Verify(); 4823 lo_space_->Verify();
4863 } 4824 }
4864 #endif 4825 #endif
4865 4826
4866 4827
4867 void Heap::ZapFromSpace() { 4828 void Heap::ZapFromSpace() {
4868 NewSpacePageIterator it(new_space_.FromSpaceStart(), 4829 NewSpacePageIterator it(new_space_.FromSpaceStart(),
4869 new_space_.FromSpaceEnd()); 4830 new_space_.FromSpaceEnd());
4870 while (it.has_next()) { 4831 while (it.has_next()) {
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
5173 *stats->new_space_size = new_space_.SizeAsInt(); 5134 *stats->new_space_size = new_space_.SizeAsInt();
5174 *stats->new_space_capacity = static_cast<int>(new_space_.Capacity()); 5135 *stats->new_space_capacity = static_cast<int>(new_space_.Capacity());
5175 *stats->old_space_size = old_space_->SizeOfObjects(); 5136 *stats->old_space_size = old_space_->SizeOfObjects();
5176 *stats->old_space_capacity = old_space_->Capacity(); 5137 *stats->old_space_capacity = old_space_->Capacity();
5177 *stats->code_space_size = code_space_->SizeOfObjects(); 5138 *stats->code_space_size = code_space_->SizeOfObjects();
5178 *stats->code_space_capacity = code_space_->Capacity(); 5139 *stats->code_space_capacity = code_space_->Capacity();
5179 *stats->map_space_size = map_space_->SizeOfObjects(); 5140 *stats->map_space_size = map_space_->SizeOfObjects();
5180 *stats->map_space_capacity = map_space_->Capacity(); 5141 *stats->map_space_capacity = map_space_->Capacity();
5181 *stats->cell_space_size = cell_space_->SizeOfObjects(); 5142 *stats->cell_space_size = cell_space_->SizeOfObjects();
5182 *stats->cell_space_capacity = cell_space_->Capacity(); 5143 *stats->cell_space_capacity = cell_space_->Capacity();
5183 *stats->property_cell_space_size = property_cell_space_->SizeOfObjects();
5184 *stats->property_cell_space_capacity = property_cell_space_->Capacity();
5185 *stats->lo_space_size = lo_space_->Size(); 5144 *stats->lo_space_size = lo_space_->Size();
5186 isolate_->global_handles()->RecordStats(stats); 5145 isolate_->global_handles()->RecordStats(stats);
5187 *stats->memory_allocator_size = isolate()->memory_allocator()->Size(); 5146 *stats->memory_allocator_size = isolate()->memory_allocator()->Size();
5188 *stats->memory_allocator_capacity = 5147 *stats->memory_allocator_capacity =
5189 isolate()->memory_allocator()->Size() + 5148 isolate()->memory_allocator()->Size() +
5190 isolate()->memory_allocator()->Available(); 5149 isolate()->memory_allocator()->Available();
5191 *stats->os_error = base::OS::GetLastError(); 5150 *stats->os_error = base::OS::GetLastError();
5192 isolate()->memory_allocator()->Available(); 5151 isolate()->memory_allocator()->Available();
5193 if (take_snapshot) { 5152 if (take_snapshot) {
5194 HeapIterator iterator(this); 5153 HeapIterator iterator(this);
5195 for (HeapObject* obj = iterator.next(); obj != NULL; 5154 for (HeapObject* obj = iterator.next(); obj != NULL;
5196 obj = iterator.next()) { 5155 obj = iterator.next()) {
5197 InstanceType type = obj->map()->instance_type(); 5156 InstanceType type = obj->map()->instance_type();
5198 DCHECK(0 <= type && type <= LAST_TYPE); 5157 DCHECK(0 <= type && type <= LAST_TYPE);
5199 stats->objects_per_type[type]++; 5158 stats->objects_per_type[type]++;
5200 stats->size_per_type[type] += obj->Size(); 5159 stats->size_per_type[type] += obj->Size();
5201 } 5160 }
5202 } 5161 }
5203 } 5162 }
5204 5163
5205 5164
5206 intptr_t Heap::PromotedSpaceSizeOfObjects() { 5165 intptr_t Heap::PromotedSpaceSizeOfObjects() {
5207 return old_space_->SizeOfObjects() + code_space_->SizeOfObjects() + 5166 return old_space_->SizeOfObjects() + code_space_->SizeOfObjects() +
5208 map_space_->SizeOfObjects() + cell_space_->SizeOfObjects() + 5167 map_space_->SizeOfObjects() + cell_space_->SizeOfObjects() +
5209 property_cell_space_->SizeOfObjects() + lo_space_->SizeOfObjects(); 5168 lo_space_->SizeOfObjects();
5210 } 5169 }
5211 5170
5212 5171
5213 int64_t Heap::PromotedExternalMemorySize() { 5172 int64_t Heap::PromotedExternalMemorySize() {
5214 if (amount_of_external_allocated_memory_ <= 5173 if (amount_of_external_allocated_memory_ <=
5215 amount_of_external_allocated_memory_at_last_global_gc_) 5174 amount_of_external_allocated_memory_at_last_global_gc_)
5216 return 0; 5175 return 0;
5217 return amount_of_external_allocated_memory_ - 5176 return amount_of_external_allocated_memory_ -
5218 amount_of_external_allocated_memory_at_last_global_gc_; 5177 amount_of_external_allocated_memory_at_last_global_gc_;
5219 } 5178 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
5346 // Initialize map space. 5305 // Initialize map space.
5347 map_space_ = new MapSpace(this, max_old_generation_size_, MAP_SPACE); 5306 map_space_ = new MapSpace(this, max_old_generation_size_, MAP_SPACE);
5348 if (map_space_ == NULL) return false; 5307 if (map_space_ == NULL) return false;
5349 if (!map_space_->SetUp()) return false; 5308 if (!map_space_->SetUp()) return false;
5350 5309
5351 // Initialize simple cell space. 5310 // Initialize simple cell space.
5352 cell_space_ = new CellSpace(this, max_old_generation_size_, CELL_SPACE); 5311 cell_space_ = new CellSpace(this, max_old_generation_size_, CELL_SPACE);
5353 if (cell_space_ == NULL) return false; 5312 if (cell_space_ == NULL) return false;
5354 if (!cell_space_->SetUp()) return false; 5313 if (!cell_space_->SetUp()) return false;
5355 5314
5356 // Initialize global property cell space.
5357 property_cell_space_ = new PropertyCellSpace(this, max_old_generation_size_,
5358 PROPERTY_CELL_SPACE);
5359 if (property_cell_space_ == NULL) return false;
5360 if (!property_cell_space_->SetUp()) return false;
5361
5362 // The large object code space may contain code or data. We set the memory 5315 // The large object code space may contain code or data. We set the memory
5363 // to be non-executable here for safety, but this means we need to enable it 5316 // to be non-executable here for safety, but this means we need to enable it
5364 // explicitly when allocating large code objects. 5317 // explicitly when allocating large code objects.
5365 lo_space_ = new LargeObjectSpace(this, max_old_generation_size_, LO_SPACE); 5318 lo_space_ = new LargeObjectSpace(this, max_old_generation_size_, LO_SPACE);
5366 if (lo_space_ == NULL) return false; 5319 if (lo_space_ == NULL) return false;
5367 if (!lo_space_->SetUp()) return false; 5320 if (!lo_space_->SetUp()) return false;
5368 5321
5369 // Set up the seed that is used to randomize the string hash function. 5322 // Set up the seed that is used to randomize the string hash function.
5370 DCHECK(hash_seed() == 0); 5323 DCHECK(hash_seed() == 0);
5371 if (FLAG_randomize_hashes) { 5324 if (FLAG_randomize_hashes) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
5462 PrintF("maximum_committed_by_new_space=%" V8_PTR_PREFIX "d ", 5415 PrintF("maximum_committed_by_new_space=%" V8_PTR_PREFIX "d ",
5463 new_space_.MaximumCommittedMemory()); 5416 new_space_.MaximumCommittedMemory());
5464 PrintF("maximum_committed_by_old_space=%" V8_PTR_PREFIX "d ", 5417 PrintF("maximum_committed_by_old_space=%" V8_PTR_PREFIX "d ",
5465 old_space_->MaximumCommittedMemory()); 5418 old_space_->MaximumCommittedMemory());
5466 PrintF("maximum_committed_by_code_space=%" V8_PTR_PREFIX "d ", 5419 PrintF("maximum_committed_by_code_space=%" V8_PTR_PREFIX "d ",
5467 code_space_->MaximumCommittedMemory()); 5420 code_space_->MaximumCommittedMemory());
5468 PrintF("maximum_committed_by_map_space=%" V8_PTR_PREFIX "d ", 5421 PrintF("maximum_committed_by_map_space=%" V8_PTR_PREFIX "d ",
5469 map_space_->MaximumCommittedMemory()); 5422 map_space_->MaximumCommittedMemory());
5470 PrintF("maximum_committed_by_cell_space=%" V8_PTR_PREFIX "d ", 5423 PrintF("maximum_committed_by_cell_space=%" V8_PTR_PREFIX "d ",
5471 cell_space_->MaximumCommittedMemory()); 5424 cell_space_->MaximumCommittedMemory());
5472 PrintF("maximum_committed_by_property_space=%" V8_PTR_PREFIX "d ",
5473 property_cell_space_->MaximumCommittedMemory());
5474 PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ", 5425 PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ",
5475 lo_space_->MaximumCommittedMemory()); 5426 lo_space_->MaximumCommittedMemory());
5476 PrintF("\n\n"); 5427 PrintF("\n\n");
5477 } 5428 }
5478 5429
5479 if (FLAG_verify_predictable) { 5430 if (FLAG_verify_predictable) {
5480 PrintAlloctionsHash(); 5431 PrintAlloctionsHash();
5481 } 5432 }
5482 5433
5483 TearDownArrayBuffers(); 5434 TearDownArrayBuffers();
(...skipping 23 matching lines...) Expand all
5507 delete map_space_; 5458 delete map_space_;
5508 map_space_ = NULL; 5459 map_space_ = NULL;
5509 } 5460 }
5510 5461
5511 if (cell_space_ != NULL) { 5462 if (cell_space_ != NULL) {
5512 cell_space_->TearDown(); 5463 cell_space_->TearDown();
5513 delete cell_space_; 5464 delete cell_space_;
5514 cell_space_ = NULL; 5465 cell_space_ = NULL;
5515 } 5466 }
5516 5467
5517 if (property_cell_space_ != NULL) {
5518 property_cell_space_->TearDown();
5519 delete property_cell_space_;
5520 property_cell_space_ = NULL;
5521 }
5522
5523 if (lo_space_ != NULL) { 5468 if (lo_space_ != NULL) {
5524 lo_space_->TearDown(); 5469 lo_space_->TearDown();
5525 delete lo_space_; 5470 delete lo_space_;
5526 lo_space_ = NULL; 5471 lo_space_ = NULL;
5527 } 5472 }
5528 5473
5529 store_buffer()->TearDown(); 5474 store_buffer()->TearDown();
5530 5475
5531 isolate_->memory_allocator()->TearDown(); 5476 isolate_->memory_allocator()->TearDown();
5532 } 5477 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
5636 case NEW_SPACE: 5581 case NEW_SPACE:
5637 return heap_->new_space(); 5582 return heap_->new_space();
5638 case OLD_SPACE: 5583 case OLD_SPACE:
5639 return heap_->old_space(); 5584 return heap_->old_space();
5640 case CODE_SPACE: 5585 case CODE_SPACE:
5641 return heap_->code_space(); 5586 return heap_->code_space();
5642 case MAP_SPACE: 5587 case MAP_SPACE:
5643 return heap_->map_space(); 5588 return heap_->map_space();
5644 case CELL_SPACE: 5589 case CELL_SPACE:
5645 return heap_->cell_space(); 5590 return heap_->cell_space();
5646 case PROPERTY_CELL_SPACE:
5647 return heap_->property_cell_space();
5648 case LO_SPACE: 5591 case LO_SPACE:
5649 return heap_->lo_space(); 5592 return heap_->lo_space();
5650 default: 5593 default:
5651 return NULL; 5594 return NULL;
5652 } 5595 }
5653 } 5596 }
5654 5597
5655 5598
5656 PagedSpace* PagedSpaces::next() { 5599 PagedSpace* PagedSpaces::next() {
5657 switch (counter_++) { 5600 switch (counter_++) {
5658 case OLD_SPACE: 5601 case OLD_SPACE:
5659 return heap_->old_space(); 5602 return heap_->old_space();
5660 case CODE_SPACE: 5603 case CODE_SPACE:
5661 return heap_->code_space(); 5604 return heap_->code_space();
5662 case MAP_SPACE: 5605 case MAP_SPACE:
5663 return heap_->map_space(); 5606 return heap_->map_space();
5664 case CELL_SPACE: 5607 case CELL_SPACE:
5665 return heap_->cell_space(); 5608 return heap_->cell_space();
5666 case PROPERTY_CELL_SPACE:
5667 return heap_->property_cell_space();
5668 default: 5609 default:
5669 return NULL; 5610 return NULL;
5670 } 5611 }
5671 } 5612 }
5672 5613
5673 5614
5674 OldSpace* OldSpaces::next() { 5615 OldSpace* OldSpaces::next() {
5675 switch (counter_++) { 5616 switch (counter_++) {
5676 case OLD_SPACE: 5617 case OLD_SPACE:
5677 return heap_->old_space(); 5618 return heap_->old_space();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
5738 break; 5679 break;
5739 case CODE_SPACE: 5680 case CODE_SPACE:
5740 iterator_ = new HeapObjectIterator(heap_->code_space(), size_func_); 5681 iterator_ = new HeapObjectIterator(heap_->code_space(), size_func_);
5741 break; 5682 break;
5742 case MAP_SPACE: 5683 case MAP_SPACE:
5743 iterator_ = new HeapObjectIterator(heap_->map_space(), size_func_); 5684 iterator_ = new HeapObjectIterator(heap_->map_space(), size_func_);
5744 break; 5685 break;
5745 case CELL_SPACE: 5686 case CELL_SPACE:
5746 iterator_ = new HeapObjectIterator(heap_->cell_space(), size_func_); 5687 iterator_ = new HeapObjectIterator(heap_->cell_space(), size_func_);
5747 break; 5688 break;
5748 case PROPERTY_CELL_SPACE:
5749 iterator_ =
5750 new HeapObjectIterator(heap_->property_cell_space(), size_func_);
5751 break;
5752 case LO_SPACE: 5689 case LO_SPACE:
5753 iterator_ = new LargeObjectIterator(heap_->lo_space(), size_func_); 5690 iterator_ = new LargeObjectIterator(heap_->lo_space(), size_func_);
5754 break; 5691 break;
5755 } 5692 }
5756 5693
5757 // Return the newly allocated iterator; 5694 // Return the newly allocated iterator;
5758 DCHECK(iterator_ != NULL); 5695 DCHECK(iterator_ != NULL);
5759 return iterator_; 5696 return iterator_;
5760 } 5697 }
5761 5698
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
6373 static_cast<int>(object_sizes_last_time_[index])); 6310 static_cast<int>(object_sizes_last_time_[index]));
6374 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6311 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6375 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6312 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6376 6313
6377 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6314 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6378 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6315 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6379 ClearObjectStats(); 6316 ClearObjectStats();
6380 } 6317 }
6381 } 6318 }
6382 } // namespace v8::internal 6319 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/heap-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698