annotate jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java @ 23721:c61554b3f6df

compiler selection should work without -Djvmci.Compiler (JDK-8160730)
author Doug Simon <doug.simon@oracle.com>
date Sat, 02 Jul 2016 01:00:12 +0200
parents b3a816d3b844
children 3db9e47b477a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22429
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
1 /*
23319
c1935b089c01 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
2 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
22429
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
4 *
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
8 *
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
13 * accompanied this code).
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
14 *
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
18 *
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
21 * questions.
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
22 */
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22623
diff changeset
23 package jdk.vm.ci.hotspot;
22429
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
24
23721
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
25 import java.util.ArrayList;
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
26 import java.util.Collections;
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
27 import java.util.Comparator;
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
28
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22623
diff changeset
29 import jdk.vm.ci.code.CompilationRequest;
22770
1fbfcc0334d3 JVMCI PrintCompilation support should reuse CompileBroker logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22767
diff changeset
30 import jdk.vm.ci.code.CompilationRequestResult;
23392
b3a816d3b844 Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents: 23387
diff changeset
31 import jdk.vm.ci.common.JVMCIError;
23319
c1935b089c01 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
32 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option;
22697
57646377e480 Rename Compiler to JVMCICompiler and expose it from JVMCIRuntime.
Roland Schatz <roland.schatz@oracle.com>
parents: 22672
diff changeset
33 import jdk.vm.ci.runtime.JVMCICompiler;
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22623
diff changeset
34 import jdk.vm.ci.runtime.JVMCIRuntime;
23363
56479400913e jdk.vm.ci needs to securely export services (JDK-8155023)
Doug Simon <doug.simon@oracle.com>
parents: 23358
diff changeset
35 import jdk.vm.ci.runtime.services.JVMCICompilerFactory;
23721
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
36 import jdk.vm.ci.runtime.services.JVMCICompilerFactory.AutoSelectionPrecedence;
22761
f2206f5bb62e removed @ServiceProvider mechanism (GRAAL-1380)
Doug Simon <doug.simon@oracle.com>
parents: 22697
diff changeset
37 import jdk.vm.ci.services.Services;
22429
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
38
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
39 final class HotSpotJVMCICompilerConfig {
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
40
23358
7eaa740eaca2 make JVMCICompilerFactory an abstract class with security checks (JDK-8155622)
Doug Simon <doug.simon@oracle.com>
parents: 23319
diff changeset
41 private static class DummyCompilerFactory extends JVMCICompilerFactory implements JVMCICompiler {
22429
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
42
22770
1fbfcc0334d3 JVMCI PrintCompilation support should reuse CompileBroker logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22767
diff changeset
43 public CompilationRequestResult compileMethod(CompilationRequest request) {
23392
b3a816d3b844 Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents: 23387
diff changeset
44 throw new JVMCIError("no JVMCI compiler selected");
22429
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
45 }
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
46
23358
7eaa740eaca2 make JVMCICompilerFactory an abstract class with security checks (JDK-8155622)
Doug Simon <doug.simon@oracle.com>
parents: 23319
diff changeset
47 @Override
22429
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
48 public String getCompilerName() {
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
49 return "<none>";
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
50 }
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
51
23358
7eaa740eaca2 make JVMCICompilerFactory an abstract class with security checks (JDK-8155622)
Doug Simon <doug.simon@oracle.com>
parents: 23319
diff changeset
52 @Override
22697
57646377e480 Rename Compiler to JVMCICompiler and expose it from JVMCIRuntime.
Roland Schatz <roland.schatz@oracle.com>
parents: 22672
diff changeset
53 public JVMCICompiler createCompiler(JVMCIRuntime runtime) {
22429
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
54 return this;
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
55 }
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
56 }
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
57
23319
c1935b089c01 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
58 /**
c1935b089c01 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
59 * Factory of the selected system compiler.
c1935b089c01 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
60 */
22697
57646377e480 Rename Compiler to JVMCICompiler and expose it from JVMCIRuntime.
Roland Schatz <roland.schatz@oracle.com>
parents: 22672
diff changeset
61 private static JVMCICompilerFactory compilerFactory;
22429
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
62
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
63 /**
23721
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
64 * Comparator that sorts available {@link JVMCICompilerFactory} objects according to their
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
65 * {@link JVMCICompilerFactory#getAutoSelectionRelationTo(JVMCICompilerFactory) relative}
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
66 * auto-selection preferences. Factories with higher preferences are sorted earlier. If a
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
67 */
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
68 static class FactoryComparator implements Comparator<JVMCICompilerFactory> {
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
69
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
70 /**
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
71 * Compares two compiler factories and returns -1 if {@code o1} should be auto-selected over
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
72 * {@code o2}, -1 if {@code o1} should be auto-selected over {@code o2} or 0 if
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
73 * {@code o1 == o2 || o1.getClass() == o2.getClass()}.
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
74 *
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
75 * @throws JVMCIError there is no auto-selection preference relation between {@code o1} and
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
76 * {@code o2}
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
77 */
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
78 public int compare(JVMCICompilerFactory o1, JVMCICompilerFactory o2) {
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
79 if (o1 == o2 || o1.getClass() == o2.getClass()) {
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
80 return 0;
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
81 }
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
82 AutoSelectionPrecedence o1Precedence = o1.getAutoSelectionRelationTo(o2);
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
83 AutoSelectionPrecedence o2Precedence = o2.getAutoSelectionRelationTo(o1);
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
84 switch (o1Precedence) {
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
85 case HIGHER: {
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
86 assert o2Precedence != o1Precedence : "auto selection precedence of " + o1 + " and " + o2 + " cannot both be " + o1Precedence;
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
87 return -1;
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
88 }
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
89 case LOWER: {
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
90 assert o2Precedence != o1Precedence : "auto selection precedence of " + o1 + " and " + o2 + " cannot both be " + o1Precedence;
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
91 return 1;
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
92 }
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
93 case UNRELATED: {
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
94 switch (o2Precedence) {
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
95 case HIGHER: {
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
96 return 1;
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
97 }
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
98 case LOWER: {
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
99 return -1;
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
100 }
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
101 default:
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
102 break;
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
103 }
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
104 }
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
105 }
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
106 // No auto-selection preference relation between o1 and o2
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
107 throw new JVMCIError("JVMCI compiler must be specified with the '%s' system property", Option.JVMCI_OPTION_PROPERTY_PREFIX + Option.Compiler);
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
108 }
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
109 }
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
110
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
111 /**
23319
c1935b089c01 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
112 * Gets the selected system compiler factory.
22437
c88c31c60755 Improved JavaDoc on HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents: 22429
diff changeset
113 *
23319
c1935b089c01 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
114 * @return the selected system compiler factory
22429
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
115 */
22697
57646377e480 Rename Compiler to JVMCICompiler and expose it from JVMCIRuntime.
Roland Schatz <roland.schatz@oracle.com>
parents: 22672
diff changeset
116 static JVMCICompilerFactory getCompilerFactory() {
22429
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
117 if (compilerFactory == null) {
23319
c1935b089c01 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
118 JVMCICompilerFactory factory = null;
c1935b089c01 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
119 String compilerName = Option.Compiler.getString();
c1935b089c01 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
120 if (compilerName != null) {
c1935b089c01 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
121 for (JVMCICompilerFactory f : Services.load(JVMCICompilerFactory.class)) {
c1935b089c01 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
122 if (f.getCompilerName().equals(compilerName)) {
c1935b089c01 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
123 factory = f;
c1935b089c01 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
124 }
c1935b089c01 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
125 }
c1935b089c01 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
126 if (factory == null) {
23392
b3a816d3b844 Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents: 23387
diff changeset
127 throw new JVMCIError("JVMCI compiler '%s' not found", compilerName);
23319
c1935b089c01 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
128 }
c1935b089c01 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
129 } else {
23721
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
130 // Auto selection
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
131 ArrayList<JVMCICompilerFactory> factories = new ArrayList<>();
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
132 for (JVMCICompilerFactory f : Services.load(JVMCICompilerFactory.class)) {
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
133 factories.add(f);
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
134 }
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
135 if (!factories.isEmpty()) {
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
136 if (factories.size() == 1) {
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
137 factory = factories.get(0);
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
138 } else {
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
139 Collections.sort(factories, new FactoryComparator());
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
140 factory = factories.get(0);
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
141 }
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
142 } else {
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
143 factory = new DummyCompilerFactory();
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
144 }
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
145 factory.onSelection();
23319
c1935b089c01 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
146 }
23721
c61554b3f6df compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
147 assert factory != null;
23319
c1935b089c01 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents: 22770
diff changeset
148 compilerFactory = factory;
22429
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
149 }
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
150 return compilerFactory;
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
151 }
a1b0a76567c7 Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
152 }