1 /* 2 * Copyright (c) 2012, 2016, 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 package org.graalvm.compiler.hotspot; 24 25 import jdk.vm.ci.meta.InvokeTarget; 26 27 import org.graalvm.compiler.core.common.LocationIdentity; 28 import org.graalvm.compiler.core.common.spi.ForeignCallLinkage; 29 import org.graalvm.compiler.core.target.Backend; 30 import org.graalvm.compiler.hotspot.stubs.Stub; 31 32 /** 33 * The details required to link a HotSpot runtime or stub call. 34 */ 35 public interface HotSpotForeignCallLinkage extends ForeignCallLinkage, InvokeTarget { 36 37 /** 38 * Constants for specifying whether a foreign call destroys or preserves registers. A foreign 39 * call will always destroy {@link HotSpotForeignCallLinkage#getOutgoingCallingConvention() its} 40 * {@linkplain ForeignCallLinkage#getTemporaries() temporary} registers. 41 */ 42 enum RegisterEffect { 43 DESTROYS_REGISTERS, 44 PRESERVES_REGISTERS 45 } 46 47 /** 48 * Constants for specifying whether a call is a leaf or not and whether a 49 * {@code JavaFrameAnchor} prologue and epilogue is required around the call. A leaf function 50 * does not lock, GC or throw exceptions. 51 */ 52 enum Transition { 53 /** 54 * A call to a leaf function that is guaranteed to not use floating point registers and will 55 * never have its caller stack inspected by the VM. That is, {@code JavaFrameAnchor} 56 * management around the call can be omitted. 57 */ 58 LEAF_NOFP, 59 60 /** 61 * A call to a leaf function that might use floating point registers but will never have its 62 * caller stack inspected. That is, {@code JavaFrameAnchor} management around the call can 63 * be omitted. 64 */ 65 LEAF, 66 67 /** 68 * A call to a leaf function that might use floating point registers and may have its caller 69 * stack inspected. That is, {@code JavaFrameAnchor} management code around the call is 70 * required. 71 */ 72 STACK_INSPECTABLE_LEAF, 73 74 /** 75 * A function that may lock, GC or raise an exception and thus requires debug info to be 76 * associated with a call site to the function. The execution stack may be inspected while 77 * in the called function. That is, {@code JavaFrameAnchor} management code around the call 78 * is required. 79 */ 80 SAFEPOINT, 81 } 82 83 /** 84 * Sentinel marker for a computed jump address. 85 */ 86 long JUMP_ADDRESS = 0xDEADDEADBEEFBEEFL; 87 88 boolean isReexecutable(); 89 90 LocationIdentity[] getKilledLocations(); 91 92 void setCompiledStub(Stub stub); 93 94 /** 95 * Determines if this is a call to a compiled {@linkplain Stub stub}. 96 */ 97 boolean isCompiledStub(); 98 99 void finalizeAddress(Backend backend); 100 101 long getAddress(); 102 103 /** 104 * Determines if the runtime function or stub might use floating point registers. If the answer 105 * is no, then no FPU state management prologue or epilogue needs to be emitted around the call. 106 */ 107 boolean mayContainFP(); 108 109 /** 110 * Determines if a {@code JavaFrameAnchor} needs to be set up and torn down around this call. 111 */ 112 boolean needsJavaFrameAnchor(); 113 114 /** 115 * Gets the VM symbol associated with the target {@linkplain #getAddress() address} of the call. 116 */ 117 String getSymbol(); 118 119 /** 120 * Identifies foreign calls which are guaranteed to include a safepoint check. 121 */ 122 boolean isGuaranteedSafepoint(); 123 }