Skip to content

Commit

Permalink
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -18,6 +18,8 @@
import org.jruby.truffle.nodes.RubyGuards;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.cast.ToSNode;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.objects.IsTaintedNode;
import org.jruby.truffle.nodes.objects.IsTaintedNodeGen;
import org.jruby.truffle.nodes.objects.TaintNode;
@@ -33,6 +35,8 @@ public final class InterpolatedStringNode extends RubyNode {

@Children private final ToSNode[] children;

@Child private CallDispatchHeadNode concatNode;
@Child private CallDispatchHeadNode dupNode;
@Child private IsTaintedNode isTaintedNode;
@Child private TaintNode taintNode;

@@ -41,6 +45,8 @@ public final class InterpolatedStringNode extends RubyNode {
public InterpolatedStringNode(RubyContext context, SourceSection sourceSection, ToSNode[] children) {
super(context, sourceSection);
this.children = children;
concatNode = DispatchHeadNodeFactory.createMethodCall(context);
dupNode = DispatchHeadNodeFactory.createMethodCall(context);
isTaintedNode = IsTaintedNodeGen.create(context, sourceSection, null);
taintNode = TaintNodeGen.create(context, sourceSection, null);
}
@@ -58,7 +64,7 @@ public Object execute(VirtualFrame frame) {
tainted |= isTaintedNode.executeIsTainted(toInterpolate);
}

final Object string = concat(strings);
final Object string = concat(frame, strings);

if (taintProfile.profile(tainted)) {
taintNode.executeTaint(string);
@@ -68,26 +74,22 @@ public Object execute(VirtualFrame frame) {
}

@TruffleBoundary
private DynamicObject concat(Object[] strings) {
private Object concat(VirtualFrame frame, Object[] strings) {

This comment has been minimized.

Copy link
@eregon

eregon Sep 28, 2015

Member

Why is it still a boundary?

This comment has been minimized.

Copy link
@nirvdrum

nirvdrum Sep 28, 2015

Author Contributor

I overlooked it. Thanks. I'm surprised I was even able to compile it. I thought Truffle complained about boundaries on methods that take a VirtualFrame.

This comment has been minimized.

Copy link
@eregon

eregon Sep 28, 2015

Member

Yes, that detection seems to only work in DSL nodes, and even then it's sporadic.

// TODO(CS): there is a lot of copying going on here - and I think this is sometimes inner loop stuff

org.jruby.RubyString builder = null;
Object builder = null;

for (Object string : strings) {
assert RubyGuards.isRubyString(string);

if (builder == null) {
builder = getContext().toJRubyString((DynamicObject) string);
builder = dupNode.call(frame, string, "dup", null);
} else {
try {
builder.append19(getContext().toJRuby(string));
} catch (org.jruby.exceptions.RaiseException e) {
throw new RaiseException(getContext().getCoreLibrary().encodingCompatibilityErrorIncompatible(builder.getEncoding().getCharsetName(), Layouts.STRING.getByteList((DynamicObject) string).getEncoding().getCharsetName(), this));
}
builder = concatNode.call(frame, builder, "concat", null, string);
}
}

return getContext().toTruffle(builder);
return builder;
}

}

0 comments on commit 4c22a45

Please sign in to comment.