Index: src/runtime/runtime-array.cc |
diff --git a/src/runtime/runtime-array.cc b/src/runtime/runtime-array.cc |
index 5538fb4c28afc84838552b8bdc36bc8f306bd12b..f1002c82c6c93216cb54ad7a8aaa2526867bd888 100644 |
--- a/src/runtime/runtime-array.cc |
+++ b/src/runtime/runtime-array.cc |
@@ -568,7 +568,13 @@ 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()))) { |
+ DCHECK(fp < std::numeric_limits<int64_t>::max()); |
+ start_from = static_cast<int64_t>(fp); |
+ } else { |
+ start_from = fp = std::numeric_limits<int64_t>::min(); |
Jakob Kummerow
2017/05/09 15:04:23
nit: assigning fp is unnecessary.
predrag.rudic
2017/05/09 15:15:40
Acknowledged.
|
+ } |
} |
int64_t index; |