Skip to content

Commit 3b690b5

Browse files
committed
Convert StringAppendNode to DSL inlinable node
1 parent 6657131 commit 3b690b5

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

src/main/java/org/truffleruby/core/string/StringHelperNodes.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -592,22 +592,18 @@ static int getCodePoint(Node node, AbstractTruffleString string, RubyEncoding en
592592

593593
}
594594

595+
@GenerateInline
596+
@GenerateCached(false)
595597
public abstract static class StringAppendNode extends RubyBaseNode {
596598

597-
@NeverDefault
598-
public static StringAppendNode create() {
599-
return StringHelperNodesFactory.StringAppendNodeGen.create();
600-
}
601-
602-
public abstract RubyString executeStringAppend(Object string, Object other);
599+
public abstract RubyString executeStringAppend(Node node, Object string, Object other);
603600

604601
@Specialization(guards = "libOther.isRubyString(other)", limit = "1")
605-
static RubyString stringAppend(Object string, Object other,
602+
static RubyString stringAppend(Node node, Object string, Object other,
606603
@Cached RubyStringLibrary libString,
607604
@Cached RubyStringLibrary libOther,
608605
@Cached EncodingNodes.CheckStringEncodingNode checkEncodingNode,
609-
@Cached TruffleString.ConcatNode concatNode,
610-
@Bind("this") Node node) {
606+
@Cached(inline = false) TruffleString.ConcatNode concatNode) {
611607

612608
var left = libString.getTString(string);
613609
var leftEncoding = libString.getEncoding(string);

src/main/java/org/truffleruby/core/string/StringNodes.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ RubyString add(Object string, Object other,
222222
@Cached ToStrNode toStrNode,
223223
@Cached StringHelperNodes.StringAppendNode stringAppendNode) {
224224
final var otherAsString = toStrNode.execute(this, other);
225-
return stringAppendNode.executeStringAppend(string, otherAsString);
225+
return stringAppendNode.executeStringAppend(this, string, otherAsString);
226226
}
227227
}
228228

@@ -3105,9 +3105,6 @@ protected boolean isMBCPrintable(Encoding encoding, int codePoint) {
31053105
@Primitive(name = "string_append")
31063106
public abstract static class StringAppendPrimitiveNode extends PrimitiveArrayArgumentsNode {
31073107

3108-
@Child private StringHelperNodes.StringAppendNode stringAppendNode = StringHelperNodes.StringAppendNode
3109-
.create();
3110-
31113108
@NeverDefault
31123109
public static StringAppendPrimitiveNode create() {
31133110
return StringAppendPrimitiveNodeFactory.create(null);
@@ -3116,8 +3113,9 @@ public static StringAppendPrimitiveNode create() {
31163113
public abstract RubyString executeStringAppend(RubyString string, Object other);
31173114

31183115
@Specialization
3119-
RubyString stringAppend(RubyString string, Object other) {
3120-
final RubyString result = stringAppendNode.executeStringAppend(string, other);
3116+
RubyString stringAppend(RubyString string, Object other,
3117+
@Cached StringHelperNodes.StringAppendNode stringAppendNode) {
3118+
final RubyString result = stringAppendNode.executeStringAppend(this, string, other);
31213119
string.setTString(result.tstring, result.getEncodingUnprofiled());
31223120
return string;
31233121
}

0 commit comments

Comments
 (0)