aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorroland <none@none>2014-02-25 18:16:24 +0100
committerroland <none@none>2014-02-25 18:16:24 +0100
commitb224b47f19d87ae777a990cec29b1fd39b83c68d (patch)
treec5f80a80bc5b97c4e8a9dfa6065fd27f06e6e5a9 /test
parent2bbdf1d4cc262990989e64ace354e8428c81a002 (diff)
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
Summary: support for speculative traps that keep track of the root of the compilation in which a trap occurs. Reviewed-by: kvn, twisti
Diffstat (limited to 'test')
-rw-r--r--test/compiler/uncommontrap/TestSpecTrapClassUnloading.java97
1 files changed, 97 insertions, 0 deletions
diff --git a/test/compiler/uncommontrap/TestSpecTrapClassUnloading.java b/test/compiler/uncommontrap/TestSpecTrapClassUnloading.java
new file mode 100644
index 000000000..11572672a
--- /dev/null
+++ b/test/compiler/uncommontrap/TestSpecTrapClassUnloading.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8031752
+ * @summary speculative traps need to be cleaned up at GC
+ * @run main/othervm -XX:-TieredCompilation -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:+UnlockExperimentalVMOptions -XX:+UseTypeSpeculation -XX:TypeProfileLevel=222 -XX:CompileCommand=exclude,java.lang.reflect.Method::invoke -XX:CompileCommand=exclude,sun.reflect.DelegatingMethodAccessorImpl::invoke -Xmx1M TestSpecTrapClassUnloading
+ *
+ */
+
+import java.lang.reflect.Method;
+
+public class TestSpecTrapClassUnloading {
+ static class B {
+ final public boolean m(Object o) {
+ if (o.getClass() == B.class) {
+ return true;
+ }
+ return false;
+ }
+ }
+
+ static class MemoryChunk {
+ MemoryChunk other;
+ long[] array;
+ MemoryChunk(MemoryChunk other) {
+ other = other;
+ array = new long[1024 * 1024 * 1024];
+ }
+ }
+
+ static void m1(B b, Object o) {
+ b.m(o);
+ }
+
+ static void m2(B b, Object o) {
+ b.m(o);
+ }
+
+ public static void main(String[] args) throws Exception {
+ Method m = B.class.getMethod("m", Object.class);
+ Object o = new Object();
+ B b = new B();
+
+ // add speculative trap in B.m() for m1
+ for (int i = 0; i < 20000; i++) {
+ m1(b, b);
+ }
+ m1(b, o);
+
+ // add speculative trap in B.m() for code generated by reflection
+ for (int i = 0; i < 20000; i++) {
+ m.invoke(b, b);
+ }
+ m.invoke(b, o);
+
+ m = null;
+
+ // add speculative trap in B.m() for m2
+ for (int i = 0; i < 20000; i++) {
+ m2(b, b);
+ }
+ m2(b, o);
+
+ // Exhaust memory which causes the code generated by
+ // reflection to be unloaded but B.m() is not.
+ MemoryChunk root = null;
+ try {
+ while (true) {
+ root = new MemoryChunk(root);
+ }
+ } catch(OutOfMemoryError e) {
+ root = null;
+ }
+ }
+}