Mercurial > hg > truffle
annotate graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java @ 12362:f53dc8bbb88c
refactored isReexecutable(), getKilledLocations() and canDeoptimize() out of MetaAccessProvider into ForeignCallsProvider (GRAAL-511)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Sat, 12 Oct 2013 00:31:37 +0200 |
parents | bba234a1670e |
children | 1a4dc163cd0a |
rev | line source |
---|---|
10482
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.java.decompiler.test; |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
25 import static com.oracle.graal.api.code.CodeUtil.*; |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
26 |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 import com.oracle.graal.api.code.*; |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 import com.oracle.graal.api.code.CallingConvention.Type; |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.graal.api.meta.*; |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.api.runtime.*; |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.graal.compiler.*; |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.graal.compiler.target.*; |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.graal.java.*; |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 import com.oracle.graal.nodes.*; |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
35 import com.oracle.graal.phases.*; |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
36 import com.oracle.graal.phases.PhasePlan.PhasePosition; |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 import com.oracle.graal.phases.tiers.*; |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
38 import com.oracle.graal.phases.util.*; |
10482
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
40 public class TestUtil { |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
42 public static void compileMethod(ResolvedJavaMethod method) { |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
43 Providers providers = GraalCompiler.getGraalProviders(); |
10482
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 Suites suites = Graal.getRequiredCapability(SuitesProvider.class).createSuites(); |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 StructuredGraph graph = new StructuredGraph(method); |
12362
f53dc8bbb88c
refactored isReexecutable(), getKilledLocations() and canDeoptimize() out of MetaAccessProvider into ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12054
diff
changeset
|
46 MetaAccessProvider metaAccess = providers.getMetaAccess(); |
f53dc8bbb88c
refactored isReexecutable(), getKilledLocations() and canDeoptimize() out of MetaAccessProvider into ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12054
diff
changeset
|
47 ForeignCallsProvider foreignCalls = providers.getForeignCalls(); |
f53dc8bbb88c
refactored isReexecutable(), getKilledLocations() and canDeoptimize() out of MetaAccessProvider into ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12054
diff
changeset
|
48 new GraphBuilderPhase(metaAccess, foreignCalls, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); |
10482
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 PhasePlan phasePlan = new PhasePlan(); |
12362
f53dc8bbb88c
refactored isReexecutable(), getKilledLocations() and canDeoptimize() out of MetaAccessProvider into ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12054
diff
changeset
|
50 GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(metaAccess, foreignCalls, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL); |
10482
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
52 CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false); |
10482
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 Backend backend = Graal.getRequiredCapability(Backend.class); |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
54 GraalCompiler.compileGraph(graph, cc, method, providers, backend, providers.getCodeCache().getTarget(), null, phasePlan, OptimisticOptimizations.ALL, new SpeculationLog(), suites, |
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
55 new CompilationResult()); |
10482
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 } |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 } |