249 r.register2("getAddress", Receiver.class, long.class, new UnsafeGetPlugin(JavaKind.Long, false)); |
249 r.register2("getAddress", Receiver.class, long.class, new UnsafeGetPlugin(JavaKind.Long, false)); |
250 r.register3("putAddress", Receiver.class, long.class, long.class, new UnsafePutPlugin(JavaKind.Long, false)); |
250 r.register3("putAddress", Receiver.class, long.class, long.class, new UnsafePutPlugin(JavaKind.Long, false)); |
251 |
251 |
252 for (JavaKind kind : new JavaKind[]{JavaKind.Int, JavaKind.Long, JavaKind.Object}) { |
252 for (JavaKind kind : new JavaKind[]{JavaKind.Int, JavaKind.Long, JavaKind.Object}) { |
253 Class<?> javaClass = kind == JavaKind.Object ? Object.class : kind.toJavaClass(); |
253 Class<?> javaClass = kind == JavaKind.Object ? Object.class : kind.toJavaClass(); |
254 r.register5("compareAndSwap" + kind.name(), Receiver.class, Object.class, long.class, javaClass, javaClass, new InvocationPlugin() { |
254 String casName; |
|
255 if (Java8OrEarlier) { |
|
256 casName = "compareAndSwap"; |
|
257 } else { |
|
258 casName = "compareAndSet"; |
|
259 } |
|
260 r.register5(casName + kind.name(), Receiver.class, Object.class, long.class, javaClass, javaClass, new InvocationPlugin() { |
255 @Override |
261 @Override |
256 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode object, ValueNode offset, ValueNode expected, ValueNode x) { |
262 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode object, ValueNode offset, ValueNode expected, ValueNode x) { |
257 // Emits a null-check for the otherwise unused receiver |
263 // Emits a null-check for the otherwise unused receiver |
258 unsafe.get(); |
264 unsafe.get(); |
259 b.addPush(JavaKind.Int, new CompareAndSwapNode(object, offset, expected, x, kind, LocationIdentity.any())); |
265 b.addPush(JavaKind.Int, new CompareAndSwapNode(object, offset, expected, x, kind, LocationIdentity.any())); |