Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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/heap/spaces.h" | 5 #include "src/heap/spaces.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
| (...skipping 2471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2482 // allocation space has been set up with the top and limit of the space. If | 2482 // allocation space has been set up with the top and limit of the space. If |
| 2483 // the allocation fails then NULL is returned, and the caller can perform a GC | 2483 // the allocation fails then NULL is returned, and the caller can perform a GC |
| 2484 // or allocate a new page before retrying. | 2484 // or allocate a new page before retrying. |
| 2485 HeapObject* FreeList::Allocate(int size_in_bytes) { | 2485 HeapObject* FreeList::Allocate(int size_in_bytes) { |
| 2486 DCHECK(0 < size_in_bytes); | 2486 DCHECK(0 < size_in_bytes); |
| 2487 DCHECK(size_in_bytes <= kMaxBlockSize); | 2487 DCHECK(size_in_bytes <= kMaxBlockSize); |
| 2488 DCHECK(IsAligned(size_in_bytes, kPointerSize)); | 2488 DCHECK(IsAligned(size_in_bytes, kPointerSize)); |
| 2489 // Don't free list allocate if there is linear space available. | 2489 // Don't free list allocate if there is linear space available. |
| 2490 DCHECK(owner_->limit() - owner_->top() < size_in_bytes); | 2490 DCHECK(owner_->limit() - owner_->top() < size_in_bytes); |
| 2491 | 2491 |
| 2492 int old_linear_size = static_cast<int>(owner_->limit() - owner_->top()); | |
| 2493 // Mark the old linear allocation area with a free space map so it can be | 2492 // Mark the old linear allocation area with a free space map so it can be |
| 2494 // skipped when scanning the heap. This also puts it back in the free list | 2493 // skipped when scanning the heap. This also puts it back in the free list |
| 2495 // if it is big enough. | 2494 // if it is big enough. |
| 2496 owner_->EmptyAllocationInfo(); | 2495 owner_->EmptyAllocationInfo(); |
| 2497 | 2496 |
| 2498 owner_->heap()->incremental_marking()->OldSpaceStep(size_in_bytes - | 2497 owner_->heap()->StartIncrementalMarkingIfNeeded( |
| 2499 old_linear_size); | 2498 Heap::kNoGCFlags, kNoGCCallbackFlags, "old space step"); |
|
Michael Lippautz
2016/09/02 19:05:19
Previously this would also do a step if marking ha
ulan
2016/09/05 08:02:23
Marking progress is ensured by the allocation obse
| |
| 2500 | 2499 |
| 2501 int new_node_size = 0; | 2500 int new_node_size = 0; |
| 2502 FreeSpace* new_node = FindNodeFor(size_in_bytes, &new_node_size); | 2501 FreeSpace* new_node = FindNodeFor(size_in_bytes, &new_node_size); |
| 2503 if (new_node == nullptr) return nullptr; | 2502 if (new_node == nullptr) return nullptr; |
| 2504 | 2503 |
| 2505 int bytes_left = new_node_size - size_in_bytes; | 2504 int bytes_left = new_node_size - size_in_bytes; |
| 2506 DCHECK(bytes_left >= 0); | 2505 DCHECK(bytes_left >= 0); |
| 2507 | 2506 |
| 2508 #ifdef DEBUG | 2507 #ifdef DEBUG |
| 2509 for (int i = 0; i < size_in_bytes / kPointerSize; i++) { | 2508 for (int i = 0; i < size_in_bytes / kPointerSize; i++) { |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2925 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(object->address(), object_size); | 2924 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(object->address(), object_size); |
| 2926 | 2925 |
| 2927 if (Heap::ShouldZapGarbage()) { | 2926 if (Heap::ShouldZapGarbage()) { |
| 2928 // Make the object consistent so the heap can be verified in OldSpaceStep. | 2927 // Make the object consistent so the heap can be verified in OldSpaceStep. |
| 2929 // We only need to do this in debug builds or if verify_heap is on. | 2928 // We only need to do this in debug builds or if verify_heap is on. |
| 2930 reinterpret_cast<Object**>(object->address())[0] = | 2929 reinterpret_cast<Object**>(object->address())[0] = |
| 2931 heap()->fixed_array_map(); | 2930 heap()->fixed_array_map(); |
| 2932 reinterpret_cast<Object**>(object->address())[1] = Smi::FromInt(0); | 2931 reinterpret_cast<Object**>(object->address())[1] = Smi::FromInt(0); |
| 2933 } | 2932 } |
| 2934 | 2933 |
| 2935 heap()->incremental_marking()->OldSpaceStep(object_size); | 2934 heap()->StartIncrementalMarkingIfNeeded(Heap::kNoGCFlags, kNoGCCallbackFlags, |
| 2935 "old space step"); | |
| 2936 AllocationStep(object->address(), object_size); | 2936 AllocationStep(object->address(), object_size); |
| 2937 | 2937 |
| 2938 if (heap()->incremental_marking()->black_allocation()) { | 2938 if (heap()->incremental_marking()->black_allocation()) { |
| 2939 Marking::MarkBlack(ObjectMarking::MarkBitFrom(object)); | 2939 Marking::MarkBlack(ObjectMarking::MarkBitFrom(object)); |
| 2940 MemoryChunk::IncrementLiveBytesFromGC(object, object_size); | 2940 MemoryChunk::IncrementLiveBytesFromGC(object, object_size); |
| 2941 } | 2941 } |
| 2942 return object; | 2942 return object; |
| 2943 } | 2943 } |
| 2944 | 2944 |
| 2945 | 2945 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3165 object->ShortPrint(); | 3165 object->ShortPrint(); |
| 3166 PrintF("\n"); | 3166 PrintF("\n"); |
| 3167 } | 3167 } |
| 3168 printf(" --------------------------------------\n"); | 3168 printf(" --------------------------------------\n"); |
| 3169 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3169 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3170 } | 3170 } |
| 3171 | 3171 |
| 3172 #endif // DEBUG | 3172 #endif // DEBUG |
| 3173 } // namespace internal | 3173 } // namespace internal |
| 3174 } // namespace v8 | 3174 } // namespace v8 |
| OLD | NEW |