OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/elements.h" | 5 #include "src/elements.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/conversions.h" | 8 #include "src/conversions.h" |
9 #include "src/factory.h" | 9 #include "src/factory.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 2620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2631 | 2631 |
2632 static Maybe<int64_t> IndexOfValueImpl(Isolate* isolate, | 2632 static Maybe<int64_t> IndexOfValueImpl(Isolate* isolate, |
2633 Handle<JSObject> receiver, | 2633 Handle<JSObject> receiver, |
2634 Handle<Object> search_value, | 2634 Handle<Object> search_value, |
2635 uint32_t start_from, uint32_t length) { | 2635 uint32_t start_from, uint32_t length) { |
2636 DCHECK(JSObject::PrototypeHasNoElements(isolate, *receiver)); | 2636 DCHECK(JSObject::PrototypeHasNoElements(isolate, *receiver)); |
2637 DisallowHeapAllocation no_gc; | 2637 DisallowHeapAllocation no_gc; |
2638 FixedArrayBase* elements_base = receiver->elements(); | 2638 FixedArrayBase* elements_base = receiver->elements(); |
2639 Object* value = *search_value; | 2639 Object* value = *search_value; |
2640 | 2640 |
| 2641 length = std::min(static_cast<uint32_t>(elements_base->length()), length); |
| 2642 |
2641 if (start_from >= length) return Just<int64_t>(-1); | 2643 if (start_from >= length) return Just<int64_t>(-1); |
2642 | 2644 |
2643 length = std::min(static_cast<uint32_t>(elements_base->length()), length); | |
2644 | |
2645 if (!value->IsNumber()) { | 2645 if (!value->IsNumber()) { |
2646 return Just<int64_t>(-1); | 2646 return Just<int64_t>(-1); |
2647 } | 2647 } |
2648 if (value->IsNaN()) { | 2648 if (value->IsNaN()) { |
2649 return Just<int64_t>(-1); | 2649 return Just<int64_t>(-1); |
2650 } | 2650 } |
2651 double numeric_search_value = value->Number(); | 2651 double numeric_search_value = value->Number(); |
2652 FixedDoubleArray* elements = FixedDoubleArray::cast(receiver->elements()); | 2652 FixedDoubleArray* elements = FixedDoubleArray::cast(receiver->elements()); |
2653 | 2653 |
2654 for (uint32_t k = start_from; k < length; ++k) { | 2654 for (uint32_t k = start_from; k < length; ++k) { |
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3863 insertion_index += len; | 3863 insertion_index += len; |
3864 } | 3864 } |
3865 | 3865 |
3866 DCHECK_EQ(insertion_index, result_len); | 3866 DCHECK_EQ(insertion_index, result_len); |
3867 return result_array; | 3867 return result_array; |
3868 } | 3868 } |
3869 | 3869 |
3870 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 3870 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; |
3871 } // namespace internal | 3871 } // namespace internal |
3872 } // namespace v8 | 3872 } // namespace v8 |
OLD | NEW |