Skip to content

Commit 7d7ea5f

Browse files
committed
[GR-69718] Fix regression due to removed Java String caching.
PullRequest: graal/22171
2 parents de22927 + d4a6c50 commit 7d7ea5f

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TStringUnsafe.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ static int getJavaStringHashMasked(String s) {
163163
return hash;
164164
}
165165

166-
@TruffleBoundary
167166
private static String allocateJavaString() {
168167
try {
169168
return (String) UNSAFE.allocateInstance(String.class);
@@ -172,10 +171,9 @@ private static String allocateJavaString() {
172171
}
173172
}
174173

175-
@TruffleBoundary
176174
static String createJavaString(byte[] bytes, int stride, int hash) {
177175
if (stride < (COMPACT_STRINGS_ENABLED ? 0 : 1) || stride > 1) {
178-
throw new IllegalArgumentException("illegal stride!");
176+
throw CompilerDirectives.shouldNotReachHere("illegal stride!");
179177
}
180178
String ret = allocateJavaString();
181179
UNSAFE.putInt(ret, javaStringHashFieldOffset, hash);

truffle/src/com.oracle.truffle.api.strings/src/com/oracle/truffle/api/strings/TruffleString.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7006,13 +7006,13 @@ static String doUTF16(TruffleString a,
70067006
if (a.isEmpty()) {
70077007
return "";
70087008
}
7009-
TruffleString cur = a.next;
7010-
if (cur != null) {
7009+
TruffleString cur;
7010+
if (a.isCompatibleToIntl(Encoding.UTF_16) || (cur = a.next) == null) {
7011+
cur = a;
7012+
} else {
70117013
while (cur != a && !cur.isCompatibleToIntl(Encoding.UTF_16)) {
70127014
cur = cur.next;
70137015
}
7014-
} else {
7015-
cur = a;
70167016
}
70177017
Encoding encodingA = Encoding.get(cur.encoding());
70187018
final AbstractTruffleString utf16String;

0 commit comments

Comments
 (0)