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

Commits on Jun 16, 2015

  1. Copy the full SHA
    32941af View commit details
  2. [Truffle] Remove extraneous catch(NextException | RedoException).

    * They are already caught at the right place upper in the chain.
    eregon committed Jun 16, 2015
    Copy the full SHA
    e3012aa View commit details
2 changes: 2 additions & 0 deletions spec/truffle/tags/core/kernel/spawn_tags.txt
Original file line number Diff line number Diff line change
@@ -171,3 +171,5 @@ fails:Kernel.spawn when passed :close_others => true does not close STDERR
fails:Kernel.spawn when passed :close_others => false does not close STDIN
fails:Kernel.spawn when passed :close_others => false does not close STDOUT
fails:Kernel.spawn when passed :close_others => false does not close STDERR
fails:Kernel#spawn redirects STDOUT to the given file if :out => [String name, String mode]
fails:Kernel.spawn redirects STDOUT to the given file if :out => [String name, String mode]
1 change: 1 addition & 0 deletions spec/truffle/tags/core/process/spawn_tags.txt
Original file line number Diff line number Diff line change
@@ -84,3 +84,4 @@ fails:Process.spawn when passed :close_others => true does not close STDERR
fails:Process.spawn when passed :close_others => false does not close STDIN
fails:Process.spawn when passed :close_others => false does not close STDOUT
fails:Process.spawn when passed :close_others => false does not close STDERR
fails:Process.spawn redirects STDOUT to the given file if :out => [String name, String mode]
153 changes: 29 additions & 124 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/IntegerNodes.java
Original file line number Diff line number Diff line change
@@ -13,12 +13,9 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;
import org.jruby.truffle.nodes.methods.UnsupportedOperationBehavior;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.NextException;
import org.jruby.truffle.runtime.control.RedoException;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyProc;

