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

Side by Side Diff: src/mark-compact.h

Issue 8256012: Remove some asserts to speed up debug mode. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 2 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
« no previous file with comments | « src/incremental-marking-inl.h ('k') | src/mark-compact-inl.h » ('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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 static inline MarkBit MarkBitFrom(Address addr); 55 static inline MarkBit MarkBitFrom(Address addr);
56 56
57 static inline MarkBit MarkBitFrom(HeapObject* obj) { 57 static inline MarkBit MarkBitFrom(HeapObject* obj) {
58 return MarkBitFrom(reinterpret_cast<Address>(obj)); 58 return MarkBitFrom(reinterpret_cast<Address>(obj));
59 } 59 }
60 60
61 // Impossible markbits: 01 61 // Impossible markbits: 01
62 static const char* kImpossibleBitPattern; 62 static const char* kImpossibleBitPattern;
63 static inline bool IsImpossible(MarkBit mark_bit) { 63 static inline bool IsImpossible(MarkBit mark_bit) {
64 ASSERT(strcmp(kImpossibleBitPattern, "01") == 0);
65 return !mark_bit.Get() && mark_bit.Next().Get(); 64 return !mark_bit.Get() && mark_bit.Next().Get();
66 } 65 }
67 66
68 // Black markbits: 10 - this is required by the sweeper. 67 // Black markbits: 10 - this is required by the sweeper.
69 static const char* kBlackBitPattern; 68 static const char* kBlackBitPattern;
70 static inline bool IsBlack(MarkBit mark_bit) { 69 static inline bool IsBlack(MarkBit mark_bit) {
71 ASSERT(strcmp(kBlackBitPattern, "10") == 0);
72 ASSERT(!IsImpossible(mark_bit));
73 return mark_bit.Get() && !mark_bit.Next().Get(); 70 return mark_bit.Get() && !mark_bit.Next().Get();
74 } 71 }
75 72
76 // White markbits: 00 - this is required by the mark bit clearer. 73 // White markbits: 00 - this is required by the mark bit clearer.
77 static const char* kWhiteBitPattern; 74 static const char* kWhiteBitPattern;
78 static inline bool IsWhite(MarkBit mark_bit) { 75 static inline bool IsWhite(MarkBit mark_bit) {
79 ASSERT(strcmp(kWhiteBitPattern, "00") == 0);
80 ASSERT(!IsImpossible(mark_bit));
81 return !mark_bit.Get(); 76 return !mark_bit.Get();
82 } 77 }
83 78
84 // Grey markbits: 11 79 // Grey markbits: 11
85 static const char* kGreyBitPattern; 80 static const char* kGreyBitPattern;
86 static inline bool IsGrey(MarkBit mark_bit) { 81 static inline bool IsGrey(MarkBit mark_bit) {
87 ASSERT(strcmp(kGreyBitPattern, "11") == 0);
88 ASSERT(!IsImpossible(mark_bit));
89 return mark_bit.Get() && mark_bit.Next().Get(); 82 return mark_bit.Get() && mark_bit.Next().Get();
90 } 83 }
91 84
92 static inline void MarkBlack(MarkBit mark_bit) { 85 static inline void MarkBlack(MarkBit mark_bit) {
93 mark_bit.Set(); 86 mark_bit.Set();
94 mark_bit.Next().Clear(); 87 mark_bit.Next().Clear();
95 ASSERT(Marking::IsBlack(mark_bit));
96 } 88 }
97 89
98 static inline void BlackToGrey(MarkBit markbit) { 90 static inline void BlackToGrey(MarkBit markbit) {
99 ASSERT(IsBlack(markbit));
100 markbit.Next().Set(); 91 markbit.Next().Set();
101 ASSERT(IsGrey(markbit));
102 } 92 }
103 93
104 static inline void WhiteToGrey(MarkBit markbit) { 94 static inline void WhiteToGrey(MarkBit markbit) {
105 ASSERT(IsWhite(markbit));
106 markbit.Set(); 95 markbit.Set();
107 markbit.Next().Set(); 96 markbit.Next().Set();
108 ASSERT(IsGrey(markbit));
109 } 97 }
110 98
111 static inline void GreyToBlack(MarkBit markbit) { 99 static inline void GreyToBlack(MarkBit markbit) {
112 ASSERT(IsGrey(markbit));
113 markbit.Next().Clear(); 100 markbit.Next().Clear();
114 ASSERT(IsBlack(markbit));
115 } 101 }
116 102
117 static inline void BlackToGrey(HeapObject* obj) { 103 static inline void BlackToGrey(HeapObject* obj) {
118 ASSERT(obj->Size() >= 2 * kPointerSize);
119 BlackToGrey(MarkBitFrom(obj)); 104 BlackToGrey(MarkBitFrom(obj));
120 } 105 }
121 106
122 static inline void AnyToGrey(MarkBit markbit) { 107 static inline void AnyToGrey(MarkBit markbit) {
123 markbit.Set(); 108 markbit.Set();
124 markbit.Next().Set(); 109 markbit.Next().Set();
125 ASSERT(IsGrey(markbit));
126 } 110 }
127 111
128 // Returns true if the the object whose mark is transferred is marked black. 112 // Returns true if the the object whose mark is transferred is marked black.
129 bool TransferMark(Address old_start, Address new_start); 113 bool TransferMark(Address old_start, Address new_start);
130 114
131 #ifdef DEBUG 115 #ifdef DEBUG
132 enum ObjectColor { 116 enum ObjectColor {
133 BLACK_OBJECT, 117 BLACK_OBJECT,
134 WHITE_OBJECT, 118 WHITE_OBJECT,
135 GREY_OBJECT, 119 GREY_OBJECT,
(...skipping 30 matching lines...) Expand all
166 MarkBit to_mark_bit = MarkBitFrom(to); 150 MarkBit to_mark_bit = MarkBitFrom(to);
167 bool is_black = false; 151 bool is_black = false;
168 if (from_mark_bit.Get()) { 152 if (from_mark_bit.Get()) {
169 to_mark_bit.Set(); 153 to_mark_bit.Set();
170 is_black = true; // Looks black so far. 154 is_black = true; // Looks black so far.
171 } 155 }
172 if (from_mark_bit.Next().Get()) { 156 if (from_mark_bit.Next().Get()) {
173 to_mark_bit.Next().Set(); 157 to_mark_bit.Next().Set();
174 is_black = false; // Was actually gray. 158 is_black = false; // Was actually gray.
175 } 159 }
176 ASSERT(Color(from) == Color(to));
177 ASSERT(is_black == (Color(to) == BLACK_OBJECT));
178 return is_black; 160 return is_black;
179 } 161 }
180 162
181 private: 163 private:
182 Heap* heap_; 164 Heap* heap_;
183 }; 165 };
184 166
185 // ---------------------------------------------------------------------------- 167 // ----------------------------------------------------------------------------
186 // Marking deque for tracing live objects. 168 // Marking deque for tracing live objects.
187 169
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 SetOverflowed(); 202 SetOverflowed();
221 } else { 203 } else {
222 array_[top_] = object; 204 array_[top_] = object;
223 top_ = ((top_ + 1) & mask_); 205 top_ = ((top_ + 1) & mask_);
224 } 206 }
225 } 207 }
226 208
227 inline void PushGrey(HeapObject* object) { 209 inline void PushGrey(HeapObject* object) {
228 ASSERT(object->IsHeapObject()); 210 ASSERT(object->IsHeapObject());
229 if (IsFull()) { 211 if (IsFull()) {
230 ASSERT(Marking::IsGrey(Marking::MarkBitFrom(object)));
231 SetOverflowed(); 212 SetOverflowed();
232 } else { 213 } else {
233 array_[top_] = object; 214 array_[top_] = object;
234 top_ = ((top_ + 1) & mask_); 215 top_ = ((top_ + 1) & mask_);
235 } 216 }
236 } 217 }
237 218
238 inline HeapObject* Pop() { 219 inline HeapObject* Pop() {
239 ASSERT(!IsEmpty()); 220 ASSERT(!IsEmpty());
240 top_ = ((top_ - 1) & mask_); 221 top_ = ((top_ - 1) & mask_);
241 HeapObject* object = array_[top_]; 222 HeapObject* object = array_[top_];
242 ASSERT(object->IsHeapObject()); 223 ASSERT(object->IsHeapObject());
243 return object; 224 return object;
244 } 225 }
245 226
246 inline void UnshiftGrey(HeapObject* object) { 227 inline void UnshiftGrey(HeapObject* object) {
247 ASSERT(object->IsHeapObject()); 228 ASSERT(object->IsHeapObject());
248 if (IsFull()) { 229 if (IsFull()) {
249 ASSERT(Marking::IsGrey(Marking::MarkBitFrom(object)));
250 SetOverflowed(); 230 SetOverflowed();
251 } else { 231 } else {
252 bottom_ = ((bottom_ - 1) & mask_); 232 bottom_ = ((bottom_ - 1) & mask_);
253 array_[bottom_] = object; 233 array_[bottom_] = object;
254 } 234 }
255 } 235 }
256 236
257 HeapObject** array() { return array_; } 237 HeapObject** array() { return array_; }
258 int bottom() { return bottom_; } 238 int bottom() { return bottom_; }
259 int top() { return top_; } 239 int top() { return top_; }
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 764
785 friend class Heap; 765 friend class Heap;
786 }; 766 };
787 767
788 768
789 const char* AllocationSpaceName(AllocationSpace space); 769 const char* AllocationSpaceName(AllocationSpace space);
790 770
791 } } // namespace v8::internal 771 } } // namespace v8::internal
792 772
793 #endif // V8_MARK_COMPACT_H_ 773 #endif // V8_MARK_COMPACT_H_
OLDNEW
« no previous file with comments | « src/incremental-marking-inl.h ('k') | src/mark-compact-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698