1 // Copyright 2020 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_MARKING_BARRIER_INL_H_ 6 #define V8_HEAP_MARKING_BARRIER_INL_H_ 7 8 #include "src/heap/incremental-marking-inl.h" 9 #include "src/heap/incremental-marking.h" 10 #include "src/heap/marking-barrier.h" 11 12 namespace v8 { 13 namespace internal { 14 MarkValue(HeapObject host,HeapObject value)15bool MarkingBarrier::MarkValue(HeapObject host, HeapObject value) { 16 DCHECK(is_activated_); 17 DCHECK(!marking_state_.IsImpossible(value)); 18 // Host may have an impossible markbit pattern if manual allocation folding 19 // is performed and host happens to be the last word of an allocated region. 20 // In that case host has only one markbit and the second markbit belongs to 21 // another object. We can detect that case by checking if value is a one word 22 // filler map. 23 DCHECK(!marking_state_.IsImpossible(host) || 24 value == ReadOnlyRoots(heap_->isolate()).one_pointer_filler_map()); 25 if (!V8_CONCURRENT_MARKING_BOOL && !marking_state_.IsBlack(host)) { 26 // The value will be marked and the slot will be recorded when the marker 27 // visits the host object. 28 return false; 29 } 30 if (WhiteToGreyAndPush(value) && is_main_thread_barrier_) { 31 incremental_marking_->RestartIfNotMarking(); 32 } 33 return true; 34 } 35 WhiteToGreyAndPush(HeapObject obj)36bool MarkingBarrier::WhiteToGreyAndPush(HeapObject obj) { 37 if (marking_state_.WhiteToGrey(obj)) { 38 worklist_.Push(obj); 39 return true; 40 } 41 return false; 42 } 43 44 } // namespace internal 45 } // namespace v8 46 47 #endif // V8_HEAP_MARKING_BARRIER_INL_H_ 48