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