Commit a68f7fdb authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

Add a comment explaining some weirdness in IndexOf

Bug: chromium:898469
Change-Id: I988a71ed92e1c466224235d32bc4e281dd4818cd
Reviewed-on: https://chromium-review.googlesource.com/c/1301494Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57020}
parent 6396a361
...@@ -2626,6 +2626,10 @@ class FastSmiOrObjectElementsAccessor ...@@ -2626,6 +2626,10 @@ class FastSmiOrObjectElementsAccessor
// NaN can never be found by strict equality. // NaN can never be found by strict equality.
if (value->IsNaN()) return Just<int64_t>(-1); if (value->IsNaN()) return Just<int64_t>(-1);
// k can be greater than receiver->length() below, but it is bounded by
// elements_base->length() so we never read out of bounds. This means that
// elements->get(k) can return the hole, for which the StrictEquals will
// always fail.
FixedArray* elements = FixedArray::cast(receiver->elements()); FixedArray* elements = FixedArray::cast(receiver->elements());
for (uint32_t k = start_from; k < length; ++k) { for (uint32_t k = start_from; k < length; ++k) {
if (value->StrictEquals(elements->get(k))) return Just<int64_t>(k); if (value->StrictEquals(elements->get(k))) return Just<int64_t>(k);
......
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