OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_MARK_COMPACT_H_ | 5 #ifndef V8_MARK_COMPACT_H_ |
6 #define V8_MARK_COMPACT_H_ | 6 #define V8_MARK_COMPACT_H_ |
7 | 7 |
8 #include "src/compiler-intrinsics.h" | 8 #include "src/compiler-intrinsics.h" |
9 #include "src/spaces.h" | 9 #include "src/spaces.h" |
10 | 10 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 bool overflowed() const { return overflowed_; } | 163 bool overflowed() const { return overflowed_; } |
164 | 164 |
165 void ClearOverflowed() { overflowed_ = false; } | 165 void ClearOverflowed() { overflowed_ = false; } |
166 | 166 |
167 void SetOverflowed() { overflowed_ = true; } | 167 void SetOverflowed() { overflowed_ = true; } |
168 | 168 |
169 // Push the (marked) object on the marking stack if there is room, | 169 // Push the (marked) object on the marking stack if there is room, |
170 // otherwise mark the object as overflowed and wait for a rescan of the | 170 // otherwise mark the object as overflowed and wait for a rescan of the |
171 // heap. | 171 // heap. |
172 INLINE(void PushBlack(HeapObject* object)) { | 172 INLINE(void PushBlack(HeapObject* object)) { |
173 ASSERT(object->IsHeapObject()); | 173 DCHECK(object->IsHeapObject()); |
174 if (IsFull()) { | 174 if (IsFull()) { |
175 Marking::BlackToGrey(object); | 175 Marking::BlackToGrey(object); |
176 MemoryChunk::IncrementLiveBytesFromGC(object->address(), -object->Size()); | 176 MemoryChunk::IncrementLiveBytesFromGC(object->address(), -object->Size()); |
177 SetOverflowed(); | 177 SetOverflowed(); |
178 } else { | 178 } else { |
179 array_[top_] = object; | 179 array_[top_] = object; |
180 top_ = ((top_ + 1) & mask_); | 180 top_ = ((top_ + 1) & mask_); |
181 } | 181 } |
182 } | 182 } |
183 | 183 |
184 INLINE(void PushGrey(HeapObject* object)) { | 184 INLINE(void PushGrey(HeapObject* object)) { |
185 ASSERT(object->IsHeapObject()); | 185 DCHECK(object->IsHeapObject()); |
186 if (IsFull()) { | 186 if (IsFull()) { |
187 SetOverflowed(); | 187 SetOverflowed(); |
188 } else { | 188 } else { |
189 array_[top_] = object; | 189 array_[top_] = object; |
190 top_ = ((top_ + 1) & mask_); | 190 top_ = ((top_ + 1) & mask_); |
191 } | 191 } |
192 } | 192 } |
193 | 193 |
194 INLINE(HeapObject* Pop()) { | 194 INLINE(HeapObject* Pop()) { |
195 ASSERT(!IsEmpty()); | 195 DCHECK(!IsEmpty()); |
196 top_ = ((top_ - 1) & mask_); | 196 top_ = ((top_ - 1) & mask_); |
197 HeapObject* object = array_[top_]; | 197 HeapObject* object = array_[top_]; |
198 ASSERT(object->IsHeapObject()); | 198 DCHECK(object->IsHeapObject()); |
199 return object; | 199 return object; |
200 } | 200 } |
201 | 201 |
202 INLINE(void UnshiftGrey(HeapObject* object)) { | 202 INLINE(void UnshiftGrey(HeapObject* object)) { |
203 ASSERT(object->IsHeapObject()); | 203 DCHECK(object->IsHeapObject()); |
204 if (IsFull()) { | 204 if (IsFull()) { |
205 SetOverflowed(); | 205 SetOverflowed(); |
206 } else { | 206 } else { |
207 bottom_ = ((bottom_ - 1) & mask_); | 207 bottom_ = ((bottom_ - 1) & mask_); |
208 array_[bottom_] = object; | 208 array_[bottom_] = object; |
209 } | 209 } |
210 } | 210 } |
211 | 211 |
212 HeapObject** array() { return array_; } | 212 HeapObject** array() { return array_; } |
213 int bottom() { return bottom_; } | 213 int bottom() { return bottom_; } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 : idx_(0), chain_length_(1), next_(next_buffer) { | 258 : idx_(0), chain_length_(1), next_(next_buffer) { |
259 if (next_ != NULL) { | 259 if (next_ != NULL) { |
260 chain_length_ = next_->chain_length_ + 1; | 260 chain_length_ = next_->chain_length_ + 1; |
261 } | 261 } |
262 } | 262 } |
263 | 263 |
264 ~SlotsBuffer() { | 264 ~SlotsBuffer() { |
265 } | 265 } |
266 | 266 |
267 void Add(ObjectSlot slot) { | 267 void Add(ObjectSlot slot) { |
268 ASSERT(0 <= idx_ && idx_ < kNumberOfElements); | 268 DCHECK(0 <= idx_ && idx_ < kNumberOfElements); |
269 slots_[idx_++] = slot; | 269 slots_[idx_++] = slot; |
270 } | 270 } |
271 | 271 |
272 enum SlotType { | 272 enum SlotType { |
273 EMBEDDED_OBJECT_SLOT, | 273 EMBEDDED_OBJECT_SLOT, |
274 RELOCATED_CODE_OBJECT, | 274 RELOCATED_CODE_OBJECT, |
275 CODE_TARGET_SLOT, | 275 CODE_TARGET_SLOT, |
276 CODE_ENTRY_SLOT, | 276 CODE_ENTRY_SLOT, |
277 DEBUG_TARGET_SLOT, | 277 DEBUG_TARGET_SLOT, |
278 JS_RETURN_SLOT, | 278 JS_RETURN_SLOT, |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 optimized_code_map_holder_head_(NULL) {} | 397 optimized_code_map_holder_head_(NULL) {} |
398 | 398 |
399 void AddCandidate(SharedFunctionInfo* shared_info) { | 399 void AddCandidate(SharedFunctionInfo* shared_info) { |
400 if (GetNextCandidate(shared_info) == NULL) { | 400 if (GetNextCandidate(shared_info) == NULL) { |
401 SetNextCandidate(shared_info, shared_function_info_candidates_head_); | 401 SetNextCandidate(shared_info, shared_function_info_candidates_head_); |
402 shared_function_info_candidates_head_ = shared_info; | 402 shared_function_info_candidates_head_ = shared_info; |
403 } | 403 } |
404 } | 404 } |
405 | 405 |
406 void AddCandidate(JSFunction* function) { | 406 void AddCandidate(JSFunction* function) { |
407 ASSERT(function->code() == function->shared()->code()); | 407 DCHECK(function->code() == function->shared()->code()); |
408 if (GetNextCandidate(function)->IsUndefined()) { | 408 if (GetNextCandidate(function)->IsUndefined()) { |
409 SetNextCandidate(function, jsfunction_candidates_head_); | 409 SetNextCandidate(function, jsfunction_candidates_head_); |
410 jsfunction_candidates_head_ = function; | 410 jsfunction_candidates_head_ = function; |
411 } | 411 } |
412 } | 412 } |
413 | 413 |
414 void AddOptimizedCodeMap(SharedFunctionInfo* code_map_holder) { | 414 void AddOptimizedCodeMap(SharedFunctionInfo* code_map_holder) { |
415 if (GetNextCodeMap(code_map_holder)->IsUndefined()) { | 415 if (GetNextCodeMap(code_map_holder)->IsUndefined()) { |
416 SetNextCodeMap(code_map_holder, optimized_code_map_holder_head_); | 416 SetNextCodeMap(code_map_holder, optimized_code_map_holder_head_); |
417 optimized_code_map_holder_head_ = code_map_holder; | 417 optimized_code_map_holder_head_ = code_map_holder; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 Object* next_candidate = candidate->next_function_link(); | 453 Object* next_candidate = candidate->next_function_link(); |
454 return reinterpret_cast<JSFunction*>(next_candidate); | 454 return reinterpret_cast<JSFunction*>(next_candidate); |
455 } | 455 } |
456 | 456 |
457 static void SetNextCandidate(JSFunction* candidate, | 457 static void SetNextCandidate(JSFunction* candidate, |
458 JSFunction* next_candidate) { | 458 JSFunction* next_candidate) { |
459 candidate->set_next_function_link(next_candidate); | 459 candidate->set_next_function_link(next_candidate); |
460 } | 460 } |
461 | 461 |
462 static void ClearNextCandidate(JSFunction* candidate, Object* undefined) { | 462 static void ClearNextCandidate(JSFunction* candidate, Object* undefined) { |
463 ASSERT(undefined->IsUndefined()); | 463 DCHECK(undefined->IsUndefined()); |
464 candidate->set_next_function_link(undefined, SKIP_WRITE_BARRIER); | 464 candidate->set_next_function_link(undefined, SKIP_WRITE_BARRIER); |
465 } | 465 } |
466 | 466 |
467 static SharedFunctionInfo* GetNextCandidate(SharedFunctionInfo* candidate) { | 467 static SharedFunctionInfo* GetNextCandidate(SharedFunctionInfo* candidate) { |
468 Object* next_candidate = candidate->code()->gc_metadata(); | 468 Object* next_candidate = candidate->code()->gc_metadata(); |
469 return reinterpret_cast<SharedFunctionInfo*>(next_candidate); | 469 return reinterpret_cast<SharedFunctionInfo*>(next_candidate); |
470 } | 470 } |
471 | 471 |
472 static void SetNextCandidate(SharedFunctionInfo* candidate, | 472 static void SetNextCandidate(SharedFunctionInfo* candidate, |
473 SharedFunctionInfo* next_candidate) { | 473 SharedFunctionInfo* next_candidate) { |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 Bitmap::CellAlignIndex( | 937 Bitmap::CellAlignIndex( |
938 chunk_->AddressToMarkbitIndex(cell_base_))); | 938 chunk_->AddressToMarkbitIndex(cell_base_))); |
939 cells_ = chunk_->markbits()->cells(); | 939 cells_ = chunk_->markbits()->cells(); |
940 } | 940 } |
941 | 941 |
942 inline bool Done() { return cell_index_ == last_cell_index_; } | 942 inline bool Done() { return cell_index_ == last_cell_index_; } |
943 | 943 |
944 inline bool HasNext() { return cell_index_ < last_cell_index_ - 1; } | 944 inline bool HasNext() { return cell_index_ < last_cell_index_ - 1; } |
945 | 945 |
946 inline MarkBit::CellType* CurrentCell() { | 946 inline MarkBit::CellType* CurrentCell() { |
947 ASSERT(cell_index_ == Bitmap::IndexToCell(Bitmap::CellAlignIndex( | 947 DCHECK(cell_index_ == Bitmap::IndexToCell(Bitmap::CellAlignIndex( |
948 chunk_->AddressToMarkbitIndex(cell_base_)))); | 948 chunk_->AddressToMarkbitIndex(cell_base_)))); |
949 return &cells_[cell_index_]; | 949 return &cells_[cell_index_]; |
950 } | 950 } |
951 | 951 |
952 inline Address CurrentCellBase() { | 952 inline Address CurrentCellBase() { |
953 ASSERT(cell_index_ == Bitmap::IndexToCell(Bitmap::CellAlignIndex( | 953 DCHECK(cell_index_ == Bitmap::IndexToCell(Bitmap::CellAlignIndex( |
954 chunk_->AddressToMarkbitIndex(cell_base_)))); | 954 chunk_->AddressToMarkbitIndex(cell_base_)))); |
955 return cell_base_; | 955 return cell_base_; |
956 } | 956 } |
957 | 957 |
958 inline void Advance() { | 958 inline void Advance() { |
959 cell_index_++; | 959 cell_index_++; |
960 cell_base_ += 32 * kPointerSize; | 960 cell_base_ += 32 * kPointerSize; |
961 } | 961 } |
962 | 962 |
963 private: | 963 private: |
(...skipping 19 matching lines...) Expand all Loading... |
983 private: | 983 private: |
984 MarkCompactCollector* collector_; | 984 MarkCompactCollector* collector_; |
985 }; | 985 }; |
986 | 986 |
987 | 987 |
988 const char* AllocationSpaceName(AllocationSpace space); | 988 const char* AllocationSpaceName(AllocationSpace space); |
989 | 989 |
990 } } // namespace v8::internal | 990 } } // namespace v8::internal |
991 | 991 |
992 #endif // V8_MARK_COMPACT_H_ | 992 #endif // V8_MARK_COMPACT_H_ |
OLD | NEW |