| 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 2540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2551 DCHECK(size_in_bytes <= kMaxBlockSize); | 2551 DCHECK(size_in_bytes <= kMaxBlockSize); |
| 2552 DCHECK(IsAligned(size_in_bytes, kPointerSize)); | 2552 DCHECK(IsAligned(size_in_bytes, kPointerSize)); |
| 2553 // Don't free list allocate if there is linear space available. | 2553 // Don't free list allocate if there is linear space available. |
| 2554 DCHECK(owner_->limit() - owner_->top() < size_in_bytes); | 2554 DCHECK(owner_->limit() - owner_->top() < size_in_bytes); |
| 2555 | 2555 |
| 2556 // Mark the old linear allocation area with a free space map so it can be | 2556 // Mark the old linear allocation area with a free space map so it can be |
| 2557 // skipped when scanning the heap. This also puts it back in the free list | 2557 // skipped when scanning the heap. This also puts it back in the free list |
| 2558 // if it is big enough. | 2558 // if it is big enough. |
| 2559 owner_->EmptyAllocationInfo(); | 2559 owner_->EmptyAllocationInfo(); |
| 2560 | 2560 |
| 2561 owner_->heap()->StartIncrementalMarkingIfNeeded( | 2561 owner_->heap()->StartIncrementalMarkingIfAllocationLimitIsReached( |
| 2562 Heap::kNoGCFlags, kNoGCCallbackFlags, "old space step"); | 2562 Heap::kNoGCFlags, kNoGCCallbackFlags); |
| 2563 | 2563 |
| 2564 int new_node_size = 0; | 2564 int new_node_size = 0; |
| 2565 FreeSpace* new_node = FindNodeFor(size_in_bytes, &new_node_size); | 2565 FreeSpace* new_node = FindNodeFor(size_in_bytes, &new_node_size); |
| 2566 if (new_node == nullptr) return nullptr; | 2566 if (new_node == nullptr) return nullptr; |
| 2567 | 2567 |
| 2568 int bytes_left = new_node_size - size_in_bytes; | 2568 int bytes_left = new_node_size - size_in_bytes; |
| 2569 DCHECK(bytes_left >= 0); | 2569 DCHECK(bytes_left >= 0); |
| 2570 | 2570 |
| 2571 #ifdef DEBUG | 2571 #ifdef DEBUG |
| 2572 for (int i = 0; i < size_in_bytes / kPointerSize; i++) { | 2572 for (int i = 0; i < size_in_bytes / kPointerSize; i++) { |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2988 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(object->address(), object_size); | 2988 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(object->address(), object_size); |
| 2989 | 2989 |
| 2990 if (Heap::ShouldZapGarbage()) { | 2990 if (Heap::ShouldZapGarbage()) { |
| 2991 // Make the object consistent so the heap can be verified in OldSpaceStep. | 2991 // Make the object consistent so the heap can be verified in OldSpaceStep. |
| 2992 // We only need to do this in debug builds or if verify_heap is on. | 2992 // We only need to do this in debug builds or if verify_heap is on. |
| 2993 reinterpret_cast<Object**>(object->address())[0] = | 2993 reinterpret_cast<Object**>(object->address())[0] = |
| 2994 heap()->fixed_array_map(); | 2994 heap()->fixed_array_map(); |
| 2995 reinterpret_cast<Object**>(object->address())[1] = Smi::FromInt(0); | 2995 reinterpret_cast<Object**>(object->address())[1] = Smi::FromInt(0); |
| 2996 } | 2996 } |
| 2997 | 2997 |
| 2998 heap()->StartIncrementalMarkingIfNeeded(Heap::kNoGCFlags, kNoGCCallbackFlags, | 2998 heap()->StartIncrementalMarkingIfAllocationLimitIsReached(Heap::kNoGCFlags, |
| 2999 "old space step"); | 2999 kNoGCCallbackFlags); |
| 3000 AllocationStep(object->address(), object_size); | 3000 AllocationStep(object->address(), object_size); |
| 3001 | 3001 |
| 3002 if (heap()->incremental_marking()->black_allocation()) { | 3002 if (heap()->incremental_marking()->black_allocation()) { |
| 3003 Marking::MarkBlack(ObjectMarking::MarkBitFrom(object)); | 3003 Marking::MarkBlack(ObjectMarking::MarkBitFrom(object)); |
| 3004 MemoryChunk::IncrementLiveBytesFromGC(object, object_size); | 3004 MemoryChunk::IncrementLiveBytesFromGC(object, object_size); |
| 3005 } | 3005 } |
| 3006 return object; | 3006 return object; |
| 3007 } | 3007 } |
| 3008 | 3008 |
| 3009 | 3009 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3229 object->ShortPrint(); | 3229 object->ShortPrint(); |
| 3230 PrintF("\n"); | 3230 PrintF("\n"); |
| 3231 } | 3231 } |
| 3232 printf(" --------------------------------------\n"); | 3232 printf(" --------------------------------------\n"); |
| 3233 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3233 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3234 } | 3234 } |
| 3235 | 3235 |
| 3236 #endif // DEBUG | 3236 #endif // DEBUG |
| 3237 } // namespace internal | 3237 } // namespace internal |
| 3238 } // namespace v8 | 3238 } // namespace v8 |
| OLD | NEW |