Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java @ 23789:0cb263db490f
use MethodParameters attribute instead of depending on -g option for sanity checks (JDK-8168915)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 04 Nov 2016 14:22:47 +0100 |
parents | 5cf445d2acf6 |
children | 42cc0c2dd4a7 |
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; |
23785
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23725
diff
changeset
|
30 import jdk.vm.ci.runtime.JVMCICompilerFactory; |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22623
diff
changeset
|
31 import jdk.vm.ci.runtime.JVMCIRuntime; |
23785
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23725
diff
changeset
|
32 import jdk.vm.ci.services.JVMCIServiceLocator; |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23725
diff
changeset
|
33 import jdk.vm.ci.services.JVMCIPermission; |
22429
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
34 |
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
35 final class HotSpotJVMCICompilerConfig { |
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
36 |
23725
5595ab8ba8bd
documented DummyCompilerFactory
Doug Simon <doug.simon@oracle.com>
parents:
23723
diff
changeset
|
37 /** |
5595ab8ba8bd
documented DummyCompilerFactory
Doug Simon <doug.simon@oracle.com>
parents:
23723
diff
changeset
|
38 * This factory allows JVMCI initialization to succeed but raises an error if the VM asks JVMCI |
5595ab8ba8bd
documented DummyCompilerFactory
Doug Simon <doug.simon@oracle.com>
parents:
23723
diff
changeset
|
39 * to perform a compilation. This allows the reflective parts of the JVMCI API to be used |
5595ab8ba8bd
documented DummyCompilerFactory
Doug Simon <doug.simon@oracle.com>
parents:
23723
diff
changeset
|
40 * without requiring a compiler implementation to be available. |
5595ab8ba8bd
documented DummyCompilerFactory
Doug Simon <doug.simon@oracle.com>
parents:
23723
diff
changeset
|
41 */ |
23785
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23725
diff
changeset
|
42 private static class DummyCompilerFactory implements JVMCICompilerFactory, JVMCICompiler { |
22429
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
43 |
22770
1fbfcc0334d3
JVMCI PrintCompilation support should reuse CompileBroker logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22767
diff
changeset
|
44 public CompilationRequestResult compileMethod(CompilationRequest request) { |
23392
b3a816d3b844
Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents:
23387
diff
changeset
|
45 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
|
46 } |
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
47 |
23358
7eaa740eaca2
make JVMCICompilerFactory an abstract class with security checks (JDK-8155622)
Doug Simon <doug.simon@oracle.com>
parents:
23319
diff
changeset
|
48 @Override |
22429
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
49 public String getCompilerName() { |
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
50 return "<none>"; |
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 |
23358
7eaa740eaca2
make JVMCICompilerFactory an abstract class with security checks (JDK-8155622)
Doug Simon <doug.simon@oracle.com>
parents:
23319
diff
changeset
|
53 @Override |
22697
57646377e480
Rename Compiler to JVMCICompiler and expose it from JVMCIRuntime.
Roland Schatz <roland.schatz@oracle.com>
parents:
22672
diff
changeset
|
54 public JVMCICompiler createCompiler(JVMCIRuntime runtime) { |
22429
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
55 return this; |
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 } |
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 /** |
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
60 * 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
|
61 */ |
22697
57646377e480
Rename Compiler to JVMCICompiler and expose it from JVMCIRuntime.
Roland Schatz <roland.schatz@oracle.com>
parents:
22672
diff
changeset
|
62 private static JVMCICompilerFactory compilerFactory; |
22429
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
63 |
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
64 /** |
23319
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
65 * Gets the selected system compiler factory. |
22437
c88c31c60755
Improved JavaDoc on HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22429
diff
changeset
|
66 * |
23319
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
67 * @return the selected system compiler factory |
23785
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23725
diff
changeset
|
68 * @throws SecurityException if a security manager is present and it denies |
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23725
diff
changeset
|
69 * {@link JVMCIPermission} for any {@link JVMCIServiceLocator} loaded by this method |
22429
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
70 */ |
22697
57646377e480
Rename Compiler to JVMCICompiler and expose it from JVMCIRuntime.
Roland Schatz <roland.schatz@oracle.com>
parents:
22672
diff
changeset
|
71 static JVMCICompilerFactory getCompilerFactory() { |
22429
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
72 if (compilerFactory == null) { |
23319
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
73 JVMCICompilerFactory factory = null; |
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
74 String compilerName = Option.Compiler.getString(); |
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
75 if (compilerName != null) { |
23785
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23725
diff
changeset
|
76 for (JVMCICompilerFactory f : JVMCIServiceLocator.getProviders(JVMCICompilerFactory.class)) { |
23319
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
77 if (f.getCompilerName().equals(compilerName)) { |
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
78 factory = f; |
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
79 } |
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
80 } |
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
81 if (factory == null) { |
23392
b3a816d3b844
Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents:
23387
diff
changeset
|
82 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
|
83 } |
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
84 } else { |
23723
3db9e47b477a
simplified JVMCI compiler auto selection (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23721
diff
changeset
|
85 // Auto select a single available compiler |
23785
5cf445d2acf6
Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
Doug Simon <doug.simon@oracle.com>
parents:
23725
diff
changeset
|
86 for (JVMCICompilerFactory f : JVMCIServiceLocator.getProviders(JVMCICompilerFactory.class)) { |
23723
3db9e47b477a
simplified JVMCI compiler auto selection (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23721
diff
changeset
|
87 if (factory == null) { |
3db9e47b477a
simplified JVMCI compiler auto selection (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23721
diff
changeset
|
88 factory = f; |
3db9e47b477a
simplified JVMCI compiler auto selection (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23721
diff
changeset
|
89 } else { |
3db9e47b477a
simplified JVMCI compiler auto selection (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23721
diff
changeset
|
90 // Multiple factories seen - cancel auto selection |
3db9e47b477a
simplified JVMCI compiler auto selection (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23721
diff
changeset
|
91 factory = null; |
3db9e47b477a
simplified JVMCI compiler auto selection (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23721
diff
changeset
|
92 break; |
3db9e47b477a
simplified JVMCI compiler auto selection (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23721
diff
changeset
|
93 } |
23721
c61554b3f6df
compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23392
diff
changeset
|
94 } |
23723
3db9e47b477a
simplified JVMCI compiler auto selection (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23721
diff
changeset
|
95 if (factory == null) { |
23721
c61554b3f6df
compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23392
diff
changeset
|
96 factory = new DummyCompilerFactory(); |
c61554b3f6df
compiler selection should work without -Djvmci.Compiler (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23392
diff
changeset
|
97 } |
23319
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
98 } |
23723
3db9e47b477a
simplified JVMCI compiler auto selection (JDK-8160730)
Doug Simon <doug.simon@oracle.com>
parents:
23721
diff
changeset
|
99 factory.onSelection(); |
23319
c1935b089c01
8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
Roland Schatz <roland.schatz@oracle.com>
parents:
22770
diff
changeset
|
100 compilerFactory = factory; |
22429
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
101 } |
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
102 return compilerFactory; |
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
103 } |
a1b0a76567c7
Select default compiler from jvmci.compiler system property.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
104 } |