43972
|
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 |
*/
|
50858
|
23 |
|
|
24 |
|
43972
|
25 |
package org.graalvm.compiler.hotspot;
|
|
26 |
|
|
27 |
import jdk.vm.ci.meta.InvokeTarget;
|
|
28 |
|
|
29 |
import org.graalvm.compiler.core.common.spi.ForeignCallLinkage;
|
|
30 |
import org.graalvm.compiler.core.target.Backend;
|
|
31 |
import org.graalvm.compiler.hotspot.stubs.Stub;
|
49873
|
32 |
import jdk.internal.vm.compiler.word.LocationIdentity;
|
43972
|
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_REGISTERS,
|
|
46 |
PRESERVES_REGISTERS
|
|
47 |
}
|
|
48 |
|
|
49 |
/**
|
|
50 |
* Constants for specifying whether a call is a leaf or not and whether a
|
|
51 |
* {@code JavaFrameAnchor} prologue and epilogue is required around the call. A leaf function
|
|
52 |
* does not lock, GC or throw exceptions.
|
|
53 |
*/
|
|
54 |
enum Transition {
|
|
55 |
/**
|
|
56 |
* A call to a leaf function that is guaranteed to not use floating point registers and will
|
|
57 |
* never have its caller stack inspected by the VM. That is, {@code JavaFrameAnchor}
|
|
58 |
* management around the call can be omitted.
|
|
59 |
*/
|
|
60 |
LEAF_NOFP,
|
|
61 |
|
|
62 |
/**
|
|
63 |
* A call to a leaf function that might use floating point registers but will never have its
|
|
64 |
* caller stack inspected. That is, {@code JavaFrameAnchor} management around the call can
|
|
65 |
* be omitted.
|
|
66 |
*/
|
|
67 |
LEAF,
|
|
68 |
|
|
69 |
/**
|
|
70 |
* A call to a leaf function that might use floating point registers and may have its caller
|
|
71 |
* stack inspected. That is, {@code JavaFrameAnchor} management code around the call is
|
|
72 |
* required.
|
|
73 |
*/
|
|
74 |
STACK_INSPECTABLE_LEAF,
|
|
75 |
|
|
76 |
/**
|
|
77 |
* A function that may lock, GC or raise an exception and thus requires debug info to be
|
|
78 |
* associated with a call site to the function. The execution stack may be inspected while
|
|
79 |
* in the called function. That is, {@code JavaFrameAnchor} management code around the call
|
|
80 |
* is required.
|
|
81 |
*/
|
|
82 |
SAFEPOINT,
|
|
83 |
}
|
|
84 |
|
|
85 |
/**
|
51436
|
86 |
* Constants specifying when a foreign call or stub call is re-executable.
|
|
87 |
*/
|
|
88 |
enum Reexecutability {
|
|
89 |
/**
|
|
90 |
* Denotes a call that cannot be re-executed. If an exception is raised, the call is
|
|
91 |
* deoptimized and the exception is passed on to be dispatched. If the call can throw an
|
|
92 |
* exception it needs to have a precise frame state.
|
|
93 |
*/
|
|
94 |
NOT_REEXECUTABLE,
|
|
95 |
|
|
96 |
/**
|
|
97 |
* Denotes a call that can only be re-executed if it returns with a pending exception. This
|
|
98 |
* type of call models a function that may throw exceptions before any side effects happen.
|
|
99 |
* In this case if an exception is raised the call may be deoptimized and reexecuted. It
|
|
100 |
* also means that while the call has side effects and may deoptimize it doesn't necessarily
|
|
101 |
* need to have a precise frame state.
|
|
102 |
*/
|
|
103 |
REEXECUTABLE_ONLY_AFTER_EXCEPTION,
|
|
104 |
|
|
105 |
/**
|
|
106 |
* Denotes a call that can always be re-executed. If an exception is raised by the call it
|
|
107 |
* may be cleared, compiled code deoptimized and reexecuted. Since the call has no side
|
|
108 |
* effects it is assumed that the same exception will be thrown.
|
|
109 |
*/
|
|
110 |
REEXECUTABLE
|
|
111 |
}
|
|
112 |
|
|
113 |
/**
|
43972
|
114 |
* Sentinel marker for a computed jump address.
|
|
115 |
*/
|
|
116 |
long JUMP_ADDRESS = 0xDEADDEADBEEFBEEFL;
|
|
117 |
|
51436
|
118 |
/**
|
|
119 |
* Determines if the call has side effects.
|
|
120 |
*/
|
43972
|
121 |
boolean isReexecutable();
|
|
122 |
|
51436
|
123 |
/**
|
|
124 |
* Determines if the call returning a pending exception implies it is side-effect free.
|
|
125 |
*/
|
|
126 |
boolean isReexecutableOnlyAfterException();
|
|
127 |
|
43972
|
128 |
LocationIdentity[] getKilledLocations();
|
|
129 |
|
|
130 |
void setCompiledStub(Stub stub);
|
|
131 |
|
|
132 |
/**
|
|
133 |
* Determines if this is a call to a compiled {@linkplain Stub stub}.
|
|
134 |
*/
|
|
135 |
boolean isCompiledStub();
|
|
136 |
|
46344
|
137 |
/**
|
|
138 |
* Gets the stub, if any, this foreign call links to.
|
|
139 |
*/
|
|
140 |
Stub getStub();
|
|
141 |
|
43972
|
142 |
void finalizeAddress(Backend backend);
|
|
143 |
|
|
144 |
long getAddress();
|
|
145 |
|
|
146 |
/**
|
|
147 |
* Determines if the runtime function or stub might use floating point registers. If the answer
|
|
148 |
* is no, then no FPU state management prologue or epilogue needs to be emitted around the call.
|
|
149 |
*/
|
|
150 |
boolean mayContainFP();
|
|
151 |
|
|
152 |
/**
|
|
153 |
* Determines if a {@code JavaFrameAnchor} needs to be set up and torn down around this call.
|
|
154 |
*/
|
|
155 |
boolean needsJavaFrameAnchor();
|
|
156 |
|
|
157 |
/**
|
|
158 |
* Gets the VM symbol associated with the target {@linkplain #getAddress() address} of the call.
|
|
159 |
*/
|
|
160 |
String getSymbol();
|
|
161 |
|
|
162 |
/**
|
|
163 |
* Identifies foreign calls which are guaranteed to include a safepoint check.
|
|
164 |
*/
|
|
165 |
boolean isGuaranteedSafepoint();
|
|
166 |
}
|