V8 Project
v8::internal::MarkCompactMarkingVisitor Class Reference
+ Inheritance diagram for v8::internal::MarkCompactMarkingVisitor:
+ Collaboration diagram for v8::internal::MarkCompactMarkingVisitor:

Classes

class  ObjectStatsTracker
 
class  ObjectStatsTracker< MarkCompactMarkingVisitor::kVisitCode >
 
class  ObjectStatsTracker< MarkCompactMarkingVisitor::kVisitFixedArray >
 
class  ObjectStatsTracker< MarkCompactMarkingVisitor::kVisitMap >
 
class  ObjectStatsTracker< MarkCompactMarkingVisitor::kVisitSharedFunctionInfo >
 

Public Member Functions

 INLINE (static void VisitPointer(Heap *heap, Object **p))
 
 INLINE (static void VisitPointers(Heap *heap, Object **start, Object **end))
 
 INLINE (static void MarkObject(Heap *heap, HeapObject *object))
 
 INLINE (static bool MarkObjectWithoutPush(Heap *heap, HeapObject *object))
 
 INLINE (static void MarkObjectByPointer(MarkCompactCollector *collector, Object **anchor_slot, Object **p))
 
 INLINE (static void VisitUnmarkedObject(MarkCompactCollector *collector, HeapObject *obj))
 
 INLINE (static bool VisitUnmarkedObjects(Heap *heap, Object **start, Object **end))
 
- Public Member Functions inherited from v8::internal::StaticMarkingVisitor< MarkCompactMarkingVisitor >
 INLINE (static void IterateBody(Map *map, HeapObject *obj))
 
 INLINE (static void VisitPropertyCell(Map *map, HeapObject *object))
 
 INLINE (static void VisitCodeEntry(Heap *heap, Address entry_address))
 
 INLINE (static void VisitEmbeddedPointer(Heap *heap, RelocInfo *rinfo))
 
 INLINE (static void VisitCell(Heap *heap, RelocInfo *rinfo))
 
 INLINE (static void VisitDebugTarget(Heap *heap, RelocInfo *rinfo))
 
 INLINE (static void VisitCodeTarget(Heap *heap, RelocInfo *rinfo))
 
 INLINE (static void VisitCodeAgeSequence(Heap *heap, RelocInfo *rinfo))
 
 INLINE (static void VisitExternalReference(RelocInfo *rinfo))
 
 INLINE (static void VisitRuntimeEntry(RelocInfo *rinfo))
 
 INLINE (static void VisitNextCodeLink(Heap *heap, Object **slot))
 
- Public Member Functions inherited from v8::internal::StaticVisitorBase
 STATIC_ASSERT (kVisitorIdCount<=256)
 

Static Public Member Functions

static void ObjectStatsVisitBase (StaticVisitorBase::VisitorId id, Map *map, HeapObject *obj)
 
static void ObjectStatsCountFixedArray (FixedArrayBase *fixed_array, FixedArraySubInstanceType fast_type, FixedArraySubInstanceType dictionary_type)
 
static void Initialize ()
 
- Static Public Member Functions inherited from v8::internal::StaticMarkingVisitor< MarkCompactMarkingVisitor >
static void Initialize ()
 
static void MarkInlinedFunctionsCode (Heap *heap, Code *code)
 
- Static Public Member Functions inherited from v8::internal::StaticVisitorBase
static VisitorId GetVisitorId (int instance_type, int instance_size)
 
static VisitorId GetVisitorId (Map *map)
 
static VisitorId GetVisitorIdForSize (VisitorId base, VisitorId generic, int object_size)
 

Static Private Member Functions

template<int id>
static void TrackObjectStatsAndVisit (Map *map, HeapObject *obj)
 
static void UpdateRegExpCodeAgeAndFlush (Heap *heap, JSRegExp *re, bool is_one_byte)
 
