Commit 8ae11886 authored by Shu-yu Guo's avatar Shu-yu Guo Committed by V8 LUCI CQ

Correctly skip unittests

Not all V8 build configs support JS shared memory features. Trying to
create a new shared Isolate on such a config DCHECKs at runtime. Make
the shared Isolate test fixture conditionally initialize the shared
Isolate. Users must explicitly check for support.

Bug: v8:12547
Change-Id: I3df1ce7eb5ae9a3c136f88ea8f44c650cc0408ab
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3687565
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80961}
parent 5828eb42
......@@ -77,8 +77,7 @@ class LockingThread final : public v8::base::Thread {
} // namespace
TEST_F(JSAtomicsMutexTest, Contention) {
if (!ReadOnlyHeap::IsReadOnlySpaceShared()) return;
if (!COMPRESS_POINTERS_IN_SHARED_CAGE_BOOL) return;
if (!IsJSSharedMemorySupported()) return;
FLAG_harmony_struct = true;
......
......@@ -86,11 +86,10 @@ class IsolateWrapper final {
//
// A set of mixins from which the test fixtures will be constructed.
//
template <typename TMixin, CountersMode kCountersMode = kNoCounters,
IsolateSharedMode kSharedMode = kStandaloneIsolate>
template <typename TMixin, CountersMode kCountersMode = kNoCounters>
class WithIsolateMixin : public TMixin {
public:
WithIsolateMixin() : isolate_wrapper_(kCountersMode, kSharedMode) {}
WithIsolateMixin() : isolate_wrapper_(kCountersMode, kStandaloneIsolate) {}
v8::Isolate* v8_isolate() const { return isolate_wrapper_.isolate(); }
......@@ -98,6 +97,37 @@ class WithIsolateMixin : public TMixin {
v8::IsolateWrapper isolate_wrapper_;
};
// Warning: This is not a drop-in replacement for WithIsolateMixin!
//
// Users of WithMaybeSharedIsolateMixin, including TEST_F tests and classes that
// mix this class in, must explicit check IsJSSharedMemorySupported() before
// calling v8_isolate(). Creating shared Isolates is not supported on all build
// configurations.
template <typename TMixin, CountersMode kCountersMode = kNoCounters>
class WithMaybeSharedIsolateMixin : public TMixin {
public:
WithMaybeSharedIsolateMixin() {
if (IsJSSharedMemorySupported()) {
isolate_wrapper_.emplace(kCountersMode, kSharedIsolate);
}
}
bool IsJSSharedMemorySupported() const {
DCHECK_IMPLIES(
internal::ReadOnlyHeap::IsReadOnlySpaceShared(),
!COMPRESS_POINTERS_BOOL || COMPRESS_POINTERS_IN_SHARED_CAGE_BOOL);
return internal::ReadOnlyHeap::IsReadOnlySpaceShared();
}
v8::Isolate* v8_isolate() const {
DCHECK(IsJSSharedMemorySupported());
return isolate_wrapper_->isolate();
}
private:
base::Optional<v8::IsolateWrapper> isolate_wrapper_;
};
template <typename TMixin>
class WithIsolateScopeMixin : public TMixin {
public:
......@@ -396,9 +426,9 @@ using TestWithNativeContextAndZone = //
::testing::Test>>>>>>;
using TestWithSharedIsolate = //
WithIsolateMixin< //
WithMaybeSharedIsolateMixin< //
WithDefaultPlatformMixin<::testing::Test>, //
kNoCounters, kSharedIsolate>;
kNoCounters>;
class V8_NODISCARD SaveFlags {
public:
......
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