OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 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 | 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 #ifndef V8_OBJECTS_BODY_DESCRIPTORS_INL_H_ | 5 #ifndef V8_OBJECTS_BODY_DESCRIPTORS_INL_H_ |
6 #define V8_OBJECTS_BODY_DESCRIPTORS_INL_H_ | 6 #define V8_OBJECTS_BODY_DESCRIPTORS_INL_H_ |
7 | 7 |
8 #include "src/assembler-inl.h" | 8 #include "src/assembler-inl.h" |
9 #include "src/objects-body-descriptors.h" | 9 #include "src/objects-body-descriptors.h" |
10 #include "src/transitions.h" | 10 #include "src/transitions.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 IteratePointers<StaticVisitor>(heap, obj, kPropertiesOffset, | 232 IteratePointers<StaticVisitor>(heap, obj, kPropertiesOffset, |
233 kBackingStoreOffset); | 233 kBackingStoreOffset); |
234 IterateBodyImpl<StaticVisitor>(heap, obj, kSize, object_size); | 234 IterateBodyImpl<StaticVisitor>(heap, obj, kSize, object_size); |
235 } | 235 } |
236 | 236 |
237 static inline int SizeOf(Map* map, HeapObject* object) { | 237 static inline int SizeOf(Map* map, HeapObject* object) { |
238 return map->instance_size(); | 238 return map->instance_size(); |
239 } | 239 } |
240 }; | 240 }; |
241 | 241 |
| 242 class ByteArray::BodyDescriptor final : public BodyDescriptorBase { |
| 243 public: |
| 244 static bool IsValidSlot(HeapObject* obj, int offset) { return false; } |
| 245 |
| 246 template <typename ObjectVisitor> |
| 247 static inline void IterateBody(HeapObject* obj, int object_size, |
| 248 ObjectVisitor* v) {} |
| 249 |
| 250 template <typename StaticVisitor> |
| 251 static inline void IterateBody(HeapObject* obj, int object_size) {} |
| 252 |
| 253 static inline int SizeOf(Map* map, HeapObject* obj) { |
| 254 return reinterpret_cast<ByteArray*>(obj)->ByteArraySize(); |
| 255 } |
| 256 }; |
| 257 |
242 class BytecodeArray::BodyDescriptor final : public BodyDescriptorBase { | 258 class BytecodeArray::BodyDescriptor final : public BodyDescriptorBase { |
243 public: | 259 public: |
244 static bool IsValidSlot(HeapObject* obj, int offset) { | 260 static bool IsValidSlot(HeapObject* obj, int offset) { |
245 return offset >= kConstantPoolOffset && | 261 return offset >= kConstantPoolOffset && |
246 offset <= kSourcePositionTableOffset; | 262 offset <= kSourcePositionTableOffset; |
247 } | 263 } |
248 | 264 |
249 template <typename ObjectVisitor> | 265 template <typename ObjectVisitor> |
250 static inline void IterateBody(HeapObject* obj, int object_size, | 266 static inline void IterateBody(HeapObject* obj, int object_size, |
251 ObjectVisitor* v) { | 267 ObjectVisitor* v) { |
252 IteratePointer(obj, kConstantPoolOffset, v); | 268 IteratePointer(obj, kConstantPoolOffset, v); |
253 IteratePointer(obj, kHandlerTableOffset, v); | 269 IteratePointer(obj, kHandlerTableOffset, v); |
254 IteratePointer(obj, kSourcePositionTableOffset, v); | 270 IteratePointer(obj, kSourcePositionTableOffset, v); |
255 } | 271 } |
256 | 272 |
257 template <typename StaticVisitor> | 273 template <typename StaticVisitor> |
258 static inline void IterateBody(HeapObject* obj, int object_size) { | 274 static inline void IterateBody(HeapObject* obj, int object_size) { |
259 Heap* heap = obj->GetHeap(); | 275 Heap* heap = obj->GetHeap(); |
260 IteratePointer<StaticVisitor>(heap, obj, kConstantPoolOffset); | 276 IteratePointer<StaticVisitor>(heap, obj, kConstantPoolOffset); |
261 IteratePointer<StaticVisitor>(heap, obj, kHandlerTableOffset); | 277 IteratePointer<StaticVisitor>(heap, obj, kHandlerTableOffset); |
262 IteratePointer<StaticVisitor>(heap, obj, kSourcePositionTableOffset); | 278 IteratePointer<StaticVisitor>(heap, obj, kSourcePositionTableOffset); |
263 } | 279 } |
264 | 280 |
265 static inline int SizeOf(Map* map, HeapObject* obj) { | 281 static inline int SizeOf(Map* map, HeapObject* obj) { |
266 return reinterpret_cast<BytecodeArray*>(obj)->BytecodeArraySize(); | 282 return reinterpret_cast<BytecodeArray*>(obj)->BytecodeArraySize(); |
267 } | 283 } |
268 }; | 284 }; |
269 | 285 |
| 286 class FixedDoubleArray::BodyDescriptor final : public BodyDescriptorBase { |
| 287 public: |
| 288 static bool IsValidSlot(HeapObject* obj, int offset) { return false; } |
| 289 |
| 290 template <typename ObjectVisitor> |
| 291 static inline void IterateBody(HeapObject* obj, int object_size, |
| 292 ObjectVisitor* v) {} |
| 293 |
| 294 template <typename StaticVisitor> |
| 295 static inline void IterateBody(HeapObject* obj, int object_size) {} |
| 296 |
| 297 static inline int SizeOf(Map* map, HeapObject* obj) { |
| 298 return FixedDoubleArray::SizeFor( |
| 299 reinterpret_cast<FixedDoubleArray*>(obj)->length()); |
| 300 } |
| 301 }; |
| 302 |
270 class FixedTypedArrayBase::BodyDescriptor final : public BodyDescriptorBase { | 303 class FixedTypedArrayBase::BodyDescriptor final : public BodyDescriptorBase { |
271 public: | 304 public: |
272 static bool IsValidSlot(HeapObject* obj, int offset) { | 305 static bool IsValidSlot(HeapObject* obj, int offset) { |
273 return offset == kBasePointerOffset; | 306 return offset == kBasePointerOffset; |
274 } | 307 } |
275 | 308 |
276 template <typename ObjectVisitor> | 309 template <typename ObjectVisitor> |
277 static inline void IterateBody(HeapObject* obj, int object_size, | 310 static inline void IterateBody(HeapObject* obj, int object_size, |
278 ObjectVisitor* v) { | 311 ObjectVisitor* v) { |
279 IteratePointer(obj, kBasePointerOffset, v); | 312 IteratePointer(obj, kBasePointerOffset, v); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 template <typename StaticVisitor> | 485 template <typename StaticVisitor> |
453 static inline void IterateBody(HeapObject* obj, int object_size) { | 486 static inline void IterateBody(HeapObject* obj, int object_size) { |
454 IterateBody<StaticVisitor>(obj); | 487 IterateBody<StaticVisitor>(obj); |
455 } | 488 } |
456 | 489 |
457 static inline int SizeOf(Map* map, HeapObject* object) { | 490 static inline int SizeOf(Map* map, HeapObject* object) { |
458 return reinterpret_cast<Code*>(object)->CodeSize(); | 491 return reinterpret_cast<Code*>(object)->CodeSize(); |
459 } | 492 } |
460 }; | 493 }; |
461 | 494 |
| 495 class SeqOneByteString::BodyDescriptor final : public BodyDescriptorBase { |
| 496 public: |
| 497 static bool IsValidSlot(HeapObject* obj, int offset) { return false; } |
| 498 |
| 499 template <typename ObjectVisitor> |
| 500 static inline void IterateBody(HeapObject* obj, int object_size, |
| 501 ObjectVisitor* v) {} |
| 502 |
| 503 template <typename StaticVisitor> |
| 504 static inline void IterateBody(HeapObject* obj, int object_size) {} |
| 505 |
| 506 static inline int SizeOf(Map* map, HeapObject* obj) { |
| 507 SeqOneByteString* string = SeqOneByteString::cast(obj); |
| 508 return string->SizeFor(string->length()); |
| 509 } |
| 510 }; |
| 511 |
| 512 class SeqTwoByteString::BodyDescriptor final : public BodyDescriptorBase { |
| 513 public: |
| 514 static bool IsValidSlot(HeapObject* obj, int offset) { return false; } |
| 515 |
| 516 template <typename ObjectVisitor> |
| 517 static inline void IterateBody(HeapObject* obj, int object_size, |
| 518 ObjectVisitor* v) {} |
| 519 |
| 520 template <typename StaticVisitor> |
| 521 static inline void IterateBody(HeapObject* obj, int object_size) {} |
| 522 |
| 523 static inline int SizeOf(Map* map, HeapObject* obj) { |
| 524 SeqTwoByteString* string = SeqTwoByteString::cast(obj); |
| 525 return string->SizeFor(string->length()); |
| 526 } |
| 527 }; |
462 | 528 |
463 template <typename Op, typename ReturnType, typename T1, typename T2, | 529 template <typename Op, typename ReturnType, typename T1, typename T2, |
464 typename T3> | 530 typename T3> |
465 ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3) { | 531 ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3) { |
466 if (type < FIRST_NONSTRING_TYPE) { | 532 if (type < FIRST_NONSTRING_TYPE) { |
467 switch (type & kStringRepresentationMask) { | 533 switch (type & kStringRepresentationMask) { |
468 case kSeqStringTag: | 534 case kSeqStringTag: |
469 return ReturnType(); | 535 return ReturnType(); |
470 case kConsStringTag: | 536 case kConsStringTag: |
471 return Op::template apply<ConsString::BodyDescriptor>(p1, p2, p3); | 537 return Op::template apply<ConsString::BodyDescriptor>(p1, p2, p3); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 | 708 |
643 template <typename ObjectVisitor> | 709 template <typename ObjectVisitor> |
644 void HeapObject::IterateBodyFast(InstanceType type, int object_size, | 710 void HeapObject::IterateBodyFast(InstanceType type, int object_size, |
645 ObjectVisitor* v) { | 711 ObjectVisitor* v) { |
646 BodyDescriptorApply<CallIterateBody, void>(type, this, object_size, v); | 712 BodyDescriptorApply<CallIterateBody, void>(type, this, object_size, v); |
647 } | 713 } |
648 } // namespace internal | 714 } // namespace internal |
649 } // namespace v8 | 715 } // namespace v8 |
650 | 716 |
651 #endif // V8_OBJECTS_BODY_DESCRIPTORS_INL_H_ | 717 #endif // V8_OBJECTS_BODY_DESCRIPTORS_INL_H_ |
OLD | NEW |