Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Truffle] Add a few TruffleBoundary for pidigits.
  • Loading branch information
eregon committed Feb 18, 2015
1 parent a770f1a commit a5ad48a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Expand Up @@ -10,12 +10,13 @@
package org.jruby.truffle.nodes.core;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
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 com.oracle.truffle.api.utilities.ConditionProfile;

import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyContext;
Expand Down Expand Up @@ -145,11 +146,13 @@ public MulNode(MulNode prev) {
super(prev);
}

@TruffleBoundary
@Specialization
public Object mul(RubyBignum a, int b) {
return fixnumOrBignum(a.bigIntegerValue().multiply(BigInteger.valueOf(b)));
}

@TruffleBoundary
@Specialization
public Object mul(RubyBignum a, long b) {
return fixnumOrBignum(a.bigIntegerValue().multiply(BigInteger.valueOf(b)));
Expand All @@ -160,6 +163,7 @@ public double mul(RubyBignum a, double b) {
return a.bigIntegerValue().doubleValue() * b;
}

@TruffleBoundary
@Specialization
public Object mul(RubyBignum a, RubyBignum b) {
return fixnumOrBignum(a.bigIntegerValue().multiply(b.bigIntegerValue()));
Expand Down
Expand Up @@ -11,6 +11,7 @@

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.ExactMath;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
Expand Down Expand Up @@ -296,6 +297,7 @@ public Object mul(int a, long b) {
return ExactMath.multiplyExact(a, b);
}

@TruffleBoundary
@Specialization
public Object mulWithOverflow(int a, long b) {
return fixnumOrBignum(BigInteger.valueOf(a).multiply(BigInteger.valueOf(b)));
Expand All @@ -306,6 +308,7 @@ public double mul(int a, double b) {
return a * b;
}

@TruffleBoundary
@Specialization
public Object mul(int a, RubyBignum b) {
return fixnumOrBignum(BigInteger.valueOf(a).multiply(b.bigIntegerValue()));
Expand All @@ -316,6 +319,7 @@ public long mul(long a, int b) {
return ExactMath.multiplyExact(a, b);
}

@TruffleBoundary
@Specialization
public Object mulWithOverflow(long a, int b) {
return fixnumOrBignum(BigInteger.valueOf(a).multiply(BigInteger.valueOf(b)));
Expand All @@ -326,6 +330,7 @@ public long mul(long a, long b) {
return ExactMath.multiplyExact(a, b);
}

@TruffleBoundary
@Specialization
public Object mulWithOverflow(long a, long b) {
return fixnumOrBignum(BigInteger.valueOf(a).multiply(BigInteger.valueOf(b)));
Expand All @@ -336,6 +341,7 @@ public double mul(long a, double b) {
return a * b;
}

@TruffleBoundary
@Specialization
public Object mul(long a, RubyBignum b) {
return fixnumOrBignum(BigInteger.valueOf(a).multiply(b.bigIntegerValue()));
Expand Down

0 comments on commit a5ad48a

Please sign in to comment.