mark which SkVM tests should JIT or not

Most of these tests converted over to test_interpreter_only()
are failing to JIT because of unimplemented instructions.  No
bug there, just TODOs.

But SkVM_hoist _should_ be JITting.  A while back I landed a CL
that messed with value lifetimes that prevents it from JITting.
Will be using this as a regression test to fix that bug.

Change-Id: Id2034f6548a45ed9aeb9ae3cbb24d389cad7dc60
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/248980
Commit-Queue: Mike Klein <mtklein@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: Mike Klein <mtklein@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Herb Derby <herb@google.com>
This commit is contained in:
Mike Klein 2019-10-16 10:11:56 -05:00 committed by Skia Commit-Bot
parent 91c1a231d4
commit 52435503e9

View File

@ -30,13 +30,26 @@ static void dump(skvm::Builder& builder, SkWStream* o) {
o->writeText("\n"); o->writeText("\n");
} }
// TODO: I'd like this to go away and have every test in here run both JIT and interpreter.
template <typename Fn> template <typename Fn>
static void test_jit_and_interpreter(skvm::Program&& program, Fn&& test) { static void test_interpreter_only(skiatest::Reporter* r, skvm::Program&& program, Fn&& test) {
test((const skvm::Program&) program); #if defined(SKVM_JIT)
program.dropJIT(); REPORTER_ASSERT(r, !program.hasJIT());
#endif
test((const skvm::Program&) program); test((const skvm::Program&) program);
} }
template <typename Fn>
static void test_jit_and_interpreter(skiatest::Reporter* r, skvm::Program&& program, Fn&& test) {
#if defined(SKVM_JIT)
REPORTER_ASSERT(r, program.hasJIT());
test((const skvm::Program&) program);
program.dropJIT();
#endif
test_interpreter_only(r, std::move(program), std::move(test));
}
DEF_TEST(SkVM, r) { DEF_TEST(SkVM, r) {
SkDynamicMemoryWStream buf; SkDynamicMemoryWStream buf;
@ -95,7 +108,7 @@ DEF_TEST(SkVM, r) {
dump(b, &buf); dump(b, &buf);
test_jit_and_interpreter(std::move(program), [&](const skvm::Program& program) { test_jit_and_interpreter(r, std::move(program), [&](const skvm::Program& program) {
int arg[] = {0,1,2,3,4,5,6,7,8,9}; int arg[] = {0,1,2,3,4,5,6,7,8,9};
program.eval(SK_ARRAY_COUNT(arg), arg); program.eval(SK_ARRAY_COUNT(arg), arg);
@ -131,7 +144,7 @@ DEF_TEST(SkVM, r) {
uint32_t src[9]; uint32_t src[9];
uint32_t dst[SK_ARRAY_COUNT(src)]; uint32_t dst[SK_ARRAY_COUNT(src)];
test_jit_and_interpreter(std::move(program), [&](const skvm::Program& program) { test_jit_and_interpreter(r, std::move(program), [&](const skvm::Program& program) {
for (int i = 0; i < (int)SK_ARRAY_COUNT(src); i++) { for (int i = 0; i < (int)SK_ARRAY_COUNT(src); i++) {
src[i] = 0xbb007733; src[i] = 0xbb007733;
dst[i] = 0xffaaccee; dst[i] = 0xffaaccee;
@ -163,7 +176,7 @@ DEF_TEST(SkVM, r) {
test_8888(SrcoverBuilder_I32{}.done("srcover_i32")); test_8888(SrcoverBuilder_I32{}.done("srcover_i32"));
test_8888(SrcoverBuilder_I32_SWAR{}.done("srcover_i32_SWAR")); test_8888(SrcoverBuilder_I32_SWAR{}.done("srcover_i32_SWAR"));
test_jit_and_interpreter(SrcoverBuilder_F32{Fmt::RGBA_8888, Fmt::G8}.done(), test_jit_and_interpreter(r, SrcoverBuilder_F32{Fmt::RGBA_8888, Fmt::G8}.done(),
[&](const skvm::Program& program) { [&](const skvm::Program& program) {
uint32_t src[9]; uint32_t src[9];
uint8_t dst[SK_ARRAY_COUNT(src)]; uint8_t dst[SK_ARRAY_COUNT(src)];
@ -186,7 +199,7 @@ DEF_TEST(SkVM, r) {
} }
}); });
test_jit_and_interpreter(SrcoverBuilder_F32{Fmt::A8, Fmt::A8}.done(), test_jit_and_interpreter(r, SrcoverBuilder_F32{Fmt::A8, Fmt::A8}.done(),
[&](const skvm::Program& program) { [&](const skvm::Program& program) {
uint8_t src[256], uint8_t src[256],
dst[256]; dst[256];
@ -214,7 +227,7 @@ DEF_TEST(SkVM_Pointless, r) {
b.splat(4.0f)); b.splat(4.0f));
} }
test_jit_and_interpreter(b.done(), [&](const skvm::Program& program) { test_jit_and_interpreter(r, b.done(), [&](const skvm::Program& program) {
for (int N = 0; N < 64; N++) { for (int N = 0; N < 64; N++) {
program.eval(N); program.eval(N);
} }
@ -235,7 +248,7 @@ DEF_TEST(SkVM_LoopCounts, r) {
b.add(b.splat(1), b.add(b.splat(1),
b.load32(arg))); b.load32(arg)));
test_jit_and_interpreter(b.done(), [&](const skvm::Program& program) { test_jit_and_interpreter(r, b.done(), [&](const skvm::Program& program) {
int buf[64]; int buf[64];
for (int N = 0; N <= (int)SK_ARRAY_COUNT(buf); N++) { for (int N = 0; N <= (int)SK_ARRAY_COUNT(buf); N++) {
for (int i = 0; i < (int)SK_ARRAY_COUNT(buf); i++) { for (int i = 0; i < (int)SK_ARRAY_COUNT(buf); i++) {
@ -268,7 +281,7 @@ DEF_TEST(SkVM_gathers, r) {
b.store8 (buf8 , b.gather8 (img, b.bit_and(x, b.splat(31)))); b.store8 (buf8 , b.gather8 (img, b.bit_and(x, b.splat(31))));
} }
test_jit_and_interpreter(b.done(), [&](const skvm::Program& program) { test_interpreter_only(r, b.done(), [&](const skvm::Program& program) {
const int img[] = {12,34,56,78, 90,98,76,54}; const int img[] = {12,34,56,78, 90,98,76,54};
constexpr int N = 20; constexpr int N = 20;
@ -326,7 +339,7 @@ DEF_TEST(SkVM_bitops, r) {
b.store32(ptr, x); b.store32(ptr, x);
} }
test_jit_and_interpreter(b.done(), [&](const skvm::Program& program) { test_jit_and_interpreter(r, b.done(), [&](const skvm::Program& program) {
int x = 0x42; int x = 0x42;
program.eval(1, &x); program.eval(1, &x);
REPORTER_ASSERT(r, x == 0x7fff'ffff); REPORTER_ASSERT(r, x == 0x7fff'ffff);
@ -345,7 +358,7 @@ DEF_TEST(SkVM_f32, r) {
b.store32(arg, b.bit_cast(w)); b.store32(arg, b.bit_cast(w));
} }
test_jit_and_interpreter(b.done(), [&](const skvm::Program& program) { test_jit_and_interpreter(r, b.done(), [&](const skvm::Program& program) {
float buf[] = { 1,2,3,4,5,6,7,8,9 }; float buf[] = { 1,2,3,4,5,6,7,8,9 };
program.eval(SK_ARRAY_COUNT(buf), buf); program.eval(SK_ARRAY_COUNT(buf), buf);
for (float v : buf) { for (float v : buf) {
@ -374,7 +387,7 @@ DEF_TEST(SkVM_cmp_i32, r) {
b.store32(b.varying<int>(), m); b.store32(b.varying<int>(), m);
} }
test_jit_and_interpreter(b.done(), [&](const skvm::Program& program) { test_interpreter_only(r, b.done(), [&](const skvm::Program& program) {
int in[] = { 0,1,2,3,4,5,6,7,8,9 }; int in[] = { 0,1,2,3,4,5,6,7,8,9 };
int out[SK_ARRAY_COUNT(in)]; int out[SK_ARRAY_COUNT(in)];
@ -411,7 +424,7 @@ DEF_TEST(SkVM_cmp_f32, r) {
b.store32(b.varying<int>(), m); b.store32(b.varying<int>(), m);
} }
test_jit_and_interpreter(b.done(), [&](const skvm::Program& program) { test_interpreter_only(r, b.done(), [&](const skvm::Program& program) {
float in[] = { 0,1,2,3,4,5,6,7,8,9 }; float in[] = { 0,1,2,3,4,5,6,7,8,9 };
int out[SK_ARRAY_COUNT(in)]; int out[SK_ARRAY_COUNT(in)];
@ -442,7 +455,7 @@ DEF_TEST(SkVM_i16x2, r) {
b.store32(buf, u); b.store32(buf, u);
} }
test_jit_and_interpreter(b.done(), [&](const skvm::Program& program) { test_interpreter_only(r, b.done(), [&](const skvm::Program& program) {
uint16_t buf[] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13 }; uint16_t buf[] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13 };
program.eval(SK_ARRAY_COUNT(buf)/2, buf); program.eval(SK_ARRAY_COUNT(buf)/2, buf);
@ -475,7 +488,7 @@ DEF_TEST(SkVM_cmp_i16, r) {
b.store32(buf, m); b.store32(buf, m);
} }
test_jit_and_interpreter(b.done(), [&](const skvm::Program& program) { test_interpreter_only(r, b.done(), [&](const skvm::Program& program) {
int16_t buf[] = { 0,1, 2,3, 4,5, 6,7, 8,9 }; int16_t buf[] = { 0,1, 2,3, 4,5, 6,7, 8,9 };
program.eval(SK_ARRAY_COUNT(buf)/2, buf); program.eval(SK_ARRAY_COUNT(buf)/2, buf);
@ -508,7 +521,7 @@ DEF_TEST(SkVM_mad, r) {
b.store32(arg, b.to_i32(v)); b.store32(arg, b.to_i32(v));
} }
test_jit_and_interpreter(b.done(), [&](const skvm::Program& program) { test_jit_and_interpreter(r, b.done(), [&](const skvm::Program& program) {
int x = 2; int x = 2;
program.eval(1, &x); program.eval(1, &x);
// x = 2 // x = 2
@ -532,7 +545,7 @@ DEF_TEST(SkVM_madder, r) {
b.store32(arg, b.bit_cast(w)); b.store32(arg, b.bit_cast(w));
} }
test_jit_and_interpreter(b.done(), [&](const skvm::Program& program) { test_jit_and_interpreter(r, b.done(), [&](const skvm::Program& program) {
float x = 2.0f; float x = 2.0f;
// y = 2*2 + 2 = 6 // y = 2*2 + 2 = 6
// z = 6*2 + 6 = 18 // z = 6*2 + 6 = 18
@ -555,7 +568,9 @@ DEF_TEST(SkVM_hoist, r) {
b.store32(arg, x); b.store32(arg, x);
} }
test_jit_and_interpreter(b.done(), [&](const skvm::Program& program) { // TODO: this really should JIT... a bug slipped in making it fail to.
// See https://skia-review.googlesource.com/c/skia/+/242591.
test_interpreter_only(r, b.done(), [&](const skvm::Program& program) {
int x = 4; int x = 4;
program.eval(1, &x); program.eval(1, &x);
// x += 0 + 1 + 2 + 3 + ... + 30 + 31 // x += 0 + 1 + 2 + 3 + ... + 30 + 31
@ -576,7 +591,7 @@ DEF_TEST(SkVM_select, r) {
b.store32(buf, x); b.store32(buf, x);
} }
test_jit_and_interpreter(b.done(), [&](const skvm::Program& program) { test_jit_and_interpreter(r, b.done(), [&](const skvm::Program& program) {
int buf[] = { 0,1,2,3,4,5,6,7,8 }; int buf[] = { 0,1,2,3,4,5,6,7,8 };
program.eval(SK_ARRAY_COUNT(buf), buf); program.eval(SK_ARRAY_COUNT(buf), buf);
for (int i = 0; i < (int)SK_ARRAY_COUNT(buf); i++) { for (int i = 0; i < (int)SK_ARRAY_COUNT(buf); i++) {
@ -615,7 +630,7 @@ DEF_TEST(SkVM_NewOps, r) {
SkDebugf("%.*s\n", blob->size(), blob->data()); SkDebugf("%.*s\n", blob->size(), blob->data());
} }
test_jit_and_interpreter(b.done(), [&](const skvm::Program& program) { test_interpreter_only(r, b.done(), [&](const skvm::Program& program) {
const int N = 31; const int N = 31;
int16_t buf[N]; int16_t buf[N];
for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) {