| 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 #ifndef V8_INCREMENTAL_MARKING_INL_H_ | 28 #ifndef V8_INCREMENTAL_MARKING_INL_H_ |
| 29 #define V8_INCREMENTAL_MARKING_INL_H_ | 29 #define V8_INCREMENTAL_MARKING_INL_H_ |
| 30 | 30 |
| 31 #include "incremental-marking.h" | 31 #include "incremental-marking.h" |
| 32 | 32 |
| 33 namespace v8 { | 33 namespace v8 { |
| 34 namespace internal { | 34 namespace internal { |
| 35 | 35 |
| 36 | 36 |
| 37 bool IncrementalMarking::BaseRecordWrite(HeapObject* obj, |
| 38 Object** slot, |
| 39 Object* value) { |
| 40 if (IsMarking() && value->IsHeapObject()) { |
| 41 MarkBit value_bit = Marking::MarkBitFrom(HeapObject::cast(value)); |
| 42 if (Marking::IsWhite(value_bit)) { |
| 43 MarkBit obj_bit = Marking::MarkBitFrom(obj); |
| 44 if (Marking::IsBlack(obj_bit)) { |
| 45 BlackToGreyAndUnshift(obj, obj_bit); |
| 46 RestartIfNotMarking(); |
| 47 } |
| 48 |
| 49 // Object is either grey or white it will be scanned if survives. |
| 50 return false; |
| 51 } |
| 52 return true; |
| 53 } |
| 54 return false; |
| 55 } |
| 56 |
| 57 |
| 37 void IncrementalMarking::RecordWrite(HeapObject* obj, | 58 void IncrementalMarking::RecordWrite(HeapObject* obj, |
| 38 Object** slot, | 59 Object** slot, |
| 39 Object* value) { | 60 Object* value) { |
| 61 if (BaseRecordWrite(obj, slot, value) && is_compacting_ && slot != NULL) { |
| 62 MarkBit obj_bit = Marking::MarkBitFrom(obj); |
| 63 if (Marking::IsBlack(obj_bit)) { |
| 64 // Object is not going to be rescanned we need to record the slot. |
| 65 heap_->mark_compact_collector()->RecordSlot( |
| 66 HeapObject::RawField(obj, 0), slot, value); |
| 67 } |
| 68 } |
| 69 } |
| 70 |
| 71 |
| 72 void IncrementalMarking::RecordWriteIntoCode(HeapObject* obj, |
| 73 RelocInfo* rinfo, |
| 74 Object* value) { |
| 40 if (IsMarking() && value->IsHeapObject()) { | 75 if (IsMarking() && value->IsHeapObject()) { |
| 41 MarkBit value_bit = Marking::MarkBitFrom(HeapObject::cast(value)); | 76 MarkBit value_bit = Marking::MarkBitFrom(HeapObject::cast(value)); |
| 42 if (Marking::IsWhite(value_bit)) { | 77 if (Marking::IsWhite(value_bit)) { |
| 43 MarkBit obj_bit = Marking::MarkBitFrom(obj); | 78 MarkBit obj_bit = Marking::MarkBitFrom(obj); |
| 44 if (Marking::IsBlack(obj_bit)) { | 79 if (Marking::IsBlack(obj_bit)) { |
| 45 BlackToGreyAndUnshift(obj, obj_bit); | 80 BlackToGreyAndUnshift(obj, obj_bit); |
| 46 RestartIfNotMarking(); | 81 RestartIfNotMarking(); |
| 47 } | 82 } |
| 48 | 83 |
| 49 // Object is either grey or white it will be scanned if survives. | 84 // Object is either grey or white it will be scanned if survives. |
| 50 return; | 85 return; |
| 51 } | 86 } |
| 52 | 87 |
| 53 if (is_compacting_ && slot != NULL) { | 88 if (is_compacting_) { |
| 54 MarkBit obj_bit = Marking::MarkBitFrom(obj); | 89 MarkBit obj_bit = Marking::MarkBitFrom(obj); |
| 55 if (Marking::IsBlack(obj_bit)) { | 90 if (Marking::IsBlack(obj_bit)) { |
| 56 // Object is not going to be rescanned we need to record the slot. | 91 // Object is not going to be rescanned we need to record the slot. |
| 57 heap_->mark_compact_collector()->RecordSlot( | 92 heap_->mark_compact_collector()->RecordRelocSlot(rinfo, |
| 58 HeapObject::RawField(obj, 0), slot, value); | 93 Code::cast(value)); |
| 59 } | 94 } |
| 60 } | 95 } |
| 61 } | 96 } |
| 62 } | 97 } |
| 63 | 98 |
| 64 | 99 |
| 65 void IncrementalMarking::RecordWriteOf(HeapObject* value) { | |
| 66 if (IsMarking()) { | |
| 67 ASSERT(!MarkCompactCollector::IsOnEvacuationCandidate(value)); | |
| 68 | |
| 69 MarkBit value_bit = Marking::MarkBitFrom(value); | |
| 70 if (Marking::IsWhite(value_bit)) { | |
| 71 WhiteToGreyAndPush(value, value_bit); | |
| 72 RestartIfNotMarking(); | |
| 73 } | |
| 74 } | |
| 75 } | |
| 76 | |
| 77 | |
| 78 void IncrementalMarking::RecordWrites(HeapObject* obj) { | 100 void IncrementalMarking::RecordWrites(HeapObject* obj) { |
| 79 if (IsMarking()) { | 101 if (IsMarking()) { |
| 80 MarkBit obj_bit = Marking::MarkBitFrom(obj); | 102 MarkBit obj_bit = Marking::MarkBitFrom(obj); |
| 81 if (Marking::IsBlack(obj_bit)) { | 103 if (Marking::IsBlack(obj_bit)) { |
| 82 BlackToGreyAndUnshift(obj, obj_bit); | 104 BlackToGreyAndUnshift(obj, obj_bit); |
| 83 RestartIfNotMarking(); | 105 RestartIfNotMarking(); |
| 84 } | 106 } |
| 85 } | 107 } |
| 86 } | 108 } |
| 87 | 109 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 ASSERT(Marking::MarkBitFrom(obj) == mark_bit); | 144 ASSERT(Marking::MarkBitFrom(obj) == mark_bit); |
| 123 ASSERT(obj->Size() >= 2*kPointerSize); | 145 ASSERT(obj->Size() >= 2*kPointerSize); |
| 124 ASSERT(IsMarking()); | 146 ASSERT(IsMarking()); |
| 125 Marking::WhiteToGrey(mark_bit); | 147 Marking::WhiteToGrey(mark_bit); |
| 126 } | 148 } |
| 127 | 149 |
| 128 | 150 |
| 129 } } // namespace v8::internal | 151 } } // namespace v8::internal |
| 130 | 152 |
| 131 #endif // V8_INCREMENTAL_MARKING_INL_H_ | 153 #endif // V8_INCREMENTAL_MARKING_INL_H_ |
| OLD | NEW |