< prev index next >

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

Print this page




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  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 jdk.vm.ci.common.*;
  26 import jdk.vm.ci.compiler.Compiler;
  27 import jdk.vm.ci.meta.*;
  28 import jdk.vm.ci.runtime.*;
  29 import sun.misc.*;




  30 
  31 //JaCoCo Exclude
  32 
  33 /**
  34  * Configuration information for the HotSpot JVMCI runtime.
  35  */
  36 public interface HotSpotJVMCIRuntimeProvider extends JVMCIRuntime {
  37 
  38     HotSpotVMConfig getConfig();
  39 
  40     CompilerToVM getCompilerToVM();
  41 
  42     Compiler getCompiler();



  43 
  44     /**
  45      * Converts a name to a Java type. This method attempts to resolve {@code name} to a
  46      * {@link ResolvedJavaType}.
  47      *
  48      * @param name a well formed Java type in {@linkplain JavaType#getName() internal} format
  49      * @param accessingType the context of resolution which must be non-null
  50      * @param resolve specifies whether resolution failure results in an unresolved type being
  51      *            return or a {@link LinkageError} being thrown
  52      * @return a Java type for {@code name} which is guaranteed to be of type
  53      *         {@link ResolvedJavaType} if {@code resolve == true}
  54      * @throws LinkageError if {@code resolve == true} and the resolution failed
  55      * @throws NullPointerException if {@code accessingClass} is {@code null}
  56      */
  57     JavaType lookupType(String name, HotSpotResolvedObjectType accessingType, boolean resolve);
  58 
  59     /**
  60      * Gets the JVMCI mirror for a {@link Class} object.
  61      *
  62      * @return the {@link ResolvedJavaType} corresponding to {@code javaClass}
  63      */
  64     ResolvedJavaType fromClass(Class<?> clazz);
  65 
  66     JVMCIMetaAccessContext getMetaAccessContext();
  67 
  68     /**
  69      * The offset from the origin of an array to the first element.
  70      *
  71      * @return the offset in bytes
  72      */
  73     default int getArrayBaseOffset(JavaKind kind) {
  74         switch (kind) {
  75             case Boolean:
  76                 return Unsafe.ARRAY_BOOLEAN_BASE_OFFSET;
  77             case Byte:
  78                 return Unsafe.ARRAY_BYTE_BASE_OFFSET;
  79             case Char:
  80                 return Unsafe.ARRAY_CHAR_BASE_OFFSET;
  81             case Short:
  82                 return Unsafe.ARRAY_SHORT_BASE_OFFSET;
  83             case Int:
  84                 return Unsafe.ARRAY_INT_BASE_OFFSET;
  85             case Long:
  86                 return Unsafe.ARRAY_LONG_BASE_OFFSET;
  87             case Float:
  88                 return Unsafe.ARRAY_FLOAT_BASE_OFFSET;
  89             case Double:
  90                 return Unsafe.ARRAY_DOUBLE_BASE_OFFSET;
  91             case Object:
  92                 return Unsafe.ARRAY_OBJECT_BASE_OFFSET;
  93             default:
  94                 throw new JVMCIError("%s", kind);
  95         }
  96     }
  97 
  98     /**
  99      * The scale used for the index when accessing elements of an array of this kind.
 100      *
 101      * @return the scale in order to convert the index into a byte offset
 102      */
 103     default int getArrayIndexScale(JavaKind kind) {
 104         switch (kind) {
 105             case Boolean:
 106                 return Unsafe.ARRAY_BOOLEAN_INDEX_SCALE;
 107             case Byte:
 108                 return Unsafe.ARRAY_BYTE_INDEX_SCALE;
 109             case Char:
 110                 return Unsafe.ARRAY_CHAR_INDEX_SCALE;
 111             case Short:
 112                 return Unsafe.ARRAY_SHORT_INDEX_SCALE;
 113             case Int:
 114                 return Unsafe.ARRAY_INT_INDEX_SCALE;
 115             case Long:
 116                 return Unsafe.ARRAY_LONG_INDEX_SCALE;
 117             case Float:
 118                 return Unsafe.ARRAY_FLOAT_INDEX_SCALE;
 119             case Double:
 120                 return Unsafe.ARRAY_DOUBLE_INDEX_SCALE;
 121             case Object:
 122                 return Unsafe.ARRAY_OBJECT_INDEX_SCALE;
 123             default:


   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  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 java.io.OutputStream;
  26 
  27 import jdk.vm.ci.common.JVMCIError;
  28 import jdk.vm.ci.meta.JVMCIMetaAccessContext;
  29 import jdk.vm.ci.meta.JavaKind;
  30 import jdk.vm.ci.meta.JavaType;
  31 import jdk.vm.ci.meta.ResolvedJavaType;
  32 import jdk.vm.ci.runtime.JVMCIRuntime;
  33 import sun.misc.Unsafe;
  34 
  35 //JaCoCo Exclude
  36 
  37 /**
  38  * Configuration information for the HotSpot JVMCI runtime.
  39  */
  40 public interface HotSpotJVMCIRuntimeProvider extends JVMCIRuntime {
  41 
  42     HotSpotVMConfig getConfig();
  43 
  44     CompilerToVM getCompilerToVM();
  45 
  46     /**
  47      * Gets an output stream that writes to the HotSpot's {@code tty} stream.
  48      */
  49     OutputStream getLogStream();
  50 
  51     /**
  52      * Converts a name to a Java type. This method attempts to resolve {@code name} to a
  53      * {@link ResolvedJavaType}.
  54      *
  55      * @param name a well formed Java type in {@linkplain JavaType#getName() internal} format
  56      * @param accessingType the context of resolution which must be non-null
  57      * @param resolve specifies whether resolution failure results in an unresolved type being
  58      *            return or a {@link LinkageError} being thrown
  59      * @return a Java type for {@code name} which is guaranteed to be of type
  60      *         {@link ResolvedJavaType} if {@code resolve == true}
  61      * @throws LinkageError if {@code resolve == true} and the resolution failed
  62      * @throws NullPointerException if {@code accessingClass} is {@code null}
  63      */
  64     JavaType lookupType(String name, HotSpotResolvedObjectType accessingType, boolean resolve);
  65 
  66     /**
  67      * Gets the JVMCI mirror for a {@link Class} object.
  68      *
  69      * @return the {@link ResolvedJavaType} corresponding to {@code javaClass}
  70      */
  71     ResolvedJavaType fromClass(Class<?> clazz);
  72 
  73     JVMCIMetaAccessContext getMetaAccessContext();
  74 
  75     /**
  76      * The offset from the origin of an array to the first element.
  77      *
  78      * @return the offset in bytes
  79      */
  80     static int getArrayBaseOffset(JavaKind kind) {
  81         switch (kind) {
  82             case Boolean:
  83                 return Unsafe.ARRAY_BOOLEAN_BASE_OFFSET;
  84             case Byte:
  85                 return Unsafe.ARRAY_BYTE_BASE_OFFSET;
  86             case Char:
  87                 return Unsafe.ARRAY_CHAR_BASE_OFFSET;
  88             case Short:
  89                 return Unsafe.ARRAY_SHORT_BASE_OFFSET;
  90             case Int:
  91                 return Unsafe.ARRAY_INT_BASE_OFFSET;
  92             case Long:
  93                 return Unsafe.ARRAY_LONG_BASE_OFFSET;
  94             case Float:
  95                 return Unsafe.ARRAY_FLOAT_BASE_OFFSET;
  96             case Double:
  97                 return Unsafe.ARRAY_DOUBLE_BASE_OFFSET;
  98             case Object:
  99                 return Unsafe.ARRAY_OBJECT_BASE_OFFSET;
 100             default:
 101                 throw new JVMCIError("%s", kind);
 102         }
 103     }
 104 
 105     /**
 106      * The scale used for the index when accessing elements of an array of this kind.
 107      *
 108      * @return the scale in order to convert the index into a byte offset
 109      */
 110     static int getArrayIndexScale(JavaKind kind) {
 111         switch (kind) {
 112             case Boolean:
 113                 return Unsafe.ARRAY_BOOLEAN_INDEX_SCALE;
 114             case Byte:
 115                 return Unsafe.ARRAY_BYTE_INDEX_SCALE;
 116             case Char:
 117                 return Unsafe.ARRAY_CHAR_INDEX_SCALE;
 118             case Short:
 119                 return Unsafe.ARRAY_SHORT_INDEX_SCALE;
 120             case Int:
 121                 return Unsafe.ARRAY_INT_INDEX_SCALE;
 122             case Long:
 123                 return Unsafe.ARRAY_LONG_INDEX_SCALE;
 124             case Float:
 125                 return Unsafe.ARRAY_FLOAT_INDEX_SCALE;
 126             case Double:
 127                 return Unsafe.ARRAY_DOUBLE_INDEX_SCALE;
 128             case Object:
 129                 return Unsafe.ARRAY_OBJECT_INDEX_SCALE;
 130             default:
< prev index next >