@@ -152,28 +152,6 @@ default void setDouble(DynamicObject store, double value, Shape shape) {
152
152
}
153
153
}
154
154
155
- sealed interface BooleanLocation extends TypedLocation , com .oracle .truffle .api .object .BooleanLocation {
156
- @ Override
157
- boolean getBoolean (DynamicObject store , boolean guard );
158
-
159
- @ Override
160
- default boolean getBoolean (DynamicObject store , Shape shape ) {
161
- return getBoolean (store , store .getShape () == shape );
162
- }
163
-
164
- void setBoolean (DynamicObject store , boolean value , boolean guard , boolean init );
165
-
166
- @ Override
167
- default void setBoolean (DynamicObject store , boolean value , Shape shape ) {
168
- setBoolean (store , value , store .getShape () == shape , false );
169
- }
170
-
171
- @ Override
172
- default Class <Boolean > getType () {
173
- return boolean .class ;
174
- }
175
- }
176
-
177
155
abstract static sealed class ValueLocation extends LocationImpl {
178
156
179
157
private final Object value ;
@@ -775,6 +753,7 @@ abstract static sealed class AbstractPrimitiveFieldLocation extends InstanceLoca
775
753
776
754
AbstractPrimitiveFieldLocation (int index , FieldInfo field , Assumption finalAssumption ) {
777
755
super (index , finalAssumption );
756
+ assert field .type () == long .class : field ;
778
757
this .field = Objects .requireNonNull (field );
779
758
}
780
759
@@ -804,7 +783,6 @@ static final class IntFieldLocation extends AbstractPrimitiveFieldLocation imple
804
783
805
784
IntFieldLocation (int index , FieldInfo field , Assumption finalAssumption ) {
806
785
super (index , field , finalAssumption );
807
- assert field .type () == long .class || field .type () == int .class : field ;
808
786
}
809
787
810
788
@ Override
@@ -815,18 +793,10 @@ public Object get(DynamicObject store, boolean guard) {
815
793
@ Override
816
794
public int getInt (DynamicObject store , boolean guard ) {
817
795
if (UseVarHandle ) {
818
- if (field .type () == long .class ) {
819
- return (int ) (long ) field .varHandle ().get (store );
820
- } else {
821
- return (int ) field .varHandle ().get (store );
822
- }
796
+ return (int ) (long ) field .varHandle ().get (store );
823
797
}
824
798
field .receiverCheck (store );
825
- if (field .type () == long .class ) {
826
- return (int ) UnsafeAccess .unsafeGetLong (store , getOffset (), guard , this );
827
- } else {
828
- return UnsafeAccess .unsafeGetInt (store , getOffset (), guard , this );
829
- }
799
+ return (int ) UnsafeAccess .unsafeGetLong (store , getOffset (), guard , this );
830
800
}
831
801
832
802
@ Override
@@ -848,19 +818,11 @@ public void setInt(DynamicObject store, int value, boolean guard, boolean init)
848
818
849
819
private void setIntInternal (DynamicObject store , int value ) {
850
820
if (UseVarHandle ) {
851
- if (field .type () == long .class ) {
852
- field .varHandle ().set (store , value & 0xffff_ffffL );
853
- } else {
854
- field .varHandle ().set (store , value );
855
- }
821
+ field .varHandle ().set (store , value & 0xffff_ffffL );
856
822
return ;
857
823
}
858
824
field .receiverCheck (store );
859
- if (field .type () == long .class ) {
860
- UnsafeAccess .unsafePutLong (store , getOffset (), value & 0xffff_ffffL , this );
861
- } else {
862
- UnsafeAccess .unsafePutInt (store , getOffset (), value , this );
863
- }
825
+ UnsafeAccess .unsafePutLong (store , getOffset (), value & 0xffff_ffffL , this );
864
826
}
865
827
866
828
@ Override
@@ -886,13 +848,10 @@ public void accept(LocationVisitor locationVisitor) {
886
848
887
849
static final class DoubleFieldLocation extends AbstractPrimitiveFieldLocation implements DoubleLocation {
888
850
private final boolean allowInt ;
889
- private final byte slotSize ;
890
851
891
- DoubleFieldLocation (int index , FieldInfo field , boolean allowInt , int slotSize , Assumption finalAssumption ) {
852
+ DoubleFieldLocation (int index , FieldInfo field , boolean allowInt , Assumption finalAssumption ) {
892
853
super (index , field , finalAssumption );
893
854
this .allowInt = allowInt ;
894
- assert slotSize >= 1 && slotSize <= 2 ;
895
- this .slotSize = (byte ) slotSize ;
896
855
}
897
856
898
857
@ Override
@@ -906,11 +865,7 @@ public double getDouble(DynamicObject store, boolean guard) {
906
865
return Double .longBitsToDouble ((long ) field .varHandle ().get (store ));
907
866
}
908
867
field .receiverCheck (store );
909
- if (field .type () == long .class ) {
910
- return Double .longBitsToDouble (UnsafeAccess .unsafeGetLong (store , getOffset (), guard , this ));
911
- } else {
912
- return UnsafeAccess .unsafeGetDouble (store , getOffset (), guard , this );
913
- }
868
+ return Double .longBitsToDouble (UnsafeAccess .unsafeGetLong (store , getOffset (), guard , this ));
914
869
}
915
870
916
871
@ Override
@@ -927,11 +882,7 @@ private void setDoubleInternal(DynamicObject store, double value) {
927
882
return ;
928
883
}
929
884
field .receiverCheck (store );
930
- if (field .type () == long .class ) {
931
- UnsafeAccess .unsafePutLong (store , getOffset (), Double .doubleToRawLongBits (value ), this );
932
- } else {
933
- UnsafeAccess .unsafePutDouble (store , getOffset (), value , this );
934
- }
885
+ UnsafeAccess .unsafePutLong (store , getOffset (), Double .doubleToRawLongBits (value ), this );
935
886
}
936
887
937
888
@ Override
@@ -970,12 +921,12 @@ public Class<Double> getType() {
970
921
971
922
@ Override
972
923
public int primitiveFieldCount () {
973
- return slotSize ;
924
+ return 1 ;
974
925
}
975
926
976
927
@ Override
977
928
public void accept (LocationVisitor locationVisitor ) {
978
- locationVisitor .visitPrimitiveField (getIndex (), slotSize );
929
+ locationVisitor .visitPrimitiveField (getIndex (), 1 );
979
930
}
980
931
981
932
@ Override
@@ -989,74 +940,6 @@ public boolean isImplicitCastIntToDouble() {
989
940
}
990
941
}
991
942
992
- static final class BooleanFieldLocation extends AbstractPrimitiveFieldLocation implements BooleanLocation {
993
-
994
- BooleanFieldLocation (int index , FieldInfo field , Assumption finalAssumption ) {
995
- super (index , field , finalAssumption );
996
- assert field .type () == int .class : field ;
997
- }
998
-
999
- @ Override
1000
- public Object get (DynamicObject store , boolean guard ) {
1001
- return getBoolean (store , guard );
1002
- }
1003
-
1004
- @ Override
1005
- public boolean getBoolean (DynamicObject store , boolean guard ) {
1006
- if (UseVarHandle ) {
1007
- return UnsafeAccess .booleanCast ((int ) field .varHandle ().get (store ));
1008
- }
1009
- field .receiverCheck (store );
1010
- return UnsafeAccess .booleanCast (UnsafeAccess .unsafeGetInt (store , getOffset (), guard , this ));
1011
- }
1012
-
1013
- @ Override
1014
- public void setBoolean (DynamicObject store , boolean value , boolean guard , boolean init ) {
1015
- if (!init ) {
1016
- maybeInvalidateFinalAssumption ();
1017
- }
1018
- setBooleanInternal (store , value );
1019
- }
1020
-
1021
- private void setBooleanInternal (DynamicObject store , boolean value ) {
1022
- if (UseVarHandle ) {
1023
- field .varHandle ().set (store , UnsafeAccess .intCast (value ));
1024
- return ;
1025
- }
1026
- field .receiverCheck (store );
1027
- UnsafeAccess .unsafePutInt (store , getOffset (), UnsafeAccess .intCast (value ), this );
1028
- }
1029
-
1030
- @ Override
1031
- protected void set (DynamicObject store , Object value , boolean guard , boolean init ) {
1032
- if (canStore (value )) {
1033
- setBoolean (store , (boolean ) value , guard , init );
1034
- } else {
1035
- throw incompatibleLocationException ();
1036
- }
1037
- }
1038
-
1039
- @ Override
1040
- public boolean canStore (Object value ) {
1041
- return value instanceof Boolean ;
1042
- }
1043
-
1044
- @ Override
1045
- public Class <Boolean > getType () {
1046
- return boolean .class ;
1047
- }
1048
-
1049
- @ Override
1050
- public int primitiveFieldCount () {
1051
- return INT_FIELD_SLOT_SIZE ;
1052
- }
1053
-
1054
- @ Override
1055
- public void accept (LocationVisitor locationVisitor ) {
1056
- locationVisitor .visitPrimitiveField (getIndex (), INT_FIELD_SLOT_SIZE );
1057
- }
1058
- }
1059
-
1060
943
abstract static sealed class AbstractPrimitiveArrayLocation extends InstanceLocation implements ArrayLocation {
1061
944
1062
945
AbstractPrimitiveArrayLocation (int index , Assumption finalAssumption ) {
@@ -1224,13 +1107,10 @@ protected int getBytes() {
1224
1107
1225
1108
static final class LongFieldLocation extends AbstractPrimitiveFieldLocation implements LongLocation {
1226
1109
private final boolean allowInt ;
1227
- private final byte slotSize ;
1228
1110
1229
- LongFieldLocation (int index , FieldInfo field , boolean allowInt , int slotSize , Assumption finalAssumption ) {
1111
+ LongFieldLocation (int index , FieldInfo field , boolean allowInt , Assumption finalAssumption ) {
1230
1112
super (index , field , finalAssumption );
1231
1113
this .allowInt = allowInt ;
1232
- assert slotSize >= 1 && slotSize <= 2 ;
1233
- this .slotSize = (byte ) slotSize ;
1234
1114
}
1235
1115
1236
1116
@ Override
@@ -1295,12 +1175,12 @@ public Class<Long> getType() {
1295
1175
1296
1176
@ Override
1297
1177
public int primitiveFieldCount () {
1298
- return slotSize ;
1178
+ return 1 ;
1299
1179
}
1300
1180
1301
1181
@ Override
1302
1182
public void accept (LocationVisitor locationVisitor ) {
1303
- locationVisitor .visitPrimitiveField (getIndex (), slotSize );
1183
+ locationVisitor .visitPrimitiveField (getIndex (), 1 );
1304
1184
}
1305
1185
1306
1186
@ Override
0 commit comments