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

Unified Diff: src/runtime/runtime-array.cc

Issue 2865113005: [runtime function] Fix IndexOf when start is -Infinity (Closed)
Patch Set: Created 3 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-array.cc
diff --git a/src/runtime/runtime-array.cc b/src/runtime/runtime-array.cc
index 5538fb4c28afc84838552b8bdc36bc8f306bd12b..0ac965566c9ab46d2993b11e82e0ac2b6f3f1264 100644
--- a/src/runtime/runtime-array.cc
+++ b/src/runtime/runtime-array.cc
@@ -568,7 +568,15 @@ RUNTIME_FUNCTION(Runtime_ArrayIndexOf) {
Object::ToInteger(isolate, from_index));
double fp = from_index->Number();
if (fp > len) return Smi::FromInt(-1);
- start_from = static_cast<int64_t>(fp);
+ if (V8_LIKELY(
+ fp >= static_cast<double>(std::numeric_limits<int64_t>::min()) &&
+ fp < static_cast<double>(std::numeric_limits<int64_t>::max()))) {
Jakob Kummerow 2017/05/09 11:03:32 You don't need the second condition; the "fp > len
predrag.rudic 2017/05/09 12:43:08 Acknowledged.
+ start_from = static_cast<int64_t>(fp);
+ } else {
+ start_from = fp < static_cast<double>(std::numeric_limits<int64_t>::min())
Jakob Kummerow 2017/05/09 11:03:32 ...and then you don't need a case distinction here
predrag.rudic 2017/05/09 12:43:07 Acknowledged.
+ ? std::numeric_limits<int64_t>::min()
+ : std::numeric_limits<int64_t>::max();
+ }
}
int64_t index;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698