comparison jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java @ 23785:5cf445d2acf6 jvmci-0.22

Exported elements referring to inaccessible types in jdk.vm.ci (JDK-8167180)
author Doug Simon <doug.simon@oracle.com>
date Tue, 11 Oct 2016 22:13:23 +0200
parents 5595ab8ba8bd
children 42cc0c2dd4a7
comparison
equal deleted inserted replaced
23784:19222d463306 23785:5cf445d2acf6
25 import jdk.vm.ci.code.CompilationRequest; 25 import jdk.vm.ci.code.CompilationRequest;
26 import jdk.vm.ci.code.CompilationRequestResult; 26 import jdk.vm.ci.code.CompilationRequestResult;
27 import jdk.vm.ci.common.JVMCIError; 27 import jdk.vm.ci.common.JVMCIError;
28 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; 28 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option;
29 import jdk.vm.ci.runtime.JVMCICompiler; 29 import jdk.vm.ci.runtime.JVMCICompiler;
30 import jdk.vm.ci.runtime.JVMCICompilerFactory;
30 import jdk.vm.ci.runtime.JVMCIRuntime; 31 import jdk.vm.ci.runtime.JVMCIRuntime;
31 import jdk.vm.ci.runtime.services.JVMCICompilerFactory; 32 import jdk.vm.ci.services.JVMCIServiceLocator;
32 import jdk.vm.ci.services.Services; 33 import jdk.vm.ci.services.JVMCIPermission;
33 34
34 final class HotSpotJVMCICompilerConfig { 35 final class HotSpotJVMCICompilerConfig {
35 36
36 /** 37 /**
37 * This factory allows JVMCI initialization to succeed but raises an error if the VM asks JVMCI 38 * This factory allows JVMCI initialization to succeed but raises an error if the VM asks JVMCI
38 * to perform a compilation. This allows the reflective parts of the JVMCI API to be used 39 * to perform a compilation. This allows the reflective parts of the JVMCI API to be used
39 * without requiring a compiler implementation to be available. 40 * without requiring a compiler implementation to be available.
40 */ 41 */
41 private static class DummyCompilerFactory extends JVMCICompilerFactory implements JVMCICompiler { 42 private static class DummyCompilerFactory implements JVMCICompilerFactory, JVMCICompiler {
42 43
43 public CompilationRequestResult compileMethod(CompilationRequest request) { 44 public CompilationRequestResult compileMethod(CompilationRequest request) {
44 throw new JVMCIError("no JVMCI compiler selected"); 45 throw new JVMCIError("no JVMCI compiler selected");
45 } 46 }
46 47
62 63
63 /** 64 /**
64 * Gets the selected system compiler factory. 65 * Gets the selected system compiler factory.
65 * 66 *
66 * @return the selected system compiler factory 67 * @return the selected system compiler factory
68 * @throws SecurityException if a security manager is present and it denies
69 * {@link JVMCIPermission} for any {@link JVMCIServiceLocator} loaded by this method
67 */ 70 */
68 static JVMCICompilerFactory getCompilerFactory() { 71 static JVMCICompilerFactory getCompilerFactory() {
69 if (compilerFactory == null) { 72 if (compilerFactory == null) {
70 JVMCICompilerFactory factory = null; 73 JVMCICompilerFactory factory = null;
71 String compilerName = Option.Compiler.getString(); 74 String compilerName = Option.Compiler.getString();
72 if (compilerName != null) { 75 if (compilerName != null) {
73 for (JVMCICompilerFactory f : Services.load(JVMCICompilerFactory.class)) { 76 for (JVMCICompilerFactory f : JVMCIServiceLocator.getProviders(JVMCICompilerFactory.class)) {
74 if (f.getCompilerName().equals(compilerName)) { 77 if (f.getCompilerName().equals(compilerName)) {
75 factory = f; 78 factory = f;
76 } 79 }
77 } 80 }
78 if (factory == null) { 81 if (factory == null) {
79 throw new JVMCIError("JVMCI compiler '%s' not found", compilerName); 82 throw new JVMCIError("JVMCI compiler '%s' not found", compilerName);
80 } 83 }
81 } else { 84 } else {
82 // Auto select a single available compiler 85 // Auto select a single available compiler
83 for (JVMCICompilerFactory f : Services.load(JVMCICompilerFactory.class)) { 86 for (JVMCICompilerFactory f : JVMCIServiceLocator.getProviders(JVMCICompilerFactory.class)) {
84 if (factory == null) { 87 if (factory == null) {
85 factory = f; 88 factory = f;
86 } else { 89 } else {
87 // Multiple factories seen - cancel auto selection 90 // Multiple factories seen - cancel auto selection
88 factory = null; 91 factory = null;