OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 PropertyAttributes* attributes) { | 163 PropertyAttributes* attributes) { |
164 LookupResult lookup(name->GetIsolate()); | 164 LookupResult lookup(name->GetIsolate()); |
165 object->Lookup(*name, &lookup); | 165 object->Lookup(*name, &lookup); |
166 MaybeHandle<Object> result = | 166 MaybeHandle<Object> result = |
167 GetProperty(object, receiver, &lookup, name, attributes); | 167 GetProperty(object, receiver, &lookup, name, attributes); |
168 ASSERT(*attributes <= ABSENT); | 168 ASSERT(*attributes <= ABSENT); |
169 return result; | 169 return result; |
170 } | 170 } |
171 | 171 |
172 | 172 |
173 MaybeObject* Object::GetPropertyWithReceiver(Object* receiver, | |
174 Name* name, | |
175 PropertyAttributes* attributes) { | |
176 LookupResult result(name->GetIsolate()); | |
177 Lookup(name, &result); | |
178 MaybeObject* value = GetProperty(receiver, &result, name, attributes); | |
179 ASSERT(*attributes <= ABSENT); | |
180 return value; | |
181 } | |
182 | |
183 | |
184 bool Object::ToInt32(int32_t* value) { | 173 bool Object::ToInt32(int32_t* value) { |
185 if (IsSmi()) { | 174 if (IsSmi()) { |
186 *value = Smi::cast(this)->value(); | 175 *value = Smi::cast(this)->value(); |
187 return true; | 176 return true; |
188 } | 177 } |
189 if (IsHeapNumber()) { | 178 if (IsHeapNumber()) { |
190 double num = HeapNumber::cast(this)->value(); | 179 double num = HeapNumber::cast(this)->value(); |
191 if (FastI2D(FastD2I(num)) == num) { | 180 if (FastI2D(FastD2I(num)) == num) { |
192 *value = FastD2I(num); | 181 *value = FastD2I(num); |
193 return true; | 182 return true; |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 if (getter->IsSpecFunction()) { | 456 if (getter->IsSpecFunction()) { |
468 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 457 // TODO(rossberg): nicer would be to cast to some JSCallable here... |
469 return Object::GetPropertyWithDefinedGetter( | 458 return Object::GetPropertyWithDefinedGetter( |
470 object, receiver, Handle<JSReceiver>::cast(getter)); | 459 object, receiver, Handle<JSReceiver>::cast(getter)); |
471 } | 460 } |
472 // Getter is not a function. | 461 // Getter is not a function. |
473 return isolate->factory()->undefined_value(); | 462 return isolate->factory()->undefined_value(); |
474 } | 463 } |
475 | 464 |
476 | 465 |
477 MaybeObject* JSProxy::GetPropertyWithHandler(Object* receiver_raw, | 466 MaybeHandle<Object> JSProxy::GetPropertyWithHandler(Handle<JSProxy> proxy, |
478 Name* name_raw) { | 467 Handle<Object> receiver, |
479 Isolate* isolate = GetIsolate(); | 468 Handle<Name> name) { |
480 HandleScope scope(isolate); | 469 Isolate* isolate = proxy->GetIsolate(); |
481 Handle<Object> receiver(receiver_raw, isolate); | |
482 Handle<Object> name(name_raw, isolate); | |
483 | 470 |
484 // TODO(rossberg): adjust once there is a story for symbols vs proxies. | 471 // TODO(rossberg): adjust once there is a story for symbols vs proxies. |
485 if (name->IsSymbol()) return isolate->heap()->undefined_value(); | 472 if (name->IsSymbol()) return isolate->factory()->undefined_value(); |
486 | 473 |
487 Handle<Object> args[] = { receiver, name }; | 474 Handle<Object> args[] = { receiver, name }; |
488 Handle<Object> result; | 475 return CallTrap( |
489 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 476 proxy, "get", isolate->derived_get_trap(), ARRAY_SIZE(args), args); |
490 isolate, result, | |
491 CallTrap(handle(this), | |
492 "get", | |
493 isolate->derived_get_trap(), | |
494 ARRAY_SIZE(args), | |
495 args)); | |
496 return *result; | |
497 } | 477 } |
498 | 478 |
499 | 479 |
500 MaybeHandle<Object> Object::GetPropertyOrElement(Handle<Object> object, | |
501 Handle<Name> name) { | |
502 uint32_t index; | |
503 Isolate* isolate = name->GetIsolate(); | |
504 if (name->AsArrayIndex(&index)) return GetElement(isolate, object, index); | |
505 return GetProperty(object, name); | |
506 } | |
507 | |
508 | |
509 Handle<Object> Object::GetProperty(Handle<Object> object, | |
510 Handle<Name> name) { | |
511 CALL_HEAP_FUNCTION(name->GetIsolate(), object->GetProperty(*name), Object); | |
512 } | |
513 | |
514 | |
515 MaybeObject* JSProxy::GetElementWithHandler(Object* receiver, | |
516 uint32_t index) { | |
517 String* name; | |
518 MaybeObject* maybe = GetHeap()->Uint32ToString(index); | |
519 if (!maybe->To<String>(&name)) return maybe; | |
520 return GetPropertyWithHandler(receiver, name); | |
521 } | |
522 | |
523 | |
524 MaybeHandle<Object> JSProxy::SetElementWithHandler(Handle<JSProxy> proxy, | |
525 Handle<JSReceiver> receiver, | |
526 uint32_t index, | |
527 Handle<Object> value, | |
528 StrictMode strict_mode) { | |
529 Isolate* isolate = proxy->GetIsolate(); | |
530 Handle<String> name = isolate->factory()->Uint32ToString(index); | |
531 return SetPropertyWithHandler( | |
532 proxy, receiver, name, value, NONE, strict_mode); | |
533 } | |
534 | |
535 | |
536 bool JSProxy::HasElementWithHandler(Handle<JSProxy> proxy, uint32_t index) { | |
537 Isolate* isolate = proxy->GetIsolate(); | |
538 Handle<String> name = isolate->factory()->Uint32ToString(index); | |
539 return HasPropertyWithHandler(proxy, name); | |
540 } | |
541 | |
542 | |
543 MaybeHandle<Object> Object::GetPropertyWithDefinedGetter( | 480 MaybeHandle<Object> Object::GetPropertyWithDefinedGetter( |
544 Handle<Object> object, | 481 Handle<Object> object, |
545 Handle<Object> receiver, | 482 Handle<Object> receiver, |
546 Handle<JSReceiver> getter) { | 483 Handle<JSReceiver> getter) { |
547 Isolate* isolate = getter->GetIsolate(); | 484 Isolate* isolate = getter->GetIsolate(); |
548 #ifdef ENABLE_DEBUGGER_SUPPORT | 485 #ifdef ENABLE_DEBUGGER_SUPPORT |
549 Debug* debug = isolate->debug(); | 486 Debug* debug = isolate->debug(); |
550 // Handle stepping into a getter if step into is active. | 487 // Handle stepping into a getter if step into is active. |
551 // TODO(rossberg): should this apply to getters that are function proxies? | 488 // TODO(rossberg): should this apply to getters that are function proxies? |
552 if (debug->StepInActive() && getter->IsJSFunction()) { | 489 if (debug->StepInActive() && getter->IsJSFunction()) { |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 // created with then no changes can have been made to it. | 766 // created with then no changes can have been made to it. |
830 return map() != fun->initial_map() | 767 return map() != fun->initial_map() |
831 || !HasFastObjectElements() | 768 || !HasFastObjectElements() |
832 || !HasFastProperties(); | 769 || !HasFastProperties(); |
833 } | 770 } |
834 | 771 |
835 | 772 |
836 MaybeHandle<Object> Object::GetProperty(Handle<Object> object, | 773 MaybeHandle<Object> Object::GetProperty(Handle<Object> object, |
837 Handle<Object> receiver, | 774 Handle<Object> receiver, |
838 LookupResult* result, | 775 LookupResult* result, |
839 Handle<Name> key, | 776 Handle<Name> name, |
840 PropertyAttributes* attributes) { | 777 PropertyAttributes* attributes) { |
841 Isolate* isolate = result->isolate(); | |
842 CALL_HEAP_FUNCTION( | |
843 isolate, | |
844 object->GetProperty(*receiver, result, *key, attributes), | |
845 Object); | |
846 } | |
847 | |
848 | |
849 // TODO(yangguo): handlify this and get rid of. | |
850 MaybeObject* Object::GetProperty(Object* receiver, | |
851 LookupResult* result, | |
852 Name* name, | |
853 PropertyAttributes* attributes) { | |
854 Isolate* isolate = name->GetIsolate(); | 778 Isolate* isolate = name->GetIsolate(); |
855 Heap* heap = isolate->heap(); | 779 Factory* factory = isolate->factory(); |
856 | |
857 #ifdef DEBUG | |
858 // TODO(mstarzinger): Only because of the AssertNoContextChange, drop as soon | |
859 // as this method has been fully handlified. | |
860 HandleScope scope(isolate); | |
861 #endif | |
862 | 780 |
863 // Make sure that the top context does not change when doing | 781 // Make sure that the top context does not change when doing |
864 // callbacks or interceptor calls. | 782 // callbacks or interceptor calls. |
865 AssertNoContextChange ncc(isolate); | 783 AssertNoContextChange ncc(isolate); |
866 | 784 |
867 // Traverse the prototype chain from the current object (this) to | 785 // Traverse the prototype chain from the current object (this) to |
868 // the holder and check for access rights. This avoids traversing the | 786 // the holder and check for access rights. This avoids traversing the |
869 // objects more than once in case of interceptors, because the | 787 // objects more than once in case of interceptors, because the |
870 // holder will always be the interceptor holder and the search may | 788 // holder will always be the interceptor holder and the search may |
871 // only continue with a current object just after the interceptor | 789 // only continue with a current object just after the interceptor |
872 // holder in the prototype chain. | 790 // holder in the prototype chain. |
873 // Proxy handlers do not use the proxy's prototype, so we can skip this. | 791 // Proxy handlers do not use the proxy's prototype, so we can skip this. |
874 if (!result->IsHandler()) { | 792 if (!result->IsHandler()) { |
875 Object* last = result->IsProperty() | 793 ASSERT(*object != object->GetPrototype(isolate)); |
876 ? result->holder() | 794 Handle<Object> last = result->IsProperty() |
877 : Object::cast(heap->null_value()); | 795 ? Handle<Object>(result->holder(), isolate) |
878 ASSERT(this != this->GetPrototype(isolate)); | 796 : Handle<Object>::cast(factory->null_value()); |
879 for (Object* current = this; | 797 for (Handle<Object> current = object; |
880 true; | 798 true; |
881 current = current->GetPrototype(isolate)) { | 799 current = Handle<Object>(current->GetPrototype(isolate), isolate)) { |
882 if (current->IsAccessCheckNeeded()) { | 800 if (current->IsAccessCheckNeeded()) { |
883 // Check if we're allowed to read from the current object. Note | 801 // Check if we're allowed to read from the current object. Note |
884 // that even though we may not actually end up loading the named | 802 // that even though we may not actually end up loading the named |
885 // property from the current object, we still check that we have | 803 // property from the current object, we still check that we have |
886 // access to it. | 804 // access to it. |
887 JSObject* checked = JSObject::cast(current); | 805 Handle<JSObject> checked = Handle<JSObject>::cast(current); |
888 if (!isolate->MayNamedAccess(checked, name, v8::ACCESS_GET)) { | 806 if (!isolate->MayNamedAccessWrapper(checked, name, v8::ACCESS_GET)) { |
889 HandleScope scope(isolate); | 807 return JSObject::GetPropertyWithFailedAccessCheck( |
890 Handle<Object> value; | 808 checked, receiver, result, name, attributes); |
891 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | |
892 isolate, value, | |
893 JSObject::GetPropertyWithFailedAccessCheck( | |
894 handle(checked, isolate), | |
895 handle(receiver, isolate), | |
896 result, | |
897 handle(name, isolate), | |
898 attributes)); | |
899 return *value; | |
900 } | 809 } |
901 } | 810 } |
902 // Stop traversing the chain once we reach the last object in the | 811 // Stop traversing the chain once we reach the last object in the |
903 // chain; either the holder of the result or null in case of an | 812 // chain; either the holder of the result or null in case of an |
904 // absent property. | 813 // absent property. |
905 if (current == last) break; | 814 if (current.is_identical_to(last)) break; |
906 } | 815 } |
907 } | 816 } |
908 | 817 |
909 if (!result->IsProperty()) { | 818 if (!result->IsProperty()) { |
910 *attributes = ABSENT; | 819 *attributes = ABSENT; |
911 return heap->undefined_value(); | 820 return factory->undefined_value(); |
912 } | 821 } |
913 *attributes = result->GetAttributes(); | 822 *attributes = result->GetAttributes(); |
914 Object* value; | 823 |
| 824 Handle<Object> value; |
915 switch (result->type()) { | 825 switch (result->type()) { |
916 case NORMAL: | 826 case NORMAL: { |
917 value = result->holder()->GetNormalizedProperty(result); | 827 DisallowHeapAllocation no_gc; |
918 ASSERT(!value->IsTheHole() || result->IsReadOnly()); | 828 value = handle(result->holder()->GetNormalizedProperty(result), isolate); |
919 return value->IsTheHole() ? heap->undefined_value() : value; | 829 break; |
920 case FIELD: { | |
921 MaybeObject* maybe_result = result->holder()->FastPropertyAt( | |
922 result->representation(), | |
923 result->GetFieldIndex().field_index()); | |
924 if (!maybe_result->To(&value)) return maybe_result; | |
925 ASSERT(!value->IsTheHole() || result->IsReadOnly()); | |
926 return value->IsTheHole() ? heap->undefined_value() : value; | |
927 } | 830 } |
| 831 case FIELD: |
| 832 value = JSObject::FastPropertyAt(handle(result->holder(), isolate), |
| 833 result->representation(), |
| 834 result->GetFieldIndex().field_index()); |
| 835 break; |
928 case CONSTANT: | 836 case CONSTANT: |
929 return result->GetConstant(); | 837 return handle(result->GetConstant(), isolate); |
930 case CALLBACKS: { | 838 case CALLBACKS: |
931 HandleScope scope(isolate); | 839 return JSObject::GetPropertyWithCallback( |
932 Handle<Object> value; | 840 handle(result->holder(), isolate), |
933 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 841 receiver, |
934 isolate, value, | 842 handle(result->GetCallbackObject(), isolate), |
935 JSObject::GetPropertyWithCallback( | 843 name); |
936 handle(result->holder(), isolate), | |
937 handle(receiver, isolate), | |
938 handle(result->GetCallbackObject(), isolate), | |
939 handle(name, isolate))); | |
940 return *value; | |
941 } | |
942 case HANDLER: | 844 case HANDLER: |
943 return result->proxy()->GetPropertyWithHandler(receiver, name); | 845 return JSProxy::GetPropertyWithHandler( |
944 case INTERCEPTOR: { | 846 handle(result->proxy(), isolate), receiver, name); |
945 HandleScope scope(isolate); | 847 case INTERCEPTOR: |
946 Handle<Object> value; | 848 return JSObject::GetPropertyWithInterceptor( |
947 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 849 handle(result->holder(), isolate), receiver, name, attributes); |
948 isolate, value, | |
949 JSObject::GetPropertyWithInterceptor( | |
950 handle(result->holder(), isolate), | |
951 handle(receiver, isolate), | |
952 handle(name, isolate), | |
953 attributes)); | |
954 return *value; | |
955 } | |
956 case NONEXISTENT: | 850 case NONEXISTENT: |
957 UNREACHABLE(); | 851 UNREACHABLE(); |
958 break; | 852 break; |
959 } | 853 } |
960 UNREACHABLE(); | 854 ASSERT(!value->IsTheHole() || result->IsReadOnly()); |
961 return NULL; | 855 return value->IsTheHole() ? Handle<Object>::cast(factory->undefined_value()) |
| 856 : value; |
962 } | 857 } |
963 | 858 |
964 | 859 |
965 MaybeHandle<Object> Object::GetElementWithReceiver(Isolate* isolate, | 860 MaybeHandle<Object> Object::GetElementWithReceiver(Isolate* isolate, |
966 Handle<Object> object, | 861 Handle<Object> object, |
967 Handle<Object> receiver, | 862 Handle<Object> receiver, |
968 uint32_t index) { | 863 uint32_t index) { |
969 Handle<Object> holder; | 864 Handle<Object> holder; |
970 | 865 |
971 // Iterate up the prototype chain until an element is found or the null | 866 // Iterate up the prototype chain until an element is found or the null |
972 // prototype is encountered. | 867 // prototype is encountered. |
973 for (holder = object; | 868 for (holder = object; |
974 !holder->IsNull(); | 869 !holder->IsNull(); |
975 holder = Handle<Object>(holder->GetPrototype(isolate), isolate)) { | 870 holder = Handle<Object>(holder->GetPrototype(isolate), isolate)) { |
976 if (!holder->IsJSObject()) { | 871 if (!holder->IsJSObject()) { |
977 Context* native_context = isolate->context()->native_context(); | 872 Context* native_context = isolate->context()->native_context(); |
978 if (holder->IsNumber()) { | 873 if (holder->IsNumber()) { |
979 holder = Handle<Object>( | 874 holder = Handle<Object>( |
980 native_context->number_function()->instance_prototype(), isolate); | 875 native_context->number_function()->instance_prototype(), isolate); |
981 } else if (holder->IsString()) { | 876 } else if (holder->IsString()) { |
982 holder = Handle<Object>( | 877 holder = Handle<Object>( |
983 native_context->string_function()->instance_prototype(), isolate); | 878 native_context->string_function()->instance_prototype(), isolate); |
984 } else if (holder->IsSymbol()) { | 879 } else if (holder->IsSymbol()) { |
985 holder = Handle<Object>( | 880 holder = Handle<Object>( |
986 native_context->symbol_function()->instance_prototype(), isolate); | 881 native_context->symbol_function()->instance_prototype(), isolate); |
987 } else if (holder->IsBoolean()) { | 882 } else if (holder->IsBoolean()) { |
988 holder = Handle<Object>( | 883 holder = Handle<Object>( |
989 native_context->boolean_function()->instance_prototype(), isolate); | 884 native_context->boolean_function()->instance_prototype(), isolate); |
990 } else if (holder->IsJSProxy()) { | 885 } else if (holder->IsJSProxy()) { |
991 CALL_HEAP_FUNCTION(isolate, | 886 return JSProxy::GetElementWithHandler( |
992 Handle<JSProxy>::cast(holder)->GetElementWithHandler( | 887 Handle<JSProxy>::cast(holder), receiver, index); |
993 *receiver, index), | |
994 Object); | |
995 } else { | 888 } else { |
996 // Undefined and null have no indexed properties. | 889 // Undefined and null have no indexed properties. |
997 ASSERT(holder->IsUndefined() || holder->IsNull()); | 890 ASSERT(holder->IsUndefined() || holder->IsNull()); |
998 return isolate->factory()->undefined_value(); | 891 return isolate->factory()->undefined_value(); |
999 } | 892 } |
1000 } | 893 } |
1001 | 894 |
1002 // Inline the case for JSObjects. Doing so significantly improves the | 895 // Inline the case for JSObjects. Doing so significantly improves the |
1003 // performance of fetching elements where checking the prototype chain is | 896 // performance of fetching elements where checking the prototype chain is |
1004 // necessary. | 897 // necessary. |
(...skipping 2610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3615 isolate->to_complete_property_descriptor(), | 3508 isolate->to_complete_property_descriptor(), |
3616 result, | 3509 result, |
3617 ARRAY_SIZE(argv), | 3510 ARRAY_SIZE(argv), |
3618 argv), | 3511 argv), |
3619 Object); | 3512 Object); |
3620 | 3513 |
3621 // [[GetProperty]] requires to check that all properties are configurable. | 3514 // [[GetProperty]] requires to check that all properties are configurable. |
3622 Handle<String> configurable_name = | 3515 Handle<String> configurable_name = |
3623 isolate->factory()->InternalizeOneByteString( | 3516 isolate->factory()->InternalizeOneByteString( |
3624 STATIC_ASCII_VECTOR("configurable_")); | 3517 STATIC_ASCII_VECTOR("configurable_")); |
3625 Handle<Object> configurable = Object::GetProperty(desc, configurable_name); | 3518 Handle<Object> configurable = |
3626 ASSERT(!configurable.is_null()); | 3519 Object::GetProperty(desc, configurable_name).ToHandleChecked(); |
3627 ASSERT(configurable->IsTrue() || configurable->IsFalse()); | 3520 ASSERT(configurable->IsBoolean()); |
3628 if (configurable->IsFalse()) { | 3521 if (configurable->IsFalse()) { |
3629 Handle<String> trap = | 3522 Handle<String> trap = |
3630 isolate->factory()->InternalizeOneByteString( | 3523 isolate->factory()->InternalizeOneByteString( |
3631 STATIC_ASCII_VECTOR("getPropertyDescriptor")); | 3524 STATIC_ASCII_VECTOR("getPropertyDescriptor")); |
3632 Handle<Object> args[] = { handler, trap, name }; | 3525 Handle<Object> args[] = { handler, trap, name }; |
3633 Handle<Object> error = isolate->factory()->NewTypeError( | 3526 Handle<Object> error = isolate->factory()->NewTypeError( |
3634 "proxy_prop_not_configurable", HandleVector(args, ARRAY_SIZE(args))); | 3527 "proxy_prop_not_configurable", HandleVector(args, ARRAY_SIZE(args))); |
3635 return isolate->Throw<Object>(error); | 3528 return isolate->Throw<Object>(error); |
3636 } | 3529 } |
3637 ASSERT(configurable->IsTrue()); | 3530 ASSERT(configurable->IsTrue()); |
3638 | 3531 |
3639 // Check for DataDescriptor. | 3532 // Check for DataDescriptor. |
3640 Handle<String> hasWritable_name = | 3533 Handle<String> hasWritable_name = |
3641 isolate->factory()->InternalizeOneByteString( | 3534 isolate->factory()->InternalizeOneByteString( |
3642 STATIC_ASCII_VECTOR("hasWritable_")); | 3535 STATIC_ASCII_VECTOR("hasWritable_")); |
3643 Handle<Object> hasWritable = Object::GetProperty(desc, hasWritable_name); | 3536 Handle<Object> hasWritable = |
3644 ASSERT(!hasWritable.is_null()); | 3537 Object::GetProperty(desc, hasWritable_name).ToHandleChecked(); |
3645 ASSERT(hasWritable->IsTrue() || hasWritable->IsFalse()); | 3538 ASSERT(hasWritable->IsBoolean()); |
3646 if (hasWritable->IsTrue()) { | 3539 if (hasWritable->IsTrue()) { |
3647 Handle<String> writable_name = | 3540 Handle<String> writable_name = |
3648 isolate->factory()->InternalizeOneByteString( | 3541 isolate->factory()->InternalizeOneByteString( |
3649 STATIC_ASCII_VECTOR("writable_")); | 3542 STATIC_ASCII_VECTOR("writable_")); |
3650 Handle<Object> writable = Object::GetProperty(desc, writable_name); | 3543 Handle<Object> writable = |
3651 ASSERT(!writable.is_null()); | 3544 Object::GetProperty(desc, writable_name).ToHandleChecked(); |
3652 ASSERT(writable->IsTrue() || writable->IsFalse()); | 3545 ASSERT(writable->IsBoolean()); |
3653 *done = writable->IsFalse(); | 3546 *done = writable->IsFalse(); |
3654 if (!*done) return isolate->factory()->the_hole_value(); | 3547 if (!*done) return isolate->factory()->the_hole_value(); |
3655 if (strict_mode == SLOPPY) return value; | 3548 if (strict_mode == SLOPPY) return value; |
3656 Handle<Object> args[] = { name, receiver }; | 3549 Handle<Object> args[] = { name, receiver }; |
3657 Handle<Object> error = isolate->factory()->NewTypeError( | 3550 Handle<Object> error = isolate->factory()->NewTypeError( |
3658 "strict_read_only_property", HandleVector(args, ARRAY_SIZE(args))); | 3551 "strict_read_only_property", HandleVector(args, ARRAY_SIZE(args))); |
3659 return isolate->Throw<Object>(error); | 3552 return isolate->Throw<Object>(error); |
3660 } | 3553 } |
3661 | 3554 |
3662 // We have an AccessorDescriptor. | 3555 // We have an AccessorDescriptor. |
3663 Handle<String> set_name = isolate->factory()->InternalizeOneByteString( | 3556 Handle<String> set_name = isolate->factory()->InternalizeOneByteString( |
3664 STATIC_ASCII_VECTOR("set_")); | 3557 STATIC_ASCII_VECTOR("set_")); |
3665 Handle<Object> setter = Object::GetProperty(desc, set_name); | 3558 Handle<Object> setter = Object::GetProperty(desc, set_name).ToHandleChecked(); |
3666 ASSERT(!setter.is_null()); | |
3667 if (!setter->IsUndefined()) { | 3559 if (!setter->IsUndefined()) { |
3668 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 3560 // TODO(rossberg): nicer would be to cast to some JSCallable here... |
3669 return SetPropertyWithDefinedSetter( | 3561 return SetPropertyWithDefinedSetter( |
3670 receiver, Handle<JSReceiver>::cast(setter), value); | 3562 receiver, Handle<JSReceiver>::cast(setter), value); |
3671 } | 3563 } |
3672 | 3564 |
3673 if (strict_mode == SLOPPY) return value; | 3565 if (strict_mode == SLOPPY) return value; |
3674 Handle<Object> args2[] = { name, proxy }; | 3566 Handle<Object> args2[] = { name, proxy }; |
3675 Handle<Object> error = isolate->factory()->NewTypeError( | 3567 Handle<Object> error = isolate->factory()->NewTypeError( |
3676 "no_setter_in_callback", HandleVector(args2, ARRAY_SIZE(args2))); | 3568 "no_setter_in_callback", HandleVector(args2, ARRAY_SIZE(args2))); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3748 Execution::Call(isolate, | 3640 Execution::Call(isolate, |
3749 isolate->to_complete_property_descriptor(), | 3641 isolate->to_complete_property_descriptor(), |
3750 result, | 3642 result, |
3751 ARRAY_SIZE(argv), | 3643 ARRAY_SIZE(argv), |
3752 argv), | 3644 argv), |
3753 NONE); | 3645 NONE); |
3754 | 3646 |
3755 // Convert result to PropertyAttributes. | 3647 // Convert result to PropertyAttributes. |
3756 Handle<String> enum_n = isolate->factory()->InternalizeOneByteString( | 3648 Handle<String> enum_n = isolate->factory()->InternalizeOneByteString( |
3757 STATIC_ASCII_VECTOR("enumerable_")); | 3649 STATIC_ASCII_VECTOR("enumerable_")); |
3758 Handle<Object> enumerable = Object::GetProperty(desc, enum_n); | 3650 Handle<Object> enumerable; |
3759 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, enumerable, NONE); | 3651 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 3652 isolate, enumerable, Object::GetProperty(desc, enum_n), NONE); |
3760 Handle<String> conf_n = isolate->factory()->InternalizeOneByteString( | 3653 Handle<String> conf_n = isolate->factory()->InternalizeOneByteString( |
3761 STATIC_ASCII_VECTOR("configurable_")); | 3654 STATIC_ASCII_VECTOR("configurable_")); |
3762 Handle<Object> configurable = Object::GetProperty(desc, conf_n); | 3655 Handle<Object> configurable; |
3763 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, configurable, NONE); | 3656 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 3657 isolate, configurable, Object::GetProperty(desc, conf_n), NONE); |
3764 Handle<String> writ_n = isolate->factory()->InternalizeOneByteString( | 3658 Handle<String> writ_n = isolate->factory()->InternalizeOneByteString( |
3765 STATIC_ASCII_VECTOR("writable_")); | 3659 STATIC_ASCII_VECTOR("writable_")); |
3766 Handle<Object> writable = Object::GetProperty(desc, writ_n); | 3660 Handle<Object> writable; |
3767 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, writable, NONE); | 3661 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 3662 isolate, writable, Object::GetProperty(desc, writ_n), NONE); |
3768 if (!writable->BooleanValue()) { | 3663 if (!writable->BooleanValue()) { |
3769 Handle<String> set_n = isolate->factory()->InternalizeOneByteString( | 3664 Handle<String> set_n = isolate->factory()->InternalizeOneByteString( |
3770 STATIC_ASCII_VECTOR("set_")); | 3665 STATIC_ASCII_VECTOR("set_")); |
3771 Handle<Object> setter = Object::GetProperty(desc, set_n); | 3666 Handle<Object> setter; |
3772 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, setter, NONE); | 3667 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 3668 isolate, setter, Object::GetProperty(desc, set_n), NONE); |
3773 writable = isolate->factory()->ToBoolean(!setter->IsUndefined()); | 3669 writable = isolate->factory()->ToBoolean(!setter->IsUndefined()); |
3774 } | 3670 } |
3775 | 3671 |
3776 if (configurable->IsFalse()) { | 3672 if (configurable->IsFalse()) { |
3777 Handle<Object> handler(proxy->handler(), isolate); | 3673 Handle<Object> handler(proxy->handler(), isolate); |
3778 Handle<String> trap = isolate->factory()->InternalizeOneByteString( | 3674 Handle<String> trap = isolate->factory()->InternalizeOneByteString( |
3779 STATIC_ASCII_VECTOR("getPropertyDescriptor")); | 3675 STATIC_ASCII_VECTOR("getPropertyDescriptor")); |
3780 Handle<Object> args[] = { handler, trap, name }; | 3676 Handle<Object> args[] = { handler, trap, name }; |
3781 Handle<Object> error = isolate->factory()->NewTypeError( | 3677 Handle<Object> error = isolate->factory()->NewTypeError( |
3782 "proxy_prop_not_configurable", HandleVector(args, ARRAY_SIZE(args))); | 3678 "proxy_prop_not_configurable", HandleVector(args, ARRAY_SIZE(args))); |
(...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5213 } | 5109 } |
5214 | 5110 |
5215 Handle<Object> old_value; | 5111 Handle<Object> old_value; |
5216 bool should_enqueue_change_record = false; | 5112 bool should_enqueue_change_record = false; |
5217 if (object->map()->is_observed()) { | 5113 if (object->map()->is_observed()) { |
5218 should_enqueue_change_record = HasLocalElement(object, index); | 5114 should_enqueue_change_record = HasLocalElement(object, index); |
5219 if (should_enqueue_change_record) { | 5115 if (should_enqueue_change_record) { |
5220 if (!GetLocalElementAccessorPair(object, index).is_null()) { | 5116 if (!GetLocalElementAccessorPair(object, index).is_null()) { |
5221 old_value = Handle<Object>::cast(factory->the_hole_value()); | 5117 old_value = Handle<Object>::cast(factory->the_hole_value()); |
5222 } else { | 5118 } else { |
5223 old_value = Object::GetElementNoExceptionThrown(isolate, object, index); | 5119 old_value = Object::GetElement( |
| 5120 isolate, object, index).ToHandleChecked(); |
5224 } | 5121 } |
5225 } | 5122 } |
5226 } | 5123 } |
5227 | 5124 |
5228 // Skip interceptor if forcing deletion. | 5125 // Skip interceptor if forcing deletion. |
5229 MaybeHandle<Object> maybe_result; | 5126 MaybeHandle<Object> maybe_result; |
5230 if (object->HasIndexedInterceptor() && mode != FORCE_DELETION) { | 5127 if (object->HasIndexedInterceptor() && mode != FORCE_DELETION) { |
5231 maybe_result = DeleteElementWithInterceptor(object, index); | 5128 maybe_result = DeleteElementWithInterceptor(object, index); |
5232 } else { | 5129 } else { |
5233 maybe_result = object->GetElementsAccessor()->Delete(object, index, mode); | 5130 maybe_result = object->GetElementsAccessor()->Delete(object, index, mode); |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5814 copy->GetLocalPropertyNames(*names, 0); | 5711 copy->GetLocalPropertyNames(*names, 0); |
5815 for (int i = 0; i < names->length(); i++) { | 5712 for (int i = 0; i < names->length(); i++) { |
5816 ASSERT(names->get(i)->IsString()); | 5713 ASSERT(names->get(i)->IsString()); |
5817 Handle<String> key_string(String::cast(names->get(i))); | 5714 Handle<String> key_string(String::cast(names->get(i))); |
5818 PropertyAttributes attributes = | 5715 PropertyAttributes attributes = |
5819 JSReceiver::GetLocalPropertyAttribute(copy, key_string); | 5716 JSReceiver::GetLocalPropertyAttribute(copy, key_string); |
5820 // Only deep copy fields from the object literal expression. | 5717 // Only deep copy fields from the object literal expression. |
5821 // In particular, don't try to copy the length attribute of | 5718 // In particular, don't try to copy the length attribute of |
5822 // an array. | 5719 // an array. |
5823 if (attributes != NONE) continue; | 5720 if (attributes != NONE) continue; |
5824 Handle<Object> value = Object::GetProperty(copy, key_string); | 5721 Handle<Object> value = |
5825 CHECK_NOT_EMPTY_HANDLE(isolate, value); | 5722 Object::GetProperty(copy, key_string).ToHandleChecked(); |
5826 if (value->IsJSObject()) { | 5723 if (value->IsJSObject()) { |
5827 Handle<JSObject> result = VisitElementOrProperty( | 5724 Handle<JSObject> result = VisitElementOrProperty( |
5828 copy, Handle<JSObject>::cast(value)); | 5725 copy, Handle<JSObject>::cast(value)); |
5829 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, result, Handle<JSObject>()); | 5726 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, result, Handle<JSObject>()); |
5830 if (copying) { | 5727 if (copying) { |
5831 // Creating object copy for literals. No strict mode needed. | 5728 // Creating object copy for literals. No strict mode needed. |
5832 JSObject::SetProperty( | 5729 JSObject::SetProperty( |
5833 copy, key_string, result, NONE, SLOPPY).Assert(); | 5730 copy, key_string, result, NONE, SLOPPY).Assert(); |
5834 } | 5731 } |
5835 } | 5732 } |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6378 bool is_element = name->AsArrayIndex(&index); | 6275 bool is_element = name->AsArrayIndex(&index); |
6379 | 6276 |
6380 Handle<Object> old_value = isolate->factory()->the_hole_value(); | 6277 Handle<Object> old_value = isolate->factory()->the_hole_value(); |
6381 bool is_observed = object->map()->is_observed() && | 6278 bool is_observed = object->map()->is_observed() && |
6382 *name != isolate->heap()->hidden_string(); | 6279 *name != isolate->heap()->hidden_string(); |
6383 bool preexists = false; | 6280 bool preexists = false; |
6384 if (is_observed) { | 6281 if (is_observed) { |
6385 if (is_element) { | 6282 if (is_element) { |
6386 preexists = HasLocalElement(object, index); | 6283 preexists = HasLocalElement(object, index); |
6387 if (preexists && GetLocalElementAccessorPair(object, index).is_null()) { | 6284 if (preexists && GetLocalElementAccessorPair(object, index).is_null()) { |
6388 old_value = Object::GetElementNoExceptionThrown(isolate, object, index); | 6285 old_value = |
| 6286 Object::GetElement(isolate, object, index).ToHandleChecked(); |
6389 } | 6287 } |
6390 } else { | 6288 } else { |
6391 LookupResult lookup(isolate); | 6289 LookupResult lookup(isolate); |
6392 object->LocalLookup(*name, &lookup, true); | 6290 object->LocalLookup(*name, &lookup, true); |
6393 preexists = lookup.IsProperty(); | 6291 preexists = lookup.IsProperty(); |
6394 if (preexists && lookup.IsDataProperty()) { | 6292 if (preexists && lookup.IsDataProperty()) { |
6395 old_value = | 6293 old_value = |
6396 Object::GetPropertyOrElement(object, name).ToHandleChecked(); | 6294 Object::GetPropertyOrElement(object, name).ToHandleChecked(); |
6397 } | 6295 } |
6398 } | 6296 } |
(...skipping 4887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11286 List<Handle<Object> >* old_values, | 11184 List<Handle<Object> >* old_values, |
11287 List<uint32_t>* indices) { | 11185 List<uint32_t>* indices) { |
11288 PropertyAttributes attributes = | 11186 PropertyAttributes attributes = |
11289 JSReceiver::GetLocalElementAttribute(object, index); | 11187 JSReceiver::GetLocalElementAttribute(object, index); |
11290 ASSERT(attributes != ABSENT); | 11188 ASSERT(attributes != ABSENT); |
11291 if (attributes == DONT_DELETE) return false; | 11189 if (attributes == DONT_DELETE) return false; |
11292 Handle<Object> value; | 11190 Handle<Object> value; |
11293 if (!JSObject::GetLocalElementAccessorPair(object, index).is_null()) { | 11191 if (!JSObject::GetLocalElementAccessorPair(object, index).is_null()) { |
11294 value = Handle<Object>::cast(isolate->factory()->the_hole_value()); | 11192 value = Handle<Object>::cast(isolate->factory()->the_hole_value()); |
11295 } else { | 11193 } else { |
11296 value = Object::GetElementNoExceptionThrown(isolate, object, index); | 11194 value = Object::GetElement(isolate, object, index).ToHandleChecked(); |
11297 } | 11195 } |
11298 old_values->Add(value); | 11196 old_values->Add(value); |
11299 indices->Add(index); | 11197 indices->Add(index); |
11300 return true; | 11198 return true; |
11301 } | 11199 } |
11302 | 11200 |
11303 static void EnqueueSpliceRecord(Handle<JSArray> object, | 11201 static void EnqueueSpliceRecord(Handle<JSArray> object, |
11304 uint32_t index, | 11202 uint32_t index, |
11305 Handle<JSArray> deleted, | 11203 Handle<JSArray> deleted, |
11306 uint32_t add_count) { | 11204 uint32_t add_count) { |
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12537 } | 12435 } |
12538 | 12436 |
12539 PropertyAttributes old_attributes = | 12437 PropertyAttributes old_attributes = |
12540 JSReceiver::GetLocalElementAttribute(object, index); | 12438 JSReceiver::GetLocalElementAttribute(object, index); |
12541 Handle<Object> old_value = isolate->factory()->the_hole_value(); | 12439 Handle<Object> old_value = isolate->factory()->the_hole_value(); |
12542 Handle<Object> old_length_handle; | 12440 Handle<Object> old_length_handle; |
12543 Handle<Object> new_length_handle; | 12441 Handle<Object> new_length_handle; |
12544 | 12442 |
12545 if (old_attributes != ABSENT) { | 12443 if (old_attributes != ABSENT) { |
12546 if (GetLocalElementAccessorPair(object, index).is_null()) { | 12444 if (GetLocalElementAccessorPair(object, index).is_null()) { |
12547 old_value = Object::GetElementNoExceptionThrown(isolate, object, index); | 12445 old_value = Object::GetElement(isolate, object, index).ToHandleChecked(); |
12548 } | 12446 } |
12549 } else if (object->IsJSArray()) { | 12447 } else if (object->IsJSArray()) { |
12550 // Store old array length in case adding an element grows the array. | 12448 // Store old array length in case adding an element grows the array. |
12551 old_length_handle = handle(Handle<JSArray>::cast(object)->length(), | 12449 old_length_handle = handle(Handle<JSArray>::cast(object)->length(), |
12552 isolate); | 12450 isolate); |
12553 } | 12451 } |
12554 | 12452 |
12555 // Check for lookup interceptor | 12453 // Check for lookup interceptor |
12556 Handle<Object> result; | 12454 Handle<Object> result; |
12557 ASSIGN_RETURN_ON_EXCEPTION( | 12455 ASSIGN_RETURN_ON_EXCEPTION( |
(...skipping 28 matching lines...) Expand all Loading... |
12586 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0); | 12484 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0); |
12587 EnqueueSpliceRecord(Handle<JSArray>::cast(object), old_length, deleted, | 12485 EnqueueSpliceRecord(Handle<JSArray>::cast(object), old_length, deleted, |
12588 new_length - old_length); | 12486 new_length - old_length); |
12589 } else { | 12487 } else { |
12590 EnqueueChangeRecord(object, "add", name, old_value); | 12488 EnqueueChangeRecord(object, "add", name, old_value); |
12591 } | 12489 } |
12592 } else if (old_value->IsTheHole()) { | 12490 } else if (old_value->IsTheHole()) { |
12593 EnqueueChangeRecord(object, "reconfigure", name, old_value); | 12491 EnqueueChangeRecord(object, "reconfigure", name, old_value); |
12594 } else { | 12492 } else { |
12595 Handle<Object> new_value = | 12493 Handle<Object> new_value = |
12596 Object::GetElementNoExceptionThrown(isolate, object, index); | 12494 Object::GetElement(isolate, object, index).ToHandleChecked(); |
12597 bool value_changed = !old_value->SameValue(*new_value); | 12495 bool value_changed = !old_value->SameValue(*new_value); |
12598 if (old_attributes != new_attributes) { | 12496 if (old_attributes != new_attributes) { |
12599 if (!value_changed) old_value = isolate->factory()->the_hole_value(); | 12497 if (!value_changed) old_value = isolate->factory()->the_hole_value(); |
12600 EnqueueChangeRecord(object, "reconfigure", name, old_value); | 12498 EnqueueChangeRecord(object, "reconfigure", name, old_value); |
12601 } else if (value_changed) { | 12499 } else if (value_changed) { |
12602 EnqueueChangeRecord(object, "update", name, old_value); | 12500 EnqueueChangeRecord(object, "update", name, old_value); |
12603 } | 12501 } |
12604 } | 12502 } |
12605 | 12503 |
12606 return result; | 12504 return result; |
(...skipping 4001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16608 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16506 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16609 static const char* error_messages_[] = { | 16507 static const char* error_messages_[] = { |
16610 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16508 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16611 }; | 16509 }; |
16612 #undef ERROR_MESSAGES_TEXTS | 16510 #undef ERROR_MESSAGES_TEXTS |
16613 return error_messages_[reason]; | 16511 return error_messages_[reason]; |
16614 } | 16512 } |
16615 | 16513 |
16616 | 16514 |
16617 } } // namespace v8::internal | 16515 } } // namespace v8::internal |
OLD | NEW |