< prev index next >

src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java

Print this page
rev 12121 : 8167180: [JVMCI] Exported elements referring to inaccessible types in jdk.vm.ci


  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  */
  23 package jdk.vm.ci.hotspot;
  24 
  25 import static jdk.vm.ci.common.InitTimer.timer;
  26 
  27 import java.io.IOException;
  28 import java.io.OutputStream;
  29 import java.io.PrintStream;
  30 import java.util.ArrayList;
  31 import java.util.Collections;
  32 import java.util.HashMap;
  33 import java.util.List;
  34 import java.util.Map;
  35 import java.util.Objects;
  36 import java.util.ServiceLoader;
  37 import java.util.TreeMap;
  38 
  39 import jdk.internal.misc.VM;
  40 import jdk.vm.ci.code.Architecture;
  41 import jdk.vm.ci.code.CompilationRequestResult;
  42 import jdk.vm.ci.code.CompiledCode;
  43 import jdk.vm.ci.code.InstalledCode;
  44 import jdk.vm.ci.common.InitTimer;
  45 import jdk.vm.ci.common.JVMCIError;
  46 import jdk.vm.ci.hotspot.services.HotSpotJVMCICompilerFactory;
  47 import jdk.vm.ci.hotspot.services.HotSpotJVMCICompilerFactory.CompilationLevel;
  48 import jdk.vm.ci.hotspot.services.HotSpotVMEventListener;
  49 import jdk.vm.ci.meta.JavaKind;
  50 import jdk.vm.ci.meta.JavaType;
  51 import jdk.vm.ci.meta.ResolvedJavaType;
  52 import jdk.vm.ci.runtime.JVMCI;
  53 import jdk.vm.ci.runtime.JVMCIBackend;
  54 import jdk.vm.ci.runtime.JVMCICompiler;
  55 import jdk.vm.ci.runtime.services.JVMCICompilerFactory;

  56 import jdk.vm.ci.services.Services;
  57 
  58 /**
  59  * HotSpot implementation of a JVMCI runtime.
  60  *
  61  * The initialization of this class is very fragile since it's initialized both through
  62  * {@link JVMCI#initialize()} or through calling {@link HotSpotJVMCIRuntime#runtime()} and
  63  * {@link HotSpotJVMCIRuntime#runtime()} is also called by {@link JVMCI#initialize()}. So this class
  64  * can't have a static initializer and any required initialization must be done as part of
  65  * {@link #runtime()}. This allows the initialization to funnel back through
  66  * {@link JVMCI#initialize()} without deadlocking.
  67  */
  68 public final class HotSpotJVMCIRuntime implements HotSpotJVMCIRuntimeProvider {
  69 
  70     @SuppressWarnings("try")
  71     static class DelayedInit {
  72         private static final HotSpotJVMCIRuntime instance;
  73 
  74         static {
  75             try (InitTimer t = timer("HotSpotJVMCIRuntime.<init>")) {


 229 
 230     private final JVMCICompilerFactory compilerFactory;
 231     private final HotSpotJVMCICompilerFactory hsCompilerFactory;
 232     private volatile JVMCICompiler compiler;
 233     protected final HotSpotJVMCIMetaAccessContext metaAccessContext;
 234 
 235     /**
 236      * Stores the result of {@link HotSpotJVMCICompilerFactory#getCompilationLevelAdjustment} so
 237      * that it can be read from the VM.
 238      */
 239     @SuppressWarnings("unused") private final int compilationLevelAdjustment;
 240 
 241     private final Map<Class<? extends Architecture>, JVMCIBackend> backends = new HashMap<>();
 242 
 243     private volatile List<HotSpotVMEventListener> vmEventListeners;
 244 
 245     private Iterable<HotSpotVMEventListener> getVmEventListeners() {
 246         if (vmEventListeners == null) {
 247             synchronized (this) {
 248                 if (vmEventListeners == null) {
 249                     List<HotSpotVMEventListener> listeners = new ArrayList<>();
 250                     for (HotSpotVMEventListener vmEventListener : ServiceLoader.load(HotSpotVMEventListener.class)) {
 251                         listeners.add(vmEventListener);
 252                     }
 253                     vmEventListeners = listeners;
 254                 }
 255             }
 256         }
 257         return vmEventListeners;
 258     }
 259 
 260     /**
 261      * Stores the result of {@link HotSpotJVMCICompilerFactory#getTrivialPrefixes()} so that it can
 262      * be read from the VM.
 263      */
 264     @SuppressWarnings("unused") private final String[] trivialPrefixes;
 265 
 266     @SuppressWarnings("try")
 267     private HotSpotJVMCIRuntime() {
 268         compilerToVm = new CompilerToVM();
 269 
 270         try (InitTimer t = timer("HotSpotVMConfig<init>")) {
 271             configStore = new HotSpotVMConfigStore(compilerToVm);
 272             config = new HotSpotVMConfig(configStore);
 273         }




  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  */
  23 package jdk.vm.ci.hotspot;
  24 
  25 import static jdk.vm.ci.common.InitTimer.timer;
  26 
  27 import java.io.IOException;
  28 import java.io.OutputStream;
  29 import java.io.PrintStream;

  30 import java.util.Collections;
  31 import java.util.HashMap;
  32 import java.util.List;
  33 import java.util.Map;
  34 import java.util.Objects;

  35 import java.util.TreeMap;
  36 
  37 import jdk.internal.misc.VM;
  38 import jdk.vm.ci.code.Architecture;
  39 import jdk.vm.ci.code.CompilationRequestResult;
  40 import jdk.vm.ci.code.CompiledCode;
  41 import jdk.vm.ci.code.InstalledCode;
  42 import jdk.vm.ci.common.InitTimer;
  43 import jdk.vm.ci.common.JVMCIError;
  44 import jdk.vm.ci.hotspot.HotSpotJVMCICompilerFactory.CompilationLevel;


  45 import jdk.vm.ci.meta.JavaKind;
  46 import jdk.vm.ci.meta.JavaType;
  47 import jdk.vm.ci.meta.ResolvedJavaType;
  48 import jdk.vm.ci.runtime.JVMCI;
  49 import jdk.vm.ci.runtime.JVMCIBackend;
  50 import jdk.vm.ci.runtime.JVMCICompiler;
  51 import jdk.vm.ci.runtime.JVMCICompilerFactory;
  52 import jdk.vm.ci.services.JVMCIServiceLocator;
  53 import jdk.vm.ci.services.Services;
  54 
  55 /**
  56  * HotSpot implementation of a JVMCI runtime.
  57  *
  58  * The initialization of this class is very fragile since it's initialized both through
  59  * {@link JVMCI#initialize()} or through calling {@link HotSpotJVMCIRuntime#runtime()} and
  60  * {@link HotSpotJVMCIRuntime#runtime()} is also called by {@link JVMCI#initialize()}. So this class
  61  * can't have a static initializer and any required initialization must be done as part of
  62  * {@link #runtime()}. This allows the initialization to funnel back through
  63  * {@link JVMCI#initialize()} without deadlocking.
  64  */
  65 public final class HotSpotJVMCIRuntime implements HotSpotJVMCIRuntimeProvider {
  66 
  67     @SuppressWarnings("try")
  68     static class DelayedInit {
  69         private static final HotSpotJVMCIRuntime instance;
  70 
  71         static {
  72             try (InitTimer t = timer("HotSpotJVMCIRuntime.<init>")) {


 226 
 227     private final JVMCICompilerFactory compilerFactory;
 228     private final HotSpotJVMCICompilerFactory hsCompilerFactory;
 229     private volatile JVMCICompiler compiler;
 230     protected final HotSpotJVMCIMetaAccessContext metaAccessContext;
 231 
 232     /**
 233      * Stores the result of {@link HotSpotJVMCICompilerFactory#getCompilationLevelAdjustment} so
 234      * that it can be read from the VM.
 235      */
 236     @SuppressWarnings("unused") private final int compilationLevelAdjustment;
 237 
 238     private final Map<Class<? extends Architecture>, JVMCIBackend> backends = new HashMap<>();
 239 
 240     private volatile List<HotSpotVMEventListener> vmEventListeners;
 241 
 242     private Iterable<HotSpotVMEventListener> getVmEventListeners() {
 243         if (vmEventListeners == null) {
 244             synchronized (this) {
 245                 if (vmEventListeners == null) {
 246                     vmEventListeners = JVMCIServiceLocator.getProviders(HotSpotVMEventListener.class);




 247                 }
 248             }
 249         }
 250         return vmEventListeners;
 251     }
 252 
 253     /**
 254      * Stores the result of {@link HotSpotJVMCICompilerFactory#getTrivialPrefixes()} so that it can
 255      * be read from the VM.
 256      */
 257     @SuppressWarnings("unused") private final String[] trivialPrefixes;
 258 
 259     @SuppressWarnings("try")
 260     private HotSpotJVMCIRuntime() {
 261         compilerToVm = new CompilerToVM();
 262 
 263         try (InitTimer t = timer("HotSpotVMConfig<init>")) {
 264             configStore = new HotSpotVMConfigStore(compilerToVm);
 265             config = new HotSpotVMConfig(configStore);
 266         }


< prev index next >