43972
|
1 |
/*
|
58299
|
2 |
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
|
43972
|
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 org.graalvm.compiler.core.common.spi.ForeignCallLinkage;
|
|
28 |
import org.graalvm.compiler.core.target.Backend;
|
|
29 |
import org.graalvm.compiler.hotspot.stubs.Stub;
|
49873
|
30 |
import jdk.internal.vm.compiler.word.LocationIdentity;
|
43972
|
31 |
|
58299
|
32 |
import jdk.vm.ci.meta.InvokeTarget;
|
|
33 |
|
43972
|
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 {
|
58299
|
45 |
DESTROYS_ALL_CALLER_SAVE_REGISTERS,
|
|
46 |
COMPUTES_REGISTERS_KILLED
|
43972
|
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 |
/**
|
54601
|
56 |
* A call to a leaf function that is guaranteed to not use floating point registers.
|
|
57 |
* Consequently, floating point registers cleanup will be waived. On AMD64, this means the
|
|
58 |
* compiler will no longer emit vzeroupper instruction around the foreign call, which it
|
|
59 |
* normally does for unknown foreign calls to avoid potential SSE-AVX transition penalty.
|
|
60 |
* Besides, this foreign call will never have its caller stack inspected by the VM. That is,
|
|
61 |
* {@code JavaFrameAnchor} management around the call can be omitted.
|
43972
|
62 |
*/
|
54601
|
63 |
LEAF_NO_VZERO,
|
43972
|
64 |
|
|
65 |
/**
|
|
66 |
* A call to a leaf function that might use floating point registers but will never have its
|
|
67 |
* caller stack inspected. That is, {@code JavaFrameAnchor} management around the call can
|
|
68 |
* be omitted.
|
|
69 |
*/
|
|
70 |
LEAF,
|
|
71 |
|
|
72 |
/**
|
|
73 |
* A call to a leaf function that might use floating point registers and may have its caller
|
|
74 |
* stack inspected. That is, {@code JavaFrameAnchor} management code around the call is
|
|
75 |
* required.
|
|
76 |
*/
|
|
77 |
STACK_INSPECTABLE_LEAF,
|
|
78 |
|
|
79 |
/**
|
|
80 |
* A function that may lock, GC or raise an exception and thus requires debug info to be
|
|
81 |
* associated with a call site to the function. The execution stack may be inspected while
|
|
82 |
* in the called function. That is, {@code JavaFrameAnchor} management code around the call
|
|
83 |
* is required.
|
|
84 |
*/
|
|
85 |
SAFEPOINT,
|
|
86 |
}
|
|
87 |
|
|
88 |
/**
|
51436
|
89 |
* Constants specifying when a foreign call or stub call is re-executable.
|
|
90 |
*/
|
|
91 |
enum Reexecutability {
|
|
92 |
/**
|
|
93 |
* Denotes a call that cannot be re-executed. If an exception is raised, the call is
|
|
94 |
* deoptimized and the exception is passed on to be dispatched. If the call can throw an
|
|
95 |
* exception it needs to have a precise frame state.
|
|
96 |
*/
|
|
97 |
NOT_REEXECUTABLE,
|
|
98 |
|
|
99 |
/**
|
|
100 |
* Denotes a call that can always be re-executed. If an exception is raised by the call it
|
|
101 |
* may be cleared, compiled code deoptimized and reexecuted. Since the call has no side
|
|
102 |
* effects it is assumed that the same exception will be thrown.
|
|
103 |
*/
|
|
104 |
REEXECUTABLE
|
|
105 |
}
|
|
106 |
|
|
107 |
/**
|
43972
|
108 |
* Sentinel marker for a computed jump address.
|
|
109 |
*/
|
|
110 |
long JUMP_ADDRESS = 0xDEADDEADBEEFBEEFL;
|
|
111 |
|
51436
|
112 |
/**
|
|
113 |
* Determines if the call has side effects.
|
|
114 |
*/
|
43972
|
115 |
boolean isReexecutable();
|
|
116 |
|
|
117 |
LocationIdentity[] getKilledLocations();
|
|
118 |
|
|
119 |
void setCompiledStub(Stub stub);
|
|
120 |
|
58299
|
121 |
RegisterEffect getEffect();
|
|
122 |
|
43972
|
123 |
/**
|
|
124 |
* Determines if this is a call to a compiled {@linkplain Stub stub}.
|
|
125 |
*/
|
|
126 |
boolean isCompiledStub();
|
|
127 |
|
46344
|
128 |
/**
|
|
129 |
* Gets the stub, if any, this foreign call links to.
|
|
130 |
*/
|
|
131 |
Stub getStub();
|
|
132 |
|
43972
|
133 |
void finalizeAddress(Backend backend);
|
|
134 |
|
|
135 |
long getAddress();
|
|
136 |
|
|
137 |
/**
|
|
138 |
* Determines if the runtime function or stub might use floating point registers. If the answer
|
|
139 |
* is no, then no FPU state management prologue or epilogue needs to be emitted around the call.
|
|
140 |
*/
|
|
141 |
boolean mayContainFP();
|
|
142 |
|
|
143 |
/**
|
|
144 |
* Determines if a {@code JavaFrameAnchor} needs to be set up and torn down around this call.
|
|
145 |
*/
|
|
146 |
boolean needsJavaFrameAnchor();
|
|
147 |
|
|
148 |
/**
|
|
149 |
* Gets the VM symbol associated with the target {@linkplain #getAddress() address} of the call.
|
|
150 |
*/
|
|
151 |
String getSymbol();
|
|
152 |
|
|
153 |
/**
|
|
154 |
* Identifies foreign calls which are guaranteed to include a safepoint check.
|
|
155 |
*/
|
|
156 |
boolean isGuaranteedSafepoint();
|
|
157 |
}
|