28 #ifndef V8_OBJECTS_VISITING_H_
29 #define V8_OBJECTS_VISITING_H_
49 #define VISITOR_ID_LIST(V) \
52 V(ShortcutCandidate) \
66 V(DataObjectGeneric) \
91 V(SharedFunctionInfo) \
106 #define VISITOR_ID_ENUM_DECL(id) kVisit##id,
108 #undef VISITOR_ID_ENUM_DECL
142 return Min(specialization,
generic);
147 template<
typename Callback>
160 return reinterpret_cast<Callback
>(callbacks_[id]);
164 return reinterpret_cast<Callback
>(callbacks_[map->
visitor_id()]);
169 callbacks_[id] =
reinterpret_cast<AtomicWord>(callback);
172 template<
typename Visitor,
175 int object_size_in_words>
177 static const int size = object_size_in_words *
kPointerSize;
179 &Visitor::template VisitSpecialized<size>);
183 template<
typename Visitor,
189 RegisterSpecialization<Visitor, base, generic, 2>();
190 RegisterSpecialization<Visitor, base, generic, 3>();
191 RegisterSpecialization<Visitor, base, generic, 4>();
192 RegisterSpecialization<Visitor, base, generic, 5>();
193 RegisterSpecialization<Visitor, base, generic, 6>();
194 RegisterSpecialization<Visitor, base, generic, 7>();
195 RegisterSpecialization<Visitor, base, generic, 8>();
196 RegisterSpecialization<Visitor, base, generic, 9>();
205 template<
typename StaticVisitor>
212 Object** start_slot =
reinterpret_cast<Object**
>(
object->address() +
214 Object** end_slot =
reinterpret_cast<Object**
>(
object->address() +
216 StaticVisitor::VisitPointers(heap, start_slot, end_slot);
221 template<
typename StaticVisitor,
typename BodyDescriptor,
typename ReturnType>
225 int object_size = BodyDescriptor::SizeOf(map,
object);
229 BodyDescriptor::kStartOffset,
231 return static_cast<ReturnType
>(object_size);
234 template<
int object_size>
236 ASSERT(BodyDescriptor::SizeOf(map,
object) == object_size);
240 BodyDescriptor::kStartOffset,
242 return static_cast<ReturnType
>(object_size);
247 template<
typename StaticVisitor,
typename BodyDescriptor,
typename ReturnType>
254 BodyDescriptor::kStartOffset,
255 BodyDescriptor::kEndOffset);
256 return static_cast<ReturnType
>(BodyDescriptor::kSize);
277 template<
typename StaticVisitor>
283 return table_.GetVisitor(map)(map, obj);
287 for (
Object** p = start; p < end; p++) StaticVisitor::VisitPointer(heap, p);
291 static inline int VisitJSFunction(
Map* map,
HeapObject*
object) {
308 static inline int VisitByteArray(Map* map, HeapObject*
object) {
309 return reinterpret_cast<ByteArray*
>(object)->ByteArraySize();
312 static inline int VisitFixedDoubleArray(Map* map, HeapObject*
object) {
313 int length =
reinterpret_cast<FixedDoubleArray*
>(object)->length();
317 static inline int VisitJSObject(Map* map, HeapObject*
object) {
321 static inline int VisitSeqAsciiString(Map* map, HeapObject*
object) {
323 SeqAsciiStringSize(map->instance_type());
326 static inline int VisitSeqTwoByteString(Map* map, HeapObject*
object) {
328 SeqTwoByteStringSize(map->instance_type());
331 static inline int VisitFreeSpace(Map* map, HeapObject*
object) {
335 class DataObjectVisitor {
337 template<
int object_size>
338 static inline int VisitSpecialized(Map* map, HeapObject*
object) {
342 static inline int Visit(Map* map, HeapObject*
object) {
343 return map->instance_size();
347 typedef FlexibleBodyVisitor<StaticVisitor,
348 StructBodyDescriptor,
351 typedef FlexibleBodyVisitor<StaticVisitor,
352 JSObject::BodyDescriptor,
353 int> JSObjectVisitor;
355 typedef int (*Callback)(Map* map, HeapObject* object);
357 static VisitorDispatchTable<Callback> table_;
361 template<
typename StaticVisitor>
362 VisitorDispatchTable<typename StaticNewSpaceVisitor<StaticVisitor>::Callback>
363 StaticNewSpaceVisitor<StaticVisitor>::table_;
380 template<
typename StaticVisitor>
386 table_.GetVisitor(map)(map, obj);
452 template<
typename StaticVisitor>
459 #endif // V8_OBJECTS_VISITING_H_
static void VisitCodeEntry(Heap *heap, Address entry_address)
static void VisitCodeTarget(Heap *heap, RelocInfo *rinfo)
STATIC_ASSERT(kVisitorIdCount<=256)
static const int kCodeEntryOffset
static VisitorDispatchTable< Callback > table_
static void VisitJSFunction(Map *map, HeapObject *object)
static void VisitJSRegExp(Map *map, HeapObject *object)
static void MarkInlinedFunctionsCode(Heap *heap, Code *code)
static void VisitPointers(Heap *heap, Object **start, Object **end)
static void MarkMapContents(Heap *heap, Map *map)
static void VisitDebugTarget(Heap *heap, RelocInfo *rinfo)
static VisitorId GetVisitorIdForSize(VisitorId base, VisitorId generic, int object_size)
static VisitorId GetVisitorId(Map *map)
static FreeSpace * cast(Object *obj)
static void VisitSpecialized(Map *map, HeapObject *object)
#define ASSERT(condition)
static bool IsFlushable(Heap *heap, JSFunction *function)
static void VisitExternalReference(RelocInfo *rinfo)
const int kPointerSizeLog2
#define VISITOR_ID_LIST(V)
static void VisitGlobalPropertyCell(Heap *heap, RelocInfo *rinfo)
void NoBarrier_Store(volatile Atomic32 *ptr, Atomic32 value)
static ReturnType Visit(Map *map, HeapObject *object)
static Object ** RawField(HeapObject *obj, int offset)
void(* Callback)(Map *map, HeapObject *object)
FlexibleBodyVisitor< StaticVisitor, StructBodyDescriptor, void > StructObjectVisitor
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 void VisitRuntimeEntry(RelocInfo *rinfo)
static void IterateBody(Map *map, HeapObject *obj)
static const int kPropertiesOffset
static void VisitSharedFunctionInfoStrongCode(Heap *heap, HeapObject *object)
static const int kMaxNonCodeHeapObjectSize
static void VisitCode(Map *map, HeapObject *object)
static int SizeFor(int length)
static int IterateBody(Map *map, HeapObject *obj)
static void VisitSharedFunctionInfoWeakCode(Heap *heap, HeapObject *object)
Callback GetVisitorById(StaticVisitorBase::VisitorId id)
static const int kNonWeakFieldsEndOffset
void RegisterSpecialization()
static SeqTwoByteString * cast(Object *obj)
#define VISITOR_ID_ENUM_DECL(id)
FlexibleBodyVisitor< StaticVisitor, JSObject::BodyDescriptor, void > JSObjectVisitor
InstanceType instance_type()
static void VisitSharedFunctionInfo(Map *map, HeapObject *object)
static void VisitJSFunctionWeakCode(Heap *heap, HeapObject *object)
static void Visit(Map *map, HeapObject *object)
static void VisitMap(Map *map, HeapObject *object)
static VisitorId GetVisitorId(int instance_type, int instance_size)
static void MarkTransitionArray(Heap *heap, TransitionArray *transitions)
void CopyFrom(VisitorDispatchTable *other)
void RegisterSpecializations()
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra code(assertions) for debugging") DEFINE_bool(code_comments
static void VisitNativeContext(Map *map, HeapObject *object)
static void VisitJSFunctionStrongCode(Heap *heap, HeapObject *object)
static ReturnType VisitSpecialized(Map *map, HeapObject *object)
static void VisitEmbeddedPointer(Heap *heap, RelocInfo *rinfo)
Callback GetVisitor(Map *map)