Line data Source code
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/heap/mark-compact-inl.h"
11 : #include "src/isolate.h"
12 : #include "src/objects-inl.h"
13 : #include "src/objects/maybe-object.h"
14 :
15 : namespace v8 {
16 : namespace internal {
17 :
18 : void IncrementalMarking::TransferColor(HeapObject from, HeapObject to) {
19 3253319 : if (atomic_marking_state()->IsBlack(to)) {
20 : DCHECK(black_allocation());
21 : return;
22 : }
23 :
24 : DCHECK(atomic_marking_state()->IsWhite(to));
25 3250842 : if (atomic_marking_state()->IsGrey(from)) {
26 : bool success = atomic_marking_state()->WhiteToGrey(to);
27 : DCHECK(success);
28 : USE(success);
29 3064274 : } else if (atomic_marking_state()->IsBlack(from)) {
30 : bool success = atomic_marking_state()->WhiteToBlack(to);
31 : DCHECK(success);
32 : USE(success);
33 : }
34 : }
35 :
36 : void IncrementalMarking::RecordWrite(HeapObject obj, ObjectSlot slot,
37 : Object value) {
38 : DCHECK_IMPLIES(slot.address() != kNullAddress, !HasWeakHeapObjectTag(*slot));
39 : DCHECK(!HasWeakHeapObjectTag(value));
40 : if (IsMarking() && value->IsHeapObject()) {
41 : RecordWriteSlow(obj, HeapObjectSlot(slot), HeapObject::cast(value));
42 : }
43 : }
44 :
45 : void IncrementalMarking::RecordMaybeWeakWrite(HeapObject obj,
46 : MaybeObjectSlot slot,
47 : MaybeObject value) {
48 : // When writing a weak reference, treat it as strong for the purposes of the
49 : // marking barrier.
50 4881920 : HeapObject heap_object;
51 9763838 : if (IsMarking() && value->GetHeapObject(&heap_object)) {
52 4881917 : RecordWriteSlow(obj, HeapObjectSlot(slot), heap_object);
53 : }
54 : }
55 :
56 18647905 : void IncrementalMarking::RestartIfNotMarking() {
57 18647905 : if (state_ == COMPLETE) {
58 9257 : state_ = MARKING;
59 9257 : if (FLAG_trace_incremental_marking) {
60 : heap()->isolate()->PrintWithTimestamp(
61 0 : "[IncrementalMarking] Restarting (new grey objects)\n");
62 : }
63 : }
64 18647905 : }
65 :
66 : } // namespace internal
67 : } // namespace v8
68 :
69 : #endif // V8_HEAP_INCREMENTAL_MARKING_INL_H_
|