Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Unified Diff: src/js/math.js

Issue 2020203006: math.js: Use %_TypedArrayGetLength to get length (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: add typedarray check Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-615776.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-615776.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698