Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: src/heap/spaces.cc

Issue 2304123003: [heap] Refactor incremental marking step. (Closed)
Patch Set: another fix of the test Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/memory-reducer.cc ('k') | test/cctest/heap/heap-utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2535 matching lines...) Expand 10 before | Expand all | Expand 10 after
2546 // allocation space has been set up with the top and limit of the space. If 2546 // allocation space has been set up with the top and limit of the space. If
2547 // the allocation fails then NULL is returned, and the caller can perform a GC 2547 // the allocation fails then NULL is returned, and the caller can perform a GC
2548 // or allocate a new page before retrying. 2548 // or allocate a new page before retrying.
2549 HeapObject* FreeList::Allocate(int size_in_bytes) { 2549 HeapObject* FreeList::Allocate(int size_in_bytes) {
2550 DCHECK(0 < size_in_bytes); 2550 DCHECK(0 < size_in_bytes);
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 int old_linear_size = static_cast<int>(owner_->limit() - owner_->top());
2557 // 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
2558 // 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
2559 // if it is big enough. 2558 // if it is big enough.
2560 owner_->EmptyAllocationInfo(); 2559 owner_->EmptyAllocationInfo();
2561 2560
2562 owner_->heap()->incremental_marking()->OldSpaceStep(size_in_bytes - 2561 owner_->heap()->StartIncrementalMarkingIfNeeded(
2563 old_linear_size); 2562 Heap::kNoGCFlags, kNoGCCallbackFlags, "old space step");
2564 2563
2565 int new_node_size = 0; 2564 int new_node_size = 0;
2566 FreeSpace* new_node = FindNodeFor(size_in_bytes, &new_node_size); 2565 FreeSpace* new_node = FindNodeFor(size_in_bytes, &new_node_size);
2567 if (new_node == nullptr) return nullptr; 2566 if (new_node == nullptr) return nullptr;
2568 2567
2569 int bytes_left = new_node_size - size_in_bytes; 2568 int bytes_left = new_node_size - size_in_bytes;
2570 DCHECK(bytes_left >= 0); 2569 DCHECK(bytes_left >= 0);
2571 2570
2572 #ifdef DEBUG 2571 #ifdef DEBUG
2573 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
2989 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(object->address(), object_size); 2988 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(object->address(), object_size);
2990 2989
2991 if (Heap::ShouldZapGarbage()) { 2990 if (Heap::ShouldZapGarbage()) {
2992 // 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.
2993 // 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.
2994 reinterpret_cast<Object**>(object->address())[0] = 2993 reinterpret_cast<Object**>(object->address())[0] =
2995 heap()->fixed_array_map(); 2994 heap()->fixed_array_map();
2996 reinterpret_cast<Object**>(object->address())[1] = Smi::FromInt(0); 2995 reinterpret_cast<Object**>(object->address())[1] = Smi::FromInt(0);
2997 } 2996 }
2998 2997
2999 heap()->incremental_marking()->OldSpaceStep(object_size); 2998 heap()->StartIncrementalMarkingIfNeeded(Heap::kNoGCFlags, kNoGCCallbackFlags,
2999 "old space step");
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
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
OLDNEW
« no previous file with comments | « src/heap/memory-reducer.cc ('k') | test/cctest/heap/heap-utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698