OLD | NEW |
---|---|
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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 mark_bit.Clear(); | 359 mark_bit.Clear(); |
360 mark_bit.Next().Clear(); | 360 mark_bit.Next().Clear(); |
361 } | 361 } |
362 } | 362 } |
363 | 363 |
364 | 364 |
365 bool Marking::TransferMark(Address old_start, Address new_start) { | 365 bool Marking::TransferMark(Address old_start, Address new_start) { |
366 // This is only used when resizing an object. | 366 // This is only used when resizing an object. |
367 ASSERT(MemoryChunk::FromAddress(old_start) == | 367 ASSERT(MemoryChunk::FromAddress(old_start) == |
368 MemoryChunk::FromAddress(new_start)); | 368 MemoryChunk::FromAddress(new_start)); |
369 | |
369 // If the mark doesn't move, we don't check the color of the object. | 370 // If the mark doesn't move, we don't check the color of the object. |
370 // It doesn't matter whether the object is black, since it hasn't changed | 371 // It doesn't matter whether the object is black, since it hasn't changed |
371 // size, so the adjustment to the live data count will be zero anyway. | 372 // size, so the adjustment to the live data count will be zero anyway. |
372 if (old_start == new_start) return false; | 373 if (old_start == new_start) return false; |
373 | 374 |
374 MarkBit new_mark_bit = MarkBitFrom(new_start); | 375 MarkBit new_mark_bit = MarkBitFrom(new_start); |
375 | 376 MarkBit old_mark_bit = MarkBitFrom(old_start); |
376 if (heap_->incremental_marking()->IsMarking()) { | |
377 MarkBit old_mark_bit = MarkBitFrom(old_start); | |
378 #ifdef DEBUG | |
379 ObjectColor old_color = Color(old_mark_bit); | |
380 #endif | |
381 if (Marking::IsBlack(old_mark_bit)) { | |
382 Marking::MarkBlack(new_mark_bit); | |
383 old_mark_bit.Clear(); | |
384 return true; | |
385 } else if (Marking::IsGrey(old_mark_bit)) { | |
386 old_mark_bit.Next().Clear(); | |
387 heap_->incremental_marking()->WhiteToGreyAndPush( | |
388 HeapObject::FromAddress(new_start), new_mark_bit); | |
389 heap_->incremental_marking()->RestartIfNotMarking(); | |
390 } | |
391 | 377 |
392 #ifdef DEBUG | 378 #ifdef DEBUG |
393 ObjectColor new_color = Color(new_mark_bit); | 379 ObjectColor old_color = Color(old_mark_bit); |
394 ASSERT(new_color == old_color); | |
395 #endif | 380 #endif |
396 return false; | 381 |
382 if (Marking::IsBlack(old_mark_bit)) { | |
383 old_mark_bit.Clear(); | |
384 Marking::MarkBlack(new_mark_bit); | |
385 return true; | |
386 } else if (Marking::IsGrey(old_mark_bit)) { | |
387 ASSERT(heap_->incremental_marking()->IsMarking()); | |
388 old_mark_bit.Next().Clear(); | |
Vyacheslav Egorov (Chromium)
2011/09/22 11:59:02
should not we clear both bits? (grey = 11)
Michael Starzinger
2011/09/22 13:03:02
Done. You are right, didn't look into the grey cas
| |
389 heap_->incremental_marking()->WhiteToGreyAndPush( | |
390 HeapObject::FromAddress(new_start), new_mark_bit); | |
391 heap_->incremental_marking()->RestartIfNotMarking(); | |
397 } | 392 } |
398 MarkBit old_mark_bit = MarkBitFrom(old_start); | 393 |
399 if (!old_mark_bit.Get()) { | 394 #ifdef DEBUG |
400 return false; | 395 ObjectColor new_color = Color(new_mark_bit); |
401 } | 396 ASSERT(new_color == old_color); |
402 new_mark_bit.Set(); | 397 #endif |
403 return true; | 398 |
399 return false; | |
404 } | 400 } |
405 | 401 |
406 | 402 |
407 const char* AllocationSpaceName(AllocationSpace space) { | 403 const char* AllocationSpaceName(AllocationSpace space) { |
408 switch (space) { | 404 switch (space) { |
409 case NEW_SPACE: return "NEW_SPACE"; | 405 case NEW_SPACE: return "NEW_SPACE"; |
410 case OLD_POINTER_SPACE: return "OLD_POINTER_SPACE"; | 406 case OLD_POINTER_SPACE: return "OLD_POINTER_SPACE"; |
411 case OLD_DATA_SPACE: return "OLD_DATA_SPACE"; | 407 case OLD_DATA_SPACE: return "OLD_DATA_SPACE"; |
412 case CODE_SPACE: return "CODE_SPACE"; | 408 case CODE_SPACE: return "CODE_SPACE"; |
413 case MAP_SPACE: return "MAP_SPACE"; | 409 case MAP_SPACE: return "MAP_SPACE"; |
(...skipping 2816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3230 offset += 8; | 3226 offset += 8; |
3231 } | 3227 } |
3232 return objects; | 3228 return objects; |
3233 } | 3229 } |
3234 | 3230 |
3235 | 3231 |
3236 static inline Address DigestFreeStart(Address approximate_free_start, | 3232 static inline Address DigestFreeStart(Address approximate_free_start, |
3237 uint32_t free_start_cell) { | 3233 uint32_t free_start_cell) { |
3238 ASSERT(free_start_cell != 0); | 3234 ASSERT(free_start_cell != 0); |
3239 | 3235 |
3236 // No consecutive 1 bits. | |
3237 ASSERT((free_start_cell & (free_start_cell << 1)) == 0); | |
3238 | |
3240 int offsets[16]; | 3239 int offsets[16]; |
3241 uint32_t cell = free_start_cell; | 3240 uint32_t cell = free_start_cell; |
3242 int offset_of_last_live; | 3241 int offset_of_last_live; |
3243 if ((cell & 0x80000000u) != 0) { | 3242 if ((cell & 0x80000000u) != 0) { |
3244 // This case would overflow below. | 3243 // This case would overflow below. |
3245 offset_of_last_live = 31; | 3244 offset_of_last_live = 31; |
3246 } else { | 3245 } else { |
3247 // Remove all but one bit, the most significant. This is an optimization | 3246 // Remove all but one bit, the most significant. This is an optimization |
3248 // that may or may not be worthwhile. | 3247 // that may or may not be worthwhile. |
3249 cell |= cell >> 16; | 3248 cell |= cell >> 16; |
(...skipping 10 matching lines...) Expand all Loading... | |
3260 approximate_free_start + offset_of_last_live * kPointerSize; | 3259 approximate_free_start + offset_of_last_live * kPointerSize; |
3261 HeapObject* last_live = HeapObject::FromAddress(last_live_start); | 3260 HeapObject* last_live = HeapObject::FromAddress(last_live_start); |
3262 Address free_start = last_live_start + last_live->Size(); | 3261 Address free_start = last_live_start + last_live->Size(); |
3263 return free_start; | 3262 return free_start; |
3264 } | 3263 } |
3265 | 3264 |
3266 | 3265 |
3267 static inline Address StartOfLiveObject(Address block_address, uint32_t cell) { | 3266 static inline Address StartOfLiveObject(Address block_address, uint32_t cell) { |
3268 ASSERT(cell != 0); | 3267 ASSERT(cell != 0); |
3269 | 3268 |
3269 // No consecutive 1 bits. | |
3270 ASSERT((cell & (cell << 1)) == 0); | |
3271 | |
3270 int offsets[16]; | 3272 int offsets[16]; |
3271 if (cell == 0x80000000u) { // Avoid overflow below. | 3273 if (cell == 0x80000000u) { // Avoid overflow below. |
3272 return block_address + 31 * kPointerSize; | 3274 return block_address + 31 * kPointerSize; |
3273 } | 3275 } |
3274 uint32_t first_set_bit = ((cell ^ (cell - 1)) + 1) >> 1; | 3276 uint32_t first_set_bit = ((cell ^ (cell - 1)) + 1) >> 1; |
3275 ASSERT((first_set_bit & cell) == first_set_bit); | 3277 ASSERT((first_set_bit & cell) == first_set_bit); |
3276 int live_objects = MarkWordToObjectStarts(first_set_bit, offsets); | 3278 int live_objects = MarkWordToObjectStarts(first_set_bit, offsets); |
3277 ASSERT(live_objects == 1); | 3279 ASSERT(live_objects == 1); |
3278 USE(live_objects); | 3280 USE(live_objects); |
3279 return block_address + offsets[0] * kPointerSize; | 3281 return block_address + offsets[0] * kPointerSize; |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3624 while (buffer != NULL) { | 3626 while (buffer != NULL) { |
3625 SlotsBuffer* next_buffer = buffer->next(); | 3627 SlotsBuffer* next_buffer = buffer->next(); |
3626 DeallocateBuffer(buffer); | 3628 DeallocateBuffer(buffer); |
3627 buffer = next_buffer; | 3629 buffer = next_buffer; |
3628 } | 3630 } |
3629 *buffer_address = NULL; | 3631 *buffer_address = NULL; |
3630 } | 3632 } |
3631 | 3633 |
3632 | 3634 |
3633 } } // namespace v8::internal | 3635 } } // namespace v8::internal |
OLD | NEW |