Skip to content

Commit

Permalink
Merge PR #344: Replace BranchProfile with transferToInterpreterAndInv…
Browse files Browse the repository at this point in the history
…alidate
  • Loading branch information
smarr committed May 11, 2020
2 parents 8a562d5 + 1aed90a commit 4f7ad41
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/som/primitives/IntegerPrims.java
Expand Up @@ -2,11 +2,11 @@

import java.math.BigInteger;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.instrumentation.Tag;
import com.oracle.truffle.api.profiles.BranchProfile;

import bd.primitives.Primitive;
import som.interpreter.nodes.nary.BinaryComplexOperation;
Expand Down Expand Up @@ -91,14 +91,13 @@ public final Object doSClass(final SSymbol argument) {
@GenerateNodeFactory
@Primitive(primitive = "int:leftShift:", selector = "<<", receiverType = Long.class)
public abstract static class LeftShiftPrim extends ArithmeticPrim {
private final BranchProfile overflow = BranchProfile.create();

@Specialization(rewriteOn = ArithmeticException.class)
public final long doLong(final long receiver, final long right) {
assert right >= 0; // currently not defined for negative values of right

if (Long.SIZE - Long.numberOfLeadingZeros(receiver) + right > Long.SIZE - 1) {
overflow.enter();
CompilerDirectives.transferToInterpreterAndInvalidate();
throw new ArithmeticException("shift overflows long");
}
return receiver << right;
Expand Down

0 comments on commit 4f7ad41

Please sign in to comment.