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

Side by Side Diff: src/objects-visiting-inl.h

Issue 10816007: Refactor incremental marking to use static visitor. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Toon Verwaest. Created 8 years, 5 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 | « src/objects-visiting.h ('k') | 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 2012 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
11 // with the distribution. 11 // with the distribution.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 table_.template RegisterSpecializations<JSObjectVisitor, 87 table_.template RegisterSpecializations<JSObjectVisitor,
88 kVisitJSObject, 88 kVisitJSObject,
89 kVisitJSObjectGeneric>(); 89 kVisitJSObjectGeneric>();
90 table_.template RegisterSpecializations<StructVisitor, 90 table_.template RegisterSpecializations<StructVisitor,
91 kVisitStruct, 91 kVisitStruct,
92 kVisitStructGeneric>(); 92 kVisitStructGeneric>();
93 } 93 }
94 94
95 95
96 template<typename StaticVisitor>
97 void StaticMarkingVisitor<StaticVisitor>::Initialize() {
98 table_.Register(kVisitShortcutCandidate,
99 &FixedBodyVisitor<StaticVisitor,
100 ConsString::BodyDescriptor,
101 void>::Visit);
102
103 table_.Register(kVisitConsString,
104 &FixedBodyVisitor<StaticVisitor,
105 ConsString::BodyDescriptor,
106 void>::Visit);
107
108 table_.Register(kVisitSlicedString,
109 &FixedBodyVisitor<StaticVisitor,
110 SlicedString::BodyDescriptor,
111 void>::Visit);
112
113 table_.Register(kVisitFixedArray,
114 &FlexibleBodyVisitor<StaticVisitor,
115 FixedArray::BodyDescriptor,
116 void>::Visit);
117
118 table_.Register(kVisitFixedDoubleArray, &DataObjectVisitor::Visit);
119
120 table_.Register(kVisitGlobalContext, &VisitGlobalContext);
121
122 table_.Register(kVisitByteArray, &DataObjectVisitor::Visit);
123
124 table_.Register(kVisitFreeSpace, &DataObjectVisitor::Visit);
125
126 table_.Register(kVisitSeqAsciiString, &DataObjectVisitor::Visit);
127
128 table_.Register(kVisitSeqTwoByteString, &DataObjectVisitor::Visit);
129
130 table_.Register(kVisitJSWeakMap, &StaticVisitor::VisitJSWeakMap);
131
132 table_.Register(kVisitOddball,
133 &FixedBodyVisitor<StaticVisitor,
134 Oddball::BodyDescriptor,
135 void>::Visit);
136
137 table_.Register(kVisitMap,
138 &FixedBodyVisitor<StaticVisitor,
139 Map::BodyDescriptor,
140 void>::Visit);
141
142 table_.Register(kVisitCode, &StaticVisitor::VisitCode);
143
144 // Registration for kVisitSharedFunctionInfo is done by StaticVisitor.
145
146 // Registration for kVisitJSFunction is done by StaticVisitor.
147
148 // Registration for kVisitJSRegExp is done by StaticVisitor.
149
150 table_.Register(kVisitPropertyCell,
151 &FixedBodyVisitor<StaticVisitor,
152 JSGlobalPropertyCell::BodyDescriptor,
153 void>::Visit);
154
155 table_.template RegisterSpecializations<DataObjectVisitor,
156 kVisitDataObject,
157 kVisitDataObjectGeneric>();
158
159 table_.template RegisterSpecializations<JSObjectVisitor,
160 kVisitJSObject,
161 kVisitJSObjectGeneric>();
162
163 table_.template RegisterSpecializations<StructObjectVisitor,
164 kVisitStruct,
165 kVisitStructGeneric>();
166 }
167
168
169 template<typename StaticVisitor>
170 void StaticMarkingVisitor<StaticVisitor>::VisitCodeEntry(
171 Heap* heap, Address entry_address) {
172 Code* code = Code::cast(Code::GetObjectFromEntryAddress(entry_address));
173 heap->mark_compact_collector()->RecordCodeEntrySlot(entry_address, code);
174 StaticVisitor::MarkObject(heap, code);
175 }
176
177
178 template<typename StaticVisitor>
179 void StaticMarkingVisitor<StaticVisitor>::VisitGlobalPropertyCell(
180 Heap* heap, RelocInfo* rinfo) {
181 ASSERT(rinfo->rmode() == RelocInfo::GLOBAL_PROPERTY_CELL);
182 JSGlobalPropertyCell* cell = rinfo->target_cell();
183 StaticVisitor::MarkObject(heap, cell);
184 }
185
186
187 template<typename StaticVisitor>
188 void StaticMarkingVisitor<StaticVisitor>::VisitDebugTarget(
189 Heap* heap, RelocInfo* rinfo) {
190 ASSERT((RelocInfo::IsJSReturn(rinfo->rmode()) &&
191 rinfo->IsPatchedReturnSequence()) ||
192 (RelocInfo::IsDebugBreakSlot(rinfo->rmode()) &&
193 rinfo->IsPatchedDebugBreakSlotSequence()));
194 Code* target = Code::GetCodeFromTargetAddress(rinfo->call_address());
195 heap->mark_compact_collector()->RecordRelocSlot(rinfo, target);
196 StaticVisitor::MarkObject(heap, target);
197 }
198
199
200 template<typename StaticVisitor>
201 void StaticMarkingVisitor<StaticVisitor>::VisitGlobalContext(
202 Map* map, HeapObject* object) {
203 FixedBodyVisitor<StaticVisitor,
204 Context::MarkCompactBodyDescriptor,
205 void>::Visit(map, object);
206
207 MarkCompactCollector* collector = map->GetHeap()->mark_compact_collector();
208 for (int idx = Context::FIRST_WEAK_SLOT;
209 idx < Context::GLOBAL_CONTEXT_SLOTS;
210 ++idx) {
211 Object** slot =
212 HeapObject::RawField(object, FixedArray::OffsetOfElementAt(idx));
213 collector->RecordSlot(slot, slot, *slot);
214 }
215 }
216
217
218 template<typename StaticVisitor>
219 void StaticMarkingVisitor<StaticVisitor>::VisitJSRegExp(
220 Map* map, HeapObject* object) {
221 int last_property_offset =
222 JSRegExp::kSize + kPointerSize * map->inobject_properties();
223 StaticVisitor::VisitPointers(map->GetHeap(),
224 HeapObject::RawField(object, JSRegExp::kPropertiesOffset),
225 HeapObject::RawField(object, last_property_offset));
226 }
227
228
96 void Code::CodeIterateBody(ObjectVisitor* v) { 229 void Code::CodeIterateBody(ObjectVisitor* v) {
97 int mode_mask = RelocInfo::kCodeTargetMask | 230 int mode_mask = RelocInfo::kCodeTargetMask |
98 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | 231 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
99 RelocInfo::ModeMask(RelocInfo::GLOBAL_PROPERTY_CELL) | 232 RelocInfo::ModeMask(RelocInfo::GLOBAL_PROPERTY_CELL) |
100 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | 233 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) |
101 RelocInfo::ModeMask(RelocInfo::JS_RETURN) | 234 RelocInfo::ModeMask(RelocInfo::JS_RETURN) |
102 RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) | 235 RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) |
103 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY); 236 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY);
104 237
105 // There are two places where we iterate code bodies: here and the 238 // There are two places where we iterate code bodies: here and the
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 RelocIterator it(this, mode_mask); 277 RelocIterator it(this, mode_mask);
145 for (; !it.done(); it.next()) { 278 for (; !it.done(); it.next()) {
146 it.rinfo()->template Visit<StaticVisitor>(heap); 279 it.rinfo()->template Visit<StaticVisitor>(heap);
147 } 280 }
148 } 281 }
149 282
150 283
151 } } // namespace v8::internal 284 } } // namespace v8::internal
152 285
153 #endif // V8_OBJECTS_VISITING_INL_H_ 286 #endif // V8_OBJECTS_VISITING_INL_H_
OLDNEW
« no previous file with comments | « src/objects-visiting.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698