diff options
author | 2018-09-06 10:05:57 +0100 | |
---|---|---|
committer | 2018-09-06 15:21:00 +0100 | |
commit | 2c4ffe1c2a348248af930f47e095e1e051ec1a3d (patch) | |
tree | 4ad09de627703f392c108817c974a9e264a56473 | |
parent | 0651b221dd55042ac69e2c0b2cec8843f10f5dfd (diff) |
Fix StackWalk test.
- Make sure methods expected in the C code do exist.
- Adjust new register expectations for $noinline$f
- Make sure all methods were compiled.
- Remove unused test/StackWalk2/StackWalk2.java
Test: 004-StackWalk
Change-Id: I0bd2fa63a152dc696ea0516a5c3f4a2008e7ef2c
-rw-r--r-- | test/004-StackWalk/build | 6 | ||||
-rw-r--r-- | test/004-StackWalk/classes.dex | bin | 3912 -> 3844 bytes | |||
-rw-r--r-- | test/004-StackWalk/src/Main.java | 42 | ||||
-rw-r--r-- | test/004-StackWalk/stack_walk_jni.cc | 44 | ||||
-rw-r--r-- | test/StackWalk2/StackWalk2.java | 58 | ||||
-rw-r--r-- | test/knownfailures.json | 4 |
6 files changed, 58 insertions, 96 deletions
diff --git a/test/004-StackWalk/build b/test/004-StackWalk/build index eeecbfcc40..3de541c75d 100644 --- a/test/004-StackWalk/build +++ b/test/004-StackWalk/build @@ -18,10 +18,8 @@ set -e # This test depends on the exact format of the DEX file. Since dx is deprecated, -# the classes.dex file is packaged as a test input. It was created with: -# -# $ javac -g -Xlint:-options -source 1.7 -target 1.7 -d classes src/Main.java -# $ dx --debug --dex --output=classes.dex classes +# the classes.dex file is packaged as a test input. See src/Main.java file +# to check how it was created. # Wrapper function for javac which for this test does nothing as the # test uses a pre-built DEX file. diff --git a/test/004-StackWalk/classes.dex b/test/004-StackWalk/classes.dex Binary files differindex ad452960c3..61a7277cf9 100644 --- a/test/004-StackWalk/classes.dex +++ b/test/004-StackWalk/classes.dex diff --git a/test/004-StackWalk/src/Main.java b/test/004-StackWalk/src/Main.java index 072b1d0c4d..2a098f7686 100644 --- a/test/004-StackWalk/src/Main.java +++ b/test/004-StackWalk/src/Main.java @@ -1,19 +1,36 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// This test depends on the exact format of the DEX file. Since dx is deprecated, +// the classes.dex file is packaged as a test input. It was created with: +// +// $ javac -g -Xlint:-options -source 1.7 -target 1.7 -d classes src/Main.java +// $ dx --debug --dex --output=classes.dex classes + public class Main { public Main() { } - boolean doThrow = false; - int $noinline$f() throws Exception { - g(1); - g(2); - - // This currently defeats inlining of `f`. - if (doThrow) { throw new Error(); } + $noinline$g(1); + $noinline$g(2); return 0; } - void g(int num_calls) { + void $noinline$g(int num_calls) { if (num_calls == 1) { System.out.println("1st call"); } else if (num_calls == 2) { @@ -81,11 +98,14 @@ public class Main { s4 = s18 = s19; s += s4; s += s18; - stackmap(0); - return s; + // Add a branch to workaround ART's large methods without branches heuristic. + if (testStackWalk(0) != 0) { + return s; + } + return s18; } - native int stackmap(int x); + native int testStackWalk(int x); public static void main(String[] args) throws Exception { System.loadLibrary(args[0]); diff --git a/test/004-StackWalk/stack_walk_jni.cc b/test/004-StackWalk/stack_walk_jni.cc index 89e2e660d9..53e0dae13d 100644 --- a/test/004-StackWalk/stack_walk_jni.cc +++ b/test/004-StackWalk/stack_walk_jni.cc @@ -20,7 +20,7 @@ namespace art { -#define CHECK_REGS(...) do { \ +#define CHECK_REGS_ARE_REFERENCES(...) do { \ int t[] = {__VA_ARGS__}; \ int t_size = sizeof(t) / sizeof(*t); \ CheckReferences(t, t_size, GetNativePcOffset()); \ @@ -43,58 +43,60 @@ class TestReferenceMapVisitor : public CheckReferenceMapVisitor { // Given the method name and the number of times the method has been called, // we know the Dex registers with live reference values. Assert that what we // find is what is expected. - if (m_name == "f") { + if (m_name == "$noinline$f") { if (gJava_StackWalk_refmap_calls == 1) { CHECK_EQ(1U, GetDexPc()); - CHECK_REGS(4); + CHECK_REGS_ARE_REFERENCES(1); } else { CHECK_EQ(gJava_StackWalk_refmap_calls, 2); CHECK_EQ(5U, GetDexPc()); - CHECK_REGS(4); + CHECK_REGS_ARE_REFERENCES(1); } - } else if (m_name == "g") { + found_f_ = true; + } else if (m_name == "$noinline$g") { if (gJava_StackWalk_refmap_calls == 1) { CHECK_EQ(0xcU, GetDexPc()); - CHECK_REGS(0, 2); // Note that v1 is not in the minimal root set + CHECK_REGS_ARE_REFERENCES(0, 2); // Note that v1 is not in the minimal root set } else { CHECK_EQ(gJava_StackWalk_refmap_calls, 2); CHECK_EQ(0xcU, GetDexPc()); - CHECK_REGS(0, 2); + CHECK_REGS_ARE_REFERENCES(0, 2); } + found_g_ = true; } else if (m_name == "shlemiel") { if (gJava_StackWalk_refmap_calls == 1) { CHECK_EQ(0x380U, GetDexPc()); - CHECK_REGS(2, 4, 5, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 21, 25); + CHECK_REGS_ARE_REFERENCES(2, 4, 5, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 21, 25); } else { CHECK_EQ(gJava_StackWalk_refmap_calls, 2); CHECK_EQ(0x380U, GetDexPc()); - CHECK_REGS(2, 4, 5, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 21, 25); + CHECK_REGS_ARE_REFERENCES(2, 4, 5, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 21, 25); } + found_shlemiel_ = true; } return true; } -}; -extern "C" JNIEXPORT jint JNICALL Java_Main_stackmap(JNIEnv*, jobject, jint count) { - ScopedObjectAccess soa(Thread::Current()); - CHECK_EQ(count, 0); - gJava_StackWalk_refmap_calls++; - - // Visitor - TestReferenceMapVisitor mapper(soa.Self()); - mapper.WalkStack(); + ~TestReferenceMapVisitor() { + } - return count + 1; -} + bool found_f_ = false; + bool found_g_ = false; + bool found_shlemiel_ = false; +}; -extern "C" JNIEXPORT jint JNICALL Java_Main_refmap2(JNIEnv*, jobject, jint count) { +extern "C" JNIEXPORT jint JNICALL Java_Main_testStackWalk(JNIEnv*, jobject, jint count) { ScopedObjectAccess soa(Thread::Current()); + CHECK_EQ(count, 0); gJava_StackWalk_refmap_calls++; // Visitor TestReferenceMapVisitor mapper(soa.Self()); mapper.WalkStack(); + CHECK(mapper.found_f_); + CHECK(mapper.found_g_); + CHECK(mapper.found_shlemiel_); return count + 1; } diff --git a/test/StackWalk2/StackWalk2.java b/test/StackWalk2/StackWalk2.java deleted file mode 100644 index 5e7b22c252..0000000000 --- a/test/StackWalk2/StackWalk2.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -public class StackWalk2 { - // use v1 for this - - String str = new String(); // use v0 for str in <init> - - int f() { - g(1); // use v0 for 1, v1 for this - g(2); // use v0 for 2, v1 for this - strTest(); // use v1 for this - return 0; - } - - void g(int num_calls) throws RuntimeException { - if (num_calls == 1) { // use v0 for 1, v3 for num_calls - System.logI("1st call"); // use v0 for PrintStream, v1 for "1st call" - refmap2(24); // use v0 for 24, v2 for this - } else if (num_calls == 2) { // use v0 for 2, v3 for num_calls - System.logI("2nd call"); // use v0 for PrintStream, v1 for "2nd call" - refmap2(25); // use v0 for 24, v2 for this - } - throw new RuntimeException(); // use v0 for new RuntimeException - } - - void strTest() { - System.logI(str); // use v1 for PrintStream, v2, v3 for str - str = null; // use v1 for null, v3 for str - str = new String("ya"); // use v2 for "ya", v1 for new String - String s = str; // use v0, v1, v3 - System.logI(str); // use v1 for PrintStream, v2, v3 for str - System.logI(s); // use v1 for PrintStream, v0 for s - s = null; // use v0 - System.logI(s); // use v1 for PrintStream, v0 for s - } - - native int refmap2(int x); - - public static void main(String[] args) { - System.loadLibrary(args[0]); - StackWalk2 st = new StackWalk2(); - st.f(); - } -} diff --git a/test/knownfailures.json b/test/knownfailures.json index 6004f25285..05c9aa9157 100644 --- a/test/knownfailures.json +++ b/test/knownfailures.json @@ -697,9 +697,9 @@ "description": ["Tests that depend on input-vdex are not supported with compact dex"] }, { - "tests": "661-oat-writer-layout", + "tests": ["661-oat-writer-layout", "004-StackWalk"], "variant": "interp-ac | interpreter | jit | no-prebuild | no-image | trace | redefine-stress | jvmti-stress", - "description": ["Test is designed to only check --compiler-filter=speed"] + "description": ["Tests are designed to only check --optimizing"] }, { "tests": "674-HelloWorld-Dm", |