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

Commits on Feb 17, 2016

  1. Copy the full SHA
    2f6f0c4 View commit details
  2. Copy the full SHA
    f235cb0 View commit details
  3. Copy the full SHA
    1407e2c View commit details
  4. [Truffle] Tidy up OrNode.

    chrisseaton committed Feb 17, 2016
    Copy the full SHA
    b57de6c View commit details
  5. [Truffle] Tidy up IfNode.

    chrisseaton committed Feb 17, 2016
    Copy the full SHA
    bd48295 View commit details
  6. Copy the full SHA
    68c2f19 View commit details
  7. Copy the full SHA
    2f55695 View commit details
Original file line number Diff line number Diff line change
@@ -32,4 +32,5 @@ public Node getCallNode() {
public MaterializedFrame getMaterializedFrame() {
return materializedFrame;
}

}
Original file line number Diff line number Diff line change
@@ -35,7 +35,8 @@ public class BacktraceFormatter {
public enum FormattingFlags {
OMIT_EXCEPTION,
OMIT_FROM_PREFIX,
INCLUDE_CORE_FILES
INCLUDE_CORE_FILES,
INTERLEAVE_JAVA
}

private final RubyContext context;
@@ -48,15 +49,19 @@ public static BacktraceFormatter createDefaultFormatter(RubyContext context) {
flags.add(FormattingFlags.INCLUDE_CORE_FILES);
}

if (context.getOptions().BACKTRACES_INTERLEAVE_JAVA) {
flags.add(FormattingFlags.INTERLEAVE_JAVA);
}

return new BacktraceFormatter(context, flags);
}

// for debugging
// For debugging
public static List<String> rubyBacktrace(RubyContext context) {
return BacktraceFormatter.createDefaultFormatter(context).formatBacktrace(context, null, context.getCallStack().getBacktrace(null));
}

// for debugging
// For debugging
public static String printableRubyBacktrace(RubyContext context) {
final StringBuilder builder = new StringBuilder();
for (String line : rubyBacktrace(context)) {
@@ -87,6 +92,7 @@ public List<String> formatBacktrace(RubyContext context, DynamicObject exception
if (backtrace == null) {
backtrace = context.getCallStack().getBacktrace(null);
}

final List<Activation> activations = backtrace.getActivations();
final ArrayList<String> lines = new ArrayList<>();

@@ -112,7 +118,7 @@ public List<String> formatBacktrace(RubyContext context, DynamicObject exception
}
}

if (backtrace.getJavaThrowable() != null && context.getOptions().BACKTRACES_INTERLEAVE_JAVA) {
if (backtrace.getJavaThrowable() != null && flags.contains(FormattingFlags.INTERLEAVE_JAVA)) {
return BacktraceInterleaver.interleave(lines, backtrace.getJavaThrowable().getStackTrace());
}

Original file line number Diff line number Diff line change
@@ -17,31 +17,32 @@
import org.jruby.truffle.core.cast.BooleanCastNodeGen;
import org.jruby.truffle.language.RubyNode;

/**
* Represents a Ruby {@code and} or {@code &&} expression.
*/
public class AndNode extends RubyNode {

@Child private RubyNode left;
@Child private BooleanCastNode leftCast;
@Child private RubyNode right;

@Child private BooleanCastNode leftCast;

private final ConditionProfile conditionProfile = ConditionProfile.createCountingProfile();

public AndNode(RubyContext context, SourceSection sourceSection, RubyNode left, RubyNode right) {
super(context, sourceSection);
this.left = left;
leftCast = BooleanCastNodeGen.create(context, sourceSection, null);
this.right = right;
leftCast = BooleanCastNodeGen.create(context, sourceSection, null);
}

@Override
public Object execute(VirtualFrame frame) {
final Object leftValue = left.execute(frame);
if (conditionProfile.profile(leftCast.executeBoolean(frame, leftValue))) {
// Right expression evaluated and returned if left expression returns true.
final boolean leftBoolean = leftCast.executeBoolean(frame, leftValue);

if (conditionProfile.profile(leftBoolean)) {
return right.execute(frame);
} else {
return leftValue;
}
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -17,24 +17,17 @@
import org.jruby.truffle.core.cast.BooleanCastNodeGen;
import org.jruby.truffle.language.RubyNode;

/**
* Represents a Ruby {@code if} expression. Note that in this representation we always have an
* {@code else} part.
*/
public class IfNode extends RubyNode {

@Child private BooleanCastNode condition;
@Child private RubyNode thenBody;
@Child private RubyNode elseBody;

private final ConditionProfile conditionProfile = ConditionProfile.createCountingProfile();

public IfNode(RubyContext context, SourceSection sourceSection, RubyNode condition, RubyNode thenBody, RubyNode elseBody) {
super(context, sourceSection);

assert condition != null;
assert thenBody != null;
assert elseBody != null;

this.condition = BooleanCastNodeGen.create(context, sourceSection, condition);
this.thenBody = thenBody;
this.elseBody = elseBody;
@@ -48,4 +41,5 @@ public Object execute(VirtualFrame frame) {
return elseBody.execute(frame);
}
}

}
Original file line number Diff line number Diff line change
@@ -16,9 +16,6 @@
import org.jruby.truffle.core.cast.BooleanCastNodeGen;
import org.jruby.truffle.language.RubyNode;

/**
* Cast to boolean and negate, as {@code BasicObject#!}.
*/
public class NotNode extends RubyNode {

@Child private BooleanCastNode child;
Original file line number Diff line number Diff line change
@@ -17,30 +17,32 @@
import org.jruby.truffle.core.cast.BooleanCastNodeGen;
import org.jruby.truffle.language.RubyNode;

/**
* Represents a Ruby {@code or} or {@code ||} expression.
*/
public class OrNode extends RubyNode {

@Child private RubyNode left;
@Child private BooleanCastNode leftCast;
@Child private RubyNode right;

@Child private BooleanCastNode leftCast;

private final ConditionProfile conditionProfile = ConditionProfile.createCountingProfile();

public OrNode(RubyContext context, SourceSection sourceSection, RubyNode left, RubyNode right) {
super(context, sourceSection);
this.left = left;
leftCast = BooleanCastNodeGen.create(context, sourceSection, null);
this.right = right;
leftCast = BooleanCastNodeGen.create(context, sourceSection, null);
}

@Override
public Object execute(VirtualFrame frame) {
final Object leftValue = left.execute(frame);
if (conditionProfile.profile(leftCast.executeBoolean(frame, leftValue))) {
final boolean leftBoolean = leftCast.executeBoolean(frame, leftValue);

if (conditionProfile.profile(leftBoolean)) {
return leftValue;
} else {
return right.execute(frame);
}
}

}