| 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_pointer_space_(NULL), | 87       old_space_(NULL), | 
| 88       old_data_space_(NULL), |  | 
| 89       code_space_(NULL), | 88       code_space_(NULL), | 
| 90       map_space_(NULL), | 89       map_space_(NULL), | 
| 91       cell_space_(NULL), | 90       cell_space_(NULL), | 
| 92       property_cell_space_(NULL), | 91       property_cell_space_(NULL), | 
| 93       lo_space_(NULL), | 92       lo_space_(NULL), | 
| 94       gc_state_(NOT_IN_GC), | 93       gc_state_(NOT_IN_GC), | 
| 95       gc_post_processing_depth_(0), | 94       gc_post_processing_depth_(0), | 
| 96       allocations_count_(0), | 95       allocations_count_(0), | 
| 97       raw_allocations_hash_(0), | 96       raw_allocations_hash_(0), | 
| 98       dump_allocations_hash_countdown_(FLAG_dump_allocations_digest_at_alloc), | 97       dump_allocations_hash_countdown_(FLAG_dump_allocations_digest_at_alloc), | 
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 166   // minidump even if there are no real unmapped pages. | 165   // minidump even if there are no real unmapped pages. | 
| 167   RememberUnmappedPage(NULL, false); | 166   RememberUnmappedPage(NULL, false); | 
| 168 | 167 | 
| 169   ClearObjectStats(true); | 168   ClearObjectStats(true); | 
| 170 } | 169 } | 
| 171 | 170 | 
| 172 | 171 | 
| 173 intptr_t Heap::Capacity() { | 172 intptr_t Heap::Capacity() { | 
| 174   if (!HasBeenSetUp()) return 0; | 173   if (!HasBeenSetUp()) return 0; | 
| 175 | 174 | 
| 176   return new_space_.Capacity() + old_pointer_space_->Capacity() + | 175   return new_space_.Capacity() + old_space_->Capacity() + | 
| 177          old_data_space_->Capacity() + code_space_->Capacity() + | 176          code_space_->Capacity() + map_space_->Capacity() + | 
| 178          map_space_->Capacity() + cell_space_->Capacity() + | 177          cell_space_->Capacity() + property_cell_space_->Capacity(); | 
| 179          property_cell_space_->Capacity(); |  | 
| 180 } | 178 } | 
| 181 | 179 | 
| 182 | 180 | 
| 183 intptr_t Heap::CommittedOldGenerationMemory() { | 181 intptr_t Heap::CommittedOldGenerationMemory() { | 
| 184   if (!HasBeenSetUp()) return 0; | 182   if (!HasBeenSetUp()) return 0; | 
| 185 | 183 | 
| 186   return old_pointer_space_->CommittedMemory() + | 184   return old_space_->CommittedMemory() + code_space_->CommittedMemory() + | 
| 187          old_data_space_->CommittedMemory() + code_space_->CommittedMemory() + |  | 
| 188          map_space_->CommittedMemory() + cell_space_->CommittedMemory() + | 185          map_space_->CommittedMemory() + cell_space_->CommittedMemory() + | 
| 189          property_cell_space_->CommittedMemory() + lo_space_->Size(); | 186          property_cell_space_->CommittedMemory() + lo_space_->Size(); | 
| 190 } | 187 } | 
| 191 | 188 | 
| 192 | 189 | 
| 193 intptr_t Heap::CommittedMemory() { | 190 intptr_t Heap::CommittedMemory() { | 
| 194   if (!HasBeenSetUp()) return 0; | 191   if (!HasBeenSetUp()) return 0; | 
| 195 | 192 | 
| 196   return new_space_.CommittedMemory() + CommittedOldGenerationMemory(); | 193   return new_space_.CommittedMemory() + CommittedOldGenerationMemory(); | 
| 197 } | 194 } | 
| 198 | 195 | 
| 199 | 196 | 
| 200 size_t Heap::CommittedPhysicalMemory() { | 197 size_t Heap::CommittedPhysicalMemory() { | 
| 201   if (!HasBeenSetUp()) return 0; | 198   if (!HasBeenSetUp()) return 0; | 
| 202 | 199 | 
| 203   return new_space_.CommittedPhysicalMemory() + | 200   return new_space_.CommittedPhysicalMemory() + | 
| 204          old_pointer_space_->CommittedPhysicalMemory() + | 201          old_space_->CommittedPhysicalMemory() + | 
| 205          old_data_space_->CommittedPhysicalMemory() + |  | 
| 206          code_space_->CommittedPhysicalMemory() + | 202          code_space_->CommittedPhysicalMemory() + | 
| 207          map_space_->CommittedPhysicalMemory() + | 203          map_space_->CommittedPhysicalMemory() + | 
| 208          cell_space_->CommittedPhysicalMemory() + | 204          cell_space_->CommittedPhysicalMemory() + | 
| 209          property_cell_space_->CommittedPhysicalMemory() + | 205          property_cell_space_->CommittedPhysicalMemory() + | 
| 210          lo_space_->CommittedPhysicalMemory(); | 206          lo_space_->CommittedPhysicalMemory(); | 
| 211 } | 207 } | 
| 212 | 208 | 
| 213 | 209 | 
| 214 intptr_t Heap::CommittedMemoryExecutable() { | 210 intptr_t Heap::CommittedMemoryExecutable() { | 
| 215   if (!HasBeenSetUp()) return 0; | 211   if (!HasBeenSetUp()) return 0; | 
| 216 | 212 | 
| 217   return isolate()->memory_allocator()->SizeExecutable(); | 213   return isolate()->memory_allocator()->SizeExecutable(); | 
| 218 } | 214 } | 
| 219 | 215 | 
| 220 | 216 | 
| 221 void Heap::UpdateMaximumCommitted() { | 217 void Heap::UpdateMaximumCommitted() { | 
| 222   if (!HasBeenSetUp()) return; | 218   if (!HasBeenSetUp()) return; | 
| 223 | 219 | 
| 224   intptr_t current_committed_memory = CommittedMemory(); | 220   intptr_t current_committed_memory = CommittedMemory(); | 
| 225   if (current_committed_memory > maximum_committed_) { | 221   if (current_committed_memory > maximum_committed_) { | 
| 226     maximum_committed_ = current_committed_memory; | 222     maximum_committed_ = current_committed_memory; | 
| 227   } | 223   } | 
| 228 } | 224 } | 
| 229 | 225 | 
| 230 | 226 | 
| 231 intptr_t Heap::Available() { | 227 intptr_t Heap::Available() { | 
| 232   if (!HasBeenSetUp()) return 0; | 228   if (!HasBeenSetUp()) return 0; | 
| 233 | 229 | 
| 234   return new_space_.Available() + old_pointer_space_->Available() + | 230   return new_space_.Available() + old_space_->Available() + | 
| 235          old_data_space_->Available() + code_space_->Available() + | 231          code_space_->Available() + map_space_->Available() + | 
| 236          map_space_->Available() + cell_space_->Available() + | 232          cell_space_->Available() + property_cell_space_->Available(); | 
| 237          property_cell_space_->Available(); |  | 
| 238 } | 233 } | 
| 239 | 234 | 
| 240 | 235 | 
| 241 bool Heap::HasBeenSetUp() { | 236 bool Heap::HasBeenSetUp() { | 
| 242   return old_pointer_space_ != NULL && old_data_space_ != NULL && | 237   return old_space_ != NULL && code_space_ != NULL && map_space_ != NULL && | 
| 243          code_space_ != NULL && map_space_ != NULL && cell_space_ != NULL && | 238          cell_space_ != NULL && property_cell_space_ != NULL && | 
| 244          property_cell_space_ != NULL && lo_space_ != NULL; | 239          lo_space_ != NULL; | 
| 245 } | 240 } | 
| 246 | 241 | 
| 247 | 242 | 
| 248 int Heap::GcSafeSizeOfOldObject(HeapObject* object) { | 243 int Heap::GcSafeSizeOfOldObject(HeapObject* object) { | 
| 249   if (IntrusiveMarking::IsMarked(object)) { | 244   if (IntrusiveMarking::IsMarked(object)) { | 
| 250     return IntrusiveMarking::SizeOfMarkedObject(object); | 245     return IntrusiveMarking::SizeOfMarkedObject(object); | 
| 251   } | 246   } | 
| 252   return object->SizeFromMap(object->map()); | 247   return object->SizeFromMap(object->map()); | 
| 253 } | 248 } | 
| 254 | 249 | 
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 337            ", available: %6" V8_PTR_PREFIX "d KB\n", | 332            ", available: %6" V8_PTR_PREFIX "d KB\n", | 
| 338            isolate_->memory_allocator()->Size() / KB, | 333            isolate_->memory_allocator()->Size() / KB, | 
| 339            isolate_->memory_allocator()->Available() / KB); | 334            isolate_->memory_allocator()->Available() / KB); | 
| 340   PrintPID("New space,          used: %6" V8_PTR_PREFIX | 335   PrintPID("New space,          used: %6" V8_PTR_PREFIX | 
| 341            "d KB" | 336            "d KB" | 
| 342            ", available: %6" V8_PTR_PREFIX | 337            ", available: %6" V8_PTR_PREFIX | 
| 343            "d KB" | 338            "d KB" | 
| 344            ", committed: %6" V8_PTR_PREFIX "d KB\n", | 339            ", committed: %6" V8_PTR_PREFIX "d KB\n", | 
| 345            new_space_.Size() / KB, new_space_.Available() / KB, | 340            new_space_.Size() / KB, new_space_.Available() / KB, | 
| 346            new_space_.CommittedMemory() / KB); | 341            new_space_.CommittedMemory() / KB); | 
| 347   PrintPID("Old pointers,       used: %6" V8_PTR_PREFIX | 342   PrintPID("Old space,       used: %6" V8_PTR_PREFIX | 
| 348            "d KB" | 343            "d KB" | 
| 349            ", available: %6" V8_PTR_PREFIX | 344            ", available: %6" V8_PTR_PREFIX | 
| 350            "d KB" | 345            "d KB" | 
| 351            ", committed: %6" V8_PTR_PREFIX "d KB\n", | 346            ", committed: %6" V8_PTR_PREFIX "d KB\n", | 
| 352            old_pointer_space_->SizeOfObjects() / KB, | 347            old_space_->SizeOfObjects() / KB, old_space_->Available() / KB, | 
| 353            old_pointer_space_->Available() / KB, | 348            old_space_->CommittedMemory() / KB); | 
| 354            old_pointer_space_->CommittedMemory() / KB); |  | 
| 355   PrintPID("Old data space,     used: %6" V8_PTR_PREFIX |  | 
| 356            "d KB" |  | 
| 357            ", available: %6" V8_PTR_PREFIX |  | 
| 358            "d KB" |  | 
| 359            ", committed: %6" V8_PTR_PREFIX "d KB\n", |  | 
| 360            old_data_space_->SizeOfObjects() / KB, |  | 
| 361            old_data_space_->Available() / KB, |  | 
| 362            old_data_space_->CommittedMemory() / KB); |  | 
| 363   PrintPID("Code space,         used: %6" V8_PTR_PREFIX | 349   PrintPID("Code space,         used: %6" V8_PTR_PREFIX | 
| 364            "d KB" | 350            "d KB" | 
| 365            ", available: %6" V8_PTR_PREFIX | 351            ", available: %6" V8_PTR_PREFIX | 
| 366            "d KB" | 352            "d KB" | 
| 367            ", committed: %6" V8_PTR_PREFIX "d KB\n", | 353            ", committed: %6" V8_PTR_PREFIX "d KB\n", | 
| 368            code_space_->SizeOfObjects() / KB, code_space_->Available() / KB, | 354            code_space_->SizeOfObjects() / KB, code_space_->Available() / KB, | 
| 369            code_space_->CommittedMemory() / KB); | 355            code_space_->CommittedMemory() / KB); | 
| 370   PrintPID("Map space,          used: %6" V8_PTR_PREFIX | 356   PrintPID("Map space,          used: %6" V8_PTR_PREFIX | 
| 371            "d KB" | 357            "d KB" | 
| 372            ", available: %6" V8_PTR_PREFIX | 358            ", available: %6" V8_PTR_PREFIX | 
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 656                          (crankshaft_codegen_bytes_generated_ + | 642                          (crankshaft_codegen_bytes_generated_ + | 
| 657                           full_codegen_bytes_generated_))); | 643                           full_codegen_bytes_generated_))); | 
| 658   } | 644   } | 
| 659 | 645 | 
| 660   if (CommittedMemory() > 0) { | 646   if (CommittedMemory() > 0) { | 
| 661     isolate_->counters()->external_fragmentation_total()->AddSample( | 647     isolate_->counters()->external_fragmentation_total()->AddSample( | 
| 662         static_cast<int>(100 - (SizeOfObjects() * 100.0) / CommittedMemory())); | 648         static_cast<int>(100 - (SizeOfObjects() * 100.0) / CommittedMemory())); | 
| 663 | 649 | 
| 664     isolate_->counters()->heap_fraction_new_space()->AddSample(static_cast<int>( | 650     isolate_->counters()->heap_fraction_new_space()->AddSample(static_cast<int>( | 
| 665         (new_space()->CommittedMemory() * 100.0) / CommittedMemory())); | 651         (new_space()->CommittedMemory() * 100.0) / CommittedMemory())); | 
| 666     isolate_->counters()->heap_fraction_old_pointer_space()->AddSample( | 652     isolate_->counters()->heap_fraction_old_space()->AddSample(static_cast<int>( | 
| 667         static_cast<int>((old_pointer_space()->CommittedMemory() * 100.0) / | 653         (old_space()->CommittedMemory() * 100.0) / CommittedMemory())); | 
| 668                          CommittedMemory())); |  | 
| 669     isolate_->counters()->heap_fraction_old_data_space()->AddSample( |  | 
| 670         static_cast<int>((old_data_space()->CommittedMemory() * 100.0) / |  | 
| 671                          CommittedMemory())); |  | 
| 672     isolate_->counters()->heap_fraction_code_space()->AddSample( | 654     isolate_->counters()->heap_fraction_code_space()->AddSample( | 
| 673         static_cast<int>((code_space()->CommittedMemory() * 100.0) / | 655         static_cast<int>((code_space()->CommittedMemory() * 100.0) / | 
| 674                          CommittedMemory())); | 656                          CommittedMemory())); | 
| 675     isolate_->counters()->heap_fraction_map_space()->AddSample(static_cast<int>( | 657     isolate_->counters()->heap_fraction_map_space()->AddSample(static_cast<int>( | 
| 676         (map_space()->CommittedMemory() * 100.0) / CommittedMemory())); | 658         (map_space()->CommittedMemory() * 100.0) / CommittedMemory())); | 
| 677     isolate_->counters()->heap_fraction_cell_space()->AddSample( | 659     isolate_->counters()->heap_fraction_cell_space()->AddSample( | 
| 678         static_cast<int>((cell_space()->CommittedMemory() * 100.0) / | 660         static_cast<int>((cell_space()->CommittedMemory() * 100.0) / | 
| 679                          CommittedMemory())); | 661                          CommittedMemory())); | 
| 680     isolate_->counters()->heap_fraction_property_cell_space()->AddSample( | 662     isolate_->counters()->heap_fraction_property_cell_space()->AddSample( | 
| 681         static_cast<int>((property_cell_space()->CommittedMemory() * 100.0) / | 663         static_cast<int>((property_cell_space()->CommittedMemory() * 100.0) / | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 714     isolate_->counters()->external_fragmentation_##space()->AddSample( \ | 696     isolate_->counters()->external_fragmentation_##space()->AddSample( \ | 
| 715         static_cast<int>(100 -                                         \ | 697         static_cast<int>(100 -                                         \ | 
| 716                          (space()->SizeOfObjects() * 100.0) /          \ | 698                          (space()->SizeOfObjects() * 100.0) /          \ | 
| 717                              space()->CommittedMemory()));             \ | 699                              space()->CommittedMemory()));             \ | 
| 718   } | 700   } | 
| 719 #define UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(space) \ | 701 #define UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(space) \ | 
| 720   UPDATE_COUNTERS_FOR_SPACE(space)                         \ | 702   UPDATE_COUNTERS_FOR_SPACE(space)                         \ | 
| 721   UPDATE_FRAGMENTATION_FOR_SPACE(space) | 703   UPDATE_FRAGMENTATION_FOR_SPACE(space) | 
| 722 | 704 | 
| 723   UPDATE_COUNTERS_FOR_SPACE(new_space) | 705   UPDATE_COUNTERS_FOR_SPACE(new_space) | 
| 724   UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(old_pointer_space) | 706   UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(old_space) | 
| 725   UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(old_data_space) |  | 
| 726   UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(code_space) | 707   UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(code_space) | 
| 727   UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(map_space) | 708   UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(map_space) | 
| 728   UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(cell_space) | 709   UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(cell_space) | 
| 729   UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(property_cell_space) | 710   UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(property_cell_space) | 
| 730   UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(lo_space) | 711   UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(lo_space) | 
| 731 #undef UPDATE_COUNTERS_FOR_SPACE | 712 #undef UPDATE_COUNTERS_FOR_SPACE | 
| 732 #undef UPDATE_FRAGMENTATION_FOR_SPACE | 713 #undef UPDATE_FRAGMENTATION_FOR_SPACE | 
| 733 #undef UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE | 714 #undef UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE | 
| 734 | 715 | 
| 735 #ifdef DEBUG | 716 #ifdef DEBUG | 
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 793   } | 774   } | 
| 794 } | 775 } | 
| 795 | 776 | 
| 796 | 777 | 
| 797 void Heap::CollectAllGarbage(int flags, const char* gc_reason, | 778 void Heap::CollectAllGarbage(int flags, const char* gc_reason, | 
| 798                              const v8::GCCallbackFlags gc_callback_flags) { | 779                              const v8::GCCallbackFlags gc_callback_flags) { | 
| 799   // Since we are ignoring the return value, the exact choice of space does | 780   // Since we are ignoring the return value, the exact choice of space does | 
| 800   // not matter, so long as we do not specify NEW_SPACE, which would not | 781   // not matter, so long as we do not specify NEW_SPACE, which would not | 
| 801   // cause a full GC. | 782   // cause a full GC. | 
| 802   mark_compact_collector_.SetFlags(flags); | 783   mark_compact_collector_.SetFlags(flags); | 
| 803   CollectGarbage(OLD_POINTER_SPACE, gc_reason, gc_callback_flags); | 784   CollectGarbage(OLD_SPACE, gc_reason, gc_callback_flags); | 
| 804   mark_compact_collector_.SetFlags(kNoGCFlags); | 785   mark_compact_collector_.SetFlags(kNoGCFlags); | 
| 805 } | 786 } | 
| 806 | 787 | 
| 807 | 788 | 
| 808 void Heap::CollectAllAvailableGarbage(const char* gc_reason) { | 789 void Heap::CollectAllAvailableGarbage(const char* gc_reason) { | 
| 809   // Since we are ignoring the return value, the exact choice of space does | 790   // Since we are ignoring the return value, the exact choice of space does | 
| 810   // not matter, so long as we do not specify NEW_SPACE, which would not | 791   // not matter, so long as we do not specify NEW_SPACE, which would not | 
| 811   // cause a full GC. | 792   // cause a full GC. | 
| 812   // Major GC would invoke weak handle callbacks on weakly reachable | 793   // Major GC would invoke weak handle callbacks on weakly reachable | 
| 813   // handles, but won't collect weakly reachable objects until next | 794   // handles, but won't collect weakly reachable objects until next | 
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1376 | 1357 | 
| 1377 | 1358 | 
| 1378 static void VerifyNonPointerSpacePointers(Heap* heap) { | 1359 static void VerifyNonPointerSpacePointers(Heap* heap) { | 
| 1379   // Verify that there are no pointers to new space in spaces where we | 1360   // Verify that there are no pointers to new space in spaces where we | 
| 1380   // do not expect them. | 1361   // do not expect them. | 
| 1381   VerifyNonPointerSpacePointersVisitor v(heap); | 1362   VerifyNonPointerSpacePointersVisitor v(heap); | 
| 1382   HeapObjectIterator code_it(heap->code_space()); | 1363   HeapObjectIterator code_it(heap->code_space()); | 
| 1383   for (HeapObject* object = code_it.Next(); object != NULL; | 1364   for (HeapObject* object = code_it.Next(); object != NULL; | 
| 1384        object = code_it.Next()) | 1365        object = code_it.Next()) | 
| 1385     object->Iterate(&v); | 1366     object->Iterate(&v); | 
| 1386 |  | 
| 1387     HeapObjectIterator data_it(heap->old_data_space()); |  | 
| 1388     for (HeapObject* object = data_it.Next(); object != NULL; |  | 
| 1389          object = data_it.Next()) |  | 
| 1390       object->Iterate(&v); |  | 
| 1391 } | 1367 } | 
| 1392 #endif  // VERIFY_HEAP | 1368 #endif  // VERIFY_HEAP | 
| 1393 | 1369 | 
| 1394 | 1370 | 
| 1395 void Heap::CheckNewSpaceExpansionCriteria() { | 1371 void Heap::CheckNewSpaceExpansionCriteria() { | 
| 1396   if (FLAG_experimental_new_space_growth_heuristic) { | 1372   if (FLAG_experimental_new_space_growth_heuristic) { | 
| 1397     if (new_space_.TotalCapacity() < new_space_.MaximumCapacity() && | 1373     if (new_space_.TotalCapacity() < new_space_.MaximumCapacity() && | 
| 1398         survived_last_scavenge_ * 100 / new_space_.TotalCapacity() >= 10) { | 1374         survived_last_scavenge_ * 100 / new_space_.TotalCapacity() >= 10) { | 
| 1399       // Grow the size of new space if there is room to grow, and more than 10% | 1375       // Grow the size of new space if there is room to grow, and more than 10% | 
| 1400       // have survived the last scavenge. | 1376       // have survived the last scavenge. | 
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2177                                    HeapObject* object, int object_size) { | 2153                                    HeapObject* object, int object_size) { | 
| 2178     Heap* heap = map->GetHeap(); | 2154     Heap* heap = map->GetHeap(); | 
| 2179 | 2155 | 
| 2180     int allocation_size = object_size; | 2156     int allocation_size = object_size; | 
| 2181     if (alignment != kObjectAlignment) { | 2157     if (alignment != kObjectAlignment) { | 
| 2182       DCHECK(alignment == kDoubleAlignment); | 2158       DCHECK(alignment == kDoubleAlignment); | 
| 2183       allocation_size += kPointerSize; | 2159       allocation_size += kPointerSize; | 
| 2184     } | 2160     } | 
| 2185 | 2161 | 
| 2186     AllocationResult allocation; | 2162     AllocationResult allocation; | 
| 2187     if (object_contents == DATA_OBJECT) { | 2163     allocation = heap->old_space()->AllocateRaw(allocation_size); | 
| 2188       DCHECK(heap->AllowedToBeMigrated(object, OLD_DATA_SPACE)); |  | 
| 2189       allocation = heap->old_data_space()->AllocateRaw(allocation_size); |  | 
| 2190     } else { |  | 
| 2191       DCHECK(heap->AllowedToBeMigrated(object, OLD_POINTER_SPACE)); |  | 
| 2192       allocation = heap->old_pointer_space()->AllocateRaw(allocation_size); |  | 
| 2193     } |  | 
| 2194 | 2164 | 
| 2195     HeapObject* target = NULL;  // Initialization to please compiler. | 2165     HeapObject* target = NULL;  // Initialization to please compiler. | 
| 2196     if (allocation.To(&target)) { | 2166     if (allocation.To(&target)) { | 
| 2197       if (alignment != kObjectAlignment) { | 2167       if (alignment != kObjectAlignment) { | 
| 2198         target = EnsureDoubleAligned(heap, target, allocation_size); | 2168         target = EnsureDoubleAligned(heap, target, allocation_size); | 
| 2199       } | 2169       } | 
| 2200       MigrateObject(heap, object, target, object_size); | 2170       MigrateObject(heap, object, target, object_size); | 
| 2201 | 2171 | 
| 2202       // Update slot to new target. | 2172       // Update slot to new target. | 
| 2203       *slot = target; | 2173       *slot = target; | 
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2599   } | 2569   } | 
| 2600 | 2570 | 
| 2601   // Allocate the empty array. | 2571   // Allocate the empty array. | 
| 2602   { | 2572   { | 
| 2603     AllocationResult allocation = AllocateEmptyFixedArray(); | 2573     AllocationResult allocation = AllocateEmptyFixedArray(); | 
| 2604     if (!allocation.To(&obj)) return false; | 2574     if (!allocation.To(&obj)) return false; | 
| 2605   } | 2575   } | 
| 2606   set_empty_fixed_array(FixedArray::cast(obj)); | 2576   set_empty_fixed_array(FixedArray::cast(obj)); | 
| 2607 | 2577 | 
| 2608   { | 2578   { | 
| 2609     AllocationResult allocation = Allocate(null_map(), OLD_POINTER_SPACE); | 2579     AllocationResult allocation = Allocate(null_map(), OLD_SPACE); | 
| 2610     if (!allocation.To(&obj)) return false; | 2580     if (!allocation.To(&obj)) return false; | 
| 2611   } | 2581   } | 
| 2612   set_null_value(Oddball::cast(obj)); | 2582   set_null_value(Oddball::cast(obj)); | 
| 2613   Oddball::cast(obj)->set_kind(Oddball::kNull); | 2583   Oddball::cast(obj)->set_kind(Oddball::kNull); | 
| 2614 | 2584 | 
| 2615   { | 2585   { | 
| 2616     AllocationResult allocation = Allocate(undefined_map(), OLD_POINTER_SPACE); | 2586     AllocationResult allocation = Allocate(undefined_map(), OLD_SPACE); | 
| 2617     if (!allocation.To(&obj)) return false; | 2587     if (!allocation.To(&obj)) return false; | 
| 2618   } | 2588   } | 
| 2619   set_undefined_value(Oddball::cast(obj)); | 2589   set_undefined_value(Oddball::cast(obj)); | 
| 2620   Oddball::cast(obj)->set_kind(Oddball::kUndefined); | 2590   Oddball::cast(obj)->set_kind(Oddball::kUndefined); | 
| 2621   DCHECK(!InNewSpace(undefined_value())); | 2591   DCHECK(!InNewSpace(undefined_value())); | 
| 2622 | 2592 | 
| 2623   // Set preliminary exception sentinel value before actually initializing it. | 2593   // Set preliminary exception sentinel value before actually initializing it. | 
| 2624   set_exception(null_value()); | 2594   set_exception(null_value()); | 
| 2625 | 2595 | 
| 2626   // Allocate the empty descriptor array. | 2596   // Allocate the empty descriptor array. | 
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2843 } | 2813 } | 
| 2844 | 2814 | 
| 2845 | 2815 | 
| 2846 AllocationResult Heap::AllocateHeapNumber(double value, MutableMode mode, | 2816 AllocationResult Heap::AllocateHeapNumber(double value, MutableMode mode, | 
| 2847                                           PretenureFlag pretenure) { | 2817                                           PretenureFlag pretenure) { | 
| 2848   // Statically ensure that it is safe to allocate heap numbers in paged | 2818   // Statically ensure that it is safe to allocate heap numbers in paged | 
| 2849   // spaces. | 2819   // spaces. | 
| 2850   int size = HeapNumber::kSize; | 2820   int size = HeapNumber::kSize; | 
| 2851   STATIC_ASSERT(HeapNumber::kSize <= Page::kMaxRegularHeapObjectSize); | 2821   STATIC_ASSERT(HeapNumber::kSize <= Page::kMaxRegularHeapObjectSize); | 
| 2852 | 2822 | 
| 2853   AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); | 2823   AllocationSpace space = SelectSpace(size, pretenure); | 
| 2854 | 2824 | 
| 2855   HeapObject* result; | 2825   HeapObject* result; | 
| 2856   { | 2826   { | 
| 2857     AllocationResult allocation = AllocateRaw(size, space, OLD_DATA_SPACE); | 2827     AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 
| 2858     if (!allocation.To(&result)) return allocation; | 2828     if (!allocation.To(&result)) return allocation; | 
| 2859   } | 2829   } | 
| 2860 | 2830 | 
| 2861   Map* map = mode == MUTABLE ? mutable_heap_number_map() : heap_number_map(); | 2831   Map* map = mode == MUTABLE ? mutable_heap_number_map() : heap_number_map(); | 
| 2862   HeapObject::cast(result)->set_map_no_write_barrier(map); | 2832   HeapObject::cast(result)->set_map_no_write_barrier(map); | 
| 2863   HeapNumber::cast(result)->set_value(value); | 2833   HeapNumber::cast(result)->set_value(value); | 
| 2864   return result; | 2834   return result; | 
| 2865 } | 2835 } | 
| 2866 | 2836 | 
| 2867 | 2837 | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
| 2897   cell->set_type(HeapType::None()); | 2867   cell->set_type(HeapType::None()); | 
| 2898   return result; | 2868   return result; | 
| 2899 } | 2869 } | 
| 2900 | 2870 | 
| 2901 | 2871 | 
| 2902 AllocationResult Heap::AllocateWeakCell(HeapObject* value) { | 2872 AllocationResult Heap::AllocateWeakCell(HeapObject* value) { | 
| 2903   int size = WeakCell::kSize; | 2873   int size = WeakCell::kSize; | 
| 2904   STATIC_ASSERT(WeakCell::kSize <= Page::kMaxRegularHeapObjectSize); | 2874   STATIC_ASSERT(WeakCell::kSize <= Page::kMaxRegularHeapObjectSize); | 
| 2905   HeapObject* result; | 2875   HeapObject* result; | 
| 2906   { | 2876   { | 
| 2907     AllocationResult allocation = | 2877     AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); | 
| 2908         AllocateRaw(size, OLD_POINTER_SPACE, OLD_POINTER_SPACE); |  | 
| 2909     if (!allocation.To(&result)) return allocation; | 2878     if (!allocation.To(&result)) return allocation; | 
| 2910   } | 2879   } | 
| 2911   result->set_map_no_write_barrier(weak_cell_map()); | 2880   result->set_map_no_write_barrier(weak_cell_map()); | 
| 2912   WeakCell::cast(result)->initialize(value); | 2881   WeakCell::cast(result)->initialize(value); | 
| 2913   WeakCell::cast(result)->set_next(undefined_value(), SKIP_WRITE_BARRIER); | 2882   WeakCell::cast(result)->set_next(undefined_value(), SKIP_WRITE_BARRIER); | 
| 2914   return result; | 2883   return result; | 
| 2915 } | 2884 } | 
| 2916 | 2885 | 
| 2917 | 2886 | 
| 2918 void Heap::CreateApiObjects() { | 2887 void Heap::CreateApiObjects() { | 
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3453 FixedTypedArrayBase* Heap::EmptyFixedTypedArrayForMap(Map* map) { | 3422 FixedTypedArrayBase* Heap::EmptyFixedTypedArrayForMap(Map* map) { | 
| 3454   return FixedTypedArrayBase::cast( | 3423   return FixedTypedArrayBase::cast( | 
| 3455       roots_[RootIndexForEmptyFixedTypedArray(map->elements_kind())]); | 3424       roots_[RootIndexForEmptyFixedTypedArray(map->elements_kind())]); | 
| 3456 } | 3425 } | 
| 3457 | 3426 | 
| 3458 | 3427 | 
| 3459 AllocationResult Heap::AllocateForeign(Address address, | 3428 AllocationResult Heap::AllocateForeign(Address address, | 
| 3460                                        PretenureFlag pretenure) { | 3429                                        PretenureFlag pretenure) { | 
| 3461   // Statically ensure that it is safe to allocate foreigns in paged spaces. | 3430   // Statically ensure that it is safe to allocate foreigns in paged spaces. | 
| 3462   STATIC_ASSERT(Foreign::kSize <= Page::kMaxRegularHeapObjectSize); | 3431   STATIC_ASSERT(Foreign::kSize <= Page::kMaxRegularHeapObjectSize); | 
| 3463   AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; | 3432   AllocationSpace space = (pretenure == TENURED) ? OLD_SPACE : NEW_SPACE; | 
| 3464   Foreign* result; | 3433   Foreign* result; | 
| 3465   AllocationResult allocation = Allocate(foreign_map(), space); | 3434   AllocationResult allocation = Allocate(foreign_map(), space); | 
| 3466   if (!allocation.To(&result)) return allocation; | 3435   if (!allocation.To(&result)) return allocation; | 
| 3467   result->set_foreign_address(address); | 3436   result->set_foreign_address(address); | 
| 3468   return result; | 3437   return result; | 
| 3469 } | 3438 } | 
| 3470 | 3439 | 
| 3471 | 3440 | 
| 3472 AllocationResult Heap::AllocateByteArray(int length, PretenureFlag pretenure) { | 3441 AllocationResult Heap::AllocateByteArray(int length, PretenureFlag pretenure) { | 
| 3473   if (length < 0 || length > ByteArray::kMaxLength) { | 3442   if (length < 0 || length > ByteArray::kMaxLength) { | 
| 3474     v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); | 3443     v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); | 
| 3475   } | 3444   } | 
| 3476   int size = ByteArray::SizeFor(length); | 3445   int size = ByteArray::SizeFor(length); | 
| 3477   AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); | 3446   AllocationSpace space = SelectSpace(size, pretenure); | 
| 3478   HeapObject* result; | 3447   HeapObject* result; | 
| 3479   { | 3448   { | 
| 3480     AllocationResult allocation = AllocateRaw(size, space, OLD_DATA_SPACE); | 3449     AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 
| 3481     if (!allocation.To(&result)) return allocation; | 3450     if (!allocation.To(&result)) return allocation; | 
| 3482   } | 3451   } | 
| 3483 | 3452 | 
| 3484   result->set_map_no_write_barrier(byte_array_map()); | 3453   result->set_map_no_write_barrier(byte_array_map()); | 
| 3485   ByteArray::cast(result)->set_length(length); | 3454   ByteArray::cast(result)->set_length(length); | 
| 3486   return result; | 3455   return result; | 
| 3487 } | 3456 } | 
| 3488 | 3457 | 
| 3489 | 3458 | 
| 3490 void Heap::CreateFillerObjectAt(Address addr, int size) { | 3459 void Heap::CreateFillerObjectAt(Address addr, int size) { | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 3501   } else { | 3470   } else { | 
| 3502     filler->set_map_no_write_barrier(raw_unchecked_free_space_map()); | 3471     filler->set_map_no_write_barrier(raw_unchecked_free_space_map()); | 
| 3503     DCHECK(filler->map() == NULL || filler->map() == free_space_map()); | 3472     DCHECK(filler->map() == NULL || filler->map() == free_space_map()); | 
| 3504     FreeSpace::cast(filler)->nobarrier_set_size(size); | 3473     FreeSpace::cast(filler)->nobarrier_set_size(size); | 
| 3505   } | 3474   } | 
| 3506 } | 3475 } | 
| 3507 | 3476 | 
| 3508 | 3477 | 
| 3509 bool Heap::CanMoveObjectStart(HeapObject* object) { | 3478 bool Heap::CanMoveObjectStart(HeapObject* object) { | 
| 3510   Address address = object->address(); | 3479   Address address = object->address(); | 
| 3511   bool is_in_old_pointer_space = InOldPointerSpace(address); |  | 
| 3512   bool is_in_old_data_space = InOldDataSpace(address); |  | 
| 3513 | 3480 | 
| 3514   if (lo_space()->Contains(object)) return false; | 3481   if (lo_space()->Contains(object)) return false; | 
| 3515 | 3482 | 
| 3516   Page* page = Page::FromAddress(address); | 3483   Page* page = Page::FromAddress(address); | 
| 3517   // We can move the object start if: | 3484   // We can move the object start if: | 
| 3518   // (1) the object is not in old pointer or old data space, | 3485   // (1) the object is not in old space, | 
| 3519   // (2) the page of the object was already swept, | 3486   // (2) the page of the object was already swept, | 
| 3520   // (3) the page was already concurrently swept. This case is an optimization | 3487   // (3) the page was already concurrently swept. This case is an optimization | 
| 3521   // for concurrent sweeping. The WasSwept predicate for concurrently swept | 3488   // for concurrent sweeping. The WasSwept predicate for concurrently swept | 
| 3522   // pages is set after sweeping all pages. | 3489   // pages is set after sweeping all pages. | 
| 3523   return (!is_in_old_pointer_space && !is_in_old_data_space) || | 3490   return !InOldSpace(address) || page->WasSwept() || page->SweepingCompleted(); | 
| 3524          page->WasSwept() || page->SweepingCompleted(); |  | 
| 3525 } | 3491 } | 
| 3526 | 3492 | 
| 3527 | 3493 | 
| 3528 void Heap::AdjustLiveBytes(Address address, int by, InvocationMode mode) { | 3494 void Heap::AdjustLiveBytes(Address address, int by, InvocationMode mode) { | 
| 3529   if (incremental_marking()->IsMarking() && | 3495   if (incremental_marking()->IsMarking() && | 
| 3530       Marking::IsBlack(Marking::MarkBitFrom(address))) { | 3496       Marking::IsBlack(Marking::MarkBitFrom(address))) { | 
| 3531     if (mode == FROM_GC) { | 3497     if (mode == FROM_GC) { | 
| 3532       MemoryChunk::IncrementLiveBytesFromGC(address, by); | 3498       MemoryChunk::IncrementLiveBytesFromGC(address, by); | 
| 3533     } else { | 3499     } else { | 
| 3534       MemoryChunk::IncrementLiveBytesFromMutator(address, by); | 3500       MemoryChunk::IncrementLiveBytesFromMutator(address, by); | 
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3631     profiler->UpdateObjectSizeEvent(object->address(), object->Size()); | 3597     profiler->UpdateObjectSizeEvent(object->address(), object->Size()); | 
| 3632   } | 3598   } | 
| 3633 } | 3599 } | 
| 3634 | 3600 | 
| 3635 | 3601 | 
| 3636 AllocationResult Heap::AllocateExternalArray(int length, | 3602 AllocationResult Heap::AllocateExternalArray(int length, | 
| 3637                                              ExternalArrayType array_type, | 3603                                              ExternalArrayType array_type, | 
| 3638                                              void* external_pointer, | 3604                                              void* external_pointer, | 
| 3639                                              PretenureFlag pretenure) { | 3605                                              PretenureFlag pretenure) { | 
| 3640   int size = ExternalArray::kAlignedSize; | 3606   int size = ExternalArray::kAlignedSize; | 
| 3641   AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); | 3607   AllocationSpace space = SelectSpace(size, pretenure); | 
| 3642   HeapObject* result; | 3608   HeapObject* result; | 
| 3643   { | 3609   { | 
| 3644     AllocationResult allocation = AllocateRaw(size, space, OLD_DATA_SPACE); | 3610     AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 
| 3645     if (!allocation.To(&result)) return allocation; | 3611     if (!allocation.To(&result)) return allocation; | 
| 3646   } | 3612   } | 
| 3647 | 3613 | 
| 3648   result->set_map_no_write_barrier(MapForExternalArrayType(array_type)); | 3614   result->set_map_no_write_barrier(MapForExternalArrayType(array_type)); | 
| 3649   ExternalArray::cast(result)->set_length(length); | 3615   ExternalArray::cast(result)->set_length(length); | 
| 3650   ExternalArray::cast(result)->set_external_pointer(external_pointer); | 3616   ExternalArray::cast(result)->set_external_pointer(external_pointer); | 
| 3651   return result; | 3617   return result; | 
| 3652 } | 3618 } | 
| 3653 | 3619 | 
| 3654 static void ForFixedTypedArray(ExternalArrayType array_type, int* element_size, | 3620 static void ForFixedTypedArray(ExternalArrayType array_type, int* element_size, | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
| 3677   int element_size; | 3643   int element_size; | 
| 3678   ElementsKind elements_kind; | 3644   ElementsKind elements_kind; | 
| 3679   ForFixedTypedArray(array_type, &element_size, &elements_kind); | 3645   ForFixedTypedArray(array_type, &element_size, &elements_kind); | 
| 3680   int size = OBJECT_POINTER_ALIGN(length * element_size + | 3646   int size = OBJECT_POINTER_ALIGN(length * element_size + | 
| 3681                                   FixedTypedArrayBase::kDataOffset); | 3647                                   FixedTypedArrayBase::kDataOffset); | 
| 3682 #ifndef V8_HOST_ARCH_64_BIT | 3648 #ifndef V8_HOST_ARCH_64_BIT | 
| 3683   if (array_type == kExternalFloat64Array) { | 3649   if (array_type == kExternalFloat64Array) { | 
| 3684     size += kPointerSize; | 3650     size += kPointerSize; | 
| 3685   } | 3651   } | 
| 3686 #endif | 3652 #endif | 
| 3687   AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); | 3653   AllocationSpace space = SelectSpace(size, pretenure); | 
| 3688 | 3654 | 
| 3689   HeapObject* object; | 3655   HeapObject* object; | 
| 3690   AllocationResult allocation = AllocateRaw(size, space, OLD_DATA_SPACE); | 3656   AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 
| 3691   if (!allocation.To(&object)) return allocation; | 3657   if (!allocation.To(&object)) return allocation; | 
| 3692 | 3658 | 
| 3693   if (array_type == kExternalFloat64Array) { | 3659   if (array_type == kExternalFloat64Array) { | 
| 3694     object = EnsureDoubleAligned(this, object, size); | 3660     object = EnsureDoubleAligned(this, object, size); | 
| 3695   } | 3661   } | 
| 3696 | 3662 | 
| 3697   object->set_map(MapForFixedTypedArray(array_type)); | 3663   object->set_map(MapForFixedTypedArray(array_type)); | 
| 3698   FixedTypedArrayBase* elements = FixedTypedArrayBase::cast(object); | 3664   FixedTypedArrayBase* elements = FixedTypedArrayBase::cast(object); | 
| 3699   elements->set_length(length); | 3665   elements->set_length(length); | 
| 3700   memset(elements->DataPtr(), 0, elements->DataSize()); | 3666   memset(elements->DataPtr(), 0, elements->DataSize()); | 
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3844   } | 3810   } | 
| 3845 } | 3811 } | 
| 3846 | 3812 | 
| 3847 | 3813 | 
| 3848 AllocationResult Heap::Allocate(Map* map, AllocationSpace space, | 3814 AllocationResult Heap::Allocate(Map* map, AllocationSpace space, | 
| 3849                                 AllocationSite* allocation_site) { | 3815                                 AllocationSite* allocation_site) { | 
| 3850   DCHECK(gc_state_ == NOT_IN_GC); | 3816   DCHECK(gc_state_ == NOT_IN_GC); | 
| 3851   DCHECK(map->instance_type() != MAP_TYPE); | 3817   DCHECK(map->instance_type() != MAP_TYPE); | 
| 3852   // If allocation failures are disallowed, we may allocate in a different | 3818   // If allocation failures are disallowed, we may allocate in a different | 
| 3853   // space when new space is full and the object is not a large object. | 3819   // space when new space is full and the object is not a large object. | 
| 3854   AllocationSpace retry_space = | 3820   AllocationSpace retry_space = (space != NEW_SPACE) ? space : OLD_SPACE; | 
| 3855       (space != NEW_SPACE) ? space : TargetSpaceId(map->instance_type()); |  | 
| 3856   int size = map->instance_size(); | 3821   int size = map->instance_size(); | 
| 3857   if (allocation_site != NULL) { | 3822   if (allocation_site != NULL) { | 
| 3858     size += AllocationMemento::kSize; | 3823     size += AllocationMemento::kSize; | 
| 3859   } | 3824   } | 
| 3860   HeapObject* result; | 3825   HeapObject* result; | 
| 3861   AllocationResult allocation = AllocateRaw(size, space, retry_space); | 3826   AllocationResult allocation = AllocateRaw(size, space, retry_space); | 
| 3862   if (!allocation.To(&result)) return allocation; | 3827   if (!allocation.To(&result)) return allocation; | 
| 3863   // No need for write barrier since object is white and map is in old space. | 3828   // No need for write barrier since object is white and map is in old space. | 
| 3864   result->set_map_no_write_barrier(map); | 3829   result->set_map_no_write_barrier(map); | 
| 3865   if (allocation_site != NULL) { | 3830   if (allocation_site != NULL) { | 
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3922     { | 3887     { | 
| 3923       AllocationResult allocation = AllocateFixedArray(prop_size, pretenure); | 3888       AllocationResult allocation = AllocateFixedArray(prop_size, pretenure); | 
| 3924       if (!allocation.To(&properties)) return allocation; | 3889       if (!allocation.To(&properties)) return allocation; | 
| 3925     } | 3890     } | 
| 3926   } else { | 3891   } else { | 
| 3927     properties = empty_fixed_array(); | 3892     properties = empty_fixed_array(); | 
| 3928   } | 3893   } | 
| 3929 | 3894 | 
| 3930   // Allocate the JSObject. | 3895   // Allocate the JSObject. | 
| 3931   int size = map->instance_size(); | 3896   int size = map->instance_size(); | 
| 3932   AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, pretenure); | 3897   AllocationSpace space = SelectSpace(size, pretenure); | 
| 3933   JSObject* js_obj; | 3898   JSObject* js_obj; | 
| 3934   AllocationResult allocation = Allocate(map, space, allocation_site); | 3899   AllocationResult allocation = Allocate(map, space, allocation_site); | 
| 3935   if (!allocation.To(&js_obj)) return allocation; | 3900   if (!allocation.To(&js_obj)) return allocation; | 
| 3936 | 3901 | 
| 3937   // Initialize the JSObject. | 3902   // Initialize the JSObject. | 
| 3938   InitializeJSObjectFromMap(js_obj, properties, map); | 3903   InitializeJSObjectFromMap(js_obj, properties, map); | 
| 3939   DCHECK(js_obj->HasFastElements() || js_obj->HasExternalArrayElements() || | 3904   DCHECK(js_obj->HasFastElements() || js_obj->HasExternalArrayElements() || | 
| 3940          js_obj->HasFixedTypedArrayElements()); | 3905          js_obj->HasFixedTypedArrayElements()); | 
| 3941   return js_obj; | 3906   return js_obj; | 
| 3942 } | 3907 } | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
| 3973 | 3938 | 
| 3974   DCHECK(site == NULL || AllocationSite::CanTrack(map->instance_type())); | 3939   DCHECK(site == NULL || AllocationSite::CanTrack(map->instance_type())); | 
| 3975 | 3940 | 
| 3976   WriteBarrierMode wb_mode = UPDATE_WRITE_BARRIER; | 3941   WriteBarrierMode wb_mode = UPDATE_WRITE_BARRIER; | 
| 3977 | 3942 | 
| 3978   // If we're forced to always allocate, we use the general allocation | 3943   // If we're forced to always allocate, we use the general allocation | 
| 3979   // functions which may leave us with an object in old space. | 3944   // functions which may leave us with an object in old space. | 
| 3980   if (always_allocate()) { | 3945   if (always_allocate()) { | 
| 3981     { | 3946     { | 
| 3982       AllocationResult allocation = | 3947       AllocationResult allocation = | 
| 3983           AllocateRaw(object_size, NEW_SPACE, OLD_POINTER_SPACE); | 3948           AllocateRaw(object_size, NEW_SPACE, OLD_SPACE); | 
| 3984       if (!allocation.To(&clone)) return allocation; | 3949       if (!allocation.To(&clone)) return allocation; | 
| 3985     } | 3950     } | 
| 3986     Address clone_address = clone->address(); | 3951     Address clone_address = clone->address(); | 
| 3987     CopyBlock(clone_address, source->address(), object_size); | 3952     CopyBlock(clone_address, source->address(), object_size); | 
| 3988 | 3953 | 
| 3989     // Update write barrier for all tagged fields that lie beyond the header. | 3954     // Update write barrier for all tagged fields that lie beyond the header. | 
| 3990     const int start_offset = JSObject::kHeaderSize; | 3955     const int start_offset = JSObject::kHeaderSize; | 
| 3991     const int end_offset = object_size; | 3956     const int end_offset = object_size; | 
| 3992 | 3957 | 
| 3993 #if V8_DOUBLE_FIELDS_UNBOXING | 3958 #if V8_DOUBLE_FIELDS_UNBOXING | 
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4124 | 4089 | 
| 4125   DCHECK_LE(0, chars); | 4090   DCHECK_LE(0, chars); | 
| 4126   DCHECK_GE(String::kMaxLength, chars); | 4091   DCHECK_GE(String::kMaxLength, chars); | 
| 4127   if (is_one_byte) { | 4092   if (is_one_byte) { | 
| 4128     map = one_byte_internalized_string_map(); | 4093     map = one_byte_internalized_string_map(); | 
| 4129     size = SeqOneByteString::SizeFor(chars); | 4094     size = SeqOneByteString::SizeFor(chars); | 
| 4130   } else { | 4095   } else { | 
| 4131     map = internalized_string_map(); | 4096     map = internalized_string_map(); | 
| 4132     size = SeqTwoByteString::SizeFor(chars); | 4097     size = SeqTwoByteString::SizeFor(chars); | 
| 4133   } | 4098   } | 
| 4134   AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, TENURED); | 4099   AllocationSpace space = SelectSpace(size, TENURED); | 
| 4135 | 4100 | 
| 4136   // Allocate string. | 4101   // Allocate string. | 
| 4137   HeapObject* result; | 4102   HeapObject* result; | 
| 4138   { | 4103   { | 
| 4139     AllocationResult allocation = AllocateRaw(size, space, OLD_DATA_SPACE); | 4104     AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 
| 4140     if (!allocation.To(&result)) return allocation; | 4105     if (!allocation.To(&result)) return allocation; | 
| 4141   } | 4106   } | 
| 4142 | 4107 | 
| 4143   result->set_map_no_write_barrier(map); | 4108   result->set_map_no_write_barrier(map); | 
| 4144   // Set length and hash fields of the allocated string. | 4109   // Set length and hash fields of the allocated string. | 
| 4145   String* answer = String::cast(result); | 4110   String* answer = String::cast(result); | 
| 4146   answer->set_length(chars); | 4111   answer->set_length(chars); | 
| 4147   answer->set_hash_field(hash_field); | 4112   answer->set_hash_field(hash_field); | 
| 4148 | 4113 | 
| 4149   DCHECK_EQ(size, answer->Size()); | 4114   DCHECK_EQ(size, answer->Size()); | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 4167 template AllocationResult Heap::AllocateInternalizedStringImpl<false>( | 4132 template AllocationResult Heap::AllocateInternalizedStringImpl<false>( | 
| 4168     Vector<const char>, int, uint32_t); | 4133     Vector<const char>, int, uint32_t); | 
| 4169 | 4134 | 
| 4170 | 4135 | 
| 4171 AllocationResult Heap::AllocateRawOneByteString(int length, | 4136 AllocationResult Heap::AllocateRawOneByteString(int length, | 
| 4172                                                 PretenureFlag pretenure) { | 4137                                                 PretenureFlag pretenure) { | 
| 4173   DCHECK_LE(0, length); | 4138   DCHECK_LE(0, length); | 
| 4174   DCHECK_GE(String::kMaxLength, length); | 4139   DCHECK_GE(String::kMaxLength, length); | 
| 4175   int size = SeqOneByteString::SizeFor(length); | 4140   int size = SeqOneByteString::SizeFor(length); | 
| 4176   DCHECK(size <= SeqOneByteString::kMaxSize); | 4141   DCHECK(size <= SeqOneByteString::kMaxSize); | 
| 4177   AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); | 4142   AllocationSpace space = SelectSpace(size, pretenure); | 
| 4178 | 4143 | 
| 4179   HeapObject* result; | 4144   HeapObject* result; | 
| 4180   { | 4145   { | 
| 4181     AllocationResult allocation = AllocateRaw(size, space, OLD_DATA_SPACE); | 4146     AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 
| 4182     if (!allocation.To(&result)) return allocation; | 4147     if (!allocation.To(&result)) return allocation; | 
| 4183   } | 4148   } | 
| 4184 | 4149 | 
| 4185   // Partially initialize the object. | 4150   // Partially initialize the object. | 
| 4186   result->set_map_no_write_barrier(one_byte_string_map()); | 4151   result->set_map_no_write_barrier(one_byte_string_map()); | 
| 4187   String::cast(result)->set_length(length); | 4152   String::cast(result)->set_length(length); | 
| 4188   String::cast(result)->set_hash_field(String::kEmptyHashField); | 4153   String::cast(result)->set_hash_field(String::kEmptyHashField); | 
| 4189   DCHECK_EQ(size, HeapObject::cast(result)->Size()); | 4154   DCHECK_EQ(size, HeapObject::cast(result)->Size()); | 
| 4190 | 4155 | 
| 4191   return result; | 4156   return result; | 
| 4192 } | 4157 } | 
| 4193 | 4158 | 
| 4194 | 4159 | 
| 4195 AllocationResult Heap::AllocateRawTwoByteString(int length, | 4160 AllocationResult Heap::AllocateRawTwoByteString(int length, | 
| 4196                                                 PretenureFlag pretenure) { | 4161                                                 PretenureFlag pretenure) { | 
| 4197   DCHECK_LE(0, length); | 4162   DCHECK_LE(0, length); | 
| 4198   DCHECK_GE(String::kMaxLength, length); | 4163   DCHECK_GE(String::kMaxLength, length); | 
| 4199   int size = SeqTwoByteString::SizeFor(length); | 4164   int size = SeqTwoByteString::SizeFor(length); | 
| 4200   DCHECK(size <= SeqTwoByteString::kMaxSize); | 4165   DCHECK(size <= SeqTwoByteString::kMaxSize); | 
| 4201   AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); | 4166   AllocationSpace space = SelectSpace(size, pretenure); | 
| 4202 | 4167 | 
| 4203   HeapObject* result; | 4168   HeapObject* result; | 
| 4204   { | 4169   { | 
| 4205     AllocationResult allocation = AllocateRaw(size, space, OLD_DATA_SPACE); | 4170     AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 
| 4206     if (!allocation.To(&result)) return allocation; | 4171     if (!allocation.To(&result)) return allocation; | 
| 4207   } | 4172   } | 
| 4208 | 4173 | 
| 4209   // Partially initialize the object. | 4174   // Partially initialize the object. | 
| 4210   result->set_map_no_write_barrier(string_map()); | 4175   result->set_map_no_write_barrier(string_map()); | 
| 4211   String::cast(result)->set_length(length); | 4176   String::cast(result)->set_length(length); | 
| 4212   String::cast(result)->set_hash_field(String::kEmptyHashField); | 4177   String::cast(result)->set_hash_field(String::kEmptyHashField); | 
| 4213   DCHECK_EQ(size, HeapObject::cast(result)->Size()); | 4178   DCHECK_EQ(size, HeapObject::cast(result)->Size()); | 
| 4214   return result; | 4179   return result; | 
| 4215 } | 4180 } | 
| 4216 | 4181 | 
| 4217 | 4182 | 
| 4218 AllocationResult Heap::AllocateEmptyFixedArray() { | 4183 AllocationResult Heap::AllocateEmptyFixedArray() { | 
| 4219   int size = FixedArray::SizeFor(0); | 4184   int size = FixedArray::SizeFor(0); | 
| 4220   HeapObject* result; | 4185   HeapObject* result; | 
| 4221   { | 4186   { | 
| 4222     AllocationResult allocation = | 4187     AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); | 
| 4223         AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE); |  | 
| 4224     if (!allocation.To(&result)) return allocation; | 4188     if (!allocation.To(&result)) return allocation; | 
| 4225   } | 4189   } | 
| 4226   // Initialize the object. | 4190   // Initialize the object. | 
| 4227   result->set_map_no_write_barrier(fixed_array_map()); | 4191   result->set_map_no_write_barrier(fixed_array_map()); | 
| 4228   FixedArray::cast(result)->set_length(0); | 4192   FixedArray::cast(result)->set_length(0); | 
| 4229   return result; | 4193   return result; | 
| 4230 } | 4194 } | 
| 4231 | 4195 | 
| 4232 | 4196 | 
| 4233 AllocationResult Heap::AllocateEmptyExternalArray( | 4197 AllocationResult Heap::AllocateEmptyExternalArray( | 
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4335   return obj; | 4299   return obj; | 
| 4336 } | 4300 } | 
| 4337 | 4301 | 
| 4338 | 4302 | 
| 4339 AllocationResult Heap::AllocateRawFixedArray(int length, | 4303 AllocationResult Heap::AllocateRawFixedArray(int length, | 
| 4340                                              PretenureFlag pretenure) { | 4304                                              PretenureFlag pretenure) { | 
| 4341   if (length < 0 || length > FixedArray::kMaxLength) { | 4305   if (length < 0 || length > FixedArray::kMaxLength) { | 
| 4342     v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); | 4306     v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); | 
| 4343   } | 4307   } | 
| 4344   int size = FixedArray::SizeFor(length); | 4308   int size = FixedArray::SizeFor(length); | 
| 4345   AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, pretenure); | 4309   AllocationSpace space = SelectSpace(size, pretenure); | 
| 4346 | 4310 | 
| 4347   return AllocateRaw(size, space, OLD_POINTER_SPACE); | 4311   return AllocateRaw(size, space, OLD_SPACE); | 
| 4348 } | 4312 } | 
| 4349 | 4313 | 
| 4350 | 4314 | 
| 4351 AllocationResult Heap::AllocateFixedArrayWithFiller(int length, | 4315 AllocationResult Heap::AllocateFixedArrayWithFiller(int length, | 
| 4352                                                     PretenureFlag pretenure, | 4316                                                     PretenureFlag pretenure, | 
| 4353                                                     Object* filler) { | 4317                                                     Object* filler) { | 
| 4354   DCHECK(length >= 0); | 4318   DCHECK(length >= 0); | 
| 4355   DCHECK(empty_fixed_array()->IsFixedArray()); | 4319   DCHECK(empty_fixed_array()->IsFixedArray()); | 
| 4356   if (length == 0) return empty_fixed_array(); | 4320   if (length == 0) return empty_fixed_array(); | 
| 4357 | 4321 | 
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4406 | 4370 | 
| 4407 AllocationResult Heap::AllocateRawFixedDoubleArray(int length, | 4371 AllocationResult Heap::AllocateRawFixedDoubleArray(int length, | 
| 4408                                                    PretenureFlag pretenure) { | 4372                                                    PretenureFlag pretenure) { | 
| 4409   if (length < 0 || length > FixedDoubleArray::kMaxLength) { | 4373   if (length < 0 || length > FixedDoubleArray::kMaxLength) { | 
| 4410     v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); | 4374     v8::internal::Heap::FatalProcessOutOfMemory("invalid array length", true); | 
| 4411   } | 4375   } | 
| 4412   int size = FixedDoubleArray::SizeFor(length); | 4376   int size = FixedDoubleArray::SizeFor(length); | 
| 4413 #ifndef V8_HOST_ARCH_64_BIT | 4377 #ifndef V8_HOST_ARCH_64_BIT | 
| 4414   size += kPointerSize; | 4378   size += kPointerSize; | 
| 4415 #endif | 4379 #endif | 
| 4416   AllocationSpace space = SelectSpace(size, OLD_DATA_SPACE, pretenure); | 4380   AllocationSpace space = SelectSpace(size, pretenure); | 
| 4417 | 4381 | 
| 4418   HeapObject* object; | 4382   HeapObject* object; | 
| 4419   { | 4383   { | 
| 4420     AllocationResult allocation = AllocateRaw(size, space, OLD_DATA_SPACE); | 4384     AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 
| 4421     if (!allocation.To(&object)) return allocation; | 4385     if (!allocation.To(&object)) return allocation; | 
| 4422   } | 4386   } | 
| 4423 | 4387 | 
| 4424   return EnsureDoubleAligned(this, object, size); | 4388   return EnsureDoubleAligned(this, object, size); | 
| 4425 } | 4389 } | 
| 4426 | 4390 | 
| 4427 | 4391 | 
| 4428 AllocationResult Heap::AllocateConstantPoolArray( | 4392 AllocationResult Heap::AllocateConstantPoolArray( | 
| 4429     const ConstantPoolArray::NumberOfEntries& small) { | 4393     const ConstantPoolArray::NumberOfEntries& small) { | 
| 4430   CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType)); | 4394   CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType)); | 
| 4431   int size = ConstantPoolArray::SizeFor(small); | 4395   int size = ConstantPoolArray::SizeFor(small); | 
| 4432 #ifndef V8_HOST_ARCH_64_BIT | 4396 #ifndef V8_HOST_ARCH_64_BIT | 
| 4433   size += kPointerSize; | 4397   size += kPointerSize; | 
| 4434 #endif | 4398 #endif | 
| 4435   AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, TENURED); | 4399   AllocationSpace space = SelectSpace(size, TENURED); | 
| 4436 | 4400 | 
| 4437   HeapObject* object; | 4401   HeapObject* object; | 
| 4438   { | 4402   { | 
| 4439     AllocationResult allocation = AllocateRaw(size, space, OLD_POINTER_SPACE); | 4403     AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 
| 4440     if (!allocation.To(&object)) return allocation; | 4404     if (!allocation.To(&object)) return allocation; | 
| 4441   } | 4405   } | 
| 4442   object = EnsureDoubleAligned(this, object, size); | 4406   object = EnsureDoubleAligned(this, object, size); | 
| 4443   object->set_map_no_write_barrier(constant_pool_array_map()); | 4407   object->set_map_no_write_barrier(constant_pool_array_map()); | 
| 4444 | 4408 | 
| 4445   ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); | 4409   ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); | 
| 4446   constant_pool->Init(small); | 4410   constant_pool->Init(small); | 
| 4447   constant_pool->ClearPtrEntries(isolate()); | 4411   constant_pool->ClearPtrEntries(isolate()); | 
| 4448   return constant_pool; | 4412   return constant_pool; | 
| 4449 } | 4413 } | 
| 4450 | 4414 | 
| 4451 | 4415 | 
| 4452 AllocationResult Heap::AllocateExtendedConstantPoolArray( | 4416 AllocationResult Heap::AllocateExtendedConstantPoolArray( | 
| 4453     const ConstantPoolArray::NumberOfEntries& small, | 4417     const ConstantPoolArray::NumberOfEntries& small, | 
| 4454     const ConstantPoolArray::NumberOfEntries& extended) { | 4418     const ConstantPoolArray::NumberOfEntries& extended) { | 
| 4455   CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType)); | 4419   CHECK(small.are_in_range(0, ConstantPoolArray::kMaxSmallEntriesPerType)); | 
| 4456   CHECK(extended.are_in_range(0, kMaxInt)); | 4420   CHECK(extended.are_in_range(0, kMaxInt)); | 
| 4457   int size = ConstantPoolArray::SizeForExtended(small, extended); | 4421   int size = ConstantPoolArray::SizeForExtended(small, extended); | 
| 4458 #ifndef V8_HOST_ARCH_64_BIT | 4422 #ifndef V8_HOST_ARCH_64_BIT | 
| 4459   size += kPointerSize; | 4423   size += kPointerSize; | 
| 4460 #endif | 4424 #endif | 
| 4461   AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, TENURED); | 4425   AllocationSpace space = SelectSpace(size, TENURED); | 
| 4462 | 4426 | 
| 4463   HeapObject* object; | 4427   HeapObject* object; | 
| 4464   { | 4428   { | 
| 4465     AllocationResult allocation = AllocateRaw(size, space, OLD_POINTER_SPACE); | 4429     AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 
| 4466     if (!allocation.To(&object)) return allocation; | 4430     if (!allocation.To(&object)) return allocation; | 
| 4467   } | 4431   } | 
| 4468   object = EnsureDoubleAligned(this, object, size); | 4432   object = EnsureDoubleAligned(this, object, size); | 
| 4469   object->set_map_no_write_barrier(constant_pool_array_map()); | 4433   object->set_map_no_write_barrier(constant_pool_array_map()); | 
| 4470 | 4434 | 
| 4471   ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); | 4435   ConstantPoolArray* constant_pool = ConstantPoolArray::cast(object); | 
| 4472   constant_pool->InitExtended(small, extended); | 4436   constant_pool->InitExtended(small, extended); | 
| 4473   constant_pool->ClearPtrEntries(isolate()); | 4437   constant_pool->ClearPtrEntries(isolate()); | 
| 4474   return constant_pool; | 4438   return constant_pool; | 
| 4475 } | 4439 } | 
| 4476 | 4440 | 
| 4477 | 4441 | 
| 4478 AllocationResult Heap::AllocateEmptyConstantPoolArray() { | 4442 AllocationResult Heap::AllocateEmptyConstantPoolArray() { | 
| 4479   ConstantPoolArray::NumberOfEntries small(0, 0, 0, 0); | 4443   ConstantPoolArray::NumberOfEntries small(0, 0, 0, 0); | 
| 4480   int size = ConstantPoolArray::SizeFor(small); | 4444   int size = ConstantPoolArray::SizeFor(small); | 
| 4481   HeapObject* result; | 4445   HeapObject* result; | 
| 4482   { | 4446   { | 
| 4483     AllocationResult allocation = | 4447     AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); | 
| 4484         AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE); |  | 
| 4485     if (!allocation.To(&result)) return allocation; | 4448     if (!allocation.To(&result)) return allocation; | 
| 4486   } | 4449   } | 
| 4487   result->set_map_no_write_barrier(constant_pool_array_map()); | 4450   result->set_map_no_write_barrier(constant_pool_array_map()); | 
| 4488   ConstantPoolArray::cast(result)->Init(small); | 4451   ConstantPoolArray::cast(result)->Init(small); | 
| 4489   return result; | 4452   return result; | 
| 4490 } | 4453 } | 
| 4491 | 4454 | 
| 4492 | 4455 | 
| 4493 AllocationResult Heap::AllocateSymbol() { | 4456 AllocationResult Heap::AllocateSymbol() { | 
| 4494   // 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. | 
| 4495   STATIC_ASSERT(Symbol::kSize <= Page::kMaxRegularHeapObjectSize); | 4458   STATIC_ASSERT(Symbol::kSize <= Page::kMaxRegularHeapObjectSize); | 
| 4496 | 4459 | 
| 4497   HeapObject* result; | 4460   HeapObject* result; | 
| 4498   AllocationResult allocation = | 4461   AllocationResult allocation = | 
| 4499       AllocateRaw(Symbol::kSize, OLD_POINTER_SPACE, OLD_POINTER_SPACE); | 4462       AllocateRaw(Symbol::kSize, OLD_SPACE, OLD_SPACE); | 
| 4500   if (!allocation.To(&result)) return allocation; | 4463   if (!allocation.To(&result)) return allocation; | 
| 4501 | 4464 | 
| 4502   result->set_map_no_write_barrier(symbol_map()); | 4465   result->set_map_no_write_barrier(symbol_map()); | 
| 4503 | 4466 | 
| 4504   // Generate a random hash value. | 4467   // Generate a random hash value. | 
| 4505   int hash; | 4468   int hash; | 
| 4506   int attempts = 0; | 4469   int attempts = 0; | 
| 4507   do { | 4470   do { | 
| 4508     hash = isolate()->random_number_generator()->NextInt() & Name::kHashBitMask; | 4471     hash = isolate()->random_number_generator()->NextInt() & Name::kHashBitMask; | 
| 4509     attempts++; | 4472     attempts++; | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 4527   case NAME##_TYPE:                 \ | 4490   case NAME##_TYPE:                 \ | 
| 4528     map = name##_map();             \ | 4491     map = name##_map();             \ | 
| 4529     break; | 4492     break; | 
| 4530     STRUCT_LIST(MAKE_CASE) | 4493     STRUCT_LIST(MAKE_CASE) | 
| 4531 #undef MAKE_CASE | 4494 #undef MAKE_CASE | 
| 4532     default: | 4495     default: | 
| 4533       UNREACHABLE(); | 4496       UNREACHABLE(); | 
| 4534       return exception(); | 4497       return exception(); | 
| 4535   } | 4498   } | 
| 4536   int size = map->instance_size(); | 4499   int size = map->instance_size(); | 
| 4537   AllocationSpace space = SelectSpace(size, OLD_POINTER_SPACE, TENURED); | 4500   AllocationSpace space = SelectSpace(size, TENURED); | 
| 4538   Struct* result; | 4501   Struct* result; | 
| 4539   { | 4502   { | 
| 4540     AllocationResult allocation = Allocate(map, space); | 4503     AllocationResult allocation = Allocate(map, space); | 
| 4541     if (!allocation.To(&result)) return allocation; | 4504     if (!allocation.To(&result)) return allocation; | 
| 4542   } | 4505   } | 
| 4543   result->InitializeBody(size); | 4506   result->InitializeBody(size); | 
| 4544   return result; | 4507   return result; | 
| 4545 } | 4508 } | 
| 4546 | 4509 | 
| 4547 | 4510 | 
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4791 | 4754 | 
| 4792   PrintF("\n"); | 4755   PrintF("\n"); | 
| 4793   PrintF("Number of handles : %d\n", HandleScope::NumberOfHandles(isolate_)); | 4756   PrintF("Number of handles : %d\n", HandleScope::NumberOfHandles(isolate_)); | 
| 4794   isolate_->global_handles()->PrintStats(); | 4757   isolate_->global_handles()->PrintStats(); | 
| 4795   PrintF("\n"); | 4758   PrintF("\n"); | 
| 4796 | 4759 | 
| 4797   PrintF("Heap statistics : "); | 4760   PrintF("Heap statistics : "); | 
| 4798   isolate_->memory_allocator()->ReportStatistics(); | 4761   isolate_->memory_allocator()->ReportStatistics(); | 
| 4799   PrintF("To space : "); | 4762   PrintF("To space : "); | 
| 4800   new_space_.ReportStatistics(); | 4763   new_space_.ReportStatistics(); | 
| 4801   PrintF("Old pointer space : "); | 4764   PrintF("Old space : "); | 
| 4802   old_pointer_space_->ReportStatistics(); | 4765   old_space_->ReportStatistics(); | 
| 4803   PrintF("Old data space : "); |  | 
| 4804   old_data_space_->ReportStatistics(); |  | 
| 4805   PrintF("Code space : "); | 4766   PrintF("Code space : "); | 
| 4806   code_space_->ReportStatistics(); | 4767   code_space_->ReportStatistics(); | 
| 4807   PrintF("Map space : "); | 4768   PrintF("Map space : "); | 
| 4808   map_space_->ReportStatistics(); | 4769   map_space_->ReportStatistics(); | 
| 4809   PrintF("Cell space : "); | 4770   PrintF("Cell space : "); | 
| 4810   cell_space_->ReportStatistics(); | 4771   cell_space_->ReportStatistics(); | 
| 4811   PrintF("PropertyCell space : "); | 4772   PrintF("PropertyCell space : "); | 
| 4812   property_cell_space_->ReportStatistics(); | 4773   property_cell_space_->ReportStatistics(); | 
| 4813   PrintF("Large object space : "); | 4774   PrintF("Large object space : "); | 
| 4814   lo_space_->ReportStatistics(); | 4775   lo_space_->ReportStatistics(); | 
| 4815   PrintF(">>>>>> ========================================= >>>>>>\n"); | 4776   PrintF(">>>>>> ========================================= >>>>>>\n"); | 
| 4816 } | 4777 } | 
| 4817 | 4778 | 
| 4818 #endif  // DEBUG | 4779 #endif  // DEBUG | 
| 4819 | 4780 | 
| 4820 bool Heap::Contains(HeapObject* value) { return Contains(value->address()); } | 4781 bool Heap::Contains(HeapObject* value) { return Contains(value->address()); } | 
| 4821 | 4782 | 
| 4822 | 4783 | 
| 4823 bool Heap::Contains(Address addr) { | 4784 bool Heap::Contains(Address addr) { | 
| 4824   if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; | 4785   if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; | 
| 4825   return HasBeenSetUp() && | 4786   return HasBeenSetUp() && | 
| 4826          (new_space_.ToSpaceContains(addr) || | 4787          (new_space_.ToSpaceContains(addr) || old_space_->Contains(addr) || | 
| 4827           old_pointer_space_->Contains(addr) || | 4788           code_space_->Contains(addr) || map_space_->Contains(addr) || | 
| 4828           old_data_space_->Contains(addr) || code_space_->Contains(addr) || | 4789           cell_space_->Contains(addr) || property_cell_space_->Contains(addr) || | 
| 4829           map_space_->Contains(addr) || cell_space_->Contains(addr) || |  | 
| 4830           property_cell_space_->Contains(addr) || |  | 
| 4831           lo_space_->SlowContains(addr)); | 4790           lo_space_->SlowContains(addr)); | 
| 4832 } | 4791 } | 
| 4833 | 4792 | 
| 4834 | 4793 | 
| 4835 bool Heap::InSpace(HeapObject* value, AllocationSpace space) { | 4794 bool Heap::InSpace(HeapObject* value, AllocationSpace space) { | 
| 4836   return InSpace(value->address(), space); | 4795   return InSpace(value->address(), space); | 
| 4837 } | 4796 } | 
| 4838 | 4797 | 
| 4839 | 4798 | 
| 4840 bool Heap::InSpace(Address addr, AllocationSpace space) { | 4799 bool Heap::InSpace(Address addr, AllocationSpace space) { | 
| 4841   if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; | 4800   if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; | 
| 4842   if (!HasBeenSetUp()) return false; | 4801   if (!HasBeenSetUp()) return false; | 
| 4843 | 4802 | 
| 4844   switch (space) { | 4803   switch (space) { | 
| 4845     case NEW_SPACE: | 4804     case NEW_SPACE: | 
| 4846       return new_space_.ToSpaceContains(addr); | 4805       return new_space_.ToSpaceContains(addr); | 
| 4847     case OLD_POINTER_SPACE: | 4806     case OLD_SPACE: | 
| 4848       return old_pointer_space_->Contains(addr); | 4807       return old_space_->Contains(addr); | 
| 4849     case OLD_DATA_SPACE: |  | 
| 4850       return old_data_space_->Contains(addr); |  | 
| 4851     case CODE_SPACE: | 4808     case CODE_SPACE: | 
| 4852       return code_space_->Contains(addr); | 4809       return code_space_->Contains(addr); | 
| 4853     case MAP_SPACE: | 4810     case MAP_SPACE: | 
| 4854       return map_space_->Contains(addr); | 4811       return map_space_->Contains(addr); | 
| 4855     case CELL_SPACE: | 4812     case CELL_SPACE: | 
| 4856       return cell_space_->Contains(addr); | 4813       return cell_space_->Contains(addr); | 
| 4857     case PROPERTY_CELL_SPACE: | 4814     case PROPERTY_CELL_SPACE: | 
| 4858       return property_cell_space_->Contains(addr); | 4815       return property_cell_space_->Contains(addr); | 
| 4859     case LO_SPACE: | 4816     case LO_SPACE: | 
| 4860       return lo_space_->SlowContains(addr); | 4817       return lo_space_->SlowContains(addr); | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
| 4890   } | 4847   } | 
| 4891 | 4848 | 
| 4892   VerifyPointersVisitor visitor; | 4849   VerifyPointersVisitor visitor; | 
| 4893   IterateRoots(&visitor, VISIT_ONLY_STRONG); | 4850   IterateRoots(&visitor, VISIT_ONLY_STRONG); | 
| 4894 | 4851 | 
| 4895   VerifySmisVisitor smis_visitor; | 4852   VerifySmisVisitor smis_visitor; | 
| 4896   IterateSmiRoots(&smis_visitor); | 4853   IterateSmiRoots(&smis_visitor); | 
| 4897 | 4854 | 
| 4898   new_space_.Verify(); | 4855   new_space_.Verify(); | 
| 4899 | 4856 | 
| 4900   old_pointer_space_->Verify(&visitor); | 4857   old_space_->Verify(&visitor); | 
| 4901   map_space_->Verify(&visitor); | 4858   map_space_->Verify(&visitor); | 
| 4902 | 4859 | 
| 4903   VerifyPointersVisitor no_dirty_regions_visitor; | 4860   VerifyPointersVisitor no_dirty_regions_visitor; | 
| 4904   old_data_space_->Verify(&no_dirty_regions_visitor); |  | 
| 4905   code_space_->Verify(&no_dirty_regions_visitor); | 4861   code_space_->Verify(&no_dirty_regions_visitor); | 
| 4906   cell_space_->Verify(&no_dirty_regions_visitor); | 4862   cell_space_->Verify(&no_dirty_regions_visitor); | 
| 4907   property_cell_space_->Verify(&no_dirty_regions_visitor); | 4863   property_cell_space_->Verify(&no_dirty_regions_visitor); | 
| 4908 | 4864 | 
| 4909   lo_space_->Verify(); | 4865   lo_space_->Verify(); | 
| 4910 } | 4866 } | 
| 4911 #endif | 4867 #endif | 
| 4912 | 4868 | 
| 4913 | 4869 | 
| 4914 void Heap::ZapFromSpace() { | 4870 void Heap::ZapFromSpace() { | 
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5212 | 5168 | 
| 5213 | 5169 | 
| 5214 bool Heap::ConfigureHeapDefault() { return ConfigureHeap(0, 0, 0, 0); } | 5170 bool Heap::ConfigureHeapDefault() { return ConfigureHeap(0, 0, 0, 0); } | 
| 5215 | 5171 | 
| 5216 | 5172 | 
| 5217 void Heap::RecordStats(HeapStats* stats, bool take_snapshot) { | 5173 void Heap::RecordStats(HeapStats* stats, bool take_snapshot) { | 
| 5218   *stats->start_marker = HeapStats::kStartMarker; | 5174   *stats->start_marker = HeapStats::kStartMarker; | 
| 5219   *stats->end_marker = HeapStats::kEndMarker; | 5175   *stats->end_marker = HeapStats::kEndMarker; | 
| 5220   *stats->new_space_size = new_space_.SizeAsInt(); | 5176   *stats->new_space_size = new_space_.SizeAsInt(); | 
| 5221   *stats->new_space_capacity = static_cast<int>(new_space_.Capacity()); | 5177   *stats->new_space_capacity = static_cast<int>(new_space_.Capacity()); | 
| 5222   *stats->old_pointer_space_size = old_pointer_space_->SizeOfObjects(); | 5178   *stats->old_space_size = old_space_->SizeOfObjects(); | 
| 5223   *stats->old_pointer_space_capacity = old_pointer_space_->Capacity(); | 5179   *stats->old_space_capacity = old_space_->Capacity(); | 
| 5224   *stats->old_data_space_size = old_data_space_->SizeOfObjects(); |  | 
| 5225   *stats->old_data_space_capacity = old_data_space_->Capacity(); |  | 
| 5226   *stats->code_space_size = code_space_->SizeOfObjects(); | 5180   *stats->code_space_size = code_space_->SizeOfObjects(); | 
| 5227   *stats->code_space_capacity = code_space_->Capacity(); | 5181   *stats->code_space_capacity = code_space_->Capacity(); | 
| 5228   *stats->map_space_size = map_space_->SizeOfObjects(); | 5182   *stats->map_space_size = map_space_->SizeOfObjects(); | 
| 5229   *stats->map_space_capacity = map_space_->Capacity(); | 5183   *stats->map_space_capacity = map_space_->Capacity(); | 
| 5230   *stats->cell_space_size = cell_space_->SizeOfObjects(); | 5184   *stats->cell_space_size = cell_space_->SizeOfObjects(); | 
| 5231   *stats->cell_space_capacity = cell_space_->Capacity(); | 5185   *stats->cell_space_capacity = cell_space_->Capacity(); | 
| 5232   *stats->property_cell_space_size = property_cell_space_->SizeOfObjects(); | 5186   *stats->property_cell_space_size = property_cell_space_->SizeOfObjects(); | 
| 5233   *stats->property_cell_space_capacity = property_cell_space_->Capacity(); | 5187   *stats->property_cell_space_capacity = property_cell_space_->Capacity(); | 
| 5234   *stats->lo_space_size = lo_space_->Size(); | 5188   *stats->lo_space_size = lo_space_->Size(); | 
| 5235   isolate_->global_handles()->RecordStats(stats); | 5189   isolate_->global_handles()->RecordStats(stats); | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 5246       InstanceType type = obj->map()->instance_type(); | 5200       InstanceType type = obj->map()->instance_type(); | 
| 5247       DCHECK(0 <= type && type <= LAST_TYPE); | 5201       DCHECK(0 <= type && type <= LAST_TYPE); | 
| 5248       stats->objects_per_type[type]++; | 5202       stats->objects_per_type[type]++; | 
| 5249       stats->size_per_type[type] += obj->Size(); | 5203       stats->size_per_type[type] += obj->Size(); | 
| 5250     } | 5204     } | 
| 5251   } | 5205   } | 
| 5252 } | 5206 } | 
| 5253 | 5207 | 
| 5254 | 5208 | 
| 5255 intptr_t Heap::PromotedSpaceSizeOfObjects() { | 5209 intptr_t Heap::PromotedSpaceSizeOfObjects() { | 
| 5256   return old_pointer_space_->SizeOfObjects() + | 5210   return old_space_->SizeOfObjects() + code_space_->SizeOfObjects() + | 
| 5257          old_data_space_->SizeOfObjects() + code_space_->SizeOfObjects() + |  | 
| 5258          map_space_->SizeOfObjects() + cell_space_->SizeOfObjects() + | 5211          map_space_->SizeOfObjects() + cell_space_->SizeOfObjects() + | 
| 5259          property_cell_space_->SizeOfObjects() + lo_space_->SizeOfObjects(); | 5212          property_cell_space_->SizeOfObjects() + lo_space_->SizeOfObjects(); | 
| 5260 } | 5213 } | 
| 5261 | 5214 | 
| 5262 | 5215 | 
| 5263 int64_t Heap::PromotedExternalMemorySize() { | 5216 int64_t Heap::PromotedExternalMemorySize() { | 
| 5264   if (amount_of_external_allocated_memory_ <= | 5217   if (amount_of_external_allocated_memory_ <= | 
| 5265       amount_of_external_allocated_memory_at_last_global_gc_) | 5218       amount_of_external_allocated_memory_at_last_global_gc_) | 
| 5266     return 0; | 5219     return 0; | 
| 5267   return amount_of_external_allocated_memory_ - | 5220   return amount_of_external_allocated_memory_ - | 
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5371   // Set up memory allocator. | 5324   // Set up memory allocator. | 
| 5372   if (!isolate_->memory_allocator()->SetUp(MaxReserved(), MaxExecutableSize())) | 5325   if (!isolate_->memory_allocator()->SetUp(MaxReserved(), MaxExecutableSize())) | 
| 5373     return false; | 5326     return false; | 
| 5374 | 5327 | 
| 5375   // Set up new space. | 5328   // Set up new space. | 
| 5376   if (!new_space_.SetUp(reserved_semispace_size_, max_semi_space_size_)) { | 5329   if (!new_space_.SetUp(reserved_semispace_size_, max_semi_space_size_)) { | 
| 5377     return false; | 5330     return false; | 
| 5378   } | 5331   } | 
| 5379   new_space_top_after_last_gc_ = new_space()->top(); | 5332   new_space_top_after_last_gc_ = new_space()->top(); | 
| 5380 | 5333 | 
| 5381   // Initialize old pointer space. | 5334   // Initialize old space. | 
| 5382   old_pointer_space_ = new OldSpace(this, max_old_generation_size_, | 5335   old_space_ = | 
| 5383                                     OLD_POINTER_SPACE, NOT_EXECUTABLE); | 5336       new OldSpace(this, max_old_generation_size_, OLD_SPACE, NOT_EXECUTABLE); | 
| 5384   if (old_pointer_space_ == NULL) return false; | 5337   if (old_space_ == NULL) return false; | 
| 5385   if (!old_pointer_space_->SetUp()) return false; | 5338   if (!old_space_->SetUp()) return false; | 
| 5386 |  | 
| 5387   // Initialize old data space. |  | 
| 5388   old_data_space_ = new OldSpace(this, max_old_generation_size_, OLD_DATA_SPACE, |  | 
| 5389                                  NOT_EXECUTABLE); |  | 
| 5390   if (old_data_space_ == NULL) return false; |  | 
| 5391   if (!old_data_space_->SetUp()) return false; |  | 
| 5392 | 5339 | 
| 5393   if (!isolate_->code_range()->SetUp(code_range_size_)) return false; | 5340   if (!isolate_->code_range()->SetUp(code_range_size_)) return false; | 
| 5394 | 5341 | 
| 5395   // Initialize the code space, set its maximum capacity to the old | 5342   // Initialize the code space, set its maximum capacity to the old | 
| 5396   // generation size. It needs executable memory. | 5343   // generation size. It needs executable memory. | 
| 5397   code_space_ = | 5344   code_space_ = | 
| 5398       new OldSpace(this, max_old_generation_size_, CODE_SPACE, EXECUTABLE); | 5345       new OldSpace(this, max_old_generation_size_, CODE_SPACE, EXECUTABLE); | 
| 5399   if (code_space_ == NULL) return false; | 5346   if (code_space_ == NULL) return false; | 
| 5400   if (!code_space_->SetUp()) return false; | 5347   if (!code_space_->SetUp()) return false; | 
| 5401 | 5348 | 
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5510     PrintF("total_sweeping_time=%.1f ", tracer_.cumulative_sweeping_duration()); | 5457     PrintF("total_sweeping_time=%.1f ", tracer_.cumulative_sweeping_duration()); | 
| 5511     PrintF("\n\n"); | 5458     PrintF("\n\n"); | 
| 5512   } | 5459   } | 
| 5513 | 5460 | 
| 5514   if (FLAG_print_max_heap_committed) { | 5461   if (FLAG_print_max_heap_committed) { | 
| 5515     PrintF("\n"); | 5462     PrintF("\n"); | 
| 5516     PrintF("maximum_committed_by_heap=%" V8_PTR_PREFIX "d ", | 5463     PrintF("maximum_committed_by_heap=%" V8_PTR_PREFIX "d ", | 
| 5517            MaximumCommittedMemory()); | 5464            MaximumCommittedMemory()); | 
| 5518     PrintF("maximum_committed_by_new_space=%" V8_PTR_PREFIX "d ", | 5465     PrintF("maximum_committed_by_new_space=%" V8_PTR_PREFIX "d ", | 
| 5519            new_space_.MaximumCommittedMemory()); | 5466            new_space_.MaximumCommittedMemory()); | 
| 5520     PrintF("maximum_committed_by_old_pointer_space=%" V8_PTR_PREFIX "d ", | 5467     PrintF("maximum_committed_by_old_space=%" V8_PTR_PREFIX "d ", | 
| 5521            old_data_space_->MaximumCommittedMemory()); | 5468            old_space_->MaximumCommittedMemory()); | 
| 5522     PrintF("maximum_committed_by_old_data_space=%" V8_PTR_PREFIX "d ", |  | 
| 5523            old_pointer_space_->MaximumCommittedMemory()); |  | 
| 5524     PrintF("maximum_committed_by_old_data_space=%" V8_PTR_PREFIX "d ", |  | 
| 5525            old_pointer_space_->MaximumCommittedMemory()); |  | 
| 5526     PrintF("maximum_committed_by_code_space=%" V8_PTR_PREFIX "d ", | 5469     PrintF("maximum_committed_by_code_space=%" V8_PTR_PREFIX "d ", | 
| 5527            code_space_->MaximumCommittedMemory()); | 5470            code_space_->MaximumCommittedMemory()); | 
| 5528     PrintF("maximum_committed_by_map_space=%" V8_PTR_PREFIX "d ", | 5471     PrintF("maximum_committed_by_map_space=%" V8_PTR_PREFIX "d ", | 
| 5529            map_space_->MaximumCommittedMemory()); | 5472            map_space_->MaximumCommittedMemory()); | 
| 5530     PrintF("maximum_committed_by_cell_space=%" V8_PTR_PREFIX "d ", | 5473     PrintF("maximum_committed_by_cell_space=%" V8_PTR_PREFIX "d ", | 
| 5531            cell_space_->MaximumCommittedMemory()); | 5474            cell_space_->MaximumCommittedMemory()); | 
| 5532     PrintF("maximum_committed_by_property_space=%" V8_PTR_PREFIX "d ", | 5475     PrintF("maximum_committed_by_property_space=%" V8_PTR_PREFIX "d ", | 
| 5533            property_cell_space_->MaximumCommittedMemory()); | 5476            property_cell_space_->MaximumCommittedMemory()); | 
| 5534     PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ", | 5477     PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ", | 
| 5535            lo_space_->MaximumCommittedMemory()); | 5478            lo_space_->MaximumCommittedMemory()); | 
| 5536     PrintF("\n\n"); | 5479     PrintF("\n\n"); | 
| 5537   } | 5480   } | 
| 5538 | 5481 | 
| 5539   if (FLAG_verify_predictable) { | 5482   if (FLAG_verify_predictable) { | 
| 5540     PrintAlloctionsHash(); | 5483     PrintAlloctionsHash(); | 
| 5541   } | 5484   } | 
| 5542 | 5485 | 
| 5543   TearDownArrayBuffers(); | 5486   TearDownArrayBuffers(); | 
| 5544 | 5487 | 
| 5545   isolate_->global_handles()->TearDown(); | 5488   isolate_->global_handles()->TearDown(); | 
| 5546 | 5489 | 
| 5547   external_string_table_.TearDown(); | 5490   external_string_table_.TearDown(); | 
| 5548 | 5491 | 
| 5549   mark_compact_collector()->TearDown(); | 5492   mark_compact_collector()->TearDown(); | 
| 5550 | 5493 | 
| 5551   new_space_.TearDown(); | 5494   new_space_.TearDown(); | 
| 5552 | 5495 | 
| 5553   if (old_pointer_space_ != NULL) { | 5496   if (old_space_ != NULL) { | 
| 5554     old_pointer_space_->TearDown(); | 5497     old_space_->TearDown(); | 
| 5555     delete old_pointer_space_; | 5498     delete old_space_; | 
| 5556     old_pointer_space_ = NULL; | 5499     old_space_ = NULL; | 
| 5557   } |  | 
| 5558 |  | 
| 5559   if (old_data_space_ != NULL) { |  | 
| 5560     old_data_space_->TearDown(); |  | 
| 5561     delete old_data_space_; |  | 
| 5562     old_data_space_ = NULL; |  | 
| 5563   } | 5500   } | 
| 5564 | 5501 | 
| 5565   if (code_space_ != NULL) { | 5502   if (code_space_ != NULL) { | 
| 5566     code_space_->TearDown(); | 5503     code_space_->TearDown(); | 
| 5567     delete code_space_; | 5504     delete code_space_; | 
| 5568     code_space_ = NULL; | 5505     code_space_ = NULL; | 
| 5569   } | 5506   } | 
| 5570 | 5507 | 
| 5571   if (map_space_ != NULL) { | 5508   if (map_space_ != NULL) { | 
| 5572     map_space_->TearDown(); | 5509     map_space_->TearDown(); | 
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5694   isolate_->handle_scope_implementer()->Iterate(&v); | 5631   isolate_->handle_scope_implementer()->Iterate(&v); | 
| 5695 } | 5632 } | 
| 5696 | 5633 | 
| 5697 #endif | 5634 #endif | 
| 5698 | 5635 | 
| 5699 | 5636 | 
| 5700 Space* AllSpaces::next() { | 5637 Space* AllSpaces::next() { | 
| 5701   switch (counter_++) { | 5638   switch (counter_++) { | 
| 5702     case NEW_SPACE: | 5639     case NEW_SPACE: | 
| 5703       return heap_->new_space(); | 5640       return heap_->new_space(); | 
| 5704     case OLD_POINTER_SPACE: | 5641     case OLD_SPACE: | 
| 5705       return heap_->old_pointer_space(); | 5642       return heap_->old_space(); | 
| 5706     case OLD_DATA_SPACE: |  | 
| 5707       return heap_->old_data_space(); |  | 
| 5708     case CODE_SPACE: | 5643     case CODE_SPACE: | 
| 5709       return heap_->code_space(); | 5644       return heap_->code_space(); | 
| 5710     case MAP_SPACE: | 5645     case MAP_SPACE: | 
| 5711       return heap_->map_space(); | 5646       return heap_->map_space(); | 
| 5712     case CELL_SPACE: | 5647     case CELL_SPACE: | 
| 5713       return heap_->cell_space(); | 5648       return heap_->cell_space(); | 
| 5714     case PROPERTY_CELL_SPACE: | 5649     case PROPERTY_CELL_SPACE: | 
| 5715       return heap_->property_cell_space(); | 5650       return heap_->property_cell_space(); | 
| 5716     case LO_SPACE: | 5651     case LO_SPACE: | 
| 5717       return heap_->lo_space(); | 5652       return heap_->lo_space(); | 
| 5718     default: | 5653     default: | 
| 5719       return NULL; | 5654       return NULL; | 
| 5720   } | 5655   } | 
| 5721 } | 5656 } | 
| 5722 | 5657 | 
| 5723 | 5658 | 
| 5724 PagedSpace* PagedSpaces::next() { | 5659 PagedSpace* PagedSpaces::next() { | 
| 5725   switch (counter_++) { | 5660   switch (counter_++) { | 
| 5726     case OLD_POINTER_SPACE: | 5661     case OLD_SPACE: | 
| 5727       return heap_->old_pointer_space(); | 5662       return heap_->old_space(); | 
| 5728     case OLD_DATA_SPACE: |  | 
| 5729       return heap_->old_data_space(); |  | 
| 5730     case CODE_SPACE: | 5663     case CODE_SPACE: | 
| 5731       return heap_->code_space(); | 5664       return heap_->code_space(); | 
| 5732     case MAP_SPACE: | 5665     case MAP_SPACE: | 
| 5733       return heap_->map_space(); | 5666       return heap_->map_space(); | 
| 5734     case CELL_SPACE: | 5667     case CELL_SPACE: | 
| 5735       return heap_->cell_space(); | 5668       return heap_->cell_space(); | 
| 5736     case PROPERTY_CELL_SPACE: | 5669     case PROPERTY_CELL_SPACE: | 
| 5737       return heap_->property_cell_space(); | 5670       return heap_->property_cell_space(); | 
| 5738     default: | 5671     default: | 
| 5739       return NULL; | 5672       return NULL; | 
| 5740   } | 5673   } | 
| 5741 } | 5674 } | 
| 5742 | 5675 | 
| 5743 | 5676 | 
| 5744 OldSpace* OldSpaces::next() { | 5677 OldSpace* OldSpaces::next() { | 
| 5745   switch (counter_++) { | 5678   switch (counter_++) { | 
| 5746     case OLD_POINTER_SPACE: | 5679     case OLD_SPACE: | 
| 5747       return heap_->old_pointer_space(); | 5680       return heap_->old_space(); | 
| 5748     case OLD_DATA_SPACE: |  | 
| 5749       return heap_->old_data_space(); |  | 
| 5750     case CODE_SPACE: | 5681     case CODE_SPACE: | 
| 5751       return heap_->code_space(); | 5682       return heap_->code_space(); | 
| 5752     default: | 5683     default: | 
| 5753       return NULL; | 5684       return NULL; | 
| 5754   } | 5685   } | 
| 5755 } | 5686 } | 
| 5756 | 5687 | 
| 5757 | 5688 | 
| 5758 SpaceIterator::SpaceIterator(Heap* heap) | 5689 SpaceIterator::SpaceIterator(Heap* heap) | 
| 5759     : heap_(heap), | 5690     : heap_(heap), | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5798 | 5729 | 
| 5799 | 5730 | 
| 5800 // Create an iterator for the space to iterate. | 5731 // Create an iterator for the space to iterate. | 
| 5801 ObjectIterator* SpaceIterator::CreateIterator() { | 5732 ObjectIterator* SpaceIterator::CreateIterator() { | 
| 5802   DCHECK(iterator_ == NULL); | 5733   DCHECK(iterator_ == NULL); | 
| 5803 | 5734 | 
| 5804   switch (current_space_) { | 5735   switch (current_space_) { | 
| 5805     case NEW_SPACE: | 5736     case NEW_SPACE: | 
| 5806       iterator_ = new SemiSpaceIterator(heap_->new_space(), size_func_); | 5737       iterator_ = new SemiSpaceIterator(heap_->new_space(), size_func_); | 
| 5807       break; | 5738       break; | 
| 5808     case OLD_POINTER_SPACE: | 5739     case OLD_SPACE: | 
| 5809       iterator_ = | 5740       iterator_ = new HeapObjectIterator(heap_->old_space(), size_func_); | 
| 5810           new HeapObjectIterator(heap_->old_pointer_space(), size_func_); |  | 
| 5811       break; |  | 
| 5812     case OLD_DATA_SPACE: |  | 
| 5813       iterator_ = new HeapObjectIterator(heap_->old_data_space(), size_func_); |  | 
| 5814       break; | 5741       break; | 
| 5815     case CODE_SPACE: | 5742     case CODE_SPACE: | 
| 5816       iterator_ = new HeapObjectIterator(heap_->code_space(), size_func_); | 5743       iterator_ = new HeapObjectIterator(heap_->code_space(), size_func_); | 
| 5817       break; | 5744       break; | 
| 5818     case MAP_SPACE: | 5745     case MAP_SPACE: | 
| 5819       iterator_ = new HeapObjectIterator(heap_->map_space(), size_func_); | 5746       iterator_ = new HeapObjectIterator(heap_->map_space(), size_func_); | 
| 5820       break; | 5747       break; | 
| 5821     case CELL_SPACE: | 5748     case CELL_SPACE: | 
| 5822       iterator_ = new HeapObjectIterator(heap_->cell_space(), size_func_); | 5749       iterator_ = new HeapObjectIterator(heap_->cell_space(), size_func_); | 
| 5823       break; | 5750       break; | 
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 6449       static_cast<int>(object_sizes_last_time_[index])); | 6376       static_cast<int>(object_sizes_last_time_[index])); | 
| 6450   CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6377   CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 
| 6451 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6378 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 
| 6452 | 6379 | 
| 6453   MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6380   MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 
| 6454   MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6381   MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 
| 6455   ClearObjectStats(); | 6382   ClearObjectStats(); | 
| 6456 } | 6383 } | 
| 6457 } | 6384 } | 
| 6458 }  // namespace v8::internal | 6385 }  // namespace v8::internal | 
| OLD | NEW | 
|---|