Commit a1f00971 authored by predrag.rudic's avatar predrag.rudic Committed by Commit bot

[runtime function] Fix IndexOf when start is -Infinity

By C++ standard, behaviour is undedined when converting -Infinity to
integer. This patch assures correct behaviour in this case on all
platforms.

BUG=

Review-Url: https://codereview.chromium.org/2865113005
Cr-Commit-Position: refs/heads/master@{#45220}
parent 9fbfd6ea
......@@ -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);
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 = std::numeric_limits<int64_t>::min();
}
}
int64_t index;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment