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