cppgc: Make ObjectSizeTrait::GetSize atomic
ObjectSizeTrait::GetSize is used by Trace methods in Blink and may be called while concurrent marking is active. The current version is non-atmoic and therefore can race with marking on other threads. Bug: chromium:1261860 Change-Id: Ia0b41ec496ac64ae3dd5a040b25f6972b21561c5 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3240832 Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Commit-Queue: Omer Katz <omerkatz@chromium.org> Cr-Commit-Position: refs/heads/main@{#77527}
This commit is contained in:
parent
cf98260e46
commit
5fe0aa3bc7
@ -14,7 +14,8 @@ namespace internal {
|
|||||||
// static
|
// static
|
||||||
size_t BaseObjectSizeTrait::GetObjectSizeForGarbageCollected(
|
size_t BaseObjectSizeTrait::GetObjectSizeForGarbageCollected(
|
||||||
const void* object) {
|
const void* object) {
|
||||||
return ObjectView(HeapObjectHeader::FromObject(object)).Size();
|
return ObjectView(HeapObjectHeader::FromObject(object))
|
||||||
|
.Size<AccessMode::kAtomic>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
@ -26,7 +27,7 @@ size_t BaseObjectSizeTrait::GetObjectSizeForGarbageCollectedMixin(
|
|||||||
BasePage::FromPayload(address)
|
BasePage::FromPayload(address)
|
||||||
->ObjectHeaderFromInnerAddress<AccessMode::kAtomic>(address);
|
->ObjectHeaderFromInnerAddress<AccessMode::kAtomic>(address);
|
||||||
DCHECK(!header.IsLargeObject());
|
DCHECK(!header.IsLargeObject());
|
||||||
return header.ObjectSize();
|
return header.ObjectSize<AccessMode::kAtomic>();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#define V8_HEAP_CPPGC_OBJECT_VIEW_H_
|
#define V8_HEAP_CPPGC_OBJECT_VIEW_H_
|
||||||
|
|
||||||
#include "include/v8config.h"
|
#include "include/v8config.h"
|
||||||
|
#include "src/heap/cppgc/globals.h"
|
||||||
#include "src/heap/cppgc/heap-object-header.h"
|
#include "src/heap/cppgc/heap-object-header.h"
|
||||||
#include "src/heap/cppgc/heap-page.h"
|
#include "src/heap/cppgc/heap-page.h"
|
||||||
|
|
||||||
@ -20,6 +21,7 @@ class ObjectView final {
|
|||||||
|
|
||||||
V8_INLINE Address Start() const;
|
V8_INLINE Address Start() const;
|
||||||
V8_INLINE ConstAddress End() const;
|
V8_INLINE ConstAddress End() const;
|
||||||
|
template <AccessMode = AccessMode::kNonAtomic>
|
||||||
V8_INLINE size_t Size() const;
|
V8_INLINE size_t Size() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -43,9 +45,10 @@ ConstAddress ObjectView::End() const {
|
|||||||
: header_.ObjectEnd();
|
: header_.ObjectEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <AccessMode mode>
|
||||||
size_t ObjectView::Size() const {
|
size_t ObjectView::Size() const {
|
||||||
return is_large_object_ ? LargePage::From(base_page_)->ObjectSize()
|
return is_large_object_ ? LargePage::From(base_page_)->ObjectSize()
|
||||||
: header_.ObjectSize();
|
: header_.ObjectSize<mode>();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
Loading…
Reference in New Issue
Block a user