annotate graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeHintsTest.java @ 20068:cc3131ff7ce2

Remove GraphCache option.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sun, 29 Mar 2015 20:51:22 +0200
parents 2fd45bb25118
children 05183a084a08
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
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: 5780
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
25 import java.util.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
26
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
27 import org.junit.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
29 import com.oracle.graal.nodes.*;
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19250
diff changeset
30 import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
6526
ee651c726397 split phases out of graal.phases project into graal.phases.common project
Doug Simon <doug.simon@oracle.com>
parents: 6525
diff changeset
31 import com.oracle.graal.phases.common.*;
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 13585
diff changeset
32 import com.oracle.graal.phases.common.inlining.*;
10933
9878214a0093 Remove fields from InliningPhase that are already available in HighTierContext.
Roland Schatz <roland.schatz@oracle.com>
parents: 9909
diff changeset
33 import com.oracle.graal.phases.tiers.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34
5780
64257cbef60c removed compile method from GraalCodeCacheProvider interface
Doug Simon <doug.simon@oracle.com>
parents: 5565
diff changeset
35 public class InvokeHintsTest extends GraalCompilerTest {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37 private static final String REFERENCE_SNIPPET = "referenceSnippet";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
38
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5177
diff changeset
39 public static int const1() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40 return 1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
42
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5177
diff changeset
43 public static int const7() {
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5177
diff changeset
44 return 7;
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5177
diff changeset
45 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5177
diff changeset
46
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5177
diff changeset
47 @SuppressWarnings("all")
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5177
diff changeset
48 public static int referenceSnippet() {
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5177
diff changeset
49 return 7;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
52 @Test
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
53 public void test1() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
54 test("test1Snippet");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
55 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
57 @SuppressWarnings("all")
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5177
diff changeset
58 public static int test1Snippet() {
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5177
diff changeset
59 return const7();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
62 @Test
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
63 public void test2() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
64 test("test2Snippet");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
67 @SuppressWarnings("all")
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5177
diff changeset
68 public static int test2Snippet() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
69 return const1() + const1() + const1() + const1() + const1() + const1() + const1();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
70 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
71
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
72 private void test(String snippet) {
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19250
diff changeset
73 StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
8552
31b7a648b4b3 turn inlining hints into a map
Lukas Stadler <lukas.stadler@jku.at>
parents: 7827
diff changeset
74 Map<Invoke, Double> hints = new HashMap<>();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
75 for (Invoke invoke : graph.getInvokes()) {
8552
31b7a648b4b3 turn inlining hints into a map
Lukas Stadler <lukas.stadler@jku.at>
parents: 7827
diff changeset
76 hints.put(invoke, 1000d);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77 }
7064
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 6526
diff changeset
78
20068
cc3131ff7ce2 Remove GraphCache option.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19716
diff changeset
79 HighTierContext context = getDefaultHighTierContext();
19716
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19306
diff changeset
80 new InliningPhase(hints, new CanonicalizerPhase()).apply(graph, context);
2fd45bb25118 Initial version of new dominator-based conditional elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19306
diff changeset
81 new CanonicalizerPhase().apply(graph, context);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
82 new DeadCodeEliminationPhase().apply(graph);
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19250
diff changeset
83 StructuredGraph referenceGraph = parseEager(REFERENCE_SNIPPET, AllowAssumptions.NO);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
84 assertEquals(referenceGraph, graph);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
85 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
86 }