Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 760d8c563e52
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1035a86f135c
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on Apr 17, 2015

  1. [Truffle] Simplify constructor used for maybeTaint.

    * taintFromSelf and taintFromParameter are unused.
    * Use the lazy node pattern and refactor StringByteSubstringPrimitiveNode.
    eregon committed Apr 17, 2015
    Copy the full SHA
    cc1fbfb View commit details
  2. Copy the full SHA
    1035a86 View commit details
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.ControlFlowException;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.ConditionProfile;
@@ -44,10 +43,10 @@ public TaintResultNode(boolean taintFromSelf, int taintFromParameter, RubyNode m
this.isTaintedNode = IsTaintedNodeFactory.create(getContext(), getSourceSection(), null);
}

public TaintResultNode(RubyContext context, SourceSection sourceSection, boolean taintFromSelf, int taintFromParameter) {
public TaintResultNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
this.taintFromSelf = taintFromSelf;
this.taintFromParameter = taintFromParameter;
this.taintFromSelf = false;
this.taintFromParameter = -1;
this.isTaintedNode = IsTaintedNodeFactory.create(getContext(), getSourceSection(), null);
}

Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ public RubyBignum coerceRubyBignum(RubyBignum value) {
public Object coerceDouble(VirtualFrame frame, double value) {
if (floatToIntNode == null) {
CompilerDirectives.transferToInterpreter();
floatToIntNode = insert(FloatNodesFactory.ToINodeFactory.create(getContext(), getSourceSection(), new RubyNode[]{}));
floatToIntNode = insert(FloatNodesFactory.ToINodeFactory.create(getContext(), getSourceSection(), new RubyNode[] { null }));
}
return floatToIntNode.executeToI(frame, value);
}
Original file line number Diff line number Diff line change
@@ -107,7 +107,7 @@ public RubyString add(RubyString string, RubyString other) {

if (taintResultNode == null) {
CompilerDirectives.transferToInterpreter();
taintResultNode = insert(new TaintResultNode(getContext(), getSourceSection(), false, -1));
taintResultNode = insert(new TaintResultNode(getContext(), getSourceSection()));
}

ret.getByteList().setEncoding(enc);
@@ -1172,7 +1172,7 @@ private Object substr(RubyString string, int beg, int len) {

if (taintResultNode == null) {
CompilerDirectives.transferToInterpreter();
taintResultNode = insert(new TaintResultNode(getContext(), getSourceSection(), true, -1));
taintResultNode = insert(new TaintResultNode(getContext(), getSourceSection()));
}

final RubyString ret = getContext().makeString(string.getLogicalClass(), substringBytes);
@@ -1417,7 +1417,7 @@ public abstract static class InsertNode extends RubyNode {
public InsertNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
concatNode = DispatchHeadNodeFactory.createMethodCall(context);
taintResultNode = new TaintResultNode(context, sourceSection, false, -1);
taintResultNode = new TaintResultNode(context, sourceSection);
}

public InsertNode(InsertNode prev) {
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@ public static abstract class StringAwkSplitPrimitiveNode extends RubiniusPrimiti

public StringAwkSplitPrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
taintResultNode = new TaintResultNode(context, sourceSection, true, -1);
taintResultNode = new TaintResultNode(context, sourceSection);
}

public StringAwkSplitPrimitiveNode(StringAwkSplitPrimitiveNode prev) {
@@ -203,7 +203,7 @@ public static abstract class StringByteSubstringPrimitiveNode extends RubiniusPr

public StringByteSubstringPrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
taintResultNode = new TaintResultNode(context, sourceSection, true, -1);
taintResultNode = new TaintResultNode(context, sourceSection);
}

public StringByteSubstringPrimitiveNode(StringByteSubstringPrimitiveNode prev) {
@@ -490,11 +490,7 @@ public Object stringFindCharacterSingleByte(RubyString string, int offset) {

final RubyString ret = getContext().makeString(string.getLogicalClass(), new ByteList(string.getByteList().unsafeBytes(), offset, 1));

ret.getByteList().setEncoding(string.getByteList().getEncoding());
ret.setCodeRange(string.getCodeRange());
getTaintResultNode().maybeTaint(string, ret);

return ret;
return propagate(string, ret);
}

@Specialization(guards = "!isSingleByte")
@@ -520,20 +516,21 @@ public Object stringFindCharacter(RubyString string, int offset) {
ret = getContext().makeString(string.getLogicalClass(), new ByteList(string.getByteList().unsafeBytes(), offset, 1));
}

return propagate(string, ret);
}

private Object propagate(RubyString string, RubyString ret) {
ret.getByteList().setEncoding(string.getByteList().getEncoding());
ret.setCodeRange(string.getCodeRange());
getTaintResultNode().maybeTaint(string, ret);

return ret;
return maybeTaint(string, ret);
}

private TaintResultNode getTaintResultNode() {
private Object maybeTaint(RubyString source, RubyString value) {
if (taintResultNode == null) {
CompilerDirectives.transferToInterpreter();
taintResultNode = insert(new TaintResultNode(getContext(), getSourceSection(), true, -1));
taintResultNode = insert(new TaintResultNode(getContext(), getSourceSection()));
}

return taintResultNode;
return taintResultNode.maybeTaint(source, value);
}

}
@@ -1313,7 +1310,7 @@ public Object stringSubstring(RubyString string, int beg, int len) {
private RubyString makeSubstring(RubyString string, int beg, int len) {
if (taintResultNode == null) {
CompilerDirectives.transferToInterpreter();
taintResultNode = insert(new TaintResultNode(getContext(), getSourceSection(), true, -1));
taintResultNode = insert(new TaintResultNode(getContext(), getSourceSection()));
}

final RubyString ret = getContext().makeString(string.getLogicalClass(), new ByteList(string.getByteList(), beg, len));