1 // Copyright 2012 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef V8_HEAP_INCREMENTAL_MARKING_INL_H_ 6 #define V8_HEAP_INCREMENTAL_MARKING_INL_H_ 7 8 #include "src/heap/incremental-marking.h" 9 10 #include "src/execution/isolate.h" 11 #include "src/heap/mark-compact-inl.h" 12 #include "src/objects/maybe-object.h" 13 #include "src/objects/objects-inl.h" 14 15 namespace v8 { 16 namespace internal { 17 TransferColor(HeapObject from,HeapObject to)18void IncrementalMarking::TransferColor(HeapObject from, HeapObject to) { 19 if (atomic_marking_state()->IsBlack(to)) { 20 DCHECK(black_allocation()); 21 return; 22 } 23 24 DCHECK(atomic_marking_state()->IsWhite(to)); 25 if (atomic_marking_state()->IsGrey(from)) { 26 bool success = atomic_marking_state()->WhiteToGrey(to); 27 DCHECK(success); 28 USE(success); 29 } else if (atomic_marking_state()->IsBlack(from)) { 30 bool success = atomic_marking_state()->WhiteToBlack(to); 31 DCHECK(success); 32 USE(success); 33 } 34 } 35 WhiteToGreyAndPush(HeapObject obj)36bool IncrementalMarking::WhiteToGreyAndPush(HeapObject obj) { 37 if (marking_state()->WhiteToGrey(obj)) { 38 local_marking_worklists()->Push(obj); 39 return true; 40 } 41 return false; 42 } 43 RestartIfNotMarking()44void IncrementalMarking::RestartIfNotMarking() { 45 if (state_ == COMPLETE) { 46 state_ = MARKING; 47 if (FLAG_trace_incremental_marking) { 48 heap()->isolate()->PrintWithTimestamp( 49 "[IncrementalMarking] Restarting (new grey objects)\n"); 50 } 51 } 52 } 53 54 } // namespace internal 55 } // namespace v8 56 57 #endif // V8_HEAP_INCREMENTAL_MARKING_INL_H_ 58