< prev index next >

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

Print this page
rev 56282 : [mq]: graal
   1 /*
   2  * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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 
  24 
  25 package org.graalvm.compiler.hotspot;
  26 
  27 import static jdk.vm.ci.code.CodeUtil.K;
  28 import static jdk.vm.ci.code.CodeUtil.getCallingConvention;
  29 import static jdk.vm.ci.common.InitTimer.timer;
  30 
  31 import java.util.Collections;
  32 

  33 import org.graalvm.compiler.core.common.NumUtil;

  34 import org.graalvm.compiler.core.common.spi.ForeignCallDescriptor;

  35 import org.graalvm.compiler.debug.DebugHandlersFactory;
  36 import org.graalvm.compiler.hotspot.meta.HotSpotHostForeignCallsProvider;
  37 import org.graalvm.compiler.hotspot.meta.HotSpotLoweringProvider;
  38 import org.graalvm.compiler.hotspot.meta.HotSpotProviders;
  39 import org.graalvm.compiler.hotspot.stubs.Stub;

  40 import org.graalvm.compiler.lir.asm.CompilationResultBuilder;

  41 import org.graalvm.compiler.lir.framemap.ReferenceMapBuilder;

  42 import org.graalvm.compiler.nodes.StructuredGraph;
  43 import org.graalvm.compiler.options.OptionValues;
  44 import org.graalvm.compiler.printer.GraalDebugHandlersFactory;
  45 import org.graalvm.compiler.word.Word;
  46 
  47 import jdk.vm.ci.code.CallingConvention;

  48 import jdk.vm.ci.common.InitTimer;
  49 import jdk.vm.ci.hotspot.HotSpotCallingConventionType;
  50 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
  51 import jdk.vm.ci.meta.JavaKind;
  52 import jdk.vm.ci.meta.JavaType;
  53 import jdk.vm.ci.runtime.JVMCICompiler;
  54 
  55 /**
  56  * Common functionality of HotSpot host backends.
  57  */
  58 public abstract class HotSpotHostBackend extends HotSpotBackend {
  59 
  60     /**
  61      * Descriptor for {@code SharedRuntime::deopt_blob()->unpack()}.
  62      */
  63     public static final ForeignCallDescriptor DEOPTIMIZATION_HANDLER = new ForeignCallDescriptor("deoptHandler", void.class);
  64 
  65     /**
  66      * Descriptor for {@code SharedRuntime::deopt_blob()->uncommon_trap()}.
  67      */
  68     public static final ForeignCallDescriptor UNCOMMON_TRAP_HANDLER = new ForeignCallDescriptor("uncommonTrapHandler", void.class);
  69 
  70     public static final ForeignCallDescriptor ENABLE_STACK_RESERVED_ZONE = new ForeignCallDescriptor("enableStackReservedZoneEntry", void.class, Word.class);
  71 
  72     public static final ForeignCallDescriptor THROW_DELAYED_STACKOVERFLOW_ERROR = new ForeignCallDescriptor("throwDelayedStackoverflowError", void.class);
  73 
  74     protected final GraalHotSpotVMConfig config;
  75 
  76     public HotSpotHostBackend(GraalHotSpotVMConfig config, HotSpotGraalRuntimeProvider runtime, HotSpotProviders providers) {
  77         super(runtime, providers);
  78         this.config = config;


 138             int bangOffset = bangEndSafe;
 139             if (bangOffset <= bangEnd) {
 140                 crb.blockComment("[stack overflow check]");
 141             }
 142             while (bangOffset <= bangEnd) {
 143                 // Need at least one stack bang at end of shadow zone.
 144                 bangStackWithOffset(crb, bangOffset);
 145                 bangOffset += pageSize;
 146             }
 147         }
 148     }
 149 
 150     protected abstract void bangStackWithOffset(CompilationResultBuilder crb, int bangOffset);
 151 
 152     @Override
 153     public ReferenceMapBuilder newReferenceMapBuilder(int totalFrameSize) {
 154         int uncompressedReferenceSize = getTarget().arch.getPlatformKind(JavaKind.Object).getSizeInBytes();
 155         return new HotSpotReferenceMapBuilder(totalFrameSize, config.maxOopMapStackOffset, uncompressedReferenceSize);
 156     }
 157 








 158 }
   1 /*
   2  * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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 
  24 
  25 package org.graalvm.compiler.hotspot;
  26 
  27 import static jdk.vm.ci.code.CodeUtil.K;
  28 import static jdk.vm.ci.code.CodeUtil.getCallingConvention;
  29 import static jdk.vm.ci.common.InitTimer.timer;
  30 
  31 import java.util.Collections;
  32 
  33 import org.graalvm.compiler.core.common.CompilationIdentifier;
  34 import org.graalvm.compiler.core.common.NumUtil;
  35 import org.graalvm.compiler.core.common.alloc.RegisterAllocationConfig;
  36 import org.graalvm.compiler.core.common.spi.ForeignCallDescriptor;
  37 import org.graalvm.compiler.core.gen.LIRGenerationProvider;
  38 import org.graalvm.compiler.debug.DebugHandlersFactory;
  39 import org.graalvm.compiler.hotspot.meta.HotSpotHostForeignCallsProvider;
  40 import org.graalvm.compiler.hotspot.meta.HotSpotLoweringProvider;
  41 import org.graalvm.compiler.hotspot.meta.HotSpotProviders;
  42 import org.graalvm.compiler.hotspot.stubs.Stub;
  43 import org.graalvm.compiler.lir.LIR;
  44 import org.graalvm.compiler.lir.asm.CompilationResultBuilder;
  45 import org.graalvm.compiler.lir.framemap.FrameMapBuilder;
  46 import org.graalvm.compiler.lir.framemap.ReferenceMapBuilder;
  47 import org.graalvm.compiler.lir.gen.LIRGenerationResult;
  48 import org.graalvm.compiler.nodes.StructuredGraph;
  49 import org.graalvm.compiler.options.OptionValues;
  50 import org.graalvm.compiler.printer.GraalDebugHandlersFactory;
  51 import org.graalvm.compiler.word.Word;
  52 
  53 import jdk.vm.ci.code.CallingConvention;
  54 import jdk.vm.ci.code.RegisterConfig;
  55 import jdk.vm.ci.common.InitTimer;
  56 import jdk.vm.ci.hotspot.HotSpotCallingConventionType;
  57 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
  58 import jdk.vm.ci.meta.JavaKind;
  59 import jdk.vm.ci.meta.JavaType;
  60 import jdk.vm.ci.runtime.JVMCICompiler;
  61 
  62 /**
  63  * Common functionality of HotSpot host backends.
  64  */
  65 public abstract class HotSpotHostBackend extends HotSpotBackend implements LIRGenerationProvider {
  66 
  67     /**
  68      * Descriptor for {@code SharedRuntime::deopt_blob()->unpack()}.
  69      */
  70     public static final ForeignCallDescriptor DEOPTIMIZATION_HANDLER = new ForeignCallDescriptor("deoptHandler", void.class);
  71 
  72     /**
  73      * Descriptor for {@code SharedRuntime::deopt_blob()->uncommon_trap()}.
  74      */
  75     public static final ForeignCallDescriptor UNCOMMON_TRAP_HANDLER = new ForeignCallDescriptor("uncommonTrapHandler", void.class);
  76 
  77     public static final ForeignCallDescriptor ENABLE_STACK_RESERVED_ZONE = new ForeignCallDescriptor("enableStackReservedZoneEntry", void.class, Word.class);
  78 
  79     public static final ForeignCallDescriptor THROW_DELAYED_STACKOVERFLOW_ERROR = new ForeignCallDescriptor("throwDelayedStackoverflowError", void.class);
  80 
  81     protected final GraalHotSpotVMConfig config;
  82 
  83     public HotSpotHostBackend(GraalHotSpotVMConfig config, HotSpotGraalRuntimeProvider runtime, HotSpotProviders providers) {
  84         super(runtime, providers);
  85         this.config = config;


 145             int bangOffset = bangEndSafe;
 146             if (bangOffset <= bangEnd) {
 147                 crb.blockComment("[stack overflow check]");
 148             }
 149             while (bangOffset <= bangEnd) {
 150                 // Need at least one stack bang at end of shadow zone.
 151                 bangStackWithOffset(crb, bangOffset);
 152                 bangOffset += pageSize;
 153             }
 154         }
 155     }
 156 
 157     protected abstract void bangStackWithOffset(CompilationResultBuilder crb, int bangOffset);
 158 
 159     @Override
 160     public ReferenceMapBuilder newReferenceMapBuilder(int totalFrameSize) {
 161         int uncompressedReferenceSize = getTarget().arch.getPlatformKind(JavaKind.Object).getSizeInBytes();
 162         return new HotSpotReferenceMapBuilder(totalFrameSize, config.maxOopMapStackOffset, uncompressedReferenceSize);
 163     }
 164 
 165     @Override
 166     public LIRGenerationResult newLIRGenerationResult(CompilationIdentifier compilationId, LIR lir, RegisterAllocationConfig registerAllocationConfig, StructuredGraph graph, Object stub) {
 167         return new HotSpotLIRGenerationResult(compilationId, lir, newFrameMapBuilder(registerAllocationConfig.getRegisterConfig()), registerAllocationConfig, makeCallingConvention(graph, (Stub) stub),
 168                         stub,
 169                         config.requiresReservedStackCheck(graph.getMethods()));
 170     }
 171 
 172     protected abstract FrameMapBuilder newFrameMapBuilder(RegisterConfig registerConfig);
 173 }
< prev index next >