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

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

Issue 2408233004: [heap] Old-to-new pointer updates need atomic accessors. (Closed)
Patch Set: inline check Created 4 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
« no previous file with comments | « src/base/atomic-utils.h ('k') | test/unittests/base/atomic-utils-unittest.cc » ('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 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 #include "src/heap/mark-compact.h" 5 #include "src/heap/mark-compact.h"
6 6
7 #include "src/base/atomicops.h" 7 #include "src/base/atomicops.h"
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/base/sys-info.h" 9 #include "src/base/sys-info.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 3614 matching lines...) Expand 10 before | Expand all | Expand 10 after
3625 isolate, type, slot, [heap](Object** slot) { 3625 isolate, type, slot, [heap](Object** slot) {
3626 return CheckAndUpdateOldToNewSlot( 3626 return CheckAndUpdateOldToNewSlot(
3627 heap, reinterpret_cast<Address>(slot)); 3627 heap, reinterpret_cast<Address>(slot));
3628 }); 3628 });
3629 }); 3629 });
3630 } 3630 }
3631 } 3631 }
3632 3632
3633 static SlotCallbackResult CheckAndUpdateOldToNewSlot(Heap* heap, 3633 static SlotCallbackResult CheckAndUpdateOldToNewSlot(Heap* heap,
3634 Address slot_address) { 3634 Address slot_address) {
3635 Object** slot = reinterpret_cast<Object**>(slot_address); 3635 base::NoBarrierAtomicValue<Object*>* slot =
3636 if (heap->InFromSpace(*slot)) { 3636 base::NoBarrierAtomicValue<Object*>::FromAddress(slot_address);
3637 HeapObject* heap_object = reinterpret_cast<HeapObject*>(*slot); 3637 Object* slot_reference = slot->Value();
3638 if (heap->InFromSpace(slot_reference)) {
3639 HeapObject* heap_object = reinterpret_cast<HeapObject*>(slot_reference);
3638 DCHECK(heap_object->IsHeapObject()); 3640 DCHECK(heap_object->IsHeapObject());
3639 MapWord map_word = heap_object->map_word(); 3641 MapWord map_word = heap_object->map_word();
3640 // There could still be stale pointers in large object space, map space, 3642 // There could still be stale pointers in large object space, map space,
3641 // and old space for pages that have been promoted. 3643 // and old space for pages that have been promoted.
3642 if (map_word.IsForwardingAddress()) { 3644 if (map_word.IsForwardingAddress()) {
3643 // Update the corresponding slot. 3645 // Update the corresponding slot.
3644 *slot = map_word.ToForwardingAddress(); 3646 slot->SetValue(map_word.ToForwardingAddress());
3645 } 3647 }
3646 // If the object was in from space before and is after executing the 3648 // If the object was in from space before and is after executing the
3647 // callback in to space, the object is still live. 3649 // callback in to space, the object is still live.
3648 // Unfortunately, we do not know about the slot. It could be in a 3650 // Unfortunately, we do not know about the slot. It could be in a
3649 // just freed free space object. 3651 // just freed free space object.
3650 if (heap->InToSpace(*slot)) { 3652 if (heap->InToSpace(slot->Value())) {
3651 return KEEP_SLOT; 3653 return KEEP_SLOT;
3652 } 3654 }
3653 } else if (heap->InToSpace(*slot)) { 3655 } else if (heap->InToSpace(slot_reference)) {
3654 // Slots can point to "to" space if the page has been moved, or if the 3656 // Slots can point to "to" space if the page has been moved, or if the
3655 // slot has been recorded multiple times in the remembered set. Since 3657 // slot has been recorded multiple times in the remembered set. Since
3656 // there is no forwarding information present we need to check the 3658 // there is no forwarding information present we need to check the
3657 // markbits to determine liveness. 3659 // markbits to determine liveness.
3658 if (Marking::IsBlack( 3660 if (Marking::IsBlack(ObjectMarking::MarkBitFrom(
3659 ObjectMarking::MarkBitFrom(reinterpret_cast<HeapObject*>(*slot)))) 3661 reinterpret_cast<HeapObject*>(slot_reference))))
3660 return KEEP_SLOT; 3662 return KEEP_SLOT;
3661 } else { 3663 } else {
3662 DCHECK(!heap->InNewSpace(*slot)); 3664 DCHECK(!heap->InNewSpace(slot_reference));
3663 } 3665 }
3664 return REMOVE_SLOT; 3666 return REMOVE_SLOT;
3665 } 3667 }
3666 }; 3668 };
3667 3669
3668 int NumberOfPointerUpdateTasks(int pages) { 3670 int NumberOfPointerUpdateTasks(int pages) {
3669 if (!FLAG_parallel_pointer_update) return 1; 3671 if (!FLAG_parallel_pointer_update) return 1;
3670 const int kMaxTasks = 4; 3672 const int kMaxTasks = 4;
3671 const int kPagesPerTask = 4; 3673 const int kPagesPerTask = 4;
3672 return Min(kMaxTasks, (pages + kPagesPerTask - 1) / kPagesPerTask); 3674 return Min(kMaxTasks, (pages + kPagesPerTask - 1) / kPagesPerTask);
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
4008 // The target is always in old space, we don't have to record the slot in 4010 // The target is always in old space, we don't have to record the slot in
4009 // the old-to-new remembered set. 4011 // the old-to-new remembered set.
4010 DCHECK(!heap()->InNewSpace(target)); 4012 DCHECK(!heap()->InNewSpace(target));
4011 RecordRelocSlot(host, &rinfo, target); 4013 RecordRelocSlot(host, &rinfo, target);
4012 } 4014 }
4013 } 4015 }
4014 } 4016 }
4015 4017
4016 } // namespace internal 4018 } // namespace internal
4017 } // namespace v8 4019 } // namespace v8
OLDNEW
« no previous file with comments | « src/base/atomic-utils.h ('k') | test/unittests/base/atomic-utils-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698