diff --git a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RandGenerationFunctions.java b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RandGenerationFunctions.java index 32d44ac1c923010593429876142efcc0008d77ab..b3548e5ea37864b9ef8641ae6a6b5d13ac0b7e56 100644 --- a/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RandGenerationFunctions.java +++ b/com.oracle.truffle.r.library/src/com/oracle/truffle/r/library/stats/RandGenerationFunctions.java @@ -101,15 +101,16 @@ public final class RandGenerationFunctions { final BranchProfile nan = BranchProfile.create(); final VectorLengthProfile resultVectorLengthProfile = VectorLengthProfile.create(); final LoopConditionProfile loopConditionProfile = LoopConditionProfile.createCountingProfile(); - final ValueProfile randClassProfile = ValueProfile.createClassProfile(); - final ValueProfile normKindProfile = ValueProfile.createEqualityProfile(); + private final ValueProfile randClassProfile = ValueProfile.createClassProfile(); + private final ValueProfile generatorProfile = ValueProfile.createIdentityProfile(); + private final ValueProfile normKindProfile = ValueProfile.createEqualityProfile(); public static RandGenerationProfiles create() { return new RandGenerationProfiles(); } public RandomNumberProvider createRandProvider() { - return new RandomNumberProvider(randClassProfile.profile(RRNG.currentGenerator()), normKindProfile.profile(RRNG.currentNormKind())); + return new RandomNumberProvider(randClassProfile.profile(generatorProfile.profile(RRNG.currentGenerator())), normKindProfile.profile(RRNG.currentNormKind())); } } @@ -133,6 +134,7 @@ public final class RandGenerationFunctions { int[] result = new int[length]; RRNG.getRNGState(); RandomNumberProvider rand = profiles.createRandProvider(); + profiles.loopConditionProfile.profileCounted(length); for (int i = 0; profiles.loopConditionProfile.inject(i < length); i++) { double aValue = a.getDataAt(i % aLength); double bValue = b.getDataAt(i % bLength); @@ -172,6 +174,7 @@ public final class RandGenerationFunctions { result = new double[length]; RRNG.getRNGState(); RandomNumberProvider rand = profiles.createRandProvider(); + profiles.loopConditionProfile.profileCounted(length); for (int i = 0; profiles.loopConditionProfile.inject(i < length); i++) { double aValue = a.getDataAt(i % aLength); double bValue = b.getDataAt(i % bLength); diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/rng/RNGInitAdapter.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/rng/RNGInitAdapter.java index a7f110a81d24055ff480bccf250b9725a55a2b1f..ca4a665de1e1940abf16686e7411b8bab8060319 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/rng/RNGInitAdapter.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/rng/RNGInitAdapter.java @@ -29,15 +29,15 @@ public abstract class RNGInitAdapter implements RandomNumberGenerator { } @Override - public int[] getSeeds() { + public final int[] getSeeds() { return iSeed; } - protected int getISeedItem(int index) { + protected final int getISeedItem(int index) { return iSeed[index + 1]; } - protected void setISeedItem(int index, int value) { + protected final void setISeedItem(int index, int value) { iSeed[index + 1] = value; } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/rng/mt/MersenneTwister.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/rng/mt/MersenneTwister.java index d9472bda6891c062db2b2136df6a530f3dd37899..1bccf6eb4b973a527f1af77f564e3f2528df80ca 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/rng/mt/MersenneTwister.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/rng/mt/MersenneTwister.java @@ -64,7 +64,6 @@ package com.oracle.truffle.r.runtime.rng.mt; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.r.runtime.RInternalError; import com.oracle.truffle.r.runtime.rng.RNGInitAdapter; import com.oracle.truffle.r.runtime.rng.RRNG; import com.oracle.truffle.r.runtime.rng.RRNG.Kind; @@ -159,8 +158,7 @@ public final class MersenneTwister extends RNGInitAdapter { int localMti = localDummy0; // It appears that this never happens // sgenrand(4357); - RInternalError.guarantee(localMti != N + 1); - + assert localMti != N + 1; int pos = 0; while (true) { int loopCount = Math.min(BUFFER_SIZE - pos, N - localMti);