Commit 8c8732f4 authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[heap] Add missing per-context size accounting

This adds accounting for
- StringTable that is marked black directly without going through
  ProcessMarkingWorklist.
- DescriptorArray that is marked black directly inside VisitMap.
- FeedbackMetadata that erroneously was assigned kVisitDataObject
  visitor id, which works only for a fixed size data object.

Bug: chromium:973627
Change-Id: If7c8bca06316f60e975bf86beea09481df8aca8b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2023545Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66006}
parent bc6ebfec
......@@ -1589,6 +1589,10 @@ void MarkCompactCollector::MarkStringTable(
if (marking_state()->WhiteToBlack(string_table)) {
// Explicitly mark the prefix.
string_table.IteratePrefix(custom_root_body_visitor);
if (marking_worklists()->IsPerContextMode()) {
native_context_stats_.IncrementSize(MarkingWorklists::kSharedContext,
string_table.Size());
}
}
}
......
......@@ -352,14 +352,18 @@ int MarkingVisitorBase<ConcreteVisitor, MarkingState>::VisitWeakCell(
// ===========================================================================
template <typename ConcreteVisitor, typename MarkingState>
void MarkingVisitorBase<ConcreteVisitor, MarkingState>::
MarkDescriptorArrayBlack(HeapObject host, DescriptorArray descriptors) {
size_t
MarkingVisitorBase<ConcreteVisitor, MarkingState>::MarkDescriptorArrayBlack(
HeapObject host, DescriptorArray descriptors) {
concrete_visitor()->marking_state()->WhiteToGrey(descriptors);
if (concrete_visitor()->marking_state()->GreyToBlack(descriptors)) {
VisitPointer(descriptors, descriptors.map_slot());
VisitPointers(descriptors, descriptors.GetFirstPointerSlot(),
descriptors.GetDescriptorSlot(0));
return DescriptorArray::BodyDescriptor::SizeOf(descriptors.map(),
descriptors);
}
return 0;
}
template <typename ConcreteVisitor, typename MarkingState>
......@@ -401,7 +405,7 @@ int MarkingVisitorBase<ConcreteVisitor, MarkingState>::VisitMap(Map meta_map,
// slot holding the descriptor array will be implicitly recorded when the
// pointer fields of this map are visited.
DescriptorArray descriptors = map.synchronized_instance_descriptors();
MarkDescriptorArrayBlack(map, descriptors);
size += MarkDescriptorArrayBlack(map, descriptors);
int number_of_own_descriptors = map.NumberOfOwnDescriptors();
if (number_of_own_descriptors) {
// It is possible that the concurrent marker observes the
......
......@@ -222,9 +222,10 @@ class MarkingVisitorBase : public HeapVisitor<int, ConcreteVisitor> {
V8_INLINE int VisitFixedArrayWithProgressBar(Map map, FixedArray object,
MemoryChunk* chunk);
// Marks the descriptor array black without pushing it on the marking work
// list and visits its header.
V8_INLINE void MarkDescriptorArrayBlack(HeapObject host,
DescriptorArray descriptors);
// list and visits its header. Returns the size of the descriptor array
// if it was successully marked as black.
V8_INLINE size_t MarkDescriptorArrayBlack(HeapObject host,
DescriptorArray descriptors);
// Marks the object grey and pushes it on the marking work list.
V8_INLINE void MarkObject(HeapObject host, HeapObject obj);
......
......@@ -28,6 +28,7 @@ namespace internal {
V(EmbedderDataArray) \
V(EphemeronHashTable) \
V(FeedbackCell) \
V(FeedbackMetadata) \
V(FeedbackVector) \
V(FixedArray) \
V(FixedDoubleArray) \
......
......@@ -180,6 +180,9 @@ VisitorId Map::GetVisitorId(Map map) {
case FEEDBACK_CELL_TYPE:
return kVisitFeedbackCell;
case FEEDBACK_METADATA_TYPE:
return kVisitFeedbackMetadata;
case FEEDBACK_VECTOR_TYPE:
return kVisitFeedbackVector;
......@@ -322,7 +325,6 @@ VisitorId Map::GetVisitorId(Map map) {
case FILLER_TYPE:
case FOREIGN_TYPE:
case HEAP_NUMBER_TYPE:
case FEEDBACK_METADATA_TYPE:
return kVisitDataObject;
case BIGINT_TYPE:
......
......@@ -26,6 +26,7 @@ enum InstanceType : uint16_t;
V(BigInt) \
V(ByteArray) \
V(DataObject) \
V(FeedbackMetadata) \
V(FixedDoubleArray) \
V(SeqOneByteString) \
V(SeqTwoByteString)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment