@@ -5953,7 +5953,8 @@ static boolean sameObject(AbstractTruffleString a, AbstractTruffleString b, Enco
5953
5953
}
5954
5954
5955
5955
@ Fallback
5956
- final boolean check (AbstractTruffleString a , AbstractTruffleString b , Encoding expectedEncoding ,
5956
+ static boolean check (AbstractTruffleString a , AbstractTruffleString b , Encoding expectedEncoding ,
5957
+ @ Cached Node node ,
5957
5958
@ Cached InlinedConditionProfile managedProfileA ,
5958
5959
@ Cached InlinedConditionProfile nativeProfileA ,
5959
5960
@ Cached InlinedConditionProfile managedProfileB ,
@@ -5963,7 +5964,7 @@ final boolean check(AbstractTruffleString a, AbstractTruffleString b, Encoding e
5963
5964
@ Cached InlinedConditionProfile checkFirstByteProfile ) {
5964
5965
a .looseCheckEncoding (expectedEncoding , a .codeRange ());
5965
5966
b .looseCheckEncoding (expectedEncoding , b .codeRange ());
5966
- return checkContentEquals (this , a , b , managedProfileA , nativeProfileA , managedProfileB , nativeProfileB , lengthAndCodeRangeCheckProfile , compareHashProfile , checkFirstByteProfile );
5967
+ return checkContentEquals (node , a , b , managedProfileA , nativeProfileA , managedProfileB , nativeProfileB , lengthAndCodeRangeCheckProfile , compareHashProfile , checkFirstByteProfile );
5967
5968
}
5968
5969
5969
5970
static boolean checkContentEquals (
@@ -6046,6 +6047,79 @@ static boolean checkContentEquals(
6046
6047
}
6047
6048
}
6048
6049
6050
+ /**
6051
+ * A copy of {@link #checkContentEquals} but without profiles. Keep in sync.
6052
+ */
6053
+ static boolean checkContentEqualsUncached (AbstractTruffleString a , AbstractTruffleString b ) {
6054
+ Node node = TruffleString .EqualNode .getUncached ();
6055
+ int codeRangeA = a .codeRange ();
6056
+ int codeRangeB = b .codeRange ();
6057
+ int lengthCMP = a .length ();
6058
+ if (lengthCMP != b .length () ||
6059
+ (TSCodeRange .isPrecise (codeRangeA , codeRangeB ) && codeRangeA != codeRangeB )) {
6060
+ return false ;
6061
+ }
6062
+ if (a .isHashCodeCalculated () && b .isHashCodeCalculated ()) {
6063
+ if (a .getHashCodeUnsafe () != b .getHashCodeUnsafe ()) {
6064
+ return false ;
6065
+ }
6066
+ }
6067
+ if (lengthCMP == 0 ) {
6068
+ return true ;
6069
+ }
6070
+ Object dataA = a .data ();
6071
+ Object dataB = b .data ();
6072
+ try {
6073
+ final byte [] arrayA ;
6074
+ final long addOffsetA ;
6075
+ if (dataA instanceof byte []) {
6076
+ arrayA = (byte []) dataA ;
6077
+ addOffsetA = byteArrayBaseOffset ();
6078
+ } else if (dataA instanceof NativePointer ) {
6079
+ arrayA = null ;
6080
+ addOffsetA = NativePointer .unwrap (dataA );
6081
+ } else {
6082
+ if (dataA instanceof LazyLong lazyLongA && dataB instanceof LazyLong lazyLongB ) {
6083
+ return lazyLongA .value == lazyLongB .value ;
6084
+ }
6085
+ arrayA = a .materializeLazy (node , dataA );
6086
+ addOffsetA = byteArrayBaseOffset ();
6087
+ }
6088
+ final long offsetA = a .offset () + addOffsetA ;
6089
+
6090
+ final byte [] arrayB ;
6091
+ final long addOffsetB ;
6092
+ if (dataB instanceof byte []) {
6093
+ arrayB = (byte []) dataB ;
6094
+ addOffsetB = byteArrayBaseOffset ();
6095
+ } else if (dataB instanceof NativePointer ) {
6096
+ arrayB = null ;
6097
+ addOffsetB = NativePointer .unwrap (dataB );
6098
+ } else {
6099
+ arrayB = b .materializeLazy (node , dataB );
6100
+ addOffsetB = byteArrayBaseOffset ();
6101
+ }
6102
+ final long offsetB = b .offset () + addOffsetB ;
6103
+
6104
+ int strideA = a .stride ();
6105
+ int strideB = b .stride ();
6106
+ if ((strideA | strideB ) == 0 ) {
6107
+ // fast path: check first byte
6108
+ if (TStringOps .readS0 (arrayA , offsetA , a .length (), 0 ) != TStringOps .readS0 (arrayB , offsetB , b .length (), 0 )) {
6109
+ return false ;
6110
+ } else if (lengthCMP == 1 ) {
6111
+ return true ;
6112
+ }
6113
+ }
6114
+ return TStringOps .regionEqualsWithOrMaskWithStride (node ,
6115
+ a , arrayA , offsetA , strideA , 0 ,
6116
+ b , arrayB , offsetB , strideB , 0 , null , lengthCMP );
6117
+ } finally {
6118
+ Reference .reachabilityFence (dataA );
6119
+ Reference .reachabilityFence (dataB );
6120
+ }
6121
+ }
6122
+
6049
6123
/**
6050
6124
* Create a new {@link EqualNode}.
6051
6125
*
0 commit comments