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 2533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2544 if (AccessorClass::kind() < FLOAT32_ELEMENTS || | 2544 if (AccessorClass::kind() < FLOAT32_ELEMENTS || |
2545 AccessorClass::kind() > FLOAT64_ELEMENTS) { | 2545 AccessorClass::kind() > FLOAT64_ELEMENTS) { |
2546 return Just(false); | 2546 return Just(false); |
2547 } | 2547 } |
2548 } else if (search_value < std::numeric_limits<ctype>::lowest() || | 2548 } else if (search_value < std::numeric_limits<ctype>::lowest() || |
2549 search_value > std::numeric_limits<ctype>::max()) { | 2549 search_value > std::numeric_limits<ctype>::max()) { |
2550 // Return false if value can't be represented in this space | 2550 // Return false if value can't be represented in this space |
2551 return Just(false); | 2551 return Just(false); |
2552 } | 2552 } |
2553 | 2553 |
| 2554 // Prototype has no elements, and not searching for the hole --- limit |
| 2555 // search to backing store length. |
| 2556 if (static_cast<uint32_t>(elements->length()) < length) { |
| 2557 length = elements->length(); |
| 2558 } |
| 2559 |
2554 if (!std::isnan(search_value)) { | 2560 if (!std::isnan(search_value)) { |
2555 for (uint32_t k = start_from; k < length; ++k) { | 2561 for (uint32_t k = start_from; k < length; ++k) { |
2556 double element_k = elements->get_scalar(k); | 2562 double element_k = elements->get_scalar(k); |
2557 if (element_k == search_value) return Just(true); | 2563 if (element_k == search_value) return Just(true); |
2558 } | 2564 } |
2559 return Just(false); | 2565 return Just(false); |
2560 } else { | 2566 } else { |
2561 for (uint32_t k = start_from; k < length; ++k) { | 2567 for (uint32_t k = start_from; k < length; ++k) { |
2562 double element_k = elements->get_scalar(k); | 2568 double element_k = elements->get_scalar(k); |
2563 if (std::isnan(element_k)) return Just(true); | 2569 if (std::isnan(element_k)) return Just(true); |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3443 insertion_index += len; | 3449 insertion_index += len; |
3444 } | 3450 } |
3445 | 3451 |
3446 DCHECK_EQ(insertion_index, result_len); | 3452 DCHECK_EQ(insertion_index, result_len); |
3447 return result_array; | 3453 return result_array; |
3448 } | 3454 } |
3449 | 3455 |
3450 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 3456 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; |
3451 } // namespace internal | 3457 } // namespace internal |
3452 } // namespace v8 | 3458 } // namespace v8 |
OLD | NEW |