| 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(); |
| 2584 | 2593 |
| 2585 size_t new_node_size = 0; | 2594 size_t new_node_size = 0; |
| 2586 FreeSpace* new_node = FindNodeFor(size_in_bytes, &new_node_size); | 2595 FreeSpace* new_node = FindNodeFor(size_in_bytes, &new_node_size); |
| 2587 if (new_node == nullptr) return nullptr; | 2596 if (new_node == nullptr) return nullptr; |
| 2588 | 2597 |
| 2589 DCHECK_GE(new_node_size, size_in_bytes); | 2598 DCHECK_GE(new_node_size, size_in_bytes); |
| 2590 size_t bytes_left = new_node_size - size_in_bytes; | 2599 size_t bytes_left = new_node_size - size_in_bytes; |
| 2591 | 2600 |
| 2592 #ifdef DEBUG | 2601 #ifdef DEBUG |
| 2593 for (size_t i = 0; i < size_in_bytes / kPointerSize; i++) { | 2602 for (size_t i = 0; i < size_in_bytes / kPointerSize; i++) { |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3003 if (Heap::ShouldZapGarbage()) { | 3012 if (Heap::ShouldZapGarbage()) { |
| 3004 // Make the object consistent so the heap can be verified in OldSpaceStep. | 3013 // Make the object consistent so the heap can be verified in OldSpaceStep. |
| 3005 // We only need to do this in debug builds or if verify_heap is on. | 3014 // We only need to do this in debug builds or if verify_heap is on. |
| 3006 reinterpret_cast<Object**>(object->address())[0] = | 3015 reinterpret_cast<Object**>(object->address())[0] = |
| 3007 heap()->fixed_array_map(); | 3016 heap()->fixed_array_map(); |
| 3008 reinterpret_cast<Object**>(object->address())[1] = Smi::kZero; | 3017 reinterpret_cast<Object**>(object->address())[1] = Smi::kZero; |
| 3009 } | 3018 } |
| 3010 | 3019 |
| 3011 heap()->StartIncrementalMarkingIfAllocationLimitIsReached(Heap::kNoGCFlags, | 3020 heap()->StartIncrementalMarkingIfAllocationLimitIsReached(Heap::kNoGCFlags, |
| 3012 kNoGCCallbackFlags); | 3021 kNoGCCallbackFlags); |
| 3022 heap()->incremental_marking()->AdvanceIncrementalMarkingOnAllocation(); |
| 3023 |
| 3013 AllocationStep(object->address(), object_size); | 3024 AllocationStep(object->address(), object_size); |
| 3014 | 3025 |
| 3015 if (heap()->incremental_marking()->black_allocation()) { | 3026 if (heap()->incremental_marking()->black_allocation()) { |
| 3016 Marking::MarkBlack(ObjectMarking::MarkBitFrom(object)); | 3027 Marking::MarkBlack(ObjectMarking::MarkBitFrom(object)); |
| 3017 MemoryChunk::IncrementLiveBytesFromGC(object, object_size); | 3028 MemoryChunk::IncrementLiveBytesFromGC(object, object_size); |
| 3018 } | 3029 } |
| 3019 return object; | 3030 return object; |
| 3020 } | 3031 } |
| 3021 | 3032 |
| 3022 | 3033 |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3245 object->ShortPrint(); | 3256 object->ShortPrint(); |
| 3246 PrintF("\n"); | 3257 PrintF("\n"); |
| 3247 } | 3258 } |
| 3248 printf(" --------------------------------------\n"); | 3259 printf(" --------------------------------------\n"); |
| 3249 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3260 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3250 } | 3261 } |
| 3251 | 3262 |
| 3252 #endif // DEBUG | 3263 #endif // DEBUG |
| 3253 } // namespace internal | 3264 } // namespace internal |
| 3254 } // namespace v8 | 3265 } // namespace v8 |
| OLD | NEW |