Skip to content

Commit

Permalink
Showing 6 changed files with 41 additions and 22 deletions.
4 changes: 0 additions & 4 deletions spec/truffle/tags/core/kernel/taint_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/kernel/trust_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/kernel/untrust_tags.txt

This file was deleted.

3 changes: 0 additions & 3 deletions spec/truffle/tags/core/kernel/untrusted_tags.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -47,10 +47,16 @@ public boolean isTainted(double object) {
return false;
}

@Specialization
@Specialization(guards = "isRubySymbol(object) || isNil(object)")
protected boolean isTaintedNilOrSymbol(
DynamicObject object) {

This comment has been minimized.

Copy link
@nirvdrum

nirvdrum Apr 19, 2016

Contributor

Small thing, but I don't think you need to put this on its own line. There are no other arguments to try to align.

This comment has been minimized.

Copy link
@bjfish

bjfish Apr 19, 2016

Author Contributor

@nirvdrum Okay, I've added a commit to fix this

return false;
}

@Specialization(guards = {"!isRubySymbol(object)", "!isNil(object)"})
protected boolean isTainted(
DynamicObject object,
@Cached("createReadTaintedNode()") ReadObjectFieldNode readTaintedNode) {
DynamicObject object,
@Cached("createReadTaintedNode()") ReadObjectFieldNode readTaintedNode) {
return (boolean) readTaintedNode.execute(object);
}

Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
*/
package org.jruby.truffle.language.objects;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.Specialization;
@@ -22,6 +23,9 @@
@NodeChild(value = "child", type = RubyNode.class)
public abstract class TaintNode extends RubyNode {

@Child private IsFrozenNode isFrozenNode;
@Child private IsTaintedNode isTaintedNode;

public TaintNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}
@@ -30,33 +34,51 @@ public TaintNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public Object taint(boolean object) {
return frozen(object);
return object;
}

@Specialization
public Object taint(int object) {
return frozen(object);
return object;
}

@Specialization
public Object taint(long object) {
return frozen(object);
return object;
}

@Specialization
public Object taint(double object) {
return frozen(object);
return object;
}

@Specialization(guards = "isRubySymbol(symbol)")
public Object taintSymbol(DynamicObject symbol) {
return frozen(symbol);

@Specialization(guards = "isRubySymbol(object) || isNil(object)")
public Object taintNilOrSymbol(DynamicObject object) {
return object;
}

@Specialization(guards = "!isRubySymbol(object)")
@Specialization(guards = {"!isRubySymbol(object)", "!isNil(object)"})
public Object taint(
DynamicObject object,
@Cached("createWriteTaintNode()") WriteObjectFieldNode writeTaintNode) {
DynamicObject object,
@Cached("createWriteTaintNode()") WriteObjectFieldNode writeTaintNode) {

if (isTaintedNode == null) {
CompilerDirectives.transferToInterpreter();
isTaintedNode = insert(IsTaintedNodeGen.create(getContext(), getSourceSection(), null));
}

if (!isTaintedNode.executeIsTainted(object)) {
if (isFrozenNode == null) {
CompilerDirectives.transferToInterpreter();
isFrozenNode = insert(IsFrozenNodeGen.create(getContext(), getSourceSection(), null));
}

if (isFrozenNode.executeIsFrozen(object)) {
frozen(object);
}
}

writeTaintNode.execute(object, true);
return object;
}

1 comment on commit 58ff364

@chrisseaton
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work @bjfish!

Sorry, something went wrong.

Please sign in to comment.