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

Commits on Oct 29, 2014

  1. [Truffle] Introduce ImplicitCast from int to long.

    * Only minimal changes required to make it compile.
    eregon committed Oct 29, 2014
    Copy the full SHA
    032326d View commit details
  2. Copy the full SHA
    27efcb8 View commit details
  3. Copy the full SHA
    c134174 View commit details
  4. [Truffle] Remove now useless (and incorrect!) AddNode specialization.

    * Missing rewriteOn there.
    eregon committed Oct 29, 2014
    Copy the full SHA
    27712b7 View commit details
  5. [Truffle] Remove a useless AddNode specialization.

    * Identical to the previous one.
    eregon committed Oct 29, 2014
    Copy the full SHA
    5a1bfde View commit details
  6. [Truffle] Add with overflow should be SlowPath, otherwise it makes th…

    …ings much slower!
    
    * for chunky-canvas-resampling-nearest-neighbor at least.
    eregon committed Oct 29, 2014
    Copy the full SHA
    b23bd9b View commit details
6 changes: 6 additions & 0 deletions core/src/main/java/org/jruby/truffle/nodes/RubyTypes.java
Original file line number Diff line number Diff line change
@@ -73,6 +73,12 @@

public class RubyTypes {

@ImplicitCast
public long int2long(int value) {
return value;
}


@ImplicitCast
public boolean unboxBoolean(RubyTrueClass value) {
return true;
Original file line number Diff line number Diff line change
@@ -122,12 +122,10 @@ public ReferenceEqualNode(ReferenceEqualNode prev) {
@Specialization public boolean equal(boolean a, BigInteger b) { return false; }

@Specialization public boolean equal(int a, boolean b) { return false; }
@Specialization public boolean equal(int a, long b) { return false; }
@Specialization public boolean equal(int a, double b) { return false; }
@Specialization public boolean equal(int a, BigInteger b) { return false; }

@Specialization public boolean equal(long a, boolean b) { return false; }
@Specialization public boolean equal(long a, int b) { return false; }
@Specialization public boolean equal(long a, double b) { return false; }
@Specialization public boolean equal(long a, BigInteger b) { return false; }

43 changes: 9 additions & 34 deletions core/src/main/java/org/jruby/truffle/nodes/core/FixnumNodes.java
Original file line number Diff line number Diff line change
@@ -107,26 +107,16 @@ public int add(int a, int b) {
return ExactMath.addExact(a, b);
}

@Specialization(rewriteOn = ArithmeticException.class)
public long addWithLongOverflow(int a, int b) {
return ExactMath.addExact((long) a, (long) b);
}

@Specialization
public Object addWithBigIntegerOverflow(int a, int b) {
return fixnumOrBignum.fixnumOrBignum(SlowPathBigInteger.add(BigInteger.valueOf(a), BigInteger.valueOf(b)));
public long addWithLongOverflow(int a, int b) {
return (long) a + (long) b;
}

@Specialization
public double add(int a, double b) {
return a + b;
}

@Specialization
public long add(int a, long b) {
return ExactMath.addExact(a, b);
}

@Specialization
public Object add(int a, BigInteger b) {
return fixnumOrBignum.fixnumOrBignum(SlowPathBigInteger.add(BigInteger.valueOf(a), b));
@@ -137,14 +127,9 @@ public long add(long a, int b) {
return ExactMath.addExact(a, b);
}

@Specialization(rewriteOn = ArithmeticException.class)
public long addWithLong(long a, int b) {
return ExactMath.addExact(a, (long) b);
}

@Specialization
public Object addWithBigIntegerOverflow(long a, int b) {
return fixnumOrBignum.fixnumOrBignum(BigInteger.valueOf(a).add(BigInteger.valueOf(b)));
return fixnumOrBignum.fixnumOrBignum(SlowPathBigInteger.add(BigInteger.valueOf(a), BigInteger.valueOf(b)));
}

@Specialization(rewriteOn = ArithmeticException.class)
@@ -154,7 +139,7 @@ public long add(long a, long b) {

@Specialization
public Object addWithBigIntegerOverflow(long a, long b) {
return fixnumOrBignum.fixnumOrBignum(BigInteger.valueOf(a).add(BigInteger.valueOf(b)));
return fixnumOrBignum.fixnumOrBignum(SlowPathBigInteger.add(BigInteger.valueOf(a), BigInteger.valueOf(b)));
}

@Specialization
@@ -189,14 +174,9 @@ public int sub(int a, int b) {
return ExactMath.subtractExact(a, b);
}

@Specialization(rewriteOn = ArithmeticException.class)
public long subWithLongOverflow(int a, int b) {
return ExactMath.subtractExact((long) a, (long) b);
}

@Specialization
public Object subWithBigIntegerOverflow(int a, int b) {
return fixnumOrBignum.fixnumOrBignum(SlowPathBigInteger.subtract(BigInteger.valueOf(a), BigInteger.valueOf(b)));
public long subWithLongOverflow(int a, int b) {
return (long) a - (long) b;
}

@Specialization
@@ -271,14 +251,9 @@ public int mul(int a, int b) {
return ExactMath.multiplyExact(a, b);
}

@Specialization(rewriteOn = ArithmeticException.class)
public long mulWithLong(int a, int b) {
return ExactMath.multiplyExact((long) a, (long) b);
}

@Specialization
public Object mulWithBigInteger(int a, int b) {
return fixnumOrBignum.fixnumOrBignum(BigInteger.valueOf(a).multiply(BigInteger.valueOf(b)));
public long mulWithLong(int a, int b) {
return (long) a * (long) b;
}

@Specialization(rewriteOn = ArithmeticException.class)
@@ -312,7 +287,7 @@ public Object mulWithBigInteger(long a, int b) {
}

@Specialization(rewriteOn = ArithmeticException.class)
public Object mul(long a, long b) {
public long mul(long a, long b) {
return ExactMath.multiplyExact(a, b);
}

Original file line number Diff line number Diff line change
@@ -43,21 +43,11 @@ public RubyRange.IntegerFixnumRange doRange(int begin, int end) {
return new RubyRange.IntegerFixnumRange(getContext().getCoreLibrary().getRangeClass(), begin, end, excludeEnd);
}

@Specialization
public RubyRange.LongFixnumRange doRange(int begin, long end) {
return new RubyRange.LongFixnumRange(getContext().getCoreLibrary().getRangeClass(), begin, end, excludeEnd);
}

@Specialization
public RubyRange.LongFixnumRange doRange(long begin, long end) {
return new RubyRange.LongFixnumRange(getContext().getCoreLibrary().getRangeClass(), begin, end, excludeEnd);
}

@Specialization
public RubyRange.LongFixnumRange doRange(long begin, int end) {
return new RubyRange.LongFixnumRange(getContext().getCoreLibrary().getRangeClass(), begin, end, excludeEnd);
}

@Specialization
public Object doRange(Object begin, Object end) {
if (begin instanceof Integer) {