Skip to content

Commit

Permalink
Merge branch 'jruby-9.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Apr 16, 2018
2 parents e7bf9d1 + be44d2d commit ef34483
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 6 deletions.
17 changes: 13 additions & 4 deletions core/src/main/java/org/jruby/RubyNumeric.java
Expand Up @@ -1059,20 +1059,29 @@ private static void fixnumStep(ThreadContext context, Ruby runtime, RubyFixnum f
long i = from.getLongValue();
long diff = step.getLongValue();

// We must avoid integer overflows in "i += step".
if (inf) {
for (;; i += diff) {
block.yield(context, RubyFixnum.newFixnum(runtime, i));
}
} else {
// We must avoid integer overflows in "i += step".
long end = ((RubyFixnum) to).getLongValue();

if (desc) {
for (; i >= end && i < Long.MAX_VALUE; i += diff) {
long tov = Long.MIN_VALUE - diff;
if (end > tov) tov = end;
for (; i >= tov; i += diff) {
block.yield(context, RubyFixnum.newFixnum(runtime, i));
}
if (i >= end) {
block.yield(context, RubyFixnum.newFixnum(runtime, i));
}
} else {
for (; i <= end && i > Long.MIN_VALUE; i += diff) {
long tov = Long.MAX_VALUE - diff;
if (end < tov) tov = end;
for (; i <= tov; i += diff) {
block.yield(context, RubyFixnum.newFixnum(runtime, i));
}
if (i <= end) {
block.yield(context, RubyFixnum.newFixnum(runtime, i));
}
}
Expand Down
6 changes: 6 additions & 0 deletions core/src/main/java/org/jruby/RubyThread.java
Expand Up @@ -64,6 +64,7 @@
import org.jruby.anno.JRubyMethod;
import org.jruby.exceptions.RaiseException;
import org.jruby.exceptions.ThreadKill;
import org.jruby.exceptions.Unrescuable;
import org.jruby.internal.runtime.NativeThread;
import org.jruby.internal.runtime.RubyRunnable;
import org.jruby.internal.runtime.ThreadLike;
Expand Down Expand Up @@ -1729,6 +1730,11 @@ protected void printReportExceptionWarning() {
* @param throwable
*/
public void exceptionRaised(Throwable throwable) {
// if unrescuable (internal exceptions) just re-raise and let it be handled by thread handler
if (throwable instanceof Unrescuable) {
Helpers.throwException(throwable);
}

Ruby runtime = getRuntime();

assert isCurrent();
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/JumpInstr.java
Expand Up @@ -16,6 +16,10 @@ public Label getJumpTarget() {
return (Label) getOperand1();
}

public void setJumpTarget(Label target) {
setOperand1(target);
}

@Override
public Instr clone(CloneInfo ii) {
return new JumpInstr(ii.getRenamedLabel(getJumpTarget()));
Expand Down
Expand Up @@ -7,4 +7,5 @@
*/
public interface JumpTargetInstr {
Label getJumpTarget();
void setJumpTarget(Label target);
}
Expand Up @@ -34,6 +34,10 @@ public void setOperand(int i, Operand operand) {
}
}

public void setJumpTarget(Label target) {
this.jumpTarget = target;
}

public Label getJumpTarget() {
return jumpTarget;
}
Expand Down
Expand Up @@ -38,6 +38,10 @@ public void setOperand(int i, Operand operand) {
}
}

public void setJumpTarget(Label target) {
this.jumpTarget = target;
}

public Label getJumpTarget() {
return jumpTarget;
}
Expand Down
14 changes: 13 additions & 1 deletion core/src/main/java/org/jruby/ir/representations/CFG.java
Expand Up @@ -2,7 +2,6 @@

import org.jruby.dirgra.DirectedGraph;
import org.jruby.dirgra.Edge;
import org.jruby.ir.IRClosure;
import org.jruby.ir.IRManager;
import org.jruby.ir.IRScope;
import org.jruby.ir.Operation;
Expand Down Expand Up @@ -476,6 +475,19 @@ private boolean mergeBBs(BasicBlock a, BasicBlock b) {
addEdge(a, e.getDestination().getData(), e.getType());
}

// Move all incoming edges of b to be incoming edges of a.
for (Edge<BasicBlock> e : getIncomingEdges(b)) {
BasicBlock fixupBB = e.getSource().getData();
removeEdge(fixupBB, b);
addEdge(fixupBB, a, e.getType());

// a -fall-through->b handled above. Any jumps to b must be pointed to a's label.
Instr fixupLastInstr = fixupBB.getLastInstr();
if (fixupLastInstr instanceof JumpTargetInstr) {
((JumpTargetInstr) fixupLastInstr).setJumpTarget(a.getLabel());
}
}

// Delete bb
removeBB(b);

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/util/io/EncodingUtils.java
Expand Up @@ -57,7 +57,7 @@
import java.util.List;

public class EncodingUtils {
public static final int ECONV_DEFAULT_NEWLINE_DECORATOR = Platform.IS_WINDOWS ? EConvFlags.UNIVERSAL_NEWLINE_DECORATOR : 0;
public static final int ECONV_DEFAULT_NEWLINE_DECORATOR = Platform.IS_WINDOWS ? EConvFlags.CRLF_NEWLINE_DECORATOR : 0;
public static final int DEFAULT_TEXTMODE = Platform.IS_WINDOWS ? OpenFile.TEXTMODE : 0;
public static final int TEXTMODE_NEWLINE_DECORATOR_ON_WRITE = Platform.IS_WINDOWS ? EConvFlags.CRLF_NEWLINE_DECORATOR : 0;

Expand Down

0 comments on commit ef34483

Please sign in to comment.