Mercurial > hg > graal-jvmci-8
changeset 5517:e09a1efdeafd
Remove compilation restriction on run* methods in jtt, add Object::<init> to the compiled method to test escape analysis
Added a loop+escape analysis test
Remove unused import
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Thu, 07 Jun 2012 21:13:41 +0200 |
parents | 35f9b57d70cb |
children | 62952fa9e7aa |
files | graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopEscape.java graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/SnippetTemplate.java mx/commands.py |
diffstat | 3 files changed, 107 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopEscape.java Thu Jun 07 21:13:41 2012 +0200 @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2012, 2012, 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. + */ +// Checkstyle: stop +package com.oracle.graal.jtt.loop; + +import org.junit.*; + +/* + * Test around an object that escapes directly from inside a loop (no virtual phi on the loop) + */ +public class LoopEscape { + public static L ll = new L(0, 1, 2); + + private static class L { + public int a; + public int b; + public int c; + public L(int a, int b, int c) { + this.a = a; + this.b = b; + this.c = c; + } + } + + + public static int test0(int count) { + L l = new L(5, 5, 5); + for (int i = 0; i < count; i++) { + l.a++; + l.b--; + l.c = 4; + } + + return l.a + l.b * 10 + l.c * 100; + } + + public static int test1(int count) { + L l = new L(5, 5, 5); + for (int i = 0; i < count; i++) { + if (l.a % 2 == 0) { + l.a++; + l.b--; + l.c = 4; + } else { + l.a++; + } + } + + return l.a + l.b * 10 + l.c * 100; + } + + @Test + public void run10() throws Throwable { + Assert.assertEquals(555, test1(0)); + } + + @Test + public void run11() throws Throwable { + Assert.assertEquals(556, test1(1)); + } + + @Test + public void run12() throws Throwable { + Assert.assertEquals(447, test1(2)); + } + + @Test + public void run00() throws Throwable { + Assert.assertEquals(555, test0(0)); + } + + @Test + public void run01() throws Throwable { + Assert.assertEquals(446, test0(1)); + } + + @Test + public void run02() throws Throwable { + Assert.assertEquals(437, test0(2)); + } + + @Test + public void run05() throws Throwable { + Assert.assertEquals(410, test0(5)); + } +}
--- a/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/SnippetTemplate.java Thu Jun 07 13:01:45 2012 +0200 +++ b/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/SnippetTemplate.java Thu Jun 07 21:13:41 2012 +0200 @@ -32,7 +32,6 @@ import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.Node.Verbosity; -import com.oracle.graal.lir.cfg.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.type.*;
--- a/mx/commands.py Thu Jun 07 13:01:45 2012 +0200 +++ b/mx/commands.py Thu Jun 07 21:13:41 2012 +0200 @@ -689,7 +689,7 @@ if len(neg) != 0: classes = [c for c in classes if not containsAny(c, neg)] - vm(['-XX:-BootstrapGraal', '-XX:CompileOnly=com/oracle/graal/jtt', '-XX:CompileCommand=exclude,com/oracle/graal/jtt*.run*', '-XX:CompileCommand=quiet', '-Xcomp', '-esa'] + vmArgs + ['-cp', mx.classpath(proj), 'org.junit.runner.JUnitCore'] + classes) + vm(['-XX:-BootstrapGraal', '-XX:CompileOnly=com/oracle/graal/jtt', '-XX:CompileCommand=compileonly,java/lang/Object::<init>', '-XX:CompileCommand=quiet', '-Xcomp', '-esa'] + vmArgs + ['-cp', mx.classpath(proj), 'org.junit.runner.JUnitCore'] + classes) def buildvms(args): """build one or more VMs in various configurations"""