Mercurial > hg > truffle
annotate graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java @ 21543:93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 25 May 2015 23:30:34 +0200 |
parents | c1e2fdb5fea3 |
children | b1530a6cce8c |
rev | line source |
---|---|
9001 | 1 /* |
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
9122
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
23 package com.oracle.graal.phases.tiers; |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
24 |
9987
b270f0856a39
fixed issues detected by VerifyHotSpotOptionsPhase
Doug Simon <doug.simon@oracle.com>
parents:
9968
diff
changeset
|
25 import static com.oracle.graal.phases.tiers.Suites.Options.*; |
b270f0856a39
fixed issues detected by VerifyHotSpotOptionsPhase
Doug Simon <doug.simon@oracle.com>
parents:
9968
diff
changeset
|
26 |
9122
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
27 import java.util.*; |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
28 |
19230 | 29 import com.oracle.graal.lir.phases.*; |
9855
6898d8995866
converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9264
diff
changeset
|
30 import com.oracle.graal.options.*; |
9122
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
31 import com.oracle.graal.phases.*; |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21538
diff
changeset
|
32 import com.oracle.jvmci.common.*; |
21538
c1e2fdb5fea3
removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19762
diff
changeset
|
33 import com.oracle.jvmci.runtime.*; |
9001 | 34 |
9122
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
35 public final class Suites { |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
36 |
9987
b270f0856a39
fixed issues detected by VerifyHotSpotOptionsPhase
Doug Simon <doug.simon@oracle.com>
parents:
9968
diff
changeset
|
37 static class Options { |
b270f0856a39
fixed issues detected by VerifyHotSpotOptionsPhase
Doug Simon <doug.simon@oracle.com>
parents:
9968
diff
changeset
|
38 |
b270f0856a39
fixed issues detected by VerifyHotSpotOptionsPhase
Doug Simon <doug.simon@oracle.com>
parents:
9968
diff
changeset
|
39 // @formatter:off |
18674
ecb9d0cedbab
First draft of option classification.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
16871
diff
changeset
|
40 @Option(help = "The compiler configuration to use", type = OptionType.User) |
10508
3e9820de1c1c
New strategy for selecting the default compiler configuration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9987
diff
changeset
|
41 static final OptionValue<String> CompilerConfiguration = new OptionValue<>(""); |
9987
b270f0856a39
fixed issues detected by VerifyHotSpotOptionsPhase
Doug Simon <doug.simon@oracle.com>
parents:
9968
diff
changeset
|
42 // @formatter:on |
b270f0856a39
fixed issues detected by VerifyHotSpotOptionsPhase
Doug Simon <doug.simon@oracle.com>
parents:
9968
diff
changeset
|
43 } |
9855
6898d8995866
converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9264
diff
changeset
|
44 |
9142
e178e4598f85
Remove public fields.
Roland Schatz <roland.schatz@oracle.com>
parents:
9137
diff
changeset
|
45 private final PhaseSuite<HighTierContext> highTier; |
e178e4598f85
Remove public fields.
Roland Schatz <roland.schatz@oracle.com>
parents:
9137
diff
changeset
|
46 private final PhaseSuite<MidTierContext> midTier; |
9264
3df022b2eebe
LowTier phase suite.
Roland Schatz <roland.schatz@oracle.com>
parents:
9188
diff
changeset
|
47 private final PhaseSuite<LowTierContext> lowTier; |
9142
e178e4598f85
Remove public fields.
Roland Schatz <roland.schatz@oracle.com>
parents:
9137
diff
changeset
|
48 |
10508
3e9820de1c1c
New strategy for selecting the default compiler configuration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9987
diff
changeset
|
49 private static final CompilerConfiguration defaultConfiguration; |
9122
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
50 private static final Map<String, CompilerConfiguration> configurations; |
9001 | 51 |
9142
e178e4598f85
Remove public fields.
Roland Schatz <roland.schatz@oracle.com>
parents:
9137
diff
changeset
|
52 public PhaseSuite<HighTierContext> getHighTier() { |
e178e4598f85
Remove public fields.
Roland Schatz <roland.schatz@oracle.com>
parents:
9137
diff
changeset
|
53 return highTier; |
e178e4598f85
Remove public fields.
Roland Schatz <roland.schatz@oracle.com>
parents:
9137
diff
changeset
|
54 } |
e178e4598f85
Remove public fields.
Roland Schatz <roland.schatz@oracle.com>
parents:
9137
diff
changeset
|
55 |
e178e4598f85
Remove public fields.
Roland Schatz <roland.schatz@oracle.com>
parents:
9137
diff
changeset
|
56 public PhaseSuite<MidTierContext> getMidTier() { |
e178e4598f85
Remove public fields.
Roland Schatz <roland.schatz@oracle.com>
parents:
9137
diff
changeset
|
57 return midTier; |
e178e4598f85
Remove public fields.
Roland Schatz <roland.schatz@oracle.com>
parents:
9137
diff
changeset
|
58 } |
e178e4598f85
Remove public fields.
Roland Schatz <roland.schatz@oracle.com>
parents:
9137
diff
changeset
|
59 |
9264
3df022b2eebe
LowTier phase suite.
Roland Schatz <roland.schatz@oracle.com>
parents:
9188
diff
changeset
|
60 public PhaseSuite<LowTierContext> getLowTier() { |
3df022b2eebe
LowTier phase suite.
Roland Schatz <roland.schatz@oracle.com>
parents:
9188
diff
changeset
|
61 return lowTier; |
3df022b2eebe
LowTier phase suite.
Roland Schatz <roland.schatz@oracle.com>
parents:
9188
diff
changeset
|
62 } |
3df022b2eebe
LowTier phase suite.
Roland Schatz <roland.schatz@oracle.com>
parents:
9188
diff
changeset
|
63 |
9122
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
64 static { |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
65 configurations = new HashMap<>(); |
10508
3e9820de1c1c
New strategy for selecting the default compiler configuration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9987
diff
changeset
|
66 CompilerConfiguration basic = null; |
3e9820de1c1c
New strategy for selecting the default compiler configuration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9987
diff
changeset
|
67 CompilerConfiguration nonBasic = null; |
3e9820de1c1c
New strategy for selecting the default compiler configuration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9987
diff
changeset
|
68 int nonBasicCount = 0; |
3e9820de1c1c
New strategy for selecting the default compiler configuration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9987
diff
changeset
|
69 |
15916
6aa352b260f4
removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
15193
diff
changeset
|
70 for (CompilerConfiguration config : Services.load(CompilerConfiguration.class)) { |
9122
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
71 String name = config.getClass().getSimpleName(); |
9188
fb676e23ba51
Rename BasicConfiguration to BasicCompilerConfiguration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9142
diff
changeset
|
72 if (name.endsWith("CompilerConfiguration")) { |
fb676e23ba51
Rename BasicConfiguration to BasicCompilerConfiguration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9142
diff
changeset
|
73 name = name.substring(0, name.length() - "CompilerConfiguration".length()); |
9122
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
74 } |
10508
3e9820de1c1c
New strategy for selecting the default compiler configuration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9987
diff
changeset
|
75 name = name.toLowerCase(); |
3e9820de1c1c
New strategy for selecting the default compiler configuration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9987
diff
changeset
|
76 |
3e9820de1c1c
New strategy for selecting the default compiler configuration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9987
diff
changeset
|
77 configurations.put(name, config); |
19762
b7f2540b28a5
Make sure new "economy" compiler configuration is not picked up as the default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19468
diff
changeset
|
78 if (name.equals("economy")) { |
b7f2540b28a5
Make sure new "economy" compiler configuration is not picked up as the default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19468
diff
changeset
|
79 // ignore economy configuration if not explicitely specified |
b7f2540b28a5
Make sure new "economy" compiler configuration is not picked up as the default.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19468
diff
changeset
|
80 } else if (name.equals("basic")) { |
10508
3e9820de1c1c
New strategy for selecting the default compiler configuration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9987
diff
changeset
|
81 assert basic == null; |
3e9820de1c1c
New strategy for selecting the default compiler configuration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9987
diff
changeset
|
82 basic = config; |
3e9820de1c1c
New strategy for selecting the default compiler configuration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9987
diff
changeset
|
83 } else { |
3e9820de1c1c
New strategy for selecting the default compiler configuration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9987
diff
changeset
|
84 nonBasic = config; |
3e9820de1c1c
New strategy for selecting the default compiler configuration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9987
diff
changeset
|
85 nonBasicCount++; |
3e9820de1c1c
New strategy for selecting the default compiler configuration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9987
diff
changeset
|
86 } |
3e9820de1c1c
New strategy for selecting the default compiler configuration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9987
diff
changeset
|
87 } |
3e9820de1c1c
New strategy for selecting the default compiler configuration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9987
diff
changeset
|
88 |
16871
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
16458
diff
changeset
|
89 if (nonBasicCount == 1) { |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
16458
diff
changeset
|
90 /* |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
16458
diff
changeset
|
91 * There is exactly one non-basic configuration. We use this one as default. |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
16458
diff
changeset
|
92 */ |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
16458
diff
changeset
|
93 defaultConfiguration = nonBasic; |
10508
3e9820de1c1c
New strategy for selecting the default compiler configuration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9987
diff
changeset
|
94 } else { |
16871
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
16458
diff
changeset
|
95 /* |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
16458
diff
changeset
|
96 * There is either no extended configuration available, or more than one. In that case, |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
16458
diff
changeset
|
97 * default to "basic". |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
16458
diff
changeset
|
98 */ |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
16458
diff
changeset
|
99 defaultConfiguration = basic; |
10508
3e9820de1c1c
New strategy for selecting the default compiler configuration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9987
diff
changeset
|
100 if (defaultConfiguration == null) { |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21538
diff
changeset
|
101 throw new JVMCIError("unable to find basic compiler configuration"); |
10508
3e9820de1c1c
New strategy for selecting the default compiler configuration.
Roland Schatz <roland.schatz@oracle.com>
parents:
9987
diff
changeset
|
102 } |
9122
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
103 } |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
104 } |
9001 | 105 |
16458
162c6fba1168
start Stub compilation at mid tier
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15916
diff
changeset
|
106 public Suites(PhaseSuite<HighTierContext> highTier, PhaseSuite<MidTierContext> midTier, PhaseSuite<LowTierContext> lowTier) { |
162c6fba1168
start Stub compilation at mid tier
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15916
diff
changeset
|
107 this.highTier = highTier; |
162c6fba1168
start Stub compilation at mid tier
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15916
diff
changeset
|
108 this.midTier = midTier; |
162c6fba1168
start Stub compilation at mid tier
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15916
diff
changeset
|
109 this.lowTier = lowTier; |
162c6fba1168
start Stub compilation at mid tier
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15916
diff
changeset
|
110 } |
162c6fba1168
start Stub compilation at mid tier
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15916
diff
changeset
|
111 |
9122
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
112 private Suites(CompilerConfiguration config) { |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
113 highTier = config.createHighTier(); |
9137
f5c6a9b0262f
MidTier phase suite.
Roland Schatz <roland.schatz@oracle.com>
parents:
9122
diff
changeset
|
114 midTier = config.createMidTier(); |
9264
3df022b2eebe
LowTier phase suite.
Roland Schatz <roland.schatz@oracle.com>
parents:
9188
diff
changeset
|
115 lowTier = config.createLowTier(); |
9122
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
116 } |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
117 |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
118 public static Suites createDefaultSuites() { |
16871
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
16458
diff
changeset
|
119 String selected = CompilerConfiguration.getValue(); |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
16458
diff
changeset
|
120 if (selected.equals("")) { |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
16458
diff
changeset
|
121 return new Suites(defaultConfiguration); |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
16458
diff
changeset
|
122 } else { |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
16458
diff
changeset
|
123 return createSuites(selected); |
e728b9d4905c
Recompute phase suites when options are changed.
Roland Schatz <roland.schatz@oracle.com>
parents:
16458
diff
changeset
|
124 } |
9122
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
125 } |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
126 |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
127 public static Suites createSuites(String name) { |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
128 CompilerConfiguration config = configurations.get(name); |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
129 if (config == null) { |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21538
diff
changeset
|
130 throw new JVMCIError("unknown compiler configuration: " + name); |
9122
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
131 } |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
132 return new Suites(config); |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
133 } |
dedfff70763f
Compiler configurations.
Roland Schatz <roland.schatz@oracle.com>
parents:
9121
diff
changeset
|
134 |
19270
292442bed972
Rename LowLevelSuites to LIRSuites.
Josef Eisl <josef.eisl@jku.at>
parents:
19230
diff
changeset
|
135 public static LIRSuites createDefaultLIRSuites() { |
19230 | 136 String selected = CompilerConfiguration.getValue(); |
137 if (selected.equals("")) { | |
19468 | 138 return new LIRSuites(defaultConfiguration.createPreAllocationOptimizationStage(), defaultConfiguration.createAllocationStage(), |
139 defaultConfiguration.createPostAllocationOptimizationStage()); | |
19230 | 140 } else { |
19270
292442bed972
Rename LowLevelSuites to LIRSuites.
Josef Eisl <josef.eisl@jku.at>
parents:
19230
diff
changeset
|
141 return createLIRSuites(selected); |
19230 | 142 } |
143 } | |
144 | |
19270
292442bed972
Rename LowLevelSuites to LIRSuites.
Josef Eisl <josef.eisl@jku.at>
parents:
19230
diff
changeset
|
145 public static LIRSuites createLIRSuites(String name) { |
19230 | 146 CompilerConfiguration config = configurations.get(name); |
147 if (config == null) { | |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21538
diff
changeset
|
148 throw new JVMCIError("unknown compiler configuration: " + name); |
19230 | 149 } |
19466
cb7e8c0da978
Rename LIRLowTier to PostAllocationOptimizationStage.
Josef Eisl <josef.eisl@jku.at>
parents:
19465
diff
changeset
|
150 return new LIRSuites(config.createPreAllocationOptimizationStage(), config.createAllocationStage(), config.createPostAllocationOptimizationStage()); |
19230 | 151 } |
152 | |
9001 | 153 } |