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

Side by Side Diff: src/incremental-marking-inl.h

Issue 6880010: Merge (7265, 7271] from bleeding_edge to experimental/gc branch.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 8 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 #ifndef V8_INCREMENTAL_MARKING_INL_H_
29 #define V8_INCREMENTAL_MARKING_INL_H_
30
31 #include "incremental-marking.h"
32
33 namespace v8 {
34 namespace internal {
35
36
37 void IncrementalMarking::RecordWrite(HeapObject* obj, Object* value) {
38 if (!IsStopped() && value->IsHeapObject()) {
39 MarkBit value_bit = heap_->marking()->MarkBitFrom(HeapObject::cast(value));
40 if (IsWhite(value_bit)) {
41 MarkBit obj_bit = heap_->marking()->MarkBitFrom(obj);
42 if (IsBlack(obj_bit)) {
43 BlackToGreyAndPush(obj, obj_bit);
44 RestartIfNotMarking();
45 }
46 }
47 }
48 }
49
50
51 void IncrementalMarking::RecordWriteOf(HeapObject* value) {
52 if (state_ != STOPPED) {
53 MarkBit value_bit = heap_->marking()->MarkBitFrom(value);
54 if (IsWhite(value_bit)) {
55 WhiteToGreyAndPush(value, value_bit);
56 RestartIfNotMarking();
57 }
58 }
59 }
60
61
62 void IncrementalMarking::RecordWrites(HeapObject* obj) {
63 if (!IsStopped()) {
64 MarkBit obj_bit = heap_->marking()->MarkBitFrom(obj);
65 if (IsBlack(obj_bit)) {
66 BlackToGreyAndPush(obj, obj_bit);
67 RestartIfNotMarking();
68 }
69 }
70 }
71
72
73 void IncrementalMarking::BlackToGreyAndPush(HeapObject* obj, MarkBit mark_bit) {
74 ASSERT(heap_->marking()->MarkBitFrom(obj) == mark_bit);
75 ASSERT(obj->Size() >= 2*kPointerSize);
76 ASSERT(!IsStopped());
77 ASSERT(IsBlack(mark_bit));
78 mark_bit.Next().Set();
79 ASSERT(IsGrey(mark_bit));
80
81 marking_stack_.Push(obj);
82 ASSERT(!marking_stack_.overflowed());
83 }
84
85
86 void IncrementalMarking::WhiteToGreyAndPush(HeapObject* obj, MarkBit mark_bit) {
87 WhiteToGrey(obj, mark_bit);
88 marking_stack_.Push(obj);
89 ASSERT(!marking_stack_.overflowed());
90 }
91
92
93 void IncrementalMarking::WhiteToGrey(HeapObject* obj, MarkBit mark_bit) {
94 ASSERT(heap_->marking()->MarkBitFrom(obj) == mark_bit);
95 ASSERT(obj->Size() >= 2*kPointerSize);
96 ASSERT(!IsStopped());
97 ASSERT(IsWhite(mark_bit));
98 mark_bit.Set();
99 mark_bit.Next().Set();
100 ASSERT(IsGrey(mark_bit));
101 }
102
103
104 IncrementalMarking::ObjectColor IncrementalMarking::Color(HeapObject* obj) {
105 MarkBit mark_bit = heap_->marking()->MarkBitFrom(obj);
106 if (IsBlack(mark_bit)) return BLACK_OBJECT;
107 if (IsWhite(mark_bit)) return WHITE_OBJECT;
108 if (IsGrey(mark_bit)) return GREY_OBJECT;
109 UNREACHABLE();
110 return IMPOSSIBLE_COLOR;
111 }
112
113
114 } } // namespace v8::internal
115
116 #endif // V8_INCREMENTAL_MARKING_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698