@@ -1098,6 +1098,7 @@ final void append(TruffleStringBuilderUTF8 sb, AbstractTruffleString a, int from
1098
1098
@ Specialization
1099
1099
final void append (TruffleStringBuilderUTF16 sb , AbstractTruffleString a , int fromByteIndex , int byteLength ,
1100
1100
@ Cached @ Shared TruffleString .ToIndexableNode toIndexableNode ,
1101
+ @ Cached @ Shared TStringInternalNodes .GetPreciseCodeRangeNode getPreciseCodeRangeNode ,
1101
1102
@ Cached @ Shared InlinedBranchProfile slowPathProfile ,
1102
1103
@ Cached @ Shared InlinedBranchProfile inflateProfile ,
1103
1104
@ Cached @ Shared InlinedBranchProfile bufferGrowProfile ,
@@ -1120,30 +1121,32 @@ final void append(TruffleStringBuilderUTF16 sb, AbstractTruffleString a, int fro
1120
1121
sb .codePointLength += length ;
1121
1122
} else {
1122
1123
slowPathProfile .enter (this );
1123
- final int codeRangeA = a .codeRange ();
1124
1124
final int codePointLength ;
1125
1125
final int codeRange ;
1126
1126
if (a .stride () == 0 ) {
1127
- codeRange = TSCodeRange .markImprecise (codeRangeA );
1127
+ codeRange = TSCodeRange .markImprecise (a . codeRange () );
1128
1128
codePointLength = length ;
1129
- } else if (fromIndex == 0 && length == a .length ()) {
1130
- codeRange = codeRangeA ;
1131
- codePointLength = a .codePointLength ();
1132
- } else if (TSCodeRange .is16Bit (codeRangeA )) {
1133
- assert a .stride () == 1 ;
1134
- codeRange = TStringOps .calcStringAttributesBMP (this , arrayA , a .offset () + fromByteIndex , length );
1135
- codePointLength = length ;
1136
- } else if (TSCodeRange .isValidMultiByte (codeRangeA )) {
1137
- long attrs = TStringOps .calcStringAttributesUTF16 (this , arrayA , a .offset () + fromByteIndex , length , true );
1138
- codeRange = StringAttributes .getCodeRange (attrs );
1139
- codePointLength = StringAttributes .getCodePointLength (attrs );
1140
1129
} else {
1141
- long attrs = TStringOps .calcStringAttributesUTF16 (this , arrayA , a .offset () + fromByteIndex , length , false );
1142
- codeRange = StringAttributes .getCodeRange (attrs );
1143
- codePointLength = StringAttributes .getCodePointLength (attrs );
1130
+ final int codeRangeA = getPreciseCodeRangeNode .execute (this , a , Encoding .UTF_16 );
1131
+ if (fromIndex == 0 && length == a .length ()) {
1132
+ codeRange = codeRangeA ;
1133
+ codePointLength = a .codePointLength ();
1134
+ } else if (TSCodeRange .is16Bit (codeRangeA )) {
1135
+ assert a .stride () == 1 ;
1136
+ codeRange = TStringOps .calcStringAttributesBMP (this , arrayA , a .offset () + fromByteIndex , length );
1137
+ codePointLength = length ;
1138
+ } else if (TSCodeRange .isValidMultiByte (codeRangeA )) {
1139
+ long attrs = TStringOps .calcStringAttributesUTF16 (this , arrayA , a .offset () + fromByteIndex , length , true );
1140
+ codeRange = StringAttributes .getCodeRange (attrs );
1141
+ codePointLength = StringAttributes .getCodePointLength (attrs );
1142
+ } else {
1143
+ long attrs = TStringOps .calcStringAttributesUTF16 (this , arrayA , a .offset () + fromByteIndex , length , false );
1144
+ codeRange = StringAttributes .getCodeRange (attrs );
1145
+ codePointLength = StringAttributes .getCodePointLength (attrs );
1146
+ }
1144
1147
}
1145
1148
sb .updateCodeRange (codeRange );
1146
- sb .ensureCapacityAndInflate (this , a .length (), Stride .fromCodeRangeUTF16AllowImprecise (codeRangeA ), inflateProfile , bufferGrowProfile , errorProfile );
1149
+ sb .ensureCapacityAndInflate (this , a .length (), Stride .fromCodeRangeUTF16AllowImprecise (codeRange ), inflateProfile , bufferGrowProfile , errorProfile );
1147
1150
TStringOps .arraycopyWithStride (this ,
1148
1151
arrayA , a .offset (), a .stride (), fromIndex ,
1149
1152
sb .buf , 0 , sb .stride , sb .length , length );
@@ -1155,6 +1158,7 @@ final void append(TruffleStringBuilderUTF16 sb, AbstractTruffleString a, int fro
1155
1158
@ Specialization
1156
1159
final void append (TruffleStringBuilderUTF32 sb , AbstractTruffleString a , int fromByteIndex , int byteLength ,
1157
1160
@ Cached @ Shared TruffleString .ToIndexableNode toIndexableNode ,
1161
+ @ Cached @ Shared TStringInternalNodes .GetPreciseCodeRangeNode getPreciseCodeRangeNode ,
1158
1162
@ Cached @ Shared InlinedBranchProfile slowPathProfile ,
1159
1163
@ Cached @ Shared InlinedBranchProfile inflateProfile ,
1160
1164
@ Cached @ Shared InlinedBranchProfile bufferGrowProfile ,
@@ -1175,18 +1179,17 @@ final void append(TruffleStringBuilderUTF32 sb, AbstractTruffleString a, int fro
1175
1179
sb .buf , 0 , 0 , sb .length , length );
1176
1180
} else {
1177
1181
slowPathProfile .enter (this );
1178
- final int codeRangeA = a .codeRange ();
1179
1182
final int codeRange ;
1180
- if (a .stride () == 0 || fromIndex == 0 && length == a .length () || !TSCodeRange .isMoreGeneralThan (codeRangeA , sb .codeRange )) {
1181
- codeRange = TSCodeRange .markImprecise (codeRangeA );
1183
+ if (a .stride () == 0 || fromIndex == 0 && length == a .length () || !TSCodeRange .isMoreGeneralThan (getPreciseCodeRangeNode . execute ( this , a , Encoding . UTF_32 ) , sb .codeRange )) {
1184
+ codeRange = TSCodeRange .markImprecise (a . codeRange () );
1182
1185
} else if (a .stride () == 1 ) {
1183
1186
codeRange = TStringOps .calcStringAttributesBMP (this , arrayA , a .offset () + (fromIndex << 1 ), length );
1184
1187
} else {
1185
1188
assert a .stride () == 2 ;
1186
1189
codeRange = TStringOps .calcStringAttributesUTF32 (this , arrayA , a .offset () + fromByteIndex , length );
1187
1190
}
1188
1191
sb .updateCodeRange (codeRange );
1189
- sb .ensureCapacityAndInflate (this , a .length (), Stride .fromCodeRangeUTF32AllowImprecise (codeRangeA ), inflateProfile , bufferGrowProfile , errorProfile );
1192
+ sb .ensureCapacityAndInflate (this , a .length (), Stride .fromCodeRangeUTF32AllowImprecise (codeRange ), inflateProfile , bufferGrowProfile , errorProfile );
1190
1193
TStringOps .arraycopyWithStride (this ,
1191
1194
arrayA , a .offset (), a .stride (), fromIndex ,
1192
1195
sb .buf , 0 , sb .stride , sb .length , length );
@@ -1199,7 +1202,7 @@ static void append(TruffleStringBuilderGeneric sb, AbstractTruffleString a, int
1199
1202
@ Bind ("this" ) Node node ,
1200
1203
@ Cached @ Shared TruffleString .ToIndexableNode toIndexableNode ,
1201
1204
@ Cached TStringInternalNodes .GetCodePointLengthNode getCodePointLengthNode ,
1202
- @ Cached TStringInternalNodes .GetPreciseCodeRangeNode getPreciseCodeRangeNode ,
1205
+ @ Cached @ Exclusive TStringInternalNodes .GetPreciseCodeRangeNode getPreciseCodeRangeNode ,
1203
1206
@ Cached TStringInternalNodes .CalcStringAttributesNode calcAttributesNode ,
1204
1207
@ Cached InlinedConditionProfile calcAttrsProfile ,
1205
1208
@ Cached @ Shared InlinedBranchProfile bufferGrowProfile ,
0 commit comments