Skip to content

Commit 5ea09ac

Browse files
committed
Implement Reference.get0 intrinsic (JDK-8352565)
1 parent 0e1bc06 commit 5ea09ac

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/HotSpotGraphBuilderPlugins.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,13 +1607,26 @@ protected boolean useExplicitReachabilityFence(GraphBuilderContext b) {
16071607
return Options.ForceExplicitReachabilityFence.getValue(b.getOptions());
16081608
}
16091609
});
1610+
r.register(new InlineOnlyInvocationPlugin("get0", Receiver.class) {
1611+
@Override
1612+
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
1613+
ValueNode offset = b.add(ConstantNode.forLong(HotSpotReplacementsUtil.referentOffset(b.getMetaAccess())));
1614+
AddressNode address = b.add(new OffsetAddressNode(receiver.get(true), offset));
1615+
FieldLocationIdentity locationIdentity = new FieldLocationIdentity(HotSpotReplacementsUtil.referentField(b.getMetaAccess()));
1616+
JavaReadNode read = b.add(new JavaReadNode(StampFactory.object(), JavaKind.Object, address, locationIdentity, BarrierType.REFERENCE_GET, MemoryOrderMode.PLAIN, true));
1617+
b.add(new MembarNode(MembarNode.FenceKind.NONE, locationIdentity));
1618+
b.addPush(JavaKind.Object, read);
1619+
return true;
1620+
}
1621+
});
16101622
r.register(new InlineOnlyInvocationPlugin("refersTo0", Receiver.class, Object.class) {
16111623
@Override
16121624
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode o) {
16131625
ValueNode offset = b.add(ConstantNode.forLong(HotSpotReplacementsUtil.referentOffset(b.getMetaAccess())));
16141626
AddressNode address = b.add(new OffsetAddressNode(receiver.get(true), offset));
16151627
FieldLocationIdentity locationIdentity = new FieldLocationIdentity(HotSpotReplacementsUtil.referentField(b.getMetaAccess()));
16161628
JavaReadNode read = b.add(new JavaReadNode(StampFactory.object(), JavaKind.Object, address, locationIdentity, BarrierType.WEAK_REFERS_TO, MemoryOrderMode.PLAIN, true));
1629+
b.add(new MembarNode(MembarNode.FenceKind.NONE, locationIdentity));
16171630
LogicNode objectEquals = b.add(ObjectEqualsNode.create(b.getConstantReflection(), b.getMetaAccess(), b.getOptions(), read, o, NodeView.DEFAULT));
16181631
b.addPush(JavaKind.Boolean, ConditionalNode.create(objectEquals, b.add(forBoolean(true)), b.add(forBoolean(false)), NodeView.DEFAULT));
16191632
return true;

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/UnimplementedGraalIntrinsics.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ public UnimplementedGraalIntrinsics(Architecture arch) {
128128
// handled by an intrinsic for StringUTF16.indexOfLatin1Unsafe
129129
"java/lang/StringUTF16.indexOfLatin1([BI[BII)I",
130130
"java/lang/StringUTF16.indexOfLatin1([B[B)I",
131-
// implemented through lowering
132-
"java/lang/ref/Reference.get0()Ljava/lang/Object;",
133131
// Relevant for Java flight recorder
134132
// [GR-10106] These JFR intrinsics are used for firing socket/file events
135133
// via Java instrumentation and are of low priority.

0 commit comments

Comments
 (0)