author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 58299 | 6df94ce3ab2f |
permissions | -rw-r--r-- |
43972 | 1 |
/* |
54914 | 2 |
* Copyright (c) 2015, 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.replacements.amd64; |
26 |
||
50858 | 27 |
import static org.graalvm.compiler.replacements.StandardGraphBuilderPlugins.registerPlatformSpecificUnsafePlugins; |
43972 | 28 |
import static org.graalvm.compiler.replacements.nodes.BinaryMathIntrinsicNode.BinaryOperation.POW; |
29 |
import static org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.COS; |
|
30 |
import static org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.EXP; |
|
31 |
import static org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.LOG; |
|
32 |
import static org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.LOG10; |
|
33 |
import static org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.SIN; |
|
34 |
import static org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation.TAN; |
|
35 |
||
46963 | 36 |
import java.util.Arrays; |
37 |
||
43972 | 38 |
import org.graalvm.compiler.bytecode.BytecodeProvider; |
39 |
import org.graalvm.compiler.lir.amd64.AMD64ArithmeticLIRGeneratorTool.RoundingMode; |
|
52910 | 40 |
import org.graalvm.compiler.nodes.PauseNode; |
43972 | 41 |
import org.graalvm.compiler.nodes.ValueNode; |
42 |
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins; |
|
43 |
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext; |
|
44 |
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin; |
|
45 |
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver; |
|
46 |
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins; |
|
47 |
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration; |
|
48 |
import org.graalvm.compiler.nodes.java.AtomicReadAndAddNode; |
|
49 |
import org.graalvm.compiler.nodes.java.AtomicReadAndWriteNode; |
|
50 |
import org.graalvm.compiler.nodes.memory.address.OffsetAddressNode; |
|
46963 | 51 |
import org.graalvm.compiler.replacements.ArraysSubstitutions; |
43972 | 52 |
import org.graalvm.compiler.replacements.IntegerSubstitutions; |
53 |
import org.graalvm.compiler.replacements.LongSubstitutions; |
|
50858 | 54 |
import org.graalvm.compiler.replacements.StandardGraphBuilderPlugins.UnsafeAccessPlugin; |
43972 | 55 |
import org.graalvm.compiler.replacements.StandardGraphBuilderPlugins.UnsafeGetPlugin; |
56 |
import org.graalvm.compiler.replacements.StandardGraphBuilderPlugins.UnsafePutPlugin; |
|
58299 | 57 |
import org.graalvm.compiler.replacements.TargetGraphBuilderPlugins; |
43972 | 58 |
import org.graalvm.compiler.replacements.nodes.BinaryMathIntrinsicNode; |
59 |
import org.graalvm.compiler.replacements.nodes.BinaryMathIntrinsicNode.BinaryOperation; |
|
60 |
import org.graalvm.compiler.replacements.nodes.BitCountNode; |
|
54914 | 61 |
import org.graalvm.compiler.replacements.nodes.FusedMultiplyAddNode; |
43972 | 62 |
import org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode; |
63 |
import org.graalvm.compiler.replacements.nodes.UnaryMathIntrinsicNode.UnaryOperation; |
|
55509 | 64 |
import org.graalvm.compiler.serviceprovider.JavaVersionUtil; |
43972 | 65 |
|
66 |
import jdk.vm.ci.amd64.AMD64; |
|
67 |
import jdk.vm.ci.amd64.AMD64.CPUFeature; |
|
58299 | 68 |
import jdk.vm.ci.code.Architecture; |
43972 | 69 |
import jdk.vm.ci.meta.JavaKind; |
70 |
import jdk.vm.ci.meta.ResolvedJavaMethod; |
|
71 |
import sun.misc.Unsafe; |
|
72 |
||
58299 | 73 |
public class AMD64GraphBuilderPlugins implements TargetGraphBuilderPlugins { |
74 |
@Override |
|
75 |
public void register(Plugins plugins, BytecodeProvider replacementsBytecodeProvider, Architecture architecture, boolean explicitUnsafeNullChecks, |
|
76 |
boolean registerMathPlugins, boolean emitJDK9StringSubstitutions, boolean useFMAIntrinsics) { |
|
77 |
register(plugins, replacementsBytecodeProvider, (AMD64) architecture, explicitUnsafeNullChecks, emitJDK9StringSubstitutions, useFMAIntrinsics); |
|
78 |
} |
|
43972 | 79 |
|
54914 | 80 |
public static void register(Plugins plugins, BytecodeProvider replacementsBytecodeProvider, AMD64 arch, boolean explicitUnsafeNullChecks, boolean emitJDK9StringSubstitutions, |
81 |
boolean useFMAIntrinsics) { |
|
43972 | 82 |
InvocationPlugins invocationPlugins = plugins.getInvocationPlugins(); |
83 |
invocationPlugins.defer(new Runnable() { |
|
84 |
@Override |
|
85 |
public void run() { |
|
52910 | 86 |
registerThreadPlugins(invocationPlugins, arch); |
43972 | 87 |
registerIntegerLongPlugins(invocationPlugins, IntegerSubstitutions.class, JavaKind.Int, arch, replacementsBytecodeProvider); |
88 |
registerIntegerLongPlugins(invocationPlugins, LongSubstitutions.class, JavaKind.Long, arch, replacementsBytecodeProvider); |
|
50858 | 89 |
registerPlatformSpecificUnsafePlugins(invocationPlugins, replacementsBytecodeProvider, explicitUnsafeNullChecks, |
50330 | 90 |
new JavaKind[]{JavaKind.Int, JavaKind.Long, JavaKind.Object, JavaKind.Boolean, JavaKind.Byte, JavaKind.Short, JavaKind.Char, JavaKind.Float, JavaKind.Double}); |
50858 | 91 |
registerUnsafePlugins(invocationPlugins, replacementsBytecodeProvider, explicitUnsafeNullChecks); |
54084 | 92 |
registerStringPlugins(invocationPlugins, replacementsBytecodeProvider); |
54204 | 93 |
if (emitJDK9StringSubstitutions) { |
94 |
registerStringLatin1Plugins(invocationPlugins, replacementsBytecodeProvider); |
|
95 |
registerStringUTF16Plugins(invocationPlugins, replacementsBytecodeProvider); |
|
96 |
} |
|
54914 | 97 |
registerMathPlugins(invocationPlugins, useFMAIntrinsics, arch, replacementsBytecodeProvider); |
46963 | 98 |
registerArraysEqualsPlugins(invocationPlugins, replacementsBytecodeProvider); |
43972 | 99 |
} |
100 |
}); |
|
101 |
} |
|
102 |
||
52910 | 103 |
private static void registerThreadPlugins(InvocationPlugins plugins, AMD64 arch) { |
55509 | 104 |
if (JavaVersionUtil.JAVA_SPEC > 8) { |
52910 | 105 |
// Pause instruction introduced with SSE2 |
106 |
if (arch.getFeatures().contains(AMD64.CPUFeature.SSE2)) { |
|
107 |
Registration r = new Registration(plugins, Thread.class); |
|
108 |
r.register0("onSpinWait", new InvocationPlugin() { |
|
109 |
@Override |
|
110 |
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) { |
|
111 |
b.append(new PauseNode()); |
|
112 |
return true; |
|
113 |
} |
|
114 |
}); |
|
115 |
} |
|
116 |
} |
|
117 |
} |
|
118 |
||
43972 | 119 |
private static void registerIntegerLongPlugins(InvocationPlugins plugins, Class<?> substituteDeclaringClass, JavaKind kind, AMD64 arch, BytecodeProvider bytecodeProvider) { |
120 |
Class<?> declaringClass = kind.toBoxedJavaClass(); |
|
121 |
Class<?> type = kind.toJavaClass(); |
|
122 |
Registration r = new Registration(plugins, declaringClass, bytecodeProvider); |
|
54914 | 123 |
r.registerMethodSubstitution(substituteDeclaringClass, "numberOfLeadingZeros", type); |
43972 | 124 |
if (arch.getFeatures().contains(AMD64.CPUFeature.LZCNT) && arch.getFlags().contains(AMD64.Flag.UseCountLeadingZerosInstruction)) { |
54914 | 125 |
r.setAllowOverwrite(true); |
43972 | 126 |
r.register1("numberOfLeadingZeros", type, new InvocationPlugin() { |
127 |
@Override |
|
128 |
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) { |
|
129 |
ValueNode folded = AMD64CountLeadingZerosNode.tryFold(value); |
|
130 |
if (folded != null) { |
|
131 |
b.addPush(JavaKind.Int, folded); |
|
132 |
} else { |
|
133 |
b.addPush(JavaKind.Int, new AMD64CountLeadingZerosNode(value)); |
|
134 |
} |
|
135 |
return true; |
|
136 |
} |
|
137 |
}); |
|
138 |
} |
|
54914 | 139 |
|
140 |
r.registerMethodSubstitution(substituteDeclaringClass, "numberOfTrailingZeros", type); |
|
43972 | 141 |
if (arch.getFeatures().contains(AMD64.CPUFeature.BMI1) && arch.getFlags().contains(AMD64.Flag.UseCountTrailingZerosInstruction)) { |
54914 | 142 |
r.setAllowOverwrite(true); |
43972 | 143 |
r.register1("numberOfTrailingZeros", type, new InvocationPlugin() { |
54914 | 144 |
|
43972 | 145 |
@Override |
146 |
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) { |
|
147 |
ValueNode folded = AMD64CountTrailingZerosNode.tryFold(value); |
|
148 |
if (folded != null) { |
|
149 |
b.addPush(JavaKind.Int, folded); |
|
150 |
} else { |
|
151 |
b.addPush(JavaKind.Int, new AMD64CountTrailingZerosNode(value)); |
|
152 |
} |
|
153 |
return true; |
|
154 |
} |
|
155 |
}); |
|
156 |
} |
|
157 |
||
158 |
if (arch.getFeatures().contains(AMD64.CPUFeature.POPCNT)) { |
|
159 |
r.register1("bitCount", type, new InvocationPlugin() { |
|
160 |
@Override |
|
161 |
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) { |
|
46393 | 162 |
b.push(JavaKind.Int, b.append(new BitCountNode(value).canonical(null))); |
43972 | 163 |
return true; |
164 |
} |
|
165 |
}); |
|
166 |
} |
|
54914 | 167 |
|
43972 | 168 |
} |
169 |
||
54914 | 170 |
private static void registerMathPlugins(InvocationPlugins plugins, boolean useFMAIntrinsics, AMD64 arch, BytecodeProvider bytecodeProvider) { |
43972 | 171 |
Registration r = new Registration(plugins, Math.class, bytecodeProvider); |
172 |
registerUnaryMath(r, "log", LOG); |
|
173 |
registerUnaryMath(r, "log10", LOG10); |
|
174 |
registerUnaryMath(r, "exp", EXP); |
|
175 |
registerBinaryMath(r, "pow", POW); |
|
54084 | 176 |
registerUnaryMath(r, "sin", SIN); |
177 |
registerUnaryMath(r, "cos", COS); |
|
178 |
registerUnaryMath(r, "tan", TAN); |
|
43972 | 179 |
|
180 |
if (arch.getFeatures().contains(CPUFeature.SSE4_1)) { |
|
181 |
registerRound(r, "rint", RoundingMode.NEAREST); |
|
182 |
registerRound(r, "ceil", RoundingMode.UP); |
|
183 |
registerRound(r, "floor", RoundingMode.DOWN); |
|
184 |
} |
|
54914 | 185 |
|
55509 | 186 |
if (useFMAIntrinsics && JavaVersionUtil.JAVA_SPEC > 8 && arch.getFeatures().contains(CPUFeature.FMA)) { |
54914 | 187 |
registerFMA(r); |
188 |
} |
|
189 |
} |
|
190 |
||
191 |
private static void registerFMA(Registration r) { |
|
192 |
r.register3("fma", |
|
193 |
Double.TYPE, |
|
194 |
Double.TYPE, |
|
195 |
Double.TYPE, |
|
196 |
new InvocationPlugin() { |
|
197 |
@Override |
|
198 |
public boolean apply(GraphBuilderContext b, |
|
199 |
ResolvedJavaMethod targetMethod, |
|
200 |
Receiver receiver, |
|
201 |
ValueNode na, |
|
202 |
ValueNode nb, |
|
203 |
ValueNode nc) { |
|
204 |
b.push(JavaKind.Double, b.append(new FusedMultiplyAddNode(na, nb, nc))); |
|
205 |
return true; |
|
206 |
} |
|
207 |
}); |
|
208 |
r.register3("fma", |
|
209 |
Float.TYPE, |
|
210 |
Float.TYPE, |
|
211 |
Float.TYPE, |
|
212 |
new InvocationPlugin() { |
|
213 |
@Override |
|
214 |
public boolean apply(GraphBuilderContext b, |
|
215 |
ResolvedJavaMethod targetMethod, |
|
216 |
Receiver receiver, |
|
217 |
ValueNode na, |
|
218 |
ValueNode nb, |
|
219 |
ValueNode nc) { |
|
220 |
b.push(JavaKind.Float, b.append(new FusedMultiplyAddNode(na, nb, nc))); |
|
221 |
return true; |
|
222 |
} |
|
223 |
}); |
|
43972 | 224 |
} |
225 |
||
226 |
private static void registerUnaryMath(Registration r, String name, UnaryOperation operation) { |
|
227 |
r.register1(name, Double.TYPE, new InvocationPlugin() { |
|
228 |
@Override |
|
229 |
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) { |
|
46393 | 230 |
b.push(JavaKind.Double, b.append(UnaryMathIntrinsicNode.create(value, operation))); |
43972 | 231 |
return true; |
232 |
} |
|
233 |
}); |
|
234 |
} |
|
235 |
||
236 |
private static void registerBinaryMath(Registration r, String name, BinaryOperation operation) { |
|
237 |
r.register2(name, Double.TYPE, Double.TYPE, new InvocationPlugin() { |
|
238 |
@Override |
|
239 |
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) { |
|
46393 | 240 |
b.push(JavaKind.Double, b.append(BinaryMathIntrinsicNode.create(x, y, operation))); |
43972 | 241 |
return true; |
242 |
} |
|
243 |
}); |
|
244 |
} |
|
245 |
||
246 |
private static void registerRound(Registration r, String name, RoundingMode mode) { |
|
247 |
r.register1(name, Double.TYPE, new InvocationPlugin() { |
|
248 |
@Override |
|
249 |
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode arg) { |
|
250 |
b.push(JavaKind.Double, b.append(new AMD64RoundNode(arg, mode))); |
|
251 |
return true; |
|
252 |
} |
|
253 |
}); |
|
254 |
} |
|
255 |
||
54084 | 256 |
private static void registerStringPlugins(InvocationPlugins plugins, BytecodeProvider replacementsBytecodeProvider) { |
55509 | 257 |
if (JavaVersionUtil.JAVA_SPEC <= 8) { |
46344 | 258 |
Registration r; |
259 |
r = new Registration(plugins, String.class, replacementsBytecodeProvider); |
|
260 |
r.setAllowOverwrite(true); |
|
54084 | 261 |
r.registerMethodSubstitution(AMD64StringSubstitutions.class, "indexOf", char[].class, int.class, |
262 |
int.class, char[].class, int.class, int.class, int.class); |
|
263 |
r.registerMethodSubstitution(AMD64StringSubstitutions.class, "indexOf", Receiver.class, int.class, int.class); |
|
49873 | 264 |
r.registerMethodSubstitution(AMD64StringSubstitutions.class, "compareTo", Receiver.class, String.class); |
49451 | 265 |
} |
266 |
} |
|
267 |
||
54084 | 268 |
private static void registerStringLatin1Plugins(InvocationPlugins plugins, BytecodeProvider replacementsBytecodeProvider) { |
54204 | 269 |
Registration r = new Registration(plugins, "java.lang.StringLatin1", replacementsBytecodeProvider); |
270 |
r.setAllowOverwrite(true); |
|
271 |
r.registerMethodSubstitution(AMD64StringLatin1Substitutions.class, "compareTo", byte[].class, byte[].class); |
|
272 |
r.registerMethodSubstitution(AMD64StringLatin1Substitutions.class, "compareToUTF16", byte[].class, byte[].class); |
|
273 |
r.registerMethodSubstitution(AMD64StringLatin1Substitutions.class, "inflate", byte[].class, int.class, char[].class, int.class, int.class); |
|
274 |
r.registerMethodSubstitution(AMD64StringLatin1Substitutions.class, "inflate", byte[].class, int.class, byte[].class, int.class, int.class); |
|
275 |
r.registerMethodSubstitution(AMD64StringLatin1Substitutions.class, "indexOf", byte[].class, int.class, int.class); |
|
276 |
r.registerMethodSubstitution(AMD64StringLatin1Substitutions.class, "indexOf", byte[].class, int.class, byte[].class, int.class, int.class); |
|
49451 | 277 |
} |
278 |
||
54084 | 279 |
private static void registerStringUTF16Plugins(InvocationPlugins plugins, BytecodeProvider replacementsBytecodeProvider) { |
54204 | 280 |
Registration r = new Registration(plugins, "java.lang.StringUTF16", replacementsBytecodeProvider); |
281 |
r.setAllowOverwrite(true); |
|
282 |
r.registerMethodSubstitution(AMD64StringUTF16Substitutions.class, "compareTo", byte[].class, byte[].class); |
|
283 |
r.registerMethodSubstitution(AMD64StringUTF16Substitutions.class, "compareToLatin1", byte[].class, byte[].class); |
|
284 |
r.registerMethodSubstitution(AMD64StringUTF16Substitutions.class, "compress", char[].class, int.class, byte[].class, int.class, int.class); |
|
285 |
r.registerMethodSubstitution(AMD64StringUTF16Substitutions.class, "compress", byte[].class, int.class, byte[].class, int.class, int.class); |
|
286 |
r.registerMethodSubstitution(AMD64StringUTF16Substitutions.class, "indexOfCharUnsafe", byte[].class, int.class, int.class, int.class); |
|
287 |
r.registerMethodSubstitution(AMD64StringUTF16Substitutions.class, "indexOfUnsafe", byte[].class, int.class, byte[].class, int.class, int.class); |
|
288 |
r.registerMethodSubstitution(AMD64StringUTF16Substitutions.class, "indexOfLatin1Unsafe", byte[].class, int.class, byte[].class, int.class, int.class); |
|
46344 | 289 |
} |
290 |
||
50858 | 291 |
private static void registerUnsafePlugins(InvocationPlugins plugins, BytecodeProvider replacementsBytecodeProvider, boolean explicitUnsafeNullChecks) { |
52220
9c260a6b6471
8207146: Rename jdk.internal.misc.Unsafe::xxxObject to xxxReference
mchung
parents:
51436
diff
changeset
|
292 |
registerUnsafePlugins(new Registration(plugins, Unsafe.class), explicitUnsafeNullChecks, new JavaKind[]{JavaKind.Int, JavaKind.Long, JavaKind.Object}, true); |
55509 | 293 |
if (JavaVersionUtil.JAVA_SPEC > 8) { |
50858 | 294 |
registerUnsafePlugins(new Registration(plugins, "jdk.internal.misc.Unsafe", replacementsBytecodeProvider), explicitUnsafeNullChecks, |
55509 | 295 |
new JavaKind[]{JavaKind.Boolean, JavaKind.Byte, JavaKind.Char, JavaKind.Short, JavaKind.Int, JavaKind.Long, JavaKind.Object}, |
296 |
JavaVersionUtil.JAVA_SPEC <= 11); |
|
43972 | 297 |
} |
50609 | 298 |
} |
50330 | 299 |
|
52220
9c260a6b6471
8207146: Rename jdk.internal.misc.Unsafe::xxxObject to xxxReference
mchung
parents:
51436
diff
changeset
|
300 |
private static void registerUnsafePlugins(Registration r, boolean explicitUnsafeNullChecks, JavaKind[] unsafeJavaKinds, boolean java11OrEarlier) { |
50330 | 301 |
for (JavaKind kind : unsafeJavaKinds) { |
43972 | 302 |
Class<?> javaClass = kind == JavaKind.Object ? Object.class : kind.toJavaClass(); |
52220
9c260a6b6471
8207146: Rename jdk.internal.misc.Unsafe::xxxObject to xxxReference
mchung
parents:
51436
diff
changeset
|
303 |
String kindName = (kind == JavaKind.Object && !java11OrEarlier) ? "Reference" : kind.name(); |
9c260a6b6471
8207146: Rename jdk.internal.misc.Unsafe::xxxObject to xxxReference
mchung
parents:
51436
diff
changeset
|
304 |
r.register4("getAndSet" + kindName, Receiver.class, Object.class, long.class, javaClass, new UnsafeAccessPlugin(kind, explicitUnsafeNullChecks) { |
43972 | 305 |
@Override |
306 |
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode object, ValueNode offset, ValueNode value) { |
|
307 |
// Emits a null-check for the otherwise unused receiver |
|
308 |
unsafe.get(); |
|
50858 | 309 |
createUnsafeAccess(object, b, (obj, loc) -> new AtomicReadAndWriteNode(obj, offset, value, kind, loc)); |
43972 | 310 |
return true; |
311 |
} |
|
312 |
}); |
|
50330 | 313 |
if (kind != JavaKind.Boolean && kind.isNumericInteger()) { |
52220
9c260a6b6471
8207146: Rename jdk.internal.misc.Unsafe::xxxObject to xxxReference
mchung
parents:
51436
diff
changeset
|
314 |
r.register4("getAndAdd" + kindName, Receiver.class, Object.class, long.class, javaClass, new UnsafeAccessPlugin(kind, explicitUnsafeNullChecks) { |
43972 | 315 |
@Override |
316 |
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode object, ValueNode offset, ValueNode delta) { |
|
317 |
// Emits a null-check for the otherwise unused receiver |
|
318 |
unsafe.get(); |
|
50858 | 319 |
createUnsafeAccess(object, b, (obj, loc) -> new AtomicReadAndAddNode(b.add(new OffsetAddressNode(obj, offset)), delta, kind, loc)); |
43972 | 320 |
return true; |
321 |
} |
|
322 |
}); |
|
323 |
} |
|
324 |
} |
|
325 |
||
326 |
for (JavaKind kind : new JavaKind[]{JavaKind.Char, JavaKind.Short, JavaKind.Int, JavaKind.Long}) { |
|
327 |
Class<?> javaClass = kind.toJavaClass(); |
|
50858 | 328 |
r.registerOptional3("get" + kind.name() + "Unaligned", Receiver.class, Object.class, long.class, new UnsafeGetPlugin(kind, explicitUnsafeNullChecks)); |
329 |
r.registerOptional4("put" + kind.name() + "Unaligned", Receiver.class, Object.class, long.class, javaClass, new UnsafePutPlugin(kind, explicitUnsafeNullChecks)); |
|
43972 | 330 |
} |
331 |
} |
|
46963 | 332 |
|
333 |
private static void registerArraysEqualsPlugins(InvocationPlugins plugins, BytecodeProvider bytecodeProvider) { |
|
334 |
Registration r = new Registration(plugins, Arrays.class, bytecodeProvider); |
|
335 |
r.registerMethodSubstitution(ArraysSubstitutions.class, "equals", float[].class, float[].class); |
|
336 |
r.registerMethodSubstitution(ArraysSubstitutions.class, "equals", double[].class, double[].class); |
|
337 |
} |
|
43972 | 338 |
} |