Index: src/js/math.js |
diff --git a/src/js/math.js b/src/js/math.js |
index d615f29a2674464b0ed99c08f0d226b83994c7f3..5d889674f6f827fdda72fe02adc1ff26ccaec309 100644 |
--- a/src/js/math.js |
+++ b/src/js/math.js |
@@ -62,7 +62,11 @@ function MathRandom() { |
// first two elements are reserved for the PRNG state. |
if (nextRandomIndex <= kRandomNumberStart) { |
randomNumbers = %GenerateRandomNumbers(randomNumbers); |
- nextRandomIndex = randomNumbers.length; |
+ if (%_IsTypedArray(randomNumbers)) { |
+ nextRandomIndex = %_TypedArrayGetLength(randomNumbers); |
+ } else { |
+ nextRandomIndex = randomNumbers.length; |
+ } |
} |
return randomNumbers[--nextRandomIndex]; |
} |
@@ -70,7 +74,7 @@ function MathRandom() { |
function MathRandomRaw() { |
if (nextRandomIndex <= kRandomNumberStart) { |
randomNumbers = %GenerateRandomNumbers(randomNumbers); |
- nextRandomIndex = randomNumbers.length; |
+ nextRandomIndex = %_TypedArrayGetLength(randomNumbers); |
} |
return %_DoubleLo(randomNumbers[--nextRandomIndex]) & 0x3FFFFFFF; |
} |