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

Side by Side Diff: src/runtime/runtime-array.cc

Issue 2865113005: [runtime function] Fix IndexOf when start is -Infinity (Closed)
Patch Set: Corrected 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/conversions-inl.h" 9 #include "src/conversions-inl.h"
10 #include "src/elements.h" 10 #include "src/elements.h"
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 if (len == 0) return Smi::FromInt(-1); 561 if (len == 0) return Smi::FromInt(-1);
562 562
563 // Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step 563 // Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
564 // produces the value 0.) 564 // produces the value 0.)
565 int64_t start_from; 565 int64_t start_from;
566 { 566 {
567 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, from_index, 567 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, from_index,
568 Object::ToInteger(isolate, from_index)); 568 Object::ToInteger(isolate, from_index));
569 double fp = from_index->Number(); 569 double fp = from_index->Number();
570 if (fp > len) return Smi::FromInt(-1); 570 if (fp > len) return Smi::FromInt(-1);
571 start_from = static_cast<int64_t>(fp); 571 if (V8_LIKELY(fp >=
572 static_cast<double>(std::numeric_limits<int64_t>::min()))) {
573 DCHECK(fp < std::numeric_limits<int64_t>::max());
574 start_from = static_cast<int64_t>(fp);
575 } else {
576 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.
577 }
572 } 578 }
573 579
574 int64_t index; 580 int64_t index;
575 if (start_from >= 0) { 581 if (start_from >= 0) {
576 index = start_from; 582 index = start_from;
577 } else { 583 } else {
578 index = len + start_from; 584 index = len + start_from;
579 if (index < 0) { 585 if (index < 0) {
580 index = 0; 586 index = 0;
581 } 587 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 DCHECK(accessor->HasElement(*spread_array, i)); 664 DCHECK(accessor->HasElement(*spread_array, i));
659 Handle<Object> element = accessor->Get(spread_array, i); 665 Handle<Object> element = accessor->Get(spread_array, i);
660 result->set(i, *element); 666 result->set(i, *element);
661 } 667 }
662 668
663 return *result; 669 return *result;
664 } 670 }
665 671
666 } // namespace internal 672 } // namespace internal
667 } // namespace v8 673 } // namespace v8
OLDNEW
« 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