src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotHostBackend.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotHostBackend.java

Print this page




   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 org.graalvm.compiler.hotspot;
  24 
  25 import static jdk.vm.ci.code.CodeUtil.K;
  26 import static jdk.vm.ci.code.CodeUtil.getCallingConvention;
  27 import static jdk.vm.ci.common.InitTimer.timer;
  28 


  29 import org.graalvm.compiler.core.common.NumUtil;
  30 import org.graalvm.compiler.core.common.spi.ForeignCallDescriptor;

  31 import org.graalvm.compiler.hotspot.meta.HotSpotHostForeignCallsProvider;
  32 import org.graalvm.compiler.hotspot.meta.HotSpotLoweringProvider;
  33 import org.graalvm.compiler.hotspot.meta.HotSpotProviders;
  34 import org.graalvm.compiler.hotspot.stubs.Stub;
  35 import org.graalvm.compiler.lir.asm.CompilationResultBuilder;
  36 import org.graalvm.compiler.lir.framemap.ReferenceMapBuilder;
  37 import org.graalvm.compiler.nodes.StructuredGraph;
  38 import org.graalvm.compiler.options.OptionValues;

  39 
  40 import jdk.vm.ci.code.CallingConvention;
  41 import jdk.vm.ci.common.InitTimer;
  42 import jdk.vm.ci.hotspot.HotSpotCallingConventionType;
  43 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
  44 import jdk.vm.ci.meta.JavaType;
  45 import jdk.vm.ci.runtime.JVMCICompiler;
  46 
  47 /**
  48  * Common functionality of HotSpot host backends.
  49  */
  50 public abstract class HotSpotHostBackend extends HotSpotBackend {
  51 
  52     /**
  53      * Descriptor for {@code SharedRuntime::deopt_blob()->unpack()}.
  54      */
  55     public static final ForeignCallDescriptor DEOPTIMIZATION_HANDLER = new ForeignCallDescriptor("deoptHandler", void.class);
  56 
  57     /**
  58      * Descriptor for {@code SharedRuntime::deopt_blob()->uncommon_trap()}.


  60     public static final ForeignCallDescriptor UNCOMMON_TRAP_HANDLER = new ForeignCallDescriptor("uncommonTrapHandler", void.class);
  61 
  62     protected final GraalHotSpotVMConfig config;
  63 
  64     public HotSpotHostBackend(GraalHotSpotVMConfig config, HotSpotGraalRuntimeProvider runtime, HotSpotProviders providers) {
  65         super(runtime, providers);
  66         this.config = config;
  67     }
  68 
  69     @Override
  70     @SuppressWarnings("try")
  71     public void completeInitialization(HotSpotJVMCIRuntime jvmciRuntime, OptionValues options) {
  72         final HotSpotProviders providers = getProviders();
  73         HotSpotHostForeignCallsProvider foreignCalls = (HotSpotHostForeignCallsProvider) providers.getForeignCalls();
  74         final HotSpotLoweringProvider lowerer = (HotSpotLoweringProvider) providers.getLowerer();
  75 
  76         try (InitTimer st = timer("foreignCalls.initialize")) {
  77             foreignCalls.initialize(providers, options);
  78         }
  79         try (InitTimer st = timer("lowerer.initialize")) {
  80             lowerer.initialize(options, providers, config);

  81         }
  82     }
  83 
  84     protected CallingConvention makeCallingConvention(StructuredGraph graph, Stub stub) {
  85         if (stub != null) {
  86             return stub.getLinkage().getIncomingCallingConvention();
  87         }
  88 
  89         CallingConvention cc = getCallingConvention(getCodeCache(), HotSpotCallingConventionType.JavaCallee, graph.method(), this);
  90         if (graph.getEntryBCI() != JVMCICompiler.INVOCATION_ENTRY_BCI) {
  91             // for OSR, only a pointer is passed to the method.
  92             JavaType[] parameterTypes = new JavaType[]{getMetaAccess().lookupJavaType(long.class)};
  93             CallingConvention tmp = getCodeCache().getRegisterConfig().getCallingConvention(HotSpotCallingConventionType.JavaCallee, getMetaAccess().lookupJavaType(void.class), parameterTypes, this);
  94             cc = new CallingConvention(cc.getStackSize(), cc.getReturn(), tmp.getArgument(0));
  95         }
  96         return cc;
  97     }
  98 
  99     public void emitStackOverflowCheck(CompilationResultBuilder crb) {
 100         if (config.useStackBanging) {




   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 org.graalvm.compiler.hotspot;
  24 
  25 import static jdk.vm.ci.code.CodeUtil.K;
  26 import static jdk.vm.ci.code.CodeUtil.getCallingConvention;
  27 import static jdk.vm.ci.common.InitTimer.timer;
  28 
  29 import java.util.Collections;
  30 
  31 import org.graalvm.compiler.core.common.NumUtil;
  32 import org.graalvm.compiler.core.common.spi.ForeignCallDescriptor;
  33 import org.graalvm.compiler.debug.DebugHandlersFactory;
  34 import org.graalvm.compiler.hotspot.meta.HotSpotHostForeignCallsProvider;
  35 import org.graalvm.compiler.hotspot.meta.HotSpotLoweringProvider;
  36 import org.graalvm.compiler.hotspot.meta.HotSpotProviders;
  37 import org.graalvm.compiler.hotspot.stubs.Stub;
  38 import org.graalvm.compiler.lir.asm.CompilationResultBuilder;
  39 import org.graalvm.compiler.lir.framemap.ReferenceMapBuilder;
  40 import org.graalvm.compiler.nodes.StructuredGraph;
  41 import org.graalvm.compiler.options.OptionValues;
  42 import org.graalvm.compiler.printer.GraalDebugHandlersFactory;
  43 
  44 import jdk.vm.ci.code.CallingConvention;
  45 import jdk.vm.ci.common.InitTimer;
  46 import jdk.vm.ci.hotspot.HotSpotCallingConventionType;
  47 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
  48 import jdk.vm.ci.meta.JavaType;
  49 import jdk.vm.ci.runtime.JVMCICompiler;
  50 
  51 /**
  52  * Common functionality of HotSpot host backends.
  53  */
  54 public abstract class HotSpotHostBackend extends HotSpotBackend {
  55 
  56     /**
  57      * Descriptor for {@code SharedRuntime::deopt_blob()->unpack()}.
  58      */
  59     public static final ForeignCallDescriptor DEOPTIMIZATION_HANDLER = new ForeignCallDescriptor("deoptHandler", void.class);
  60 
  61     /**
  62      * Descriptor for {@code SharedRuntime::deopt_blob()->uncommon_trap()}.


  64     public static final ForeignCallDescriptor UNCOMMON_TRAP_HANDLER = new ForeignCallDescriptor("uncommonTrapHandler", void.class);
  65 
  66     protected final GraalHotSpotVMConfig config;
  67 
  68     public HotSpotHostBackend(GraalHotSpotVMConfig config, HotSpotGraalRuntimeProvider runtime, HotSpotProviders providers) {
  69         super(runtime, providers);
  70         this.config = config;
  71     }
  72 
  73     @Override
  74     @SuppressWarnings("try")
  75     public void completeInitialization(HotSpotJVMCIRuntime jvmciRuntime, OptionValues options) {
  76         final HotSpotProviders providers = getProviders();
  77         HotSpotHostForeignCallsProvider foreignCalls = (HotSpotHostForeignCallsProvider) providers.getForeignCalls();
  78         final HotSpotLoweringProvider lowerer = (HotSpotLoweringProvider) providers.getLowerer();
  79 
  80         try (InitTimer st = timer("foreignCalls.initialize")) {
  81             foreignCalls.initialize(providers, options);
  82         }
  83         try (InitTimer st = timer("lowerer.initialize")) {
  84             Iterable<DebugHandlersFactory> factories = Collections.singletonList(new GraalDebugHandlersFactory(providers.getSnippetReflection()));
  85             lowerer.initialize(options, factories, providers, config);
  86         }
  87     }
  88 
  89     protected CallingConvention makeCallingConvention(StructuredGraph graph, Stub stub) {
  90         if (stub != null) {
  91             return stub.getLinkage().getIncomingCallingConvention();
  92         }
  93 
  94         CallingConvention cc = getCallingConvention(getCodeCache(), HotSpotCallingConventionType.JavaCallee, graph.method(), this);
  95         if (graph.getEntryBCI() != JVMCICompiler.INVOCATION_ENTRY_BCI) {
  96             // for OSR, only a pointer is passed to the method.
  97             JavaType[] parameterTypes = new JavaType[]{getMetaAccess().lookupJavaType(long.class)};
  98             CallingConvention tmp = getCodeCache().getRegisterConfig().getCallingConvention(HotSpotCallingConventionType.JavaCallee, getMetaAccess().lookupJavaType(void.class), parameterTypes, this);
  99             cc = new CallingConvention(cc.getStackSize(), cc.getReturn(), tmp.getArgument(0));
 100         }
 101         return cc;
 102     }
 103 
 104     public void emitStackOverflowCheck(CompilationResultBuilder crb) {
 105         if (config.useStackBanging) {


src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotHostBackend.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File