Commit 59fe9618 authored by Michael Lippautz's avatar Michael Lippautz Committed by V8 LUCI CQ

cppgc: Move interesting checks behind DEBUG

v8_enable_v8_checks has very little coverage outside of V8 itself.
Move pointer verification checks behind DEBUG so that they fire in
regular debug or dcheck_always_on builds.

Change-Id: Ib2803240dd996f4223e403d20e927aff2955afbc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3242006Reviewed-by: 's avatarOmer Katz <omerkatz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77534}
parent 447c3f3c
...@@ -141,21 +141,17 @@ class V8_EXPORT PersistentRegion final : public PersistentRegionBase { ...@@ -141,21 +141,17 @@ class V8_EXPORT PersistentRegion final : public PersistentRegionBase {
PersistentRegion& operator=(const PersistentRegion&) = delete; PersistentRegion& operator=(const PersistentRegion&) = delete;
V8_INLINE PersistentNode* AllocateNode(void* owner, TraceCallback trace) { V8_INLINE PersistentNode* AllocateNode(void* owner, TraceCallback trace) {
#if V8_ENABLE_CHECKS CPPGC_DCHECK(IsCreationThread());
CheckIsCreationThread();
#endif // V8_ENABLE_CHECKS
return PersistentRegionBase::AllocateNode(owner, trace); return PersistentRegionBase::AllocateNode(owner, trace);
} }
V8_INLINE void FreeNode(PersistentNode* node) { V8_INLINE void FreeNode(PersistentNode* node) {
#if V8_ENABLE_CHECKS CPPGC_DCHECK(IsCreationThread());
CheckIsCreationThread();
#endif // V8_ENABLE_CHECKS
PersistentRegionBase::FreeNode(node); PersistentRegionBase::FreeNode(node);
} }
private: private:
void CheckIsCreationThread(); bool IsCreationThread();
int creation_thread_id_; int creation_thread_id_;
}; };
......
...@@ -92,19 +92,19 @@ class DisabledCheckingPolicy { ...@@ -92,19 +92,19 @@ class DisabledCheckingPolicy {
void CheckPointer(const void*) {} void CheckPointer(const void*) {}
}; };
#if V8_ENABLE_CHECKS #ifdef DEBUG
// Off heap members are not connected to object graph and thus cannot ressurect // Off heap members are not connected to object graph and thus cannot ressurect
// dead objects. // dead objects.
using DefaultMemberCheckingPolicy = using DefaultMemberCheckingPolicy =
SameThreadEnabledCheckingPolicy<false /* kCheckOffHeapAssignments*/>; SameThreadEnabledCheckingPolicy<false /* kCheckOffHeapAssignments*/>;
using DefaultPersistentCheckingPolicy = using DefaultPersistentCheckingPolicy =
SameThreadEnabledCheckingPolicy<true /* kCheckOffHeapAssignments*/>; SameThreadEnabledCheckingPolicy<true /* kCheckOffHeapAssignments*/>;
#else #else // !DEBUG
using DefaultMemberCheckingPolicy = DisabledCheckingPolicy; using DefaultMemberCheckingPolicy = DisabledCheckingPolicy;
using DefaultPersistentCheckingPolicy = DisabledCheckingPolicy; using DefaultPersistentCheckingPolicy = DisabledCheckingPolicy;
#endif #endif // !DEBUG
// For CT(W)P neither marking information (for value), nor objectstart bitmap // For CT(W)P neither marking information (for value), nor objectstart bitmap
// (for slot) are guaranteed to be present because there's no synchonization // (for slot) are guaranteed to be present because there's no synchronization
// between heaps after marking. // between heaps after marking.
using DefaultCrossThreadPersistentCheckingPolicy = DisabledCheckingPolicy; using DefaultCrossThreadPersistentCheckingPolicy = DisabledCheckingPolicy;
......
...@@ -109,8 +109,8 @@ PersistentRegion::PersistentRegion(const FatalOutOfMemoryHandler& oom_handler) ...@@ -109,8 +109,8 @@ PersistentRegion::PersistentRegion(const FatalOutOfMemoryHandler& oom_handler)
USE(creation_thread_id_); USE(creation_thread_id_);
} }
void PersistentRegion::CheckIsCreationThread() { bool PersistentRegion::IsCreationThread() {
DCHECK_EQ(creation_thread_id_, v8::base::OS::GetCurrentThreadId()); return creation_thread_id_ == v8::base::OS::GetCurrentThreadId();
} }
PersistentRegionLock::PersistentRegionLock() { PersistentRegionLock::PersistentRegionLock() {
......
...@@ -291,7 +291,7 @@ class GCedHolder : public GarbageCollected<GCedHolder> { ...@@ -291,7 +291,7 @@ class GCedHolder : public GarbageCollected<GCedHolder> {
} // namespace } // namespace
#if V8_ENABLE_CHECKS #if DEBUG
#ifdef CPPGC_VERIFY_HEAP #ifdef CPPGC_VERIFY_HEAP
TEST_F(PrefinalizerDeathTest, PrefinalizerCanRewireGraphWithDeadObjects) { TEST_F(PrefinalizerDeathTest, PrefinalizerCanRewireGraphWithDeadObjects) {
...@@ -328,7 +328,7 @@ TEST_F(PrefinalizerDeathTest, PrefinalizerCantRessurectObjectOnHeap) { ...@@ -328,7 +328,7 @@ TEST_F(PrefinalizerDeathTest, PrefinalizerCantRessurectObjectOnHeap) {
} }
#endif // CPPGC_VERIFY_HEAP #endif // CPPGC_VERIFY_HEAP
#endif // V8_ENABLE_CHECKS #endif // DEBUG
#ifdef CPPGC_ALLOW_ALLOCATIONS_IN_PREFINALIZERS #ifdef CPPGC_ALLOW_ALLOCATIONS_IN_PREFINALIZERS
TEST_F(PrefinalizerTest, AllocatingPrefinalizersInMultipleGCCycles) { TEST_F(PrefinalizerTest, AllocatingPrefinalizersInMultipleGCCycles) {
......
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