Skip to content

Commit

Permalink
Have to use PrimitiveValueProfile when profiling primitive values
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed Aug 8, 2023
1 parent 665786c commit dc9ebe0
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.profiles.CountingConditionProfile;
import com.oracle.truffle.api.profiles.PrimitiveValueProfile;
import com.oracle.truffle.api.profiles.ValueProfile;
import java.math.BigDecimal;
import java.math.BigInteger;
Expand Down Expand Up @@ -34,13 +35,13 @@ public class RoundNode extends Node {
/** Minimum value for the `n` parameter to `roundDouble`. */
private static final double ROUND_MAX_DOUBLE = 99999999999999.0;

private final ValueProfile constantPlacesDecimalPlaces = ValueProfile.createIdentityProfile();
private final PrimitiveValueProfile constantPlacesDecimalPlaces = PrimitiveValueProfile.create();

private final ValueProfile constantPlacesUseBankers = ValueProfile.createIdentityProfile();
private final PrimitiveValueProfile constantPlacesUseBankers = PrimitiveValueProfile.create();

Object execute(double n, long decimalPlaces, boolean useBankers) {
decimalPlaces = constantPlacesDecimalPlaces.profile(decimalPlaces);
useBankers = constantPlacesUseBankers.profile(useBankers);
Object execute(double n, long dp, boolean ub) {
long decimalPlaces = constantPlacesDecimalPlaces.profile(dp);
boolean useBankers = constantPlacesUseBankers.profile(ub);

if (decimalPlaces < ROUND_MIN_DECIMAL_PLACES || decimalPlaces > ROUND_MAX_DECIMAL_PLACES) {
decimalPlacesOutOfRangePanic(decimalPlaces);
Expand Down

0 comments on commit dc9ebe0

Please sign in to comment.