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/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 MAYBE_RETURN_NULL(Object::SetProperty(&it, value, language_mode, | 223 MAYBE_RETURN_NULL(Object::SetProperty(&it, value, language_mode, |
224 Object::MAY_BE_STORE_FROM_KEYED)); | 224 Object::MAY_BE_STORE_FROM_KEYED)); |
225 return value; | 225 return value; |
226 } | 226 } |
227 | 227 |
228 | 228 |
229 RUNTIME_FUNCTION(Runtime_GetPrototype) { | 229 RUNTIME_FUNCTION(Runtime_GetPrototype) { |
230 HandleScope scope(isolate); | 230 HandleScope scope(isolate); |
231 DCHECK(args.length() == 1); | 231 DCHECK(args.length() == 1); |
232 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0); | 232 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0); |
233 Handle<Object> prototype; | 233 RETURN_RESULT_OR_FAILURE(isolate, JSReceiver::GetPrototype(isolate, obj)); |
234 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, prototype, | |
235 JSReceiver::GetPrototype(isolate, obj)); | |
236 return *prototype; | |
237 } | 234 } |
238 | 235 |
239 | 236 |
240 RUNTIME_FUNCTION(Runtime_InternalSetPrototype) { | 237 RUNTIME_FUNCTION(Runtime_InternalSetPrototype) { |
241 HandleScope scope(isolate); | 238 HandleScope scope(isolate); |
242 DCHECK(args.length() == 2); | 239 DCHECK(args.length() == 2); |
243 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0); | 240 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0); |
244 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); | 241 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); |
245 MAYBE_RETURN( | 242 MAYBE_RETURN( |
246 JSReceiver::SetPrototype(obj, prototype, false, Object::THROW_ON_ERROR), | 243 JSReceiver::SetPrototype(obj, prototype, false, Object::THROW_ON_ERROR), |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 it.GetHolder<Object>().is_identical_to(global_object)) { | 295 it.GetHolder<Object>().is_identical_to(global_object)) { |
299 // Now update the cell in the script context. | 296 // Now update the cell in the script context. |
300 Handle<PropertyCell> cell = it.GetPropertyCell(); | 297 Handle<PropertyCell> cell = it.GetPropertyCell(); |
301 script_context->set(slot, *cell); | 298 script_context->set(slot, *cell); |
302 } else { | 299 } else { |
303 // This is not a fast case, so keep this access in a slow mode. | 300 // This is not a fast case, so keep this access in a slow mode. |
304 // Store empty_property_cell here to release the outdated property cell. | 301 // Store empty_property_cell here to release the outdated property cell. |
305 script_context->set(slot, isolate->heap()->empty_property_cell()); | 302 script_context->set(slot, isolate->heap()->empty_property_cell()); |
306 } | 303 } |
307 | 304 |
308 Handle<Object> result; | 305 RETURN_RESULT_OR_FAILURE(isolate, Object::GetProperty(&it)); |
309 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it)); | |
310 return *result; | |
311 } | 306 } |
312 | 307 |
313 | 308 |
314 namespace { | 309 namespace { |
315 | 310 |
316 Object* StoreGlobalViaContext(Isolate* isolate, int slot, Handle<Object> value, | 311 Object* StoreGlobalViaContext(Isolate* isolate, int slot, Handle<Object> value, |
317 LanguageMode language_mode) { | 312 LanguageMode language_mode) { |
318 // Go up context chain to the script context. | 313 // Go up context chain to the script context. |
319 Handle<Context> script_context(isolate->context()->script_context(), isolate); | 314 Handle<Context> script_context(isolate->context()->script_context(), isolate); |
320 DCHECK(script_context->IsScriptContext()); | 315 DCHECK(script_context->IsScriptContext()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 } | 364 } |
370 | 365 |
371 | 366 |
372 RUNTIME_FUNCTION(Runtime_GetProperty) { | 367 RUNTIME_FUNCTION(Runtime_GetProperty) { |
373 HandleScope scope(isolate); | 368 HandleScope scope(isolate); |
374 DCHECK(args.length() == 2); | 369 DCHECK(args.length() == 2); |
375 | 370 |
376 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 371 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
377 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 372 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
378 | 373 |
379 Handle<Object> result; | 374 RETURN_RESULT_OR_FAILURE(isolate, |
380 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 375 Runtime::GetObjectProperty(isolate, object, key)); |
381 isolate, result, Runtime::GetObjectProperty(isolate, object, key)); | |
382 return *result; | |
383 } | 376 } |
384 | 377 |
385 | 378 |
386 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. | 379 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. |
387 RUNTIME_FUNCTION(Runtime_KeyedGetProperty) { | 380 RUNTIME_FUNCTION(Runtime_KeyedGetProperty) { |
388 HandleScope scope(isolate); | 381 HandleScope scope(isolate); |
389 DCHECK(args.length() == 2); | 382 DCHECK(args.length() == 2); |
390 | 383 |
391 CONVERT_ARG_HANDLE_CHECKED(Object, receiver_obj, 0); | 384 CONVERT_ARG_HANDLE_CHECKED(Object, receiver_obj, 0); |
392 CONVERT_ARG_HANDLE_CHECKED(Object, key_obj, 1); | 385 CONVERT_ARG_HANDLE_CHECKED(Object, key_obj, 1); |
393 | 386 |
394 Handle<Object> result; | 387 RETURN_RESULT_OR_FAILURE( |
395 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 388 isolate, KeyedGetObjectProperty(isolate, receiver_obj, key_obj)); |
396 isolate, result, KeyedGetObjectProperty(isolate, receiver_obj, key_obj)); | |
397 return *result; | |
398 } | 389 } |
399 | 390 |
400 | 391 |
401 RUNTIME_FUNCTION(Runtime_AddNamedProperty) { | 392 RUNTIME_FUNCTION(Runtime_AddNamedProperty) { |
402 HandleScope scope(isolate); | 393 HandleScope scope(isolate); |
403 RUNTIME_ASSERT(args.length() == 4); | 394 RUNTIME_ASSERT(args.length() == 4); |
404 | 395 |
405 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 396 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
406 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 397 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
407 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 398 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
408 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); | 399 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); |
409 | 400 |
410 #ifdef DEBUG | 401 #ifdef DEBUG |
411 uint32_t index = 0; | 402 uint32_t index = 0; |
412 DCHECK(!name->ToArrayIndex(&index)); | 403 DCHECK(!name->ToArrayIndex(&index)); |
413 LookupIterator it(object, name, object, LookupIterator::OWN_SKIP_INTERCEPTOR); | 404 LookupIterator it(object, name, object, LookupIterator::OWN_SKIP_INTERCEPTOR); |
414 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); | 405 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); |
415 if (!maybe.IsJust()) return isolate->heap()->exception(); | 406 if (!maybe.IsJust()) return isolate->heap()->exception(); |
416 RUNTIME_ASSERT(!it.IsFound()); | 407 RUNTIME_ASSERT(!it.IsFound()); |
417 #endif | 408 #endif |
418 | 409 |
419 Handle<Object> result; | 410 RETURN_RESULT_OR_FAILURE(isolate, JSObject::SetOwnPropertyIgnoreAttributes( |
420 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 411 object, name, value, attrs)); |
421 isolate, result, | |
422 JSObject::SetOwnPropertyIgnoreAttributes(object, name, value, attrs)); | |
423 return *result; | |
424 } | 412 } |
425 | 413 |
426 | 414 |
427 // Adds an element to an array. | 415 // Adds an element to an array. |
428 // This is used to create an indexed data property into an array. | 416 // This is used to create an indexed data property into an array. |
429 RUNTIME_FUNCTION(Runtime_AddElement) { | 417 RUNTIME_FUNCTION(Runtime_AddElement) { |
430 HandleScope scope(isolate); | 418 HandleScope scope(isolate); |
431 RUNTIME_ASSERT(args.length() == 3); | 419 RUNTIME_ASSERT(args.length() == 3); |
432 | 420 |
433 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 421 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
434 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 422 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
435 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 423 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
436 | 424 |
437 uint32_t index = 0; | 425 uint32_t index = 0; |
438 CHECK(key->ToArrayIndex(&index)); | 426 CHECK(key->ToArrayIndex(&index)); |
439 | 427 |
440 #ifdef DEBUG | 428 #ifdef DEBUG |
441 LookupIterator it(isolate, object, index, object, | 429 LookupIterator it(isolate, object, index, object, |
442 LookupIterator::OWN_SKIP_INTERCEPTOR); | 430 LookupIterator::OWN_SKIP_INTERCEPTOR); |
443 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); | 431 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); |
444 if (!maybe.IsJust()) return isolate->heap()->exception(); | 432 if (!maybe.IsJust()) return isolate->heap()->exception(); |
445 RUNTIME_ASSERT(!it.IsFound()); | 433 RUNTIME_ASSERT(!it.IsFound()); |
446 | 434 |
447 if (object->IsJSArray()) { | 435 if (object->IsJSArray()) { |
448 Handle<JSArray> array = Handle<JSArray>::cast(object); | 436 Handle<JSArray> array = Handle<JSArray>::cast(object); |
449 RUNTIME_ASSERT(!JSArray::WouldChangeReadOnlyLength(array, index)); | 437 RUNTIME_ASSERT(!JSArray::WouldChangeReadOnlyLength(array, index)); |
450 } | 438 } |
451 #endif | 439 #endif |
452 | 440 |
453 Handle<Object> result; | 441 RETURN_RESULT_OR_FAILURE(isolate, JSObject::SetOwnElementIgnoreAttributes( |
454 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 442 object, index, value, NONE)); |
455 isolate, result, | |
456 JSObject::SetOwnElementIgnoreAttributes(object, index, value, NONE)); | |
457 return *result; | |
458 } | 443 } |
459 | 444 |
460 | 445 |
461 RUNTIME_FUNCTION(Runtime_AppendElement) { | 446 RUNTIME_FUNCTION(Runtime_AppendElement) { |
462 HandleScope scope(isolate); | 447 HandleScope scope(isolate); |
463 RUNTIME_ASSERT(args.length() == 2); | 448 RUNTIME_ASSERT(args.length() == 2); |
464 | 449 |
465 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 450 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
466 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 451 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
467 | 452 |
468 uint32_t index; | 453 uint32_t index; |
469 CHECK(array->length()->ToArrayIndex(&index)); | 454 CHECK(array->length()->ToArrayIndex(&index)); |
470 | 455 |
471 Handle<Object> result; | 456 RETURN_FAILURE_ON_EXCEPTION( |
472 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 457 isolate, JSObject::AddDataElement(array, index, value, NONE)); |
473 isolate, result, JSObject::AddDataElement(array, index, value, NONE)); | |
474 JSObject::ValidateElements(array); | 458 JSObject::ValidateElements(array); |
475 return *array; | 459 return *array; |
476 } | 460 } |
477 | 461 |
478 | 462 |
479 RUNTIME_FUNCTION(Runtime_SetProperty) { | 463 RUNTIME_FUNCTION(Runtime_SetProperty) { |
480 HandleScope scope(isolate); | 464 HandleScope scope(isolate); |
481 RUNTIME_ASSERT(args.length() == 4); | 465 RUNTIME_ASSERT(args.length() == 4); |
482 | 466 |
483 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 467 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
484 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 468 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
485 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 469 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
486 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode_arg, 3); | 470 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode_arg, 3); |
487 LanguageMode language_mode = language_mode_arg; | 471 LanguageMode language_mode = language_mode_arg; |
488 | 472 |
489 Handle<Object> result; | 473 RETURN_RESULT_OR_FAILURE( |
490 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 474 isolate, |
491 isolate, result, | |
492 Runtime::SetObjectProperty(isolate, object, key, value, language_mode)); | 475 Runtime::SetObjectProperty(isolate, object, key, value, language_mode)); |
493 return *result; | |
494 } | 476 } |
495 | 477 |
496 | 478 |
497 namespace { | 479 namespace { |
498 | 480 |
499 // ES6 section 12.5.4. | 481 // ES6 section 12.5.4. |
500 Object* DeleteProperty(Isolate* isolate, Handle<Object> object, | 482 Object* DeleteProperty(Isolate* isolate, Handle<Object> object, |
501 Handle<Object> key, LanguageMode language_mode) { | 483 Handle<Object> key, LanguageMode language_mode) { |
502 Handle<JSReceiver> receiver; | 484 Handle<JSReceiver> receiver; |
503 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, | 485 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 DCHECK(args.length() == 0); | 604 DCHECK(args.length() == 0); |
623 return *isolate->factory()->NewHeapNumber(0); | 605 return *isolate->factory()->NewHeapNumber(0); |
624 } | 606 } |
625 | 607 |
626 | 608 |
627 RUNTIME_FUNCTION(Runtime_NewObject) { | 609 RUNTIME_FUNCTION(Runtime_NewObject) { |
628 HandleScope scope(isolate); | 610 HandleScope scope(isolate); |
629 DCHECK_EQ(2, args.length()); | 611 DCHECK_EQ(2, args.length()); |
630 CONVERT_ARG_HANDLE_CHECKED(JSFunction, target, 0); | 612 CONVERT_ARG_HANDLE_CHECKED(JSFunction, target, 0); |
631 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, new_target, 1); | 613 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, new_target, 1); |
632 Handle<JSObject> result; | 614 RETURN_RESULT_OR_FAILURE(isolate, JSObject::New(target, new_target)); |
633 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | |
634 JSObject::New(target, new_target)); | |
635 return *result; | |
636 } | 615 } |
637 | 616 |
638 | 617 |
639 RUNTIME_FUNCTION(Runtime_FinalizeInstanceSize) { | 618 RUNTIME_FUNCTION(Runtime_FinalizeInstanceSize) { |
640 HandleScope scope(isolate); | 619 HandleScope scope(isolate); |
641 DCHECK(args.length() == 1); | 620 DCHECK(args.length() == 1); |
642 | 621 |
643 CONVERT_ARG_HANDLE_CHECKED(Map, initial_map, 0); | 622 CONVERT_ARG_HANDLE_CHECKED(Map, initial_map, 0); |
644 initial_map->CompleteInobjectSlackTracking(); | 623 initial_map->CompleteInobjectSlackTracking(); |
645 | 624 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), | 808 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), |
830 setter, attrs)); | 809 setter, attrs)); |
831 return isolate->heap()->undefined_value(); | 810 return isolate->heap()->undefined_value(); |
832 } | 811 } |
833 | 812 |
834 | 813 |
835 RUNTIME_FUNCTION(Runtime_ToObject) { | 814 RUNTIME_FUNCTION(Runtime_ToObject) { |
836 HandleScope scope(isolate); | 815 HandleScope scope(isolate); |
837 DCHECK_EQ(1, args.length()); | 816 DCHECK_EQ(1, args.length()); |
838 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 817 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
839 Handle<JSReceiver> receiver; | 818 RETURN_RESULT_OR_FAILURE(isolate, Object::ToObject(isolate, object)); |
840 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, | |
841 Object::ToObject(isolate, object)); | |
842 return *receiver; | |
843 } | 819 } |
844 | 820 |
845 | 821 |
846 RUNTIME_FUNCTION(Runtime_ToPrimitive) { | 822 RUNTIME_FUNCTION(Runtime_ToPrimitive) { |
847 HandleScope scope(isolate); | 823 HandleScope scope(isolate); |
848 DCHECK_EQ(1, args.length()); | 824 DCHECK_EQ(1, args.length()); |
849 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 825 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
850 Handle<Object> result; | 826 RETURN_RESULT_OR_FAILURE(isolate, Object::ToPrimitive(input)); |
851 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | |
852 Object::ToPrimitive(input)); | |
853 return *result; | |
854 } | 827 } |
855 | 828 |
856 | 829 |
857 RUNTIME_FUNCTION(Runtime_ToPrimitive_Number) { | 830 RUNTIME_FUNCTION(Runtime_ToPrimitive_Number) { |
858 HandleScope scope(isolate); | 831 HandleScope scope(isolate); |
859 DCHECK_EQ(1, args.length()); | 832 DCHECK_EQ(1, args.length()); |
860 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 833 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
861 Handle<Object> result; | 834 RETURN_RESULT_OR_FAILURE( |
862 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 835 isolate, Object::ToPrimitive(input, ToPrimitiveHint::kNumber)); |
863 isolate, result, Object::ToPrimitive(input, ToPrimitiveHint::kNumber)); | |
864 return *result; | |
865 } | 836 } |
866 | 837 |
867 | 838 |
868 RUNTIME_FUNCTION(Runtime_ToPrimitive_String) { | 839 RUNTIME_FUNCTION(Runtime_ToPrimitive_String) { |
869 HandleScope scope(isolate); | 840 HandleScope scope(isolate); |
870 DCHECK_EQ(1, args.length()); | 841 DCHECK_EQ(1, args.length()); |
871 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 842 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
872 Handle<Object> result; | 843 RETURN_RESULT_OR_FAILURE( |
873 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 844 isolate, Object::ToPrimitive(input, ToPrimitiveHint::kString)); |
874 isolate, result, Object::ToPrimitive(input, ToPrimitiveHint::kString)); | |
875 return *result; | |
876 } | 845 } |
877 | 846 |
878 | 847 |
879 RUNTIME_FUNCTION(Runtime_ToNumber) { | 848 RUNTIME_FUNCTION(Runtime_ToNumber) { |
880 HandleScope scope(isolate); | 849 HandleScope scope(isolate); |
881 DCHECK_EQ(1, args.length()); | 850 DCHECK_EQ(1, args.length()); |
882 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 851 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
883 Handle<Object> result; | 852 RETURN_RESULT_OR_FAILURE(isolate, Object::ToNumber(input)); |
884 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::ToNumber(input)); | |
885 return *result; | |
886 } | 853 } |
887 | 854 |
888 | 855 |
889 RUNTIME_FUNCTION(Runtime_ToInteger) { | 856 RUNTIME_FUNCTION(Runtime_ToInteger) { |
890 HandleScope scope(isolate); | 857 HandleScope scope(isolate); |
891 DCHECK_EQ(1, args.length()); | 858 DCHECK_EQ(1, args.length()); |
892 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 859 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
893 Handle<Object> result; | 860 RETURN_RESULT_OR_FAILURE(isolate, Object::ToInteger(isolate, input)); |
894 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | |
895 Object::ToInteger(isolate, input)); | |
896 return *result; | |
897 } | 861 } |
898 | 862 |
899 | 863 |
900 RUNTIME_FUNCTION(Runtime_ToLength) { | 864 RUNTIME_FUNCTION(Runtime_ToLength) { |
901 HandleScope scope(isolate); | 865 HandleScope scope(isolate); |
902 DCHECK_EQ(1, args.length()); | 866 DCHECK_EQ(1, args.length()); |
903 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 867 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
904 Handle<Object> result; | 868 RETURN_RESULT_OR_FAILURE(isolate, Object::ToLength(isolate, input)); |
905 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | |
906 Object::ToLength(isolate, input)); | |
907 return *result; | |
908 } | 869 } |
909 | 870 |
910 | 871 |
911 RUNTIME_FUNCTION(Runtime_ToString) { | 872 RUNTIME_FUNCTION(Runtime_ToString) { |
912 HandleScope scope(isolate); | 873 HandleScope scope(isolate); |
913 DCHECK_EQ(1, args.length()); | 874 DCHECK_EQ(1, args.length()); |
914 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 875 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
915 Handle<Object> result; | 876 RETURN_RESULT_OR_FAILURE(isolate, Object::ToString(isolate, input)); |
916 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | |
917 Object::ToString(isolate, input)); | |
918 return *result; | |
919 } | 877 } |
920 | 878 |
921 | 879 |
922 RUNTIME_FUNCTION(Runtime_ToName) { | 880 RUNTIME_FUNCTION(Runtime_ToName) { |
923 HandleScope scope(isolate); | 881 HandleScope scope(isolate); |
924 DCHECK_EQ(1, args.length()); | 882 DCHECK_EQ(1, args.length()); |
925 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 883 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
926 Handle<Object> result; | 884 RETURN_RESULT_OR_FAILURE(isolate, Object::ToName(isolate, input)); |
927 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | |
928 Object::ToName(isolate, input)); | |
929 return *result; | |
930 } | 885 } |
931 | 886 |
932 | 887 |
933 RUNTIME_FUNCTION(Runtime_SameValue) { | 888 RUNTIME_FUNCTION(Runtime_SameValue) { |
934 SealHandleScope scope(isolate); | 889 SealHandleScope scope(isolate); |
935 DCHECK_EQ(2, args.length()); | 890 DCHECK_EQ(2, args.length()); |
936 CONVERT_ARG_CHECKED(Object, x, 0); | 891 CONVERT_ARG_CHECKED(Object, x, 0); |
937 CONVERT_ARG_CHECKED(Object, y, 1); | 892 CONVERT_ARG_CHECKED(Object, y, 1); |
938 return isolate->heap()->ToBoolean(x->SameValue(y)); | 893 return isolate->heap()->ToBoolean(x->SameValue(y)); |
939 } | 894 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 isolate, o, key, &success, LookupIterator::OWN); | 973 isolate, o, key, &success, LookupIterator::OWN); |
1019 if (!success) return isolate->heap()->exception(); | 974 if (!success) return isolate->heap()->exception(); |
1020 MAYBE_RETURN( | 975 MAYBE_RETURN( |
1021 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), | 976 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), |
1022 isolate->heap()->exception()); | 977 isolate->heap()->exception()); |
1023 return *value; | 978 return *value; |
1024 } | 979 } |
1025 | 980 |
1026 } // namespace internal | 981 } // namespace internal |
1027 } // namespace v8 | 982 } // namespace v8 |
OLD | NEW |