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

Commits on Jan 3, 2015

  1. Copy the full SHA
    48c8202 View commit details
  2. Copy the full SHA
    a3ee8f7 View commit details
  3. Copy the full SHA
    7761539 View commit details
  4. Copy the full SHA
    89a0471 View commit details
  5. Copy the full SHA
    d454e2f View commit details
  6. Copy the full SHA
    5093171 View commit details
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;
import com.oracle.truffle.api.utilities.ConditionProfile;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.ReturnException;
@@ -25,7 +25,7 @@ public class CallRubiniusPrimitiveNode extends RubyNode {
@Child protected RubyNode primitive;
private final long returnID;

private final BranchProfile branchProfile = BranchProfile.create();
private final ConditionProfile primitiveSucceededCondition = ConditionProfile.createBinaryProfile();

public CallRubiniusPrimitiveNode(RubyContext context, SourceSection sourceSection, RubyNode primitive, long returnID) {
super(context, sourceSection);
@@ -37,17 +37,13 @@ public CallRubiniusPrimitiveNode(RubyContext context, SourceSection sourceSectio
public void executeVoid(VirtualFrame frame) {
final Object value = primitive.execute(frame);

// Primitives may return null to indicate that they have failed

if (value != null) {
// If they didn't fail it's a return in the calling method
if (primitiveSucceededCondition.profile(value != null)) {
// If the primitive didn't fail its value is returned in the calling method

throw new ReturnException(returnID, value);
}

// The code after a primitive call is a fallback, so it makes sense to cut it off

branchProfile.enter();
// Primitives may return null to indicate that they have failed, in which case we continue with the fallback
}

@Override
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ public RubyTimeToDateTimeNode(RubyContext context, SourceSection sourceSection)
public DateTime toDateTime(VirtualFrame frame, RubyTime time) {
final Object isGMTObject = readIsGMTNode.execute(time);

// The @is_gmt instance varibale is only for internal use so we don't need a full cast here
// The @is_gmt instance variable is only for internal use so we don't need a full cast here

final boolean isGMT;

Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@

import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.ConditionProfile;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.*;

@@ -22,6 +23,8 @@ public abstract class StringPrimitiveNodes {
@RubiniusPrimitive(name = "string_check_null_safe", needsSelf = false)
public static abstract class StringCheckNullSafePrimitiveNode extends RubiniusPrimitiveNode {

private final ConditionProfile nullByteProfile = ConditionProfile.createBinaryProfile();

public StringCheckNullSafePrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}
@@ -33,7 +36,7 @@ public StringCheckNullSafePrimitiveNode(StringCheckNullSafePrimitiveNode prev) {
@Specialization
public boolean stringCheckNullSafe(RubyString string) {
for (byte b : string.getBytes().unsafeBytes()) {
if (b == 0) {
if (nullByteProfile.profile(b == 0)) {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -41,9 +41,10 @@ public TimeSNowPrimitiveNode(TimeSNowPrimitiveNode prev) {

@Specialization
public RubyTime timeSNow(RubyClass timeClass) {
final long milliseconds = System.currentTimeMillis();
return new RubyTime(timeClass,
TimeOperations.millisecondsToSeconds(System.currentTimeMillis()),
TimeOperations.millisecondsToNanoseconds(TimeOperations.millisecondsInCurrentSecond(System.currentTimeMillis())));
TimeOperations.millisecondsToSeconds(milliseconds),
TimeOperations.millisecondsToNanoseconds(TimeOperations.millisecondsInCurrentSecond(milliseconds)));
}

}
Original file line number Diff line number Diff line change
@@ -371,11 +371,11 @@ private RubyNode translateRubiniusPrimitive(SourceSection sourceSection, CallNod
/*
* Translates something that looks like
*
* Rubinius.primitive :foo
* Rubinius.primitive :foo
*
* into
*
* CallRubiniusPrimitiveNode(FooNode(arg1, arg2, ..., argN))
* CallRubiniusPrimitiveNode(FooNode(arg1, arg2, ..., argN))
*
* Where the arguments are the same arguments as the method. It looks like this is only exercised with simple
* arguments so we're not worrying too much about what happens when they're more complicated (rest,
@@ -412,11 +412,11 @@ private RubyNode translateRubiniusInvokePrimitive(SourceSection sourceSection, C
/*
* Translates something that looks like
*
* Rubinius.invoke_primitive :foo, arg1, arg2, argN
* Rubinius.invoke_primitive :foo, arg1, arg2, argN
*
* into
*
* CallRubiniusPrimitiveNode(FooNode(arg1, arg2, ..., argN))
* CallRubiniusPrimitiveNode(FooNode(arg1, arg2, ..., argN))
*/

if (node.getArgsNode().childNodes().size() < 1 || !(node.getArgsNode().childNodes().get(0) instanceof org.jruby.ast.SymbolNode)) {
@@ -442,13 +442,13 @@ private RubyNode translateRubiniusPrivately(SourceSection sourceSection, CallNod
/*
* Translates something that looks like
*
* Rubinius.privately { foo }
* Rubinius.privately { foo }
*
* into
* into just
*
* foo
* foo
*
* While we translate foo we'll make all call sites as ignoring visbility.
* While we translate foo we'll mark all call sites as ignoring visbility.
*/

if (!(node.getIterNode() instanceof org.jruby.ast.IterNode)) {
@@ -459,13 +459,28 @@ private RubyNode translateRubiniusPrivately(SourceSection sourceSection, CallNod
throw new UnsupportedOperationException("Rubinius.privately should not have any arguments");
}

/*
* Normally when you visit an 'iter' (block) node it will set the method name for you, so that we can name the
* block something like 'times-block'. Here we bypass the iter node and translate its child. So we set the
* name here.
*/

currentCallMethodName = "privately";

/*
* While we translate the body of the iter we want to create all call nodes with the ignore-visbility flag.
* This flag is checked in visitCallNodeExtraArgument.
*/

final boolean previousPrivately = privately;
privately = true;

try {
return (((org.jruby.ast.IterNode) node.getIterNode()).getBodyNode()).accept(this);
} finally {
privately = false;
// Restore the previous value of the privately flag - allowing for nesting

privately = previousPrivately;
}
}