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

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

Issue 7979038: Fix transferal of marking bits on array trimming. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Vyacheslav Egorov. Created 9 years, 3 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 | « no previous file | test/mjsunit/regress/regress-1708.js » ('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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 ASSERT(IsWhite(old_mark_bit));
385 Marking::MarkBlack(new_mark_bit);
386 return true;
387 } else if (Marking::IsGrey(old_mark_bit)) {
388 ASSERT(heap_->incremental_marking()->IsMarking());
389 old_mark_bit.Clear();
390 old_mark_bit.Next().Clear();
391 ASSERT(IsWhite(old_mark_bit));
392 heap_->incremental_marking()->WhiteToGreyAndPush(
393 HeapObject::FromAddress(new_start), new_mark_bit);
394 heap_->incremental_marking()->RestartIfNotMarking();
397 } 395 }
398 MarkBit old_mark_bit = MarkBitFrom(old_start); 396
399 if (!old_mark_bit.Get()) { 397 #ifdef DEBUG
400 return false; 398 ObjectColor new_color = Color(new_mark_bit);
401 } 399 ASSERT(new_color == old_color);
402 new_mark_bit.Set(); 400 #endif
403 return true; 401
402 return false;
404 } 403 }
405 404
406 405
407 const char* AllocationSpaceName(AllocationSpace space) { 406 const char* AllocationSpaceName(AllocationSpace space) {
408 switch (space) { 407 switch (space) {
409 case NEW_SPACE: return "NEW_SPACE"; 408 case NEW_SPACE: return "NEW_SPACE";
410 case OLD_POINTER_SPACE: return "OLD_POINTER_SPACE"; 409 case OLD_POINTER_SPACE: return "OLD_POINTER_SPACE";
411 case OLD_DATA_SPACE: return "OLD_DATA_SPACE"; 410 case OLD_DATA_SPACE: return "OLD_DATA_SPACE";
412 case CODE_SPACE: return "CODE_SPACE"; 411 case CODE_SPACE: return "CODE_SPACE";
413 case MAP_SPACE: return "MAP_SPACE"; 412 case MAP_SPACE: return "MAP_SPACE";
(...skipping 2816 matching lines...) Expand 10 before | Expand all | Expand 10 after
3230 offset += 8; 3229 offset += 8;
3231 } 3230 }
3232 return objects; 3231 return objects;
3233 } 3232 }
3234 3233
3235 3234
3236 static inline Address DigestFreeStart(Address approximate_free_start, 3235 static inline Address DigestFreeStart(Address approximate_free_start,
3237 uint32_t free_start_cell) { 3236 uint32_t free_start_cell) {
3238 ASSERT(free_start_cell != 0); 3237 ASSERT(free_start_cell != 0);
3239 3238
3239 // No consecutive 1 bits.
3240 ASSERT((free_start_cell & (free_start_cell << 1)) == 0);
3241
3240 int offsets[16]; 3242 int offsets[16];
3241 uint32_t cell = free_start_cell; 3243 uint32_t cell = free_start_cell;
3242 int offset_of_last_live; 3244 int offset_of_last_live;
3243 if ((cell & 0x80000000u) != 0) { 3245 if ((cell & 0x80000000u) != 0) {
3244 // This case would overflow below. 3246 // This case would overflow below.
3245 offset_of_last_live = 31; 3247 offset_of_last_live = 31;
3246 } else { 3248 } else {
3247 // Remove all but one bit, the most significant. This is an optimization 3249 // Remove all but one bit, the most significant. This is an optimization
3248 // that may or may not be worthwhile. 3250 // that may or may not be worthwhile.
3249 cell |= cell >> 16; 3251 cell |= cell >> 16;
(...skipping 10 matching lines...) Expand all
3260 approximate_free_start + offset_of_last_live * kPointerSize; 3262 approximate_free_start + offset_of_last_live * kPointerSize;
3261 HeapObject* last_live = HeapObject::FromAddress(last_live_start); 3263 HeapObject* last_live = HeapObject::FromAddress(last_live_start);
3262 Address free_start = last_live_start + last_live->Size(); 3264 Address free_start = last_live_start + last_live->Size();
3263 return free_start; 3265 return free_start;
3264 } 3266 }
3265 3267
3266 3268
3267 static inline Address StartOfLiveObject(Address block_address, uint32_t cell) { 3269 static inline Address StartOfLiveObject(Address block_address, uint32_t cell) {
3268 ASSERT(cell != 0); 3270 ASSERT(cell != 0);
3269 3271
3272 // No consecutive 1 bits.
3273 ASSERT((cell & (cell << 1)) == 0);
3274
3270 int offsets[16]; 3275 int offsets[16];
3271 if (cell == 0x80000000u) { // Avoid overflow below. 3276 if (cell == 0x80000000u) { // Avoid overflow below.
3272 return block_address + 31 * kPointerSize; 3277 return block_address + 31 * kPointerSize;
3273 } 3278 }
3274 uint32_t first_set_bit = ((cell ^ (cell - 1)) + 1) >> 1; 3279 uint32_t first_set_bit = ((cell ^ (cell - 1)) + 1) >> 1;
3275 ASSERT((first_set_bit & cell) == first_set_bit); 3280 ASSERT((first_set_bit & cell) == first_set_bit);
3276 int live_objects = MarkWordToObjectStarts(first_set_bit, offsets); 3281 int live_objects = MarkWordToObjectStarts(first_set_bit, offsets);
3277 ASSERT(live_objects == 1); 3282 ASSERT(live_objects == 1);
3278 USE(live_objects); 3283 USE(live_objects);
3279 return block_address + offsets[0] * kPointerSize; 3284 return block_address + offsets[0] * kPointerSize;
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
3624 while (buffer != NULL) { 3629 while (buffer != NULL) {
3625 SlotsBuffer* next_buffer = buffer->next(); 3630 SlotsBuffer* next_buffer = buffer->next();
3626 DeallocateBuffer(buffer); 3631 DeallocateBuffer(buffer);
3627 buffer = next_buffer; 3632 buffer = next_buffer;
3628 } 3633 }
3629 *buffer_address = NULL; 3634 *buffer_address = NULL;
3630 } 3635 }
3631 3636
3632 3637
3633 } } // namespace v8::internal 3638 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-1708.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698