Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java @ 23723:3db9e47b477a
simplified JVMCI compiler auto selection (JDK-8160730)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Sun, 03 Jul 2016 00:13:22 +0200 |
parents | c61554b3f6df |
children | 5595ab8ba8bd |
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 |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22623
diff
changeset
|
25 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
|
26 import jdk.vm.ci.code.CompilationRequestResult; |
23392
b3a816d3b844
Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents:
23387
diff
changeset
|
27 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
|
28 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
|
29 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
|
30 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
|
31 import jdk.vm.ci.runtime.services.JVMCICompilerFactory; |
22761
f2206f5bb62e
removed @ServiceProvider mechanism (GRAAL-1380)
Doug Simon <doug.simon@oracle.com>
parents:
22697
diff
changeset
|
32 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
|
33 |
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
34 final class HotSpotJVMCICompilerConfig { |
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
35 |
23358
7eaa740eaca2
make JVMCICompilerFactory an abstract class with security checks (JDK-8155622)
Doug Simon <doug.simon@oracle.com>
parents:
23319
diff
changeset
|
36 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
|
37 |
22770
1fbfcc0334d3
JVMCI PrintCompilation support should reuse CompileBroker logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22767
diff
changeset
|
38 public CompilationRequestResult compileMethod(CompilationRequest request) { |
23392
b3a816d3b844
Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents:
23387
diff
changeset
|
39 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
|
40 } |
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
41 |
23358
7eaa740eaca2
make JVMCICompilerFactory an abstract class with security checks (JDK-8155622)
Doug Simon <doug.simon@oracle.com>
parents:
23319
diff
changeset
|
42 @Override |
22429
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
43 public String getCompilerName() { |
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
44 return "<none>"; |
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 |
22697
57646377e480
Rename Compiler to JVMCICompiler and expose it from JVMCIRuntime.
Roland Schatz <roland.schatz@oracle.com>
parents:
22672
diff
changeset
|
48 public JVMCICompiler createCompiler(JVMCIRuntime runtime) { |
22429
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
49 return this; |
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 } |
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
52 |
23319
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
53 /** |
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
54 * 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
|
55 */ |
22697
57646377e480
Rename Compiler to JVMCICompiler and expose it from JVMCIRuntime.
Roland Schatz <roland.schatz@oracle.com>
parents:
22672
diff
changeset
|
56 private static JVMCICompilerFactory compilerFactory; |
22429
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
57 |
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
58 /** |
23319
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
59 * Gets the selected system compiler factory. |
22437
c88c31c60755
Improved JavaDoc on HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22429
diff
changeset
|
60 * |
23319
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
61 * @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
|
62 */ |
22697
57646377e480
Rename Compiler to JVMCICompiler and expose it from JVMCIRuntime.
Roland Schatz <roland.schatz@oracle.com>
parents:
22672
diff
changeset
|
63 static JVMCICompilerFactory getCompilerFactory() { |
22429
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
64 if (compilerFactory == null) { |
23319
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
65 JVMCICompilerFactory factory = null; |
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
66 String compilerName = Option.Compiler.getString(); |
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
67 if (compilerName != null) { |
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
68 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
|
69 if (f.getCompilerName().equals(compilerName)) { |
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
70 factory = f; |
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
71 } |
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
72 } |
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
73 if (factory == null) { |
23392
b3a816d3b844
Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents:
23387
diff
changeset
|
74 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
|
75 } |
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
76 } else { |
23723
3db9e47b477a
simplified JVMCI compiler auto selection (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23721
diff
changeset
|
77 // Auto select a single available compiler |
23721
c61554b3f6df
compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23392
diff
changeset
|
78 for (JVMCICompilerFactory f : Services.load(JVMCICompilerFactory.class)) { |
23723
3db9e47b477a
simplified JVMCI compiler auto selection (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23721
diff
changeset
|
79 if (factory == null) { |
3db9e47b477a
simplified JVMCI compiler auto selection (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23721
diff
changeset
|
80 factory = f; |
3db9e47b477a
simplified JVMCI compiler auto selection (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23721
diff
changeset
|
81 } else { |
3db9e47b477a
simplified JVMCI compiler auto selection (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23721
diff
changeset
|
82 // Multiple factories seen - cancel auto selection |
3db9e47b477a
simplified JVMCI compiler auto selection (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23721
diff
changeset
|
83 factory = null; |
3db9e47b477a
simplified JVMCI compiler auto selection (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23721
diff
changeset
|
84 break; |
3db9e47b477a
simplified JVMCI compiler auto selection (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23721
diff
changeset
|
85 } |
23721
c61554b3f6df
compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23392
diff
changeset
|
86 } |
23723
3db9e47b477a
simplified JVMCI compiler auto selection (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23721
diff
changeset
|
87 if (factory == null) { |
23721
c61554b3f6df
compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23392
diff
changeset
|
88 factory = new DummyCompilerFactory(); |
c61554b3f6df
compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23392
diff
changeset
|
89 } |
23319
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
90 } |
23723
3db9e47b477a
simplified JVMCI compiler auto selection (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23721
diff
changeset
|
91 factory.onSelection(); |
23319
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
92 compilerFactory = factory; |
22429
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
93 } |
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
94 return compilerFactory; |
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
95 } |
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
96 } |