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

Side by Side Diff: src/incremental-marking.cc

Issue 7834018: Support compaction for code space pages. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: port changes from ia32 to arm & x64 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
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 void IncrementalMarking::RecordWriteForEvacuationFromCode(HeapObject* obj, 76 void IncrementalMarking::RecordWriteForEvacuationFromCode(HeapObject* obj,
77 Object** slot, 77 Object** slot,
78 Isolate* isolate) { 78 Isolate* isolate) {
79 IncrementalMarking* marking = isolate->heap()->incremental_marking(); 79 IncrementalMarking* marking = isolate->heap()->incremental_marking();
80 ASSERT(marking->is_compacting_); 80 ASSERT(marking->is_compacting_);
81 marking->RecordWrite(obj, slot, *slot); 81 marking->RecordWrite(obj, slot, *slot);
82 } 82 }
83 83
84 84
85 void IncrementalMarking::RecordCodeTargetPatch(Address pc, HeapObject* value) {
86 if (IsMarking()) {
87 ASSERT(!MarkCompactCollector::IsOnEvacuationCandidate(value));
88
89 MarkBit value_bit = Marking::MarkBitFrom(value);
90 if (Marking::IsWhite(value_bit)) {
91 WhiteToGreyAndPush(value, value_bit);
92 RestartIfNotMarking();
93 }
94
95
96 if (is_compacting_) {
97 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, NULL, NULL);
98 heap_->mark_compact_collector()->RecordRelocSlot(&rinfo,
99 Code::cast(value));
100 }
101 }
102 }
103
104
105 void IncrementalMarking::RecordWriteOfCodeEntry(JSFunction* host,
106 Object** slot,
107 Code* value) {
108 if (BaseRecordWrite(host, slot, value) && is_compacting_) {
109 ASSERT(slot != NULL);
110 heap_->mark_compact_collector()->
111 RecordCodeEntrySlot(reinterpret_cast<Address>(slot), value);
112 }
113 }
114
115
116
85 class IncrementalMarkingMarkingVisitor : public ObjectVisitor { 117 class IncrementalMarkingMarkingVisitor : public ObjectVisitor {
86 public: 118 public:
87 IncrementalMarkingMarkingVisitor(Heap* heap, 119 IncrementalMarkingMarkingVisitor(Heap* heap,
88 IncrementalMarking* incremental_marking) 120 IncrementalMarking* incremental_marking)
89 : heap_(heap), 121 : heap_(heap),
90 incremental_marking_(incremental_marking) { 122 incremental_marking_(incremental_marking) {
91 } 123 }
92 124
125 void VisitCodeTarget(RelocInfo* rinfo) {
126 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode()));
127 Object* target = Code::GetCodeFromTargetAddress(rinfo->target_address());
128 heap_->mark_compact_collector()->RecordRelocSlot(rinfo, Code::cast(target));
129 MarkObject(target);
130 }
131
132 void VisitDebugTarget(RelocInfo* rinfo) {
133 ASSERT((RelocInfo::IsJSReturn(rinfo->rmode()) &&
134 rinfo->IsPatchedReturnSequence()) ||
135 (RelocInfo::IsDebugBreakSlot(rinfo->rmode()) &&
136 rinfo->IsPatchedDebugBreakSlotSequence()));
137 Object* target = Code::GetCodeFromTargetAddress(rinfo->call_address());
138 heap_->mark_compact_collector()->RecordRelocSlot(rinfo, Code::cast(target));
139 MarkObject(target);
140 }
141
142 void VisitCodeEntry(Address entry_address) {
143 Object* target = Code::GetObjectFromEntryAddress(entry_address);
144 heap_->mark_compact_collector()->
145 RecordCodeEntrySlot(entry_address, Code::cast(target));
146 MarkObject(target);
147 }
148
93 void VisitPointer(Object** p) { 149 void VisitPointer(Object** p) {
94 MarkObjectByPointer(p, p); 150 Object* obj = *p;
151 if (obj->NonFailureIsHeapObject()) {
152 heap_->mark_compact_collector()->RecordSlot(p, p, obj);
153 MarkObject(obj);
154 }
95 } 155 }
96 156
97 void VisitPointers(Object** start, Object** end) { 157 void VisitPointers(Object** start, Object** end) {
98 for (Object** p = start; p < end; p++) MarkObjectByPointer(start, p); 158 for (Object** p = start; p < end; p++) {
159 Object* obj = *p;
160 if (obj->NonFailureIsHeapObject()) {
161 heap_->mark_compact_collector()->RecordSlot(start, p, obj);
162 MarkObject(obj);
163 }
164 }
99 } 165 }
100 166
101 private: 167 private:
102 // Mark object pointed to by p. 168 // Mark object pointed to by p.
103 INLINE(void MarkObjectByPointer(Object** anchor, Object** p)) { 169 INLINE(void MarkObject(Object* obj)) {
104 Object* obj = *p; 170 HeapObject* heap_object = HeapObject::cast(obj);
105 // Since we can be sure that the object is not tagged as a failure we can 171 MarkBit mark_bit = Marking::MarkBitFrom(heap_object);
106 // inline a slightly more efficient tag check here than IsHeapObject() would 172 if (mark_bit.data_only()) {
107 // produce. 173 if (incremental_marking_->MarkBlackOrKeepGrey(mark_bit)) {
108 if (obj->NonFailureIsHeapObject()) { 174 MemoryChunk::IncrementLiveBytes(heap_object->address(),
109 HeapObject* heap_object = HeapObject::cast(obj); 175 heap_object->Size());
110
111 heap_->mark_compact_collector()->RecordSlot(anchor, p, obj);
112 MarkBit mark_bit = Marking::MarkBitFrom(heap_object);
113 if (mark_bit.data_only()) {
114 if (incremental_marking_->MarkBlackOrKeepGrey(mark_bit)) {
115 MemoryChunk::IncrementLiveBytes(heap_object->address(),
116 heap_object->Size());
117 }
118 } else if (Marking::IsWhite(mark_bit)) {
119 incremental_marking_->WhiteToGreyAndPush(heap_object, mark_bit);
120 } 176 }
177 } else if (Marking::IsWhite(mark_bit)) {
178 incremental_marking_->WhiteToGreyAndPush(heap_object, mark_bit);
121 } 179 }
122 } 180 }
123 181
124 Heap* heap_; 182 Heap* heap_;
125 IncrementalMarking* incremental_marking_; 183 IncrementalMarking* incremental_marking_;
126 }; 184 };
127 185
128 186
129 class IncrementalMarkingRootMarkingVisitor : public ObjectVisitor { 187 class IncrementalMarkingRootMarkingVisitor : public ObjectVisitor {
130 public: 188 public:
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 double end = OS::TimeCurrentMillis(); 654 double end = OS::TimeCurrentMillis();
597 double delta = (end - start); 655 double delta = (end - start);
598 longest_step_ = Max(longest_step_, delta); 656 longest_step_ = Max(longest_step_, delta);
599 steps_took_ += delta; 657 steps_took_ += delta;
600 steps_took_since_last_gc_ += delta; 658 steps_took_since_last_gc_ += delta;
601 } 659 }
602 } 660 }
603 661
604 662
605 } } // namespace v8::internal 663 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698