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: ebd6f9024671
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1b9fdedc2935
Choose a head ref
  • 4 commits
  • 6 files changed
  • 1 contributor

Commits on Mar 3, 2015

  1. 13
    Copy the full SHA
    28d7ec4 View commit details
  2. Copy the full SHA
    dc28291 View commit details
  3. Copy the full SHA
    99594eb View commit details
  4. Copy the full SHA
    1b9fded View commit details
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/slice_tags.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
fails:String#slice with index, length always taints resulting strings when self is tainted
fails:String#slice with index, length returns subclass instances
fails:String#slice with Range returns an empty string if range.begin is inside self and > real end
fails:String#slice with Range always taints resulting strings when self is tainted
@@ -23,7 +22,6 @@ fails:String#slice! with index, length calls to_int on idx and length
fails:String#slice! with index, length returns subclass instances
fails:String#slice! with index, length returns the substring given by the character offsets
fails:String#slice! Range deletes and return the substring given by the offsets of the range
fails:String#slice! Range always taints resulting strings when self is tainted
fails:String#slice! Range returns subclass instances
fails:String#slice! Range calls to_int on range arguments
fails:String#slice! Range works with Range subclasses
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/

package org.jruby.truffle.nodes.cast;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.ConditionProfile;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.core.KernelNodes;
import org.jruby.truffle.nodes.core.KernelNodesFactory;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;

public class TaintResultNode extends RubyNode {

private final boolean needsSelf;
private final int taintSourceIndex;
private final ConditionProfile taintProfile = ConditionProfile.createBinaryProfile();

@Child private RubyNode method;
@Child private KernelNodes.KernelIsTaintedNode isTaintedNode;
@Child private KernelNodes.KernelTaintNode taintNode;

public TaintResultNode(RubyContext context, SourceSection sourceSection, boolean needSelf, int taintSourceIndex, RubyNode method) {
super(context, sourceSection);
this.needsSelf = needSelf;
this.taintSourceIndex = taintSourceIndex;
this.method = method;
this.isTaintedNode = KernelNodesFactory.KernelIsTaintedNodeFactory.create(context, sourceSection, new RubyNode[]{});
}

public TaintResultNode(TaintResultNode prev) {
super(prev);
needsSelf = prev.needsSelf;
taintSourceIndex = prev.taintSourceIndex;
method = prev.method;
isTaintedNode = prev.isTaintedNode;
}

@Override
public Object execute(VirtualFrame frame) {
final Object result = method.execute(frame);

if (result != getContext().getCoreLibrary().getNilObject()) {
final Object taintSource;

if (needsSelf && taintSourceIndex == 0) {
taintSource = RubyArguments.getSelf(frame.getArguments());
} else {
final int adjustedIndex = needsSelf ? taintSourceIndex - 1 : taintSourceIndex;
taintSource = RubyArguments.getUserArgument(frame.getArguments(), adjustedIndex);
}

if (taintProfile.profile(isTaintedNode.isTainted(taintSource))) {
if (taintNode == null) {
CompilerDirectives.transferToInterpreter();
taintNode = insert(KernelNodesFactory.KernelTaintNodeFactory.create(getContext(), getSourceSection(), new RubyNode[]{}));
}

taintNode.taint(result);
}
}

return result;
}
}
Original file line number Diff line number Diff line change
@@ -55,6 +55,8 @@

int[] lowerFixnumParameters() default {};

int taintSource() default -1;

UnsupportedOperationBehavior unsupportedOperationBehavior() default UnsupportedOperationBehavior.TYPE_ERROR;

}
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
import org.jruby.truffle.nodes.CoreSourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.RubyRootNode;
import org.jruby.truffle.nodes.cast.TaintResultNode;
import org.jruby.truffle.nodes.control.SequenceNode;
import org.jruby.truffle.nodes.methods.ExceptionTranslatingNode;
import org.jruby.truffle.nodes.methods.arguments.*;
@@ -199,7 +200,13 @@ private static RubyRootNode makeGenericMethod(RubyContext context, MethodDetails
verifyNoAmbiguousDefaultArguments(methodDetails);

final CheckArityNode checkArity = new CheckArityNode(context, sourceSection, arity);
final RubyNode block = SequenceNode.sequence(context, sourceSection, checkArity, methodNode);
RubyNode block = SequenceNode.sequence(context, sourceSection, checkArity, methodNode);

final int taintSource = methodDetails.getMethodAnnotation().taintSource();
if (taintSource != -1) {
block = new TaintResultNode(context, sourceSection, needsSelf, taintSource, block);
}

final ExceptionTranslatingNode exceptionTranslatingNode = new ExceptionTranslatingNode(context, sourceSection, block, methodDetails.getMethodAnnotation().unsupportedOperationBehavior());

return new RubyRootNode(context, sourceSection, null, sharedMethodInfo, exceptionTranslatingNode);
Original file line number Diff line number Diff line change
@@ -454,7 +454,7 @@ public Object clone(VirtualFrame frame, RubyBasicObject self) {

}

@CoreMethod(names = "dup")
@CoreMethod(names = "dup", taintSource = 0)
public abstract static class DupNode extends CoreMethodNode {

@Child private CallDispatchHeadNode initializeDupNode;
Original file line number Diff line number Diff line change
@@ -280,7 +280,7 @@ private RubyString formatSlow(RubyString format, Object[] args) {
}
}

@CoreMethod(names = {"[]", "slice"}, required = 1, optional = 1, lowerFixnumParameters = {0, 1})
@CoreMethod(names = {"[]", "slice"}, required = 1, optional = 1, lowerFixnumParameters = {0, 1}, taintSource = 0)
public abstract static class GetIndexNode extends CoreMethodNode {

@Child private ToIntNode toIntNode;