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

Side by Side Diff: src/objects-body-descriptors-inl.h

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/objects-body-descriptors.h ('k') | src/objects-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
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef V8_OBJECTS_BODY_DESCRIPTORS_INL_H_
6 #define V8_OBJECTS_BODY_DESCRIPTORS_INL_H_
7
8 #include "src/objects-body-descriptors.h"
9
10 namespace v8 {
11 namespace internal {
12
13 template <int start_offset>
14 int FlexibleBodyDescriptor<start_offset>::SizeOf(Map* map, HeapObject* object) {
15 return object->SizeFromMap(map);
16 }
17
18
19 bool BodyDescriptorBase::IsValidSlotImpl(HeapObject* obj, int offset) {
20 if (!FLAG_unbox_double_fields || obj->map()->HasFastPointerLayout()) {
21 return true;
22 } else {
23 DCHECK(FLAG_unbox_double_fields);
24 DCHECK(IsAligned(offset, kPointerSize));
25
26 LayoutDescriptorHelper helper(obj->map());
27 DCHECK(!helper.all_fields_tagged());
28 return helper.IsTagged(offset);
29 }
30 }
31
32 template <typename ObjectVisitor>
33 void BodyDescriptorBase::IterateBodyImpl(HeapObject* obj, int start_offset,
34 int end_offset, ObjectVisitor* v) {
35 if (!FLAG_unbox_double_fields || obj->map()->HasFastPointerLayout()) {
36 IteratePointers(obj, start_offset, end_offset, v);
37 } else {
38 DCHECK(FLAG_unbox_double_fields);
39 DCHECK(IsAligned(start_offset, kPointerSize) &&
40 IsAligned(end_offset, kPointerSize));
41
42 LayoutDescriptorHelper helper(obj->map());
43 DCHECK(!helper.all_fields_tagged());
44 for (int offset = start_offset; offset < end_offset;) {
45 int end_of_region_offset;
46 if (helper.IsTagged(offset, end_offset, &end_of_region_offset)) {
47 IteratePointers(obj, offset, end_of_region_offset, v);
48 }
49 offset = end_of_region_offset;
50 }
51 }
52 }
53
54
55 template <typename StaticVisitor>
56 void BodyDescriptorBase::IterateBodyImpl(Heap* heap, HeapObject* obj,
57 int start_offset, int end_offset) {
58 if (!FLAG_unbox_double_fields || obj->map()->HasFastPointerLayout()) {
59 IteratePointers<StaticVisitor>(heap, obj, start_offset, end_offset);
60 } else {
61 DCHECK(FLAG_unbox_double_fields);
62 DCHECK(IsAligned(start_offset, kPointerSize) &&
63 IsAligned(end_offset, kPointerSize));
64
65 LayoutDescriptorHelper helper(obj->map());
66 DCHECK(!helper.all_fields_tagged());
67 for (int offset = start_offset; offset < end_offset;) {
68 int end_of_region_offset;
69 if (helper.IsTagged(offset, end_offset, &end_of_region_offset)) {
70 IteratePointers<StaticVisitor>(heap, obj, offset, end_of_region_offset);
71 }
72 offset = end_of_region_offset;
73 }
74 }
75 }
76
77
78 template <typename ObjectVisitor>
79 void BodyDescriptorBase::IteratePointers(HeapObject* obj, int start_offset,
80 int end_offset, ObjectVisitor* v) {
81 v->VisitPointers(HeapObject::RawField(obj, start_offset),
82 HeapObject::RawField(obj, end_offset));
83 }
84
85
86 template <typename StaticVisitor>
87 void BodyDescriptorBase::IteratePointers(Heap* heap, HeapObject* obj,
88 int start_offset, int end_offset) {
89 StaticVisitor::VisitPointers(heap, obj,
90 HeapObject::RawField(obj, start_offset),
91 HeapObject::RawField(obj, end_offset));
92 }
93
94
95 template <typename ObjectVisitor>
96 void BodyDescriptorBase::IteratePointer(HeapObject* obj, int offset,
97 ObjectVisitor* v) {
98 v->VisitPointer(HeapObject::RawField(obj, offset));
99 }
100
101
102 template <typename StaticVisitor>
103 void BodyDescriptorBase::IteratePointer(Heap* heap, HeapObject* obj,
104 int offset) {
105 StaticVisitor::VisitPointer(heap, obj, HeapObject::RawField(obj, offset));
106 }
107
108
109 // Iterates the function object according to the visiting policy.
110 template <JSFunction::BodyVisitingPolicy body_visiting_policy>
111 class JSFunction::BodyDescriptorImpl final : public BodyDescriptorBase {
112 public:
113 STATIC_ASSERT(kNonWeakFieldsEndOffset == kCodeEntryOffset);
114 STATIC_ASSERT(kCodeEntryOffset + kPointerSize == kNextFunctionLinkOffset);
115 STATIC_ASSERT(kNextFunctionLinkOffset + kPointerSize == kSize);
116
117 static bool IsValidSlot(HeapObject* obj, int offset) {
118 if (offset < kSize) return true;
119 // TODO(ishell): v8:4531, fix when JFunctions are allowed to have
120 // in-object properties
121 // return IsValidSlotImpl(obj, offset);
122 return true;
123 }
124
125 template <typename ObjectVisitor>
126 static inline void IterateBody(HeapObject* obj, int object_size,
127 ObjectVisitor* v) {
128 IteratePointers(obj, kPropertiesOffset, kNonWeakFieldsEndOffset, v);
129
130 if (body_visiting_policy & kVisitCodeEntry) {
131 v->VisitCodeEntry(obj->address() + kCodeEntryOffset);
132 }
133
134 if (body_visiting_policy & kVisitNextFunction) {
135 IteratePointers(obj, kNextFunctionLinkOffset, kSize, v);
136 }
137
138 // TODO(ishell): v8:4531, fix when JFunctions are allowed to have in-object
139 // properties
140 // IterateBodyImpl(obj, kSize, object_size, v);
141 }
142
143 template <typename StaticVisitor>
144 static inline void IterateBody(HeapObject* obj, int object_size) {
145 Heap* heap = obj->GetHeap();
146 IteratePointers<StaticVisitor>(heap, obj, kPropertiesOffset,
147 kNonWeakFieldsEndOffset);
148
149 if (body_visiting_policy & kVisitCodeEntry) {
150 StaticVisitor::VisitCodeEntry(heap, obj,
151 obj->address() + kCodeEntryOffset);
152 }
153
154 if (body_visiting_policy & kVisitNextFunction) {
155 IteratePointers<StaticVisitor>(heap, obj, kNextFunctionLinkOffset, kSize);
156 }
157
158 // TODO(ishell): v8:4531, fix when JFunctions are allowed to have in-object
159 // properties
160 // IterateBodyImpl<StaticVisitor>(heap, obj, kSize, object_size);
161 }
162
163 static inline int SizeOf(Map* map, HeapObject* object) {
164 // TODO(ishell): v8:4531, fix when JFunctions are allowed to have in-object
165 // properties
166 return JSFunction::kSize;
167 }
168 };
169
170
171 class JSArrayBuffer::BodyDescriptor final : public BodyDescriptorBase {
172 public:
173 STATIC_ASSERT(kByteLengthOffset + kPointerSize == kBackingStoreOffset);
174 STATIC_ASSERT(kBackingStoreOffset + kPointerSize == kBitFieldSlot);
175 STATIC_ASSERT(kBitFieldSlot + kPointerSize == kSize);
176
177 static bool IsValidSlot(HeapObject* obj, int offset) {
178 if (offset < kBackingStoreOffset) return true;
179 if (offset < kSize) return false;
180 if (offset < kSizeWithInternalFields) return true;
181 // TODO(ishell): v8:4531, fix when JSArrayBuffers are allowed to have
182 // in-object properties
183 // return IsValidSlotImpl(obj, offset);
184 return true;
185 }
186
187 template <typename ObjectVisitor>
188 static inline void IterateBody(HeapObject* obj, int object_size,
189 ObjectVisitor* v) {
190 IteratePointers(obj, kPropertiesOffset, kBackingStoreOffset, v);
191 IteratePointers(obj, kSize, kSizeWithInternalFields, v);
192
193 // TODO(ishell): v8:4531, fix when JSArrayBuffers are allowed to have
194 // in-object properties
195 // IterateBodyImpl(obj, kSize, object_size, v);
196 }
197
198 template <typename StaticVisitor>
199 static inline void IterateBody(HeapObject* obj, int object_size) {
200 Heap* heap = obj->GetHeap();
201 IteratePointers<StaticVisitor>(heap, obj, kPropertiesOffset,
202 kBackingStoreOffset);
203 IteratePointers<StaticVisitor>(heap, obj, kSize, kSizeWithInternalFields);
204
205 // TODO(ishell): v8:4531, fix when JSArrayBuffers are allowed to have
206 // in-object properties
207 // IterateBodyImpl<StaticVisitor>(heap, obj, kSize, object_size);
208 }
209
210 static inline int SizeOf(Map* map, HeapObject* object) {
211 // TODO(ishell): v8:4531, fix when JSArrayBuffers are allowed to have
212 // in-object properties
213 // return map->instance_size();
214 return kSizeWithInternalFields;
215 }
216 };
217
218
219 class BytecodeArray::BodyDescriptor final : public BodyDescriptorBase {
220 public:
221 static bool IsValidSlot(HeapObject* obj, int offset) {
222 return offset == kConstantPoolOffset;
223 }
224
225 template <typename ObjectVisitor>
226 static inline void IterateBody(HeapObject* obj, int object_size,
227 ObjectVisitor* v) {
228 IteratePointer(obj, kConstantPoolOffset, v);
229 }
230
231 template <typename StaticVisitor>
232 static inline void IterateBody(HeapObject* obj, int object_size) {
233 Heap* heap = obj->GetHeap();
234 IteratePointer<StaticVisitor>(heap, obj, kConstantPoolOffset);
235 }
236
237 static inline int SizeOf(Map* map, HeapObject* object) {
238 return SizeFor(
239 reinterpret_cast<FixedArray*>(object)->synchronized_length());
240 }
241 };
242
243
244 class FixedTypedArrayBase::BodyDescriptor final : public BodyDescriptorBase {
245 public:
246 static bool IsValidSlot(HeapObject* obj, int offset) {
247 return offset == kBasePointerOffset;
248 }
249
250 template <typename ObjectVisitor>
251 static inline void IterateBody(HeapObject* obj, int object_size,
252 ObjectVisitor* v) {
253 IteratePointer(obj, kBasePointerOffset, v);
254 }
255
256 template <typename StaticVisitor>
257 static inline void IterateBody(HeapObject* obj, int object_size) {
258 Heap* heap = obj->GetHeap();
259 IteratePointer<StaticVisitor>(heap, obj, kBasePointerOffset);
260 }
261
262 static inline int SizeOf(Map* map, HeapObject* object) {
263 return reinterpret_cast<FixedTypedArrayBase*>(object)->size();
264 }
265 };
266
267
268 class JSWeakCollection::BodyDescriptor final : public BodyDescriptorBase {
269 public:
270 static bool IsValidSlot(HeapObject* obj, int offset) {
271 // TODO(ishell): v8:4531, fix when JSWeakCollections are allowed to have
272 // in-object properties
273 // return IsValidSlotImpl(obj, offset);
274 return true;
275 }
276
277 template <typename ObjectVisitor>
278 static inline void IterateBody(HeapObject* obj, int object_size,
279 ObjectVisitor* v) {
280 IteratePointers(obj, kPropertiesOffset, kSize, v);
281
282 // TODO(ishell): v8:4531, fix when JSWeakCollections are allowed to have
283 // in-object properties
284 // IterateBodyImpl(obj, kSize, object_size, v);
285 }
286
287 template <typename StaticVisitor>
288 static inline void IterateBody(HeapObject* obj, int object_size) {
289 Heap* heap = obj->GetHeap();
290 IteratePointers<StaticVisitor>(heap, obj, kPropertiesOffset, kSize);
291
292 // TODO(ishell): v8:4531, fix when JSWeakCollections are allowed to have
293 // in-object properties
294 // IterateBodyImpl<StaticVisitor>(heap, obj, kSize, object_size);
295 }
296
297 static inline int SizeOf(Map* map, HeapObject* object) { return kSize; }
298 };
299
300
301 class Foreign::BodyDescriptor final : public BodyDescriptorBase {
302 public:
303 static bool IsValidSlot(HeapObject* obj, int offset) { return false; }
304
305 template <typename ObjectVisitor>
306 static inline void IterateBody(HeapObject* obj, int object_size,
307 ObjectVisitor* v) {
308 v->VisitExternalReference(reinterpret_cast<Address*>(
309 HeapObject::RawField(obj, kForeignAddressOffset)));
310 }
311
312 template <typename StaticVisitor>
313 static inline void IterateBody(HeapObject* obj, int object_size) {
314 StaticVisitor::VisitExternalReference(reinterpret_cast<Address*>(
315 HeapObject::RawField(obj, kForeignAddressOffset)));
316 }
317
318 static inline int SizeOf(Map* map, HeapObject* object) { return kSize; }
319 };
320
321
322 class ExternalOneByteString::BodyDescriptor final : public BodyDescriptorBase {
323 public:
324 static bool IsValidSlot(HeapObject* obj, int offset) { return false; }
325
326 template <typename ObjectVisitor>
327 static inline void IterateBody(HeapObject* obj, int object_size,
328 ObjectVisitor* v) {
329 typedef v8::String::ExternalOneByteStringResource Resource;
330 v->VisitExternalOneByteString(reinterpret_cast<Resource**>(
331 HeapObject::RawField(obj, kResourceOffset)));
332 }
333
334 template <typename StaticVisitor>
335 static inline void IterateBody(HeapObject* obj, int object_size) {
336 typedef v8::String::ExternalOneByteStringResource Resource;
337 StaticVisitor::VisitExternalOneByteString(reinterpret_cast<Resource**>(
338 HeapObject::RawField(obj, kResourceOffset)));
339 }
340
341 static inline int SizeOf(Map* map, HeapObject* object) { return kSize; }
342 };
343
344
345 class ExternalTwoByteString::BodyDescriptor final : public BodyDescriptorBase {
346 public:
347 static bool IsValidSlot(HeapObject* obj, int offset) { return false; }
348
349 template <typename ObjectVisitor>
350 static inline void IterateBody(HeapObject* obj, int object_size,
351 ObjectVisitor* v) {
352 typedef v8::String::ExternalStringResource Resource;
353 v->VisitExternalTwoByteString(reinterpret_cast<Resource**>(
354 HeapObject::RawField(obj, kResourceOffset)));
355 }
356
357 template <typename StaticVisitor>
358 static inline void IterateBody(HeapObject* obj, int object_size) {
359 typedef v8::String::ExternalStringResource Resource;
360 StaticVisitor::VisitExternalTwoByteString(reinterpret_cast<Resource**>(
361 HeapObject::RawField(obj, kResourceOffset)));
362 }
363
364 static inline int SizeOf(Map* map, HeapObject* object) { return kSize; }
365 };
366
367
368 class Code::BodyDescriptor final : public BodyDescriptorBase {
369 public:
370 STATIC_ASSERT(kRelocationInfoOffset + kPointerSize == kHandlerTableOffset);
371 STATIC_ASSERT(kHandlerTableOffset + kPointerSize ==
372 kDeoptimizationDataOffset);
373 STATIC_ASSERT(kDeoptimizationDataOffset + kPointerSize ==
374 kTypeFeedbackInfoOffset);
375 STATIC_ASSERT(kTypeFeedbackInfoOffset + kPointerSize == kNextCodeLinkOffset);
376
377 static bool IsValidSlot(HeapObject* obj, int offset) {
378 // Slots in code can't be invalid because we never trim code objects.
379 return true;
380 }
381
382 template <typename ObjectVisitor>
383 static inline void IterateBody(HeapObject* obj, ObjectVisitor* v) {
384 int mode_mask = RelocInfo::kCodeTargetMask |
385 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
386 RelocInfo::ModeMask(RelocInfo::CELL) |
387 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) |
388 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) |
389 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED) |
390 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY) |
391 RelocInfo::kDebugBreakSlotMask;
392
393 IteratePointers(obj, kRelocationInfoOffset, kNextCodeLinkOffset, v);
394 v->VisitNextCodeLink(HeapObject::RawField(obj, kNextCodeLinkOffset));
395
396 RelocIterator it(reinterpret_cast<Code*>(obj), mode_mask);
397 Isolate* isolate = obj->GetIsolate();
398 for (; !it.done(); it.next()) {
399 it.rinfo()->Visit(isolate, v);
400 }
401 }
402
403 template <typename ObjectVisitor>
404 static inline void IterateBody(HeapObject* obj, int object_size,
405 ObjectVisitor* v) {
406 IterateBody(obj, v);
407 }
408
409 template <typename StaticVisitor>
410 static inline void IterateBody(HeapObject* obj) {
411 int mode_mask = RelocInfo::kCodeTargetMask |
412 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
413 RelocInfo::ModeMask(RelocInfo::CELL) |
414 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) |
415 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) |
416 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED) |
417 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY) |
418 RelocInfo::kDebugBreakSlotMask;
419
420 Heap* heap = obj->GetHeap();
421 IteratePointers<StaticVisitor>(heap, obj, kRelocationInfoOffset,
422 kNextCodeLinkOffset);
423 StaticVisitor::VisitNextCodeLink(
424 heap, HeapObject::RawField(obj, kNextCodeLinkOffset));
425
426 RelocIterator it(reinterpret_cast<Code*>(obj), mode_mask);
427 for (; !it.done(); it.next()) {
428 it.rinfo()->template Visit<StaticVisitor>(heap);
429 }
430 }
431
432 template <typename StaticVisitor>
433 static inline void IterateBody(HeapObject* obj, int object_size) {
434 IterateBody<StaticVisitor>(obj);
435 }
436
437 static inline int SizeOf(Map* map, HeapObject* object) {
438 return reinterpret_cast<Code*>(object)->CodeSize();
439 }
440 };
441
442
443 template <typename Op, typename ReturnType, typename T1, typename T2,
444 typename T3>
445 ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3) {
446 if (type < FIRST_NONSTRING_TYPE) {
447 switch (type & kStringRepresentationMask) {
448 case kSeqStringTag:
449 return ReturnType();
450 case kConsStringTag:
451 return Op::template apply<ConsString::BodyDescriptor>(p1, p2, p3);
452 case kSlicedStringTag:
453 return Op::template apply<SlicedString::BodyDescriptor>(p1, p2, p3);
454 case kExternalStringTag:
455 if ((type & kStringEncodingMask) == kOneByteStringTag) {
456 return Op::template apply<ExternalOneByteString::BodyDescriptor>(
457 p1, p2, p3);
458 } else {
459 return Op::template apply<ExternalTwoByteString::BodyDescriptor>(
460 p1, p2, p3);
461 }
462 }
463 UNREACHABLE();
464 return ReturnType();
465 }
466
467 switch (type) {
468 case FIXED_ARRAY_TYPE:
469 return Op::template apply<FixedArray::BodyDescriptor>(p1, p2, p3);
470 case FIXED_DOUBLE_ARRAY_TYPE:
471 return ReturnType();
472 case JS_OBJECT_TYPE:
473 case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
474 case JS_GENERATOR_OBJECT_TYPE:
475 case JS_MODULE_TYPE:
476 case JS_VALUE_TYPE:
477 case JS_DATE_TYPE:
478 case JS_ARRAY_TYPE:
479 case JS_TYPED_ARRAY_TYPE:
480 case JS_DATA_VIEW_TYPE:
481 case JS_SET_TYPE:
482 case JS_MAP_TYPE:
483 case JS_SET_ITERATOR_TYPE:
484 case JS_MAP_ITERATOR_TYPE:
485 case JS_ITERATOR_RESULT_TYPE:
486 case JS_REGEXP_TYPE:
487 case JS_GLOBAL_PROXY_TYPE:
488 case JS_GLOBAL_OBJECT_TYPE:
489 case JS_MESSAGE_OBJECT_TYPE:
490 return Op::template apply<JSObject::BodyDescriptor>(p1, p2, p3);
491 case JS_WEAK_MAP_TYPE:
492 case JS_WEAK_SET_TYPE:
493 return Op::template apply<JSWeakCollection::BodyDescriptor>(p1, p2, p3);
494 case JS_ARRAY_BUFFER_TYPE:
495 return Op::template apply<JSArrayBuffer::BodyDescriptor>(p1, p2, p3);
496 case JS_FUNCTION_TYPE:
497 return Op::template apply<JSFunction::BodyDescriptor>(p1, p2, p3);
498 case ODDBALL_TYPE:
499 return Op::template apply<Oddball::BodyDescriptor>(p1, p2, p3);
500 case JS_PROXY_TYPE:
501 return Op::template apply<JSProxy::BodyDescriptor>(p1, p2, p3);
502 case JS_FUNCTION_PROXY_TYPE:
503 return Op::template apply<JSFunctionProxy::BodyDescriptor>(p1, p2, p3);
504 case FOREIGN_TYPE:
505 return Op::template apply<Foreign::BodyDescriptor>(p1, p2, p3);
506 case MAP_TYPE:
507 return Op::template apply<Map::BodyDescriptor>(p1, p2, p3);
508 case CODE_TYPE:
509 return Op::template apply<Code::BodyDescriptor>(p1, p2, p3);
510 case CELL_TYPE:
511 return Op::template apply<Cell::BodyDescriptor>(p1, p2, p3);
512 case PROPERTY_CELL_TYPE:
513 return Op::template apply<PropertyCell::BodyDescriptor>(p1, p2, p3);
514 case WEAK_CELL_TYPE:
515 return Op::template apply<WeakCell::BodyDescriptor>(p1, p2, p3);
516 case SYMBOL_TYPE:
517 return Op::template apply<Symbol::BodyDescriptor>(p1, p2, p3);
518 case BYTECODE_ARRAY_TYPE:
519 return Op::template apply<BytecodeArray::BodyDescriptor>(p1, p2, p3);
520
521 case HEAP_NUMBER_TYPE:
522 case MUTABLE_HEAP_NUMBER_TYPE:
523 case SIMD128_VALUE_TYPE:
524 case FILLER_TYPE:
525 case BYTE_ARRAY_TYPE:
526 case FREE_SPACE_TYPE:
527 return ReturnType();
528
529 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
530 case FIXED_##TYPE##_ARRAY_TYPE: \
531 return Op::template apply<FixedTypedArrayBase::BodyDescriptor>(p1, p2, p3);
532 TYPED_ARRAYS(TYPED_ARRAY_CASE)
533 #undef TYPED_ARRAY_CASE
534
535 case SHARED_FUNCTION_INFO_TYPE: {
536 return Op::template apply<SharedFunctionInfo::BodyDescriptor>(p1, p2, p3);
537 }
538
539 #define MAKE_STRUCT_CASE(NAME, Name, name) case NAME##_TYPE:
540 STRUCT_LIST(MAKE_STRUCT_CASE)
541 #undef MAKE_STRUCT_CASE
542 if (type == ALLOCATION_SITE_TYPE) {
543 return Op::template apply<AllocationSite::BodyDescriptor>(p1, p2, p3);
544 } else {
545 return Op::template apply<StructBodyDescriptor>(p1, p2, p3);
546 }
547 default:
548 PrintF("Unknown type: %d\n", type);
549 UNREACHABLE();
550 return ReturnType();
551 }
552 }
553
554
555 template <typename ObjectVisitor>
556 void HeapObject::IterateFast(ObjectVisitor* v) {
557 BodyDescriptorBase::IteratePointer(this, kMapOffset, v);
558 IterateBody(v);
559 }
560
561
562 template <typename ObjectVisitor>
563 void HeapObject::IterateBodyFast(ObjectVisitor* v) {
564 Map* m = map();
565 IterateBody(m->instance_type(), SizeFromMap(m), v);
566 }
567
568
569 struct CallIterateBody {
570 template <typename BodyDescriptor, typename ObjectVisitor>
571 static void apply(HeapObject* obj, int object_size, ObjectVisitor* v) {
572 BodyDescriptor::IterateBody(obj, object_size, v);
573 }
574 };
575
576 template <typename ObjectVisitor>
577 void HeapObject::IterateBodyFast(InstanceType type, int object_size,
578 ObjectVisitor* v) {
579 BodyDescriptorApply<CallIterateBody, void>(type, this, object_size, v);
580 }
581 } // namespace internal
582 } // namespace v8
583
584 #endif // V8_OBJECTS_BODY_DESCRIPTORS_INL_H_
OLDNEW
« no previous file with comments | « src/objects-body-descriptors.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698