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

Commits on Jun 20, 2015

  1. Copy the full SHA
    3c2f68b View commit details
  2. [Truffle] Fix Kernel#untaint.

    eregon committed Jun 20, 2015
    Copy the full SHA
    36eab5d View commit details
  3. [Truffle] No special cases in IsTaintedNode.

    * Just read the field to not duplicate
      the specializations of IsFrozenNode.
    eregon committed Jun 20, 2015
    Copy the full SHA
    63c3ed8 View commit details
  4. 1
    Copy the full SHA
    c608b27 View commit details
  5. Copy the full SHA
    1df9b9e View commit details
1 change: 0 additions & 1 deletion spec/truffle/tags/core/kernel/untaint_tags.txt

This file was deleted.

39 changes: 13 additions & 26 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
Original file line number Diff line number Diff line change
@@ -543,7 +543,7 @@ public ExecNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public Object require(VirtualFrame frame, Object[] args) {
public Object exec(VirtualFrame frame, Object[] args) {
if (toHashNode == null) {
CompilerDirectives.transferToInterpreter();
toHashNode = insert(DispatchHeadNodeFactory.createMethodCall(getContext()));
@@ -1956,41 +1956,28 @@ public RubyBasicObject toS(VirtualFrame frame, Object self) {
@CoreMethod(names = "untaint")
public abstract static class UntaintNode extends CoreMethodArrayArgumentsNode {

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

public UntaintNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
isFrozenNode = IsFrozenNodeGen.create(context, sourceSection, null);
isTaintedNode = IsTaintedNodeGen.create(context, sourceSection, null);
writeTaintNode = new WriteHeadObjectFieldNode(RubyBasicObject.TAINTED_IDENTIFIER);
}

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

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

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

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

private Object frozen(Object object) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().frozenError(getContext().getCoreLibrary().getLogicalClass(object).getName(), this));
}
public Object taint(RubyBasicObject object) {
if (!isTaintedNode.executeIsTainted(object)) {
return object;
}

if (isFrozenNode.executeIsFrozen(object)) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().frozenError(getContext().getCoreLibrary().getLogicalClass(object).getName(), this));
}

@Specialization
public Object taint(RubyBasicObject object) {
writeTaintNode.execute(object, false);
return object;
}
Original file line number Diff line number Diff line change
@@ -50,12 +50,7 @@ public boolean isTainted(double object) {
return false;
}

@Specialization(guards = "isRubySymbol(symbol)")
public boolean isTaintedSymbol(RubyBasicObject symbol) {
return false;
}

@Specialization(guards = "!isRubySymbol(object)")
@Specialization
public boolean isTainted(RubyBasicObject object) {
if (readTaintNode == null) {
CompilerDirectives.transferToInterpreter();
Original file line number Diff line number Diff line change
@@ -150,13 +150,16 @@ public long timeUSeconds(RubyTime time) {
@RubiniusPrimitive(name = "time_decompose")
public static abstract class TimeDecomposePrimitiveNode extends RubiniusPrimitiveNode {

@Child private ReadTimeZoneNode readTimeZoneNode;

public TimeDecomposePrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
readTimeZoneNode = new ReadTimeZoneNode(context, sourceSection);
}

@TruffleBoundary
@Specialization
public RubyBasicObject timeDecompose(RubyTime time) {
public RubyBasicObject timeDecompose(VirtualFrame frame, RubyTime time) {
CompilerDirectives.transferToInterpreter();
final DateTime dateTime = time.getDateTime();
final int sec = dateTime.getSecondOfMinute();
final int min = dateTime.getMinuteOfHour();
@@ -174,8 +177,7 @@ public RubyBasicObject timeDecompose(RubyTime time) {
final int yday = dateTime.getDayOfYear();
final boolean isdst = false;

// TODO CS 14-Feb-15 uses debug send
final String envTimeZoneString = DebugOperations.send(getContext(), getContext().getCoreLibrary().getENV(), "[]", null, createString("TZ")).toString();
final String envTimeZoneString = readTimeZoneNode.executeRubyString(frame).toString();
String zoneString = org.jruby.RubyTime.zoneHelper(envTimeZoneString, dateTime, false);
Object zone;
if (zoneString.matches(".*-\\d+")) {
@@ -210,8 +212,11 @@ public RubyBasicObject timeStrftime(RubyTime time, RubyString format) {
@RubiniusPrimitive(name = "time_s_from_array", needsSelf = true, lowerFixnumParameters = { 0 /*sec*/, 6 /*nsec*/, 7 /*isdst*/})
public static abstract class TimeSFromArrayPrimitiveNode extends RubiniusPrimitiveNode {

@Child ReadTimeZoneNode readTimeZoneNode;

public TimeSFromArrayPrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
readTimeZoneNode = new ReadTimeZoneNode(context, sourceSection);
}

@Specialization
@@ -242,7 +247,7 @@ private RubyTime buildTime(VirtualFrame frame, RubyClass timeClass, int sec, int
if (fromutc) {
zone = DateTimeZone.UTC;
} else if (utcoffset == nil()) {
String tz = DebugOperations.send(getContext(), getContext().getCoreLibrary().getENV(), "[]", null, createString("TZ")).toString();
String tz = readTimeZoneNode.executeRubyString(frame).toString();
zone = org.jruby.RubyTime.getTimeZoneFromTZString(getContext().getRuntime(), tz);
} else if (utcoffset instanceof Integer) {
zone = DateTimeZone.forOffsetMillis(((int) utcoffset) * 1_000);
Original file line number Diff line number Diff line change
@@ -11,28 +11,36 @@

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;

import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.constants.ReadConstantNode;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.literal.LiteralNode;
import org.jruby.truffle.runtime.LexicalScope;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyString;

public class ReadTimeZoneNode extends RubyNode {

@Child private CallDispatchHeadNode hashNode;
@Child private ReadConstantNode envNode;

private final RubyBasicObject TZ;

public ReadTimeZoneNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
hashNode = DispatchHeadNodeFactory.createMethodCall(context);
envNode = new ReadConstantNode(context, sourceSection, "ENV",
new LiteralNode(context, sourceSection, getContext().getCoreLibrary().getObjectClass()),
LexicalScope.NONE);
TZ = createString("TZ");
}

@Override
public RubyString executeRubyString(VirtualFrame frame) {
final Object tz = hashNode.call(frame, getContext().getCoreLibrary().getENV(), "[]", null, TZ);
final Object tz = hashNode.call(frame, envNode.execute(frame), "[]", null, TZ);

// TODO CS 4-May-15 not sure how TZ ends up being nil

3 changes: 0 additions & 3 deletions truffle/src/main/ruby/core/shims.rb
Original file line number Diff line number Diff line change
@@ -91,9 +91,6 @@ class Rational
alias :__slash__ :/
end

ENV['TZ'] = 'UTC'


# Wrapper class for Rubinius's exposure of @data within String.
#
# We can't use Array directly because we don't currently guarantee that we'll always return the same