static void VisitRegExpAndFlushCode (Map *map, HeapObject *object)
 

Static Private Attributes

static const int kRegExpCodeThreshold = 5
 
static VisitorDispatchTable< Callbacknon_count_table_
 

Additional Inherited Members

- Public Types inherited from v8::internal::StaticVisitorBase
enum  VisitorId {
  kVisitorIdCount , kVisitDataObject = kVisitDataObject2 , kVisitJSObject = kVisitJSObject2 , kVisitStruct = kVisitStruct2 ,
  kMinObjectSizeInWords = 2
}
 
- Protected Types inherited from v8::internal::StaticMarkingVisitor< MarkCompactMarkingVisitor >
typedef FlexibleBodyVisitor< MarkCompactMarkingVisitor, FixedArray::BodyDescriptor, void > FixedArrayVisitor
 
typedef FlexibleBodyVisitor< MarkCompactMarkingVisitor, JSObject::BodyDescriptor, void > JSObjectVisitor
 
typedef FlexibleBodyVisitor< MarkCompactMarkingVisitor, StructBodyDescriptor, void > StructObjectVisitor
 
typedef void(* Callback) (Map *map, HeapObject *object)
 
- Protected Member Functions inherited from v8::internal::StaticMarkingVisitor< MarkCompactMarkingVisitor >
 INLINE (static void VisitMap(Map *map, HeapObject *object))
 
 INLINE (static void VisitCode(Map *map, HeapObject *object))
 
 INLINE (static void VisitSharedFunctionInfo(Map *map, HeapObject *object))
 
 INLINE (static void VisitConstantPoolArray(Map *map, HeapObject *object))
 
 INLINE (static void VisitAllocationSite(Map *map, HeapObject *object))
 
 INLINE (static void VisitWeakCollection(Map *map, HeapObject *object))
 
 INLINE (static void VisitJSFunction(Map *map, HeapObject *object))
 
 INLINE (static void VisitJSRegExp(Map *map, HeapObject *object))
 
 INLINE (static void VisitJSArrayBuffer(Map *map, HeapObject *object))
 
 INLINE (static void VisitJSTypedArray(Map *map, HeapObject *object))
 
 INLINE (static void VisitJSDataView(Map *map, HeapObject *object))
 
 INLINE (static void VisitNativeContext(Map *map, HeapObject *object))
 
 INLINE (static bool IsFlushable(Heap *heap, JSFunction *function))
 
 INLINE (static bool IsFlushable(Heap *heap, SharedFunctionInfo *shared_info))
 
- Static Protected Member Functions inherited from v8::internal::StaticMarkingVisitor< MarkCompactMarkingVisitor >
static void MarkMapContents (Heap *heap, Map *map)
 
static void MarkTransitionArray (Heap *heap, TransitionArray *transitions)
 
static void VisitSharedFunctionInfoStrongCode (Heap *heap, HeapObject *object)
 
static void VisitSharedFunctionInfoWeakCode (Heap *heap, HeapObject *object)
 
static void VisitJSFunctionStrongCode (Heap *heap, HeapObject *object)
 
static void VisitJSFunctionWeakCode (Heap *heap, HeapObject *object)
 
- Static Protected Attributes inherited from v8::internal::StaticMarkingVisitor< MarkCompactMarkingVisitor >
static VisitorDispatchTable< Callbacktable_
 

Detailed Description

Definition at line 1353 of file mark-compact.cc.

Member Function Documentation

◆ Initialize()

void v8::internal::MarkCompactMarkingVisitor::Initialize ( )
static

Definition at line 1658 of file mark-compact.cc.

