| 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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 return isolate->heap()->false_value(); | 530 return isolate->heap()->false_value(); |
| 531 } | 531 } |
| 532 | 532 |
| 533 RUNTIME_FUNCTION(Runtime_ArrayIndexOf) { | 533 RUNTIME_FUNCTION(Runtime_ArrayIndexOf) { |
| 534 HandleScope shs(isolate); | 534 HandleScope shs(isolate); |
| 535 DCHECK(args.length() == 3); | 535 DCHECK(args.length() == 3); |
| 536 CONVERT_ARG_HANDLE_CHECKED(Object, search_element, 1); | 536 CONVERT_ARG_HANDLE_CHECKED(Object, search_element, 1); |
| 537 CONVERT_ARG_HANDLE_CHECKED(Object, from_index, 2); | 537 CONVERT_ARG_HANDLE_CHECKED(Object, from_index, 2); |
| 538 | 538 |
| 539 // Let O be ? ToObject(this value). | 539 // Let O be ? ToObject(this value). |
| 540 Handle<Object> receiver_obj = args.at<Object>(0); | 540 Handle<Object> receiver_obj = args.at(0); |
| 541 if (receiver_obj->IsNull(isolate) || receiver_obj->IsUndefined(isolate)) { | 541 if (receiver_obj->IsNull(isolate) || receiver_obj->IsUndefined(isolate)) { |
| 542 THROW_NEW_ERROR_RETURN_FAILURE( | 542 THROW_NEW_ERROR_RETURN_FAILURE( |
| 543 isolate, NewTypeError(MessageTemplate::kCalledOnNullOrUndefined, | 543 isolate, NewTypeError(MessageTemplate::kCalledOnNullOrUndefined, |
| 544 isolate->factory()->NewStringFromAsciiChecked( | 544 isolate->factory()->NewStringFromAsciiChecked( |
| 545 "Array.prototype.indexOf"))); | 545 "Array.prototype.indexOf"))); |
| 546 } | 546 } |
| 547 Handle<JSReceiver> object; | 547 Handle<JSReceiver> object; |
| 548 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 548 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, object, |
| 549 isolate, object, Object::ToObject(isolate, args.at<Object>(0))); | 549 Object::ToObject(isolate, args.at(0))); |
| 550 | 550 |
| 551 // Let len be ? ToLength(? Get(O, "length")). | 551 // Let len be ? ToLength(? Get(O, "length")). |
| 552 int64_t len; | 552 int64_t len; |
| 553 { | 553 { |
| 554 if (object->IsJSArray()) { | 554 if (object->IsJSArray()) { |
| 555 uint32_t len32 = 0; | 555 uint32_t len32 = 0; |
| 556 bool success = JSArray::cast(*object)->length()->ToArrayLength(&len32); | 556 bool success = JSArray::cast(*object)->length()->ToArrayLength(&len32); |
| 557 DCHECK(success); | 557 DCHECK(success); |
| 558 USE(success); | 558 USE(success); |
| 559 len = len32; | 559 len = len32; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 668 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 669 isolate, spreaded, | 669 isolate, spreaded, |
| 670 Execution::Call(isolate, spread_iterable_function, | 670 Execution::Call(isolate, spread_iterable_function, |
| 671 isolate->factory()->undefined_value(), 1, &spread)); | 671 isolate->factory()->undefined_value(), 1, &spread)); |
| 672 | 672 |
| 673 return *spreaded; | 673 return *spreaded; |
| 674 } | 674 } |
| 675 | 675 |
| 676 } // namespace internal | 676 } // namespace internal |
| 677 } // namespace v8 | 677 } // namespace v8 |
| OLD | NEW |