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

Unified Diff: src/runtime.js

Issue 1314493005: Remove unnecessary checks and runtime calls from ToLength (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add NaN check Created 5 years, 4 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 | « src/macros.py ('k') | src/v8natives.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.js
diff --git a/src/runtime.js b/src/runtime.js
index de64541496f41ac4ce59cc7836943588804a0acb..ab088e7adfbdd45943fe8a3799af8b66592e1496 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -732,12 +732,12 @@ function ToInteger(x) {
}
-// ES6, draft 08-24-14, section 7.1.15
+// ES6, section 7.1.15
function ToLength(arg) {
- arg = ToInteger(arg);
- if (arg < 0) return 0;
- return arg < GlobalNumber.MAX_SAFE_INTEGER ? arg
- : GlobalNumber.MAX_SAFE_INTEGER;
+ arg = TO_NUMBER_INLINE(arg);
+ if (arg <= 0 || NUMBER_IS_NAN(arg)) return 0;
+ arg = %_MathFloor(arg);
adamk 2015/08/25 21:55:42 This line is the problem. I get a crash if |arg| i
+ return arg < kMaxSafeInteger ? arg : kMaxSafeInteger;
}
« no previous file with comments | « src/macros.py ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698