зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1670940 - Speed up Atomic jsapi-tests by reusing cx+global r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D93344
This commit is contained in:
Родитель
1677e557a4
Коммит
1accae5496
|
@ -32,7 +32,7 @@ void* hidePointerValue(void* p) {
|
|||
//
|
||||
// Lock-freedom predicates
|
||||
|
||||
BEGIN_TEST(testAtomicLockFree8) {
|
||||
BEGIN_REUSABLE_TEST(testAtomicLockFree8) {
|
||||
// isLockfree8() must not return true if there are no 8-byte atomics
|
||||
|
||||
CHECK(!jit::AtomicOperations::isLockfree8() ||
|
||||
|
@ -48,7 +48,7 @@ END_TEST(testAtomicLockFree8)
|
|||
|
||||
// The JS spec requires specific behavior for all but 1 and 2.
|
||||
|
||||
BEGIN_TEST(testAtomicLockFreeJS) {
|
||||
BEGIN_REUSABLE_TEST(testAtomicLockFreeJS) {
|
||||
CHECK(jit::AtomicOperations::isLockfreeJS(1) ==
|
||||
true); // false is allowed by spec but not in SpiderMonkey
|
||||
CHECK(jit::AtomicOperations::isLockfreeJS(2) == true); // ditto
|
||||
|
@ -69,7 +69,7 @@ END_TEST(testAtomicLockFreeJS)
|
|||
// This only tests that fenceSeqCst is defined and that it doesn't crash if we
|
||||
// call it, but it has no return value and its effect is not observable here.
|
||||
|
||||
BEGIN_TEST(testAtomicFence) {
|
||||
BEGIN_REUSABLE_TEST(testAtomicFence) {
|
||||
jit::AtomicOperations::fenceSeqCst();
|
||||
return true;
|
||||
}
|
||||
|
@ -160,49 +160,49 @@ MOZ_ALIGNED_DECL(8, static uint8_t atomicMem2[8]);
|
|||
CHECK(*q2 == A); \
|
||||
return true
|
||||
|
||||
BEGIN_TEST(testAtomicOperationsU8) {
|
||||
BEGIN_REUSABLE_TEST(testAtomicOperationsU8) {
|
||||
const uint8_t A = 0xab;
|
||||
const uint8_t B = 0x37;
|
||||
ATOMIC_TESTS(uint8_t, A, B);
|
||||
}
|
||||
END_TEST(testAtomicOperationsU8)
|
||||
|
||||
BEGIN_TEST(testAtomicOperationsI8) {
|
||||
BEGIN_REUSABLE_TEST(testAtomicOperationsI8) {
|
||||
const int8_t A = 0x3b;
|
||||
const int8_t B = 0x27;
|
||||
ATOMIC_TESTS(int8_t, A, B);
|
||||
}
|
||||
END_TEST(testAtomicOperationsI8)
|
||||
|
||||
BEGIN_TEST(testAtomicOperationsU16) {
|
||||
BEGIN_REUSABLE_TEST(testAtomicOperationsU16) {
|
||||
const uint16_t A = 0xabdc;
|
||||
const uint16_t B = 0x3789;
|
||||
ATOMIC_TESTS(uint16_t, A, B);
|
||||
}
|
||||
END_TEST(testAtomicOperationsU16)
|
||||
|
||||
BEGIN_TEST(testAtomicOperationsI16) {
|
||||
BEGIN_REUSABLE_TEST(testAtomicOperationsI16) {
|
||||
const int16_t A = 0x3bdc;
|
||||
const int16_t B = 0x2737;
|
||||
ATOMIC_TESTS(int16_t, A, B);
|
||||
}
|
||||
END_TEST(testAtomicOperationsI16)
|
||||
|
||||
BEGIN_TEST(testAtomicOperationsU32) {
|
||||
BEGIN_REUSABLE_TEST(testAtomicOperationsU32) {
|
||||
const uint32_t A = 0xabdc0588;
|
||||
const uint32_t B = 0x37891942;
|
||||
ATOMIC_TESTS(uint32_t, A, B);
|
||||
}
|
||||
END_TEST(testAtomicOperationsU32)
|
||||
|
||||
BEGIN_TEST(testAtomicOperationsI32) {
|
||||
BEGIN_REUSABLE_TEST(testAtomicOperationsI32) {
|
||||
const int32_t A = 0x3bdc0588;
|
||||
const int32_t B = 0x27371843;
|
||||
ATOMIC_TESTS(int32_t, A, B);
|
||||
}
|
||||
END_TEST(testAtomicOperationsI32)
|
||||
|
||||
BEGIN_TEST(testAtomicOperationsU64) {
|
||||
BEGIN_REUSABLE_TEST(testAtomicOperationsU64) {
|
||||
if (!jit::AtomicOperations::hasAtomic8()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ BEGIN_TEST(testAtomicOperationsU64) {
|
|||
}
|
||||
END_TEST(testAtomicOperationsU64)
|
||||
|
||||
BEGIN_TEST(testAtomicOperationsI64) {
|
||||
BEGIN_REUSABLE_TEST(testAtomicOperationsI64) {
|
||||
if (!jit::AtomicOperations::hasAtomic8()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -267,14 +267,14 @@ END_TEST(testAtomicOperationsI64)
|
|||
CHECK(*q2 == A); \
|
||||
return true
|
||||
|
||||
BEGIN_TEST(testAtomicOperationsF32) {
|
||||
BEGIN_REUSABLE_TEST(testAtomicOperationsF32) {
|
||||
const float A(123.25);
|
||||
const float B(-987.75);
|
||||
ATOMIC_FLOAT_TESTS(float, A, B);
|
||||
}
|
||||
END_TEST(testAtomicOperationsF32)
|
||||
|
||||
BEGIN_TEST(testAtomicOperationsF64) {
|
||||
BEGIN_REUSABLE_TEST(testAtomicOperationsF64) {
|
||||
const double A(123.25);
|
||||
const double B(-987.75);
|
||||
ATOMIC_FLOAT_TESTS(double, A, B);
|
||||
|
@ -292,7 +292,7 @@ END_TEST(testAtomicOperationsF64)
|
|||
CHECK(*q == B); \
|
||||
return true
|
||||
|
||||
BEGIN_TEST(testAtomicOperationsU8Clamped) {
|
||||
BEGIN_REUSABLE_TEST(testAtomicOperationsU8Clamped) {
|
||||
const uint8_clamped A(0xab);
|
||||
const uint8_clamped B(0x37);
|
||||
ATOMIC_CLAMPED_TESTS(uint8_clamped, A, B);
|
||||
|
|
|
@ -384,14 +384,22 @@ class JSAPITest {
|
|||
virtual JSObject* createGlobal(JSPrincipals* principals = nullptr);
|
||||
};
|
||||
|
||||
#define BEGIN_TEST_WITH_ATTRIBUTES(testname, attrs) \
|
||||
class cls_##testname : public JSAPITest { \
|
||||
public: \
|
||||
virtual const char* name() override { return #testname; } \
|
||||
virtual bool run(JS::HandleObject global) override attrs
|
||||
#define BEGIN_TEST_WITH_ATTRIBUTES_AND_EXTRA(testname, attrs, extra) \
|
||||
class cls_##testname : public JSAPITest { \
|
||||
public: \
|
||||
virtual const char* name() override { return #testname; } \
|
||||
extra virtual bool run(JS::HandleObject global) override attrs
|
||||
|
||||
#define BEGIN_TEST_WITH_ATTRIBUTES(testname, attrs) \
|
||||
BEGIN_TEST_WITH_ATTRIBUTES_AND_EXTRA(testname, attrs, )
|
||||
|
||||
#define BEGIN_TEST(testname) BEGIN_TEST_WITH_ATTRIBUTES(testname, )
|
||||
|
||||
#define BEGIN_REUSABLE_TEST(testname) \
|
||||
BEGIN_TEST_WITH_ATTRIBUTES_AND_EXTRA( \
|
||||
testname, , cls_##testname() \
|
||||
: JSAPITest() { reuseGlobal = true; })
|
||||
|
||||
#define END_TEST(testname) \
|
||||
} \
|
||||
; \
|
||||
|
|
Загрузка…
Ссылка в новой задаче