Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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( |
| 572 fp >= static_cast<double>(std::numeric_limits<int64_t>::min()) && | |
| 573 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.
| |
| 574 start_from = static_cast<int64_t>(fp); | |
| 575 } else { | |
| 576 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.
| |
| 577 ? std::numeric_limits<int64_t>::min() | |
| 578 : std::numeric_limits<int64_t>::max(); | |
| 579 } | |
| 572 } | 580 } |
| 573 | 581 |
| 574 int64_t index; | 582 int64_t index; |
| 575 if (start_from >= 0) { | 583 if (start_from >= 0) { |
| 576 index = start_from; | 584 index = start_from; |
| 577 } else { | 585 } else { |
| 578 index = len + start_from; | 586 index = len + start_from; |
| 579 if (index < 0) { | 587 if (index < 0) { |
| 580 index = 0; | 588 index = 0; |
| 581 } | 589 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 658 DCHECK(accessor->HasElement(*spread_array, i)); | 666 DCHECK(accessor->HasElement(*spread_array, i)); |
| 659 Handle<Object> element = accessor->Get(spread_array, i); | 667 Handle<Object> element = accessor->Get(spread_array, i); |
| 660 result->set(i, *element); | 668 result->set(i, *element); |
| 661 } | 669 } |
| 662 | 670 |
| 663 return *result; | 671 return *result; |
| 664 } | 672 } |
| 665 | 673 |
| 666 } // namespace internal | 674 } // namespace internal |
| 667 } // namespace v8 | 675 } // namespace v8 |
| OLD | NEW |