@@ -30,9 +27,6 @@ public abstract class IntegerNodes {
@CoreMethod(names = "downto", needsBlock = true, required = 1, returnsEnumeratorIfNoBlock = true, unsupportedOperationBehavior = UnsupportedOperationBehavior.ARGUMENT_ERROR)
public abstract static class DownToNode extends YieldingCoreMethodNode {

private final BranchProfile nextProfile = BranchProfile.create();
private final BranchProfile redoProfile = BranchProfile.create();

public DownToNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}
@@ -42,23 +36,12 @@ public Object downto(VirtualFrame frame, int from, int to, RubyProc block) {
int count = 0;

try {
outer:
for (int i = from; i >= to; i--) {
while (true) {
if (CompilerDirectives.inInterpreter()) {
count++;
}

try {
yield(frame, block, i);
continue outer;
} catch (NextException e) {
nextProfile.enter();
continue outer;
} catch (RedoException e) {
redoProfile.enter();
}
if (CompilerDirectives.inInterpreter()) {
count++;
}

yield(frame, block, i);
}
} finally {
if (CompilerDirectives.inInterpreter()) {
@@ -69,39 +52,18 @@ public Object downto(VirtualFrame frame, int from, int to, RubyProc block) {
return nil();
}

@Specialization
public Object downto(VirtualFrame frame, long from, int to, RubyProc block) {
return downto(frame, from, (long) to, block);
}

@Specialization
public Object downto(VirtualFrame frame, int from, long to, RubyProc block) {
return downto(frame, (long) from, to, block);
}

@Specialization
public Object downto(VirtualFrame frame, long from, long to, RubyProc block) {
// TODO BJF 22-Apr-2015 how to handle reportLoopCount(long)
int count = 0;

try {
outer:
for (long i = from; i >= to; i--) {
while (true) {
if (CompilerDirectives.inInterpreter()) {
count++;
}

try {
yield(frame, block, i);
continue outer;
} catch (NextException e) {
nextProfile.enter();
continue outer;
} catch (RedoException e) {
redoProfile.enter();
}
if (CompilerDirectives.inInterpreter()) {
count++;
}

yield(frame, block, i);
}
} finally {
if (CompilerDirectives.inInterpreter()) {
@@ -126,15 +88,13 @@ public abstract static class TimesNode extends YieldingCoreMethodNode {

@Child private FixnumOrBignumNode fixnumOrBignum;

private final BranchProfile nextProfile = BranchProfile.create();
private final BranchProfile redoProfile = BranchProfile.create();

public TimesNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public RubyBasicObject times(VirtualFrame frame, int n, NotProvided block) {
// TODO (eregon, 16 June 2015): this should return an enumerator
final int[] array = new int[n];

for (int i = 0; i < n; i++) {
@@ -149,22 +109,12 @@ public Object times(VirtualFrame frame, int n, RubyProc block) {
int count = 0;

try {
outer: for (int i = 0; i < n; i++) {
while (true) {
if (CompilerDirectives.inInterpreter()) {
count++;
}

try {
yield(frame, block, i);
continue outer;
} catch (NextException e) {
nextProfile.enter();
continue outer;
} catch (RedoException e) {
redoProfile.enter();
}
for (int i = 0; i < n; i++) {
if (CompilerDirectives.inInterpreter()) {
count++;
}

yield(frame, block, i);
}
} finally {
if (CompilerDirectives.inInterpreter()) {
@@ -180,22 +130,12 @@ public Object times(VirtualFrame frame, long n, RubyProc block) {
int count = 0;

try {
outer: for (long i = 0; i < n; i++) {
while (true) {
if (CompilerDirectives.inInterpreter()) {
count++;
}

try {
yield(frame, block, i);
continue outer;
} catch (NextException e) {
nextProfile.enter();
continue outer;
} catch (RedoException e) {
redoProfile.enter();
}
for (long i = 0; i < n; i++) {
if (CompilerDirectives.inInterpreter()) {
count++;
}

yield(frame, block, i);
}
} finally {
if (CompilerDirectives.inInterpreter()) {
@@ -213,18 +153,8 @@ public Object times(VirtualFrame frame, RubyBasicObject n, RubyProc block) {
fixnumOrBignum = insert(new FixnumOrBignumNode(getContext(), getSourceSection()));
}

outer: for (BigInteger i = BigInteger.ZERO; i.compareTo(BignumNodes.getBigIntegerValue(n)) < 0; i = i.add(BigInteger.ONE)) {
while (true) {
try {
yield(frame, block, fixnumOrBignum.fixnumOrBignum(i));
continue outer;
} catch (NextException e) {
nextProfile.enter();
continue outer;
} catch (RedoException e) {
redoProfile.enter();
}
}
for (BigInteger i = BigInteger.ZERO; i.compareTo(BignumNodes.getBigIntegerValue(n)) < 0; i = i.add(BigInteger.ONE)) {
yield(frame, block, fixnumOrBignum.fixnumOrBignum(i));
}

return n;
@@ -259,9 +189,6 @@ public RubyBasicObject toI(RubyBasicObject n) {
@CoreMethod(names = "upto", needsBlock = true, required = 1, returnsEnumeratorIfNoBlock = true, unsupportedOperationBehavior = UnsupportedOperationBehavior.ARGUMENT_ERROR)
public abstract static class UpToNode extends YieldingCoreMethodNode {

private final BranchProfile nextProfile = BranchProfile.create();
private final BranchProfile redoProfile = BranchProfile.create();

public UpToNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}
@@ -271,23 +198,12 @@ public Object upto(VirtualFrame frame, int from, int to, RubyProc block) {
int count = 0;

try {
outer:
for (int i = from; i <= to; i++) {
while (true) {
if (CompilerDirectives.inInterpreter()) {
count++;
}

try {
yield(frame, block, i);
continue outer;
} catch (NextException e) {
nextProfile.enter();
continue outer;
} catch (RedoException e) {
redoProfile.enter();
}
if (CompilerDirectives.inInterpreter()) {
count++;
}

yield(frame, block, i);
}
} finally {
if (CompilerDirectives.inInterpreter()) {
@@ -308,23 +224,12 @@ public Object upto(VirtualFrame frame, long from, long to, RubyProc block) {
int count = 0;

try {
outer:
for (long i = from; i <= to; i++) {
while (true) {
if (CompilerDirectives.inInterpreter()) {
count++;
}

try {
yield(frame, block, i);
continue outer;
} catch (NextException e) {
nextProfile.enter();
continue outer;
} catch (RedoException e) {
redoProfile.enter();
}
if (CompilerDirectives.inInterpreter()) {
count++;
}

yield(frame, block, i);
}
} finally {
if (CompilerDirectives.inInterpreter()) {
Loading