1 /*
2  * Copyright (c) 2012, 2020, 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 org.graalvm.compiler.core.common.spi.ForeignCallLinkage;
28 import org.graalvm.compiler.core.target.Backend;
29 import org.graalvm.compiler.hotspot.meta.HotSpotForeignCallDescriptor;
30 import org.graalvm.compiler.hotspot.stubs.Stub;
31 
32 import jdk.vm.ci.meta.InvokeTarget;
33 
34 /**
35  * The details required to link a HotSpot runtime or stub call.
36  */
37 public interface HotSpotForeignCallLinkage extends ForeignCallLinkage, InvokeTarget {
38 
39     /**
40      * Constants for specifying whether a foreign call destroys or preserves registers. A foreign
41      * call will always destroy {@link HotSpotForeignCallLinkage#getOutgoingCallingConvention() its}
42      * {@linkplain ForeignCallLinkage#getTemporaries() temporary} registers.
43      */
44     enum RegisterEffect {
45         DESTROYS_ALL_CALLER_SAVE_REGISTERS,
46         COMPUTES_REGISTERS_KILLED
47     }
48 
49     @Override
getDescriptor()50     HotSpotForeignCallDescriptor getDescriptor();
51 
52     /**
53      * Sentinel marker for a computed jump address.
54      */
55     long JUMP_ADDRESS = 0xDEADDEADBEEFBEEFL;
56 
setCompiledStub(Stub stub)57     void setCompiledStub(Stub stub);
58 
getEffect()59     RegisterEffect getEffect();
60 
61     /**
62      * Determines if this is a call to a compiled {@linkplain Stub stub}.
63      */
isCompiledStub()64     boolean isCompiledStub();
65 
66     /**
67      * Gets the stub, if any, this foreign call links to.
68      */
getStub()69     Stub getStub();
70 
finalizeAddress(Backend backend)71     void finalizeAddress(Backend backend);
72 
getAddress()73     long getAddress();
74 
75     /**
76      * Determines if the runtime function or stub might use floating point registers. If the answer
77      * is no, then no FPU state management prologue or epilogue needs to be emitted around the call.
78      */
mayContainFP()79     boolean mayContainFP();
80 
81     /**
82      * Determines if a {@code JavaFrameAnchor} needs to be set up and torn down around this call.
83      */
needsJavaFrameAnchor()84     boolean needsJavaFrameAnchor();
85 
86     /**
87      * Gets the VM symbol associated with the target {@linkplain #getAddress() address} of the call.
88      */
getSymbol()89     String getSymbol();
90 }
91