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

Side by Side Diff: src/heap/objects-visiting.cc

Issue 1440243002: Object's body descriptors refactoring. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@new-visitor-base
Patch Set: New files added to the lists Created 5 years, 1 month 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/heap/objects-visiting.h ('k') | src/heap/objects-visiting-inl.h » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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/objects-visiting.h" 5 #include "src/heap/objects-visiting.h"
6 6
7 #include "src/heap/mark-compact-inl.h" 7 #include "src/heap/mark-compact-inl.h"
8 #include "src/heap/objects-visiting-inl.h" 8 #include "src/heap/objects-visiting-inl.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 return GetVisitorIdForSize(kVisitStruct, kVisitStructGeneric, 172 return GetVisitorIdForSize(kVisitStruct, kVisitStructGeneric,
173 instance_size, has_unboxed_fields); 173 instance_size, has_unboxed_fields);
174 174
175 default: 175 default:
176 UNREACHABLE(); 176 UNREACHABLE();
177 return kVisitorIdCount; 177 return kVisitorIdCount;
178 } 178 }
179 } 179 }
180 180
181 181
182 void HeapObject::IterateBody(InstanceType type, int object_size,
183 ObjectVisitor* v) {
184 // Avoiding <Type>::cast(this) because it accesses the map pointer field.
185 // During GC, the map pointer field is encoded.
186 if (type < FIRST_NONSTRING_TYPE) {
187 switch (type & kStringRepresentationMask) {
188 case kSeqStringTag:
189 break;
190 case kConsStringTag:
191 ConsString::BodyDescriptor::IterateBody(this, v);
192 break;
193 case kSlicedStringTag:
194 SlicedString::BodyDescriptor::IterateBody(this, v);
195 break;
196 case kExternalStringTag:
197 if ((type & kStringEncodingMask) == kOneByteStringTag) {
198 reinterpret_cast<ExternalOneByteString*>(this)
199 ->ExternalOneByteStringIterateBody(v);
200 } else {
201 reinterpret_cast<ExternalTwoByteString*>(this)
202 ->ExternalTwoByteStringIterateBody(v);
203 }
204 break;
205 }
206 return;
207 }
208
209 switch (type) {
210 case FIXED_ARRAY_TYPE:
211 FixedArray::BodyDescriptor::IterateBody(this, object_size, v);
212 break;
213 case FIXED_DOUBLE_ARRAY_TYPE:
214 break;
215 case JS_OBJECT_TYPE:
216 case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
217 case JS_GENERATOR_OBJECT_TYPE:
218 case JS_MODULE_TYPE:
219 case JS_VALUE_TYPE:
220 case JS_DATE_TYPE:
221 case JS_ARRAY_TYPE:
222 case JS_TYPED_ARRAY_TYPE:
223 case JS_DATA_VIEW_TYPE:
224 case JS_SET_TYPE:
225 case JS_MAP_TYPE:
226 case JS_SET_ITERATOR_TYPE:
227 case JS_MAP_ITERATOR_TYPE:
228 case JS_ITERATOR_RESULT_TYPE:
229 case JS_WEAK_MAP_TYPE:
230 case JS_WEAK_SET_TYPE:
231 case JS_REGEXP_TYPE:
232 case JS_GLOBAL_PROXY_TYPE:
233 case JS_GLOBAL_OBJECT_TYPE:
234 case JS_MESSAGE_OBJECT_TYPE:
235 JSObject::BodyDescriptor::IterateBody(this, object_size, v);
236 break;
237 case JS_ARRAY_BUFFER_TYPE:
238 JSArrayBuffer::JSArrayBufferIterateBody(this, v);
239 break;
240 case JS_FUNCTION_TYPE:
241 JSFunction::BodyDescriptor::IterateBody(this, object_size, v);
242 break;
243 case ODDBALL_TYPE:
244 Oddball::BodyDescriptor::IterateBody(this, v);
245 break;
246 case JS_PROXY_TYPE:
247 JSProxy::BodyDescriptor::IterateBody(this, v);
248 break;
249 case JS_FUNCTION_PROXY_TYPE:
250 JSFunctionProxy::BodyDescriptor::IterateBody(this, v);
251 break;
252 case FOREIGN_TYPE:
253 reinterpret_cast<Foreign*>(this)->ForeignIterateBody(v);
254 break;
255 case MAP_TYPE:
256 Map::BodyDescriptor::IterateBody(this, v);
257 break;
258 case CODE_TYPE:
259 reinterpret_cast<Code*>(this)->CodeIterateBody(v);
260 break;
261 case CELL_TYPE:
262 Cell::BodyDescriptor::IterateBody(this, v);
263 break;
264 case PROPERTY_CELL_TYPE:
265 PropertyCell::BodyDescriptor::IterateBody(this, v);
266 break;
267 case WEAK_CELL_TYPE:
268 WeakCell::BodyDescriptor::IterateBody(this, v);
269 break;
270 case SYMBOL_TYPE:
271 Symbol::BodyDescriptor::IterateBody(this, v);
272 break;
273 case BYTECODE_ARRAY_TYPE:
274 reinterpret_cast<BytecodeArray*>(this)->BytecodeArrayIterateBody(v);
275 break;
276
277 case HEAP_NUMBER_TYPE:
278 case MUTABLE_HEAP_NUMBER_TYPE:
279 case SIMD128_VALUE_TYPE:
280 case FILLER_TYPE:
281 case BYTE_ARRAY_TYPE:
282 case FREE_SPACE_TYPE:
283 break;
284
285 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
286 case FIXED_##TYPE##_ARRAY_TYPE: \
287 reinterpret_cast<FixedTypedArrayBase*>(this) \
288 ->FixedTypedArrayBaseIterateBody(v); \
289 break;
290 TYPED_ARRAYS(TYPED_ARRAY_CASE)
291 #undef TYPED_ARRAY_CASE
292
293 case SHARED_FUNCTION_INFO_TYPE: {
294 SharedFunctionInfo::BodyDescriptor::IterateBody(this, v);
295 break;
296 }
297
298 #define MAKE_STRUCT_CASE(NAME, Name, name) case NAME##_TYPE:
299 STRUCT_LIST(MAKE_STRUCT_CASE)
300 #undef MAKE_STRUCT_CASE
301 if (type == ALLOCATION_SITE_TYPE) {
302 AllocationSite::BodyDescriptor::IterateBody(this, v);
303 } else {
304 StructBodyDescriptor::IterateBody(this, object_size, v);
305 }
306 break;
307 default:
308 PrintF("Unknown type: %d\n", type);
309 UNREACHABLE();
310 }
311 }
312
313
314 // We don't record weak slots during marking or scavenges. Instead we do it 182 // We don't record weak slots during marking or scavenges. Instead we do it
315 // once when we complete mark-compact cycle. Note that write barrier has no 183 // once when we complete mark-compact cycle. Note that write barrier has no
316 // effect if we are already in the middle of compacting mark-sweep cycle and we 184 // effect if we are already in the middle of compacting mark-sweep cycle and we
317 // have to record slots manually. 185 // have to record slots manually.
318 static bool MustRecordSlots(Heap* heap) { 186 static bool MustRecordSlots(Heap* heap) {
319 return heap->gc_state() == Heap::MARK_COMPACT && 187 return heap->gc_state() == Heap::MARK_COMPACT &&
320 heap->mark_compact_collector()->is_compacting(); 188 heap->mark_compact_collector()->is_compacting();
321 } 189 }
322 190
323 191
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 }; 357 };
490 358
491 359
492 template Object* VisitWeakList<Context>(Heap* heap, Object* list, 360 template Object* VisitWeakList<Context>(Heap* heap, Object* list,
493 WeakObjectRetainer* retainer); 361 WeakObjectRetainer* retainer);
494 362
495 template Object* VisitWeakList<AllocationSite>(Heap* heap, Object* list, 363 template Object* VisitWeakList<AllocationSite>(Heap* heap, Object* list,
496 WeakObjectRetainer* retainer); 364 WeakObjectRetainer* retainer);
497 } // namespace internal 365 } // namespace internal
498 } // namespace v8 366 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/objects-visiting.h ('k') | src/heap/objects-visiting-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698