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/once.h" | 9 #include "src/base/once.h" |
10 #include "src/base/utils/random-number-generator.h" | 10 #include "src/base/utils/random-number-generator.h" |
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 | 1271 |
1272 static void VerifyNonPointerSpacePointers(Heap* heap) { | 1272 static void VerifyNonPointerSpacePointers(Heap* heap) { |
1273 // Verify that there are no pointers to new space in spaces where we | 1273 // Verify that there are no pointers to new space in spaces where we |
1274 // do not expect them. | 1274 // do not expect them. |
1275 VerifyNonPointerSpacePointersVisitor v(heap); | 1275 VerifyNonPointerSpacePointersVisitor v(heap); |
1276 HeapObjectIterator code_it(heap->code_space()); | 1276 HeapObjectIterator code_it(heap->code_space()); |
1277 for (HeapObject* object = code_it.Next(); object != NULL; | 1277 for (HeapObject* object = code_it.Next(); object != NULL; |
1278 object = code_it.Next()) | 1278 object = code_it.Next()) |
1279 object->Iterate(&v); | 1279 object->Iterate(&v); |
1280 | 1280 |
1281 // The old data space was normally swept conservatively so that the iterator | |
1282 // doesn't work, so we normally skip the next bit. | |
1283 if (heap->old_data_space()->swept_precisely()) { | |
1284 HeapObjectIterator data_it(heap->old_data_space()); | 1281 HeapObjectIterator data_it(heap->old_data_space()); |
1285 for (HeapObject* object = data_it.Next(); object != NULL; | 1282 for (HeapObject* object = data_it.Next(); object != NULL; |
1286 object = data_it.Next()) | 1283 object = data_it.Next()) |
1287 object->Iterate(&v); | 1284 object->Iterate(&v); |
1288 } | |
1289 } | 1285 } |
1290 #endif // VERIFY_HEAP | 1286 #endif // VERIFY_HEAP |
1291 | 1287 |
1292 | 1288 |
1293 void Heap::CheckNewSpaceExpansionCriteria() { | 1289 void Heap::CheckNewSpaceExpansionCriteria() { |
1294 if (new_space_.Capacity() < new_space_.MaximumCapacity() && | 1290 if (new_space_.Capacity() < new_space_.MaximumCapacity() && |
1295 survived_since_last_expansion_ > new_space_.Capacity()) { | 1291 survived_since_last_expansion_ > new_space_.Capacity()) { |
1296 // Grow the size of new space if there is room to grow, enough data | 1292 // Grow the size of new space if there is room to grow, enough data |
1297 // has survived scavenge since the last expansion and we are not in | 1293 // has survived scavenge since the last expansion and we are not in |
1298 // high promotion mode. | 1294 // high promotion mode. |
(...skipping 2940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4239 if (!allocation.To(&result)) return allocation; | 4235 if (!allocation.To(&result)) return allocation; |
4240 } | 4236 } |
4241 result->InitializeBody(size); | 4237 result->InitializeBody(size); |
4242 return result; | 4238 return result; |
4243 } | 4239 } |
4244 | 4240 |
4245 | 4241 |
4246 bool Heap::IsHeapIterable() { | 4242 bool Heap::IsHeapIterable() { |
4247 // TODO(hpayer): This function is not correct. Allocation folding in old | 4243 // TODO(hpayer): This function is not correct. Allocation folding in old |
4248 // space breaks the iterability. | 4244 // space breaks the iterability. |
4249 return (old_pointer_space()->swept_precisely() && | 4245 return new_space_top_after_last_gc_ == new_space()->top(); |
4250 old_data_space()->swept_precisely() && | |
4251 new_space_top_after_last_gc_ == new_space()->top()); | |
4252 } | 4246 } |
4253 | 4247 |
4254 | 4248 |
4255 void Heap::MakeHeapIterable() { | 4249 void Heap::MakeHeapIterable() { |
4256 DCHECK(AllowHeapAllocation::IsAllowed()); | 4250 DCHECK(AllowHeapAllocation::IsAllowed()); |
4257 if (!IsHeapIterable()) { | 4251 if (!IsHeapIterable()) { |
4258 CollectAllGarbage(kMakeHeapIterableMask, "Heap::MakeHeapIterable"); | 4252 CollectAllGarbage(kMakeHeapIterableMask, "Heap::MakeHeapIterable"); |
4259 } | 4253 } |
4260 if (mark_compact_collector()->sweeping_in_progress()) { | 4254 if (mark_compact_collector()->sweeping_in_progress()) { |
4261 mark_compact_collector()->EnsureSweepingCompleted(); | 4255 mark_compact_collector()->EnsureSweepingCompleted(); |
(...skipping 1881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6143 static_cast<int>(object_sizes_last_time_[index])); | 6137 static_cast<int>(object_sizes_last_time_[index])); |
6144 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6138 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
6145 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6139 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
6146 | 6140 |
6147 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6141 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
6148 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6142 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
6149 ClearObjectStats(); | 6143 ClearObjectStats(); |
6150 } | 6144 } |
6151 } | 6145 } |
6152 } // namespace v8::internal | 6146 } // namespace v8::internal |
OLD | NEW |