1658  {
1660 
1661  table_.Register(kVisitJSRegExp, &VisitRegExpAndFlushCode);
1662 
1663  if (FLAG_track_gc_object_stats) {
1664  // Copy the visitor table to make call-through possible.
1665  non_count_table_.CopyFrom(&table_);
1666 #define VISITOR_ID_COUNT_FUNCTION(id) \
1667  table_.Register(kVisit##id, ObjectStatsTracker<kVisit##id>::Visit);
1669 #undef VISITOR_ID_COUNT_FUNCTION
1670  }
1671 }
static VisitorDispatchTable< Callback > non_count_table_
static void VisitRegExpAndFlushCode(Map *map, HeapObject *object)
#define VISITOR_ID_COUNT_FUNCTION(id)
#define VISITOR_ID_LIST(V)

References v8::internal::StaticMarkingVisitor< StaticVisitor >::Initialize(), non_count_table_, v8::internal::StaticMarkingVisitor< MarkCompactMarkingVisitor >::table_, VISITOR_ID_COUNT_FUNCTION, VISITOR_ID_LIST, and VisitRegExpAndFlushCode().

Referenced by v8::internal::MarkCompactCollector::Initialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ INLINE() [1/7]

v8::internal::MarkCompactMarkingVisitor::INLINE ( static bool   MarkObjectWithoutPushHeap *heap, HeapObject *object)
inline

Definition at line 1396 of file mark-compact.cc.

1396  {
1397  MarkBit mark_bit = Marking::MarkBitFrom(object);
1398  if (!mark_bit.Get()) {
1399  heap->mark_compact_collector()->SetMark(object, mark_bit);
1400  return true;
1401  }
1402  return false;
1403  }

References v8::internal::MarkBit::Get(), and v8::internal::Heap::mark_compact_collector().

+ Here is the call graph for this function:

◆ INLINE() [2/7]

v8::internal::MarkCompactMarkingVisitor::INLINE ( static bool   VisitUnmarkedObjectsHeap *heap, Object **start, Object **end)
inline

Definition at line 1435 of file mark-compact.cc.

1436  {
1437  // Return false is we are close to the stack limit.
1438  StackLimitCheck check(heap->isolate());
1439  if (check.HasOverflowed()) return false;
1440 
1441  MarkCompactCollector* collector = heap->mark_compact_collector();
1442  // Visit the unmarked objects.
1443  for (Object** p = start; p < end; p++) {
1444  Object* o = *p;
1445  if (!o->IsHeapObject()) continue;
1446  collector->RecordSlot(start, p, o);
1447  HeapObject* obj = HeapObject::cast(o);
1448  MarkBit mark = Marking::MarkBitFrom(obj);
1449  if (mark.Get()) continue;
1450  VisitUnmarkedObject(collector, obj);
1451  }
1452  return true;
1453  }
kSerializedDataOffset Object
Definition: objects-inl.h:5322

References v8::internal::MarkBit::Get(), v8::internal::Heap::isolate(), and v8::internal::Heap::mark_compact_collector().

+ Here is the call graph for this function:

◆ INLINE() [3/7]

v8::internal::MarkCompactMarkingVisitor::INLINE ( static void   MarkObjectHeap *heap, HeapObject *object)
inline

Definition at line 1389 of file mark-compact.cc.

1389  {
1390  MarkBit mark = Marking::MarkBitFrom(object);
1391  heap->mark_compact_collector()->MarkObject(object, mark);
1392  }

References v8::internal::Heap::mark_compact_collector().

+ Here is the call graph for this function:

◆ INLINE() [4/7]

v8::internal::MarkCompactMarkingVisitor::INLINE ( static void   MarkObjectByPointerMarkCompactCollector *collector, Object **anchor_slot, Object **p)
inline

Definition at line 1406 of file mark-compact.cc.

1407  {
1408  if (!(*p)->IsHeapObject()) return;
1409  HeapObject* object = ShortCircuitConsString(p);
1410  collector->RecordSlot(anchor_slot, p, object);
1411  MarkBit mark = Marking::MarkBitFrom(object);
1412  collector->MarkObject(object, mark);
1413  }
static HeapObject * ShortCircuitConsString(Object **p)

References v8::internal::ShortCircuitConsString().

+ Here is the call graph for this function:

◆ INLINE() [5/7]

v8::internal::MarkCompactMarkingVisitor::INLINE ( static void   VisitPointerHeap *heap, Object **p)
inline

Definition at line 1371 of file mark-compact.cc.

1371  {
1372  MarkObjectByPointer(heap->mark_compact_collector(), p, p);
1373  }

References v8::internal::Heap::mark_compact_collector().

+ Here is the call graph for this function:

◆ INLINE() [6/7]

v8::internal::MarkCompactMarkingVisitor::INLINE ( static void   VisitPointersHeap *heap, Object **start, Object **end)
inline

Definition at line 1375 of file mark-compact.cc.

1375  {
1376  // Mark all objects pointed to in [start, end).
1377  const int kMinRangeForMarkingRecursion = 64;
1378  if (end - start >= kMinRangeForMarkingRecursion) {
1379  if (VisitUnmarkedObjects(heap, start, end)) return;
1380  // We are close to a stack overflow, so just mark the objects.
1381  }
1382  MarkCompactCollector* collector = heap->mark_compact_collector();
1383  for (Object** p = start; p < end; p++) {
1384  MarkObjectByPointer(collector, start, p);
1385  }
1386  }

References v8::internal::Heap::mark_compact_collector().

+ Here is the call graph for this function:

◆ INLINE() [7/7]

v8::internal::MarkCompactMarkingVisitor::INLINE ( static void   VisitUnmarkedObjectMarkCompactCollector *collector, HeapObject *obj)
inline

Definition at line 1417 of file mark-compact.cc.

1418  {
1419 #ifdef DEBUG
1420  DCHECK(collector->heap()->Contains(obj));
1421  DCHECK(!collector->heap()->mark_compact_collector()->IsMarked(obj));
1422 #endif
1423  Map* map = obj->map();
1424  Heap* heap = obj->GetHeap();
1425  MarkBit mark = Marking::MarkBitFrom(obj);
1426  heap->mark_compact_collector()->SetMark(obj, mark);
1427  // Mark the map pointer and the body.
1428  MarkBit map_mark = Marking::MarkBitFrom(map);
1429  heap->mark_compact_collector()->MarkObject(map, map_mark);
1430  IterateBody(map, obj);
1431  }
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf map
#define DCHECK(condition)
Definition: logging.h:205

References v8::internal::Heap::Contains(), DCHECK, v8::internal::HeapObject::GetHeap(), v8::internal::MarkCompactCollector::heap(), v8::internal::MarkCompactCollector::IsMarked(), map, v8::internal::HeapObject::map(), and v8::internal::Heap::mark_compact_collector().

+ Here is the call graph for this function:

◆ ObjectStatsCountFixedArray()

void v8::internal::MarkCompactMarkingVisitor::ObjectStatsCountFixedArray ( FixedArrayBase fixed_array,
FixedArraySubInstanceType  fast_type,
FixedArraySubInstanceType  dictionary_type 
)
static

Definition at line 1535 of file mark-compact.cc.

1537  {
1538  Heap* heap = fixed_array->map()->GetHeap();
1539  if (fixed_array->map() != heap->fixed_cow_array_map() &&
1540  fixed_array->map() != heap->fixed_double_array_map() &&
1541  fixed_array != heap->empty_fixed_array()) {
1542  if (fixed_array->IsDictionary()) {
1543  heap->RecordFixedArraySubTypeStats(dictionary_type, fixed_array->Size());
1544  } else {
1545  heap->RecordFixedArraySubTypeStats(fast_type, fixed_array->Size());
1546  }
1547  }
1548 }

References v8::internal::HeapObject::GetHeap(), v8::internal::HeapObject::map(), v8::internal::Heap::RecordFixedArraySubTypeStats(), and v8::internal::HeapObject::Size().

Referenced by ObjectStatsVisitBase().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ObjectStatsVisitBase()

void v8::internal::MarkCompactMarkingVisitor::ObjectStatsVisitBase ( StaticVisitorBase::VisitorId  id,
Map map,
HeapObject obj 
)
static

Definition at line 1551 of file mark-compact.cc.

1552  {
1553  Heap* heap = map->GetHeap();
1554  int object_size = obj->Size();
1555  heap->RecordObjectStats(map->instance_type(), object_size);
1556  non_count_table_.GetVisitorById(id)(map, obj);
1557  if (obj->IsJSObject()) {
1558  JSObject* object = JSObject::cast(obj);
1559  ObjectStatsCountFixedArray(object->elements(), DICTIONARY_ELEMENTS_SUB_TYPE,
1560  FAST_ELEMENTS_SUB_TYPE);
1561  ObjectStatsCountFixedArray(object->properties(),
1562  DICTIONARY_PROPERTIES_SUB_TYPE,
1563  FAST_PROPERTIES_SUB_TYPE);
1564  }
1565 }
static void ObjectStatsCountFixedArray(FixedArrayBase *fixed_array, FixedArraySubInstanceType fast_type, FixedArraySubInstanceType dictionary_type)

References map, non_count_table_, ObjectStatsCountFixedArray(), v8::internal::Heap::RecordObjectStats(), and v8::internal::HeapObject::Size().

Referenced by v8::internal::MarkCompactMarkingVisitor::ObjectStatsTracker< MarkCompactMarkingVisitor::kVisitMap >::Visit(), v8::internal::MarkCompactMarkingVisitor::ObjectStatsTracker< MarkCompactMarkingVisitor::kVisitCode >::Visit(), v8::internal::MarkCompactMarkingVisitor::ObjectStatsTracker< MarkCompactMarkingVisitor::kVisitSharedFunctionInfo >::Visit(), and v8::internal::MarkCompactMarkingVisitor::ObjectStatsTracker< MarkCompactMarkingVisitor::kVisitFixedArray >::Visit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ TrackObjectStatsAndVisit()

template<int id>
static void v8::internal::MarkCompactMarkingVisitor::TrackObjectStatsAndVisit ( Map map,
HeapObject obj 
)
inlinestaticprivate

◆ UpdateRegExpCodeAgeAndFlush()

static void v8::internal::MarkCompactMarkingVisitor::UpdateRegExpCodeAgeAndFlush ( Heap heap,
JSRegExp re,
bool  is_one_byte 
)
inlinestaticprivate

Definition at line 1463 of file mark-compact.cc.

1464  {
1465  // Make sure that the fixed array is in fact initialized on the RegExp.
1466  // We could potentially trigger a GC when initializing the RegExp.
1467  if (HeapObject::cast(re->data())->map()->instance_type() !=
1469  return;
1470 
1471  // Make sure this is a RegExp that actually contains code.
1472  if (re->TypeTag() != JSRegExp::IRREGEXP) return;
1473 
1474  Object* code = re->DataAt(JSRegExp::code_index(is_one_byte));
1475  if (!code->IsSmi() &&
1476  HeapObject::cast(code)->map()->instance_type() == CODE_TYPE) {
1477  // Save a copy that can be reinstated if we need the code again.
1478  re->SetDataAt(JSRegExp::saved_code_index(is_one_byte), code);
1479 
1480  // Saving a copy might create a pointer into compaction candidate
1481  // that was not observed by marker. This might happen if JSRegExp data
1482  // was marked through the compilation cache before marker reached JSRegExp
1483  // object.
1484  FixedArray* data = FixedArray::cast(re->data());
1485  Object** slot =
1486  data->data_start() + JSRegExp::saved_code_index(is_one_byte);
1487  heap->mark_compact_collector()->RecordSlot(slot, slot, code);
1488 
1489  // Set a number in the 0-255 range to guarantee no smi overflow.
1490  re->SetDataAt(JSRegExp::code_index(is_one_byte),
1491  Smi::FromInt(heap->sweep_generation() & 0xff));
1492  } else if (code->IsSmi()) {
1493  int value = Smi::cast(code)->value();
1494  // The regexp has not been compiled yet or there was a compilation error.
1495  if (value == JSRegExp::kUninitializedValue ||
1497  return;
1498  }
1499 
1500  // Check if we should flush now.
1501  if (value == ((heap->sweep_generation() - kRegExpCodeThreshold) & 0xff)) {
1502  re->SetDataAt(JSRegExp::code_index(is_one_byte),
1504  re->SetDataAt(JSRegExp::saved_code_index(is_one_byte),
1506  }
1507  }
1508  }
static const int kUninitializedValue
Definition: objects.h:7829
static const int kCompilationErrorValue
Definition: objects.h:7833
static int saved_code_index(bool is_latin1)
Definition: objects.h:7758
static int code_index(bool is_latin1)
Definition: objects.h:7750
static Smi * FromInt(int value)
Definition: objects-inl.h:1321
@ FIXED_ARRAY_TYPE
Definition: objects.h:717

References v8::internal::JSRegExp::code_index(), v8::internal::CODE_TYPE, v8::internal::FixedArray::data_start(), v8::internal::JSRegExp::DataAt(), v8::internal::FIXED_ARRAY_TYPE, v8::internal::Smi::FromInt(), v8::internal::JSRegExp::IRREGEXP, v8::internal::JSRegExp::kCompilationErrorValue, kRegExpCodeThreshold, v8::internal::JSRegExp::kUninitializedValue, v8::internal::Heap::mark_compact_collector(), v8::internal::JSRegExp::saved_code_index(), v8::internal::JSRegExp::SetDataAt(), v8::internal::Heap::sweep_generation(), and v8::internal::JSRegExp::TypeTag().

Referenced by VisitRegExpAndFlushCode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ VisitRegExpAndFlushCode()

static void v8::internal::MarkCompactMarkingVisitor::VisitRegExpAndFlushCode ( Map map,
HeapObject object 
)
inlinestaticprivate

Definition at line 1516 of file mark-compact.cc.

1516  {
1517  Heap* heap = map->GetHeap();
1518  MarkCompactCollector* collector = heap->mark_compact_collector();
1519  if (!collector->is_code_flushing_enabled()) {
1520  VisitJSRegExp(map, object);
1521  return;
1522  }
1523  JSRegExp* re = reinterpret_cast<JSRegExp*>(object);
1524  // Flush code or set age on both one byte and two byte code.
1525  UpdateRegExpCodeAgeAndFlush(heap, re, true);
1526  UpdateRegExpCodeAgeAndFlush(heap, re, false);
1527  // Visit the fields of the RegExp, including the updated FixedArray.
1528  VisitJSRegExp(map, object);
1529  }
static void UpdateRegExpCodeAgeAndFlush(Heap *heap, JSRegExp *re, bool is_one_byte)

References v8::internal::MarkCompactCollector::is_code_flushing_enabled(), map, v8::internal::Heap::mark_compact_collector(), and UpdateRegExpCodeAgeAndFlush().

Referenced by Initialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ kRegExpCodeThreshold

const int v8::internal::MarkCompactMarkingVisitor::kRegExpCodeThreshold = 5
staticprivate

Definition at line 1461 of file mark-compact.cc.

Referenced by UpdateRegExpCodeAgeAndFlush().

◆ non_count_table_

VisitorDispatchTable< MarkCompactMarkingVisitor::Callback > v8::internal::MarkCompactMarkingVisitor::non_count_table_
staticprivate

Definition at line 1531 of file mark-compact.cc.

Referenced by Initialize(), and ObjectStatsVisitBase().


The documentation for this class was generated from the following file: