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

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

Issue 8081001: Adjust assertions in UpdateSlot to match UpdatePointer in PointersUpdatingVisitor. (Closed) Base URL: https://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 | « no previous file | no next file » | 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 2449 matching lines...) Expand 10 before | Expand all | Expand 10 after
2460 void VisitDebugTarget(RelocInfo* rinfo) { 2460 void VisitDebugTarget(RelocInfo* rinfo) {
2461 ASSERT((RelocInfo::IsJSReturn(rinfo->rmode()) && 2461 ASSERT((RelocInfo::IsJSReturn(rinfo->rmode()) &&
2462 rinfo->IsPatchedReturnSequence()) || 2462 rinfo->IsPatchedReturnSequence()) ||
2463 (RelocInfo::IsDebugBreakSlot(rinfo->rmode()) && 2463 (RelocInfo::IsDebugBreakSlot(rinfo->rmode()) &&
2464 rinfo->IsPatchedDebugBreakSlotSequence())); 2464 rinfo->IsPatchedDebugBreakSlotSequence()));
2465 Object* target = Code::GetCodeFromTargetAddress(rinfo->call_address()); 2465 Object* target = Code::GetCodeFromTargetAddress(rinfo->call_address());
2466 VisitPointer(&target); 2466 VisitPointer(&target);
2467 rinfo->set_call_address(Code::cast(target)->instruction_start()); 2467 rinfo->set_call_address(Code::cast(target)->instruction_start());
2468 } 2468 }
2469 2469
2470 static inline void UpdateSlot(Heap* heap, Object** slot) {
2471 Object* obj = *slot;
2472
2473 if (!obj->IsHeapObject()) return;
2474
2475 HeapObject* heap_obj = HeapObject::cast(obj);
2476
2477 MapWord map_word = heap_obj->map_word();
2478 if (map_word.IsForwardingAddress()) {
2479 ASSERT(heap->InFromSpace(heap_obj) ||
2480 MarkCompactCollector::IsOnEvacuationCandidate(heap_obj));
2481 HeapObject* target = map_word.ToForwardingAddress();
2482 *slot = target;
2483 ASSERT(!heap->InFromSpace(target) &&
2484 !MarkCompactCollector::IsOnEvacuationCandidate(target));
2485 }
2486 }
2487
2470 private: 2488 private:
2489
2471 inline void UpdatePointer(Object** p) { 2490 inline void UpdatePointer(Object** p) {
2472 if (!(*p)->IsHeapObject()) return; 2491 UpdateSlot(heap_, p);
2473
2474 HeapObject* obj = HeapObject::cast(*p);
2475
2476 MapWord map_word = obj->map_word();
2477 if (map_word.IsForwardingAddress()) {
2478 ASSERT(heap_->InFromSpace(obj) ||
2479 MarkCompactCollector::IsOnEvacuationCandidate(obj));
2480 *p = obj->map_word().ToForwardingAddress();
2481 ASSERT(!heap_->InFromSpace(*p) &&
2482 !MarkCompactCollector::IsOnEvacuationCandidate(*p));
2483 }
2484 } 2492 }
2485 2493
2486 Heap* heap_; 2494 Heap* heap_;
2487 }; 2495 };
2488 2496
2489 2497
2490 static void UpdatePointer(HeapObject** p, HeapObject* object) { 2498 static void UpdatePointer(HeapObject** p, HeapObject* object) {
2491 ASSERT(*p == object); 2499 ASSERT(*p == object);
2492 2500
2493 Address old_addr = object->address(); 2501 Address old_addr = object->address();
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
2719 MapWord map_word = heap_object->map_word(); 2727 MapWord map_word = heap_object->map_word();
2720 if (map_word.IsForwardingAddress()) { 2728 if (map_word.IsForwardingAddress()) {
2721 return map_word.ToForwardingAddress(); 2729 return map_word.ToForwardingAddress();
2722 } 2730 }
2723 } 2731 }
2724 return object; 2732 return object;
2725 } 2733 }
2726 }; 2734 };
2727 2735
2728 2736
2729 static inline void UpdateSlot(Object** slot) {
2730 Object* obj = *slot;
2731 if (!obj->IsHeapObject()) return;
2732
2733 HeapObject* heap_obj = HeapObject::cast(obj);
2734
2735 MapWord map_word = heap_obj->map_word();
2736 if (map_word.IsForwardingAddress()) {
2737 ASSERT(MarkCompactCollector::IsOnEvacuationCandidate(*slot));
2738 *slot = map_word.ToForwardingAddress();
2739 ASSERT(!MarkCompactCollector::IsOnEvacuationCandidate(*slot));
2740 }
2741 }
2742
2743
2744 static inline void UpdateSlot(ObjectVisitor* v, 2737 static inline void UpdateSlot(ObjectVisitor* v,
2745 SlotsBuffer::SlotType slot_type, 2738 SlotsBuffer::SlotType slot_type,
2746 Address addr) { 2739 Address addr) {
2747 switch (slot_type) { 2740 switch (slot_type) {
2748 case SlotsBuffer::CODE_TARGET_SLOT: { 2741 case SlotsBuffer::CODE_TARGET_SLOT: {
2749 RelocInfo rinfo(addr, RelocInfo::CODE_TARGET, 0, NULL); 2742 RelocInfo rinfo(addr, RelocInfo::CODE_TARGET, 0, NULL);
2750 rinfo.Visit(v); 2743 rinfo.Visit(v);
2751 break; 2744 break;
2752 } 2745 }
2753 case SlotsBuffer::CODE_ENTRY_SLOT: { 2746 case SlotsBuffer::CODE_ENTRY_SLOT: {
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after
3750 return static_cast<SlotsBuffer::SlotType>(reinterpret_cast<intptr_t>(slot)); 3743 return static_cast<SlotsBuffer::SlotType>(reinterpret_cast<intptr_t>(slot));
3751 } 3744 }
3752 3745
3753 3746
3754 void SlotsBuffer::UpdateSlots(Heap* heap) { 3747 void SlotsBuffer::UpdateSlots(Heap* heap) {
3755 PointersUpdatingVisitor v(heap); 3748 PointersUpdatingVisitor v(heap);
3756 3749
3757 for (int slot_idx = 0; slot_idx < idx_; ++slot_idx) { 3750 for (int slot_idx = 0; slot_idx < idx_; ++slot_idx) {
3758 ObjectSlot slot = slots_[slot_idx]; 3751 ObjectSlot slot = slots_[slot_idx];
3759 if (!IsTypedSlot(slot)) { 3752 if (!IsTypedSlot(slot)) {
3760 UpdateSlot(slot); 3753 PointersUpdatingVisitor::UpdateSlot(heap, slot);
3761 } else { 3754 } else {
3762 ++slot_idx; 3755 ++slot_idx;
3763 ASSERT(slot_idx < idx_); 3756 ASSERT(slot_idx < idx_);
3764 UpdateSlot(&v, 3757 UpdateSlot(&v,
3765 DecodeSlotType(slot), 3758 DecodeSlotType(slot),
3766 reinterpret_cast<Address>(slots_[slot_idx])); 3759 reinterpret_cast<Address>(slots_[slot_idx]));
3767 } 3760 }
3768 } 3761 }
3769 } 3762 }
3770 3763
3771 3764
3772 void SlotsBuffer::UpdateSlotsWithFilter(Heap* heap) { 3765 void SlotsBuffer::UpdateSlotsWithFilter(Heap* heap) {
3773 PointersUpdatingVisitor v(heap); 3766 PointersUpdatingVisitor v(heap);
3774 3767
3775 for (int slot_idx = 0; slot_idx < idx_; ++slot_idx) { 3768 for (int slot_idx = 0; slot_idx < idx_; ++slot_idx) {
3776 ObjectSlot slot = slots_[slot_idx]; 3769 ObjectSlot slot = slots_[slot_idx];
3777 if (!IsTypedSlot(slot)) { 3770 if (!IsTypedSlot(slot)) {
3778 if (!IsOnInvalidatedCodeObject(reinterpret_cast<Address>(slot))) { 3771 if (!IsOnInvalidatedCodeObject(reinterpret_cast<Address>(slot))) {
3779 UpdateSlot(slot); 3772 PointersUpdatingVisitor::UpdateSlot(heap, slot);
3780 } 3773 }
3781 } else { 3774 } else {
3782 ++slot_idx; 3775 ++slot_idx;
3783 ASSERT(slot_idx < idx_); 3776 ASSERT(slot_idx < idx_);
3784 Address pc = reinterpret_cast<Address>(slots_[slot_idx]); 3777 Address pc = reinterpret_cast<Address>(slots_[slot_idx]);
3785 if (!IsOnInvalidatedCodeObject(pc)) { 3778 if (!IsOnInvalidatedCodeObject(pc)) {
3786 UpdateSlot(&v, 3779 UpdateSlot(&v,
3787 DecodeSlotType(slot), 3780 DecodeSlotType(slot),
3788 reinterpret_cast<Address>(slots_[slot_idx])); 3781 reinterpret_cast<Address>(slots_[slot_idx]));
3789 } 3782 }
(...skipping 17 matching lines...) Expand all
3807 while (buffer != NULL) { 3800 while (buffer != NULL) {
3808 SlotsBuffer* next_buffer = buffer->next(); 3801 SlotsBuffer* next_buffer = buffer->next();
3809 DeallocateBuffer(buffer); 3802 DeallocateBuffer(buffer);
3810 buffer = next_buffer; 3803 buffer = next_buffer;
3811 } 3804 }
3812 *buffer_address = NULL; 3805 *buffer_address = NULL;
3813 } 3806 }
3814 3807
3815 3808
3816 } } // namespace v8::internal 3809 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698