unified-young-gen: Don't miss tracing API objects

Apart from JSApiObject, there are other JS types with other visitor-ids
that may contain embedder fields. The CL adds support for embedder fields
visitation for such types.

Bug: v8:13475
Change-Id: Ifa6f947964d7900245287b35beab19f5b11347ea
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4079015
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#84669}
This commit is contained in:
Anton Bikineev 2022-12-05 16:13:54 +01:00 committed by V8 LUCI CQ
parent dbbc07b828
commit fd9bc064b2
3 changed files with 40 additions and 19 deletions

View File

@ -581,24 +581,13 @@ YoungGenerationMarkingVisitorBase<ConcreteVisitor, MarkingState>::
worklists_local_(worklists_local) {}
template <typename ConcreteVisitor, typename MarkingState>
int YoungGenerationMarkingVisitorBase<
ConcreteVisitor, MarkingState>::VisitJSArrayBuffer(Map map,
JSArrayBuffer object) {
if (!concrete_visitor()->ShouldVisit(object)) return 0;
object.YoungMarkExtension();
int size = JSArrayBuffer::BodyDescriptor::SizeOf(map, object);
JSArrayBuffer::BodyDescriptor::IterateBody(map, object, size, this);
return size;
}
template <typename ConcreteVisitor, typename MarkingState>
int YoungGenerationMarkingVisitorBase<
ConcreteVisitor, MarkingState>::VisitJSApiObject(Map map, JSObject object) {
if (!worklists_local_->SupportsExtractWrapper())
return this->VisitJSObject(map, object);
if (!concrete_visitor()->ShouldVisit(object)) return 0;
template <typename T>
int YoungGenerationMarkingVisitorBase<ConcreteVisitor, MarkingState>::
VisitEmbedderTracingSubClassWithEmbedderTracing(Map map, T object) {
const bool requires_snapshot = worklists_local_->SupportsExtractWrapper();
MarkingWorklists::Local::WrapperSnapshot wrapper_snapshot;
const bool valid_snapshot =
requires_snapshot &&
worklists_local_->ExtractWrapper(map, object, wrapper_snapshot);
const int size = concrete_visitor()->VisitJSObjectSubclass(map, object);
if (size && valid_snapshot) {
@ -608,6 +597,34 @@ int YoungGenerationMarkingVisitorBase<
return size;
}
template <typename ConcreteVisitor, typename MarkingState>
int YoungGenerationMarkingVisitorBase<
ConcreteVisitor, MarkingState>::VisitJSArrayBuffer(Map map,
JSArrayBuffer object) {
object.YoungMarkExtension();
return VisitEmbedderTracingSubClassWithEmbedderTracing(map, object);
}
template <typename ConcreteVisitor, typename MarkingState>
int YoungGenerationMarkingVisitorBase<
ConcreteVisitor, MarkingState>::VisitJSApiObject(Map map, JSObject object) {
return VisitEmbedderTracingSubClassWithEmbedderTracing(map, object);
}
template <typename ConcreteVisitor, typename MarkingState>
int YoungGenerationMarkingVisitorBase<
ConcreteVisitor, MarkingState>::VisitJSDataView(Map map,
JSDataView object) {
return VisitEmbedderTracingSubClassWithEmbedderTracing(map, object);
}
template <typename ConcreteVisitor, typename MarkingState>
int YoungGenerationMarkingVisitorBase<
ConcreteVisitor, MarkingState>::VisitJSTypedArray(Map map,
JSTypedArray object) {
return VisitEmbedderTracingSubClassWithEmbedderTracing(map, object);
}
template <typename ConcreteVisitor, typename MarkingState>
void YoungGenerationMarkingVisitorBase<ConcreteVisitor, MarkingState>::
MarkObjectViaMarkingWorklist(HeapObject object) {

View File

@ -242,15 +242,19 @@ class YoungGenerationMarkingVisitorBase
UNREACHABLE();
}
V8_INLINE int VisitJSArrayBuffer(Map map, JSArrayBuffer object);
V8_INLINE int VisitJSApiObject(Map map, JSObject object);
V8_INLINE int VisitJSArrayBuffer(Map map, JSArrayBuffer object);
V8_INLINE int VisitJSDataView(Map map, JSDataView object);
V8_INLINE int VisitJSTypedArray(Map map, JSTypedArray object);
protected:
ConcreteVisitor* concrete_visitor() {
return static_cast<ConcreteVisitor*>(this);
}
template <typename T>
int VisitEmbedderTracingSubClassWithEmbedderTracing(Map map, T object);
inline void MarkObjectViaMarkingWorklist(HeapObject object);
private:

View File

@ -236,7 +236,7 @@ int NewSpaceVisitor<ConcreteVisitor>::VisitWeakCell(Map map,
template <typename ConcreteVisitor>
template <typename T, typename TBodyDescriptor>
int NewSpaceVisitor<ConcreteVisitor>::VisitJSObjectSubclass(Map map, T object) {
if (!this->ShouldVisit(object)) return 0;
if (!static_cast<ConcreteVisitor*>(this)->ShouldVisit(object)) return 0;
this->VisitMapPointer(object);
int size = TBodyDescriptor::SizeOf(map, object);
TBodyDescriptor::IterateBody(map, object, size, this);