@@ -792,12 +792,27 @@ private void lowerKlassLayoutHelperNode(KlassLayoutHelperNode n, LoweringTool to
792
792
}
793
793
StructuredGraph graph = n .graph ();
794
794
assert !n .getHub ().isConstant ();
795
- AddressNode address = createOffsetAddress (graph , n .getHub (), runtime .getVMConfig ().klassLayoutHelperOffset );
796
- ReadNode memoryRead = graph .add (new ReadNode (address , HotSpotReplacementsUtil .KLASS_LAYOUT_HELPER_LOCATION , null , n .stamp (NodeView .DEFAULT ), null , BarrierType .NONE ));
797
- graph .addAfterFixed (tool .lastFixedNode (), memoryRead );
795
+ ValueNode memoryRead = createRead (graph , createOffsetAddress (graph , n .getHub (), runtime .getVMConfig ().klassLayoutHelperOffset ), HotSpotReplacementsUtil .KLASS_LAYOUT_HELPER_LOCATION ,
796
+ n .stamp (NodeView .DEFAULT ), BarrierType .NONE , tool .lastFixedNode ());
798
797
n .replaceAtUsagesAndDelete (memoryRead );
799
798
}
800
799
800
+ private static ValueNode createRead (StructuredGraph graph , AddressNode address , LocationIdentity location , Stamp stamp , BarrierType barrierType , FixedWithNextNode insertAfter ) {
801
+ return createRead (graph , address , location , stamp , null , barrierType , insertAfter );
802
+ }
803
+
804
+ private static ValueNode createRead (StructuredGraph graph , AddressNode address , LocationIdentity location , Stamp stamp , GuardingNode guard , BarrierType barrierType ,
805
+ FixedWithNextNode insertAfter ) {
806
+ if (graph .getGraphState ().allowsFloatingReads ()) {
807
+ return graph .unique (new FloatingReadNode (address , location , null , stamp , guard , barrierType ));
808
+ } else {
809
+ ReadNode memoryRead = graph .add (new ReadNode (address , location , null , stamp , guard , barrierType ));
810
+ graph .addAfterFixed (insertAfter , memoryRead );
811
+ assert memoryRead .canFloat () : "this path is only useable for floatable reads: " + memoryRead ;
812
+ return memoryRead ;
813
+ }
814
+ }
815
+
801
816
private void lowerHubGetClassNode (HubGetClassNode n , LoweringTool tool ) {
802
817
if (tool .getLoweringStage () == LoweringTool .StandardLoweringStage .HIGH_TIER ) {
803
818
return ;
@@ -809,13 +824,16 @@ private void lowerHubGetClassNode(HubGetClassNode n, LoweringTool tool) {
809
824
assert !hub .isConstant ();
810
825
AddressNode mirrorAddress = createOffsetAddress (graph , hub , vmConfig .classMirrorOffset );
811
826
Stamp loadStamp = n .stamp (NodeView .DEFAULT );
812
- FloatingReadNode read = graph .unique (
813
- new FloatingReadNode (mirrorAddress , HotSpotReplacementsUtil .CLASS_MIRROR_LOCATION , null , StampFactory .forKind (target .wordJavaKind ),
814
- null , BarrierType .NONE ));
827
+ FixedWithNextNode insertAfter = tool .lastFixedNode ();
828
+ ValueNode read = createRead (graph , mirrorAddress , HotSpotReplacementsUtil .CLASS_MIRROR_LOCATION , StampFactory .forKind (target .wordJavaKind ),
829
+ BarrierType .NONE , insertAfter );
830
+ if (read instanceof FixedWithNextNode fixed ) {
831
+ insertAfter = fixed ;
832
+ }
815
833
// Read the Object from the OopHandle
816
834
AddressNode address = createOffsetAddress (graph , read , 0 );
817
- read = graph . unique ( new FloatingReadNode ( address , HotSpotReplacementsUtil .HOTSPOT_OOP_HANDLE_LOCATION , null , loadStamp , null ,
818
- barrierSet .readBarrierType (HotSpotReplacementsUtil .HOTSPOT_OOP_HANDLE_LOCATION , address , loadStamp )) );
835
+ read = createRead ( graph , address , HotSpotReplacementsUtil .HOTSPOT_OOP_HANDLE_LOCATION , loadStamp ,
836
+ barrierSet .readBarrierType (HotSpotReplacementsUtil .HOTSPOT_OOP_HANDLE_LOCATION , address , loadStamp ), insertAfter );
819
837
n .replaceAtUsagesAndDelete (read );
820
838
}
821
839
@@ -827,7 +845,7 @@ private void lowerClassGetHubNode(ClassGetHubNode n, LoweringTool tool) {
827
845
StructuredGraph graph = n .graph ();
828
846
assert !n .getValue ().isConstant ();
829
847
AddressNode address = createOffsetAddress (graph , n .getValue (), runtime .getVMConfig ().klassOffset );
830
- FloatingReadNode read = graph . unique ( new FloatingReadNode ( address , HotSpotReplacementsUtil .CLASS_KLASS_LOCATION , null , n .stamp (NodeView .DEFAULT ), null , BarrierType .NONE ));
848
+ ValueNode read = createRead ( graph , address , HotSpotReplacementsUtil .CLASS_KLASS_LOCATION , n .stamp (NodeView .DEFAULT ), BarrierType .NONE , tool . lastFixedNode ( ));
831
849
n .replaceAtUsagesAndDelete (read );
832
850
}
833
851
@@ -920,9 +938,7 @@ protected ValueNode createReadArrayComponentHub(StructuredGraph graph, ValueNode
920
938
guard = AbstractBeginNode .prevBegin (anchor );
921
939
}
922
940
AddressNode address = createOffsetAddress (graph , arrayHub , runtime .getVMConfig ().arrayClassElementOffset );
923
- ReadNode read = graph .add (new ReadNode (address , HotSpotReplacementsUtil .OBJ_ARRAY_KLASS_ELEMENT_KLASS_LOCATION , null , KlassPointerStamp .klassNonNull (), guard , BarrierType .NONE ));
924
- graph .addAfterFixed (insertAfter , read );
925
- return read ;
941
+ return createRead (graph , address , HotSpotReplacementsUtil .OBJ_ARRAY_KLASS_ELEMENT_KLASS_LOCATION , KlassPointerStamp .klassNonNull (), guard , BarrierType .NONE , insertAfter );
926
942
}
927
943
928
944
private void lowerLoadMethodNode (LoadMethodNode loadMethodNode ) {
@@ -1157,22 +1173,17 @@ protected ValueNode createReadHub(StructuredGraph graph, ValueNode object, Lower
1157
1173
hubStamp = hubStamp .compressed (config .getKlassEncoding ());
1158
1174
}
1159
1175
1160
- FixedWithNextNode effectiveInsertAfter = insertAfter ;
1161
-
1162
1176
if (config .useCompactObjectHeaders ) {
1163
1177
AddressNode address = createOffsetAddress (graph , object , config .markOffset );
1164
- ReadNode memoryRead = graph .add (new ReadNode (address , COMPACT_HUB_LOCATION , null , StampFactory .forKind (JavaKind .Long ), null , BarrierType .NONE ));
1165
- graph .addAfterFixed (insertAfter , memoryRead );
1166
- effectiveInsertAfter = memoryRead ;
1178
+ ValueNode memoryRead = createRead (graph , address , COMPACT_HUB_LOCATION , StampFactory .forKind (JavaKind .Long ), BarrierType .NONE , insertAfter );
1167
1179
ValueNode rawCompressedHubWordSize = graph .addOrUnique (UnsignedRightShiftNode .create (memoryRead , ConstantNode .forInt (config .markWordKlassShift , graph ), NodeView .DEFAULT ));
1168
1180
ValueNode rawCompressedHub = graph .addOrUnique (NarrowNode .create (rawCompressedHubWordSize , 32 , NodeView .DEFAULT ));
1169
1181
ValueNode compressedKlassPointer = graph .addOrUnique (PointerCastNode .create (hubStamp , rawCompressedHub ));
1170
1182
return HotSpotCompressionNode .uncompress (graph , compressedKlassPointer , config .getKlassEncoding ());
1171
1183
}
1172
1184
AddressNode address = createOffsetAddress (graph , object , config .hubOffset );
1173
1185
LocationIdentity hubLocation = config .useCompressedClassPointers ? COMPRESSED_HUB_LOCATION : HUB_LOCATION ;
1174
- ReadNode memoryRead = graph .add (new ReadNode (address , hubLocation , null , hubStamp , null , BarrierType .NONE ));
1175
- graph .addAfterFixed (effectiveInsertAfter , memoryRead );
1186
+ ValueNode memoryRead = createRead (graph , address , hubLocation , hubStamp , BarrierType .NONE , insertAfter );
1176
1187
if (config .useCompressedClassPointers ) {
1177
1188
return HotSpotCompressionNode .uncompress (graph , memoryRead , config .getKlassEncoding ());
1178
1189
} else {
0 commit comments