28 #ifndef V8_OBJECTS_VISITING_H_
29 #define V8_OBJECTS_VISITING_H_
143 return Min(specialization,
generic);
148 template<
typename Callback>
161 return reinterpret_cast<Callback
>(callbacks_[id]);
165 return reinterpret_cast<Callback
>(callbacks_[map->
visitor_id()]);
170 callbacks_[id] =
reinterpret_cast<AtomicWord>(callback);
173 template<
typename Visitor,
176 int object_size_in_words>
178 static const int size = object_size_in_words *
kPointerSize;
180 &Visitor::template VisitSpecialized<size>);
184 template<
typename Visitor,
190 RegisterSpecialization<Visitor, base, generic, 2>();
191 RegisterSpecialization<Visitor, base, generic, 3>();
192 RegisterSpecialization<Visitor, base, generic, 4>();
193 RegisterSpecialization<Visitor, base, generic, 5>();
194 RegisterSpecialization<Visitor, base, generic, 6>();
195 RegisterSpecialization<Visitor, base, generic, 7>();
196 RegisterSpecialization<Visitor, base, generic, 8>();
197 RegisterSpecialization<Visitor, base, generic, 9>();
206 template<
typename StaticVisitor>
213 Object** start_slot =
reinterpret_cast<Object**
>(
object->address() +
215 Object** end_slot =
reinterpret_cast<Object**
>(
object->address() +
217 StaticVisitor::VisitPointers(heap, start_slot, end_slot);
222 template<
typename StaticVisitor,
typename BodyDescriptor,
typename ReturnType>
226 int object_size = BodyDescriptor::SizeOf(map,
object);
230 BodyDescriptor::kStartOffset,
232 return static_cast<ReturnType
>(object_size);
235 template<
int object_size>
237 ASSERT(BodyDescriptor::SizeOf(map,
object) == object_size);
241 BodyDescriptor::kStartOffset,
243 return static_cast<ReturnType
>(object_size);
248 template<
typename StaticVisitor,
typename BodyDescriptor,
typename ReturnType>
255 BodyDescriptor::kStartOffset,
256 BodyDescriptor::kEndOffset);
257 return static_cast<ReturnType
>(BodyDescriptor::kSize);
278 template<
typename StaticVisitor>
284 return table_.GetVisitor(map)(map, obj);
288 for (
Object** p = start; p < end; p++) StaticVisitor::VisitPointer(heap, p);
292 static inline int VisitJSFunction(
Map* map,
HeapObject*
object) {
309 static inline int VisitByteArray(Map* map, HeapObject*
object) {
310 return reinterpret_cast<ByteArray*
>(object)->ByteArraySize();
313 static inline int VisitFixedDoubleArray(Map* map, HeapObject*
object) {
314 int length =
reinterpret_cast<FixedDoubleArray*
>(object)->length();
318 static inline int VisitJSObject(Map* map, HeapObject*
object) {
322 static inline int VisitSeqAsciiString(Map* map, HeapObject*
object) {
324 SeqAsciiStringSize(map->instance_type());
327 static inline int VisitSeqTwoByteString(Map* map, HeapObject*
object) {
329 SeqTwoByteStringSize(map->instance_type());
332 static inline int VisitFreeSpace(Map* map, HeapObject*
object) {
336 class DataObjectVisitor {
338 template<
int object_size>
339 static inline int VisitSpecialized(Map* map, HeapObject*
object) {
343 static inline int Visit(Map* map, HeapObject*
object) {
344 return map->instance_size();
348 typedef FlexibleBodyVisitor<StaticVisitor,
349 StructBodyDescriptor,
352 typedef FlexibleBodyVisitor<StaticVisitor,
353 JSObject::BodyDescriptor,
354 int> JSObjectVisitor;
356 typedef int (*Callback)(Map* map, HeapObject* object);
358 static VisitorDispatchTable<Callback> table_;
362 template<
typename StaticVisitor>
363 VisitorDispatchTable<typename StaticNewSpaceVisitor<StaticVisitor>::Callback>
364 StaticNewSpaceVisitor<StaticVisitor>::table_;
369 #endif // V8_OBJECTS_VISITING_H_
STATIC_ASSERT(kVisitorIdCount<=256)
static const int kCodeEntryOffset
static void VisitPointers(Heap *heap, Object **start, Object **end)
static VisitorId GetVisitorIdForSize(VisitorId base, VisitorId generic, int object_size)
static VisitorId GetVisitorId(Map *map)
static FreeSpace * cast(Object *obj)
#define ASSERT(condition)
const int kPointerSizeLog2
void NoBarrier_Store(volatile Atomic32 *ptr, Atomic32 value)
static ReturnType Visit(Map *map, HeapObject *object)
static Object ** RawField(HeapObject *obj, int offset)
STATIC_ASSERT((FixedDoubleArray::kHeaderSize &kDoubleAlignmentMask)==0)
void Register(StaticVisitorBase::VisitorId id, Callback callback)
INLINE(static void IteratePointers(Heap *heap, HeapObject *object, int start_offset, int end_offset))
bool IsAligned(T value, U alignment)
static SeqAsciiString * cast(Object *obj)
static ReturnType Visit(Map *map, HeapObject *object)
static const int kPropertiesOffset
static const int kMaxNonCodeHeapObjectSize
static int SizeFor(int length)
static int IterateBody(Map *map, HeapObject *obj)
Callback GetVisitorById(StaticVisitorBase::VisitorId id)
static const int kNonWeakFieldsEndOffset
void RegisterSpecialization()
static SeqTwoByteString * cast(Object *obj)
InstanceType instance_type()
static VisitorId GetVisitorId(int instance_type, int instance_size)
void CopyFrom(VisitorDispatchTable *other)
void RegisterSpecializations()
static ReturnType VisitSpecialized(Map *map, HeapObject *object)
Callback GetVisitor(Map *map)