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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 index = start_from; | 489 index = start_from; |
490 } else { | 490 } else { |
491 index = len + start_from; | 491 index = len + start_from; |
492 if (index < 0) { | 492 if (index < 0) { |
493 index = 0; | 493 index = 0; |
494 } | 494 } |
495 } | 495 } |
496 | 496 |
497 // If the receiver is not a special receiver type, and the length is a valid | 497 // If the receiver is not a special receiver type, and the length is a valid |
498 // element index, perform fast operation tailored to specific ElementsKinds. | 498 // element index, perform fast operation tailored to specific ElementsKinds. |
499 if (!object->map()->IsSpecialReceiverMap() && len < kMaxUInt32 && | 499 if (object->map()->instance_type() > LAST_SPECIAL_RECEIVER_TYPE && |
| 500 len < kMaxUInt32 && |
500 JSObject::PrototypeHasNoElements(isolate, JSObject::cast(*object))) { | 501 JSObject::PrototypeHasNoElements(isolate, JSObject::cast(*object))) { |
501 Handle<JSObject> obj = Handle<JSObject>::cast(object); | 502 Handle<JSObject> obj = Handle<JSObject>::cast(object); |
502 ElementsAccessor* elements = obj->GetElementsAccessor(); | 503 ElementsAccessor* elements = obj->GetElementsAccessor(); |
503 Maybe<bool> result = elements->IncludesValue(isolate, obj, search_element, | 504 Maybe<bool> result = elements->IncludesValue(isolate, obj, search_element, |
504 static_cast<uint32_t>(index), | 505 static_cast<uint32_t>(index), |
505 static_cast<uint32_t>(len)); | 506 static_cast<uint32_t>(len)); |
506 MAYBE_RETURN(result, isolate->heap()->exception()); | 507 MAYBE_RETURN(result, isolate->heap()->exception()); |
507 return *isolate->factory()->ToBoolean(result.FromJust()); | 508 return *isolate->factory()->ToBoolean(result.FromJust()); |
508 } | 509 } |
509 | 510 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 index = start_from; | 588 index = start_from; |
588 } else { | 589 } else { |
589 index = len + start_from; | 590 index = len + start_from; |
590 if (index < 0) { | 591 if (index < 0) { |
591 index = 0; | 592 index = 0; |
592 } | 593 } |
593 } | 594 } |
594 | 595 |
595 // If the receiver is not a special receiver type, and the length is a valid | 596 // If the receiver is not a special receiver type, and the length is a valid |
596 // element index, perform fast operation tailored to specific ElementsKinds. | 597 // element index, perform fast operation tailored to specific ElementsKinds. |
597 if (!object->map()->IsSpecialReceiverMap() && len < kMaxUInt32 && | 598 if (object->map()->instance_type() > LAST_SPECIAL_RECEIVER_TYPE && |
| 599 len < kMaxUInt32 && |
598 JSObject::PrototypeHasNoElements(isolate, JSObject::cast(*object))) { | 600 JSObject::PrototypeHasNoElements(isolate, JSObject::cast(*object))) { |
599 Handle<JSObject> obj = Handle<JSObject>::cast(object); | 601 Handle<JSObject> obj = Handle<JSObject>::cast(object); |
600 ElementsAccessor* elements = obj->GetElementsAccessor(); | 602 ElementsAccessor* elements = obj->GetElementsAccessor(); |
601 Maybe<int64_t> result = elements->IndexOfValue(isolate, obj, search_element, | 603 Maybe<int64_t> result = elements->IndexOfValue(isolate, obj, search_element, |
602 static_cast<uint32_t>(index), | 604 static_cast<uint32_t>(index), |
603 static_cast<uint32_t>(len)); | 605 static_cast<uint32_t>(len)); |
604 MAYBE_RETURN(result, isolate->heap()->exception()); | 606 MAYBE_RETURN(result, isolate->heap()->exception()); |
605 return *isolate->factory()->NewNumberFromInt64(result.FromJust()); | 607 return *isolate->factory()->NewNumberFromInt64(result.FromJust()); |
606 } | 608 } |
607 | 609 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 isolate, spread, | 643 isolate, spread, |
642 Execution::Call(isolate, spread_iterable_function, | 644 Execution::Call(isolate, spread_iterable_function, |
643 isolate->factory()->undefined_value(), 1, &spread)); | 645 isolate->factory()->undefined_value(), 1, &spread)); |
644 } | 646 } |
645 | 647 |
646 return *spread; | 648 return *spread; |
647 } | 649 } |
648 | 650 |
649 } // namespace internal | 651 } // namespace internal |
650 } // namespace v8 | 652 } // namespace v8 |
OLD | NEW |