| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 // generation can be aligned to its size. | 77 // generation can be aligned to its size. |
| 78 maximum_committed_(0), | 78 maximum_committed_(0), |
| 79 survived_since_last_expansion_(0), | 79 survived_since_last_expansion_(0), |
| 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_pointer_space_(NULL), |
| 88 old_data_space_(NULL), |
| 88 code_space_(NULL), | 89 code_space_(NULL), |
| 89 map_space_(NULL), | 90 map_space_(NULL), |
| 90 cell_space_(NULL), | 91 cell_space_(NULL), |
| 91 lo_space_(NULL), | 92 lo_space_(NULL), |
| 92 gc_state_(NOT_IN_GC), | 93 gc_state_(NOT_IN_GC), |
| 93 gc_post_processing_depth_(0), | 94 gc_post_processing_depth_(0), |
| 94 allocations_count_(0), | 95 allocations_count_(0), |
| 95 raw_allocations_hash_(0), | 96 raw_allocations_hash_(0), |
| 96 dump_allocations_hash_countdown_(FLAG_dump_allocations_digest_at_alloc), | 97 dump_allocations_hash_countdown_(FLAG_dump_allocations_digest_at_alloc), |
| 97 ms_count_(0), | 98 ms_count_(0), |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 // minidump even if there are no real unmapped pages. | 165 // minidump even if there are no real unmapped pages. |
| 165 RememberUnmappedPage(NULL, false); | 166 RememberUnmappedPage(NULL, false); |
| 166 | 167 |
| 167 ClearObjectStats(true); | 168 ClearObjectStats(true); |
| 168 } | 169 } |
| 169 | 170 |
| 170 | 171 |
| 171 intptr_t Heap::Capacity() { | 172 intptr_t Heap::Capacity() { |
| 172 if (!HasBeenSetUp()) return 0; | 173 if (!HasBeenSetUp()) return 0; |
| 173 | 174 |
| 174 return new_space_.Capacity() + old_space_->Capacity() + | 175 return new_space_.Capacity() + old_pointer_space_->Capacity() + |
| 175 code_space_->Capacity() + map_space_->Capacity() + | 176 old_data_space_->Capacity() + code_space_->Capacity() + |
| 176 cell_space_->Capacity(); | 177 map_space_->Capacity() + cell_space_->Capacity(); |
| 177 } | 178 } |
| 178 | 179 |
| 179 | 180 |
| 180 intptr_t Heap::CommittedOldGenerationMemory() { | 181 intptr_t Heap::CommittedOldGenerationMemory() { |
| 181 if (!HasBeenSetUp()) return 0; | 182 if (!HasBeenSetUp()) return 0; |
| 182 | 183 |
| 183 return old_space_->CommittedMemory() + code_space_->CommittedMemory() + | 184 return old_pointer_space_->CommittedMemory() + |
| 185 old_data_space_->CommittedMemory() + code_space_->CommittedMemory() + |
| 184 map_space_->CommittedMemory() + cell_space_->CommittedMemory() + | 186 map_space_->CommittedMemory() + cell_space_->CommittedMemory() + |
| 185 lo_space_->Size(); | 187 lo_space_->Size(); |
| 186 } | 188 } |
| 187 | 189 |
| 188 | 190 |
| 189 intptr_t Heap::CommittedMemory() { | 191 intptr_t Heap::CommittedMemory() { |
| 190 if (!HasBeenSetUp()) return 0; | 192 if (!HasBeenSetUp()) return 0; |
| 191 | 193 |
| 192 return new_space_.CommittedMemory() + CommittedOldGenerationMemory(); | 194 return new_space_.CommittedMemory() + CommittedOldGenerationMemory(); |
| 193 } | 195 } |
| 194 | 196 |
| 195 | 197 |
| 196 size_t Heap::CommittedPhysicalMemory() { | 198 size_t Heap::CommittedPhysicalMemory() { |
| 197 if (!HasBeenSetUp()) return 0; | 199 if (!HasBeenSetUp()) return 0; |
| 198 | 200 |
| 199 return new_space_.CommittedPhysicalMemory() + | 201 return new_space_.CommittedPhysicalMemory() + |
| 200 old_space_->CommittedPhysicalMemory() + | 202 old_pointer_space_->CommittedPhysicalMemory() + |
| 203 old_data_space_->CommittedPhysicalMemory() + |
| 201 code_space_->CommittedPhysicalMemory() + | 204 code_space_->CommittedPhysicalMemory() + |
| 202 map_space_->CommittedPhysicalMemory() + | 205 map_space_->CommittedPhysicalMemory() + |
| 203 cell_space_->CommittedPhysicalMemory() + | 206 cell_space_->CommittedPhysicalMemory() + |
| 204 lo_space_->CommittedPhysicalMemory(); | 207 lo_space_->CommittedPhysicalMemory(); |
| 205 } | 208 } |
| 206 | 209 |
| 207 | 210 |
| 208 intptr_t Heap::CommittedMemoryExecutable() { | 211 intptr_t Heap::CommittedMemoryExecutable() { |
| 209 if (!HasBeenSetUp()) return 0; | 212 if (!HasBeenSetUp()) return 0; |
| 210 | 213 |
| 211 return isolate()->memory_allocator()->SizeExecutable(); | 214 return isolate()->memory_allocator()->SizeExecutable(); |
| 212 } | 215 } |
| 213 | 216 |
| 214 | 217 |
| 215 void Heap::UpdateMaximumCommitted() { | 218 void Heap::UpdateMaximumCommitted() { |
| 216 if (!HasBeenSetUp()) return; | 219 if (!HasBeenSetUp()) return; |
| 217 | 220 |
| 218 intptr_t current_committed_memory = CommittedMemory(); | 221 intptr_t current_committed_memory = CommittedMemory(); |
| 219 if (current_committed_memory > maximum_committed_) { | 222 if (current_committed_memory > maximum_committed_) { |
| 220 maximum_committed_ = current_committed_memory; | 223 maximum_committed_ = current_committed_memory; |
| 221 } | 224 } |
| 222 } | 225 } |
| 223 | 226 |
| 224 | 227 |
| 225 intptr_t Heap::Available() { | 228 intptr_t Heap::Available() { |
| 226 if (!HasBeenSetUp()) return 0; | 229 if (!HasBeenSetUp()) return 0; |
| 227 | 230 |
| 228 return new_space_.Available() + old_space_->Available() + | 231 return new_space_.Available() + old_pointer_space_->Available() + |
| 229 code_space_->Available() + map_space_->Available() + | 232 old_data_space_->Available() + code_space_->Available() + |
| 230 cell_space_->Available(); | 233 map_space_->Available() + cell_space_->Available(); |
| 231 } | 234 } |
| 232 | 235 |
| 233 | 236 |
| 234 bool Heap::HasBeenSetUp() { | 237 bool Heap::HasBeenSetUp() { |
| 235 return old_space_ != NULL && code_space_ != NULL && map_space_ != NULL && | 238 return old_pointer_space_ != NULL && old_data_space_ != NULL && |
| 236 cell_space_ != NULL && lo_space_ != NULL; | 239 code_space_ != NULL && map_space_ != NULL && cell_space_ != NULL && |
| 240 lo_space_ != NULL; |
| 237 } | 241 } |
| 238 | 242 |
| 239 | 243 |
| 240 int Heap::GcSafeSizeOfOldObject(HeapObject* object) { | 244 int Heap::GcSafeSizeOfOldObject(HeapObject* object) { |
| 241 if (IntrusiveMarking::IsMarked(object)) { | 245 if (IntrusiveMarking::IsMarked(object)) { |
| 242 return IntrusiveMarking::SizeOfMarkedObject(object); | 246 return IntrusiveMarking::SizeOfMarkedObject(object); |
| 243 } | 247 } |
| 244 return object->SizeFromMap(object->map()); | 248 return object->SizeFromMap(object->map()); |
| 245 } | 249 } |
| 246 | 250 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 ", available: %6" V8_PTR_PREFIX "d KB\n", | 333 ", available: %6" V8_PTR_PREFIX "d KB\n", |
| 330 isolate_->memory_allocator()->Size() / KB, | 334 isolate_->memory_allocator()->Size() / KB, |
| 331 isolate_->memory_allocator()->Available() / KB); | 335 isolate_->memory_allocator()->Available() / KB); |
| 332 PrintPID("New space, used: %6" V8_PTR_PREFIX | 336 PrintPID("New space, used: %6" V8_PTR_PREFIX |
| 333 "d KB" | 337 "d KB" |
| 334 ", available: %6" V8_PTR_PREFIX | 338 ", available: %6" V8_PTR_PREFIX |
| 335 "d KB" | 339 "d KB" |
| 336 ", committed: %6" V8_PTR_PREFIX "d KB\n", | 340 ", committed: %6" V8_PTR_PREFIX "d KB\n", |
| 337 new_space_.Size() / KB, new_space_.Available() / KB, | 341 new_space_.Size() / KB, new_space_.Available() / KB, |
| 338 new_space_.CommittedMemory() / KB); | 342 new_space_.CommittedMemory() / KB); |
| 339 PrintPID("Old space, used: %6" V8_PTR_PREFIX | 343 PrintPID("Old pointers, used: %6" V8_PTR_PREFIX |
| 340 "d KB" | 344 "d KB" |
| 341 ", available: %6" V8_PTR_PREFIX | 345 ", available: %6" V8_PTR_PREFIX |
| 342 "d KB" | 346 "d KB" |
| 343 ", committed: %6" V8_PTR_PREFIX "d KB\n", | 347 ", committed: %6" V8_PTR_PREFIX "d KB\n", |
| 344 old_space_->SizeOfObjects() / KB, old_space_->Available() / KB, | 348 old_pointer_space_->SizeOfObjects() / KB, |
| 345 old_space_->CommittedMemory() / KB); | 349 old_pointer_space_->Available() / KB, |
| 350 old_pointer_space_->CommittedMemory() / KB); |
| 351 PrintPID("Old data space, used: %6" V8_PTR_PREFIX |
| 352 "d KB" |
| 353 ", available: %6" V8_PTR_PREFIX |
| 354 "d KB" |
| 355 ", committed: %6" V8_PTR_PREFIX "d KB\n", |
| 356 old_data_space_->SizeOfObjects() / KB, |
| 357 old_data_space_->Available() / KB, |
| 358 old_data_space_->CommittedMemory() / KB); |
| 346 PrintPID("Code space, used: %6" V8_PTR_PREFIX | 359 PrintPID("Code space, used: %6" V8_PTR_PREFIX |
| 347 "d KB" | 360 "d KB" |
| 348 ", available: %6" V8_PTR_PREFIX | 361 ", available: %6" V8_PTR_PREFIX |
| 349 "d KB" | 362 "d KB" |
| 350 ", committed: %6" V8_PTR_PREFIX "d KB\n", | 363 ", committed: %6" V8_PTR_PREFIX "d KB\n", |
| 351 code_space_->SizeOfObjects() / KB, code_space_->Available() / KB, | 364 code_space_->SizeOfObjects() / KB, code_space_->Available() / KB, |
| 352 code_space_->CommittedMemory() / KB); | 365 code_space_->CommittedMemory() / KB); |
| 353 PrintPID("Map space, used: %6" V8_PTR_PREFIX | 366 PrintPID("Map space, used: %6" V8_PTR_PREFIX |
| 354 "d KB" | 367 "d KB" |
| 355 ", available: %6" V8_PTR_PREFIX | 368 ", available: %6" V8_PTR_PREFIX |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 (crankshaft_codegen_bytes_generated_ + | 644 (crankshaft_codegen_bytes_generated_ + |
| 632 full_codegen_bytes_generated_))); | 645 full_codegen_bytes_generated_))); |
| 633 } | 646 } |
| 634 | 647 |
| 635 if (CommittedMemory() > 0) { | 648 if (CommittedMemory() > 0) { |
| 636 isolate_->counters()->external_fragmentation_total()->AddSample( | 649 isolate_->counters()->external_fragmentation_total()->AddSample( |
| 637 static_cast<int>(100 - (SizeOfObjects() * 100.0) / CommittedMemory())); | 650 static_cast<int>(100 - (SizeOfObjects() * 100.0) / CommittedMemory())); |
| 638 | 651 |
| 639 isolate_->counters()->heap_fraction_new_space()->AddSample(static_cast<int>( | 652 isolate_->counters()->heap_fraction_new_space()->AddSample(static_cast<int>( |
| 640 (new_space()->CommittedMemory() * 100.0) / CommittedMemory())); | 653 (new_space()->CommittedMemory() * 100.0) / CommittedMemory())); |
| 641 isolate_->counters()->heap_fraction_old_space()->AddSample(static_cast<int>( | 654 isolate_->counters()->heap_fraction_old_pointer_space()->AddSample( |
| 642 (old_space()->CommittedMemory() * 100.0) / CommittedMemory())); | 655 static_cast<int>((old_pointer_space()->CommittedMemory() * 100.0) / |
| 656 CommittedMemory())); |
| 657 isolate_->counters()->heap_fraction_old_data_space()->AddSample( |
| 658 static_cast<int>((old_data_space()->CommittedMemory() * 100.0) / |
| 659 CommittedMemory())); |
| 643 isolate_->counters()->heap_fraction_code_space()->AddSample( | 660 isolate_->counters()->heap_fraction_code_space()->AddSample( |
| 644 static_cast<int>((code_space()->CommittedMemory() * 100.0) / | 661 static_cast<int>((code_space()->CommittedMemory() * 100.0) / |
| 645 CommittedMemory())); | 662 CommittedMemory())); |
| 646 isolate_->counters()->heap_fraction_map_space()->AddSample(static_cast<int>( | 663 isolate_->counters()->heap_fraction_map_space()->AddSample(static_cast<int>( |
| 647 (map_space()->CommittedMemory() * 100.0) / CommittedMemory())); | 664 (map_space()->CommittedMemory() * 100.0) / CommittedMemory())); |
| 648 isolate_->counters()->heap_fraction_cell_space()->AddSample( | 665 isolate_->counters()->heap_fraction_cell_space()->AddSample( |
| 649 static_cast<int>((cell_space()->CommittedMemory() * 100.0) / | 666 static_cast<int>((cell_space()->CommittedMemory() * 100.0) / |
| 650 CommittedMemory())); | 667 CommittedMemory())); |
| 651 isolate_->counters()->heap_fraction_lo_space()->AddSample(static_cast<int>( | 668 isolate_->counters()->heap_fraction_lo_space()->AddSample(static_cast<int>( |
| 652 (lo_space()->CommittedMemory() * 100.0) / CommittedMemory())); | 669 (lo_space()->CommittedMemory() * 100.0) / CommittedMemory())); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 678 isolate_->counters()->external_fragmentation_##space()->AddSample( \ | 695 isolate_->counters()->external_fragmentation_##space()->AddSample( \ |
| 679 static_cast<int>(100 - \ | 696 static_cast<int>(100 - \ |
| 680 (space()->SizeOfObjects() * 100.0) / \ | 697 (space()->SizeOfObjects() * 100.0) / \ |
| 681 space()->CommittedMemory())); \ | 698 space()->CommittedMemory())); \ |
| 682 } | 699 } |
| 683 #define UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(space) \ | 700 #define UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(space) \ |
| 684 UPDATE_COUNTERS_FOR_SPACE(space) \ | 701 UPDATE_COUNTERS_FOR_SPACE(space) \ |
| 685 UPDATE_FRAGMENTATION_FOR_SPACE(space) | 702 UPDATE_FRAGMENTATION_FOR_SPACE(space) |
| 686 | 703 |
| 687 UPDATE_COUNTERS_FOR_SPACE(new_space) | 704 UPDATE_COUNTERS_FOR_SPACE(new_space) |
| 688 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(old_space) | 705 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(old_pointer_space) |
| 706 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(old_data_space) |
| 689 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(code_space) | 707 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(code_space) |
| 690 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(map_space) | 708 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(map_space) |
| 691 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(cell_space) | 709 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(cell_space) |
| 692 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(lo_space) | 710 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(lo_space) |
| 693 #undef UPDATE_COUNTERS_FOR_SPACE | 711 #undef UPDATE_COUNTERS_FOR_SPACE |
| 694 #undef UPDATE_FRAGMENTATION_FOR_SPACE | 712 #undef UPDATE_FRAGMENTATION_FOR_SPACE |
| 695 #undef UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE | 713 #undef UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE |
| 696 | 714 |
| 697 #ifdef DEBUG | 715 #ifdef DEBUG |
| 698 ReportStatisticsAfterGC(); | 716 ReportStatisticsAfterGC(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 } | 773 } |
| 756 } | 774 } |
| 757 | 775 |
| 758 | 776 |
| 759 void Heap::CollectAllGarbage(int flags, const char* gc_reason, | 777 void Heap::CollectAllGarbage(int flags, const char* gc_reason, |
| 760 const v8::GCCallbackFlags gc_callback_flags) { | 778 const v8::GCCallbackFlags gc_callback_flags) { |
| 761 // Since we are ignoring the return value, the exact choice of space does | 779 // Since we are ignoring the return value, the exact choice of space does |
| 762 // not matter, so long as we do not specify NEW_SPACE, which would not | 780 // not matter, so long as we do not specify NEW_SPACE, which would not |
| 763 // cause a full GC. | 781 // cause a full GC. |
| 764 mark_compact_collector_.SetFlags(flags); | 782 mark_compact_collector_.SetFlags(flags); |
| 765 CollectGarbage(OLD_SPACE, gc_reason, gc_callback_flags); | 783 CollectGarbage(OLD_POINTER_SPACE, gc_reason, gc_callback_flags); |
| 766 mark_compact_collector_.SetFlags(kNoGCFlags); | 784 mark_compact_collector_.SetFlags(kNoGCFlags); |
| 767 } | 785 } |
| 768 | 786 |
| 769 | 787 |
| 770 void Heap::CollectAllAvailableGarbage(const char* gc_reason) { | 788 void Heap::CollectAllAvailableGarbage(const char* gc_reason) { |
| 771 // Since we are ignoring the return value, the exact choice of space does | 789 // Since we are ignoring the return value, the exact choice of space does |
| 772 // not matter, so long as we do not specify NEW_SPACE, which would not | 790 // not matter, so long as we do not specify NEW_SPACE, which would not |
| 773 // cause a full GC. | 791 // cause a full GC. |
| 774 // Major GC would invoke weak handle callbacks on weakly reachable | 792 // Major GC would invoke weak handle callbacks on weakly reachable |
| 775 // handles, but won't collect weakly reachable objects until next | 793 // handles, but won't collect weakly reachable objects until next |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1338 | 1356 |
| 1339 | 1357 |
| 1340 static void VerifyNonPointerSpacePointers(Heap* heap) { | 1358 static void VerifyNonPointerSpacePointers(Heap* heap) { |
| 1341 // Verify that there are no pointers to new space in spaces where we | 1359 // Verify that there are no pointers to new space in spaces where we |
| 1342 // do not expect them. | 1360 // do not expect them. |
| 1343 VerifyNonPointerSpacePointersVisitor v(heap); | 1361 VerifyNonPointerSpacePointersVisitor v(heap); |
| 1344 HeapObjectIterator code_it(heap->code_space()); | 1362 HeapObjectIterator code_it(heap->code_space()); |
| 1345 for (HeapObject* object = code_it.Next(); object != NULL; | 1363 for (HeapObject* object = code_it.Next(); object != NULL; |
| 1346 object = code_it.Next()) | 1364 object = code_it.Next()) |
| 1347 object->Iterate(&v); | 1365 object->Iterate(&v); |
| 1366 |
| 1367 HeapObjectIterator data_it(heap->old_data_space()); |
| 1368 for (HeapObject* object = data_it.Next(); object != NULL; |
| 1369 object = data_it.Next()) |
| 1370 object->Iterate(&v); |
| 1348 } | 1371 } |
| 1349 #endif // VERIFY_HEAP | 1372 #endif // VERIFY_HEAP |
| 1350 | 1373 |
| 1351 | 1374 |
| 1352 void Heap::CheckNewSpaceExpansionCriteria() { | 1375 void Heap::CheckNewSpaceExpansionCriteria() { |
| 1353 if (FLAG_experimental_new_space_growth_heuristic) { | 1376 if (FLAG_experimental_new_space_growth_heuristic) { |
| 1354 if (new_space_.TotalCapacity() < new_space_.MaximumCapacity() && | 1377 if (new_space_.TotalCapacity() < new_space_.MaximumCapacity() && |
| 1355 survived_last_scavenge_ * 100 / new_space_.TotalCapacity() >= 10) { | 1378 survived_last_scavenge_ * 100 / new_space_.TotalCapacity() >= 10) { |
| 1356 // Grow the size of new space if there is room to grow, and more than 10% | 1379 // Grow the size of new space if there is room to grow, and more than 10% |
| 1357 // have survived the last scavenge. | 1380 // have survived the last scavenge. |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2119 HeapObject* object, int object_size) { | 2142 HeapObject* object, int object_size) { |
| 2120 Heap* heap = map->GetHeap(); | 2143 Heap* heap = map->GetHeap(); |
| 2121 | 2144 |
| 2122 int allocation_size = object_size; | 2145 int allocation_size = object_size; |
| 2123 if (alignment != kObjectAlignment) { | 2146 if (alignment != kObjectAlignment) { |
| 2124 DCHECK(alignment == kDoubleAlignment); | 2147 DCHECK(alignment == kDoubleAlignment); |
| 2125 allocation_size += kPointerSize; | 2148 allocation_size += kPointerSize; |
| 2126 } | 2149 } |
| 2127 | 2150 |
| 2128 AllocationResult allocation; | 2151 AllocationResult allocation; |
| 2129 allocation = heap->old_space()->AllocateRaw(allocation_size); | 2152 if (object_contents == DATA_OBJECT) { |
| 2153 DCHECK(heap->AllowedToBeMigrated(object, OLD_DATA_SPACE)); |
| 2154 allocation = heap->old_data_space()->AllocateRaw(allocation_size); |
| 2155 } else { |
| 2156 DCHECK(heap->AllowedToBeMigrated(object, OLD_POINTER_SPACE)); |
| 2157 allocation = heap->old_pointer_space()->AllocateRaw(allocation_size); |
| 2158 } |
| 2130 | 2159 |
| 2131 HeapObject* target = NULL; // Initialization to please compiler. | 2160 HeapObject* target = NULL; // Initialization to please compiler. |
| 2132 if (allocation.To(&target)) { | 2161 if (allocation.To(&target)) { |
| 2133 if (alignment != kObjectAlignment) { | 2162 if (alignment != kObjectAlignment) { |
| 2134 target = EnsureDoubleAligned(heap, target, allocation_size); | 2163 target = EnsureDoubleAligned(heap, target, allocation_size); |
| 2135 } | 2164 } |
| 2136 MigrateObject(heap, object, target, object_size); | 2165 MigrateObject(heap, object, target, object_size); |
| 2137 | 2166 |
| 2138 // Update slot to new target. | 2167 // Update slot to new target. |
| 2139 *slot = target; | 2168 *slot = target; |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2535 } | 2564 } |
| 2536 | 2565 |
| 2537 // Allocate the empty array. | 2566 // Allocate the empty array. |
| 2538 { | 2567 { |
| 2539 AllocationResult allocation = AllocateEmptyFixedArray(); | 2568 AllocationResult allocation = AllocateEmptyFixedArray(); |
| 2540 if (!allocation.To(&obj)) return false; | 2569 if (!allocation.To(&obj)) return false; |
| 2541 } | 2570 } |
| 2542 set_empty_fixed_array(FixedArray::cast(obj)); | 2571 set_empty_fixed_array(FixedArray::cast(obj)); |
| 2543 | 2572 |
| 2544 { | 2573 { |
| 2545 AllocationResult allocation = Allocate(null_map(), OLD_SPACE); | 2574 AllocationResult allocation = Allocate(null_map(), OLD_POINTER_SPACE); |
| 2546 if (!allocation.To(&obj)) return false; | 2575 if (!allocation.To(&obj)) return false; |
| 2547 } | 2576 } |
| 2548 set_null_value(Oddball::cast(obj)); | 2577 set_null_value(Oddball::cast(obj)); |
| 2549 Oddball::cast(obj)->set_kind(Oddball::kNull); | 2578 Oddball::cast(obj)->set_kind(Oddball::kNull); |
| 2550 | 2579 |
| 2551 { | 2580 { |
| 2552 AllocationResult allocation = Allocate(undefined_map(), OLD_SPACE); | 2581 AllocationResult allocation = Allocate(undefined_map(), OLD_POINTER_SPACE); |
| 2553 if (!allocation.To(&obj)) return false; | 2582 if (!allocation.To(&obj)) return false; |
| 2554 } | 2583 } |
| 2555 set_undefined_value(Oddball::cast(obj)); | 2584 set_undefined_value(Oddball::cast(obj)); |
| 2556 Oddball::cast(obj)->set_kind(Oddball::kUndefined); | 2585 Oddball::cast(obj)->set_kind(Oddball::kUndefined); |
| 2557 DCHECK(!InNewSpace(undefined_value())); | 2586 DCHECK(!InNewSpace(undefined_value())); |
| 2558 | 2587 |
| 2559 // Set preliminary exception sentinel value before actually initializing it. | 2588 // Set preliminary exception sentinel value before actually initializing it. |
| 2560 set_exception(null_value()); | 2589 set_exception(null_value()); |
| 2561 | 2590 |
| 2562 // Allocate the empty descriptor array. | 2591 // Allocate the empty descriptor array. |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2779 } | 2808 } |
| 2780 | 2809 |
| 2781 | 2810 |
| 2782 AllocationResult Heap::AllocateHeapNumber(double value, MutableMode mode, | 2811 AllocationResult Heap::AllocateHeapNumber(double value, MutableMode mode, |
| 2783 PretenureFlag pretenure) { | 2812 PretenureFlag pretenure) { |
| 2784 // Statically ensure that it is safe to allocate heap numbers in paged | 2813 // Statically ensure that it is safe to allocate heap numbers in paged |
| 2785 // spaces. | 2814 // spaces. |
| 2786 int size = HeapNumber::kSize; | 2815 int size = HeapNumber::kSize; |
| 2787 STATIC_ASSERT(HeapNumber::kSize <= Page::kMaxRegularHeapObjectSize); | 2816 STATIC_ASSERT(HeapNumber::kSize <= Page::kMaxRegularHeapObjectSize); |
| 2788 | 2817 |
| 2789 AllocationSpace space = SelectSpace(size, pretenure); | 2818 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); |
| 2790 | 2819 |
| 2791 HeapObject* result; | 2820 HeapObject* result; |
| 2792 { | 2821 { |
| 2793 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 2822 AllocationResult allocation = AllocateRaw(size, space, OLD_DATA_SPACE); |
| 2794 if (!allocation.To(&result)) return allocation; | 2823 if (!allocation.To(&result)) return allocation; |
| 2795 } | 2824 } |
| 2796 | 2825 |
| 2797 Map* map = mode == MUTABLE ? mutable_heap_number_map() : heap_number_map(); | 2826 Map* map = mode == MUTABLE ? mutable_heap_number_map() : heap_number_map(); |
| 2798 HeapObject::cast(result)->set_map_no_write_barrier(map); | 2827 HeapObject::cast(result)->set_map_no_write_barrier(map); |
| 2799 HeapNumber::cast(result)->set_value(value); | 2828 HeapNumber::cast(result)->set_value(value); |
| 2800 return result; | 2829 return result; |
| 2801 } | 2830 } |
| 2802 | 2831 |
| 2803 | 2832 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2814 Cell::cast(result)->set_value(value); | 2843 Cell::cast(result)->set_value(value); |
| 2815 return result; | 2844 return result; |
| 2816 } | 2845 } |
| 2817 | 2846 |
| 2818 | 2847 |
| 2819 AllocationResult Heap::AllocatePropertyCell() { | 2848 AllocationResult Heap::AllocatePropertyCell() { |
| 2820 int size = PropertyCell::kSize; | 2849 int size = PropertyCell::kSize; |
| 2821 STATIC_ASSERT(PropertyCell::kSize <= Page::kMaxRegularHeapObjectSize); | 2850 STATIC_ASSERT(PropertyCell::kSize <= Page::kMaxRegularHeapObjectSize); |
| 2822 | 2851 |
| 2823 HeapObject* result; | 2852 HeapObject* result; |
| 2824 AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); | 2853 AllocationResult allocation = |
| 2854 AllocateRaw(size, OLD_POINTER_SPACE, OLD_POINTER_SPACE); |
| 2825 if (!allocation.To(&result)) return allocation; | 2855 if (!allocation.To(&result)) return allocation; |
| 2826 | 2856 |
| 2827 result->set_map_no_write_barrier(global_property_cell_map()); | 2857 result->set_map_no_write_barrier(global_property_cell_map()); |
| 2828 PropertyCell* cell = PropertyCell::cast(result); | 2858 PropertyCell* cell = PropertyCell::cast(result); |
| 2829 cell->set_dependent_code(DependentCode::cast(empty_fixed_array()), | 2859 cell->set_dependent_code(DependentCode::cast(empty_fixed_array()), |
| 2830 SKIP_WRITE_BARRIER); | 2860 SKIP_WRITE_BARRIER); |
| 2831 cell->set_value(the_hole_value()); | 2861 cell->set_value(the_hole_value()); |
| 2832 return result; | 2862 return result; |
| 2833 } | 2863 } |
| 2834 | 2864 |
| 2835 | 2865 |
| 2836 AllocationResult Heap::AllocateWeakCell(HeapObject* value) { | 2866 AllocationResult Heap::AllocateWeakCell(HeapObject* value) { |
| 2837 int size = WeakCell::kSize; | 2867 int size = WeakCell::kSize; |
| 2838 STATIC_ASSERT(WeakCell::kSize <= Page::kMaxRegularHeapObjectSize); | 2868 STATIC_ASSERT(WeakCell::kSize <= Page::kMaxRegularHeapObjectSize); |
| 2839 HeapObject* result = NULL; | 2869 HeapObject* result = NULL; |
| 2840 { | 2870 { |
| 2841 AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); | 2871 AllocationResult allocation = |
| 2872 AllocateRaw(size, OLD_POINTER_SPACE, OLD_POINTER_SPACE); |
| 2842 if (!allocation.To(&result)) return allocation; | 2873 if (!allocation.To(&result)) return allocation; |
| 2843 } | 2874 } |
| 2844 result->set_map_no_write_barrier(weak_cell_map()); | 2875 result->set_map_no_write_barrier(weak_cell_map()); |
| 2845 WeakCell::cast(result)->initialize(value); | 2876 WeakCell::cast(result)->initialize(value); |
| 2846 WeakCell::cast(result)->set_next(undefined_value(), SKIP_WRITE_BARRIER); | 2877 WeakCell::cast(result)->set_next(undefined_value(), SKIP_WRITE_BARRIER); |
| 2847 return result; | 2878 return result; |
| 2848 } | 2879 } |
| 2849 | 2880 |
| 2850 | 2881 |
| 2851 void Heap::CreateApiObjects() { | 2882 void Heap::CreateApiObjects() { |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3385 FixedTypedArrayBase* Heap::EmptyFixedTypedArrayForMap(Map* map) { | 3416 FixedTypedArrayBase* Heap::EmptyFixedTypedArrayForMap(Map* map) { |
| 3386 return FixedTypedArrayBase::cast( | 3417 return FixedTypedArrayBase::cast( |
| 3387 roots_[RootIndexForEmptyFixedTypedArray(map->elements_kind())]); | 3418 roots_[RootIndexForEmptyFixedTypedArray(map->elements_kind())]); |
| 3388 } | 3419 } |
| 3389 | 3420 |
| 3390 | 3421 |
| 3391 AllocationResult Heap::AllocateForeign(Address address, | 3422 AllocationResult Heap::AllocateForeign(Address address, |
| 3392 PretenureFlag pretenure) { | 3423 PretenureFlag pretenure) { |
| 3393 // Statically ensure that it is safe to allocate foreigns in paged spaces. | 3424 // Statically ensure that it is safe to allocate foreigns in paged spaces. |
| 3394 STATIC_ASSERT(Foreign::kSize <= Page::kMaxRegularHeapObjectSize); | 3425 STATIC_ASSERT(Foreign::kSize <= Page::kMaxRegularHeapObjectSize); |
| 3395 AllocationSpace space = (pretenure == TENURED) ? OLD_SPACE : NEW_SPACE; | 3426 AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; |
| 3396 Foreign* result; | 3427 Foreign* result; |
| 3397 AllocationResult allocation = Allocate(foreign_map(), space); | 3428 AllocationResult allocation = Allocate(foreign_map(), space); |
| 3398 if (!allocation.To(&result)) return allocation; | 3429 if (!allocation.To(&result)) return allocation; |
| 3399 result->set_foreign_address(address); | 3430 result->set_foreign_address(address); |
| 3400 return result; | 3431 return result; |
| 3401 } | 3432 } |
| 3402 | 3433 |
| 3403 | 3434 |
| 3404 AllocationResult Heap::AllocateByteArray(int length, PretenureFlag pretenure) { | 3435 AllocationResult Heap::AllocateByteArray(int length, PretenureFlag pretenure) { |
| 3405 if (length < 0 || length > ByteArray::kMaxLength) { | 3436 if (length < 0 || length > ByteArray::kMaxLength) { |
| 3406 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); | 3437 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); |
| 3407 } | 3438 } |
| 3408 int size = ByteArray::SizeFor(length); | 3439 int size = ByteArray::SizeFor(length); |
| 3409 AllocationSpace space = SelectSpace(size, pretenure); | 3440 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); |
| 3410 HeapObject* result; | 3441 HeapObject* result; |
| 3411 { | 3442 { |
| 3412 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 3443 AllocationResult allocation = AllocateRaw(size, space, OLD_DATA_SPACE); |
| 3413 if (!allocation.To(&result)) return allocation; | 3444 if (!allocation.To(&result)) return allocation; |
| 3414 } | 3445 } |
| 3415 | 3446 |
| 3416 result->set_map_no_write_barrier(byte_array_map()); | 3447 result->set_map_no_write_barrier(byte_array_map()); |
| 3417 ByteArray::cast(result)->set_length(length); | 3448 ByteArray::cast(result)->set_length(length); |
| 3418 return result; | 3449 return result; |
| 3419 } | 3450 } |
| 3420 | 3451 |
| 3421 | 3452 |
| 3422 void Heap::CreateFillerObjectAt(Address addr, int size) { | 3453 void Heap::CreateFillerObjectAt(Address addr, int size) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 3433 } else { | 3464 } else { |
| 3434 filler->set_map_no_write_barrier(raw_unchecked_free_space_map()); | 3465 filler->set_map_no_write_barrier(raw_unchecked_free_space_map()); |
| 3435 DCHECK(filler->map() == NULL || filler->map() == free_space_map()); | 3466 DCHECK(filler->map() == NULL || filler->map() == free_space_map()); |
| 3436 FreeSpace::cast(filler)->nobarrier_set_size(size); | 3467 FreeSpace::cast(filler)->nobarrier_set_size(size); |
| 3437 } | 3468 } |
| 3438 } | 3469 } |
| 3439 | 3470 |
| 3440 | 3471 |
| 3441 bool Heap::CanMoveObjectStart(HeapObject* object) { | 3472 bool Heap::CanMoveObjectStart(HeapObject* object) { |
| 3442 Address address = object->address(); | 3473 Address address = object->address(); |
| 3474 bool is_in_old_pointer_space = InOldPointerSpace(address); |
| 3475 bool is_in_old_data_space = InOldDataSpace(address); |
| 3443 | 3476 |
| 3444 if (lo_space()->Contains(object)) return false; | 3477 if (lo_space()->Contains(object)) return false; |
| 3445 | 3478 |
| 3446 Page* page = Page::FromAddress(address); | 3479 Page* page = Page::FromAddress(address); |
| 3447 // We can move the object start if: | 3480 // We can move the object start if: |
| 3448 // (1) the object is not in old space, | 3481 // (1) the object is not in old pointer or old data space, |
| 3449 // (2) the page of the object was already swept, | 3482 // (2) the page of the object was already swept, |
| 3450 // (3) the page was already concurrently swept. This case is an optimization | 3483 // (3) the page was already concurrently swept. This case is an optimization |
| 3451 // for concurrent sweeping. The WasSwept predicate for concurrently swept | 3484 // for concurrent sweeping. The WasSwept predicate for concurrently swept |
| 3452 // pages is set after sweeping all pages. | 3485 // pages is set after sweeping all pages. |
| 3453 return !InOldSpace(address) || page->WasSwept() || page->SweepingCompleted(); | 3486 return (!is_in_old_pointer_space && !is_in_old_data_space) || |
| 3487 page->WasSwept() || page->SweepingCompleted(); |
| 3454 } | 3488 } |
| 3455 | 3489 |
| 3456 | 3490 |
| 3457 void Heap::AdjustLiveBytes(Address address, int by, InvocationMode mode) { | 3491 void Heap::AdjustLiveBytes(Address address, int by, InvocationMode mode) { |
| 3458 if (incremental_marking()->IsMarking() && | 3492 if (incremental_marking()->IsMarking() && |
| 3459 Marking::IsBlack(Marking::MarkBitFrom(address))) { | 3493 Marking::IsBlack(Marking::MarkBitFrom(address))) { |
| 3460 if (mode == FROM_GC) { | 3494 if (mode == FROM_GC) { |
| 3461 MemoryChunk::IncrementLiveBytesFromGC(address, by); | 3495 MemoryChunk::IncrementLiveBytesFromGC(address, by); |
| 3462 } else { | 3496 } else { |
| 3463 MemoryChunk::IncrementLiveBytesFromMutator(address, by); | 3497 MemoryChunk::IncrementLiveBytesFromMutator(address, by); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3560 profiler->UpdateObjectSizeEvent(object->address(), object->Size()); | 3594 profiler->UpdateObjectSizeEvent(object->address(), object->Size()); |
| 3561 } | 3595 } |
| 3562 } | 3596 } |
| 3563 | 3597 |
| 3564 | 3598 |
| 3565 AllocationResult Heap::AllocateExternalArray(int length, | 3599 AllocationResult Heap::AllocateExternalArray(int length, |
| 3566 ExternalArrayType array_type, | 3600 ExternalArrayType array_type, |
| 3567 void* external_pointer, | 3601 void* external_pointer, |
| 3568 PretenureFlag pretenure) { | 3602 PretenureFlag pretenure) { |
| 3569 int size = ExternalArray::kAlignedSize; | 3603 int size = ExternalArray::kAlignedSize; |
| 3570 AllocationSpace space = SelectSpace(size, pretenure); | 3604 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); |
| 3571 HeapObject* result; | 3605 HeapObject* result; |
| 3572 { | 3606 { |
| 3573 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 3607 AllocationResult allocation = AllocateRaw(size, space, OLD_DATA_SPACE); |
| 3574 if (!allocation.To(&result)) return allocation; | 3608 if (!allocation.To(&result)) return allocation; |
| 3575 } | 3609 } |
| 3576 | 3610 |
| 3577 result->set_map_no_write_barrier(MapForExternalArrayType(array_type)); | 3611 result->set_map_no_write_barrier(MapForExternalArrayType(array_type)); |
| 3578 ExternalArray::cast(result)->set_length(length); | 3612 ExternalArray::cast(result)->set_length(length); |
| 3579 ExternalArray::cast(result)->set_external_pointer(external_pointer); | 3613 ExternalArray::cast(result)->set_external_pointer(external_pointer); |
| 3580 return result; | 3614 return result; |
| 3581 } | 3615 } |
| 3582 | 3616 |
| 3583 static void ForFixedTypedArray(ExternalArrayType array_type, int* element_size, | 3617 static void ForFixedTypedArray(ExternalArrayType array_type, int* element_size, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3606 int element_size; | 3640 int element_size; |
| 3607 ElementsKind elements_kind; | 3641 ElementsKind elements_kind; |
| 3608 ForFixedTypedArray(array_type, &element_size, &elements_kind); | 3642 ForFixedTypedArray(array_type, &element_size, &elements_kind); |
| 3609 int size = OBJECT_POINTER_ALIGN(length * element_size + | 3643 int size = OBJECT_POINTER_ALIGN(length * element_size + |
| 3610 FixedTypedArrayBase::kDataOffset); | 3644 FixedTypedArrayBase::kDataOffset); |
| 3611 #ifndef V8_HOST_ARCH_64_BIT | 3645 #ifndef V8_HOST_ARCH_64_BIT |
| 3612 if (array_type == kExternalFloat64Array) { | 3646 if (array_type == kExternalFloat64Array) { |
| 3613 size += kPointerSize; | 3647 size += kPointerSize; |
| 3614 } | 3648 } |
| 3615 #endif | 3649 #endif |
| 3616 AllocationSpace space = SelectSpace(size, pretenure); | 3650 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); |
| 3617 | 3651 |
| 3618 HeapObject* object; | 3652 HeapObject* object; |
| 3619 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 3653 AllocationResult allocation = AllocateRaw(size, space, OLD_DATA_SPACE); |
| 3620 if (!allocation.To(&object)) return allocation; | 3654 if (!allocation.To(&object)) return allocation; |
| 3621 | 3655 |
| 3622 if (array_type == kExternalFloat64Array) { | 3656 if (array_type == kExternalFloat64Array) { |
| 3623 object = EnsureDoubleAligned(this, object, size); | 3657 object = EnsureDoubleAligned(this, object, size); |
| 3624 } | 3658 } |
| 3625 | 3659 |
| 3626 object->set_map(MapForFixedTypedArray(array_type)); | 3660 object->set_map(MapForFixedTypedArray(array_type)); |
| 3627 FixedTypedArrayBase* elements = FixedTypedArrayBase::cast(object); | 3661 FixedTypedArrayBase* elements = FixedTypedArrayBase::cast(object); |
| 3628 elements->set_length(length); | 3662 elements->set_length(length); |
| 3629 memset(elements->DataPtr(), 0, elements->DataSize()); | 3663 memset(elements->DataPtr(), 0, elements->DataSize()); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3773 } | 3807 } |
| 3774 } | 3808 } |
| 3775 | 3809 |
| 3776 | 3810 |
| 3777 AllocationResult Heap::Allocate(Map* map, AllocationSpace space, | 3811 AllocationResult Heap::Allocate(Map* map, AllocationSpace space, |
| 3778 AllocationSite* allocation_site) { | 3812 AllocationSite* allocation_site) { |
| 3779 DCHECK(gc_state_ == NOT_IN_GC); | 3813 DCHECK(gc_state_ == NOT_IN_GC); |
| 3780 DCHECK(map->instance_type() != MAP_TYPE); | 3814 DCHECK(map->instance_type() != MAP_TYPE); |
| 3781 // If allocation failures are disallowed, we may allocate in a different | 3815 // If allocation failures are disallowed, we may allocate in a different |
| 3782 // space when new space is full and the object is not a large object. | 3816 // space when new space is full and the object is not a large object. |
| 3783 AllocationSpace retry_space = (space != NEW_SPACE) ? space : OLD_SPACE; | 3817 AllocationSpace retry_space = |
| 3818 (space != NEW_SPACE) ? space : TargetSpaceId(map->instance_type()); |
| 3784 int size = map->instance_size(); | 3819 int size = map->instance_size(); |
| 3785 if (allocation_site != NULL) { | 3820 if (allocation_site != NULL) { |
| 3786 size += AllocationMemento::kSize; | 3821 size += AllocationMemento::kSize; |
| 3787 } | 3822 } |
| 3788 HeapObject* result; | 3823 HeapObject* result; |
| 3789 AllocationResult allocation = AllocateRaw(size, space, retry_space); | 3824 AllocationResult allocation = AllocateRaw(size, space, retry_space); |
| 3790 if (!allocation.To(&result)) return allocation; | 3825 if (!allocation.To(&result)) return allocation; |
| 3791 // No need for write barrier since object is white and map is in old space. | 3826 // No need for write barrier since object is white and map is in old space. |
| 3792 result->set_map_no_write_barrier(map); | 3827 result->set_map_no_write_barrier(map); |
| 3793 if (allocation_site != NULL) { | 3828 if (allocation_site != NULL) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3850 { | 3885 { |
| 3851 AllocationResult allocation = AllocateFixedArray(prop_size, pretenure); | 3886 AllocationResult allocation = AllocateFixedArray(prop_size, pretenure); |
| 3852 if (!allocation.To(&properties)) return allocation; | 3887 if (!allocation.To(&properties)) return allocation; |
| 3853 } | 3888 } |
| 3854 } else { | 3889 } else { |
| 3855 properties = empty_fixed_array(); | 3890 properties = empty_fixed_array(); |
| 3856 } | 3891 } |
| 3857 | 3892 |
| 3858 // Allocate the JSObject. | 3893 // Allocate the JSObject. |
| 3859 int size = map->instance_size(); | 3894 int size = map->instance_size(); |
| 3860 AllocationSpace space = SelectSpace(size, pretenure); | 3895 AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, pretenure); |
| 3861 JSObject* js_obj; | 3896 JSObject* js_obj; |
| 3862 AllocationResult allocation = Allocate(map, space, allocation_site); | 3897 AllocationResult allocation = Allocate(map, space, allocation_site); |
| 3863 if (!allocation.To(&js_obj)) return allocation; | 3898 if (!allocation.To(&js_obj)) return allocation; |
| 3864 | 3899 |
| 3865 // Initialize the JSObject. | 3900 // Initialize the JSObject. |
| 3866 InitializeJSObjectFromMap(js_obj, properties, map); | 3901 InitializeJSObjectFromMap(js_obj, properties, map); |
| 3867 DCHECK(js_obj->HasFastElements() || js_obj->HasExternalArrayElements() || | 3902 DCHECK(js_obj->HasFastElements() || js_obj->HasExternalArrayElements() || |
| 3868 js_obj->HasFixedTypedArrayElements()); | 3903 js_obj->HasFixedTypedArrayElements()); |
| 3869 return js_obj; | 3904 return js_obj; |
| 3870 } | 3905 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3901 | 3936 |
| 3902 DCHECK(site == NULL || AllocationSite::CanTrack(map->instance_type())); | 3937 DCHECK(site == NULL || AllocationSite::CanTrack(map->instance_type())); |
| 3903 | 3938 |
| 3904 WriteBarrierMode wb_mode = UPDATE_WRITE_BARRIER; | 3939 WriteBarrierMode wb_mode = UPDATE_WRITE_BARRIER; |
| 3905 | 3940 |
| 3906 // If we're forced to always allocate, we use the general allocation | 3941 // If we're forced to always allocate, we use the general allocation |
| 3907 // functions which may leave us with an object in old space. | 3942 // functions which may leave us with an object in old space. |
| 3908 if (always_allocate()) { | 3943 if (always_allocate()) { |
| 3909 { | 3944 { |
| 3910 AllocationResult allocation = | 3945 AllocationResult allocation = |
| 3911 AllocateRaw(object_size, NEW_SPACE, OLD_SPACE); | 3946 AllocateRaw(object_size, NEW_SPACE, OLD_POINTER_SPACE); |
| 3912 if (!allocation.To(&clone)) return allocation; | 3947 if (!allocation.To(&clone)) return allocation; |
| 3913 } | 3948 } |
| 3914 Address clone_address = clone->address(); | 3949 Address clone_address = clone->address(); |
| 3915 CopyBlock(clone_address, source->address(), object_size); | 3950 CopyBlock(clone_address, source->address(), object_size); |
| 3916 | 3951 |
| 3917 // Update write barrier for all tagged fields that lie beyond the header. | 3952 // Update write barrier for all tagged fields that lie beyond the header. |
| 3918 const int start_offset = JSObject::kHeaderSize; | 3953 const int start_offset = JSObject::kHeaderSize; |
| 3919 const int end_offset = object_size; | 3954 const int end_offset = object_size; |
| 3920 | 3955 |
| 3921 #if V8_DOUBLE_FIELDS_UNBOXING | 3956 #if V8_DOUBLE_FIELDS_UNBOXING |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4052 | 4087 |
| 4053 DCHECK_LE(0, chars); | 4088 DCHECK_LE(0, chars); |
| 4054 DCHECK_GE(String::kMaxLength, chars); | 4089 DCHECK_GE(String::kMaxLength, chars); |
| 4055 if (is_one_byte) { | 4090 if (is_one_byte) { |
| 4056 map = one_byte_internalized_string_map(); | 4091 map = one_byte_internalized_string_map(); |
| 4057 size = SeqOneByteString::SizeFor(chars); | 4092 size = SeqOneByteString::SizeFor(chars); |
| 4058 } else { | 4093 } else { |
| 4059 map = internalized_string_map(); | 4094 map = internalized_string_map(); |
| 4060 size = SeqTwoByteString::SizeFor(chars); | 4095 size = SeqTwoByteString::SizeFor(chars); |
| 4061 } | 4096 } |
| 4062 AllocationSpace space = SelectSpace(size, TENURED); | 4097 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, TENURED); |
| 4063 | 4098 |
| 4064 // Allocate string. | 4099 // Allocate string. |
| 4065 HeapObject* result; | 4100 HeapObject* result; |
| 4066 { | 4101 { |
| 4067 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 4102 AllocationResult allocation = AllocateRaw(size, space, OLD_DATA_SPACE); |
| 4068 if (!allocation.To(&result)) return allocation; | 4103 if (!allocation.To(&result)) return allocation; |
| 4069 } | 4104 } |
| 4070 | 4105 |
| 4071 result->set_map_no_write_barrier(map); | 4106 result->set_map_no_write_barrier(map); |
| 4072 // Set length and hash fields of the allocated string. | 4107 // Set length and hash fields of the allocated string. |
| 4073 String* answer = String::cast(result); | 4108 String* answer = String::cast(result); |
| 4074 answer->set_length(chars); | 4109 answer->set_length(chars); |
| 4075 answer->set_hash_field(hash_field); | 4110 answer->set_hash_field(hash_field); |
| 4076 | 4111 |
| 4077 DCHECK_EQ(size, answer->Size()); | 4112 DCHECK_EQ(size, answer->Size()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 4095 template AllocationResult Heap::AllocateInternalizedStringImpl<false>( | 4130 template AllocationResult Heap::AllocateInternalizedStringImpl<false>( |
| 4096 Vector<const char>, int, uint32_t); | 4131 Vector<const char>, int, uint32_t); |
| 4097 | 4132 |
| 4098 | 4133 |
| 4099 AllocationResult Heap::AllocateRawOneByteString(int length, | 4134 AllocationResult Heap::AllocateRawOneByteString(int length, |
| 4100 PretenureFlag pretenure) { | 4135 PretenureFlag pretenure) { |
| 4101 DCHECK_LE(0, length); | 4136 DCHECK_LE(0, length); |
| 4102 DCHECK_GE(String::kMaxLength, length); | 4137 DCHECK_GE(String::kMaxLength, length); |
| 4103 int size = SeqOneByteString::SizeFor(length); | 4138 int size = SeqOneByteString::SizeFor(length); |
| 4104 DCHECK(size <= SeqOneByteString::kMaxSize); | 4139 DCHECK(size <= SeqOneByteString::kMaxSize); |
| 4105 AllocationSpace space = SelectSpace(size, pretenure); | 4140 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); |
| 4106 | 4141 |
| 4107 HeapObject* result; | 4142 HeapObject* result; |
| 4108 { | 4143 { |
| 4109 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 4144 AllocationResult allocation = AllocateRaw(size, space, OLD_DATA_SPACE); |
| 4110 if (!allocation.To(&result)) return allocation; | 4145 if (!allocation.To(&result)) return allocation; |
| 4111 } | 4146 } |
| 4112 | 4147 |
| 4113 // Partially initialize the object. | 4148 // Partially initialize the object. |
| 4114 result->set_map_no_write_barrier(one_byte_string_map()); | 4149 result->set_map_no_write_barrier(one_byte_string_map()); |
| 4115 String::cast(result)->set_length(length); | 4150 String::cast(result)->set_length(length); |
| 4116 String::cast(result)->set_hash_field(String::kEmptyHashField); | 4151 String::cast(result)->set_hash_field(String::kEmptyHashField); |
| 4117 DCHECK_EQ(size, HeapObject::cast(result)->Size()); | 4152 DCHECK_EQ(size, HeapObject::cast(result)->Size()); |
| 4118 | 4153 |
| 4119 return result; | 4154 return result; |
| 4120 } | 4155 } |
| 4121 | 4156 |
| 4122 | 4157 |
| 4123 AllocationResult Heap::AllocateRawTwoByteString(int length, | 4158 AllocationResult Heap::AllocateRawTwoByteString(int length, |
| 4124 PretenureFlag pretenure) { | 4159 PretenureFlag pretenure) { |
| 4125 DCHECK_LE(0, length); | 4160 DCHECK_LE(0, length); |
| 4126 DCHECK_GE(String::kMaxLength, length); | 4161 DCHECK_GE(String::kMaxLength, length); |
| 4127 int size = SeqTwoByteString::SizeFor(length); | 4162 int size = SeqTwoByteString::SizeFor(length); |
| 4128 DCHECK(size <= SeqTwoByteString::kMaxSize); | 4163 DCHECK(size <= SeqTwoByteString::kMaxSize); |
| 4129 AllocationSpace space = SelectSpace(size, pretenure); | 4164 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); |
| 4130 | 4165 |
| 4131 HeapObject* result; | 4166 HeapObject* result; |
| 4132 { | 4167 { |
| 4133 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 4168 AllocationResult allocation = AllocateRaw(size, space, OLD_DATA_SPACE); |
| 4134 if (!allocation.To(&result)) return allocation; | 4169 if (!allocation.To(&result)) return allocation; |
| 4135 } | 4170 } |
| 4136 | 4171 |
| 4137 // Partially initialize the object. | 4172 // Partially initialize the object. |
| 4138 result->set_map_no_write_barrier(string_map()); | 4173 result->set_map_no_write_barrier(string_map()); |
| 4139 String::cast(result)->set_length(length); | 4174 String::cast(result)->set_length(length); |
| 4140 String::cast(result)->set_hash_field(String::kEmptyHashField); | 4175 String::cast(result)->set_hash_field(String::kEmptyHashField); |
| 4141 DCHECK_EQ(size, HeapObject::cast(result)->Size()); | 4176 DCHECK_EQ(size, HeapObject::cast(result)->Size()); |
| 4142 return result; | 4177 return result; |
| 4143 } | 4178 } |
| 4144 | 4179 |
| 4145 | 4180 |
| 4146 AllocationResult Heap::AllocateEmptyFixedArray() { | 4181 AllocationResult Heap::AllocateEmptyFixedArray() { |
| 4147 int size = FixedArray::SizeFor(0); | 4182 int size = FixedArray::SizeFor(0); |
| 4148 HeapObject* result; | 4183 HeapObject* result; |
| 4149 { | 4184 { |
| 4150 AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); | 4185 AllocationResult allocation = |
| 4186 AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE); |
| 4151 if (!allocation.To(&result)) return allocation; | 4187 if (!allocation.To(&result)) return allocation; |
| 4152 } | 4188 } |
| 4153 // Initialize the object. | 4189 // Initialize the object. |
| 4154 result->set_map_no_write_barrier(fixed_array_map()); | 4190 result->set_map_no_write_barrier(fixed_array_map()); |
| 4155 FixedArray::cast(result)->set_length(0); | 4191 FixedArray::cast(result)->set_length(0); |
| 4156 return result; | 4192 return result; |
| 4157 } | 4193 } |
| 4158 | 4194 |
| 4159 | 4195 |
| 4160 AllocationResult Heap::AllocateEmptyExternalArray( | 4196 AllocationResult Heap::AllocateEmptyExternalArray( |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4262 return obj; | 4298 return obj; |
| 4263 } | 4299 } |
| 4264 | 4300 |
| 4265 | 4301 |
| 4266 AllocationResult Heap::AllocateRawFixedArray(int length, | 4302 AllocationResult Heap::AllocateRawFixedArray(int length, |
| 4267 PretenureFlag pretenure) { | 4303 PretenureFlag pretenure) { |
| 4268 if (length < 0 || length > FixedArray::kMaxLength) { | 4304 if (length < 0 || length > FixedArray::kMaxLength) { |
| 4269 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); | 4305 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); |
| 4270 } | 4306 } |
| 4271 int size = FixedArray::SizeFor(length); | 4307 int size = FixedArray::SizeFor(length); |
| 4272 AllocationSpace space = SelectSpace(size, pretenure); | 4308 AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, pretenure); |
| 4273 | 4309 |
| 4274 return AllocateRaw(size, space, OLD_SPACE); | 4310 return AllocateRaw(size, space, OLD_POINTER_SPACE); |
| 4275 } | 4311 } |
| 4276 | 4312 |
| 4277 | 4313 |
| 4278 AllocationResult Heap::AllocateFixedArrayWithFiller(int length, | 4314 AllocationResult Heap::AllocateFixedArrayWithFiller(int length, |
| 4279 PretenureFlag pretenure, | 4315 PretenureFlag pretenure, |
| 4280 Object* filler) { | 4316 Object* filler) { |
| 4281 DCHECK(length >= 0); | 4317 DCHECK(length >= 0); |
| 4282 DCHECK(empty_fixed_array()->IsFixedArray()); | 4318 DCHECK(empty_fixed_array()->IsFixedArray()); |
| 4283 if (length == 0) return empty_fixed_array(); | 4319 if (length == 0) return empty_fixed_array(); |
| 4284 | 4320 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4333 | 4369 |
| 4334 AllocationResult Heap::AllocateRawFixedDoubleArray(int length, | 4370 AllocationResult Heap::AllocateRawFixedDoubleArray(int length, |
| 4335 PretenureFlag pretenure) { | 4371 PretenureFlag pretenure) { |
| 4336 if (length < 0 || length > FixedDoubleArray::kMaxLength) { | 4372 if (length < 0 || length > FixedDoubleArray::kMaxLength) { |
| 4337 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); | 4373 v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); |
| 4338 } | 4374 } |
| 4339 int size = FixedDoubleArray::SizeFor(length); | 4375 int size = FixedDoubleArray::SizeFor(length); |
| 4340 #ifndef V8_HOST_ARCH_64_BIT | 4376 #ifndef V8_HOST_ARCH_64_BIT |
| 4341 size += kPointerSize; | 4377 size += kPointerSize; |
| 4342 #endif | 4378 #endif |
| 4343 AllocationSpace space = SelectSpace(size, pretenure); | 4379 AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); |
| 4344 | 4380 |
| 4345 HeapObject* object; | 4381 HeapObject* object; |
| 4346 { | 4382 { |
| 4347 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 4383 AllocationResult allocation = AllocateRaw(size, space, OLD_DATA_SPACE); |
| 4348 if (!allocation.To(&object)) return allocation; | 4384 if (!allocation.To(&object)) return allocation; |
| 4349 } | 4385 } |
| 4350 | 4386 |
| 4351 return EnsureDoubleAligned(this, object, size); | 4387 return EnsureDoubleAligned(this, object, size); |
| 4352 } | 4388 } |
| 4353 | 4389 |
| 4354 | 4390 |
| 4355 AllocationResult Heap::AllocateConstantPoolArray( | 4391 AllocationResult Heap::AllocateConstantPoolArray( |
| 4356 const ConstantPoolArray::NumberOfEntries& small) { | 4392 const ConstantPoolArray::NumberOfEntries& small) { |
| 4357 CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType)); | 4393 CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType)); |
| 4358 int size = ConstantPoolArray::SizeFor(small); | 4394 int size = ConstantPoolArray::SizeFor(small); |
| 4359 #ifndef V8_HOST_ARCH_64_BIT | 4395 #ifndef V8_HOST_ARCH_64_BIT |
| 4360 size += kPointerSize; | 4396 size += kPointerSize; |
| 4361 #endif | 4397 #endif |
| 4362 AllocationSpace space = SelectSpace(size, TENURED); | 4398 AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, TENURED); |
| 4363 | 4399 |
| 4364 HeapObject* object; | 4400 HeapObject* object; |
| 4365 { | 4401 { |
| 4366 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 4402 AllocationResult allocation = AllocateRaw(size, space, OLD_POINTER_SPACE); |
| 4367 if (!allocation.To(&object)) return allocation; | 4403 if (!allocation.To(&object)) return allocation; |
| 4368 } | 4404 } |
| 4369 object = EnsureDoubleAligned(this, object, size); | 4405 object = EnsureDoubleAligned(this, object, size); |
| 4370 object->set_map_no_write_barrier(constant_pool_array_map()); | 4406 object->set_map_no_write_barrier(constant_pool_array_map()); |
| 4371 | 4407 |
| 4372 ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); | 4408 ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); |
| 4373 constant_pool->Init(small); | 4409 constant_pool->Init(small); |
| 4374 constant_pool->ClearPtrEntries(isolate()); | 4410 constant_pool->ClearPtrEntries(isolate()); |
| 4375 return constant_pool; | 4411 return constant_pool; |
| 4376 } | 4412 } |
| 4377 | 4413 |
| 4378 | 4414 |
| 4379 AllocationResult Heap::AllocateExtendedConstantPoolArray( | 4415 AllocationResult Heap::AllocateExtendedConstantPoolArray( |
| 4380 const ConstantPoolArray::NumberOfEntries& small, | 4416 const ConstantPoolArray::NumberOfEntries& small, |
| 4381 const ConstantPoolArray::NumberOfEntries& extended) { | 4417 const ConstantPoolArray::NumberOfEntries& extended) { |
| 4382 CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType)); | 4418 CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType)); |
| 4383 CHECK(extended.are_in_range(0, kMaxInt)); | 4419 CHECK(extended.are_in_range(0, kMaxInt)); |
| 4384 int size = ConstantPoolArray::SizeForExtended(small, extended); | 4420 int size = ConstantPoolArray::SizeForExtended(small, extended); |
| 4385 #ifndef V8_HOST_ARCH_64_BIT | 4421 #ifndef V8_HOST_ARCH_64_BIT |
| 4386 size += kPointerSize; | 4422 size += kPointerSize; |
| 4387 #endif | 4423 #endif |
| 4388 AllocationSpace space = SelectSpace(size, TENURED); | 4424 AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, TENURED); |
| 4389 | 4425 |
| 4390 HeapObject* object; | 4426 HeapObject* object; |
| 4391 { | 4427 { |
| 4392 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 4428 AllocationResult allocation = AllocateRaw(size, space, OLD_POINTER_SPACE); |
| 4393 if (!allocation.To(&object)) return allocation; | 4429 if (!allocation.To(&object)) return allocation; |
| 4394 } | 4430 } |
| 4395 object = EnsureDoubleAligned(this, object, size); | 4431 object = EnsureDoubleAligned(this, object, size); |
| 4396 object->set_map_no_write_barrier(constant_pool_array_map()); | 4432 object->set_map_no_write_barrier(constant_pool_array_map()); |
| 4397 | 4433 |
| 4398 ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); | 4434 ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); |
| 4399 constant_pool->InitExtended(small, extended); | 4435 constant_pool->InitExtended(small, extended); |
| 4400 constant_pool->ClearPtrEntries(isolate()); | 4436 constant_pool->ClearPtrEntries(isolate()); |
| 4401 return constant_pool; | 4437 return constant_pool; |
| 4402 } | 4438 } |
| 4403 | 4439 |
| 4404 | 4440 |
| 4405 AllocationResult Heap::AllocateEmptyConstantPoolArray() { | 4441 AllocationResult Heap::AllocateEmptyConstantPoolArray() { |
| 4406 ConstantPoolArray::NumberOfEntries small(0, 0, 0, 0); | 4442 ConstantPoolArray::NumberOfEntries small(0, 0, 0, 0); |
| 4407 int size = ConstantPoolArray::SizeFor(small); | 4443 int size = ConstantPoolArray::SizeFor(small); |
| 4408 HeapObject* result = NULL; | 4444 HeapObject* result = NULL; |
| 4409 { | 4445 { |
| 4410 AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); | 4446 AllocationResult allocation = |
| 4447 AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE); |
| 4411 if (!allocation.To(&result)) return allocation; | 4448 if (!allocation.To(&result)) return allocation; |
| 4412 } | 4449 } |
| 4413 result->set_map_no_write_barrier(constant_pool_array_map()); | 4450 result->set_map_no_write_barrier(constant_pool_array_map()); |
| 4414 ConstantPoolArray::cast(result)->Init(small); | 4451 ConstantPoolArray::cast(result)->Init(small); |
| 4415 return result; | 4452 return result; |
| 4416 } | 4453 } |
| 4417 | 4454 |
| 4418 | 4455 |
| 4419 AllocationResult Heap::AllocateSymbol() { | 4456 AllocationResult Heap::AllocateSymbol() { |
| 4420 // Statically ensure that it is safe to allocate symbols in paged spaces. | 4457 // Statically ensure that it is safe to allocate symbols in paged spaces. |
| 4421 STATIC_ASSERT(Symbol::kSize <= Page::kMaxRegularHeapObjectSize); | 4458 STATIC_ASSERT(Symbol::kSize <= Page::kMaxRegularHeapObjectSize); |
| 4422 | 4459 |
| 4423 HeapObject* result = NULL; | 4460 HeapObject* result = NULL; |
| 4424 AllocationResult allocation = | 4461 AllocationResult allocation = |
| 4425 AllocateRaw(Symbol::kSize, OLD_SPACE, OLD_SPACE); | 4462 AllocateRaw(Symbol::kSize, OLD_POINTER_SPACE, OLD_POINTER_SPACE); |
| 4426 if (!allocation.To(&result)) return allocation; | 4463 if (!allocation.To(&result)) return allocation; |
| 4427 | 4464 |
| 4428 result->set_map_no_write_barrier(symbol_map()); | 4465 result->set_map_no_write_barrier(symbol_map()); |
| 4429 | 4466 |
| 4430 // Generate a random hash value. | 4467 // Generate a random hash value. |
| 4431 int hash; | 4468 int hash; |
| 4432 int attempts = 0; | 4469 int attempts = 0; |
| 4433 do { | 4470 do { |
| 4434 hash = isolate()->random_number_generator()->NextInt() & Name::kHashBitMask; | 4471 hash = isolate()->random_number_generator()->NextInt() & Name::kHashBitMask; |
| 4435 attempts++; | 4472 attempts++; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 4453 case NAME##_TYPE: \ | 4490 case NAME##_TYPE: \ |
| 4454 map = name##_map(); \ | 4491 map = name##_map(); \ |
| 4455 break; | 4492 break; |
| 4456 STRUCT_LIST(MAKE_CASE) | 4493 STRUCT_LIST(MAKE_CASE) |
| 4457 #undef MAKE_CASE | 4494 #undef MAKE_CASE |
| 4458 default: | 4495 default: |
| 4459 UNREACHABLE(); | 4496 UNREACHABLE(); |
| 4460 return exception(); | 4497 return exception(); |
| 4461 } | 4498 } |
| 4462 int size = map->instance_size(); | 4499 int size = map->instance_size(); |
| 4463 AllocationSpace space = SelectSpace(size, TENURED); | 4500 AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, TENURED); |
| 4464 Struct* result; | 4501 Struct* result; |
| 4465 { | 4502 { |
| 4466 AllocationResult allocation = Allocate(map, space); | 4503 AllocationResult allocation = Allocate(map, space); |
| 4467 if (!allocation.To(&result)) return allocation; | 4504 if (!allocation.To(&result)) return allocation; |
| 4468 } | 4505 } |
| 4469 result->InitializeBody(size); | 4506 result->InitializeBody(size); |
| 4470 return result; | 4507 return result; |
| 4471 } | 4508 } |
| 4472 | 4509 |
| 4473 | 4510 |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4718 | 4755 |
| 4719 PrintF("\n"); | 4756 PrintF("\n"); |
| 4720 PrintF("Number of handles : %d\n", HandleScope::NumberOfHandles(isolate_)); | 4757 PrintF("Number of handles : %d\n", HandleScope::NumberOfHandles(isolate_)); |
| 4721 isolate_->global_handles()->PrintStats(); | 4758 isolate_->global_handles()->PrintStats(); |
| 4722 PrintF("\n"); | 4759 PrintF("\n"); |
| 4723 | 4760 |
| 4724 PrintF("Heap statistics : "); | 4761 PrintF("Heap statistics : "); |
| 4725 isolate_->memory_allocator()->ReportStatistics(); | 4762 isolate_->memory_allocator()->ReportStatistics(); |
| 4726 PrintF("To space : "); | 4763 PrintF("To space : "); |
| 4727 new_space_.ReportStatistics(); | 4764 new_space_.ReportStatistics(); |
| 4728 PrintF("Old space : "); | 4765 PrintF("Old pointer space : "); |
| 4729 old_space_->ReportStatistics(); | 4766 old_pointer_space_->ReportStatistics(); |
| 4767 PrintF("Old data space : "); |
| 4768 old_data_space_->ReportStatistics(); |
| 4730 PrintF("Code space : "); | 4769 PrintF("Code space : "); |
| 4731 code_space_->ReportStatistics(); | 4770 code_space_->ReportStatistics(); |
| 4732 PrintF("Map space : "); | 4771 PrintF("Map space : "); |
| 4733 map_space_->ReportStatistics(); | 4772 map_space_->ReportStatistics(); |
| 4734 PrintF("Cell space : "); | 4773 PrintF("Cell space : "); |
| 4735 cell_space_->ReportStatistics(); | 4774 cell_space_->ReportStatistics(); |
| 4736 PrintF("Large object space : "); | 4775 PrintF("Large object space : "); |
| 4737 lo_space_->ReportStatistics(); | 4776 lo_space_->ReportStatistics(); |
| 4738 PrintF(">>>>>> ========================================= >>>>>>\n"); | 4777 PrintF(">>>>>> ========================================= >>>>>>\n"); |
| 4739 } | 4778 } |
| 4740 | 4779 |
| 4741 #endif // DEBUG | 4780 #endif // DEBUG |
| 4742 | 4781 |
| 4743 bool Heap::Contains(HeapObject* value) { return Contains(value->address()); } | 4782 bool Heap::Contains(HeapObject* value) { return Contains(value->address()); } |
| 4744 | 4783 |
| 4745 | 4784 |
| 4746 bool Heap::Contains(Address addr) { | 4785 bool Heap::Contains(Address addr) { |
| 4747 if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; | 4786 if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; |
| 4748 return HasBeenSetUp() && | 4787 return HasBeenSetUp() && |
| 4749 (new_space_.ToSpaceContains(addr) || old_space_->Contains(addr) || | 4788 (new_space_.ToSpaceContains(addr) || |
| 4750 code_space_->Contains(addr) || map_space_->Contains(addr) || | 4789 old_pointer_space_->Contains(addr) || |
| 4751 cell_space_->Contains(addr) || lo_space_->SlowContains(addr)); | 4790 old_data_space_->Contains(addr) || code_space_->Contains(addr) || |
| 4791 map_space_->Contains(addr) || cell_space_->Contains(addr) || |
| 4792 lo_space_->SlowContains(addr)); |
| 4752 } | 4793 } |
| 4753 | 4794 |
| 4754 | 4795 |
| 4755 bool Heap::InSpace(HeapObject* value, AllocationSpace space) { | 4796 bool Heap::InSpace(HeapObject* value, AllocationSpace space) { |
| 4756 return InSpace(value->address(), space); | 4797 return InSpace(value->address(), space); |
| 4757 } | 4798 } |
| 4758 | 4799 |
| 4759 | 4800 |
| 4760 bool Heap::InSpace(Address addr, AllocationSpace space) { | 4801 bool Heap::InSpace(Address addr, AllocationSpace space) { |
| 4761 if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; | 4802 if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; |
| 4762 if (!HasBeenSetUp()) return false; | 4803 if (!HasBeenSetUp()) return false; |
| 4763 | 4804 |
| 4764 switch (space) { | 4805 switch (space) { |
| 4765 case NEW_SPACE: | 4806 case NEW_SPACE: |
| 4766 return new_space_.ToSpaceContains(addr); | 4807 return new_space_.ToSpaceContains(addr); |
| 4767 case OLD_SPACE: | 4808 case OLD_POINTER_SPACE: |
| 4768 return old_space_->Contains(addr); | 4809 return old_pointer_space_->Contains(addr); |
| 4810 case OLD_DATA_SPACE: |
| 4811 return old_data_space_->Contains(addr); |
| 4769 case CODE_SPACE: | 4812 case CODE_SPACE: |
| 4770 return code_space_->Contains(addr); | 4813 return code_space_->Contains(addr); |
| 4771 case MAP_SPACE: | 4814 case MAP_SPACE: |
| 4772 return map_space_->Contains(addr); | 4815 return map_space_->Contains(addr); |
| 4773 case CELL_SPACE: | 4816 case CELL_SPACE: |
| 4774 return cell_space_->Contains(addr); | 4817 return cell_space_->Contains(addr); |
| 4775 case LO_SPACE: | 4818 case LO_SPACE: |
| 4776 return lo_space_->SlowContains(addr); | 4819 return lo_space_->SlowContains(addr); |
| 4777 } | 4820 } |
| 4778 UNREACHABLE(); | 4821 UNREACHABLE(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 4806 } | 4849 } |
| 4807 | 4850 |
| 4808 VerifyPointersVisitor visitor; | 4851 VerifyPointersVisitor visitor; |
| 4809 IterateRoots(&visitor, VISIT_ONLY_STRONG); | 4852 IterateRoots(&visitor, VISIT_ONLY_STRONG); |
| 4810 | 4853 |
| 4811 VerifySmisVisitor smis_visitor; | 4854 VerifySmisVisitor smis_visitor; |
| 4812 IterateSmiRoots(&smis_visitor); | 4855 IterateSmiRoots(&smis_visitor); |
| 4813 | 4856 |
| 4814 new_space_.Verify(); | 4857 new_space_.Verify(); |
| 4815 | 4858 |
| 4816 old_space_->Verify(&visitor); | 4859 old_pointer_space_->Verify(&visitor); |
| 4817 map_space_->Verify(&visitor); | 4860 map_space_->Verify(&visitor); |
| 4818 | 4861 |
| 4819 VerifyPointersVisitor no_dirty_regions_visitor; | 4862 VerifyPointersVisitor no_dirty_regions_visitor; |
| 4863 old_data_space_->Verify(&no_dirty_regions_visitor); |
| 4820 code_space_->Verify(&no_dirty_regions_visitor); | 4864 code_space_->Verify(&no_dirty_regions_visitor); |
| 4821 cell_space_->Verify(&no_dirty_regions_visitor); | 4865 cell_space_->Verify(&no_dirty_regions_visitor); |
| 4822 | 4866 |
| 4823 lo_space_->Verify(); | 4867 lo_space_->Verify(); |
| 4824 } | 4868 } |
| 4825 #endif | 4869 #endif |
| 4826 | 4870 |
| 4827 | 4871 |
| 4828 void Heap::ZapFromSpace() { | 4872 void Heap::ZapFromSpace() { |
| 4829 NewSpacePageIterator it(new_space_.FromSpaceStart(), | 4873 NewSpacePageIterator it(new_space_.FromSpaceStart(), |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5126 | 5170 |
| 5127 | 5171 |
| 5128 bool Heap::ConfigureHeapDefault() { return ConfigureHeap(0, 0, 0, 0); } | 5172 bool Heap::ConfigureHeapDefault() { return ConfigureHeap(0, 0, 0, 0); } |
| 5129 | 5173 |
| 5130 | 5174 |
| 5131 void Heap::RecordStats(HeapStats* stats, bool take_snapshot) { | 5175 void Heap::RecordStats(HeapStats* stats, bool take_snapshot) { |
| 5132 *stats->start_marker = HeapStats::kStartMarker; | 5176 *stats->start_marker = HeapStats::kStartMarker; |
| 5133 *stats->end_marker = HeapStats::kEndMarker; | 5177 *stats->end_marker = HeapStats::kEndMarker; |
| 5134 *stats->new_space_size = new_space_.SizeAsInt(); | 5178 *stats->new_space_size = new_space_.SizeAsInt(); |
| 5135 *stats->new_space_capacity = static_cast<int>(new_space_.Capacity()); | 5179 *stats->new_space_capacity = static_cast<int>(new_space_.Capacity()); |
| 5136 *stats->old_space_size = old_space_->SizeOfObjects(); | 5180 *stats->old_pointer_space_size = old_pointer_space_->SizeOfObjects(); |
| 5137 *stats->old_space_capacity = old_space_->Capacity(); | 5181 *stats->old_pointer_space_capacity = old_pointer_space_->Capacity(); |
| 5182 *stats->old_data_space_size = old_data_space_->SizeOfObjects(); |
| 5183 *stats->old_data_space_capacity = old_data_space_->Capacity(); |
| 5138 *stats->code_space_size = code_space_->SizeOfObjects(); | 5184 *stats->code_space_size = code_space_->SizeOfObjects(); |
| 5139 *stats->code_space_capacity = code_space_->Capacity(); | 5185 *stats->code_space_capacity = code_space_->Capacity(); |
| 5140 *stats->map_space_size = map_space_->SizeOfObjects(); | 5186 *stats->map_space_size = map_space_->SizeOfObjects(); |
| 5141 *stats->map_space_capacity = map_space_->Capacity(); | 5187 *stats->map_space_capacity = map_space_->Capacity(); |
| 5142 *stats->cell_space_size = cell_space_->SizeOfObjects(); | 5188 *stats->cell_space_size = cell_space_->SizeOfObjects(); |
| 5143 *stats->cell_space_capacity = cell_space_->Capacity(); | 5189 *stats->cell_space_capacity = cell_space_->Capacity(); |
| 5144 *stats->lo_space_size = lo_space_->Size(); | 5190 *stats->lo_space_size = lo_space_->Size(); |
| 5145 isolate_->global_handles()->RecordStats(stats); | 5191 isolate_->global_handles()->RecordStats(stats); |
| 5146 *stats->memory_allocator_size = isolate()->memory_allocator()->Size(); | 5192 *stats->memory_allocator_size = isolate()->memory_allocator()->Size(); |
| 5147 *stats->memory_allocator_capacity = | 5193 *stats->memory_allocator_capacity = |
| 5148 isolate()->memory_allocator()->Size() + | 5194 isolate()->memory_allocator()->Size() + |
| 5149 isolate()->memory_allocator()->Available(); | 5195 isolate()->memory_allocator()->Available(); |
| 5150 *stats->os_error = base::OS::GetLastError(); | 5196 *stats->os_error = base::OS::GetLastError(); |
| 5151 isolate()->memory_allocator()->Available(); | 5197 isolate()->memory_allocator()->Available(); |
| 5152 if (take_snapshot) { | 5198 if (take_snapshot) { |
| 5153 HeapIterator iterator(this); | 5199 HeapIterator iterator(this); |
| 5154 for (HeapObject* obj = iterator.next(); obj != NULL; | 5200 for (HeapObject* obj = iterator.next(); obj != NULL; |
| 5155 obj = iterator.next()) { | 5201 obj = iterator.next()) { |
| 5156 InstanceType type = obj->map()->instance_type(); | 5202 InstanceType type = obj->map()->instance_type(); |
| 5157 DCHECK(0 <= type && type <= LAST_TYPE); | 5203 DCHECK(0 <= type && type <= LAST_TYPE); |
| 5158 stats->objects_per_type[type]++; | 5204 stats->objects_per_type[type]++; |
| 5159 stats->size_per_type[type] += obj->Size(); | 5205 stats->size_per_type[type] += obj->Size(); |
| 5160 } | 5206 } |
| 5161 } | 5207 } |
| 5162 } | 5208 } |
| 5163 | 5209 |
| 5164 | 5210 |
| 5165 intptr_t Heap::PromotedSpaceSizeOfObjects() { | 5211 intptr_t Heap::PromotedSpaceSizeOfObjects() { |
| 5166 return old_space_->SizeOfObjects() + code_space_->SizeOfObjects() + | 5212 return old_pointer_space_->SizeOfObjects() + |
| 5213 old_data_space_->SizeOfObjects() + code_space_->SizeOfObjects() + |
| 5167 map_space_->SizeOfObjects() + cell_space_->SizeOfObjects() + | 5214 map_space_->SizeOfObjects() + cell_space_->SizeOfObjects() + |
| 5168 lo_space_->SizeOfObjects(); | 5215 lo_space_->SizeOfObjects(); |
| 5169 } | 5216 } |
| 5170 | 5217 |
| 5171 | 5218 |
| 5172 int64_t Heap::PromotedExternalMemorySize() { | 5219 int64_t Heap::PromotedExternalMemorySize() { |
| 5173 if (amount_of_external_allocated_memory_ <= | 5220 if (amount_of_external_allocated_memory_ <= |
| 5174 amount_of_external_allocated_memory_at_last_global_gc_) | 5221 amount_of_external_allocated_memory_at_last_global_gc_) |
| 5175 return 0; | 5222 return 0; |
| 5176 return amount_of_external_allocated_memory_ - | 5223 return amount_of_external_allocated_memory_ - |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5280 // Set up memory allocator. | 5327 // Set up memory allocator. |
| 5281 if (!isolate_->memory_allocator()->SetUp(MaxReserved(), MaxExecutableSize())) | 5328 if (!isolate_->memory_allocator()->SetUp(MaxReserved(), MaxExecutableSize())) |
| 5282 return false; | 5329 return false; |
| 5283 | 5330 |
| 5284 // Set up new space. | 5331 // Set up new space. |
| 5285 if (!new_space_.SetUp(reserved_semispace_size_, max_semi_space_size_)) { | 5332 if (!new_space_.SetUp(reserved_semispace_size_, max_semi_space_size_)) { |
| 5286 return false; | 5333 return false; |
| 5287 } | 5334 } |
| 5288 new_space_top_after_last_gc_ = new_space()->top(); | 5335 new_space_top_after_last_gc_ = new_space()->top(); |
| 5289 | 5336 |
| 5290 // Initialize old space. | 5337 // Initialize old pointer space. |
| 5291 old_space_ = | 5338 old_pointer_space_ = new OldSpace(this, max_old_generation_size_, |
| 5292 new OldSpace(this, max_old_generation_size_, OLD_SPACE, NOT_EXECUTABLE); | 5339 OLD_POINTER_SPACE, NOT_EXECUTABLE); |
| 5293 if (old_space_ == NULL) return false; | 5340 if (old_pointer_space_ == NULL) return false; |
| 5294 if (!old_space_->SetUp()) return false; | 5341 if (!old_pointer_space_->SetUp()) return false; |
| 5342 |
| 5343 // Initialize old data space. |
| 5344 old_data_space_ = new OldSpace(this, max_old_generation_size_, OLD_DATA_SPACE, |
| 5345 NOT_EXECUTABLE); |
| 5346 if (old_data_space_ == NULL) return false; |
| 5347 if (!old_data_space_->SetUp()) return false; |
| 5295 | 5348 |
| 5296 if (!isolate_->code_range()->SetUp(code_range_size_)) return false; | 5349 if (!isolate_->code_range()->SetUp(code_range_size_)) return false; |
| 5297 | 5350 |
| 5298 // Initialize the code space, set its maximum capacity to the old | 5351 // Initialize the code space, set its maximum capacity to the old |
| 5299 // generation size. It needs executable memory. | 5352 // generation size. It needs executable memory. |
| 5300 code_space_ = | 5353 code_space_ = |
| 5301 new OldSpace(this, max_old_generation_size_, CODE_SPACE, EXECUTABLE); | 5354 new OldSpace(this, max_old_generation_size_, CODE_SPACE, EXECUTABLE); |
| 5302 if (code_space_ == NULL) return false; | 5355 if (code_space_ == NULL) return false; |
| 5303 if (!code_space_->SetUp()) return false; | 5356 if (!code_space_->SetUp()) return false; |
| 5304 | 5357 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5407 PrintF("total_sweeping_time=%.1f ", tracer_.cumulative_sweeping_duration()); | 5460 PrintF("total_sweeping_time=%.1f ", tracer_.cumulative_sweeping_duration()); |
| 5408 PrintF("\n\n"); | 5461 PrintF("\n\n"); |
| 5409 } | 5462 } |
| 5410 | 5463 |
| 5411 if (FLAG_print_max_heap_committed) { | 5464 if (FLAG_print_max_heap_committed) { |
| 5412 PrintF("\n"); | 5465 PrintF("\n"); |
| 5413 PrintF("maximum_committed_by_heap=%" V8_PTR_PREFIX "d ", | 5466 PrintF("maximum_committed_by_heap=%" V8_PTR_PREFIX "d ", |
| 5414 MaximumCommittedMemory()); | 5467 MaximumCommittedMemory()); |
| 5415 PrintF("maximum_committed_by_new_space=%" V8_PTR_PREFIX "d ", | 5468 PrintF("maximum_committed_by_new_space=%" V8_PTR_PREFIX "d ", |
| 5416 new_space_.MaximumCommittedMemory()); | 5469 new_space_.MaximumCommittedMemory()); |
| 5417 PrintF("maximum_committed_by_old_space=%" V8_PTR_PREFIX "d ", | 5470 PrintF("maximum_committed_by_old_pointer_space=%" V8_PTR_PREFIX "d ", |
| 5418 old_space_->MaximumCommittedMemory()); | 5471 old_data_space_->MaximumCommittedMemory()); |
| 5472 PrintF("maximum_committed_by_old_data_space=%" V8_PTR_PREFIX "d ", |
| 5473 old_pointer_space_->MaximumCommittedMemory()); |
| 5474 PrintF("maximum_committed_by_old_data_space=%" V8_PTR_PREFIX "d ", |
| 5475 old_pointer_space_->MaximumCommittedMemory()); |
| 5419 PrintF("maximum_committed_by_code_space=%" V8_PTR_PREFIX "d ", | 5476 PrintF("maximum_committed_by_code_space=%" V8_PTR_PREFIX "d ", |
| 5420 code_space_->MaximumCommittedMemory()); | 5477 code_space_->MaximumCommittedMemory()); |
| 5421 PrintF("maximum_committed_by_map_space=%" V8_PTR_PREFIX "d ", | 5478 PrintF("maximum_committed_by_map_space=%" V8_PTR_PREFIX "d ", |
| 5422 map_space_->MaximumCommittedMemory()); | 5479 map_space_->MaximumCommittedMemory()); |
| 5423 PrintF("maximum_committed_by_cell_space=%" V8_PTR_PREFIX "d ", | 5480 PrintF("maximum_committed_by_cell_space=%" V8_PTR_PREFIX "d ", |
| 5424 cell_space_->MaximumCommittedMemory()); | 5481 cell_space_->MaximumCommittedMemory()); |
| 5425 PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ", | 5482 PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ", |
| 5426 lo_space_->MaximumCommittedMemory()); | 5483 lo_space_->MaximumCommittedMemory()); |
| 5427 PrintF("\n\n"); | 5484 PrintF("\n\n"); |
| 5428 } | 5485 } |
| 5429 | 5486 |
| 5430 if (FLAG_verify_predictable) { | 5487 if (FLAG_verify_predictable) { |
| 5431 PrintAlloctionsHash(); | 5488 PrintAlloctionsHash(); |
| 5432 } | 5489 } |
| 5433 | 5490 |
| 5434 TearDownArrayBuffers(); | 5491 TearDownArrayBuffers(); |
| 5435 | 5492 |
| 5436 isolate_->global_handles()->TearDown(); | 5493 isolate_->global_handles()->TearDown(); |
| 5437 | 5494 |
| 5438 external_string_table_.TearDown(); | 5495 external_string_table_.TearDown(); |
| 5439 | 5496 |
| 5440 mark_compact_collector()->TearDown(); | 5497 mark_compact_collector()->TearDown(); |
| 5441 | 5498 |
| 5442 new_space_.TearDown(); | 5499 new_space_.TearDown(); |
| 5443 | 5500 |
| 5444 if (old_space_ != NULL) { | 5501 if (old_pointer_space_ != NULL) { |
| 5445 old_space_->TearDown(); | 5502 old_pointer_space_->TearDown(); |
| 5446 delete old_space_; | 5503 delete old_pointer_space_; |
| 5447 old_space_ = NULL; | 5504 old_pointer_space_ = NULL; |
| 5505 } |
| 5506 |
| 5507 if (old_data_space_ != NULL) { |
| 5508 old_data_space_->TearDown(); |
| 5509 delete old_data_space_; |
| 5510 old_data_space_ = NULL; |
| 5448 } | 5511 } |
| 5449 | 5512 |
| 5450 if (code_space_ != NULL) { | 5513 if (code_space_ != NULL) { |
| 5451 code_space_->TearDown(); | 5514 code_space_->TearDown(); |
| 5452 delete code_space_; | 5515 delete code_space_; |
| 5453 code_space_ = NULL; | 5516 code_space_ = NULL; |
| 5454 } | 5517 } |
| 5455 | 5518 |
| 5456 if (map_space_ != NULL) { | 5519 if (map_space_ != NULL) { |
| 5457 map_space_->TearDown(); | 5520 map_space_->TearDown(); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5573 isolate_->handle_scope_implementer()->Iterate(&v); | 5636 isolate_->handle_scope_implementer()->Iterate(&v); |
| 5574 } | 5637 } |
| 5575 | 5638 |
| 5576 #endif | 5639 #endif |
| 5577 | 5640 |
| 5578 | 5641 |
| 5579 Space* AllSpaces::next() { | 5642 Space* AllSpaces::next() { |
| 5580 switch (counter_++) { | 5643 switch (counter_++) { |
| 5581 case NEW_SPACE: | 5644 case NEW_SPACE: |
| 5582 return heap_->new_space(); | 5645 return heap_->new_space(); |
| 5583 case OLD_SPACE: | 5646 case OLD_POINTER_SPACE: |
| 5584 return heap_->old_space(); | 5647 return heap_->old_pointer_space(); |
| 5648 case OLD_DATA_SPACE: |
| 5649 return heap_->old_data_space(); |
| 5585 case CODE_SPACE: | 5650 case CODE_SPACE: |
| 5586 return heap_->code_space(); | 5651 return heap_->code_space(); |
| 5587 case MAP_SPACE: | 5652 case MAP_SPACE: |
| 5588 return heap_->map_space(); | 5653 return heap_->map_space(); |
| 5589 case CELL_SPACE: | 5654 case CELL_SPACE: |
| 5590 return heap_->cell_space(); | 5655 return heap_->cell_space(); |
| 5591 case LO_SPACE: | 5656 case LO_SPACE: |
| 5592 return heap_->lo_space(); | 5657 return heap_->lo_space(); |
| 5593 default: | 5658 default: |
| 5594 return NULL; | 5659 return NULL; |
| 5595 } | 5660 } |
| 5596 } | 5661 } |
| 5597 | 5662 |
| 5598 | 5663 |
| 5599 PagedSpace* PagedSpaces::next() { | 5664 PagedSpace* PagedSpaces::next() { |
| 5600 switch (counter_++) { | 5665 switch (counter_++) { |
| 5601 case OLD_SPACE: | 5666 case OLD_POINTER_SPACE: |
| 5602 return heap_->old_space(); | 5667 return heap_->old_pointer_space(); |
| 5668 case OLD_DATA_SPACE: |
| 5669 return heap_->old_data_space(); |
| 5603 case CODE_SPACE: | 5670 case CODE_SPACE: |
| 5604 return heap_->code_space(); | 5671 return heap_->code_space(); |
| 5605 case MAP_SPACE: | 5672 case MAP_SPACE: |
| 5606 return heap_->map_space(); | 5673 return heap_->map_space(); |
| 5607 case CELL_SPACE: | 5674 case CELL_SPACE: |
| 5608 return heap_->cell_space(); | 5675 return heap_->cell_space(); |
| 5609 default: | 5676 default: |
| 5610 return NULL; | 5677 return NULL; |
| 5611 } | 5678 } |
| 5612 } | 5679 } |
| 5613 | 5680 |
| 5614 | 5681 |
| 5615 OldSpace* OldSpaces::next() { | 5682 OldSpace* OldSpaces::next() { |
| 5616 switch (counter_++) { | 5683 switch (counter_++) { |
| 5617 case OLD_SPACE: | 5684 case OLD_POINTER_SPACE: |
| 5618 return heap_->old_space(); | 5685 return heap_->old_pointer_space(); |
| 5686 case OLD_DATA_SPACE: |
| 5687 return heap_->old_data_space(); |
| 5619 case CODE_SPACE: | 5688 case CODE_SPACE: |
| 5620 return heap_->code_space(); | 5689 return heap_->code_space(); |
| 5621 default: | 5690 default: |
| 5622 return NULL; | 5691 return NULL; |
| 5623 } | 5692 } |
| 5624 } | 5693 } |
| 5625 | 5694 |
| 5626 | 5695 |
| 5627 SpaceIterator::SpaceIterator(Heap* heap) | 5696 SpaceIterator::SpaceIterator(Heap* heap) |
| 5628 : heap_(heap), | 5697 : heap_(heap), |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5667 | 5736 |
| 5668 | 5737 |
| 5669 // Create an iterator for the space to iterate. | 5738 // Create an iterator for the space to iterate. |
| 5670 ObjectIterator* SpaceIterator::CreateIterator() { | 5739 ObjectIterator* SpaceIterator::CreateIterator() { |
| 5671 DCHECK(iterator_ == NULL); | 5740 DCHECK(iterator_ == NULL); |
| 5672 | 5741 |
| 5673 switch (current_space_) { | 5742 switch (current_space_) { |
| 5674 case NEW_SPACE: | 5743 case NEW_SPACE: |
| 5675 iterator_ = new SemiSpaceIterator(heap_->new_space(), size_func_); | 5744 iterator_ = new SemiSpaceIterator(heap_->new_space(), size_func_); |
| 5676 break; | 5745 break; |
| 5677 case OLD_SPACE: | 5746 case OLD_POINTER_SPACE: |
| 5678 iterator_ = new HeapObjectIterator(heap_->old_space(), size_func_); | 5747 iterator_ = |
| 5748 new HeapObjectIterator(heap_->old_pointer_space(), size_func_); |
| 5749 break; |
| 5750 case OLD_DATA_SPACE: |
| 5751 iterator_ = new HeapObjectIterator(heap_->old_data_space(), size_func_); |
| 5679 break; | 5752 break; |
| 5680 case CODE_SPACE: | 5753 case CODE_SPACE: |
| 5681 iterator_ = new HeapObjectIterator(heap_->code_space(), size_func_); | 5754 iterator_ = new HeapObjectIterator(heap_->code_space(), size_func_); |
| 5682 break; | 5755 break; |
| 5683 case MAP_SPACE: | 5756 case MAP_SPACE: |
| 5684 iterator_ = new HeapObjectIterator(heap_->map_space(), size_func_); | 5757 iterator_ = new HeapObjectIterator(heap_->map_space(), size_func_); |
| 5685 break; | 5758 break; |
| 5686 case CELL_SPACE: | 5759 case CELL_SPACE: |
| 5687 iterator_ = new HeapObjectIterator(heap_->cell_space(), size_func_); | 5760 iterator_ = new HeapObjectIterator(heap_->cell_space(), size_func_); |
| 5688 break; | 5761 break; |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6310 static_cast<int>(object_sizes_last_time_[index])); | 6383 static_cast<int>(object_sizes_last_time_[index])); |
| 6311 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6384 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 6312 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6385 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 6313 | 6386 |
| 6314 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6387 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 6315 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6388 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 6316 ClearObjectStats(); | 6389 ClearObjectStats(); |
| 6317 } | 6390 } |
| 6318 } | 6391 } |
| 6319 } // namespace v8::internal | 6392 } // namespace v8::internal |
| OLD | NEW |