# HG changeset patch # User Matthias Grimmer # Date 1395044113 -3600 # Node ID 29f47f2c6388347784f98e6abeb96edbdbab422c # Parent 6fb61ad679620264a51d6583d8f7777052330c31 DebugPrinter: fix findbugs issues diff -r 6fb61ad67962 -r 29f47f2c6388 graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/DecompilerTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/DecompilerTest.java Mon Mar 17 09:15:13 2014 +0100 @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2013, 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. + */ +package com.oracle.graal.java.decompiler.test; + +import java.lang.reflect.*; + +import org.junit.*; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.api.runtime.*; +import com.oracle.graal.compiler.*; +import com.oracle.graal.java.decompiler.test.example.*; +import com.oracle.graal.phases.*; +import com.oracle.graal.printer.*; +import com.oracle.graal.runtime.*; + +public class DecompilerTest { + + public static void doTest(String name) { + try { + DebugEnvironment.initialize(System.out); + MetaAccessProvider metaAccess = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders().getMetaAccess(); + Method method = Example.class.getDeclaredMethod(name, new Class[]{int.class, int.class}); + final ResolvedJavaMethod javaMethod = metaAccess.lookupJavaMethod(method); + TestUtil.compileMethod(javaMethod); + } catch (NoSuchMethodException e) { + Assert.fail(); + } catch (SecurityException e) { + Assert.fail(); + } + } + + @Before + public void init() { + GraalOptions.DecompileAfterPhase.setValue(""); + GraalDebugConfig.Dump.setValue(""); + } + + @Test + public void test01() { + doTest("loop7"); + } + + @Test + public void test02() { + doTest("loop6"); + } + + @Test + public void test03() { + doTest("loop5"); + } + + @Test + public void test04() { + doTest("loop4"); + } + + @Test + public void test05() { + doTest("loop3"); + } + + @Test + public void test06() { + doTest("loop2"); + } + + @Test + public void test07() { + doTest("loop"); + } + + @Test + public void test08() { + doTest("if0"); + } + + @Test + public void test09() { + doTest("if1"); + } + + @Test + public void test10() { + doTest("if2"); + } + + @Test + public void test11() { + doTest("if3"); + } + + @Test + public void test12() { + doTest("if4"); + } +} diff -r 6fb61ad67962 -r 29f47f2c6388 graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/Test.java --- a/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/Test.java Sun Mar 16 19:20:21 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2013, 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. - */ -package com.oracle.graal.java.decompiler.test; - -import java.lang.reflect.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.runtime.*; -import com.oracle.graal.java.decompiler.test.example.*; -import com.oracle.graal.printer.*; -import com.oracle.graal.runtime.*; - -public class Test { - - /** - * @param args - * @throws SecurityException - * @throws NoSuchMethodException - */ - public static void main(String[] args) throws NoSuchMethodException, SecurityException { - DebugEnvironment.initialize(System.out); - MetaAccessProvider metaAccess = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders().getMetaAccess(); - Method method = Example.class.getDeclaredMethod("loop7", new Class[]{int.class, int.class}); - final ResolvedJavaMethod javaMethod = metaAccess.lookupJavaMethod(method); - TestUtil.compileMethod(javaMethod); - } -} diff -r 6fb61ad67962 -r 29f47f2c6388 graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java --- a/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java Sun Mar 16 19:20:21 2014 +0100 +++ b/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java Mon Mar 17 09:15:13 2014 +0100 @@ -24,6 +24,7 @@ import static com.oracle.graal.api.code.CodeUtil.*; import static com.oracle.graal.compiler.GraalCompiler.*; + import com.oracle.graal.api.code.*; import com.oracle.graal.api.code.CallingConvention.Type; import com.oracle.graal.api.meta.*; diff -r 6fb61ad67962 -r 29f47f2c6388 graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/DecompilerIfSimplify.java --- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/DecompilerIfSimplify.java Sun Mar 16 19:20:21 2014 +0100 +++ b/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/DecompilerIfSimplify.java Mon Mar 17 09:15:13 2014 +0100 @@ -68,7 +68,7 @@ // TODO(mg) // thenBlocks and elseBlocks can be both empty --> causes an AssertionError DecompilerIfBlock ifBlock = new DecompilerIfBlock(block.getBlock(), decompiler, thenBlocks, elseBlocks, infoStream); - if (thenBlocks.contains(block.getBlock()) || elseBlocks.contains(block.getBlock())) { + if (thenBlocks.contains(block) || elseBlocks.contains(block)) { throw new AssertionError(); } blocks.add(ifBlock); diff -r 6fb61ad67962 -r 29f47f2c6388 graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/block/DecompilerIfBlock.java --- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/block/DecompilerIfBlock.java Sun Mar 16 19:20:21 2014 +0100 +++ b/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/block/DecompilerIfBlock.java Mon Mar 17 09:15:13 2014 +0100 @@ -158,7 +158,20 @@ @Override public boolean contains(Block b) { - return b == block || thenBranch.contains(b) || elseBranch.contains(b); + if (b == block) { + return true; + } + for (DecompilerBlock i : thenBranch) { + if (i.block == b) { + return true; + } + } + for (DecompilerBlock i : elseBranch) { + if (i.block == b) { + return true; + } + } + return false; } @Override diff -r 6fb61ad67962 -r 29f47f2c6388 graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DecompilerDebugDumpHandler.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DecompilerDebugDumpHandler.java Sun Mar 16 19:20:21 2014 +0100 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DecompilerDebugDumpHandler.java Mon Mar 17 09:15:13 2014 +0100 @@ -35,6 +35,7 @@ public class DecompilerDebugDumpHandler implements DebugDumpHandler { + public static boolean printToNowhere; private final PrintStream infoPrintStream = System.out; private File file; private FileOutputStream fos; @@ -55,6 +56,15 @@ filter = filter.substring(0, filter.indexOf("Phase")); } + if (printToNowhere) { + printStream = new PrintStream(new OutputStream() { + @Override + public void write(int b) throws IOException { + // DO NOTHING + } + }); + } + if (printStream == null) { fileName = "decompilerDump_" + uniqueId.incrementAndGet() + "_" + System.currentTimeMillis() + ".txt"; file = new File(fileName); diff -r 6fb61ad67962 -r 29f47f2c6388 mx/projects --- a/mx/projects Sun Mar 16 19:20:21 2014 +0100 +++ b/mx/projects Mon Mar 17 09:15:13 2014 +0100 @@ -495,7 +495,7 @@ # graal.java.decompiler.test project@com.oracle.graal.java.decompiler.test@subDir=graal project@com.oracle.graal.java.decompiler.test@sourceDirs=src -project@com.oracle.graal.java.decompiler.test@dependencies=com.oracle.graal.printer,com.oracle.graal.runtime +project@com.oracle.graal.java.decompiler.test@dependencies=JUNIT,com.oracle.graal.printer,com.oracle.graal.runtime project@com.oracle.graal.java.decompiler.test@checkstyle=com.oracle.graal.graph project@com.oracle.graal.java.decompiler.test@javaCompliance=1.7 project@com.oracle.graal.java.decompiler.test@workingSets=Graal,Test