diff options
| author | 2017-03-15 06:28:52 +0000 | |
|---|---|---|
| committer | 2017-03-15 06:28:52 +0000 | |
| commit | 43e99be9db10111a2d6e094882cd06c248c69e11 (patch) | |
| tree | fb4d9ed1e6a5230c3a54e07157f017cf60167e51 /test | |
| parent | 8f301e26943c53485abc2da5ff1907f7c2e0ff0c (diff) | |
Revert "Revert "Revert "CHA for interface method."""
Breaks libcore tests.
This reverts commit 8f301e26943c53485abc2da5ff1907f7c2e0ff0c.
Change-Id: Iea46176118be9e05aceb06f2d290961bb1f38265
Diffstat (limited to 'test')
| -rw-r--r-- | test/616-cha-abstract/src/Main.java | 4 | ||||
| -rw-r--r-- | test/616-cha-interface-default/expected.txt | 1 | ||||
| -rw-r--r-- | test/616-cha-interface-default/info.txt | 2 | ||||
| -rw-r--r-- | test/616-cha-interface-default/multidex.jpp | 3 | ||||
| -rw-r--r-- | test/616-cha-interface-default/run | 18 | ||||
| -rw-r--r-- | test/616-cha-interface-default/src-multidex/Base.java | 41 | ||||
| -rw-r--r-- | test/616-cha-interface-default/src/Main.java | 176 | ||||
| -rw-r--r-- | test/616-cha-interface/expected.txt | 1 | ||||
| -rw-r--r-- | test/616-cha-interface/info.txt | 1 | ||||
| -rw-r--r-- | test/616-cha-interface/run | 18 | ||||
| -rw-r--r-- | test/616-cha-interface/src/Main.java | 173 | ||||
| -rw-r--r-- | test/616-cha-miranda/expected.txt | 1 | ||||
| -rw-r--r-- | test/616-cha-miranda/info.txt | 1 | ||||
| -rw-r--r-- | test/616-cha-miranda/run | 18 | ||||
| -rw-r--r-- | test/616-cha-miranda/src/Main.java | 163 |
15 files changed, 2 insertions, 619 deletions
diff --git a/test/616-cha-abstract/src/Main.java b/test/616-cha-abstract/src/Main.java index b33f575dec..e1d7db170d 100644 --- a/test/616-cha-abstract/src/Main.java +++ b/test/616-cha-abstract/src/Main.java @@ -39,8 +39,8 @@ class Main2 extends Main1 { } public class Main { - static Base sMain1; - static Base sMain2; + static Main1 sMain1; + static Main1 sMain2; static boolean sIsOptimizing = true; static boolean sHasJIT = true; diff --git a/test/616-cha-interface-default/expected.txt b/test/616-cha-interface-default/expected.txt deleted file mode 100644 index 6a5618ebc6..0000000000 --- a/test/616-cha-interface-default/expected.txt +++ /dev/null @@ -1 +0,0 @@ -JNI_OnLoad called diff --git a/test/616-cha-interface-default/info.txt b/test/616-cha-interface-default/info.txt deleted file mode 100644 index 11baa1f0f2..0000000000 --- a/test/616-cha-interface-default/info.txt +++ /dev/null @@ -1,2 +0,0 @@ -Test for Class Hierarchy Analysis (CHA) on interface method. -Test it under multidex configuration to check cross-dex inlining. diff --git a/test/616-cha-interface-default/multidex.jpp b/test/616-cha-interface-default/multidex.jpp deleted file mode 100644 index b0d200ea38..0000000000 --- a/test/616-cha-interface-default/multidex.jpp +++ /dev/null @@ -1,3 +0,0 @@ -Main: - @@com.android.jack.annotations.ForceInMainDex - class Main diff --git a/test/616-cha-interface-default/run b/test/616-cha-interface-default/run deleted file mode 100644 index d8b4f0d26c..0000000000 --- a/test/616-cha-interface-default/run +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2017 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. - -# Run without an app image to prevent the classes to be loaded at startup. -exec ${RUN} "${@}" --no-app-image diff --git a/test/616-cha-interface-default/src-multidex/Base.java b/test/616-cha-interface-default/src-multidex/Base.java deleted file mode 100644 index 2cbcb500c4..0000000000 --- a/test/616-cha-interface-default/src-multidex/Base.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -interface Base { - default public int foo(int i) { - if (i != 1) { - return -2; - } - return i + 10; - } - - // Test default method that's not inlined. - default public int $noinline$bar() { - System.out.print(""); - System.out.print(""); - System.out.print(""); - System.out.print(""); - System.out.print(""); - System.out.print(""); - System.out.print(""); - System.out.print(""); - return -1; - } - - default void printError(String msg) { - System.out.println(msg); - } -} diff --git a/test/616-cha-interface-default/src/Main.java b/test/616-cha-interface-default/src/Main.java deleted file mode 100644 index 951607d2cf..0000000000 --- a/test/616-cha-interface-default/src/Main.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -class Main1 implements Base { -} - -class Main2 extends Main1 { - public void foobar() {} -} - -class Main3 implements Base { - public int foo(int i) { - if (i != 3) { - printError("error3"); - } - return -(i + 10); - } -} - -public class Main { - static Base sMain1; - static Base sMain2; - static Base sMain3; - - static boolean sIsOptimizing = true; - static boolean sHasJIT = true; - static volatile boolean sOtherThreadStarted; - - private static void assertSingleImplementation(Class<?> clazz, String method_name, boolean b) { - if (hasSingleImplementation(clazz, method_name) != b) { - System.out.println(clazz + "." + method_name + - " doesn't have single implementation value of " + b); - } - } - - static int getValue(Class<?> cls) { - if (cls == Main1.class || cls == Main2.class) { - return 1; - } - return 3; - } - - // sMain1.foo()/sMain2.foo() will be always be Base.foo() before Main3 is loaded/linked. - // So sMain1.foo() can be devirtualized to Base.foo() and be inlined. - // After Dummy.createMain3() which links in Main3, live testImplement() on stack - // should be deoptimized. - static void testImplement(boolean createMain3, boolean wait, boolean setHasJIT) { - if (setHasJIT) { - if (isInterpreted()) { - sHasJIT = false; - } - return; - } - - if (createMain3 && (sIsOptimizing || sHasJIT)) { - assertIsManaged(); - } - - if (sMain1.foo(getValue(sMain1.getClass())) != 11) { - System.out.println("11 expected."); - } - if (sMain1.$noinline$bar() != -1) { - System.out.println("-1 expected."); - } - if (sMain2.foo(getValue(sMain2.getClass())) != 11) { - System.out.println("11 expected."); - } - - if (createMain3) { - // Wait for the other thread to start. - while (!sOtherThreadStarted); - // Create an Main2 instance and assign it to sMain2. - // sMain1 is kept the same. - sMain3 = Dummy.createMain3(); - // Wake up the other thread. - synchronized(Main.class) { - Main.class.notify(); - } - } else if (wait) { - // This is the other thread. - synchronized(Main.class) { - sOtherThreadStarted = true; - // Wait for Main2 to be linked and deoptimization is triggered. - try { - Main.class.wait(); - } catch (Exception e) { - } - } - } - - // There should be a deoptimization here right after Main3 is linked by - // calling Dummy.createMain3(), even though sMain1 didn't change. - // The behavior here would be different if inline-cache is used, which - // doesn't deoptimize since sMain1 still hits the type cache. - if (sMain1.foo(getValue(sMain1.getClass())) != 11) { - System.out.println("11 expected."); - } - if ((createMain3 || wait) && sHasJIT && !sIsOptimizing) { - // This method should be deoptimized right after Main3 is created. - assertIsInterpreted(); - } - - if (sMain3 != null) { - if (sMain3.foo(getValue(sMain3.getClass())) != -13) { - System.out.println("-13 expected."); - } - } - } - - // Test scenarios under which CHA-based devirtualization happens, - // and class loading that implements a method can invalidate compiled code. - public static void main(String[] args) { - System.loadLibrary(args[0]); - - if (isInterpreted()) { - sIsOptimizing = false; - } - - // sMain1 is an instance of Main1. - // sMain2 is an instance of Main2. - // Neither Main1 nor Main2 override default method Base.foo(). - // Main3 hasn't bee loaded yet. - sMain1 = new Main1(); - sMain2 = new Main2(); - - ensureJitCompiled(Main.class, "testImplement"); - testImplement(false, false, true); - - if (sHasJIT && !sIsOptimizing) { - assertSingleImplementation(Base.class, "foo", true); - assertSingleImplementation(Main1.class, "foo", true); - } else { - // Main3 is verified ahead-of-time so it's linked in already. - } - - // Create another thread that also calls sMain1.foo(). - // Try to test suspend and deopt another thread. - new Thread() { - public void run() { - testImplement(false, true, false); - } - }.start(); - - // This will create Main3 instance in the middle of testImplement(). - testImplement(true, false, false); - assertSingleImplementation(Base.class, "foo", false); - assertSingleImplementation(Main1.class, "foo", true); - assertSingleImplementation(sMain3.getClass(), "foo", true); - } - - private static native void ensureJitCompiled(Class<?> itf, String method_name); - private static native void assertIsInterpreted(); - private static native void assertIsManaged(); - private static native boolean isInterpreted(); - private static native boolean hasSingleImplementation(Class<?> clazz, String method_name); -} - -// Put createMain3() in another class to avoid class loading due to verifier. -class Dummy { - static Base createMain3() { - return new Main3(); - } -} diff --git a/test/616-cha-interface/expected.txt b/test/616-cha-interface/expected.txt deleted file mode 100644 index 6a5618ebc6..0000000000 --- a/test/616-cha-interface/expected.txt +++ /dev/null @@ -1 +0,0 @@ -JNI_OnLoad called diff --git a/test/616-cha-interface/info.txt b/test/616-cha-interface/info.txt deleted file mode 100644 index 1fd330afd4..0000000000 --- a/test/616-cha-interface/info.txt +++ /dev/null @@ -1 +0,0 @@ -Test for Class Hierarchy Analysis (CHA) on interface method. diff --git a/test/616-cha-interface/run b/test/616-cha-interface/run deleted file mode 100644 index d8b4f0d26c..0000000000 --- a/test/616-cha-interface/run +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2017 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. - -# Run without an app image to prevent the classes to be loaded at startup. -exec ${RUN} "${@}" --no-app-image diff --git a/test/616-cha-interface/src/Main.java b/test/616-cha-interface/src/Main.java deleted file mode 100644 index 3c9349663d..0000000000 --- a/test/616-cha-interface/src/Main.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -interface Base { - void foo(int i); - void $noinline$bar(); -} - -class Main1 implements Base { - public void foo(int i) { - if (i != 1) { - printError("error1"); - } - } - - // Test rewriting invoke-interface into invoke-virtual when inlining fails. - public void $noinline$bar() { - System.out.print(""); - System.out.print(""); - System.out.print(""); - System.out.print(""); - System.out.print(""); - System.out.print(""); - System.out.print(""); - System.out.print(""); - } - - void printError(String msg) { - System.out.println(msg); - } -} - -class Main2 extends Main1 { - public void foo(int i) { - if (i != 2) { - printError("error2"); - } - } -} - -public class Main { - static Base sMain1; - static Base sMain2; - - static boolean sIsOptimizing = true; - static boolean sHasJIT = true; - static volatile boolean sOtherThreadStarted; - - private static void assertSingleImplementation(Class<?> clazz, String method_name, boolean b) { - if (hasSingleImplementation(clazz, method_name) != b) { - System.out.println(clazz + "." + method_name + - " doesn't have single implementation value of " + b); - } - } - - // sMain1.foo() will be always be Main1.foo() before Main2 is loaded/linked. - // So sMain1.foo() can be devirtualized to Main1.foo() and be inlined. - // After Dummy.createMain2() which links in Main2, live testImplement() on stack - // should be deoptimized. - static void testImplement(boolean createMain2, boolean wait, boolean setHasJIT) { - if (setHasJIT) { - if (isInterpreted()) { - sHasJIT = false; - } - return; - } - - if (createMain2 && (sIsOptimizing || sHasJIT)) { - assertIsManaged(); - } - - sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); - sMain1.$noinline$bar(); - - if (createMain2) { - // Wait for the other thread to start. - while (!sOtherThreadStarted); - // Create an Main2 instance and assign it to sMain2. - // sMain1 is kept the same. - sMain2 = Dummy.createMain2(); - // Wake up the other thread. - synchronized(Main.class) { - Main.class.notify(); - } - } else if (wait) { - // This is the other thread. - synchronized(Main.class) { - sOtherThreadStarted = true; - // Wait for Main2 to be linked and deoptimization is triggered. - try { - Main.class.wait(); - } catch (Exception e) { - } - } - } - - // There should be a deoptimization here right after Main2 is linked by - // calling Dummy.createMain2(), even though sMain1 didn't change. - // The behavior here would be different if inline-cache is used, which - // doesn't deoptimize since sMain1 still hits the type cache. - sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); - if ((createMain2 || wait) && sHasJIT && !sIsOptimizing) { - // This method should be deoptimized right after Main2 is created. - assertIsInterpreted(); - } - - if (sMain2 != null) { - sMain2.foo(sMain2.getClass() == Main1.class ? 1 : 2); - } - } - - // Test scenarios under which CHA-based devirtualization happens, - // and class loading that overrides a method can invalidate compiled code. - public static void main(String[] args) { - System.loadLibrary(args[0]); - - if (isInterpreted()) { - sIsOptimizing = false; - } - - // sMain1 is an instance of Main1. Main2 hasn't bee loaded yet. - sMain1 = new Main1(); - - ensureJitCompiled(Main.class, "testImplement"); - testImplement(false, false, true); - - if (sHasJIT && !sIsOptimizing) { - assertSingleImplementation(Base.class, "foo", true); - assertSingleImplementation(Main1.class, "foo", true); - } else { - // Main2 is verified ahead-of-time so it's linked in already. - } - - // Create another thread that also calls sMain1.foo(). - // Try to test suspend and deopt another thread. - new Thread() { - public void run() { - testImplement(false, true, false); - } - }.start(); - - // This will create Main2 instance in the middle of testImplement(). - testImplement(true, false, false); - assertSingleImplementation(Base.class, "foo", false); - assertSingleImplementation(Main1.class, "foo", false); - } - - private static native void ensureJitCompiled(Class<?> itf, String method_name); - private static native void assertIsInterpreted(); - private static native void assertIsManaged(); - private static native boolean isInterpreted(); - private static native boolean hasSingleImplementation(Class<?> clazz, String method_name); -} - -// Put createMain2() in another class to avoid class loading due to verifier. -class Dummy { - static Main1 createMain2() { - return new Main2(); - } -} diff --git a/test/616-cha-miranda/expected.txt b/test/616-cha-miranda/expected.txt deleted file mode 100644 index 6a5618ebc6..0000000000 --- a/test/616-cha-miranda/expected.txt +++ /dev/null @@ -1 +0,0 @@ -JNI_OnLoad called diff --git a/test/616-cha-miranda/info.txt b/test/616-cha-miranda/info.txt deleted file mode 100644 index c46f33f613..0000000000 --- a/test/616-cha-miranda/info.txt +++ /dev/null @@ -1 +0,0 @@ -Test for Class Hierarchy Analysis (CHA) on miranda method. diff --git a/test/616-cha-miranda/run b/test/616-cha-miranda/run deleted file mode 100644 index d8b4f0d26c..0000000000 --- a/test/616-cha-miranda/run +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2017 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. - -# Run without an app image to prevent the classes to be loaded at startup. -exec ${RUN} "${@}" --no-app-image diff --git a/test/616-cha-miranda/src/Main.java b/test/616-cha-miranda/src/Main.java deleted file mode 100644 index e548482eb3..0000000000 --- a/test/616-cha-miranda/src/Main.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -interface Iface { - public void foo(int i); -} - -abstract class Base implements Iface { - // Iface.foo(int) will be added as a miranda method. - - void printError(String msg) { - System.out.println(msg); - } -} - -class Main1 extends Base { - public void foo(int i) { - if (i != 1) { - printError("error1"); - } - } -} - -class Main2 extends Main1 { - public void foo(int i) { - if (i != 2) { - printError("error2"); - } - } -} - -public class Main { - static Base sMain1; - static Base sMain2; - - static boolean sIsOptimizing = true; - static boolean sHasJIT = true; - static volatile boolean sOtherThreadStarted; - - private static void assertSingleImplementation(Class<?> clazz, String method_name, boolean b) { - if (hasSingleImplementation(clazz, method_name) != b) { - System.out.println(clazz + "." + method_name + - " doesn't have single implementation value of " + b); - } - } - - // sMain1.foo() will be always be Main1.foo() before Main2 is loaded/linked. - // So sMain1.foo() can be devirtualized to Main1.foo() and be inlined. - // After Dummy.createMain2() which links in Main2, live testOverride() on stack - // should be deoptimized. - static void testOverride(boolean createMain2, boolean wait, boolean setHasJIT) { - if (setHasJIT) { - if (isInterpreted()) { - sHasJIT = false; - } - return; - } - - if (createMain2 && (sIsOptimizing || sHasJIT)) { - assertIsManaged(); - } - - sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); - - if (createMain2) { - // Wait for the other thread to start. - while (!sOtherThreadStarted); - // Create an Main2 instance and assign it to sMain2. - // sMain1 is kept the same. - sMain2 = Dummy.createMain2(); - // Wake up the other thread. - synchronized(Main.class) { - Main.class.notify(); - } - } else if (wait) { - // This is the other thread. - synchronized(Main.class) { - sOtherThreadStarted = true; - // Wait for Main2 to be linked and deoptimization is triggered. - try { - Main.class.wait(); - } catch (Exception e) { - } - } - } - - // There should be a deoptimization here right after Main2 is linked by - // calling Dummy.createMain2(), even though sMain1 didn't change. - // The behavior here would be different if inline-cache is used, which - // doesn't deoptimize since sMain1 still hits the type cache. - sMain1.foo(sMain1.getClass() == Main1.class ? 1 : 2); - if ((createMain2 || wait) && sHasJIT && !sIsOptimizing) { - // This method should be deoptimized right after Main2 is created. - assertIsInterpreted(); - } - - if (sMain2 != null) { - sMain2.foo(sMain2.getClass() == Main1.class ? 1 : 2); - } - } - - // Test scenarios under which CHA-based devirtualization happens, - // and class loading that overrides a method can invalidate compiled code. - public static void main(String[] args) { - System.loadLibrary(args[0]); - - if (isInterpreted()) { - sIsOptimizing = false; - } - - // sMain1 is an instance of Main1. Main2 hasn't bee loaded yet. - sMain1 = new Main1(); - - ensureJitCompiled(Main.class, "testOverride"); - testOverride(false, false, true); - - if (sHasJIT && !sIsOptimizing) { - assertSingleImplementation(Base.class, "foo", true); - assertSingleImplementation(Main1.class, "foo", true); - } else { - // Main2 is verified ahead-of-time so it's linked in already. - } - - // Create another thread that also calls sMain1.foo(). - // Try to test suspend and deopt another thread. - new Thread() { - public void run() { - testOverride(false, true, false); - } - }.start(); - - // This will create Main2 instance in the middle of testOverride(). - testOverride(true, false, false); - assertSingleImplementation(Base.class, "foo", false); - assertSingleImplementation(Main1.class, "foo", false); - } - - private static native void ensureJitCompiled(Class<?> itf, String method_name); - private static native void assertIsInterpreted(); - private static native void assertIsManaged(); - private static native boolean isInterpreted(); - private static native boolean hasSingleImplementation(Class<?> clazz, String method_name); -} - -// Put createMain2() in another class to avoid class loading due to verifier. -class Dummy { - static Main1 createMain2() { - return new Main2(); - } -} |