| 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 "v8.h" | 5 #include "v8.h" |
| 6 | 6 |
| 7 #include "accessors.h" | 7 #include "accessors.h" |
| 8 #include "api.h" | 8 #include "api.h" |
| 9 #include "bootstrapper.h" | 9 #include "bootstrapper.h" |
| 10 #include "codegen.h" | 10 #include "codegen.h" |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(property_cell_space) | 692 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(property_cell_space) |
| 693 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(lo_space) | 693 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(lo_space) |
| 694 #undef UPDATE_COUNTERS_FOR_SPACE | 694 #undef UPDATE_COUNTERS_FOR_SPACE |
| 695 #undef UPDATE_FRAGMENTATION_FOR_SPACE | 695 #undef UPDATE_FRAGMENTATION_FOR_SPACE |
| 696 #undef UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE | 696 #undef UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE |
| 697 | 697 |
| 698 #ifdef DEBUG | 698 #ifdef DEBUG |
| 699 ReportStatisticsAfterGC(); | 699 ReportStatisticsAfterGC(); |
| 700 #endif // DEBUG | 700 #endif // DEBUG |
| 701 isolate_->debug()->AfterGarbageCollection(); | 701 isolate_->debug()->AfterGarbageCollection(); |
| 702 |
| 703 // Remember the last top pointer so that we can later find out |
| 704 // whether we allocated in new space since the last GC. |
| 705 new_space_top_after_last_gc_ = new_space()->top(); |
| 702 } | 706 } |
| 703 | 707 |
| 704 | 708 |
| 705 void Heap::CollectAllGarbage(int flags, | 709 void Heap::CollectAllGarbage(int flags, |
| 706 const char* gc_reason, | 710 const char* gc_reason, |
| 707 const v8::GCCallbackFlags gc_callback_flags) { | 711 const v8::GCCallbackFlags gc_callback_flags) { |
| 708 // Since we are ignoring the return value, the exact choice of space does | 712 // Since we are ignoring the return value, the exact choice of space does |
| 709 // not matter, so long as we do not specify NEW_SPACE, which would not | 713 // not matter, so long as we do not specify NEW_SPACE, which would not |
| 710 // cause a full GC. | 714 // cause a full GC. |
| 711 mark_compact_collector_.SetFlags(flags); | 715 mark_compact_collector_.SetFlags(flags); |
| (...skipping 3602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4314 { AllocationResult allocation = Allocate(map, space); | 4318 { AllocationResult allocation = Allocate(map, space); |
| 4315 if (!allocation.To(&result)) return allocation; | 4319 if (!allocation.To(&result)) return allocation; |
| 4316 } | 4320 } |
| 4317 result->InitializeBody(size); | 4321 result->InitializeBody(size); |
| 4318 return result; | 4322 return result; |
| 4319 } | 4323 } |
| 4320 | 4324 |
| 4321 | 4325 |
| 4322 bool Heap::IsHeapIterable() { | 4326 bool Heap::IsHeapIterable() { |
| 4323 return (!old_pointer_space()->was_swept_conservatively() && | 4327 return (!old_pointer_space()->was_swept_conservatively() && |
| 4324 !old_data_space()->was_swept_conservatively()); | 4328 !old_data_space()->was_swept_conservatively() && |
| 4329 new_space_top_after_last_gc_ == new_space()->top()); |
| 4325 } | 4330 } |
| 4326 | 4331 |
| 4327 | 4332 |
| 4328 void Heap::EnsureHeapIsIterable() { | 4333 void Heap::MakeHeapIterable() { |
| 4329 ASSERT(AllowHeapAllocation::IsAllowed()); | 4334 ASSERT(AllowHeapAllocation::IsAllowed()); |
| 4330 if (!IsHeapIterable()) { | 4335 if (!IsHeapIterable()) { |
| 4331 CollectAllGarbage(kMakeHeapIterableMask, "Heap::EnsureHeapIsIterable"); | 4336 CollectAllGarbage(kMakeHeapIterableMask, "Heap::MakeHeapIterable"); |
| 4332 } | 4337 } |
| 4333 ASSERT(IsHeapIterable()); | 4338 ASSERT(IsHeapIterable()); |
| 4334 } | 4339 } |
| 4335 | 4340 |
| 4336 | 4341 |
| 4337 void Heap::AdvanceIdleIncrementalMarking(intptr_t step_size) { | 4342 void Heap::AdvanceIdleIncrementalMarking(intptr_t step_size) { |
| 4338 incremental_marking()->Step(step_size, | 4343 incremental_marking()->Step(step_size, |
| 4339 IncrementalMarking::NO_GC_VIA_STACK_GUARD); | 4344 IncrementalMarking::NO_GC_VIA_STACK_GUARD); |
| 4340 | 4345 |
| 4341 if (incremental_marking()->IsComplete()) { | 4346 if (incremental_marking()->IsComplete()) { |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5201 MarkMapPointersAsEncoded(false); | 5206 MarkMapPointersAsEncoded(false); |
| 5202 | 5207 |
| 5203 // Set up memory allocator. | 5208 // Set up memory allocator. |
| 5204 if (!isolate_->memory_allocator()->SetUp(MaxReserved(), MaxExecutableSize())) | 5209 if (!isolate_->memory_allocator()->SetUp(MaxReserved(), MaxExecutableSize())) |
| 5205 return false; | 5210 return false; |
| 5206 | 5211 |
| 5207 // Set up new space. | 5212 // Set up new space. |
| 5208 if (!new_space_.SetUp(reserved_semispace_size_, max_semi_space_size_)) { | 5213 if (!new_space_.SetUp(reserved_semispace_size_, max_semi_space_size_)) { |
| 5209 return false; | 5214 return false; |
| 5210 } | 5215 } |
| 5216 new_space_top_after_last_gc_ = new_space()->top(); |
| 5211 | 5217 |
| 5212 // Initialize old pointer space. | 5218 // Initialize old pointer space. |
| 5213 old_pointer_space_ = | 5219 old_pointer_space_ = |
| 5214 new OldSpace(this, | 5220 new OldSpace(this, |
| 5215 max_old_generation_size_, | 5221 max_old_generation_size_, |
| 5216 OLD_POINTER_SPACE, | 5222 OLD_POINTER_SPACE, |
| 5217 NOT_EXECUTABLE); | 5223 NOT_EXECUTABLE); |
| 5218 if (old_pointer_space_ == NULL) return false; | 5224 if (old_pointer_space_ == NULL) return false; |
| 5219 if (!old_pointer_space_->SetUp()) return false; | 5225 if (!old_pointer_space_->SetUp()) return false; |
| 5220 | 5226 |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5724 heap_->IterateRoots(&visitor, VISIT_ALL); | 5730 heap_->IterateRoots(&visitor, VISIT_ALL); |
| 5725 visitor.TransitiveClosure(); | 5731 visitor.TransitiveClosure(); |
| 5726 } | 5732 } |
| 5727 | 5733 |
| 5728 Heap* heap_; | 5734 Heap* heap_; |
| 5729 DisallowHeapAllocation no_allocation_; | 5735 DisallowHeapAllocation no_allocation_; |
| 5730 }; | 5736 }; |
| 5731 | 5737 |
| 5732 | 5738 |
| 5733 HeapIterator::HeapIterator(Heap* heap) | 5739 HeapIterator::HeapIterator(Heap* heap) |
| 5734 : heap_(heap), | 5740 : make_heap_iterable_helper_(heap), |
| 5741 no_heap_allocation_(), |
| 5742 heap_(heap), |
| 5735 filtering_(HeapIterator::kNoFiltering), | 5743 filtering_(HeapIterator::kNoFiltering), |
| 5736 filter_(NULL) { | 5744 filter_(NULL) { |
| 5737 Init(); | 5745 Init(); |
| 5738 } | 5746 } |
| 5739 | 5747 |
| 5740 | 5748 |
| 5741 HeapIterator::HeapIterator(Heap* heap, | 5749 HeapIterator::HeapIterator(Heap* heap, |
| 5742 HeapIterator::HeapObjectsFiltering filtering) | 5750 HeapIterator::HeapObjectsFiltering filtering) |
| 5743 : heap_(heap), | 5751 : make_heap_iterable_helper_(heap), |
| 5752 no_heap_allocation_(), |
| 5753 heap_(heap), |
| 5744 filtering_(filtering), | 5754 filtering_(filtering), |
| 5745 filter_(NULL) { | 5755 filter_(NULL) { |
| 5746 Init(); | 5756 Init(); |
| 5747 } | 5757 } |
| 5748 | 5758 |
| 5749 | 5759 |
| 5750 HeapIterator::~HeapIterator() { | 5760 HeapIterator::~HeapIterator() { |
| 5751 Shutdown(); | 5761 Shutdown(); |
| 5752 } | 5762 } |
| 5753 | 5763 |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6482 static_cast<int>(object_sizes_last_time_[index])); | 6492 static_cast<int>(object_sizes_last_time_[index])); |
| 6483 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6493 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 6484 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6494 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 6485 | 6495 |
| 6486 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6496 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 6487 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6497 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 6488 ClearObjectStats(); | 6498 ClearObjectStats(); |
| 6489 } | 6499 } |
| 6490 | 6500 |
| 6491 } } // namespace v8::internal | 6501 } } // namespace v8::internal |
| OLD | NEW |