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: Adam Klein <adamk@chromium.org> Cr-Commit-Position: refs/heads/main@{#80961}
This commit is contained in:
parent
5828eb4254
commit
8ae1188644
@ -77,8 +77,7 @@ class LockingThread final : public v8::base::Thread {
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
TEST_F(JSAtomicsMutexTest, Contention) {
|
TEST_F(JSAtomicsMutexTest, Contention) {
|
||||||
if (!ReadOnlyHeap::IsReadOnlySpaceShared()) return;
|
if (!IsJSSharedMemorySupported()) return;
|
||||||
if (!COMPRESS_POINTERS_IN_SHARED_CAGE_BOOL) return;
|
|
||||||
|
|
||||||
FLAG_harmony_struct = true;
|
FLAG_harmony_struct = true;
|
||||||
|
|
||||||
|
@ -86,11 +86,10 @@ class IsolateWrapper final {
|
|||||||
//
|
//
|
||||||
// A set of mixins from which the test fixtures will be constructed.
|
// A set of mixins from which the test fixtures will be constructed.
|
||||||
//
|
//
|
||||||
template <typename TMixin, CountersMode kCountersMode = kNoCounters,
|
template <typename TMixin, CountersMode kCountersMode = kNoCounters>
|
||||||
IsolateSharedMode kSharedMode = kStandaloneIsolate>
|
|
||||||
class WithIsolateMixin : public TMixin {
|
class WithIsolateMixin : public TMixin {
|
||||||
public:
|
public:
|
||||||
WithIsolateMixin() : isolate_wrapper_(kCountersMode, kSharedMode) {}
|
WithIsolateMixin() : isolate_wrapper_(kCountersMode, kStandaloneIsolate) {}
|
||||||
|
|
||||||
v8::Isolate* v8_isolate() const { return isolate_wrapper_.isolate(); }
|
v8::Isolate* v8_isolate() const { return isolate_wrapper_.isolate(); }
|
||||||
|
|
||||||
@ -98,6 +97,37 @@ class WithIsolateMixin : public TMixin {
|
|||||||
v8::IsolateWrapper isolate_wrapper_;
|
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>
|
template <typename TMixin>
|
||||||
class WithIsolateScopeMixin : public TMixin {
|
class WithIsolateScopeMixin : public TMixin {
|
||||||
public:
|
public:
|
||||||
@ -396,9 +426,9 @@ using TestWithNativeContextAndZone = //
|
|||||||
::testing::Test>>>>>>;
|
::testing::Test>>>>>>;
|
||||||
|
|
||||||
using TestWithSharedIsolate = //
|
using TestWithSharedIsolate = //
|
||||||
WithIsolateMixin< //
|
WithMaybeSharedIsolateMixin< //
|
||||||
WithDefaultPlatformMixin<::testing::Test>, //
|
WithDefaultPlatformMixin<::testing::Test>, //
|
||||||
kNoCounters, kSharedIsolate>;
|
kNoCounters>;
|
||||||
|
|
||||||
class V8_NODISCARD SaveFlags {
|
class V8_NODISCARD SaveFlags {
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user