LCOV - code coverage report
Current view: top level - src/heap - objects-visiting.h (source / functions) Hit Total Coverage
Test: app.info Lines: 2 6 33.3 %
Date: 2017-10-20 Functions: 2 20 10.0 %

          Line data    Source code
       1             : // Copyright 2012 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_VISITING_H_
       6             : #define V8_OBJECTS_VISITING_H_
       7             : 
       8             : #include "src/allocation.h"
       9             : #include "src/layout-descriptor.h"
      10             : #include "src/objects-body-descriptors.h"
      11             : #include "src/objects.h"
      12             : #include "src/objects/hash-table.h"
      13             : #include "src/objects/string.h"
      14             : #include "src/visitors.h"
      15             : 
      16             : namespace v8 {
      17             : namespace internal {
      18             : 
      19             : class BigInt;
      20             : class BytecodeArray;
      21             : class JSArrayBuffer;
      22             : class JSRegExp;
      23             : 
      24             : #define TYPED_VISITOR_ID_LIST(V) \
      25             :   V(AllocationSite)              \
      26             :   V(BigInt)                      \
      27             :   V(ByteArray)                   \
      28             :   V(BytecodeArray)               \
      29             :   V(Cell)                        \
      30             :   V(Code)                        \
      31             :   V(ConsString)                  \
      32             :   V(FeedbackVector)              \
      33             :   V(FixedArray)                  \
      34             :   V(FixedDoubleArray)            \
      35             :   V(FixedFloat64Array)           \
      36             :   V(FixedTypedArrayBase)         \
      37             :   V(JSArrayBuffer)               \
      38             :   V(JSFunction)                  \
      39             :   V(JSObject)                    \
      40             :   V(JSRegExp)                    \
      41             :   V(JSWeakCollection)            \
      42             :   V(Map)                         \
      43             :   V(Oddball)                     \
      44             :   V(PropertyArray)               \
      45             :   V(PropertyCell)                \
      46             :   V(SeqOneByteString)            \
      47             :   V(SeqTwoByteString)            \
      48             :   V(SharedFunctionInfo)          \
      49             :   V(SlicedString)                \
      50             :   V(SmallOrderedHashMap)         \
      51             :   V(SmallOrderedHashSet)         \
      52             :   V(Symbol)                      \
      53             :   V(ThinString)                  \
      54             :   V(TransitionArray)             \
      55             :   V(WeakCell)
      56             : 
      57             : // The base class for visitors that need to dispatch on object type. The default
      58             : // behavior of all visit functions is to iterate body of the given object using
      59             : // the BodyDescriptor of the object.
      60             : //
      61             : // The visit functions return the size of the object cast to ResultType.
      62             : //
      63             : // This class is intended to be used in the following way:
      64             : //
      65             : //   class SomeVisitor : public HeapVisitor<ResultType, SomeVisitor> {
      66             : //     ...
      67             : //   }
      68             : template <typename ResultType, typename ConcreteVisitor>
      69   204678815 : class HeapVisitor : public ObjectVisitor {
      70             :  public:
      71             :   V8_INLINE ResultType Visit(HeapObject* object);
      72             :   V8_INLINE ResultType Visit(Map* map, HeapObject* object);
      73             : 
      74             :  protected:
      75             :   // A guard predicate for visiting the object.
      76             :   // If it returns false then the default implementations of the Visit*
      77             :   // functions bailout from iterating the object pointers.
      78             :   V8_INLINE bool ShouldVisit(HeapObject* object) { return true; }
      79             :   // Guard predicate for visiting the objects map pointer separately.
      80             :   V8_INLINE bool ShouldVisitMapPointer() { return true; }
      81             :   // A callback for visiting the map pointer in the object header.
      82             :   V8_INLINE void VisitMapPointer(HeapObject* host, HeapObject** map);
      83             : 
      84             : #define VISIT(type) V8_INLINE ResultType Visit##type(Map* map, type* object);
      85             :   TYPED_VISITOR_ID_LIST(VISIT)
      86             : #undef VISIT
      87             :   V8_INLINE ResultType VisitShortcutCandidate(Map* map, ConsString* object);
      88             :   V8_INLINE ResultType VisitNativeContext(Map* map, Context* object);
      89             :   V8_INLINE ResultType VisitDataObject(Map* map, HeapObject* object);
      90             :   V8_INLINE ResultType VisitJSObjectFast(Map* map, JSObject* object);
      91             :   V8_INLINE ResultType VisitJSApiObject(Map* map, JSObject* object);
      92             :   V8_INLINE ResultType VisitStruct(Map* map, HeapObject* object);
      93             :   V8_INLINE ResultType VisitFreeSpace(Map* map, FreeSpace* object);
      94             : 
      95             :   template <typename T>
      96             :   static V8_INLINE T* Cast(HeapObject* object);
      97             : };
      98             : 
      99             : template <typename ConcreteVisitor>
     100      248738 : class NewSpaceVisitor : public HeapVisitor<int, ConcreteVisitor> {
     101             :  public:
     102             :   V8_INLINE bool ShouldVisitMapPointer() { return false; }
     103             : 
     104             :   // Special cases for young generation.
     105             : 
     106             :   V8_INLINE int VisitJSFunction(Map* map, JSFunction* object);
     107             :   V8_INLINE int VisitNativeContext(Map* map, Context* object);
     108             :   V8_INLINE int VisitJSApiObject(Map* map, JSObject* object);
     109             : 
     110           0 :   int VisitBytecodeArray(Map* map, BytecodeArray* object) {
     111           0 :     UNREACHABLE();
     112             :     return 0;
     113             :   }
     114             : 
     115           0 :   int VisitSharedFunctionInfo(Map* map, SharedFunctionInfo* object) {
     116           0 :     UNREACHABLE();
     117             :     return 0;
     118             :   }
     119             : };
     120             : 
     121             : class WeakObjectRetainer;
     122             : 
     123             : // A weak list is single linked list where each element has a weak pointer to
     124             : // the next element. Given the head of the list, this function removes dead
     125             : // elements from the list and if requested records slots for next-element
     126             : // pointers. The template parameter T is a WeakListVisitor that defines how to
     127             : // access the next-element pointers.
     128             : template <class T>
     129             : Object* VisitWeakList(Heap* heap, Object* list, WeakObjectRetainer* retainer);
     130             : }  // namespace internal
     131             : }  // namespace v8
     132             : 
     133             : #endif  // V8_OBJECTS_VISITING_H_

Generated by: LCOV version 1.10