annotate graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java @ 19232:66c60942c06c

GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
author Josef Eisl <josef.eisl@jku.at>
date Tue, 10 Feb 2015 11:09:28 +0100
parents 41af11212ed3
children 9f411d79ffc0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
19045
862997951c0a Add GraalDirectives API to influence compiler behavior.
Roland Schatz <roland.schatz@oracle.com>
parents: 18969
diff changeset
2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
3733
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 */
6334
f8ba3bb81f6f Renamed com.oracle.graal.tests project to com.oracle.graal.compiler.test
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6329
diff changeset
23 package com.oracle.graal.compiler.test;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
9612
66db0353f55a compilation is explicitly given a CallingConvention for the graph being compiled instead of deriving it from a method
Doug Simon <doug.simon@oracle.com>
parents: 9042
diff changeset
25 import static com.oracle.graal.api.code.CodeUtil.*;
13239
Doug Simon <doug.simon@oracle.com>
parents: 13233
diff changeset
26 import static com.oracle.graal.compiler.GraalCompiler.*;
15259
d90e5c22ba55 Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15193
diff changeset
27 import static com.oracle.graal.compiler.common.GraalOptions.*;
12573
6332050441eb fixed tests that need to take into account ConstantNodes not recording their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12488
diff changeset
28 import static com.oracle.graal.nodes.ConstantNode.*;
9612
66db0353f55a compilation is explicitly given a CallingConvention for the graph being compiled instead of deriving it from a method
Doug Simon <doug.simon@oracle.com>
parents: 9042
diff changeset
29
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30 import java.lang.reflect.*;
5650
8d420cfd2a6f added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents: 5599
diff changeset
31 import java.util.*;
11740
a402610bc52b made compilation ID allocation in tests be atomic
Doug Simon <doug.simon@oracle.com>
parents: 11738
diff changeset
32 import java.util.concurrent.atomic.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33
7260
169bbc849ee9 moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents: 7154
diff changeset
34 import org.junit.*;
10885
3f43462ce829 Work around missing support for boolean[] in junit.
Roland Schatz <roland.schatz@oracle.com>
parents: 10764
diff changeset
35 import org.junit.internal.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36
5510
426c605c9d3c Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
37 import com.oracle.graal.api.code.*;
9612
66db0353f55a compilation is explicitly given a CallingConvention for the graph being compiled instead of deriving it from a method
Doug Simon <doug.simon@oracle.com>
parents: 9042
diff changeset
38 import com.oracle.graal.api.code.CallingConvention.Type;
19045
862997951c0a Add GraalDirectives API to influence compiler behavior.
Roland Schatz <roland.schatz@oracle.com>
parents: 18969
diff changeset
39 import com.oracle.graal.api.directives.*;
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5499
diff changeset
40 import com.oracle.graal.api.meta.*;
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14919
diff changeset
41 import com.oracle.graal.api.replacements.*;
6540
31aa76ffd3bb Rename project graal.api to graal.api.runtime
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6539
diff changeset
42 import com.oracle.graal.api.runtime.*;
14066
56726a90dc71 First draft of baseline compiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14056
diff changeset
43 import com.oracle.graal.baseline.*;
18127
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
44 import com.oracle.graal.compiler.*;
18305
da76d42c397e preliminary code for managing and testing replay/remote compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
45 import com.oracle.graal.compiler.GraalCompiler.Request;
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 15188
diff changeset
46 import com.oracle.graal.compiler.common.*;
7836
a202f72872a4 Remove usage of left-over fields in GraalCompiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7835
diff changeset
47 import com.oracle.graal.compiler.target.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
48 import com.oracle.graal.debug.*;
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
49 import com.oracle.graal.debug.Debug.Scope;
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
50 import com.oracle.graal.graph.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
51 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
52 import com.oracle.graal.lir.asm.*;
19232
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 19140
diff changeset
53 import com.oracle.graal.lir.phases.*;
16841
cbd42807a31f moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents: 16714
diff changeset
54 import com.oracle.graal.nodeinfo.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
55 import com.oracle.graal.nodes.*;
6529
2e96dc4eb8e2 renamed package: com.oracle.graal.lir.cfg -> com.oracle.graal.nodes.cfg
Doug Simon <doug.simon@oracle.com>
parents: 6526
diff changeset
56 import com.oracle.graal.nodes.cfg.*;
5720
46ad94a0574a moved everything from com.oracle.graal.nodes.cri into com.oracle.graal.nodes.spi
Doug Simon <doug.simon@oracle.com>
parents: 5719
diff changeset
57 import com.oracle.graal.nodes.spi.*;
8921
ea867ede377f allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents: 8598
diff changeset
58 import com.oracle.graal.nodes.virtual.*;
6525
2c913b643422 rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents: 6447
diff changeset
59 import com.oracle.graal.phases.*;
15990
ba0e3c75bd49 add ComputeLoopFrequenciesPhase after canonicalizer
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15950
diff changeset
60 import com.oracle.graal.phases.common.*;
6525
2c913b643422 rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents: 6447
diff changeset
61 import com.oracle.graal.phases.schedule.*;
9968
3df534c97af1 Create Suites instance in runtime.
Roland Schatz <roland.schatz@oracle.com>
parents: 9864
diff changeset
62 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
63 import com.oracle.graal.phases.util.*;
7318
323ece2b012b Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7282
diff changeset
64 import com.oracle.graal.printer.*;
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: 12456
diff changeset
65 import com.oracle.graal.runtime.*;
7717
cf94bd18eb47 lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents: 7530
diff changeset
66 import com.oracle.graal.test.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68 /**
6578
1112609bb5dc updated javadoc
Doug Simon <doug.simon@oracle.com>
parents: 6543
diff changeset
69 * Base class for Graal compiler unit tests.
1112609bb5dc updated javadoc
Doug Simon <doug.simon@oracle.com>
parents: 6543
diff changeset
70 * <p>
1112609bb5dc updated javadoc
Doug Simon <doug.simon@oracle.com>
parents: 6543
diff changeset
71 * White box tests for Graal compiler transformations use this pattern:
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
72 * <ol>
16714
1668de777c42 renamed GraalCompilerTest.parse to GraalCompilerTest.parseEager and improved javadoc for all parse* methods
Doug Simon <doug.simon@oracle.com>
parents: 16713
diff changeset
73 * <li>Create a graph by {@linkplain #parseEager(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
74 * <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
75 * <li>Apply a transformation to the graph.</li>
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
76 * <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
77 * </ol>
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
78 * <p>
6578
1112609bb5dc updated javadoc
Doug Simon <doug.simon@oracle.com>
parents: 6543
diff changeset
79 * See {@link InvokeHintsTest} as an example of a white box test.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
80 * <p>
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7321
diff changeset
81 * Black box tests use the {@link #test(String, Object...)} or
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7321
diff changeset
82 * {@link #testN(int, String, Object...)} to execute some method in the interpreter and compare its
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7321
diff changeset
83 * result against that produced by a Graal compiled version of the method.
6578
1112609bb5dc updated javadoc
Doug Simon <doug.simon@oracle.com>
parents: 6543
diff changeset
84 * <p>
1112609bb5dc updated javadoc
Doug Simon <doug.simon@oracle.com>
parents: 6543
diff changeset
85 * These tests will be run by the {@code mx unittest} command.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
86 */
7717
cf94bd18eb47 lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents: 7530
diff changeset
87 public abstract class GraalCompilerTest extends GraalTest {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
88
12362
f53dc8bbb88c refactored isReexecutable(), getKilledLocations() and canDeoptimize() out of MetaAccessProvider into ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12054
diff changeset
89 private final Providers providers;
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
90 private final Backend backend;
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
91 private final Suites suites;
19232
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 19140
diff changeset
92 private final LowLevelSuites lowLevelSuites;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
93
15950
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
94 /**
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
95 * Can be overridden by unit tests to verify properties of the graph.
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
96 *
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
97 * @param graph the graph at the end of HighTier
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
98 */
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
99 protected boolean checkHighTierGraph(StructuredGraph graph) {
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
100 return true;
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
101 }
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
102
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
103 /**
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
104 * Can be overridden by unit tests to verify properties of the graph.
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
105 *
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
106 * @param graph the graph at the end of MidTier
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
107 */
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
108 protected boolean checkMidTierGraph(StructuredGraph graph) {
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
109 return true;
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
110 }
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
111
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
112 /**
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
113 * Can be overridden by unit tests to verify properties of the graph.
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
114 *
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
115 * @param graph the graph at the end of LowTier
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
116 */
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
117 protected boolean checkLowTierGraph(StructuredGraph graph) {
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
118 return true;
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
119 }
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
120
14014
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
121 private static boolean substitutionsInstalled;
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
122
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
123 private void installSubstitutions() {
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
124 if (!substitutionsInstalled) {
17605
cdd0b5d3d9bf Substitution method for inserting a native breakpoint into a unit test.
Roland Schatz <roland.schatz@oracle.com>
parents: 17211
diff changeset
125 this.providers.getReplacements().registerSubstitutions(GraalCompilerTest.class, GraalCompilerTestSubstitutions.class);
14014
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
126 substitutionsInstalled = true;
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
127 }
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
128 }
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
129
17605
cdd0b5d3d9bf Substitution method for inserting a native breakpoint into a unit test.
Roland Schatz <roland.schatz@oracle.com>
parents: 17211
diff changeset
130 protected static void breakpoint() {
cdd0b5d3d9bf Substitution method for inserting a native breakpoint into a unit test.
Roland Schatz <roland.schatz@oracle.com>
parents: 17211
diff changeset
131 }
cdd0b5d3d9bf Substitution method for inserting a native breakpoint into a unit test.
Roland Schatz <roland.schatz@oracle.com>
parents: 17211
diff changeset
132
15949
4243a6b8dd19 Fix insertion of profile data in unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15942
diff changeset
133 protected Suites createSuites() {
4243a6b8dd19 Fix insertion of profile data in unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15942
diff changeset
134 Suites ret = backend.getSuites().createSuites();
17205
873f082901c8 unittest: fix NPE if inlining is disabled
Bernhard Urban <bernhard.urban@jku.at>
parents: 17064
diff changeset
135 ListIterator<BasePhase<? super HighTierContext>> iter = ret.getHighTier().findPhase(CleanTypeProfileProxyPhase.class);
15990
ba0e3c75bd49 add ComputeLoopFrequenciesPhase after canonicalizer
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15950
diff changeset
136 PhaseSuite.findNextPhase(iter, CanonicalizerPhase.class);
ba0e3c75bd49 add ComputeLoopFrequenciesPhase after canonicalizer
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15950
diff changeset
137 iter.add(new Phase("ComputeLoopFrequenciesPhase") {
15949
4243a6b8dd19 Fix insertion of profile data in unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15942
diff changeset
138
4243a6b8dd19 Fix insertion of profile data in unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15942
diff changeset
139 @Override
4243a6b8dd19 Fix insertion of profile data in unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15942
diff changeset
140 protected void run(StructuredGraph graph) {
4243a6b8dd19 Fix insertion of profile data in unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15942
diff changeset
141 ComputeLoopFrequenciesClosure.compute(graph);
4243a6b8dd19 Fix insertion of profile data in unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15942
diff changeset
142 }
4243a6b8dd19 Fix insertion of profile data in unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15942
diff changeset
143 });
15950
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
144 ret.getHighTier().appendPhase(new Phase("CheckGraphPhase") {
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
145
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
146 @Override
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
147 protected void run(StructuredGraph graph) {
18946
4ac00633d83c Add some assertion messages
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18937
diff changeset
148 assert checkHighTierGraph(graph) : "failed HighTier graph check";
15950
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
149 }
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
150 });
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
151 ret.getMidTier().appendPhase(new Phase("CheckGraphPhase") {
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
152
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
153 @Override
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
154 protected void run(StructuredGraph graph) {
18946
4ac00633d83c Add some assertion messages
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18937
diff changeset
155 assert checkMidTierGraph(graph) : "failed MidTier graph check";
15950
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
156 }
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
157 });
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
158 ret.getLowTier().appendPhase(new Phase("CheckGraphPhase") {
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
159
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
160 @Override
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
161 protected void run(StructuredGraph graph) {
18946
4ac00633d83c Add some assertion messages
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18937
diff changeset
162 assert checkLowTierGraph(graph) : "failed LowTier graph check";
15950
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
163 }
e4567f9acc42 Interface to do graph verification after High/Mid/LowTier in unittests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15949
diff changeset
164 });
15949
4243a6b8dd19 Fix insertion of profile data in unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15942
diff changeset
165 return ret;
4243a6b8dd19 Fix insertion of profile data in unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15942
diff changeset
166 }
4243a6b8dd19 Fix insertion of profile data in unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15942
diff changeset
167
19232
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 19140
diff changeset
168 protected LowLevelSuites createLowLevelSuites() {
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 19140
diff changeset
169 LowLevelSuites ret = backend.getSuites().createLowLevelSuites();
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 19140
diff changeset
170 return ret;
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 19140
diff changeset
171 }
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 19140
diff changeset
172
5565
0083a59ced84 Renaming GraphTest => GraalCompilerTest.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5546
diff changeset
173 public GraalCompilerTest() {
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: 12456
diff changeset
174 this.backend = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend();
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
175 this.providers = getBackend().getProviders();
15949
4243a6b8dd19 Fix insertion of profile data in unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15942
diff changeset
176 this.suites = createSuites();
19232
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 19140
diff changeset
177 this.lowLevelSuites = createLowLevelSuites();
14014
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
178 installSubstitutions();
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
179 }
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
180
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
181 /**
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
182 * Set up a test for a non-default backend. The test should check (via {@link #getBackend()} )
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
183 * whether the desired backend is available.
14919
bd08e610e6f3 BaselineCompiler: create BytecodeParser.
Josef Eisl <josef.eisl@jku.at>
parents: 14890
diff changeset
184 *
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
185 * @param arch the name of the desired backend architecture
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
186 */
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: 12456
diff changeset
187 public GraalCompilerTest(Class<? extends Architecture> arch) {
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: 12456
diff changeset
188 RuntimeProvider runtime = Graal.getRequiredCapability(RuntimeProvider.class);
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: 12456
diff changeset
189 Backend b = runtime.getBackend(arch);
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
190 if (b != null) {
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
191 this.backend = b;
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
192 } else {
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
193 // Fall back to the default/host backend
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: 12456
diff changeset
194 this.backend = runtime.getHostBackend();
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
195 }
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
196 this.providers = backend.getProviders();
15949
4243a6b8dd19 Fix insertion of profile data in unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 15942
diff changeset
197 this.suites = createSuites();
19232
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 19140
diff changeset
198 this.lowLevelSuites = createLowLevelSuites();
14014
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
199 installSubstitutions();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
200 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
201
8598
5a3703970e3f share debug environment across multiple tests
Doug Simon <doug.simon@oracle.com>
parents: 8349
diff changeset
202 @BeforeClass
11560
1aa56a2fb08b fix spelling error
Doug Simon <doug.simon@oracle.com>
parents: 11405
diff changeset
203 public static void initializeDebugging() {
8598
5a3703970e3f share debug environment across multiple tests
Doug Simon <doug.simon@oracle.com>
parents: 8349
diff changeset
204 DebugEnvironment.initialize(System.out);
5a3703970e3f share debug environment across multiple tests
Doug Simon <doug.simon@oracle.com>
parents: 8349
diff changeset
205 }
5a3703970e3f share debug environment across multiple tests
Doug Simon <doug.simon@oracle.com>
parents: 8349
diff changeset
206
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
207 private Scope debugScope;
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
208
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
209 @Before
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
210 public void beforeTest() {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
211 assert debugScope == null;
14620
a0baf4eeb018 removed allocation for name of debug scope
Doug Simon <doug.simon@oracle.com>
parents: 14573
diff changeset
212 debugScope = Debug.scope(getClass());
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
213 }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
214
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
215 @After
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
216 public void afterTest() {
13579
be2b096a5f69 GraalCompilerTest: fix NPE when debugging is not enabled.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13239
diff changeset
217 if (debugScope != null) {
13580
8958eb3ff6b9 GraalCompilerTest: add messages to exception comparison asserts to make JUnit output clearer
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13579
diff changeset
218 debugScope.close();
13579
be2b096a5f69 GraalCompilerTest: fix NPE when debugging is not enabled.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13239
diff changeset
219 }
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
220 debugScope = null;
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
221 }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
222
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
223 protected void assertEquals(StructuredGraph expected, StructuredGraph graph) {
14890
8ebeb60167ee compare constants in graphs in GraalCompilerTest.assertEquals
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
224 assertEquals(expected, graph, false, true);
8921
ea867ede377f allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents: 8598
diff changeset
225 }
ea867ede377f allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents: 8598
diff changeset
226
12573
6332050441eb fixed tests that need to take into account ConstantNodes not recording their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12488
diff changeset
227 protected int countUnusedConstants(StructuredGraph graph) {
6332050441eb fixed tests that need to take into account ConstantNodes not recording their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12488
diff changeset
228 int total = 0;
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12573
diff changeset
229 for (ConstantNode node : getConstantNodes(graph)) {
18937
ff232ff8d028 Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18800
diff changeset
230 if (node.hasNoUsages()) {
16073
b38191cd1665 removed code to make recording usages optional for ConstantNodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 15990
diff changeset
231 total++;
12573
6332050441eb fixed tests that need to take into account ConstantNodes not recording their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12488
diff changeset
232 }
6332050441eb fixed tests that need to take into account ConstantNodes not recording their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12488
diff changeset
233 }
6332050441eb fixed tests that need to take into account ConstantNodes not recording their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12488
diff changeset
234 return total;
6332050441eb fixed tests that need to take into account ConstantNodes not recording their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12488
diff changeset
235 }
6332050441eb fixed tests that need to take into account ConstantNodes not recording their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12488
diff changeset
236
6332050441eb fixed tests that need to take into account ConstantNodes not recording their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12488
diff changeset
237 protected int getNodeCountExcludingUnusedConstants(StructuredGraph graph) {
6332050441eb fixed tests that need to take into account ConstantNodes not recording their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12488
diff changeset
238 return graph.getNodeCount() - countUnusedConstants(graph);
6332050441eb fixed tests that need to take into account ConstantNodes not recording their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12488
diff changeset
239 }
6332050441eb fixed tests that need to take into account ConstantNodes not recording their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12488
diff changeset
240
14890
8ebeb60167ee compare constants in graphs in GraalCompilerTest.assertEquals
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
241 protected void assertEquals(StructuredGraph expected, StructuredGraph graph, boolean excludeVirtual, boolean checkConstants) {
8ebeb60167ee compare constants in graphs in GraalCompilerTest.assertEquals
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
242 String expectedString = getCanonicalGraphString(expected, excludeVirtual, checkConstants);
8ebeb60167ee compare constants in graphs in GraalCompilerTest.assertEquals
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
243 String actualString = getCanonicalGraphString(graph, excludeVirtual, checkConstants);
18800
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
244 String mismatchString = compareGraphStrings(expected, expectedString, graph, actualString);
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
245
12573
6332050441eb fixed tests that need to take into account ConstantNodes not recording their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12488
diff changeset
246 if (!excludeVirtual && getNodeCountExcludingUnusedConstants(expected) != getNodeCountExcludingUnusedConstants(graph)) {
4363
7462c3600c3a Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4265
diff changeset
247 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
248 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
249 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
250 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
251 if (!expectedString.equals(actualString)) {
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
252 Debug.dump(expected, "mismatching graphs - expected");
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
253 Debug.dump(graph, "mismatching graphs - actual");
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
254 Assert.fail(mismatchString);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
255 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
256 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
257
18800
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
258 private static String compareGraphStrings(StructuredGraph expectedGraph, String expectedString, StructuredGraph actualGraph, String actualString) {
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
259 if (!expectedString.equals(actualString)) {
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
260 String[] expectedLines = expectedString.split("\n");
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
261 String[] actualLines = actualString.split("\n");
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
262 int diffIndex = -1;
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
263 int limit = Math.min(actualLines.length, expectedLines.length);
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
264 String marker = " <<<";
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
265 for (int i = 0; i < limit; i++) {
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
266 if (!expectedLines[i].equals(actualLines[i])) {
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
267 diffIndex = i;
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
268 break;
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
269 }
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
270 }
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
271 if (diffIndex == -1) {
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
272 // Prefix is the same so add some space after the prefix
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
273 diffIndex = limit;
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
274 if (actualLines.length == limit) {
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
275 actualLines = Arrays.copyOf(actualLines, limit + 1);
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
276 actualLines[diffIndex] = "";
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
277 } else {
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
278 assert expectedLines.length == limit;
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
279 expectedLines = Arrays.copyOf(expectedLines, limit + 1);
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
280 expectedLines[diffIndex] = "";
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
281 }
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
282 }
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
283 // Place a marker next to the first line that differs
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
284 expectedLines[diffIndex] = expectedLines[diffIndex] + marker;
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
285 actualLines[diffIndex] = actualLines[diffIndex] + marker;
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
286 String ediff = String.join("\n", expectedLines);
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
287 String adiff = String.join("\n", actualLines);
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
288 return "mismatch in graphs:\n========= expected (" + expectedGraph + ") =========\n" + ediff + "\n\n========= actual (" + actualGraph + ") =========\n" + adiff;
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
289 } else {
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
290 return "mismatch in graphs";
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
291 }
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
292 }
650934ca7157 Mark the first difference when comparing graph strings
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18659
diff changeset
293
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents: 5650
diff changeset
294 protected void assertConstantReturn(StructuredGraph graph, int value) {
14890
8ebeb60167ee compare constants in graphs in GraalCompilerTest.assertEquals
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
295 String graphString = getCanonicalGraphString(graph, false, true);
13690
08f58bfde0dd add IterableNodeType to ReturnNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 13669
diff changeset
296 Assert.assertEquals("unexpected number of ReturnNodes: " + graphString, graph.getNodes(ReturnNode.class).count(), 1);
08f58bfde0dd add IterableNodeType to ReturnNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 13669
diff changeset
297 ValueNode result = graph.getNodes(ReturnNode.class).first().result();
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents: 5650
diff changeset
298 Assert.assertTrue("unexpected ReturnNode result node: " + graphString, result.isConstant());
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18127
diff changeset
299 Assert.assertEquals("unexpected ReturnNode result kind: " + graphString, result.asJavaConstant().getKind(), Kind.Int);
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18127
diff changeset
300 Assert.assertEquals("unexpected ReturnNode result: " + graphString, result.asJavaConstant().asInt(), value);
5657
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents: 5650
diff changeset
301 }
d71eb56d6bb0 new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents: 5650
diff changeset
302
14890
8ebeb60167ee compare constants in graphs in GraalCompilerTest.assertEquals
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
303 protected static String getCanonicalGraphString(StructuredGraph graph, boolean excludeVirtual, boolean checkConstants) {
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
304 SchedulePhase schedule = new SchedulePhase();
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
305 schedule.apply(graph);
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
306
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
307 NodeMap<Integer> canonicalId = graph.createNodeMap();
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
308 int nextId = 0;
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
309
19139
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
310 List<String> constantsLines = new ArrayList<>();
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
311
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
312 StringBuilder result = new StringBuilder();
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
313 for (Block block : schedule.getCFG().getBlocks()) {
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
314 result.append("Block " + block + " ");
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
315 if (block == schedule.getCFG().getStartBlock()) {
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
316 result.append("* ");
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
317 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
318 result.append("-> ");
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
319 for (Block succ : block.getSuccessors()) {
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
320 result.append(succ + " ");
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
321 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
322 result.append("\n");
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
323 for (Node node : schedule.getBlockToNodesMap().get(block)) {
17064
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
324 if (node.isAlive()) {
12573
6332050441eb fixed tests that need to take into account ConstantNodes not recording their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12488
diff changeset
325 if (!excludeVirtual || !(node instanceof VirtualObjectNode || node instanceof ProxyNode)) {
19139
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
326 if (node instanceof ConstantNode) {
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
327 String name = checkConstants ? node.toString(Verbosity.Name) : node.getClass().getSimpleName();
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
328 String str = name + (excludeVirtual ? "\n" : " (" + node.getUsageCount() + ")\n");
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
329 constantsLines.add(str);
12573
6332050441eb fixed tests that need to take into account ConstantNodes not recording their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12488
diff changeset
330 } else {
19139
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
331 int id;
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
332 if (canonicalId.get(node) != null) {
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
333 id = canonicalId.get(node);
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
334 } else {
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
335 id = nextId++;
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
336 canonicalId.set(node, id);
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
337 }
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
338 String name = node.getClass().getSimpleName();
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
339 String str = " " + id + "|" + name + (excludeVirtual ? "\n" : " (" + node.getUsageCount() + ")\n");
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
340 result.append(str);
12573
6332050441eb fixed tests that need to take into account ConstantNodes not recording their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12488
diff changeset
341 }
8921
ea867ede377f allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents: 8598
diff changeset
342 }
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
343 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
344 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
345 }
19139
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
346
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
347 StringBuilder constantsLinesResult = new StringBuilder();
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
348 constantsLinesResult.append(constantsLines.size() + " constants:\n");
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
349 Collections.sort(constantsLines);
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
350 for (String s : constantsLines) {
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
351 constantsLinesResult.append(s);
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
352 constantsLinesResult.append("\n");
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
353 }
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
354
a884856ac5d0 Make graph equality comparison for testing purposes more robust, by sorting constants lexically.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19125
diff changeset
355 return constantsLines.toString() + result.toString();
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
356 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5360
diff changeset
357
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
358 protected Backend getBackend() {
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
359 return backend;
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
360 }
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
361
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
362 protected Suites getSuites() {
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
363 return suites;
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
364 }
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
365
19232
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 19140
diff changeset
366 protected LowLevelSuites getLowLevelSuites() {
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 19140
diff changeset
367 return lowLevelSuites;
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 19140
diff changeset
368 }
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 19140
diff changeset
369
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
370 protected Providers getProviders() {
12362
f53dc8bbb88c refactored isReexecutable(), getKilledLocations() and canDeoptimize() out of MetaAccessProvider into ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12054
diff changeset
371 return providers;
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
372 }
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
373
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14919
diff changeset
374 protected SnippetReflectionProvider getSnippetReflection() {
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14919
diff changeset
375 return Graal.getRequiredCapability(SnippetReflectionProvider.class);
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14919
diff changeset
376 }
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14919
diff changeset
377
13132
922dd1415c0a Commit pass target as a parameter to ReplacementImpl, so that it does not require a CodeCacheProvider
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
378 protected TargetDescription getTarget() {
922dd1415c0a Commit pass target as a parameter to ReplacementImpl, so that it does not require a CodeCacheProvider
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
379 return getProviders().getCodeCache().getTarget();
922dd1415c0a Commit pass target as a parameter to ReplacementImpl, so that it does not require a CodeCacheProvider
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
380 }
922dd1415c0a Commit pass target as a parameter to ReplacementImpl, so that it does not require a CodeCacheProvider
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12655
diff changeset
381
12045
0fc653a9e019 made GraalCodeCacheProvider independent of CodeCacheProvider and renamed the former to LoweringProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11959
diff changeset
382 protected CodeCacheProvider getCodeCache() {
12362
f53dc8bbb88c refactored isReexecutable(), getKilledLocations() and canDeoptimize() out of MetaAccessProvider into ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12054
diff changeset
383 return getProviders().getCodeCache();
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11740
diff changeset
384 }
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11740
diff changeset
385
12052
0afe7370260c refactored constantEquals(), lookupArrayLength() and readUnsafeConstant() out of MetaAccessProvider into ConstantReflectionProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12045
diff changeset
386 protected ConstantReflectionProvider getConstantReflection() {
12362
f53dc8bbb88c refactored isReexecutable(), getKilledLocations() and canDeoptimize() out of MetaAccessProvider into ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12054
diff changeset
387 return getProviders().getConstantReflection();
f53dc8bbb88c refactored isReexecutable(), getKilledLocations() and canDeoptimize() out of MetaAccessProvider into ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12054
diff changeset
388 }
f53dc8bbb88c refactored isReexecutable(), getKilledLocations() and canDeoptimize() out of MetaAccessProvider into ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12054
diff changeset
389
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11740
diff changeset
390 protected MetaAccessProvider getMetaAccess() {
12362
f53dc8bbb88c refactored isReexecutable(), getKilledLocations() and canDeoptimize() out of MetaAccessProvider into ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12054
diff changeset
391 return getProviders().getMetaAccess();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
392 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
393
12045
0fc653a9e019 made GraalCodeCacheProvider independent of CodeCacheProvider and renamed the former to LoweringProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11959
diff changeset
394 protected LoweringProvider getLowerer() {
12362
f53dc8bbb88c refactored isReexecutable(), getKilledLocations() and canDeoptimize() out of MetaAccessProvider into ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12054
diff changeset
395 return getProviders().getLowerer();
12045
0fc653a9e019 made GraalCodeCacheProvider independent of CodeCacheProvider and renamed the former to LoweringProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11959
diff changeset
396 }
0fc653a9e019 made GraalCodeCacheProvider independent of CodeCacheProvider and renamed the former to LoweringProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11959
diff changeset
397
11740
a402610bc52b made compilation ID allocation in tests be atomic
Doug Simon <doug.simon@oracle.com>
parents: 11738
diff changeset
398 private static AtomicInteger compilationId = new AtomicInteger();
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents: 5425
diff changeset
399
6370
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
400 protected void testN(int n, final String name, final Object... args) {
11738
aa10794f1574 better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents: 11660
diff changeset
401 final List<Throwable> errors = new ArrayList<>(n);
6370
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
402 Thread[] threads = new Thread[n];
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
403 for (int i = 0; i < n; i++) {
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
404 Thread t = new Thread(i + ":" + name) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7321
diff changeset
405
6370
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
406 @Override
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
407 public void run() {
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
408 try {
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
409 test(name, args);
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
410 } catch (Throwable e) {
11738
aa10794f1574 better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents: 11660
diff changeset
411 errors.add(e);
6370
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
412 }
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
413 }
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
414 };
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
415 threads[i] = t;
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
416 t.start();
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
417 }
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
418 for (int i = 0; i < n; i++) {
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
419 try {
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
420 threads[i].join();
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
421 } catch (InterruptedException e) {
11738
aa10794f1574 better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents: 11660
diff changeset
422 errors.add(e);
6370
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
423 }
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
424 }
11738
aa10794f1574 better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents: 11660
diff changeset
425 if (!errors.isEmpty()) {
aa10794f1574 better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents: 11660
diff changeset
426 throw new MultiCauseAssertionError(errors.size() + " failures", errors.toArray(new Throwable[errors.size()]));
aa10794f1574 better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents: 11660
diff changeset
427 }
6370
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
428 }
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
429
18120
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
430 protected Object referenceInvoke(ResolvedJavaMethod method, Object receiver, Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
431 return invoke(method, receiver, args);
6431
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6370
diff changeset
432 }
2e376f8ea4e2 added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents: 6370
diff changeset
433
8232
ab374f69e4e8 JTTTest gets the expeted result only once
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8217
diff changeset
434 protected static class Result {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7321
diff changeset
435
6447
d7bcbdf4749c minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
436 final Object returnValue;
d7bcbdf4749c minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
437 final Throwable exception;
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7321
diff changeset
438
6447
d7bcbdf4749c minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
439 public Result(Object returnValue, Throwable exception) {
d7bcbdf4749c minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
440 this.returnValue = returnValue;
d7bcbdf4749c minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
441 this.exception = exception;
d7bcbdf4749c minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
442 }
9682
86d24f120b78 Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents: 9621
diff changeset
443
86d24f120b78 Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents: 9621
diff changeset
444 @Override
86d24f120b78 Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents: 9621
diff changeset
445 public String toString() {
86d24f120b78 Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents: 9621
diff changeset
446 return exception == null ? returnValue == null ? "null" : returnValue.toString() : "!" + exception;
86d24f120b78 Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents: 9621
diff changeset
447 }
6447
d7bcbdf4749c minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
448 }
d7bcbdf4749c minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
449
7282
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
450 /**
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
451 * Called before a test is executed.
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
452 */
18120
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
453 protected void before(@SuppressWarnings("unused") ResolvedJavaMethod method) {
7282
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
454 }
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
455
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
456 /**
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
457 * Called after a test is executed.
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
458 */
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
459 protected void after() {
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
460 }
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
461
18120
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
462 protected Result executeExpected(ResolvedJavaMethod method, Object receiver, Object... args) {
9682
86d24f120b78 Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents: 9621
diff changeset
463 before(method);
5557
2e2a77f091f2 re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents: 5546
diff changeset
464 try {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7321
diff changeset
465 // This gives us both the expected return value as well as ensuring that the method to
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7321
diff changeset
466 // be compiled is fully resolved
6447
d7bcbdf4749c minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
467 return new Result(referenceInvoke(method, receiver, args), null);
5557
2e2a77f091f2 re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents: 5546
diff changeset
468 } catch (InvocationTargetException e) {
6447
d7bcbdf4749c minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
469 return new Result(null, e.getTargetException());
5557
2e2a77f091f2 re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents: 5546
diff changeset
470 } catch (Exception e) {
2e2a77f091f2 re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents: 5546
diff changeset
471 throw new RuntimeException(e);
7282
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
472 } finally {
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
473 after();
5557
2e2a77f091f2 re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents: 5546
diff changeset
474 }
6447
d7bcbdf4749c minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
475 }
6370
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
476
18120
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
477 protected Result executeActual(ResolvedJavaMethod method, Object receiver, Object... args) {
9682
86d24f120b78 Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents: 9621
diff changeset
478 before(method);
7282
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
479 Object[] executeArgs = argsWithReceiver(receiver, args);
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
480
18120
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
481 checkArgs(method, executeArgs);
8233
9484e7602276 GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8232
diff changeset
482
14053
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
483 InstalledCode compiledMethod = null;
14066
56726a90dc71 First draft of baseline compiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14056
diff changeset
484 if (UseBaselineCompiler.getValue()) {
18120
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
485 compiledMethod = getCodeBaseline(method);
14053
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
486 } else {
18127
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
487 compiledMethod = getCode(method);
14053
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
488 }
7282
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
489 try {
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
490 return new Result(compiledMethod.executeVarargs(executeArgs), null);
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
491 } catch (Throwable e) {
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
492 return new Result(null, e);
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
493 } finally {
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
494 after();
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
495 }
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
496 }
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
497
18120
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
498 protected InstalledCode getCodeBaseline(ResolvedJavaMethod javaMethod) {
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
499 return getCodeBaseline(javaMethod, false);
14053
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
500 }
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
501
18120
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
502 protected InstalledCode getCodeBaseline(ResolvedJavaMethod javaMethod, boolean forceCompile) {
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
503 assert javaMethod.getAnnotation(Test.class) == null : "shouldn't parse method with @Test annotation: " + javaMethod;
14053
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
504
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
505 try (Scope bds = Debug.scope("Baseline")) {
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
506 Debug.log("getCodeBaseline()");
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
507 } catch (Throwable e) {
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
508 throw Debug.handle(e);
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
509 }
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
510
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
511 if (!forceCompile) {
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
512 InstalledCode cached = cache.get(javaMethod);
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
513 if (cached != null) {
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
514 if (cached.isValid()) {
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
515 return cached;
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
516 }
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
517 }
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
518 }
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
519
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
520 final int id = compilationId.incrementAndGet();
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
521
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
522 InstalledCode installedCode = null;
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
523 try (Scope ds = Debug.scope("Compiling", new DebugDumpScope(String.valueOf(id), true))) {
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
524 final boolean printCompilation = PrintCompilation.getValue() && !TTY.isSuppressed();
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
525
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
526 if (printCompilation) {
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
527 TTY.println(String.format("@%-6d Graal %-70s %-45s %-50s ...", id, javaMethod.getDeclaringClass().getName(), javaMethod.getName(), javaMethod.getSignature()));
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
528 }
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
529 long start = System.currentTimeMillis();
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
530
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
531 CompilationResult compResult = compileBaseline(javaMethod);
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
532
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
533 if (printCompilation) {
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
534 TTY.println(String.format("@%-6d Graal %-70s %-45s %-50s | %4dms %5dB", id, "", "", "", System.currentTimeMillis() - start, compResult.getTargetCodeSize()));
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
535 }
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
536
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
537 try (Scope s = Debug.scope("CodeInstall", getCodeCache(), javaMethod)) {
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
538 installedCode = addMethod(javaMethod, compResult);
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
539 if (installedCode == null) {
16480
10c12d09a8d2 moved format(String format, JavaMethod method) from MetaUtil to be a default method in JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 16199
diff changeset
540 throw new GraalInternalError("Could not install code for " + javaMethod.format("%H.%n(%p)"));
14053
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
541 }
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
542 } catch (Throwable e) {
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
543 throw Debug.handle(e);
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
544 }
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
545 } catch (Throwable e) {
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
546 throw Debug.handle(e);
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
547 }
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
548
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
549 if (!forceCompile) {
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
550 cache.put(javaMethod, installedCode);
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
551 }
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
552 return installedCode;
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
553 }
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
554
14055
89bbedfe0ad3 Direct LIR generation: refactoring alternative compilation path in GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14054
diff changeset
555 private CompilationResult compileBaseline(ResolvedJavaMethod javaMethod) {
14826
Josef Eisl <josef.eisl@jku.at>
parents: 14824 14622
diff changeset
556 try (Scope bds = Debug.scope("CompileBaseline", javaMethod, providers.getCodeCache())) {
14127
452bb6e73298 BaselineCompiler: fix typo.
Josef Eisl <josef.eisl@jku.at>
parents: 14067
diff changeset
557 BaselineCompiler baselineCompiler = new BaselineCompiler(GraphBuilderConfiguration.getDefault(), providers.getMetaAccess());
14919
bd08e610e6f3 BaselineCompiler: create BytecodeParser.
Josef Eisl <josef.eisl@jku.at>
parents: 14890
diff changeset
558 OptimisticOptimizations optimisticOpts = OptimisticOptimizations.ALL;
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 19047
diff changeset
559 return baselineCompiler.generate(javaMethod, -1, getBackend(), new CompilationResult(), javaMethod, CompilationResultBuilderFactory.Default, optimisticOpts, getReplacements());
14053
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
560 } catch (Throwable e) {
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
561 throw Debug.handle(e);
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
562 }
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
563 }
a7f26a522439 Direct LIR generation: added alternative compilation path to GraalCompilerTest.
Josef Eisl <josef.eisl@jku.at>
parents: 14014
diff changeset
564
8233
9484e7602276 GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8232
diff changeset
565 protected void checkArgs(ResolvedJavaMethod method, Object[] args) {
16486
d3fc4779fc60 moved signatureToTypes(ResolvedJavaMethod method) from MetaUtil to be a default method in ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
566 JavaType[] sig = method.toParameterTypes();
8233
9484e7602276 GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8232
diff changeset
567 Assert.assertEquals(sig.length, args.length);
9484e7602276 GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8232
diff changeset
568 for (int i = 0; i < args.length; i++) {
9484e7602276 GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8232
diff changeset
569 JavaType javaType = sig[i];
9484e7602276 GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8232
diff changeset
570 Kind kind = javaType.getKind();
9484e7602276 GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8232
diff changeset
571 Object arg = args[i];
9484e7602276 GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8232
diff changeset
572 if (kind == Kind.Object) {
9484e7602276 GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8232
diff changeset
573 if (arg != null && javaType instanceof ResolvedJavaType) {
9484e7602276 GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8232
diff changeset
574 ResolvedJavaType resolvedJavaType = (ResolvedJavaType) javaType;
12362
f53dc8bbb88c refactored isReexecutable(), getKilledLocations() and canDeoptimize() out of MetaAccessProvider into ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12054
diff changeset
575 Assert.assertTrue(resolvedJavaType + " from " + getMetaAccess().lookupJavaType(arg.getClass()), resolvedJavaType.isAssignableFrom(getMetaAccess().lookupJavaType(arg.getClass())));
8233
9484e7602276 GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8232
diff changeset
576 }
9484e7602276 GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8232
diff changeset
577 } else {
9484e7602276 GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8232
diff changeset
578 Assert.assertNotNull(arg);
9484e7602276 GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8232
diff changeset
579 Assert.assertEquals(kind.toBoxedJavaClass(), arg.getClass());
9484e7602276 GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8232
diff changeset
580 }
9484e7602276 GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8232
diff changeset
581 }
9484e7602276 GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8232
diff changeset
582 }
9484e7602276 GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8232
diff changeset
583
7282
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
584 /**
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
585 * Prepends a non-null receiver argument to a given list or args.
14919
bd08e610e6f3 BaselineCompiler: create BytecodeParser.
Josef Eisl <josef.eisl@jku.at>
parents: 14890
diff changeset
586 *
7282
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
587 * @param receiver the receiver argument to prepend if it is non-null
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
588 */
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
589 protected Object[] argsWithReceiver(Object receiver, Object... args) {
6370
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
590 Object[] executeArgs;
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
591 if (receiver == null) {
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
592 executeArgs = args;
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
593 } else {
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
594 executeArgs = new Object[args.length + 1];
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
595 executeArgs[0] = receiver;
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
596 for (int i = 0; i < args.length; i++) {
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
597 executeArgs[i + 1] = args[i];
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
598 }
703a6ab8ca82 added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents: 6334
diff changeset
599 }
7282
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
600 return executeArgs;
6447
d7bcbdf4749c minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
601 }
d7bcbdf4749c minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
602
d7bcbdf4749c minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
603 protected void test(String name, Object... args) {
13647
8edc6b0779f0 suppress the exception raised by Junit's "assume" mechanism in GraalCompilerTest.test()
Doug Simon <doug.simon@oracle.com>
parents: 13622
diff changeset
604 try {
18120
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
605 ResolvedJavaMethod method = getResolvedJavaMethod(name);
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
606 Object receiver = method.isStatic() ? null : this;
13647
8edc6b0779f0 suppress the exception raised by Junit's "assume" mechanism in GraalCompilerTest.test()
Doug Simon <doug.simon@oracle.com>
parents: 13622
diff changeset
607 test(method, receiver, args);
8edc6b0779f0 suppress the exception raised by Junit's "assume" mechanism in GraalCompilerTest.test()
Doug Simon <doug.simon@oracle.com>
parents: 13622
diff changeset
608 } catch (AssumptionViolatedException e) {
8edc6b0779f0 suppress the exception raised by Junit's "assume" mechanism in GraalCompilerTest.test()
Doug Simon <doug.simon@oracle.com>
parents: 13622
diff changeset
609 // Suppress so that subsequent calls to this method within the
8edc6b0779f0 suppress the exception raised by Junit's "assume" mechanism in GraalCompilerTest.test()
Doug Simon <doug.simon@oracle.com>
parents: 13622
diff changeset
610 // same Junit @Test annotated method can proceed.
8edc6b0779f0 suppress the exception raised by Junit's "assume" mechanism in GraalCompilerTest.test()
Doug Simon <doug.simon@oracle.com>
parents: 13622
diff changeset
611 }
8232
ab374f69e4e8 JTTTest gets the expeted result only once
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8217
diff changeset
612 }
ab374f69e4e8 JTTTest gets the expeted result only once
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8217
diff changeset
613
18120
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
614 protected void test(ResolvedJavaMethod method, Object receiver, Object... args) {
6447
d7bcbdf4749c minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
615 Result expect = executeExpected(method, receiver, args);
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11740
diff changeset
616 if (getCodeCache() == null) {
6447
d7bcbdf4749c minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
617 return;
d7bcbdf4749c minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
618 }
11405
25161615539b method rename to avoid ambiguous overloading
Doug Simon <doug.simon@oracle.com>
parents: 11316
diff changeset
619 testAgainstExpected(method, expect, receiver, args);
8232
ab374f69e4e8 JTTTest gets the expeted result only once
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8217
diff changeset
620 }
ab374f69e4e8 JTTTest gets the expeted result only once
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8217
diff changeset
621
18120
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
622 protected void testAgainstExpected(ResolvedJavaMethod method, Result expect, Object receiver, Object... args) {
11405
25161615539b method rename to avoid ambiguous overloading
Doug Simon <doug.simon@oracle.com>
parents: 11316
diff changeset
623 testAgainstExpected(method, expect, Collections.<DeoptimizationReason> emptySet(), receiver, args);
9682
86d24f120b78 Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents: 9621
diff changeset
624 }
86d24f120b78 Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents: 9621
diff changeset
625
18120
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
626 protected Result executeActualCheckDeopt(ResolvedJavaMethod method, Set<DeoptimizationReason> shouldNotDeopt, Object receiver, Object... args) {
9682
86d24f120b78 Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents: 9621
diff changeset
627 Map<DeoptimizationReason, Integer> deoptCounts = new EnumMap<>(DeoptimizationReason.class);
18120
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
628 ProfilingInfo profile = method.getProfilingInfo();
9682
86d24f120b78 Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents: 9621
diff changeset
629 for (DeoptimizationReason reason : shouldNotDeopt) {
86d24f120b78 Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents: 9621
diff changeset
630 deoptCounts.put(reason, profile.getDeoptimizationCount(reason));
86d24f120b78 Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents: 9621
diff changeset
631 }
6447
d7bcbdf4749c minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
632 Result actual = executeActual(method, receiver, args);
18120
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
633 profile = method.getProfilingInfo(); // profile can change after execution
9682
86d24f120b78 Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents: 9621
diff changeset
634 for (DeoptimizationReason reason : shouldNotDeopt) {
86d24f120b78 Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents: 9621
diff changeset
635 Assert.assertEquals((int) deoptCounts.get(reason), profile.getDeoptimizationCount(reason));
86d24f120b78 Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents: 9621
diff changeset
636 }
10030
85f926430ae6 Test deoptimization in DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 10019
diff changeset
637 return actual;
85f926430ae6 Test deoptimization in DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 10019
diff changeset
638 }
6447
d7bcbdf4749c minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
639
10030
85f926430ae6 Test deoptimization in DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 10019
diff changeset
640 protected void assertEquals(Result expect, Result actual) {
6447
d7bcbdf4749c minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
641 if (expect.exception != null) {
d7bcbdf4749c minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents: 6431
diff changeset
642 Assert.assertTrue("expected " + expect.exception, actual.exception != null);
13580
8958eb3ff6b9 GraalCompilerTest: add messages to exception comparison asserts to make JUnit output clearer
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13579
diff changeset
643 Assert.assertEquals("Exception class", expect.exception.getClass(), actual.exception.getClass());
8958eb3ff6b9 GraalCompilerTest: add messages to exception comparison asserts to make JUnit output clearer
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13579
diff changeset
644 Assert.assertEquals("Exception message", expect.exception.getMessage(), actual.exception.getMessage());
5557
2e2a77f091f2 re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents: 5546
diff changeset
645 } else {
8232
ab374f69e4e8 JTTTest gets the expeted result only once
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8217
diff changeset
646 if (actual.exception != null) {
ab374f69e4e8 JTTTest gets the expeted result only once
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8217
diff changeset
647 actual.exception.printStackTrace();
ab374f69e4e8 JTTTest gets the expeted result only once
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8217
diff changeset
648 Assert.fail("expected " + expect.returnValue + " but got an exception");
ab374f69e4e8 JTTTest gets the expeted result only once
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8217
diff changeset
649 }
15622
7b09605b29c5 renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents: 15612
diff changeset
650 assertDeepEquals(expect.returnValue, actual.returnValue);
5557
2e2a77f091f2 re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents: 5546
diff changeset
651 }
2e2a77f091f2 re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents: 5546
diff changeset
652 }
2e2a77f091f2 re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents: 5546
diff changeset
653
18120
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
654 protected void testAgainstExpected(ResolvedJavaMethod method, Result expect, Set<DeoptimizationReason> shouldNotDeopt, Object receiver, Object... args) {
10030
85f926430ae6 Test deoptimization in DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 10019
diff changeset
655 Result actual = executeActualCheckDeopt(method, shouldNotDeopt, receiver, args);
85f926430ae6 Test deoptimization in DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 10019
diff changeset
656 assertEquals(expect, actual);
85f926430ae6 Test deoptimization in DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 10019
diff changeset
657 }
85f926430ae6 Test deoptimization in DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 10019
diff changeset
658
5650
8d420cfd2a6f added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents: 5599
diff changeset
659 private Map<ResolvedJavaMethod, InstalledCode> cache = new HashMap<>();
8d420cfd2a6f added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents: 5599
diff changeset
660
8d420cfd2a6f added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents: 5599
diff changeset
661 /**
18127
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
662 * Gets installed code for a given method, compiling it first if necessary. The graph is parsed
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
663 * {@link #parseEager(ResolvedJavaMethod) eagerly}.
5650
8d420cfd2a6f added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents: 5599
diff changeset
664 */
18127
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
665 protected InstalledCode getCode(ResolvedJavaMethod method) {
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
666 return getCode(method, null);
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
667 }
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
668
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
669 /**
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
670 * Gets installed code for a given method, compiling it first if necessary.
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
671 *
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
672 * @param installedCodeOwner the method the compiled code will be associated with when installed
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
673 * @param graph the graph to be compiled. If null, a graph will be obtained from
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
674 * {@code installedCodeOwner} via {@link #parseForCompile(ResolvedJavaMethod)}.
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
675 */
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
676 protected InstalledCode getCode(ResolvedJavaMethod installedCodeOwner, StructuredGraph graph) {
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
677 return getCode(installedCodeOwner, graph, false);
5650
8d420cfd2a6f added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents: 5599
diff changeset
678 }
8d420cfd2a6f added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents: 5599
diff changeset
679
8d420cfd2a6f added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents: 5599
diff changeset
680 /**
8d420cfd2a6f added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents: 5599
diff changeset
681 * Gets installed code for a given method and graph, compiling it first if necessary.
14919
bd08e610e6f3 BaselineCompiler: create BytecodeParser.
Josef Eisl <josef.eisl@jku.at>
parents: 14890
diff changeset
682 *
18127
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
683 * @param installedCodeOwner the method the compiled code will be associated with when installed
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
684 * @param graph the graph to be compiled. If null, a graph will be obtained from
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
685 * {@code installedCodeOwner} via {@link #parseForCompile(ResolvedJavaMethod)}.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7321
diff changeset
686 * @param forceCompile specifies whether to ignore any previous code cached for the (method,
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7321
diff changeset
687 * key) pair
5650
8d420cfd2a6f added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents: 5599
diff changeset
688 */
18127
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
689 protected InstalledCode getCode(final ResolvedJavaMethod installedCodeOwner, StructuredGraph graph, boolean forceCompile) {
5650
8d420cfd2a6f added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents: 5599
diff changeset
690 if (!forceCompile) {
18127
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
691 InstalledCode cached = cache.get(installedCodeOwner);
7028
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 6676
diff changeset
692 if (cached != null) {
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 6676
diff changeset
693 if (cached.isValid()) {
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 6676
diff changeset
694 return cached;
0353b031235a added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents: 6676
diff changeset
695 }
5650
8d420cfd2a6f added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents: 5599
diff changeset
696 }
8d420cfd2a6f added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents: 5599
diff changeset
697 }
7154
5d0bb7d52783 changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents: 7123
diff changeset
698
11740
a402610bc52b made compilation ID allocation in tests be atomic
Doug Simon <doug.simon@oracle.com>
parents: 11738
diff changeset
699 final int id = compilationId.incrementAndGet();
7154
5d0bb7d52783 changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents: 7123
diff changeset
700
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
701 InstalledCode installedCode = null;
18127
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
702 try (AllocSpy spy = AllocSpy.open(installedCodeOwner); Scope ds = Debug.scope("Compiling", new DebugDumpScope(String.valueOf(id), true))) {
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
703 final boolean printCompilation = PrintCompilation.getValue() && !TTY.isSuppressed();
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
704 if (printCompilation) {
18127
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
705 TTY.println(String.format("@%-6d Graal %-70s %-45s %-50s ...", id, installedCodeOwner.getDeclaringClass().getName(), installedCodeOwner.getName(), installedCodeOwner.getSignature()));
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
706 }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
707 long start = System.currentTimeMillis();
18127
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
708 CompilationResult compResult = compile(installedCodeOwner, graph);
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
709 if (printCompilation) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
710 TTY.println(String.format("@%-6d Graal %-70s %-45s %-50s | %4dms %5dB", id, "", "", "", System.currentTimeMillis() - start, compResult.getTargetCodeSize()));
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
711 }
9767
e415e58e0db2 changed location of debug scope so that a subclass that overrides 'addMethod' still matches -G:Dump=CodeInstall option
Doug Simon <doug.simon@oracle.com>
parents: 9682
diff changeset
712
18127
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
713 try (Scope s = Debug.scope("CodeInstall", getCodeCache(), installedCodeOwner)) {
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
714 installedCode = addMethod(installedCodeOwner, compResult);
13233
8ea51438445c consolidated logging and dumping of InstalledCode to HotSpotCodeCacheProvider
Doug Simon <doug.simon@oracle.com>
parents: 13229
diff changeset
715 if (installedCode == null) {
18127
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
716 throw new GraalInternalError("Could not install code for " + installedCodeOwner.format("%H.%n(%p)"));
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
717 }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
718 } catch (Throwable e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
719 throw Debug.handle(e);
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents: 5425
diff changeset
720 }
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
721 } catch (Throwable e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
722 throw Debug.handle(e);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13132
diff changeset
723 }
7154
5d0bb7d52783 changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents: 7123
diff changeset
724
7282
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
725 if (!forceCompile) {
18127
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
726 cache.put(installedCodeOwner, installedCode);
7282
390448a6b535 converted the JTT tests to use the GraalCompilerTest framework which offers more control over what is compiled and executed
Doug Simon <doug.simon@oracle.com>
parents: 7260
diff changeset
727 }
5650
8d420cfd2a6f added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents: 5599
diff changeset
728 return installedCode;
5433
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents: 5425
diff changeset
729 }
d7b5cc23945e refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents: 5425
diff changeset
730
18127
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
731 /**
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
732 * Used to produce a graph for a method about to be compiled by
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
733 * {@link #compile(ResolvedJavaMethod, StructuredGraph)} if the second parameter to that method
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
734 * is null.
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
735 *
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
736 * The default implementation in {@link GraalCompilerTest} is to call
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
737 * {@link #parseEager(ResolvedJavaMethod)}.
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
738 */
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
739 protected StructuredGraph parseForCompile(ResolvedJavaMethod method) {
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
740 return parseEager(method);
13773
e7c2351ed7d5 Throw-away speculation logs should not be used. Just use null instead
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13690
diff changeset
741 }
e7c2351ed7d5 Throw-away speculation logs should not be used. Just use null instead
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13690
diff changeset
742
18127
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
743 /**
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
744 * Compiles a given method.
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
745 *
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
746 * @param installedCodeOwner the method the compiled code will be associated with when installed
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
747 * @param graph the graph to be compiled for {@code installedCodeOwner}. If null, a graph will
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
748 * be obtained from {@code installedCodeOwner} via
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
749 * {@link #parseForCompile(ResolvedJavaMethod)}.
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
750 */
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
751 protected CompilationResult compile(ResolvedJavaMethod installedCodeOwner, StructuredGraph graph) {
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
752 StructuredGraph graphToCompile = graph == null ? parseForCompile(installedCodeOwner) : graph;
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
753 lastCompiledGraph = graphToCompile;
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
754 CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graphToCompile.method(), false);
19047
173bdcc85ab8 Remove unused parameter "stub" from GraalCompiler.compileGraph
Christian Wimmer <christian.wimmer@oracle.com>
parents: 19045
diff changeset
755 Request<CompilationResult> request = new Request<>(graphToCompile, cc, installedCodeOwner, getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultGraphBuilderSuite(),
19232
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 19140
diff changeset
756 OptimisticOptimizations.ALL, getProfilingInfo(graphToCompile), getSpeculationLog(), getSuites(), getLowLevelSuites(), new CompilationResult(),
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 19140
diff changeset
757 CompilationResultBuilderFactory.Default);
18659
81a26fb13a9e removed pluggable compiler support in GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents: 18654
diff changeset
758 return GraalCompiler.compile(request);
18127
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
759 }
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
760
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
761 protected StructuredGraph lastCompiledGraph;
7cefdad149ad enable a GraalCompilerTest to override how a method is parsed to produce a graph as well as being able to interpose on the method that is parsed/compiled
Doug Simon <doug.simon@oracle.com>
parents: 18120
diff changeset
762
13773
e7c2351ed7d5 Throw-away speculation logs should not be used. Just use null instead
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13690
diff changeset
763 protected SpeculationLog getSpeculationLog() {
e7c2351ed7d5 Throw-away speculation logs should not be used. Just use null instead
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13690
diff changeset
764 return null;
13622
02d3cfc90603 made GraalCompilerTest slightly more extensible
Doug Simon <doug.simon@oracle.com>
parents: 13612
diff changeset
765 }
02d3cfc90603 made GraalCompilerTest slightly more extensible
Doug Simon <doug.simon@oracle.com>
parents: 13612
diff changeset
766
10019
6e4b72bcc97f Remove graph from HotSpotNMethod
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9969
diff changeset
767 protected InstalledCode addMethod(final ResolvedJavaMethod method, final CompilationResult compResult) {
15162
dbb1fe8348e6 Allow to supply predefined installed code object when adding a method to the code cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15018
diff changeset
768 return getCodeCache().addMethod(method, compResult, null, null);
5360
6cc970203f30 moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents: 5122
diff changeset
769 }
6cc970203f30 moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents: 5122
diff changeset
770
18120
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
771 private final Map<ResolvedJavaMethod, Method> methodMap = new HashMap<>();
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
772
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
773 /**
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
774 * Converts a reflection {@link Method} to a {@link ResolvedJavaMethod}.
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
775 */
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
776 protected ResolvedJavaMethod asResolvedJavaMethod(Method method) {
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
777 ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(method);
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
778 methodMap.put(javaMethod, method);
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
779 return javaMethod;
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
780 }
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
781
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
782 protected ResolvedJavaMethod getResolvedJavaMethod(String methodName) {
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
783 return asResolvedJavaMethod(getMethod(methodName));
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
784 }
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
785
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
786 protected ResolvedJavaMethod getResolvedJavaMethod(Class<?> clazz, String methodName) {
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
787 return asResolvedJavaMethod(getMethod(clazz, methodName));
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
788 }
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
789
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
790 protected ResolvedJavaMethod getResolvedJavaMethod(Class<?> clazz, String methodName, Class<?>... parameterTypes) {
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
791 return asResolvedJavaMethod(getMethod(clazz, methodName, parameterTypes));
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
792 }
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
793
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
794 /**
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
795 * Gets the reflection {@link Method} from which a given {@link ResolvedJavaMethod} was created
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
796 * or null if {@code javaMethod} does not correspond to a reflection method.
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
797 */
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
798 protected Method lookupMethod(ResolvedJavaMethod javaMethod) {
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
799 return methodMap.get(javaMethod);
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
800 }
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
801
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
802 protected Object invoke(ResolvedJavaMethod javaMethod, Object receiver, Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
803 Method method = lookupMethod(javaMethod);
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
804 Assert.assertTrue(method != null);
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
805 if (!method.isAccessible()) {
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
806 method.setAccessible(true);
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
807 }
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
808 return method.invoke(receiver, args);
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
809 }
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
810
4340
5caca26cb1b9 small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents: 4315
diff changeset
811 /**
16714
1668de777c42 renamed GraalCompilerTest.parse to GraalCompilerTest.parseEager and improved javadoc for all parse* methods
Doug Simon <doug.simon@oracle.com>
parents: 16713
diff changeset
812 * Parses a Java method in {@linkplain GraphBuilderConfiguration#getDefault() default} mode to
1668de777c42 renamed GraalCompilerTest.parse to GraalCompilerTest.parseEager and improved javadoc for all parse* methods
Doug Simon <doug.simon@oracle.com>
parents: 16713
diff changeset
813 * produce a graph.
14919
bd08e610e6f3 BaselineCompiler: create BytecodeParser.
Josef Eisl <josef.eisl@jku.at>
parents: 14890
diff changeset
814 *
4340
5caca26cb1b9 small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents: 4315
diff changeset
815 * @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
816 */
5caca26cb1b9 small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents: 4315
diff changeset
817 protected StructuredGraph parseProfiled(String methodName) {
18120
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
818 return parseProfiled(getResolvedJavaMethod(methodName));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
819 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
820
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
821 /**
16714
1668de777c42 renamed GraalCompilerTest.parse to GraalCompilerTest.parseEager and improved javadoc for all parse* methods
Doug Simon <doug.simon@oracle.com>
parents: 16713
diff changeset
822 * Parses a Java method in {@linkplain GraphBuilderConfiguration#getDefault() default} mode to
1668de777c42 renamed GraalCompilerTest.parse to GraalCompilerTest.parseEager and improved javadoc for all parse* methods
Doug Simon <doug.simon@oracle.com>
parents: 16713
diff changeset
823 * produce a graph.
4340
5caca26cb1b9 small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents: 4315
diff changeset
824 */
18120
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
825 protected StructuredGraph parseProfiled(ResolvedJavaMethod m) {
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
826 return parse1(m, getDefaultGraphBuilderSuite());
9003
a8fea2979e63 eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents: 8637
diff changeset
827 }
a8fea2979e63 eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents: 8637
diff changeset
828
a8fea2979e63 eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents: 8637
diff changeset
829 /**
16714
1668de777c42 renamed GraalCompilerTest.parse to GraalCompilerTest.parseEager and improved javadoc for all parse* methods
Doug Simon <doug.simon@oracle.com>
parents: 16713
diff changeset
830 * Parses a Java method in {@linkplain GraphBuilderConfiguration#getEagerDefault() eager} mode
1668de777c42 renamed GraalCompilerTest.parse to GraalCompilerTest.parseEager and improved javadoc for all parse* methods
Doug Simon <doug.simon@oracle.com>
parents: 16713
diff changeset
831 * to produce a graph.
1668de777c42 renamed GraalCompilerTest.parse to GraalCompilerTest.parseEager and improved javadoc for all parse* methods
Doug Simon <doug.simon@oracle.com>
parents: 16713
diff changeset
832 *
1668de777c42 renamed GraalCompilerTest.parse to GraalCompilerTest.parseEager and improved javadoc for all parse* methods
Doug Simon <doug.simon@oracle.com>
parents: 16713
diff changeset
833 * @param methodName the name of the method in {@code this.getClass()} to be parsed
1668de777c42 renamed GraalCompilerTest.parse to GraalCompilerTest.parseEager and improved javadoc for all parse* methods
Doug Simon <doug.simon@oracle.com>
parents: 16713
diff changeset
834 */
1668de777c42 renamed GraalCompilerTest.parse to GraalCompilerTest.parseEager and improved javadoc for all parse* methods
Doug Simon <doug.simon@oracle.com>
parents: 16713
diff changeset
835 protected StructuredGraph parseEager(String methodName) {
18120
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
836 return parseEager(getResolvedJavaMethod(methodName));
16714
1668de777c42 renamed GraalCompilerTest.parse to GraalCompilerTest.parseEager and improved javadoc for all parse* methods
Doug Simon <doug.simon@oracle.com>
parents: 16713
diff changeset
837 }
1668de777c42 renamed GraalCompilerTest.parse to GraalCompilerTest.parseEager and improved javadoc for all parse* methods
Doug Simon <doug.simon@oracle.com>
parents: 16713
diff changeset
838
1668de777c42 renamed GraalCompilerTest.parse to GraalCompilerTest.parseEager and improved javadoc for all parse* methods
Doug Simon <doug.simon@oracle.com>
parents: 16713
diff changeset
839 /**
1668de777c42 renamed GraalCompilerTest.parse to GraalCompilerTest.parseEager and improved javadoc for all parse* methods
Doug Simon <doug.simon@oracle.com>
parents: 16713
diff changeset
840 * Parses a Java method in {@linkplain GraphBuilderConfiguration#getEagerDefault() eager} mode
1668de777c42 renamed GraalCompilerTest.parse to GraalCompilerTest.parseEager and improved javadoc for all parse* methods
Doug Simon <doug.simon@oracle.com>
parents: 16713
diff changeset
841 * to produce a graph.
1668de777c42 renamed GraalCompilerTest.parse to GraalCompilerTest.parseEager and improved javadoc for all parse* methods
Doug Simon <doug.simon@oracle.com>
parents: 16713
diff changeset
842 */
18120
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
843 protected StructuredGraph parseEager(ResolvedJavaMethod m) {
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
844 return parse1(m, getCustomGraphBuilderSuite(GraphBuilderConfiguration.getEagerDefault()));
16714
1668de777c42 renamed GraalCompilerTest.parse to GraalCompilerTest.parseEager and improved javadoc for all parse* methods
Doug Simon <doug.simon@oracle.com>
parents: 16713
diff changeset
845 }
1668de777c42 renamed GraalCompilerTest.parse to GraalCompilerTest.parseEager and improved javadoc for all parse* methods
Doug Simon <doug.simon@oracle.com>
parents: 16713
diff changeset
846
1668de777c42 renamed GraalCompilerTest.parse to GraalCompilerTest.parseEager and improved javadoc for all parse* methods
Doug Simon <doug.simon@oracle.com>
parents: 16713
diff changeset
847 /**
1668de777c42 renamed GraalCompilerTest.parse to GraalCompilerTest.parseEager and improved javadoc for all parse* methods
Doug Simon <doug.simon@oracle.com>
parents: 16713
diff changeset
848 * Parses a Java method in {@linkplain GraphBuilderConfiguration#getFullDebugDefault() full
1668de777c42 renamed GraalCompilerTest.parse to GraalCompilerTest.parseEager and improved javadoc for all parse* methods
Doug Simon <doug.simon@oracle.com>
parents: 16713
diff changeset
849 * debug} mode to produce a graph.
9003
a8fea2979e63 eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents: 8637
diff changeset
850 */
18120
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
851 protected StructuredGraph parseDebug(ResolvedJavaMethod m) {
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
852 return parse1(m, getCustomGraphBuilderSuite(GraphBuilderConfiguration.getFullDebugDefault()));
9003
a8fea2979e63 eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents: 8637
diff changeset
853 }
a8fea2979e63 eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents: 8637
diff changeset
854
18120
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
855 private StructuredGraph parse1(ResolvedJavaMethod javaMethod, PhaseSuite<HighTierContext> graphBuilderSuite) {
86ec7f6f71b3 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method
Doug Simon <doug.simon@oracle.com>
parents: 17605
diff changeset
856 assert javaMethod.getAnnotation(Test.class) == null : "shouldn't parse method with @Test annotation: " + javaMethod;
16713
47f9c47145fd added "Parsing" debug scope in GraalCompilerTest.parse0
Doug Simon <doug.simon@oracle.com>
parents: 16573
diff changeset
857 try (Scope ds = Debug.scope("Parsing", javaMethod)) {
47f9c47145fd added "Parsing" debug scope in GraalCompilerTest.parse0
Doug Simon <doug.simon@oracle.com>
parents: 16573
diff changeset
858 StructuredGraph graph = new StructuredGraph(javaMethod);
47f9c47145fd added "Parsing" debug scope in GraalCompilerTest.parse0
Doug Simon <doug.simon@oracle.com>
parents: 16573
diff changeset
859 graphBuilderSuite.apply(graph, new HighTierContext(providers, null, null, graphBuilderSuite, OptimisticOptimizations.ALL));
47f9c47145fd added "Parsing" debug scope in GraalCompilerTest.parse0
Doug Simon <doug.simon@oracle.com>
parents: 16573
diff changeset
860 return graph;
17211
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17205
diff changeset
861 } catch (Throwable e) {
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17205
diff changeset
862 throw Debug.handle(e);
16713
47f9c47145fd added "Parsing" debug scope in GraalCompilerTest.parse0
Doug Simon <doug.simon@oracle.com>
parents: 16573
diff changeset
863 }
4340
5caca26cb1b9 small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents: 4315
diff changeset
864 }
5caca26cb1b9 small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents: 4315
diff changeset
865
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
866 protected PhaseSuite<HighTierContext> getDefaultGraphBuilderSuite() {
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
867 // defensive copying
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
868 return backend.getSuites().getDefaultGraphBuilderSuite().copy();
9003
a8fea2979e63 eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents: 8637
diff changeset
869 }
a8fea2979e63 eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents: 8637
diff changeset
870
13612
8c019a9beb16 use graph builder suite for compiler tests
Lukas Stadler <lukas.stadler@jku.at>
parents: 13585
diff changeset
871 protected PhaseSuite<HighTierContext> getCustomGraphBuilderSuite(GraphBuilderConfiguration gbConf) {
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
872 PhaseSuite<HighTierContext> suite = getDefaultGraphBuilderSuite().copy();
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
873 ListIterator<BasePhase<? super HighTierContext>> iterator = suite.findPhase(GraphBuilderPhase.class);
19125
e4fda434ba74 copy GraphBuilderPlugins when copying a GraphBuilderPhase
Doug Simon <doug.simon@oracle.com>
parents: 19050
diff changeset
874 GraphBuilderPhase graphBuilderPhase = (GraphBuilderPhase) iterator.previous();
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
875 iterator.remove();
19125
e4fda434ba74 copy GraphBuilderPlugins when copying a GraphBuilderPhase
Doug Simon <doug.simon@oracle.com>
parents: 19050
diff changeset
876 iterator.add(new GraphBuilderPhase(gbConf, graphBuilderPhase.getGraphBuilderPlugins()));
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
877 return suite;
4204
4df4499e0289 Fixed unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4203
diff changeset
878 }
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
879
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
880 protected Replacements getReplacements() {
12362
f53dc8bbb88c refactored isReexecutable(), getKilledLocations() and canDeoptimize() out of MetaAccessProvider into ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12054
diff changeset
881 return getProviders().getReplacements();
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
882 }
14014
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
883
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
884 /**
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
885 * Inject a probability for a branch condition into the profiling information of this test case.
14919
bd08e610e6f3 BaselineCompiler: create BytecodeParser.
Josef Eisl <josef.eisl@jku.at>
parents: 14890
diff changeset
886 *
14014
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
887 * @param p the probability that cond is true
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
888 * @param cond the condition of the branch
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
889 * @return cond
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
890 */
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
891 protected static boolean branchProbability(double p, boolean cond) {
19045
862997951c0a Add GraalDirectives API to influence compiler behavior.
Roland Schatz <roland.schatz@oracle.com>
parents: 18969
diff changeset
892 return GraalDirectives.injectBranchProbability(p, cond);
14014
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
893 }
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
894
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
895 /**
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
896 * Inject an iteration count for a loop condition into the profiling information of this test
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
897 * case.
14919
bd08e610e6f3 BaselineCompiler: create BytecodeParser.
Josef Eisl <josef.eisl@jku.at>
parents: 14890
diff changeset
898 *
14014
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
899 * @param i the iteration count of the loop
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
900 * @param cond the condition of the loop
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
901 * @return cond
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
902 */
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
903 protected static boolean iterationCount(double i, boolean cond) {
19045
862997951c0a Add GraalDirectives API to influence compiler behavior.
Roland Schatz <roland.schatz@oracle.com>
parents: 18969
diff changeset
904 return GraalDirectives.injectIterationCount(i, cond);
14014
ac599fff18dc Substitution methods for injecting fake profiling data into unit tests.
Roland Schatz <roland.schatz@oracle.com>
parents: 13773
diff changeset
905 }
16517
cb70055faeeb [SPARC/AMD64] Ignore AllocatorTest when the platform does not match.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16199
diff changeset
906
cb70055faeeb [SPARC/AMD64] Ignore AllocatorTest when the platform does not match.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16199
diff changeset
907 /**
cb70055faeeb [SPARC/AMD64] Ignore AllocatorTest when the platform does not match.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16199
diff changeset
908 * Test if the current test runs on the given platform. The name must match the name given in
cb70055faeeb [SPARC/AMD64] Ignore AllocatorTest when the platform does not match.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16199
diff changeset
909 * the {@link Architecture#getName()}.
cb70055faeeb [SPARC/AMD64] Ignore AllocatorTest when the platform does not match.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16199
diff changeset
910 *
cb70055faeeb [SPARC/AMD64] Ignore AllocatorTest when the platform does not match.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16199
diff changeset
911 * @param name The name to test
cb70055faeeb [SPARC/AMD64] Ignore AllocatorTest when the platform does not match.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16199
diff changeset
912 * @return true if we run on the architecture given by name
cb70055faeeb [SPARC/AMD64] Ignore AllocatorTest when the platform does not match.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16199
diff changeset
913 */
cb70055faeeb [SPARC/AMD64] Ignore AllocatorTest when the platform does not match.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16199
diff changeset
914 protected boolean isArchitecture(String name) {
cb70055faeeb [SPARC/AMD64] Ignore AllocatorTest when the platform does not match.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16199
diff changeset
915 return name.equals(backend.getTarget().arch.getName());
cb70055faeeb [SPARC/AMD64] Ignore AllocatorTest when the platform does not match.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 16199
diff changeset
916 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
917 }