@@ -481,8 +481,7 @@ static IntegerStamp createEmptyStamp(int bits) {
481
481
482
482
@ Override
483
483
public Stamp constant (Constant c , MetaAccessProvider meta ) {
484
- if (c instanceof PrimitiveConstant ) {
485
- PrimitiveConstant primitiveConstant = (PrimitiveConstant ) c ;
484
+ if (c instanceof PrimitiveConstant primitiveConstant ) {
486
485
long value = primitiveConstant .asLong ();
487
486
if (primitiveConstant .getJavaKind () == JavaKind .Boolean && value == 1 ) {
488
487
// Need to special case booleans as integer stamps are always signed values.
@@ -497,20 +496,15 @@ public Stamp constant(Constant c, MetaAccessProvider meta) {
497
496
498
497
@ Override
499
498
public SerializableConstant deserialize (ByteBuffer buffer ) {
500
- switch (getBits ()) {
501
- case 1 :
502
- return JavaConstant .forBoolean (buffer .get () != 0 );
503
- case 8 :
504
- return JavaConstant .forByte (buffer .get ());
505
- case 16 :
506
- return JavaConstant .forShort (buffer .getShort ());
507
- case 32 :
508
- return JavaConstant .forInt (buffer .getInt ());
509
- case 64 :
510
- return JavaConstant .forLong (buffer .getLong ());
511
- default :
499
+ return switch (getBits ()) {
500
+ case 1 -> JavaConstant .forBoolean (buffer .get () != 0 );
501
+ case 8 -> JavaConstant .forByte (buffer .get ());
502
+ case 16 -> JavaConstant .forShort (buffer .getShort ());
503
+ case 32 -> JavaConstant .forInt (buffer .getInt ());
504
+ case 64 -> JavaConstant .forLong (buffer .getLong ());
505
+ default ->
512
506
throw GraalError .shouldNotReachHereUnexpectedValue (getBits ()); // ExcludeFromJacocoGeneratedReport
513
- }
507
+ };
514
508
}
515
509
516
510
@ Override
@@ -534,20 +528,15 @@ public LIRKind getLIRKind(LIRKindTool tool) {
534
528
535
529
@ Override
536
530
public ResolvedJavaType javaType (MetaAccessProvider metaAccess ) {
537
- switch (getBits ()) {
538
- case 1 :
539
- return metaAccess .lookupJavaType (Boolean .TYPE );
540
- case 8 :
541
- return metaAccess .lookupJavaType (Byte .TYPE );
542
- case 16 :
543
- return metaAccess .lookupJavaType (Short .TYPE );
544
- case 32 :
545
- return metaAccess .lookupJavaType (Integer .TYPE );
546
- case 64 :
547
- return metaAccess .lookupJavaType (Long .TYPE );
548
- default :
531
+ return switch (getBits ()) {
532
+ case 1 -> metaAccess .lookupJavaType (Boolean .TYPE );
533
+ case 8 -> metaAccess .lookupJavaType (Byte .TYPE );
534
+ case 16 -> metaAccess .lookupJavaType (Short .TYPE );
535
+ case 32 -> metaAccess .lookupJavaType (Integer .TYPE );
536
+ case 64 -> metaAccess .lookupJavaType (Long .TYPE );
537
+ default ->
549
538
throw GraalError .shouldNotReachHereUnexpectedValue (getBits ()); // ExcludeFromJacocoGeneratedReport
550
- }
539
+ };
551
540
}
552
541
553
542
@ Override
@@ -753,17 +742,15 @@ public boolean isCompatible(Stamp stamp) {
753
742
if (this == stamp ) {
754
743
return true ;
755
744
}
756
- if (stamp instanceof IntegerStamp ) {
757
- IntegerStamp other = (IntegerStamp ) stamp ;
745
+ if (stamp instanceof IntegerStamp other ) {
758
746
return getBits () == other .getBits ();
759
747
}
760
748
return false ;
761
749
}
762
750
763
751
@ Override
764
752
public boolean isCompatible (Constant constant ) {
765
- if (constant instanceof PrimitiveConstant ) {
766
- PrimitiveConstant prim = (PrimitiveConstant ) constant ;
753
+ if (constant instanceof PrimitiveConstant prim ) {
767
754
JavaKind kind = prim .getJavaKind ();
768
755
return kind .isNumericInteger () && kind .getBitCount () == getBits ();
769
756
}
@@ -793,10 +780,10 @@ public int hashCode() {
793
780
final int prime = 31 ;
794
781
int result = 1 ;
795
782
result = prime * result + super .hashCode ();
796
- result = prime * result + ( int ) ( lowerBound ^ ( lowerBound >>> 32 ) );
797
- result = prime * result + ( int ) ( upperBound ^ ( upperBound >>> 32 ) );
798
- result = prime * result + ( int ) ( mustBeSet ^ ( mustBeSet >>> 32 ) );
799
- result = prime * result + ( int ) ( mayBeSet ^ ( mayBeSet >>> 32 ) );
783
+ result = prime * result + Long . hashCode ( lowerBound );
784
+ result = prime * result + Long . hashCode ( upperBound );
785
+ result = prime * result + Long . hashCode ( mustBeSet );
786
+ result = prime * result + Long . hashCode ( mayBeSet );
800
787
result = prime * result + Boolean .hashCode (canBeZero );
801
788
return result ;
802
789
}
@@ -907,9 +894,9 @@ public static boolean multiplicationOverflows(long a, long b, int bits) {
907
894
if (bits == 64 ) {
908
895
if (a > 0 && b > 0 ) {
909
896
return a > 0x7FFFFFFF_FFFFFFFFL / b ;
910
- } else if (a > 0 && b <= 0 ) {
897
+ } else if (a > 0 ) {
911
898
return b < 0x80000000_00000000L / a ;
912
- } else if (a <= 0 && b > 0 ) {
899
+ } else if (b > 0 ) {
913
900
return a < 0x80000000_00000000L / b ;
914
901
} else {
915
902
// a<=0 && b <=0
@@ -1315,7 +1302,7 @@ protected Stamp foldStampImpl(Stamp stamp1, Stamp stamp2) {
1315
1302
}
1316
1303
}
1317
1304
1318
- assert newLowerBound <= newUpperBound : Assertions .errorMessageContext ("newLowerBound" , newLowerBound , "newUpperBonud " , newUpperBound , "stamp1" , stamp1 , "stamp2" ,
1305
+ assert newLowerBound <= newUpperBound : Assertions .errorMessageContext ("newLowerBound" , newLowerBound , "newUpperBound " , newUpperBound , "stamp1" , stamp1 , "stamp2" ,
1319
1306
stamp2 );
1320
1307
return StampFactory .forIntegerWithMask (bits , newLowerBound , newUpperBound , 0 , newMayBeSet );
1321
1308
}
@@ -1835,18 +1822,16 @@ public Stamp foldStampImpl(Stamp stamp, Stamp amount) {
1835
1822
return value ;
1836
1823
}
1837
1824
if (shiftAmount >= bits ) {
1838
- IntegerStamp result = IntegerStamp .create (bits , 0 , 0 , 0 , 0 );
1839
- return result ;
1825
+ return IntegerStamp .create (bits , 0 , 0 , 0 , 0 );
1840
1826
}
1841
1827
// the mask of bits that will be lost or shifted into the sign bit
1842
1828
if (testNoSignChangeAfterShifting (bits , value .lowerBound (), shiftAmount ) && testNoSignChangeAfterShifting (bits , value .upperBound (), shiftAmount )) {
1843
1829
/*
1844
1830
* use a better stamp if neither lower nor upper bound can lose
1845
1831
* bits
1846
1832
*/
1847
- IntegerStamp result = IntegerStamp .create (bits , value .lowerBound () << shiftAmount , value .upperBound () << shiftAmount ,
1833
+ return IntegerStamp .create (bits , value .lowerBound () << shiftAmount , value .upperBound () << shiftAmount ,
1848
1834
(value .mustBeSet () << shiftAmount ) & CodeUtil .mask (bits ), (value .mayBeSet () << shiftAmount ) & CodeUtil .mask (bits ));
1849
- return result ;
1850
1835
}
1851
1836
}
1852
1837
if ((shift .lowerBound () >>> shiftBits ) == (shift .upperBound () >>> shiftBits )) {
@@ -2189,11 +2174,11 @@ public Stamp invertStamp(int inputBits, int resultBits, Stamp outStamp) {
2189
2174
* @formatter:on
2190
2175
*/
2191
2176
if (zeroInExtension ) {
2192
- long msbZeroMask = ~(1 << (inputBits - 1 ));
2177
+ long msbZeroMask = ~(1L << (inputBits - 1 ));
2193
2178
inputMustBeSet &= msbZeroMask ;
2194
2179
inputMayBeSet &= msbZeroMask ;
2195
2180
} else if (oneInExtension ) {
2196
- long msbOneMask = 1 << (inputBits - 1 );
2181
+ long msbOneMask = 1L << (inputBits - 1 );
2197
2182
inputMustBeSet |= msbOneMask ;
2198
2183
inputMayBeSet |= msbOneMask ;
2199
2184
}
0 commit comments