Mercurial > hg > truffle
annotate graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java @ 12045:0fc653a9e019
made GraalCodeCacheProvider independent of CodeCacheProvider and renamed the former to LoweringProvider (GRAAL-511)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 10 Oct 2013 20:50:54 +0200 |
parents | 23ccaa863eda |
children | 0afe7370260c |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
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.*; |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9767
diff
changeset
|
26 import static com.oracle.graal.phases.GraalOptions.*; |
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
|
27 |
11738
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
28 import java.io.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 import java.lang.reflect.*; |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
5599
diff
changeset
|
30 import java.util.*; |
5360
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
31 import java.util.concurrent.*; |
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; |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5499
diff
changeset
|
39 import com.oracle.graal.api.meta.*; |
6540
31aa76ffd3bb
Rename project graal.api to graal.api.runtime
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
40 import com.oracle.graal.api.runtime.*; |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5109
diff
changeset
|
41 import com.oracle.graal.compiler.*; |
7836
a202f72872a4
Remove usage of left-over fields in GraalCompiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7835
diff
changeset
|
42 import com.oracle.graal.compiler.target.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
43 import com.oracle.graal.debug.*; |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
44 import com.oracle.graal.graph.*; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
45 import com.oracle.graal.graph.Node.Verbosity; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
46 import com.oracle.graal.java.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
47 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
|
48 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
|
49 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
|
50 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
|
51 import com.oracle.graal.phases.*; |
6543
ec196bfc458b
Minor fixes after cleanup
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6540
diff
changeset
|
52 import com.oracle.graal.phases.PhasePlan.PhasePosition; |
6525
2c913b643422
rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents:
6447
diff
changeset
|
53 import com.oracle.graal.phases.schedule.*; |
9968
3df534c97af1
Create Suites instance in runtime.
Roland Schatz <roland.schatz@oracle.com>
parents:
9864
diff
changeset
|
54 import com.oracle.graal.phases.tiers.*; |
7318
323ece2b012b
Refactor debug environment creation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7282
diff
changeset
|
55 import com.oracle.graal.printer.*; |
7717
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
7530
diff
changeset
|
56 import com.oracle.graal.test.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 /** |
6578 | 59 * Base class for Graal compiler unit tests. |
60 * <p> | |
61 * 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
|
62 * <ol> |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
63 * <li>Create a graph by {@linkplain #parse(String) parsing} a method.</li> |
5360
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
64 * <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
|
65 * <li>Apply a transformation to the graph.</li> |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
66 * <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
|
67 * </ol> |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 * <p> |
6578 | 69 * 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
|
70 * <p> |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7321
diff
changeset
|
71 * 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
|
72 * {@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
|
73 * result against that produced by a Graal compiled version of the method. |
6578 | 74 * <p> |
75 * 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
|
76 */ |
7717
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
7530
diff
changeset
|
77 public abstract class GraalCompilerTest extends GraalTest { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 |
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
|
79 private final CodeCacheProvider codeCache; |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11740
diff
changeset
|
80 private final MetaAccessProvider metaAccess; |
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
|
81 private final LoweringProvider lowerer; |
8636
ac4dbfecec8f
passed a Replacements object to inlining utility methods that need one instead of the GraalRuntime API
Doug Simon <doug.simon@oracle.com>
parents:
8598
diff
changeset
|
82 protected final Replacements replacements; |
7836
a202f72872a4
Remove usage of left-over fields in GraalCompiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7835
diff
changeset
|
83 protected final Backend backend; |
9968
3df534c97af1
Create Suites instance in runtime.
Roland Schatz <roland.schatz@oracle.com>
parents:
9864
diff
changeset
|
84 protected final Suites suites; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 |
5565
0083a59ced84
Renaming GraphTest => GraalCompilerTest.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5546
diff
changeset
|
86 public GraalCompilerTest() { |
9682
86d24f120b78
Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents:
9621
diff
changeset
|
87 this.replacements = Graal.getRequiredCapability(Replacements.class); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11740
diff
changeset
|
88 this.metaAccess = Graal.getRequiredCapability(MetaAccessProvider.class); |
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
|
89 this.codeCache = Graal.getRequiredCapability(CodeCacheProvider.class); |
0fc653a9e019
made GraalCodeCacheProvider independent of CodeCacheProvider and renamed the former to LoweringProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
90 this.lowerer = Graal.getRequiredCapability(LoweringProvider.class); |
7836
a202f72872a4
Remove usage of left-over fields in GraalCompiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7835
diff
changeset
|
91 this.backend = Graal.getRequiredCapability(Backend.class); |
9968
3df534c97af1
Create Suites instance in runtime.
Roland Schatz <roland.schatz@oracle.com>
parents:
9864
diff
changeset
|
92 this.suites = Graal.getRequiredCapability(SuitesProvider.class).createSuites(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
93 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
94 |
8598
5a3703970e3f
share debug environment across multiple tests
Doug Simon <doug.simon@oracle.com>
parents:
8349
diff
changeset
|
95 @BeforeClass |
11560 | 96 public static void initializeDebugging() { |
8598
5a3703970e3f
share debug environment across multiple tests
Doug Simon <doug.simon@oracle.com>
parents:
8349
diff
changeset
|
97 DebugEnvironment.initialize(System.out); |
5a3703970e3f
share debug environment across multiple tests
Doug Simon <doug.simon@oracle.com>
parents:
8349
diff
changeset
|
98 } |
5a3703970e3f
share debug environment across multiple tests
Doug Simon <doug.simon@oracle.com>
parents:
8349
diff
changeset
|
99 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
100 protected void assertEquals(StructuredGraph expected, StructuredGraph graph) { |
8921
ea867ede377f
allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents:
8598
diff
changeset
|
101 assertEquals(expected, graph, false); |
ea867ede377f
allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents:
8598
diff
changeset
|
102 } |
ea867ede377f
allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents:
8598
diff
changeset
|
103 |
ea867ede377f
allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents:
8598
diff
changeset
|
104 protected void assertEquals(StructuredGraph expected, StructuredGraph graph, boolean excludeVirtual) { |
ea867ede377f
allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents:
8598
diff
changeset
|
105 String expectedString = getCanonicalGraphString(expected, excludeVirtual); |
ea867ede377f
allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents:
8598
diff
changeset
|
106 String actualString = getCanonicalGraphString(graph, excludeVirtual); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
107 String mismatchString = "mismatch in graphs:\n========= expected =========\n" + expectedString + "\n\n========= actual =========\n" + actualString; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
108 |
8921
ea867ede377f
allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents:
8598
diff
changeset
|
109 if (!excludeVirtual && expected.getNodeCount() != graph.getNodeCount()) { |
4363
7462c3600c3a
Draft changes to the graph plotting.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4265
diff
changeset
|
110 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
|
111 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
|
112 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
|
113 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
114 if (!expectedString.equals(actualString)) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
115 Debug.dump(expected, "mismatching graphs - expected"); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
116 Debug.dump(graph, "mismatching graphs - actual"); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
117 Assert.fail(mismatchString); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
118 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
119 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
120 |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5650
diff
changeset
|
121 protected void assertConstantReturn(StructuredGraph graph, int value) { |
8921
ea867ede377f
allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents:
8598
diff
changeset
|
122 String graphString = getCanonicalGraphString(graph, false); |
11660
b9e963c44ed5
removed the IterableNodeType marker interface from ReturnNode (GRAAL-471)
Doug Simon <doug.simon@oracle.com>
parents:
11560
diff
changeset
|
123 Assert.assertEquals("unexpected number of ReturnNodes: " + graphString, graph.getNodes().filter(ReturnNode.class).count(), 1); |
b9e963c44ed5
removed the IterableNodeType marker interface from ReturnNode (GRAAL-471)
Doug Simon <doug.simon@oracle.com>
parents:
11560
diff
changeset
|
124 ValueNode result = graph.getNodes().filter(ReturnNode.class).first().result(); |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5650
diff
changeset
|
125 Assert.assertTrue("unexpected ReturnNode result node: " + graphString, result.isConstant()); |
6329
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5780
diff
changeset
|
126 Assert.assertEquals("unexpected ReturnNode result kind: " + graphString, result.asConstant().getKind(), Kind.Int); |
5657
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5650
diff
changeset
|
127 Assert.assertEquals("unexpected ReturnNode result: " + graphString, result.asConstant().asInt(), value); |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5650
diff
changeset
|
128 } |
d71eb56d6bb0
new stamp inference in CanonicalizerPhase, IntegerStamp.mask
Lukas Stadler <lukas.stadler@jku.at>
parents:
5650
diff
changeset
|
129 |
8921
ea867ede377f
allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents:
8598
diff
changeset
|
130 protected static String getCanonicalGraphString(StructuredGraph graph, boolean excludeVirtual) { |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
131 SchedulePhase schedule = new SchedulePhase(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
132 schedule.apply(graph); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
133 |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
134 NodeMap<Integer> canonicalId = graph.createNodeMap(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
135 int nextId = 0; |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
136 |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
137 StringBuilder result = new StringBuilder(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
138 for (Block block : schedule.getCFG().getBlocks()) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
139 result.append("Block " + block + " "); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
140 if (block == schedule.getCFG().getStartBlock()) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
141 result.append("* "); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
142 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
143 result.append("-> "); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
144 for (Block succ : block.getSuccessors()) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
145 result.append(succ + " "); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
146 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
147 result.append("\n"); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
148 for (Node node : schedule.getBlockToNodesMap().get(block)) { |
8921
ea867ede377f
allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents:
8598
diff
changeset
|
149 if (!excludeVirtual || !(node instanceof VirtualObjectNode || node instanceof ProxyNode)) { |
ea867ede377f
allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents:
8598
diff
changeset
|
150 int id; |
ea867ede377f
allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents:
8598
diff
changeset
|
151 if (canonicalId.get(node) != null) { |
ea867ede377f
allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents:
8598
diff
changeset
|
152 id = canonicalId.get(node); |
ea867ede377f
allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents:
8598
diff
changeset
|
153 } else { |
ea867ede377f
allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents:
8598
diff
changeset
|
154 id = nextId++; |
ea867ede377f
allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents:
8598
diff
changeset
|
155 canonicalId.set(node, id); |
ea867ede377f
allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents:
8598
diff
changeset
|
156 } |
ea867ede377f
allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents:
8598
diff
changeset
|
157 String name = node instanceof ConstantNode ? node.toString(Verbosity.Name) : node.getClass().getSimpleName(); |
ea867ede377f
allow GraalCompilerTests to ignore virtual and floating nodes in graph comparison
Lukas Stadler <lukas.stadler@jku.at>
parents:
8598
diff
changeset
|
158 result.append(" " + id + "|" + name + (excludeVirtual ? "\n" : " (" + node.usages().count() + ")\n")); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
159 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
160 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
161 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
162 return result.toString(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
163 } |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5360
diff
changeset
|
164 |
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
|
165 protected CodeCacheProvider getCodeCache() { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11740
diff
changeset
|
166 return codeCache; |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11740
diff
changeset
|
167 } |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11740
diff
changeset
|
168 |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11740
diff
changeset
|
169 protected MetaAccessProvider getMetaAccess() { |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11740
diff
changeset
|
170 return metaAccess; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
171 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
172 |
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
|
173 protected LoweringProvider getLowerer() { |
0fc653a9e019
made GraalCodeCacheProvider independent of CodeCacheProvider and renamed the former to LoweringProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
174 return lowerer; |
0fc653a9e019
made GraalCodeCacheProvider independent of CodeCacheProvider and renamed the former to LoweringProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
175 } |
0fc653a9e019
made GraalCodeCacheProvider independent of CodeCacheProvider and renamed the former to LoweringProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
176 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
177 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
178 * Parses a Java method to produce a graph. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7321
diff
changeset
|
179 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
180 * @param methodName the name of the method in {@code this.getClass()} to be parsed |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
181 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
182 protected StructuredGraph parse(String methodName) { |
4993
897b7d18bebc
added RiCompiledMethod.execute and the required VM infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
4410
diff
changeset
|
183 return parse(getMethod(methodName)); |
897b7d18bebc
added RiCompiledMethod.execute and the required VM infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
4410
diff
changeset
|
184 } |
897b7d18bebc
added RiCompiledMethod.execute and the required VM infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
4410
diff
changeset
|
185 |
11740
a402610bc52b
made compilation ID allocation in tests be atomic
Doug Simon <doug.simon@oracle.com>
parents:
11738
diff
changeset
|
186 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
|
187 |
7260
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
188 /** |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
189 * Compares two given objects for {@linkplain Assert#assertEquals(Object, Object) equality}. |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
190 * Does a deep copy equality comparison if {@code expected} is an array. |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
191 */ |
5599
592dfff9d410
modified GraalCompilerTest so that subclasses can override the assertEquals test
Doug Simon <doug.simon@oracle.com>
parents:
5571
diff
changeset
|
192 protected void assertEquals(Object expected, Object actual) { |
7260
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
193 if (expected != null && expected.getClass().isArray()) { |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
194 Assert.assertTrue(expected != null); |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
195 Assert.assertTrue(actual != null); |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
196 Assert.assertEquals(expected.getClass(), actual.getClass()); |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
197 if (expected instanceof int[]) { |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
198 Assert.assertArrayEquals((int[]) expected, (int[]) actual); |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
199 } else if (expected instanceof byte[]) { |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
200 Assert.assertArrayEquals((byte[]) expected, (byte[]) actual); |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
201 } else if (expected instanceof char[]) { |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
202 Assert.assertArrayEquals((char[]) expected, (char[]) actual); |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
203 } else if (expected instanceof short[]) { |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
204 Assert.assertArrayEquals((short[]) expected, (short[]) actual); |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
205 } else if (expected instanceof float[]) { |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
206 Assert.assertArrayEquals((float[]) expected, (float[]) actual, 0.0f); |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
207 } else if (expected instanceof long[]) { |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
208 Assert.assertArrayEquals((long[]) expected, (long[]) actual); |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
209 } else if (expected instanceof double[]) { |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
210 Assert.assertArrayEquals((double[]) expected, (double[]) actual, 0.0d); |
10885
3f43462ce829
Work around missing support for boolean[] in junit.
Roland Schatz <roland.schatz@oracle.com>
parents:
10764
diff
changeset
|
211 } else if (expected instanceof boolean[]) { |
3f43462ce829
Work around missing support for boolean[] in junit.
Roland Schatz <roland.schatz@oracle.com>
parents:
10764
diff
changeset
|
212 new ExactComparisonCriteria().arrayEquals(null, expected, actual); |
7260
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
213 } else if (expected instanceof Object[]) { |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
214 Assert.assertArrayEquals((Object[]) expected, (Object[]) actual); |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
215 } else { |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
216 Assert.fail("non-array value encountered: " + expected); |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
217 } |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
218 } else { |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
219 Assert.assertEquals(expected, actual); |
169bbc849ee9
moved deep array equality comparison into base test class
Doug Simon <doug.simon@oracle.com>
parents:
7154
diff
changeset
|
220 } |
5599
592dfff9d410
modified GraalCompilerTest so that subclasses can override the assertEquals test
Doug Simon <doug.simon@oracle.com>
parents:
5571
diff
changeset
|
221 } |
592dfff9d410
modified GraalCompilerTest so that subclasses can override the assertEquals test
Doug Simon <doug.simon@oracle.com>
parents:
5571
diff
changeset
|
222 |
11738
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
223 @SuppressWarnings("serial") |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
224 public static class MultiCauseAssertionError extends AssertionError { |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
225 |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
226 private Throwable[] causes; |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
227 |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
228 public MultiCauseAssertionError(String message, Throwable... causes) { |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
229 super(message); |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
230 this.causes = causes; |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
231 } |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
232 |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
233 @Override |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
234 public void printStackTrace(PrintStream out) { |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
235 super.printStackTrace(out); |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
236 int num = 0; |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
237 for (Throwable cause : causes) { |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
238 if (cause != null) { |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
239 out.print("cause " + (num++)); |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
240 cause.printStackTrace(out); |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
241 } |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
242 } |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
243 } |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
244 |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
245 @Override |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
246 public void printStackTrace(PrintWriter out) { |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
247 super.printStackTrace(out); |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
248 int num = 0; |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
249 for (Throwable cause : causes) { |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
250 if (cause != null) { |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
251 out.print("cause " + (num++) + ": "); |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
252 cause.printStackTrace(out); |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
253 } |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
254 } |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
255 } |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
256 } |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
257 |
6370
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
258 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
|
259 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
|
260 Thread[] threads = new Thread[n]; |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
261 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
|
262 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
|
263 |
6370
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
264 @Override |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
265 public void run() { |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
266 try { |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
267 test(name, args); |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
268 } catch (Throwable e) { |
11738
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
269 errors.add(e); |
6370
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
270 } |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
271 } |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
272 }; |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
273 threads[i] = t; |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
274 t.start(); |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
275 } |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
276 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
|
277 try { |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
278 threads[i].join(); |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
279 } catch (InterruptedException e) { |
11738
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
280 errors.add(e); |
6370
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
281 } |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
282 } |
11738
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
283 if (!errors.isEmpty()) { |
aa10794f1574
better reporting of failures during multi-threaded tests
Doug Simon <doug.simon@oracle.com>
parents:
11660
diff
changeset
|
284 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
|
285 } |
6370
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
286 } |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
287 |
6431
2e376f8ea4e2
added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents:
6370
diff
changeset
|
288 protected Object referenceInvoke(Method method, Object receiver, Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { |
2e376f8ea4e2
added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents:
6370
diff
changeset
|
289 return method.invoke(receiver, args); |
2e376f8ea4e2
added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents:
6370
diff
changeset
|
290 } |
2e376f8ea4e2
added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents:
6370
diff
changeset
|
291 |
8232
ab374f69e4e8
JTTTest gets the expeted result only once
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8217
diff
changeset
|
292 protected static class Result { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7321
diff
changeset
|
293 |
6447
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
294 final Object returnValue; |
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
295 final Throwable exception; |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7321
diff
changeset
|
296 |
6447
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
297 public Result(Object returnValue, Throwable exception) { |
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
298 this.returnValue = returnValue; |
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
299 this.exception = exception; |
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
300 } |
9682
86d24f120b78
Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents:
9621
diff
changeset
|
301 |
86d24f120b78
Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents:
9621
diff
changeset
|
302 @Override |
86d24f120b78
Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents:
9621
diff
changeset
|
303 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
|
304 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
|
305 } |
6447
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
306 } |
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
307 |
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
|
308 /** |
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
|
309 * 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
|
310 */ |
9682
86d24f120b78
Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents:
9621
diff
changeset
|
311 protected void before(@SuppressWarnings("unused") Method 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
|
312 } |
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
|
313 |
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
|
314 /** |
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
|
315 * 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
|
316 */ |
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
|
317 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
|
318 } |
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
|
319 |
6447
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
320 protected Result executeExpected(Method 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
|
321 before(method); |
5557
2e2a77f091f2
re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents:
5546
diff
changeset
|
322 try { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7321
diff
changeset
|
323 // 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
|
324 // be compiled is fully resolved |
6447
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
325 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
|
326 } catch (InvocationTargetException e) { |
6447
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
327 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
|
328 } catch (Exception e) { |
2e2a77f091f2
re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents:
5546
diff
changeset
|
329 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
|
330 } 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
|
331 after(); |
5557
2e2a77f091f2
re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents:
5546
diff
changeset
|
332 } |
6447
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
333 } |
6370
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
334 |
6447
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
335 protected Result executeActual(Method 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
|
336 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
|
337 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
|
338 |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11740
diff
changeset
|
339 ResolvedJavaMethod javaMethod = metaAccess.lookupJavaMethod(method); |
8233
9484e7602276
GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8232
diff
changeset
|
340 checkArgs(javaMethod, executeArgs); |
9484e7602276
GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8232
diff
changeset
|
341 |
9484e7602276
GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8232
diff
changeset
|
342 InstalledCode compiledMethod = getCode(javaMethod, parse(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
|
343 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
|
344 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
|
345 } 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
|
346 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
|
347 } 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
|
348 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
|
349 } |
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
|
350 } |
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
|
351 |
8233
9484e7602276
GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8232
diff
changeset
|
352 protected void checkArgs(ResolvedJavaMethod method, Object[] args) { |
9484e7602276
GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8232
diff
changeset
|
353 JavaType[] sig = MetaUtil.signatureToTypes(method); |
9484e7602276
GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8232
diff
changeset
|
354 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
|
355 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
|
356 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
|
357 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
|
358 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
|
359 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
|
360 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
|
361 ResolvedJavaType resolvedJavaType = (ResolvedJavaType) javaType; |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11740
diff
changeset
|
362 Assert.assertTrue(resolvedJavaType + " from " + metaAccess.lookupJavaType(arg.getClass()), resolvedJavaType.isAssignableFrom(metaAccess.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
|
363 } |
9484e7602276
GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8232
diff
changeset
|
364 } else { |
9484e7602276
GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8232
diff
changeset
|
365 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
|
366 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
|
367 } |
9484e7602276
GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8232
diff
changeset
|
368 } |
9484e7602276
GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8232
diff
changeset
|
369 } |
9484e7602276
GraalCompilerTest should assert that parameters passed to executeActual have the right type.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8232
diff
changeset
|
370 |
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
|
371 /** |
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
|
372 * Prepends a non-null receiver argument to a given list or args. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7321
diff
changeset
|
373 * |
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
|
374 * @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
|
375 */ |
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
|
376 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
|
377 Object[] executeArgs; |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
378 if (receiver == null) { |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
379 executeArgs = args; |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
380 } else { |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
381 executeArgs = new Object[args.length + 1]; |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
382 executeArgs[0] = receiver; |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
383 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
|
384 executeArgs[i + 1] = args[i]; |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
385 } |
703a6ab8ca82
added support for multi-threaded compiler tests
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
386 } |
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
|
387 return executeArgs; |
6447
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
388 } |
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
389 |
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
390 protected void test(String name, Object... args) { |
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
391 Method method = getMethod(name); |
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
392 Object receiver = Modifier.isStatic(method.getModifiers()) ? null : this; |
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
393 |
8232
ab374f69e4e8
JTTTest gets the expeted result only once
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8217
diff
changeset
|
394 test(method, receiver, args); |
ab374f69e4e8
JTTTest gets the expeted result only once
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8217
diff
changeset
|
395 } |
ab374f69e4e8
JTTTest gets the expeted result only once
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8217
diff
changeset
|
396 |
ab374f69e4e8
JTTTest gets the expeted result only once
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8217
diff
changeset
|
397 protected void test(Method method, Object receiver, Object... args) { |
6447
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
398 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
|
399 if (getCodeCache() == null) { |
6447
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
400 return; |
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
401 } |
11405
25161615539b
method rename to avoid ambiguous overloading
Doug Simon <doug.simon@oracle.com>
parents:
11316
diff
changeset
|
402 testAgainstExpected(method, expect, receiver, args); |
8232
ab374f69e4e8
JTTTest gets the expeted result only once
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8217
diff
changeset
|
403 } |
ab374f69e4e8
JTTTest gets the expeted result only once
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8217
diff
changeset
|
404 |
11405
25161615539b
method rename to avoid ambiguous overloading
Doug Simon <doug.simon@oracle.com>
parents:
11316
diff
changeset
|
405 protected void testAgainstExpected(Method method, Result expect, Object receiver, Object... args) { |
25161615539b
method rename to avoid ambiguous overloading
Doug Simon <doug.simon@oracle.com>
parents:
11316
diff
changeset
|
406 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
|
407 } |
86d24f120b78
Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents:
9621
diff
changeset
|
408 |
10030
85f926430ae6
Test deoptimization in DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
10019
diff
changeset
|
409 protected Result executeActualCheckDeopt(Method 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
|
410 Map<DeoptimizationReason, Integer> deoptCounts = new EnumMap<>(DeoptimizationReason.class); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11740
diff
changeset
|
411 ResolvedJavaMethod javaMethod = metaAccess.lookupJavaMethod(method); |
11316
33ea8e2addac
Fix GraalCompilerTest deopt checks: need to re-aquire the profile after running the method since the MethodData may not be present before running it.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11259
diff
changeset
|
412 ProfilingInfo profile = javaMethod.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
|
413 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
|
414 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
|
415 } |
6447
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
416 Result actual = executeActual(method, receiver, args); |
11316
33ea8e2addac
Fix GraalCompilerTest deopt checks: need to re-aquire the profile after running the method since the MethodData may not be present before running it.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11259
diff
changeset
|
417 profile = javaMethod.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
|
418 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
|
419 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
|
420 } |
10030
85f926430ae6
Test deoptimization in DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
10019
diff
changeset
|
421 return actual; |
85f926430ae6
Test deoptimization in DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
10019
diff
changeset
|
422 } |
6447
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
423 |
10030
85f926430ae6
Test deoptimization in DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
10019
diff
changeset
|
424 protected void assertEquals(Result expect, Result actual) { |
6447
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
425 if (expect.exception != null) { |
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
426 Assert.assertTrue("expected " + expect.exception, actual.exception != null); |
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
427 Assert.assertEquals(expect.exception.getClass(), actual.exception.getClass()); |
9682
86d24f120b78
Allow tests to check for deoptimizations, provide Method object in before hook.
Roland Schatz <roland.schatz@oracle.com>
parents:
9621
diff
changeset
|
428 Assert.assertEquals(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
|
429 } else { |
8232
ab374f69e4e8
JTTTest gets the expeted result only once
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8217
diff
changeset
|
430 if (actual.exception != null) { |
ab374f69e4e8
JTTTest gets the expeted result only once
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8217
diff
changeset
|
431 actual.exception.printStackTrace(); |
ab374f69e4e8
JTTTest gets the expeted result only once
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
8217
diff
changeset
|
432 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
|
433 } |
6447
d7bcbdf4749c
minor restructuring of GraalCompilerTest
Doug Simon <doug.simon@oracle.com>
parents:
6431
diff
changeset
|
434 assertEquals(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
|
435 } |
2e2a77f091f2
re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents:
5546
diff
changeset
|
436 } |
2e2a77f091f2
re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents:
5546
diff
changeset
|
437 |
11405
25161615539b
method rename to avoid ambiguous overloading
Doug Simon <doug.simon@oracle.com>
parents:
11316
diff
changeset
|
438 protected void testAgainstExpected(Method 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
|
439 Result actual = executeActualCheckDeopt(method, shouldNotDeopt, receiver, args); |
85f926430ae6
Test deoptimization in DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
10019
diff
changeset
|
440 assertEquals(expect, actual); |
85f926430ae6
Test deoptimization in DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
10019
diff
changeset
|
441 } |
85f926430ae6
Test deoptimization in DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
10019
diff
changeset
|
442 |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
5599
diff
changeset
|
443 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
|
444 |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
5599
diff
changeset
|
445 /** |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
5599
diff
changeset
|
446 * Gets installed code for a given method and graph, compiling it first if necessary. |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
5599
diff
changeset
|
447 */ |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
5599
diff
changeset
|
448 protected InstalledCode getCode(final ResolvedJavaMethod method, final StructuredGraph graph) { |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
5599
diff
changeset
|
449 return getCode(method, graph, false); |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
5599
diff
changeset
|
450 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
5599
diff
changeset
|
451 |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
5599
diff
changeset
|
452 /** |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
5599
diff
changeset
|
453 * Gets installed code for a given method and graph, compiling it first if necessary. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7321
diff
changeset
|
454 * |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7321
diff
changeset
|
455 * @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
|
456 * key) pair |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
5599
diff
changeset
|
457 */ |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
5599
diff
changeset
|
458 protected InstalledCode getCode(final ResolvedJavaMethod method, final StructuredGraph graph, boolean forceCompile) { |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
5599
diff
changeset
|
459 if (!forceCompile) { |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
5599
diff
changeset
|
460 InstalledCode cached = cache.get(method); |
7028
0353b031235a
added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents:
6676
diff
changeset
|
461 if (cached != null) { |
0353b031235a
added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents:
6676
diff
changeset
|
462 if (cached.isValid()) { |
0353b031235a
added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents:
6676
diff
changeset
|
463 return cached; |
0353b031235a
added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents:
6676
diff
changeset
|
464 } |
0353b031235a
added tests for instanceof with array types
Doug Simon <doug.simon@oracle.com>
parents:
6676
diff
changeset
|
465 |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
5599
diff
changeset
|
466 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
5599
diff
changeset
|
467 } |
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
|
468 |
11740
a402610bc52b
made compilation ID allocation in tests be atomic
Doug Simon <doug.simon@oracle.com>
parents:
11738
diff
changeset
|
469 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
|
470 |
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
|
471 InstalledCode installedCode = Debug.scope("Compiling", new Object[]{new DebugDumpScope(String.valueOf(id), true)}, new Callable<InstalledCode>() { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7321
diff
changeset
|
472 |
5538
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5537
diff
changeset
|
473 public InstalledCode call() throws Exception { |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9767
diff
changeset
|
474 final boolean printCompilation = PrintCompilation.getValue() && !TTY.isSuppressed(); |
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
|
475 if (printCompilation) { |
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
|
476 TTY.println(String.format("@%-6d Graal %-70s %-45s %-50s ...", id, method.getDeclaringClass().getName(), method.getName(), method.getSignature())); |
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
|
477 } |
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
|
478 long start = System.currentTimeMillis(); |
5780
64257cbef60c
removed compile method from GraalCodeCacheProvider interface
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
479 PhasePlan phasePlan = new PhasePlan(); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11740
diff
changeset
|
480 GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(metaAccess, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL); |
5780
64257cbef60c
removed compile method from GraalCodeCacheProvider interface
Doug Simon <doug.simon@oracle.com>
parents:
5720
diff
changeset
|
481 phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11740
diff
changeset
|
482 CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); |
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
|
483 final CompilationResult compResult = GraalCompiler.compileGraph(graph, cc, method, metaAccess, getCodeCache(), getLowerer(), replacements, backend, getCodeCache().getTarget(), null, |
0fc653a9e019
made GraalCodeCacheProvider independent of CodeCacheProvider and renamed the former to LoweringProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
484 phasePlan, OptimisticOptimizations.ALL, new SpeculationLog(), suites, new CompilationResult()); |
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
|
485 if (printCompilation) { |
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
|
486 TTY.println(String.format("@%-6d Graal %-70s %-45s %-50s | %4dms %5dB", id, "", "", "", System.currentTimeMillis() - start, compResult.getTargetCodeSize())); |
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
|
487 } |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11740
diff
changeset
|
488 return Debug.scope("CodeInstall", new Object[]{getCodeCache(), method}, new Callable<InstalledCode>() { |
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
|
489 |
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
|
490 @Override |
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
|
491 public InstalledCode call() throws Exception { |
10019
6e4b72bcc97f
Remove graph from HotSpotNMethod
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
9969
diff
changeset
|
492 InstalledCode code = addMethod(method, compResult); |
10531
74cbc5d6e38f
GraalCompilerTest throws an error if code installation fails
Doug Simon <doug.simon@oracle.com>
parents:
10030
diff
changeset
|
493 if (code == null) { |
74cbc5d6e38f
GraalCompilerTest throws an error if code installation fails
Doug Simon <doug.simon@oracle.com>
parents:
10030
diff
changeset
|
494 throw new GraalInternalError("Could not install code for " + MetaUtil.format("%H.%n(%p)", method)); |
74cbc5d6e38f
GraalCompilerTest throws an error if code installation fails
Doug Simon <doug.simon@oracle.com>
parents:
10030
diff
changeset
|
495 } |
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
|
496 if (Debug.isDumpEnabled()) { |
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
|
497 Debug.dump(new Object[]{compResult, code}, "After code installation"); |
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
|
498 } |
11259
3245779c0ce2
added support to disassemble installed test code via -G:Log
Doug Simon <doug.simon@oracle.com>
parents:
10936
diff
changeset
|
499 if (Debug.isLogEnabled()) { |
3245779c0ce2
added support to disassemble installed test code via -G:Log
Doug Simon <doug.simon@oracle.com>
parents:
10936
diff
changeset
|
500 DisassemblerProvider dis = Graal.getRuntime().getCapability(DisassemblerProvider.class); |
3245779c0ce2
added support to disassemble installed test code via -G:Log
Doug Simon <doug.simon@oracle.com>
parents:
10936
diff
changeset
|
501 if (dis != null) { |
3245779c0ce2
added support to disassemble installed test code via -G:Log
Doug Simon <doug.simon@oracle.com>
parents:
10936
diff
changeset
|
502 String text = dis.disassemble(code); |
3245779c0ce2
added support to disassemble installed test code via -G:Log
Doug Simon <doug.simon@oracle.com>
parents:
10936
diff
changeset
|
503 if (text != null) { |
3245779c0ce2
added support to disassemble installed test code via -G:Log
Doug Simon <doug.simon@oracle.com>
parents:
10936
diff
changeset
|
504 Debug.log("Code installed for %s%n%s", method, text); |
3245779c0ce2
added support to disassemble installed test code via -G:Log
Doug Simon <doug.simon@oracle.com>
parents:
10936
diff
changeset
|
505 } |
3245779c0ce2
added support to disassemble installed test code via -G:Log
Doug Simon <doug.simon@oracle.com>
parents:
10936
diff
changeset
|
506 } |
3245779c0ce2
added support to disassemble installed test code via -G:Log
Doug Simon <doug.simon@oracle.com>
parents:
10936
diff
changeset
|
507 } |
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
|
508 |
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
|
509 return code; |
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
|
510 } |
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
|
511 }); |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
5425
diff
changeset
|
512 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
5425
diff
changeset
|
513 }); |
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
|
514 |
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
|
515 if (!forceCompile) { |
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
|
516 cache.put(method, installedCode); |
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
|
517 } |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
5599
diff
changeset
|
518 return installedCode; |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
5425
diff
changeset
|
519 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
5425
diff
changeset
|
520 |
10019
6e4b72bcc97f
Remove graph from HotSpotNMethod
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
9969
diff
changeset
|
521 protected InstalledCode addMethod(final ResolvedJavaMethod method, final CompilationResult compResult) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11740
diff
changeset
|
522 return getCodeCache().addMethod(method, compResult); |
5360
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
523 } |
6cc970203f30
moved creation of a RiCodeInfo to the runtime side of the CRI
Doug Simon <doug.simon@oracle.com>
parents:
5122
diff
changeset
|
524 |
4340
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
525 /** |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
526 * Parses a Java method to produce a graph. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7321
diff
changeset
|
527 * |
4340
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
528 * @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
|
529 */ |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
530 protected StructuredGraph parseProfiled(String methodName) { |
4993
897b7d18bebc
added RiCompiledMethod.execute and the required VM infrastructure
Lukas Stadler <lukas.stadler@jku.at>
parents:
4410
diff
changeset
|
531 return parseProfiled(getMethod(methodName)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
532 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
533 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
534 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
535 * Parses a Java method to produce a graph. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
536 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
537 protected StructuredGraph parse(Method m) { |
9003
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8637
diff
changeset
|
538 return parse0(m, GraphBuilderConfiguration.getEagerDefault()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
539 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
540 |
4340
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
541 /** |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
542 * Parses a Java method to produce a graph. |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
543 */ |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
544 protected StructuredGraph parseProfiled(Method m) { |
9003
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8637
diff
changeset
|
545 return parse0(m, GraphBuilderConfiguration.getDefault()); |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8637
diff
changeset
|
546 } |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8637
diff
changeset
|
547 |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8637
diff
changeset
|
548 /** |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8637
diff
changeset
|
549 * Parses a Java method in debug mode to produce a graph with extra infopoints. |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8637
diff
changeset
|
550 */ |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8637
diff
changeset
|
551 protected StructuredGraph parseDebug(Method m) { |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8637
diff
changeset
|
552 GraphBuilderConfiguration gbConf = GraphBuilderConfiguration.getEagerDefault(); |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8637
diff
changeset
|
553 gbConf.setEagerInfopointMode(true); |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8637
diff
changeset
|
554 return parse0(m, gbConf); |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8637
diff
changeset
|
555 } |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8637
diff
changeset
|
556 |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8637
diff
changeset
|
557 private StructuredGraph parse0(Method m, GraphBuilderConfiguration conf) { |
10764
d2f8addaf504
assertion in GraalCompiler (don't parse @Test methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
10577
diff
changeset
|
558 assert m.getAnnotation(Test.class) == null : "shouldn't parse method with @Test annotation: " + m; |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11740
diff
changeset
|
559 ResolvedJavaMethod javaMethod = metaAccess.lookupJavaMethod(m); |
5719
429accae15aa
moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents:
5718
diff
changeset
|
560 StructuredGraph graph = new StructuredGraph(javaMethod); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11740
diff
changeset
|
561 new GraphBuilderPhase(metaAccess, conf, OptimisticOptimizations.ALL).apply(graph); |
4340
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
562 return graph; |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
563 } |
5caca26cb1b9
small fix (missing changes)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4315
diff
changeset
|
564 |
4204
4df4499e0289
Fixed unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4203
diff
changeset
|
565 protected PhasePlan getDefaultPhasePlan() { |
9003
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8637
diff
changeset
|
566 return getDefaultPhasePlan(false); |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8637
diff
changeset
|
567 } |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8637
diff
changeset
|
568 |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8637
diff
changeset
|
569 protected PhasePlan getDefaultPhasePlan(boolean eagerInfopointMode) { |
4204
4df4499e0289
Fixed unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4203
diff
changeset
|
570 PhasePlan plan = new PhasePlan(); |
9003
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8637
diff
changeset
|
571 GraphBuilderConfiguration gbConf = GraphBuilderConfiguration.getEagerDefault(); |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
8637
diff
changeset
|
572 gbConf.setEagerInfopointMode(eagerInfopointMode); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11740
diff
changeset
|
573 plan.addPhase(PhasePosition.AFTER_PARSING, new GraphBuilderPhase(metaAccess, gbConf, OptimisticOptimizations.ALL)); |
4204
4df4499e0289
Fixed unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4203
diff
changeset
|
574 return plan; |
4df4499e0289
Fixed unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4203
diff
changeset
|
575 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
576 } |