43972
|
1 |
/*
|
47667
|
2 |
* Copyright (c) 2012, 2017, 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.LIRKind;
|
|
28 |
import org.graalvm.compiler.debug.GraalError;
|
|
29 |
import org.graalvm.compiler.hotspot.meta.HotSpotConstantLoadAction;
|
|
30 |
import org.graalvm.compiler.hotspot.meta.HotSpotProviders;
|
|
31 |
import org.graalvm.compiler.hotspot.nodes.GraalHotSpotVMConfigNode;
|
|
32 |
import org.graalvm.compiler.hotspot.nodes.aot.LoadConstantIndirectlyNode;
|
|
33 |
import org.graalvm.compiler.hotspot.nodes.aot.ResolveConstantNode;
|
|
34 |
import org.graalvm.compiler.hotspot.nodes.aot.ResolveMethodAndLoadCountersNode;
|
|
35 |
import org.graalvm.compiler.hotspot.nodes.profiling.RandomSeedNode;
|
|
36 |
import org.graalvm.compiler.hotspot.replacements.EncodedSymbolConstant;
|
|
37 |
import org.graalvm.compiler.lir.LIRFrameState;
|
|
38 |
import org.graalvm.compiler.lir.VirtualStackSlot;
|
|
39 |
import org.graalvm.compiler.lir.gen.LIRGenerator;
|
|
40 |
import org.graalvm.compiler.lir.gen.LIRGeneratorTool;
|
|
41 |
|
|
42 |
import jdk.vm.ci.hotspot.HotSpotMetaspaceConstant;
|
|
43 |
import jdk.vm.ci.hotspot.HotSpotObjectConstant;
|
|
44 |
import jdk.vm.ci.meta.Constant;
|
|
45 |
import jdk.vm.ci.meta.DeoptimizationAction;
|
|
46 |
import jdk.vm.ci.meta.DeoptimizationReason;
|
|
47 |
import jdk.vm.ci.meta.ResolvedJavaMethod;
|
|
48 |
import jdk.vm.ci.meta.Value;
|
|
49 |
|
|
50 |
/**
|
|
51 |
* This interface defines the contract a HotSpot backend LIR generator needs to fulfill in addition
|
|
52 |
* to abstract methods from {@link LIRGenerator} and {@link LIRGeneratorTool}.
|
|
53 |
*/
|
|
54 |
public interface HotSpotLIRGenerator extends LIRGeneratorTool {
|
|
55 |
|
|
56 |
/**
|
|
57 |
* Emits an operation to make a tail call.
|
|
58 |
*
|
|
59 |
* @param args the arguments of the call
|
|
60 |
* @param address the target address of the call
|
|
61 |
*/
|
|
62 |
void emitTailcall(Value[] args, Value address);
|
|
63 |
|
|
64 |
void emitDeoptimizeCaller(DeoptimizationAction action, DeoptimizationReason reason);
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Emits code for a {@link LoadConstantIndirectlyNode}.
|
|
68 |
*
|
|
69 |
* @param constant
|
|
70 |
* @return value of loaded address in register
|
|
71 |
*/
|
|
72 |
default Value emitLoadObjectAddress(Constant constant) {
|
47667
|
73 |
throw new GraalError("Emitting code to load an object address is not currently supported on %s", target().arch);
|
43972
|
74 |
}
|
|
75 |
|
|
76 |
/**
|
|
77 |
* Emits code for a {@link LoadConstantIndirectlyNode}.
|
|
78 |
*
|
|
79 |
* @param constant original constant
|
|
80 |
* @param action action to perform on the metaspace object
|
|
81 |
* @return Value of loaded address in register
|
|
82 |
*/
|
|
83 |
default Value emitLoadMetaspaceAddress(Constant constant, HotSpotConstantLoadAction action) {
|
47667
|
84 |
throw new GraalError("Emitting code to load a metaspace address is not currently supported on %s", target().arch);
|
43972
|
85 |
}
|
|
86 |
|
|
87 |
/**
|
|
88 |
* Emits code for a {@link GraalHotSpotVMConfigNode}.
|
|
89 |
*
|
|
90 |
* @param markId id of the value to load
|
|
91 |
* @param kind type of the value to load
|
|
92 |
* @return value of loaded global in register
|
|
93 |
*/
|
|
94 |
default Value emitLoadConfigValue(int markId, LIRKind kind) {
|
47667
|
95 |
throw new GraalError("Emitting code to load a config value is not currently supported on %s", target().arch);
|
43972
|
96 |
}
|
|
97 |
|
|
98 |
/**
|
|
99 |
* Emits code for a {@link ResolveConstantNode} to resolve a {@link HotSpotObjectConstant}.
|
|
100 |
*
|
|
101 |
* @param constant original constant
|
|
102 |
* @param constantDescription a description of the string that need to be materialized (and
|
|
103 |
* interned) as java.lang.String, generated with {@link EncodedSymbolConstant}
|
|
104 |
* @param frameState frame state for the runtime call
|
47667
|
105 |
* @return the address of the requested constant.
|
43972
|
106 |
*/
|
|
107 |
default Value emitObjectConstantRetrieval(Constant constant, Value constantDescription, LIRFrameState frameState) {
|
47667
|
108 |
throw new GraalError("Emitting code to resolve an object constant is not currently supported on %s", target().arch);
|
|
109 |
}
|
|
110 |
|
|
111 |
/**
|
|
112 |
* Emits code to resolve a dynamic constant.
|
|
113 |
*
|
|
114 |
* @param constant original constant
|
|
115 |
* @param frameState frame state for the runtime call
|
|
116 |
* @return the address of the requested constant.
|
|
117 |
*/
|
|
118 |
default Value emitResolveDynamicInvoke(Constant constant, LIRFrameState frameState) {
|
|
119 |
throw new GraalError("Emitting code to resolve a dynamic constant is not currently supported on %s", target().arch);
|
43972
|
120 |
}
|
|
121 |
|
|
122 |
/**
|
|
123 |
* Emits code for a {@link ResolveConstantNode} to resolve a {@link HotSpotMetaspaceConstant}.
|
|
124 |
*
|
|
125 |
* @param constant original constant
|
|
126 |
* @param constantDescription a symbolic description of the {@link HotSpotMetaspaceConstant}
|
|
127 |
* generated by {@link EncodedSymbolConstant}
|
|
128 |
* @param frameState frame state for the runtime call
|
47667
|
129 |
* @return the address of the requested constant.
|
43972
|
130 |
*/
|
|
131 |
default Value emitMetaspaceConstantRetrieval(Constant constant, Value constantDescription, LIRFrameState frameState) {
|
47667
|
132 |
throw new GraalError("Emitting code to resolve a metaspace constant is not currently supported on %s", target().arch);
|
43972
|
133 |
}
|
|
134 |
|
|
135 |
/**
|
|
136 |
* Emits code for a {@link ResolveMethodAndLoadCountersNode} to resolve a
|
|
137 |
* {@link HotSpotMetaspaceConstant} that represents a {@link ResolvedJavaMethod} and return the
|
|
138 |
* corresponding MethodCounters object.
|
|
139 |
*
|
|
140 |
* @param method original constant
|
|
141 |
* @param klassHint a klass in which the method is declared
|
|
142 |
* @param methodDescription is symbolic description of the constant generated by
|
|
143 |
* {@link EncodedSymbolConstant}
|
|
144 |
* @param frameState frame state for the runtime call
|
47667
|
145 |
* @return the address of the requested constant.
|
43972
|
146 |
*/
|
|
147 |
default Value emitResolveMethodAndLoadCounters(Constant method, Value klassHint, Value methodDescription, LIRFrameState frameState) {
|
47667
|
148 |
throw new GraalError("Emitting code to resolve a method and load counters is not currently supported on %s", target().arch);
|
43972
|
149 |
}
|
|
150 |
|
|
151 |
/**
|
|
152 |
* Emits code for a {@link ResolveConstantNode} to resolve a klass
|
|
153 |
* {@link HotSpotMetaspaceConstant} and run static initializer.
|
|
154 |
*
|
|
155 |
*
|
|
156 |
* @param constant original constant
|
|
157 |
* @param constantDescription a symbolic description of the {@link HotSpotMetaspaceConstant}
|
|
158 |
* generated by {@link EncodedSymbolConstant}
|
|
159 |
* @param frameState frame state for the runtime call
|
47667
|
160 |
* @return the address of the requested constant.
|
43972
|
161 |
*/
|
|
162 |
default Value emitKlassInitializationAndRetrieval(Constant constant, Value constantDescription, LIRFrameState frameState) {
|
47667
|
163 |
throw new GraalError("Emitting code to initialize a class is not currently supported on %s", target().arch);
|
43972
|
164 |
}
|
|
165 |
|
|
166 |
/**
|
|
167 |
* Emits code for a {@link RandomSeedNode}.
|
|
168 |
*
|
|
169 |
* @return value of the counter
|
|
170 |
*/
|
|
171 |
default Value emitRandomSeed() {
|
47667
|
172 |
throw new GraalError("Emitting code to return a random seed is not currently supported on %s", target().arch);
|
43972
|
173 |
}
|
|
174 |
|
|
175 |
/**
|
|
176 |
* Gets a stack slot for a lock at a given lock nesting depth.
|
|
177 |
*/
|
|
178 |
VirtualStackSlot getLockSlot(int lockDepth);
|
|
179 |
|
|
180 |
@Override
|
|
181 |
HotSpotProviders getProviders();
|
|
182 |
|
|
183 |
}
|