Mercurial > hg > truffle
annotate graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java @ 13229:325b4e4efb60
added CompilationResultBuilderFactory to support peep-hole instrumentation of methods as their code is emitted
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 03 Dec 2013 16:33:41 +0100 |
parents | 4568980f7257 |
children | bb35fc7e0d68 |
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.*; |
13229
325b4e4efb60
added CompilationResultBuilderFactory to support peep-hole instrumentation of methods as their code is emitted
Doug Simon <doug.simon@oracle.com>
parents:
13228
diff
changeset
|
34 import com.oracle.graal.lir.asm.*; |
10482
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.nodes.*; |
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.*; |
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.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
|
38 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
|
39 import com.oracle.graal.phases.util.*; |
12488
1a4dc163cd0a
abstracted HotSpotGraalRuntime as a RuntimeProvider which removes the recent selector addition to the Graal capabilities API and also makes Truffle independent of the graal.hotspot project (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12362
diff
changeset
|
40 import com.oracle.graal.runtime.*; |
10482
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 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
|
43 |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 public static void compileMethod(ResolvedJavaMethod method) { |
12488
1a4dc163cd0a
abstracted HotSpotGraalRuntime as a RuntimeProvider which removes the recent selector addition to the Graal capabilities API and also makes Truffle independent of the graal.hotspot project (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12362
diff
changeset
|
45 Backend backend = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend(); |
1a4dc163cd0a
abstracted HotSpotGraalRuntime as a RuntimeProvider which removes the recent selector addition to the Graal capabilities API and also makes Truffle independent of the graal.hotspot project (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12362
diff
changeset
|
46 Providers providers = backend.getProviders(); |
1a4dc163cd0a
abstracted HotSpotGraalRuntime as a RuntimeProvider which removes the recent selector addition to the Graal capabilities API and also makes Truffle independent of the graal.hotspot project (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12362
diff
changeset
|
47 SuitesProvider suitesProvider = backend.getSuites(); |
1a4dc163cd0a
abstracted HotSpotGraalRuntime as a RuntimeProvider which removes the recent selector addition to the Graal capabilities API and also makes Truffle independent of the graal.hotspot project (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12362
diff
changeset
|
48 Suites suites = suitesProvider.createSuites(); |
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 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 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
|
56 CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false); |
13228
4568980f7257
removed GraalCompiler.compileGraphNoScope
Doug Simon <doug.simon@oracle.com>
parents:
12488
diff
changeset
|
57 GraalCompiler.compileGraph(graph, cc, method, providers, backend, providers.getCodeCache().getTarget(), null, phasePlan, OptimisticOptimizations.ALL, new SpeculationLog(), suites, true, |
13229
325b4e4efb60
added CompilationResultBuilderFactory to support peep-hole instrumentation of methods as their code is emitted
Doug Simon <doug.simon@oracle.com>
parents:
13228
diff
changeset
|
58 new CompilationResult(), CompilationResultBuilderFactory.Default); |
10482
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
59 } |
3e34b0318de6
Experimental decompiler that outputs Java source code from Graal IR for debug purposes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
60 } |