Skip to content

Commit 5a0a7d3

Browse files
committed
Fix PackNode to use right value in guards
1 parent d90b8f2 commit 5a0a7d3

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/main/java/org/truffleruby/core/array/ArrayNodes.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,17 +1547,19 @@ public abstract static class PackNode extends CoreMethodNode {
15471547

15481548
@Specialization(
15491549
guards = {
1550-
"libFormat.isRubyString(format)",
1551-
"equalNode.execute(libFormat, format, cachedFormat, cachedEncoding)" },
1550+
"libFormat.isRubyString(formatAsString)",
1551+
"equalNode.execute(libFormat, formatAsString, cachedFormat, cachedEncoding)" },
15521552
limit = "getCacheLimit()")
15531553
protected RubyString packCached(RubyArray array, Object format,
1554+
@Cached @Shared ToStrNode toStrNode,
1555+
@Bind("toStrNode.execute(this, format)") Object formatAsString,
15541556
@Cached @Shared InlinedBranchProfile exceptionProfile,
15551557
@Cached @Shared InlinedConditionProfile resizeProfile,
15561558
@Cached @Shared RubyStringLibrary libFormat,
1557-
@Cached("asTruffleStringUncached(format)") TruffleString cachedFormat,
1558-
@Cached("libFormat.getEncoding(format)") RubyEncoding cachedEncoding,
1559+
@Cached("asTruffleStringUncached(formatAsString)") TruffleString cachedFormat,
1560+
@Cached("libFormat.getEncoding(formatAsString)") RubyEncoding cachedEncoding,
15591561
@Cached("cachedFormat.byteLength(cachedEncoding.tencoding)") int cachedFormatLength,
1560-
@Cached("create(compileFormat(getJavaString(format)))") DirectCallNode callPackNode,
1562+
@Cached("create(compileFormat(getJavaString(formatAsString)))") DirectCallNode callPackNode,
15611563
@Cached StringHelperNodes.EqualNode equalNode) {
15621564
final BytesResult result;
15631565
try {
@@ -1571,15 +1573,15 @@ protected RubyString packCached(RubyArray array, Object format,
15711573
return finishPack(cachedFormatLength, result, resizeProfile);
15721574
}
15731575

1574-
@Specialization(guards = { "libFormat.isRubyString(format)" }, replaces = "packCached", limit = "1")
1576+
@Specialization(guards = { "libFormat.isRubyString(formatAsString)" }, replaces = "packCached", limit = "1")
15751577
protected RubyString packUncached(RubyArray array, Object format,
1576-
@Cached ToStrNode toStrNode,
1578+
@Cached @Shared ToStrNode toStrNode,
1579+
@Bind("toStrNode.execute(this, format)") Object formatAsString,
15771580
@Cached @Shared InlinedBranchProfile exceptionProfile,
15781581
@Cached @Shared InlinedConditionProfile resizeProfile,
15791582
@Cached @Shared RubyStringLibrary libFormat,
15801583
@Cached ToJavaStringNode toJavaStringNode,
15811584
@Cached IndirectCallNode callPackNode) {
1582-
final var formatAsString = toStrNode.execute(this, format);
15831585
final String formatString = toJavaStringNode.execute(formatAsString);
15841586

15851587
final BytesResult result;

0 commit comments

Comments
 (0)