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 2563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2574 DCHECK_LT(static_cast<size_t>(owner_->limit() - owner_->top()), | 2574 DCHECK_LT(static_cast<size_t>(owner_->limit() - owner_->top()), |
2575 size_in_bytes); | 2575 size_in_bytes); |
2576 | 2576 |
2577 // Mark the old linear allocation area with a free space map so it can be | 2577 // Mark the old linear allocation area with a free space map so it can be |
2578 // skipped when scanning the heap. This also puts it back in the free list | 2578 // skipped when scanning the heap. This also puts it back in the free list |
2579 // if it is big enough. | 2579 // if it is big enough. |
2580 owner_->EmptyAllocationInfo(); | 2580 owner_->EmptyAllocationInfo(); |
2581 | 2581 |
2582 owner_->heap()->StartIncrementalMarkingIfAllocationLimitIsReached( | 2582 owner_->heap()->StartIncrementalMarkingIfAllocationLimitIsReached( |
2583 Heap::kNoGCFlags, kNoGCCallbackFlags); | 2583 Heap::kNoGCFlags, kNoGCCallbackFlags); |
2584 // We cannot place incremental marking step in an AllocationObserver because | |
2585 // 1) incremental marking step can change linear allocation area. | |
2586 // 2) allocation observers are called after allocation. | |
2587 // 3) allocation folding assumes that the newly allocated object immediately | |
2588 // precedes the linear allocation area. | |
2589 // See crbug.com/659165. | |
2590 owner_->heap() | |
2591 ->incremental_marking() | |
2592 ->AdvanceIncrementalMarkingOnAllocation(); | |
2593 | 2584 |
2594 size_t new_node_size = 0; | 2585 size_t new_node_size = 0; |
2595 FreeSpace* new_node = FindNodeFor(size_in_bytes, &new_node_size); | 2586 FreeSpace* new_node = FindNodeFor(size_in_bytes, &new_node_size); |
2596 if (new_node == nullptr) return nullptr; | 2587 if (new_node == nullptr) return nullptr; |
2597 | 2588 |
2598 DCHECK_GE(new_node_size, size_in_bytes); | 2589 DCHECK_GE(new_node_size, size_in_bytes); |
2599 size_t bytes_left = new_node_size - size_in_bytes; | 2590 size_t bytes_left = new_node_size - size_in_bytes; |
2600 | 2591 |
2601 #ifdef DEBUG | 2592 #ifdef DEBUG |
2602 for (size_t i = 0; i < size_in_bytes / kPointerSize; i++) { | 2593 for (size_t i = 0; i < size_in_bytes / kPointerSize; i++) { |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3012 if (Heap::ShouldZapGarbage()) { | 3003 if (Heap::ShouldZapGarbage()) { |
3013 // Make the object consistent so the heap can be verified in OldSpaceStep. | 3004 // Make the object consistent so the heap can be verified in OldSpaceStep. |
3014 // We only need to do this in debug builds or if verify_heap is on. | 3005 // We only need to do this in debug builds or if verify_heap is on. |
3015 reinterpret_cast<Object**>(object->address())[0] = | 3006 reinterpret_cast<Object**>(object->address())[0] = |
3016 heap()->fixed_array_map(); | 3007 heap()->fixed_array_map(); |
3017 reinterpret_cast<Object**>(object->address())[1] = Smi::kZero; | 3008 reinterpret_cast<Object**>(object->address())[1] = Smi::kZero; |
3018 } | 3009 } |
3019 | 3010 |
3020 heap()->StartIncrementalMarkingIfAllocationLimitIsReached(Heap::kNoGCFlags, | 3011 heap()->StartIncrementalMarkingIfAllocationLimitIsReached(Heap::kNoGCFlags, |
3021 kNoGCCallbackFlags); | 3012 kNoGCCallbackFlags); |
3022 heap()->incremental_marking()->AdvanceIncrementalMarkingOnAllocation(); | |
3023 | |
3024 AllocationStep(object->address(), object_size); | 3013 AllocationStep(object->address(), object_size); |
3025 | 3014 |
3026 if (heap()->incremental_marking()->black_allocation()) { | 3015 if (heap()->incremental_marking()->black_allocation()) { |
3027 Marking::MarkBlack(ObjectMarking::MarkBitFrom(object)); | 3016 Marking::MarkBlack(ObjectMarking::MarkBitFrom(object)); |
3028 MemoryChunk::IncrementLiveBytesFromGC(object, object_size); | 3017 MemoryChunk::IncrementLiveBytesFromGC(object, object_size); |
3029 } | 3018 } |
3030 return object; | 3019 return object; |
3031 } | 3020 } |
3032 | 3021 |
3033 | 3022 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3256 object->ShortPrint(); | 3245 object->ShortPrint(); |
3257 PrintF("\n"); | 3246 PrintF("\n"); |
3258 } | 3247 } |
3259 printf(" --------------------------------------\n"); | 3248 printf(" --------------------------------------\n"); |
3260 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3249 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3261 } | 3250 } |
3262 | 3251 |
3263 #endif // DEBUG | 3252 #endif // DEBUG |
3264 } // namespace internal | 3253 } // namespace internal |
3265 } // namespace v8 | 3254 } // namespace v8 |
OLD | NEW |