Mercurial > hg > truffle
annotate graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/GraphTest.java @ 5433:d7b5cc23945e
refactored tests to share support for dump-aware compilation
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 23 May 2012 14:42:28 +0200 |
parents | 0364a2a874b8 |
children | 425c74c9444d |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
23 package com.oracle.graal.compiler.tests; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
25 import java.lang.reflect.*; |
5360
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
26 import java.util.concurrent.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5109
diff
changeset
|
28 import junit.framework.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5109
diff
changeset
|
30 import com.oracle.graal.compiler.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
31 import com.oracle.graal.compiler.phases.*; |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5109
diff
changeset
|
32 import com.oracle.graal.compiler.phases.PhasePlan.PhasePosition; |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
33 import com.oracle.graal.compiler.schedule.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
34 import com.oracle.graal.cri.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
35 import com.oracle.graal.debug.*; |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
36 import com.oracle.graal.graph.*; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
37 import com.oracle.graal.graph.Node.Verbosity; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
38 import com.oracle.graal.java.*; |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
39 import com.oracle.graal.lir.cfg.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
40 import com.oracle.graal.nodes.*; |
5360
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
41 import com.oracle.max.cri.ci.*; |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5109
diff
changeset
|
42 import com.oracle.max.cri.ri.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 * Base class for Graal compiler unit tests. These are white box tests |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 * for Graal compiler transformations. The general pattern for a test is: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 * <ol> |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 * <li>Create a graph by {@linkplain #parse(String) parsing} a method.</li> |
5360
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
49 * <li>Manually modify the graph (e.g. replace a parameter node with a constant).</li> |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 * <li>Apply a transformation to the graph.</li> |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 * <li>Assert that the transformed graph is equal to an expected graph.</li> |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 * </ol> |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 * <p> |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 * See {@link InvokeTest} as an example. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 * <p> |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 * The tests can be run in Eclipse with the "Compiler Unit Test" Eclipse |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 * launch configuration found in the top level of this project or by |
4410 | 58 * running {@code mx unittest} on the command line. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
59 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
60 public abstract class GraphTest { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
61 |
5360
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
62 protected final GraalCompiler graalCompiler; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
63 protected final GraalRuntime runtime; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
64 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
65 public GraphTest() { |
5085
5bdaa08ba96b
add and enable new PropagateTypeCachePhase, add type system tests
Lukas Stadler <lukas.stadler@jku.at>
parents:
5061
diff
changeset
|
66 Debug.enable(); |
5360
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
67 this.graalCompiler = GraalAccess.getGraalCompiler(); |
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
68 this.runtime = graalCompiler.runtime; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
69 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
70 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
71 protected void assertEquals(StructuredGraph expected, StructuredGraph graph) { |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
72 String expectedString = getCanonicalGraphString(expected); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
73 String actualString = getCanonicalGraphString(graph); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
74 String mismatchString = "mismatch in graphs:\n========= expected =========\n" + expectedString + "\n\n========= actual =========\n" + actualString; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
75 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 if (expected.getNodeCount() != graph.getNodeCount()) { |
4363
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4265
diff
changeset
|
77 Debug.dump(expected, "Node count not matching - expected"); |
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4265
diff
changeset
|
78 Debug.dump(graph, "Node count not matching - actual"); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
79 Assert.fail("Graphs do not have the same number of nodes: " + expected.getNodeCount() + " vs. " + graph.getNodeCount() + "\n" + mismatchString); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
80 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
81 if (!expectedString.equals(actualString)) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
82 Debug.dump(expected, "mismatching graphs - expected"); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
83 Debug.dump(graph, "mismatching graphs - actual"); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
84 Assert.fail(mismatchString); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
86 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
87 |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
88 private static String getCanonicalGraphString(StructuredGraph graph) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
89 SchedulePhase schedule = new SchedulePhase(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
90 schedule.apply(graph); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
91 |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
92 NodeMap<Integer> canonicalId = graph.createNodeMap(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
93 int nextId = 0; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
94 |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
95 StringBuilder result = new StringBuilder(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
96 for (Block block : schedule.getCFG().getBlocks()) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
97 result.append("Block " + block + " "); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
98 if (block == schedule.getCFG().getStartBlock()) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
99 result.append("* "); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
100 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
101 result.append("-> "); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
102 for (Block succ : block.getSuccessors()) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
103 result.append(succ + " "); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
104 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
105 result.append("\n"); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
106 for (Node node : schedule.getBlockToNodesMap().get(block)) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
107 int id; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
108 if (canonicalId.get(node) != null) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
109 id = canonicalId.get(node); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
110 } else { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
111 id = nextId++; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
112 canonicalId.set(node, id); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
113 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
114 String name = node instanceof ConstantNode ? node.toString(Verbosity.Name) : node.getClass().getSimpleName(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
115 result.append(" " + id + "|" + name + " (" + node.usages().size() + ")\n"); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
116 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
117 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
118 return result.toString(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
119 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
120 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
121 protected GraalRuntime runtime() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
122 return runtime; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
123 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
124 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
125 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
126 * Parses a Java method to produce a graph. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
128 * @param methodName the name of the method in {@code this.getClass()} to be parsed |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
129 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
130 protected StructuredGraph parse(String methodName) { |
4993
897b7d18bebc
added RiCompiledMethod.execute and the required VM infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
4410
diff
changeset
|
131 return parse(getMethod(methodName)); |
897b7d18bebc
added RiCompiledMethod.execute and the required VM infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
4410
diff
changeset
|
132 } |
897b7d18bebc
added RiCompiledMethod.execute and the required VM infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
4410
diff
changeset
|
133 |
897b7d18bebc
added RiCompiledMethod.execute and the required VM infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
4410
diff
changeset
|
134 protected Method getMethod(String methodName) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
135 Method found = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
136 for (Method m : this.getClass().getMethods()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
137 if (m.getName().equals(methodName)) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
138 Assert.assertNull(found); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
139 found = m; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
140 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
141 } |
4340
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
142 if (found != null) { |
4993
897b7d18bebc
added RiCompiledMethod.execute and the required VM infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
4410
diff
changeset
|
143 return found; |
4340
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
144 } else { |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
145 throw new RuntimeException("method not found: " + methodName); |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
146 } |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
147 } |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
148 |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
5425
diff
changeset
|
149 private static int compilationId = 0; |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
5425
diff
changeset
|
150 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
5425
diff
changeset
|
151 protected RiCompiledMethod compile(final RiResolvedMethod method, final StructuredGraph graph) { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
5425
diff
changeset
|
152 return Debug.scope("Compiling", new DebugDumpScope(String.valueOf(compilationId++), true), new Callable<RiCompiledMethod>() { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
5425
diff
changeset
|
153 public RiCompiledMethod call() throws Exception { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
5425
diff
changeset
|
154 CiTargetMethod targetMethod = runtime.compile(method, graph); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
5425
diff
changeset
|
155 return addMethod(method, targetMethod); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
5425
diff
changeset
|
156 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
5425
diff
changeset
|
157 }); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
5425
diff
changeset
|
158 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
5425
diff
changeset
|
159 |
5360
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
160 protected RiCompiledMethod addMethod(final RiResolvedMethod method, final CiTargetMethod tm) { |
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
161 Debug.scope("CodeInstall", new Object[] {graalCompiler, method}, new Callable<RiCompiledMethod>() { |
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
162 @Override |
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
163 public RiCompiledMethod call() throws Exception { |
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
164 final RiCodeInfo[] info = Debug.isDumpEnabled() ? new RiCodeInfo[1] : null; |
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
165 RiCompiledMethod installedMethod = runtime.addMethod(method, tm, info); |
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
166 if (info != null) { |
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
167 Debug.dump(info[0], "After code installation"); |
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
168 } |
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
169 return installedMethod; |
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
170 } |
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
171 }); |
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
172 return runtime.addMethod(method, tm, null); |
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
173 } |
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
174 |
4340
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
175 /** |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
176 * Parses a Java method to produce a graph. |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
177 * |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
178 * @param methodName the name of the method in {@code this.getClass()} to be parsed |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
179 */ |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
180 protected StructuredGraph parseProfiled(String methodName) { |
4993
897b7d18bebc
added RiCompiledMethod.execute and the required VM infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
4410
diff
changeset
|
181 return parseProfiled(getMethod(methodName)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
182 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
183 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
184 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
185 * Parses a Java method to produce a graph. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
186 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
187 protected StructuredGraph parse(Method m) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
188 RiResolvedMethod riMethod = runtime.getRiMethod(m); |
4203
847e9dcb4980
Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4200
diff
changeset
|
189 StructuredGraph graph = new StructuredGraph(riMethod); |
5122
9b940aff6c6b
fixed failing testcases
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5118
diff
changeset
|
190 new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getSnippetDefault(), OptimisticOptimizations.ALL).apply(graph); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
191 return graph; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
192 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
193 |
4340
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
194 /** |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
195 * Parses a Java method to produce a graph. |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
196 */ |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
197 protected StructuredGraph parseProfiled(Method m) { |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
198 RiResolvedMethod riMethod = runtime.getRiMethod(m); |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
199 StructuredGraph graph = new StructuredGraph(riMethod); |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5109
diff
changeset
|
200 new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL).apply(graph); |
4340
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
201 return graph; |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
202 } |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
203 |
4204
4df4499e0289
Fixed unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4203
diff
changeset
|
204 protected PhasePlan getDefaultPhasePlan() { |
4df4499e0289
Fixed unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4203
diff
changeset
|
205 PhasePlan plan = new PhasePlan(); |
5122
9b940aff6c6b
fixed failing testcases
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5118
diff
changeset
|
206 plan.addPhase(PhasePosition.AFTER_PARSING, new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getSnippetDefault(), OptimisticOptimizations.ALL)); |
4204
4df4499e0289
Fixed unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4203
diff
changeset
|
207 return plan; |
4df4499e0289
Fixed unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4203
diff
changeset
|
208 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
209 } |