summaryrefslogtreecommitdiff
path: root/deps/v8/src/heap/mark-compact-inl.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/heap/mark-compact-inl.h')
-rw-r--r--deps/v8/src/heap/mark-compact-inl.h74
1 files changed, 59 insertions, 15 deletions
diff --git a/deps/v8/src/heap/mark-compact-inl.h b/deps/v8/src/heap/mark-compact-inl.h
index a6bbecd88e..c21c7dda6e 100644
--- a/deps/v8/src/heap/mark-compact-inl.h
+++ b/deps/v8/src/heap/mark-compact-inl.h
@@ -28,7 +28,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode,
MarkingState>::VisitAllocationSite(Map* map,
AllocationSite* object) {
int size = AllocationSite::BodyDescriptorWeak::SizeOf(map, object);
- AllocationSite::BodyDescriptorWeak::IterateBody(object, size, this);
+ AllocationSite::BodyDescriptorWeak::IterateBody(map, object, size, this);
return size;
}
@@ -38,7 +38,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode,
MarkingState>::VisitBytecodeArray(Map* map,
BytecodeArray* array) {
int size = BytecodeArray::BodyDescriptor::SizeOf(map, array);
- BytecodeArray::BodyDescriptor::IterateBody(array, size, this);
+ BytecodeArray::BodyDescriptor::IterateBody(map, array, size, this);
array->MakeOlder();
return size;
}
@@ -48,7 +48,7 @@ template <FixedArrayVisitationMode fixed_array_mode,
int MarkingVisitor<fixed_array_mode, retaining_path_mode, MarkingState>::
VisitCodeDataContainer(Map* map, CodeDataContainer* object) {
int size = CodeDataContainer::BodyDescriptorWeak::SizeOf(map, object);
- CodeDataContainer::BodyDescriptorWeak::IterateBody(object, size, this);
+ CodeDataContainer::BodyDescriptorWeak::IterateBody(map, object, size, this);
return size;
}
@@ -71,7 +71,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode,
heap_->TracePossibleWrapper(object);
}
int size = JSObject::BodyDescriptor::SizeOf(map, object);
- JSObject::BodyDescriptor::IterateBody(object, size, this);
+ JSObject::BodyDescriptor::IterateBody(map, object, size, this);
return size;
}
@@ -81,7 +81,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode,
MarkingState>::VisitJSFunction(Map* map,
JSFunction* object) {
int size = JSFunction::BodyDescriptorWeak::SizeOf(map, object);
- JSFunction::BodyDescriptorWeak::IterateBody(object, size, this);
+ JSFunction::BodyDescriptorWeak::IterateBody(map, object, size, this);
return size;
}
@@ -98,7 +98,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode, MarkingState>::
// Skip visiting the backing hash table containing the mappings and the
// pointer to the other enqueued weak collections, both are post-processed.
int size = JSWeakCollection::BodyDescriptorWeak::SizeOf(map, weak_collection);
- JSWeakCollection::BodyDescriptorWeak::IterateBody(weak_collection, size,
+ JSWeakCollection::BodyDescriptorWeak::IterateBody(map, weak_collection, size,
this);
// Partially initialized weak collection is enqueued, but table is ignored.
@@ -119,14 +119,13 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode,
MarkingState>::VisitMap(Map* map, Map* object) {
// When map collection is enabled we have to mark through map's transitions
// and back pointers in a special way to make these links weak.
+ int size = Map::BodyDescriptor::SizeOf(map, object);
if (object->CanTransition()) {
MarkMapContents(object);
} else {
- VisitPointers(object,
- HeapObject::RawField(object, Map::kPointerFieldsBeginOffset),
- HeapObject::RawField(object, Map::kPointerFieldsEndOffset));
+ Map::BodyDescriptor::IterateBody(map, object, size, this);
}
- return Map::BodyDescriptor::SizeOf(map, object);
+ return size;
}
template <FixedArrayVisitationMode fixed_array_mode,
@@ -135,7 +134,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode,
MarkingState>::VisitNativeContext(Map* map,
Context* context) {
int size = Context::BodyDescriptorWeak::SizeOf(map, context);
- Context::BodyDescriptorWeak::IterateBody(context, size, this);
+ Context::BodyDescriptorWeak::IterateBody(map, context, size, this);
return size;
}
@@ -145,7 +144,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode,
MarkingState>::VisitTransitionArray(Map* map,
TransitionArray* array) {
int size = TransitionArray::BodyDescriptor::SizeOf(map, array);
- TransitionArray::BodyDescriptor::IterateBody(array, size, this);
+ TransitionArray::BodyDescriptor::IterateBody(map, array, size, this);
collector_->AddTransitionArray(array);
return size;
}
@@ -187,6 +186,32 @@ void MarkingVisitor<fixed_array_mode, retaining_path_mode,
template <FixedArrayVisitationMode fixed_array_mode,
TraceRetainingPathMode retaining_path_mode, typename MarkingState>
void MarkingVisitor<fixed_array_mode, retaining_path_mode,
+ MarkingState>::VisitPointer(HeapObject* host,
+ MaybeObject** p) {
+ HeapObject* target_object;
+ if ((*p)->ToStrongHeapObject(&target_object)) {
+ collector_->RecordSlot(host, reinterpret_cast<HeapObjectReference**>(p),
+ target_object);
+ MarkObject(host, target_object);
+ } else if ((*p)->ToWeakHeapObject(&target_object)) {
+ if (marking_state()->IsBlackOrGrey(target_object)) {
+ // Weak references with live values are directly processed here to reduce
+ // the processing time of weak cells during the main GC pause.
+ collector_->RecordSlot(host, reinterpret_cast<HeapObjectReference**>(p),
+ target_object);
+ } else {
+ // If we do not know about liveness of values of weak cells, we have to
+ // process them when we know the liveness of the whole transitive
+ // closure.
+ collector_->AddWeakReference(host,
+ reinterpret_cast<HeapObjectReference**>(p));
+ }
+ }
+}
+
+template <FixedArrayVisitationMode fixed_array_mode,
+ TraceRetainingPathMode retaining_path_mode, typename MarkingState>
+void MarkingVisitor<fixed_array_mode, retaining_path_mode,
MarkingState>::VisitPointers(HeapObject* host,
Object** start, Object** end) {
for (Object** p = start; p < end; p++) {
@@ -197,6 +222,17 @@ void MarkingVisitor<fixed_array_mode, retaining_path_mode,
template <FixedArrayVisitationMode fixed_array_mode,
TraceRetainingPathMode retaining_path_mode, typename MarkingState>
void MarkingVisitor<fixed_array_mode, retaining_path_mode,
+ MarkingState>::VisitPointers(HeapObject* host,
+ MaybeObject** start,
+ MaybeObject** end) {
+ for (MaybeObject** p = start; p < end; p++) {
+ VisitPointer(host, p);
+ }
+}
+
+template <FixedArrayVisitationMode fixed_array_mode,
+ TraceRetainingPathMode retaining_path_mode, typename MarkingState>
+void MarkingVisitor<fixed_array_mode, retaining_path_mode,
MarkingState>::VisitEmbeddedPointer(Code* host,
RelocInfo* rinfo) {
DCHECK(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT);
@@ -204,6 +240,8 @@ void MarkingVisitor<fixed_array_mode, retaining_path_mode,
collector_->RecordRelocSlot(host, rinfo, object);
if (!host->IsWeakObject(object)) {
MarkObject(host, object);
+ } else if (!marking_state()->IsBlackOrGrey(object)) {
+ collector_->AddWeakObjectInCode(object, host);
}
}
@@ -288,7 +326,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode, MarkingState>::
}
}
} else {
- FixedArray::BodyDescriptor::IterateBody(object, object_size, this);
+ FixedArray::BodyDescriptor::IterateBody(map, object, object_size, this);
}
return object_size;
}
@@ -320,8 +358,8 @@ void MarkingVisitor<fixed_array_mode, retaining_path_mode,
// Mark the pointer fields of the Map. Since the transitions array has
// been marked already, it is fine that one of these fields contains a
// pointer to it.
- VisitPointers(map, HeapObject::RawField(map, Map::kPointerFieldsBeginOffset),
- HeapObject::RawField(map, Map::kPointerFieldsEndOffset));
+ Map::BodyDescriptor::IterateBody(
+ map->map(), map, Map::BodyDescriptor::SizeOf(map->map(), map), this);
}
void MarkCompactCollector::MarkObject(HeapObject* host, HeapObject* obj) {
@@ -353,6 +391,12 @@ void MarkCompactCollector::MarkExternallyReferencedObject(HeapObject* obj) {
void MarkCompactCollector::RecordSlot(HeapObject* object, Object** slot,
Object* target) {
+ RecordSlot(object, reinterpret_cast<HeapObjectReference**>(slot), target);
+}
+
+void MarkCompactCollector::RecordSlot(HeapObject* object,
+ HeapObjectReference** slot,
+ Object* target) {
Page* target_page = Page::FromAddress(reinterpret_cast<Address>(target));
Page* source_page = Page::FromAddress(reinterpret_cast<Address>(object));
if (target_page->IsEvacuationCandidate<AccessMode::ATOMIC>() &&