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

Commits on Mar 5, 2015

  1. Copy the full SHA
    31cdfe6 View commit details
  2. [Truffle] Code cleanup.

    nirvdrum committed Mar 5, 2015
    Copy the full SHA
    637f361 View commit details
  3. Copy the full SHA
    8136f05 View commit details
  4. Copy the full SHA
    b5496e8 View commit details
  5. Copy the full SHA
    36d882b View commit details
  6. Copy the full SHA
    f081603 View commit details
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
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;
@@ -62,6 +63,7 @@ public Object maybeTaint(RubyBasicObject source, RubyBasicObject result) {
return result;
}

@ExplodeLoop
@Override
public Object execute(VirtualFrame frame) {
final RubyBasicObject result;
@@ -77,6 +79,7 @@ public Object execute(VirtualFrame frame) {
maybeTaint((RubyBasicObject) RubyArguments.getSelf(frame.getArguments()), result);
}

// TODO (nirvdrum 05-Mar-15) If we never pass more than one value in practice, we should change the annotation to be int rather than int[].
for (int i = 0; i < taintFromParameters.length; i++) {
// It's possible the taintFromParamaters value was misconfigured by the user, but the far more likely
// scenario is that the argument at that position is an UndefinedPlaceholder, which doesn't take up
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
import org.jruby.truffle.nodes.objectstorage.ReadHeadObjectFieldNode;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubySymbol;

@NodeChild(value = "child", type = RubyNode.class)
public abstract class IsTaintedNode extends RubyNode {
@@ -56,6 +57,11 @@ public boolean isTainted(double object) {
}

@Specialization
public boolean isTainted(RubySymbol object) {
return false;
}

@Specialization(guards = "!isRubySymbol")
public boolean isTainted(RubyBasicObject object) {
if (readTaintNode == null) {
CompilerDirectives.transferToInterpreter();
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubySymbol;

@NodeChild(value = "child", type = RubyNode.class)
public abstract class TaintNode extends RubyNode {
@@ -56,6 +57,11 @@ public Object taint(double object) {
}

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

@Specialization(guards = "!isRubySymbol")
public Object taint(RubyBasicObject object) {
if (writeTaintNode == null) {
CompilerDirectives.transferToInterpreter();
Original file line number Diff line number Diff line change
@@ -131,55 +131,31 @@ private static void printMethodASTBacktrace(Node currentNode) {
printASTForBacktrace(currentNode.getRootNode(), activeNodes, 0);
}

public static Object freeze(Boolean object) {
return object;
}

public static Object freeze(Integer object) {
return object;
}

public static Object freeze(Long object) {
return object;
}

public static Object freeze(Double object) {
return object;
}

public static Object freeze(RubySymbol object) {
return object;
}
public static Object verySlowFreeze(Object o) {
if ((o instanceof Boolean) ||
(o instanceof Integer) ||
(o instanceof Long) ||
(o instanceof Double) ||
(o instanceof RubySymbol)) {
return o;
}

public static Object freeze(Object o) {
final RubyBasicObject object = (RubyBasicObject) o;

object.getOperations().setInstanceVariable(object, RubyBasicObject.FROZEN_IDENTIFIER, true);

return o;
}

public static boolean isFrozen(Boolean object) {
return true;
}

public static boolean isFrozen(Integer object) {
return true;
}

public static boolean isFrozen(Long object) {
return true;
}

public static boolean isFrozen(Double object) {
return true;
}

public static boolean isFrozen(RubySymbol object) {
return true;
}
public static boolean verySlowIsFrozen(Object o) {
if ((o instanceof Boolean) ||
(o instanceof Integer) ||
(o instanceof Long) ||
(o instanceof Double) ||
(o instanceof RubySymbol)) {
return true;
}

public static boolean isFrozen(Object o) {
final RubyBasicObject object = (RubyBasicObject) o;

final Shape layout = object.getDynamicObject().getShape();
@@ -194,7 +170,15 @@ public static boolean isFrozen(Object o) {
return (boolean) storageLocation.get(object.getDynamicObject(), layout);
}

public static boolean isTainted(Object o) {
public static boolean verySlowIsTainted(Object o) {
if ((o instanceof Boolean) ||
(o instanceof Integer) ||
(o instanceof Long) ||
(o instanceof Double) ||
(o instanceof RubySymbol)) {
return false;
}

final RubyBasicObject object = (RubyBasicObject) o;

final Shape layout = object.getDynamicObject().getShape();
Original file line number Diff line number Diff line change
@@ -76,12 +76,12 @@ public boolean hasClassAsSingleton() {

@Deprecated
public void freeze() {
DebugOperations.freeze(this);
DebugOperations.verySlowFreeze(this);
}

@Deprecated
public void checkFrozen(Object self, Node currentNode) {
if (DebugOperations.isFrozen(self)) {
public void checkFrozen(Node currentNode) {
if (DebugOperations.verySlowIsFrozen(this)) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().frozenError(getLogicalClass().getName(), currentNode));
}
@@ -107,8 +107,8 @@ public RubyClass getSingletonClass(Node currentNode) {
metaClass = RubyClass.createSingletonClassOfObject(getContext(), logicalClass,
String.format("#<Class:#<%s:0x%x>>", logicalClass.getName(), getObjectID()));

if (DebugOperations.isFrozen(this)) {
DebugOperations.freeze(metaClass);
if (DebugOperations.verySlowIsFrozen(this)) {
DebugOperations.verySlowFreeze(metaClass);
}

return metaClass;
Original file line number Diff line number Diff line change
@@ -23,7 +23,6 @@

import org.jruby.runtime.Visibility;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.methods.AddMethodNode;
import org.jruby.truffle.nodes.objects.Allocator;
import org.jruby.truffle.runtime.*;
import org.jruby.truffle.runtime.control.RaiseException;
@@ -177,7 +176,7 @@ public boolean isOnlyAModule() {
public void include(Node currentNode, RubyModule module) {
RubyNode.notDesignedForCompilation();

checkFrozen(this, currentNode);
checkFrozen(currentNode);

// We need to traverse the module chain in reverse order
Stack<RubyModule> moduleAncestors = new Stack<>();
@@ -213,7 +212,7 @@ public void setAutoloadConstant(Node currentNode, String name, RubyString filena
private void setConstantInternal(Node currentNode, String name, Object value, boolean autoload) {
RubyNode.notDesignedForCompilation();

checkFrozen(this ,currentNode);
checkFrozen(currentNode);

RubyConstant previous = constants.get(name);
if (previous == null) {
@@ -231,7 +230,7 @@ private void setConstantInternal(Node currentNode, String name, Object value, bo
public RubyConstant removeConstant(Node currentNode, String name) {
RubyNode.notDesignedForCompilation();

checkFrozen(this, currentNode);
checkFrozen(currentNode);
RubyConstant oldConstant = constants.remove(name);
newLexicalVersion();
return oldConstant;
@@ -241,7 +240,7 @@ public RubyConstant removeConstant(Node currentNode, String name) {
public void setClassVariable(Node currentNode, String variableName, Object value) {
RubyNode.notDesignedForCompilation();

checkFrozen(this, currentNode);
checkFrozen(currentNode);

classVariables.put(variableName, value);
}
@@ -250,7 +249,7 @@ public void setClassVariable(Node currentNode, String variableName, Object value
public void removeClassVariable(Node currentNode, String variableName) {
RubyNode.notDesignedForCompilation();

checkFrozen(this, currentNode);
checkFrozen(currentNode);

classVariables.remove(variableName);
}
@@ -261,7 +260,7 @@ public void addMethod(Node currentNode, InternalMethod method) {

assert method != null;

checkFrozen(this, currentNode);
checkFrozen(currentNode);
methods.put(method.getName(), method.withDeclaringModule(this));
newVersion();
}
@@ -270,7 +269,7 @@ public void addMethod(Node currentNode, InternalMethod method) {
public void removeMethod(Node currentNode, String methodName) {
RubyNode.notDesignedForCompilation();

checkFrozen(this, currentNode);
checkFrozen(currentNode);

methods.remove(methodName);
newVersion();
@@ -328,7 +327,7 @@ public void changeConstantVisibility(Node currentNode, RubySymbol constant, bool
RubyNode.notDesignedForCompilation();

RubyConstant rubyConstant = ModuleOperations.lookupConstant(getContext(), LexicalScope.NONE, this, constant.toString());
checkFrozen(this, currentNode);
checkFrozen(currentNode);

if (rubyConstant != null) {
rubyConstant.setPrivate(isPrivate);