| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/objects.h" | 5 #include "src/objects.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <iomanip> | 8 #include <iomanip> |
| 9 #include <sstream> | 9 #include <sstream> |
| 10 | 10 |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 // 10. If targetDesc is not undefined, then | 792 // 10. If targetDesc is not undefined, then |
| 793 if (target_found.FromJust()) { | 793 if (target_found.FromJust()) { |
| 794 // 10.a. If IsDataDescriptor(targetDesc) and targetDesc.[[Configurable]] is | 794 // 10.a. If IsDataDescriptor(targetDesc) and targetDesc.[[Configurable]] is |
| 795 // false and targetDesc.[[Writable]] is false, then | 795 // false and targetDesc.[[Writable]] is false, then |
| 796 // 10.a.i. If SameValue(trapResult, targetDesc.[[Value]]) is false, | 796 // 10.a.i. If SameValue(trapResult, targetDesc.[[Value]]) is false, |
| 797 // throw a TypeError exception. | 797 // throw a TypeError exception. |
| 798 bool inconsistent = PropertyDescriptor::IsDataDescriptor(&target_desc) && | 798 bool inconsistent = PropertyDescriptor::IsDataDescriptor(&target_desc) && |
| 799 !target_desc.configurable() && | 799 !target_desc.configurable() && |
| 800 !target_desc.writable() && | 800 !target_desc.writable() && |
| 801 !trap_result->SameValue(*target_desc.value()); | 801 !trap_result->SameValue(*target_desc.value()); |
| 802 if (inconsistent) { |
| 803 THROW_NEW_ERROR( |
| 804 isolate, NewTypeError(MessageTemplate::kProxyGetNonConfigurableData, |
| 805 name, target_desc.value(), trap_result), |
| 806 Object); |
| 807 } |
| 802 // 10.b. If IsAccessorDescriptor(targetDesc) and targetDesc.[[Configurable]] | 808 // 10.b. If IsAccessorDescriptor(targetDesc) and targetDesc.[[Configurable]] |
| 803 // is false and targetDesc.[[Get]] is undefined, then | 809 // is false and targetDesc.[[Get]] is undefined, then |
| 804 // 10.b.i. If trapResult is not undefined, throw a TypeError exception. | 810 // 10.b.i. If trapResult is not undefined, throw a TypeError exception. |
| 805 inconsistent = | 811 inconsistent = PropertyDescriptor::IsAccessorDescriptor(&target_desc) && |
| 806 inconsistent || | 812 !target_desc.configurable() && |
| 807 (PropertyDescriptor::IsAccessorDescriptor(&target_desc) && | 813 target_desc.get()->IsUndefined() && |
| 808 !target_desc.configurable() && target_desc.get()->IsUndefined() && | 814 !trap_result->IsUndefined(); |
| 809 !trap_result->IsUndefined()); | |
| 810 if (inconsistent) { | 815 if (inconsistent) { |
| 811 THROW_NEW_ERROR( | 816 THROW_NEW_ERROR( |
| 812 isolate, | 817 isolate, |
| 813 NewTypeError(MessageTemplate::kProxyTrapViolatesInvariant, trap_name), | 818 NewTypeError(MessageTemplate::kProxyGetNonConfigurableAccessor, name, |
| 819 trap_result), |
| 814 Object); | 820 Object); |
| 815 } | 821 } |
| 816 } | 822 } |
| 817 // 11. Return trap_result | 823 // 11. Return trap_result |
| 818 return trap_result; | 824 return trap_result; |
| 819 } | 825 } |
| 820 | 826 |
| 821 | 827 |
| 822 Handle<Object> JSReceiver::GetDataProperty(Handle<JSReceiver> object, | 828 Handle<Object> JSReceiver::GetDataProperty(Handle<JSReceiver> object, |
| 823 Handle<Name> name) { | 829 Handle<Name> name) { |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 } | 986 } |
| 981 // 7. Let handlerProto be ? Call(trap, handler, «target»). | 987 // 7. Let handlerProto be ? Call(trap, handler, «target»). |
| 982 Handle<Object> argv[] = {target}; | 988 Handle<Object> argv[] = {target}; |
| 983 Handle<Object> handler_proto; | 989 Handle<Object> handler_proto; |
| 984 ASSIGN_RETURN_ON_EXCEPTION( | 990 ASSIGN_RETURN_ON_EXCEPTION( |
| 985 isolate, handler_proto, | 991 isolate, handler_proto, |
| 986 Execution::Call(isolate, trap, handler, arraysize(argv), argv), Object); | 992 Execution::Call(isolate, trap, handler, arraysize(argv), argv), Object); |
| 987 // 8. If Type(handlerProto) is neither Object nor Null, throw a TypeError. | 993 // 8. If Type(handlerProto) is neither Object nor Null, throw a TypeError. |
| 988 if (!(handler_proto->IsJSReceiver() || handler_proto->IsNull())) { | 994 if (!(handler_proto->IsJSReceiver() || handler_proto->IsNull())) { |
| 989 THROW_NEW_ERROR(isolate, | 995 THROW_NEW_ERROR(isolate, |
| 990 NewTypeError(MessageTemplate::kProxyHandlerTrapMissing, | 996 NewTypeError(MessageTemplate::kProxyGetPrototypeOfInvalid), |
| 991 handler, trap_name), | |
| 992 Object); | 997 Object); |
| 993 } | 998 } |
| 994 // 9. Let extensibleTarget be ? IsExtensible(target). | 999 // 9. Let extensibleTarget be ? IsExtensible(target). |
| 995 Maybe<bool> is_extensible = JSReceiver::IsExtensible(target); | 1000 Maybe<bool> is_extensible = JSReceiver::IsExtensible(target); |
| 996 MAYBE_RETURN_NULL(is_extensible); | 1001 MAYBE_RETURN_NULL(is_extensible); |
| 997 // 10. If extensibleTarget is true, return handlerProto. | 1002 // 10. If extensibleTarget is true, return handlerProto. |
| 998 if (is_extensible.FromJust()) return handler_proto; | 1003 if (is_extensible.FromJust()) return handler_proto; |
| 999 // 11. Let targetProto be ? target.[[GetPrototypeOf]](). | 1004 // 11. Let targetProto be ? target.[[GetPrototypeOf]](). |
| 1000 Handle<Object> target_proto; | 1005 Handle<Object> target_proto; |
| 1001 ASSIGN_RETURN_ON_EXCEPTION(isolate, target_proto, | 1006 ASSIGN_RETURN_ON_EXCEPTION(isolate, target_proto, |
| 1002 Object::GetPrototype(isolate, target), Object); | 1007 Object::GetPrototype(isolate, target), Object); |
| 1003 // 12. If SameValue(handlerProto, targetProto) is false, throw a TypeError. | 1008 // 12. If SameValue(handlerProto, targetProto) is false, throw a TypeError. |
| 1004 if (!handler_proto->SameValue(*target_proto)) { | 1009 if (!handler_proto->SameValue(*target_proto)) { |
| 1005 THROW_NEW_ERROR(isolate, | 1010 THROW_NEW_ERROR( |
| 1006 NewTypeError(MessageTemplate::kProxyHandlerTrapMissing, | 1011 isolate, |
| 1007 handler, trap_name), | 1012 NewTypeError(MessageTemplate::kProxyGetPrototypeOfNonExtensible), |
| 1008 Object); | 1013 Object); |
| 1009 } | 1014 } |
| 1010 // 13. Return handlerProto. | 1015 // 13. Return handlerProto. |
| 1011 return handler_proto; | 1016 return handler_proto; |
| 1012 } | 1017 } |
| 1013 | 1018 |
| 1014 | 1019 |
| 1015 MaybeHandle<Object> Object::GetPropertyWithAccessor( | 1020 MaybeHandle<Object> Object::GetPropertyWithAccessor( |
| 1016 LookupIterator* it, LanguageMode language_mode) { | 1021 LookupIterator* it, LanguageMode language_mode) { |
| 1017 Isolate* isolate = it->isolate(); | 1022 Isolate* isolate = it->isolate(); |
| 1018 Handle<Object> structure = it->GetAccessors(); | 1023 Handle<Object> structure = it->GetAccessors(); |
| (...skipping 3637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4656 PropertyDescriptor target_desc; | 4661 PropertyDescriptor target_desc; |
| 4657 Maybe<bool> target_found = JSReceiver::GetOwnPropertyDescriptor( | 4662 Maybe<bool> target_found = JSReceiver::GetOwnPropertyDescriptor( |
| 4658 isolate, target, name, &target_desc); | 4663 isolate, target, name, &target_desc); |
| 4659 MAYBE_RETURN(target_found, Nothing<bool>()); | 4664 MAYBE_RETURN(target_found, Nothing<bool>()); |
| 4660 // 9b. If targetDesc is not undefined, then: | 4665 // 9b. If targetDesc is not undefined, then: |
| 4661 if (target_found.FromJust()) { | 4666 if (target_found.FromJust()) { |
| 4662 // 9b i. If targetDesc.[[Configurable]] is false, throw a TypeError | 4667 // 9b i. If targetDesc.[[Configurable]] is false, throw a TypeError |
| 4663 // exception. | 4668 // exception. |
| 4664 if (!target_desc.configurable()) { | 4669 if (!target_desc.configurable()) { |
| 4665 isolate->Throw(*isolate->factory()->NewTypeError( | 4670 isolate->Throw(*isolate->factory()->NewTypeError( |
| 4666 MessageTemplate::kProxyTargetPropNotConfigurable, name)); | 4671 MessageTemplate::kProxyHasNonConfigurable, name)); |
| 4667 return Nothing<bool>(); | 4672 return Nothing<bool>(); |
| 4668 } | 4673 } |
| 4669 // 9b ii. Let extensibleTarget be ? IsExtensible(target). | 4674 // 9b ii. Let extensibleTarget be ? IsExtensible(target). |
| 4670 Maybe<bool> extensible_target = JSReceiver::IsExtensible(target); | 4675 Maybe<bool> extensible_target = JSReceiver::IsExtensible(target); |
| 4671 MAYBE_RETURN(extensible_target, Nothing<bool>()); | 4676 MAYBE_RETURN(extensible_target, Nothing<bool>()); |
| 4672 // 9b iii. If extensibleTarget is false, throw a TypeError exception. | 4677 // 9b iii. If extensibleTarget is false, throw a TypeError exception. |
| 4673 if (!extensible_target.FromJust()) { | 4678 if (!extensible_target.FromJust()) { |
| 4674 isolate->Throw(*isolate->factory()->NewTypeError( | 4679 isolate->Throw(*isolate->factory()->NewTypeError( |
| 4675 MessageTemplate::kProxyTargetNotExtensible)); | 4680 MessageTemplate::kProxyHasNonExtensible, name)); |
| 4676 return Nothing<bool>(); | 4681 return Nothing<bool>(); |
| 4677 } | 4682 } |
| 4678 } | 4683 } |
| 4679 } | 4684 } |
| 4680 // 10. Return booleanTrapResult. | 4685 // 10. Return booleanTrapResult. |
| 4681 return Just(boolean_trap_result); | 4686 return Just(boolean_trap_result); |
| 4682 } | 4687 } |
| 4683 | 4688 |
| 4684 | 4689 |
| 4685 Maybe<bool> JSProxy::SetProperty(Handle<JSProxy> proxy, Handle<Name> name, | 4690 Maybe<bool> JSProxy::SetProperty(Handle<JSProxy> proxy, Handle<Name> name, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 4710 } | 4715 } |
| 4711 | 4716 |
| 4712 Handle<Object> trap_result; | 4717 Handle<Object> trap_result; |
| 4713 Handle<Object> args[] = {target, name, value, receiver}; | 4718 Handle<Object> args[] = {target, name, value, receiver}; |
| 4714 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 4719 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 4715 isolate, trap_result, | 4720 isolate, trap_result, |
| 4716 Execution::Call(isolate, trap, handler, arraysize(args), args), | 4721 Execution::Call(isolate, trap, handler, arraysize(args), args), |
| 4717 Nothing<bool>()); | 4722 Nothing<bool>()); |
| 4718 if (!trap_result->BooleanValue()) { | 4723 if (!trap_result->BooleanValue()) { |
| 4719 RETURN_FAILURE(isolate, should_throw, | 4724 RETURN_FAILURE(isolate, should_throw, |
| 4720 NewTypeError(MessageTemplate::kProxyTrapReturnedFalseish, | 4725 NewTypeError(MessageTemplate::kProxyTrapReturnedFalsishFor, |
| 4721 handler, trap_result, trap_name)); | 4726 trap_name, name)); |
| 4722 } | 4727 } |
| 4723 | 4728 |
| 4724 // Enforce the invariant. | 4729 // Enforce the invariant. |
| 4725 PropertyDescriptor target_desc; | 4730 PropertyDescriptor target_desc; |
| 4726 Maybe<bool> owned = | 4731 Maybe<bool> owned = |
| 4727 JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, &target_desc); | 4732 JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, &target_desc); |
| 4728 MAYBE_RETURN(owned, Nothing<bool>()); | 4733 MAYBE_RETURN(owned, Nothing<bool>()); |
| 4729 if (owned.FromJust()) { | 4734 if (owned.FromJust()) { |
| 4730 bool inconsistent = | 4735 bool inconsistent = PropertyDescriptor::IsDataDescriptor(&target_desc) && |
| 4731 (PropertyDescriptor::IsDataDescriptor(&target_desc) && | 4736 !target_desc.configurable() && |
| 4732 !target_desc.configurable() && !target_desc.writable() && | 4737 !target_desc.writable() && |
| 4733 !value->SameValue(*target_desc.value())) || | 4738 !value->SameValue(*target_desc.value()); |
| 4734 (PropertyDescriptor::IsAccessorDescriptor(&target_desc) && | |
| 4735 !target_desc.configurable() && target_desc.set()->IsUndefined()); | |
| 4736 if (inconsistent) { | 4739 if (inconsistent) { |
| 4737 isolate->Throw(*isolate->factory()->NewTypeError( | 4740 isolate->Throw(*isolate->factory()->NewTypeError( |
| 4738 MessageTemplate::kProxyTrapViolatesInvariant, trap_name)); | 4741 MessageTemplate::kProxySetFrozenData, name)); |
| 4742 return Nothing<bool>(); |
| 4743 } |
| 4744 inconsistent = PropertyDescriptor::IsAccessorDescriptor(&target_desc) && |
| 4745 !target_desc.configurable() && |
| 4746 target_desc.set()->IsUndefined(); |
| 4747 if (inconsistent) { |
| 4748 isolate->Throw(*isolate->factory()->NewTypeError( |
| 4749 MessageTemplate::kProxySetFrozenAccessor, name)); |
| 4739 return Nothing<bool>(); | 4750 return Nothing<bool>(); |
| 4740 } | 4751 } |
| 4741 } | 4752 } |
| 4742 return Just(true); | 4753 return Just(true); |
| 4743 } | 4754 } |
| 4744 | 4755 |
| 4745 | 4756 |
| 4746 Maybe<bool> JSProxy::DeletePropertyOrElement(Handle<JSProxy> proxy, | 4757 Maybe<bool> JSProxy::DeletePropertyOrElement(Handle<JSProxy> proxy, |
| 4747 Handle<Name> name, | 4758 Handle<Name> name, |
| 4748 LanguageMode language_mode) { | 4759 LanguageMode language_mode) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4768 } | 4779 } |
| 4769 | 4780 |
| 4770 Handle<Object> trap_result; | 4781 Handle<Object> trap_result; |
| 4771 Handle<Object> args[] = {target, name}; | 4782 Handle<Object> args[] = {target, name}; |
| 4772 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 4783 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 4773 isolate, trap_result, | 4784 isolate, trap_result, |
| 4774 Execution::Call(isolate, trap, handler, arraysize(args), args), | 4785 Execution::Call(isolate, trap, handler, arraysize(args), args), |
| 4775 Nothing<bool>()); | 4786 Nothing<bool>()); |
| 4776 if (!trap_result->BooleanValue()) { | 4787 if (!trap_result->BooleanValue()) { |
| 4777 RETURN_FAILURE(isolate, should_throw, | 4788 RETURN_FAILURE(isolate, should_throw, |
| 4778 NewTypeError(MessageTemplate::kProxyTrapReturnedFalseish, | 4789 NewTypeError(MessageTemplate::kProxyTrapReturnedFalsishFor, |
| 4779 handler, trap_result, trap_name)); | 4790 trap_name, name)); |
| 4780 } | 4791 } |
| 4781 | 4792 |
| 4782 // Enforce the invariant. | 4793 // Enforce the invariant. |
| 4783 PropertyDescriptor target_desc; | 4794 PropertyDescriptor target_desc; |
| 4784 Maybe<bool> owned = | 4795 Maybe<bool> owned = |
| 4785 JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, &target_desc); | 4796 JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, &target_desc); |
| 4786 MAYBE_RETURN(owned, Nothing<bool>()); | 4797 MAYBE_RETURN(owned, Nothing<bool>()); |
| 4787 if (owned.FromJust() && !target_desc.configurable()) { | 4798 if (owned.FromJust() && !target_desc.configurable()) { |
| 4788 isolate->Throw(*factory->NewTypeError( | 4799 isolate->Throw(*factory->NewTypeError( |
| 4789 MessageTemplate::kProxyDeletePropertyViolatesInvariant, name)); | 4800 MessageTemplate::kProxyDeletePropertyNonConfigurable, name)); |
| 4790 return Nothing<bool>(); | 4801 return Nothing<bool>(); |
| 4791 } | 4802 } |
| 4792 return Just(true); | 4803 return Just(true); |
| 4793 } | 4804 } |
| 4794 | 4805 |
| 4795 | 4806 |
| 4796 // static | 4807 // static |
| 4797 MaybeHandle<Context> JSProxy::GetFunctionRealm(Handle<JSProxy> proxy) { | 4808 MaybeHandle<Context> JSProxy::GetFunctionRealm(Handle<JSProxy> proxy) { |
| 4798 DCHECK(proxy->map()->is_constructor()); | 4809 DCHECK(proxy->map()->is_constructor()); |
| 4799 if (proxy->IsRevoked()) { | 4810 if (proxy->IsRevoked()) { |
| (...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6248 | 6259 |
| 6249 return ValidateAndApplyPropertyDescriptor(isolate, it, extensible, desc, | 6260 return ValidateAndApplyPropertyDescriptor(isolate, it, extensible, desc, |
| 6250 ¤t, should_throw); | 6261 ¤t, should_throw); |
| 6251 } | 6262 } |
| 6252 | 6263 |
| 6253 | 6264 |
| 6254 // ES6 9.1.6.2 | 6265 // ES6 9.1.6.2 |
| 6255 // static | 6266 // static |
| 6256 Maybe<bool> JSReceiver::IsCompatiblePropertyDescriptor( | 6267 Maybe<bool> JSReceiver::IsCompatiblePropertyDescriptor( |
| 6257 Isolate* isolate, bool extensible, PropertyDescriptor* desc, | 6268 Isolate* isolate, bool extensible, PropertyDescriptor* desc, |
| 6258 PropertyDescriptor* current, Handle<Name> property_name) { | 6269 PropertyDescriptor* current, Handle<Name> property_name, |
| 6270 ShouldThrow should_throw) { |
| 6259 // 1. Return ValidateAndApplyPropertyDescriptor(undefined, undefined, | 6271 // 1. Return ValidateAndApplyPropertyDescriptor(undefined, undefined, |
| 6260 // Extensible, Desc, Current). | 6272 // Extensible, Desc, Current). |
| 6261 return ValidateAndApplyPropertyDescriptor( | 6273 return ValidateAndApplyPropertyDescriptor( |
| 6262 isolate, NULL, extensible, desc, current, THROW_ON_ERROR, property_name); | 6274 isolate, NULL, extensible, desc, current, should_throw, property_name); |
| 6263 } | 6275 } |
| 6264 | 6276 |
| 6265 | 6277 |
| 6266 // ES6 9.1.6.3 | 6278 // ES6 9.1.6.3 |
| 6267 // static | 6279 // static |
| 6268 Maybe<bool> JSReceiver::ValidateAndApplyPropertyDescriptor( | 6280 Maybe<bool> JSReceiver::ValidateAndApplyPropertyDescriptor( |
| 6269 Isolate* isolate, LookupIterator* it, bool extensible, | 6281 Isolate* isolate, LookupIterator* it, bool extensible, |
| 6270 PropertyDescriptor* desc, PropertyDescriptor* current, | 6282 PropertyDescriptor* desc, PropertyDescriptor* current, |
| 6271 ShouldThrow should_throw, Handle<Name> property_name) { | 6283 ShouldThrow should_throw, Handle<Name> property_name) { |
| 6272 // We either need a LookupIterator, or a property name. | 6284 // We either need a LookupIterator, or a property name. |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6822 : Handle<Name>::cast(isolate->factory()->NumberToString(key)); | 6834 : Handle<Name>::cast(isolate->factory()->NumberToString(key)); |
| 6823 Handle<Object> trap_result_obj; | 6835 Handle<Object> trap_result_obj; |
| 6824 Handle<Object> args[] = {target, property_name, desc_obj}; | 6836 Handle<Object> args[] = {target, property_name, desc_obj}; |
| 6825 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 6837 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 6826 isolate, trap_result_obj, | 6838 isolate, trap_result_obj, |
| 6827 Execution::Call(isolate, trap, handler, arraysize(args), args), | 6839 Execution::Call(isolate, trap, handler, arraysize(args), args), |
| 6828 Nothing<bool>()); | 6840 Nothing<bool>()); |
| 6829 // 10. If booleanTrapResult is false, return false. | 6841 // 10. If booleanTrapResult is false, return false. |
| 6830 if (!trap_result_obj->BooleanValue()) { | 6842 if (!trap_result_obj->BooleanValue()) { |
| 6831 RETURN_FAILURE(isolate, should_throw, | 6843 RETURN_FAILURE(isolate, should_throw, |
| 6832 NewTypeError(MessageTemplate::kProxyTrapReturnedFalseish, | 6844 NewTypeError(MessageTemplate::kProxyTrapReturnedFalsishFor, |
| 6833 handler, trap_result_obj, trap_name)); | 6845 trap_name, property_name)); |
| 6834 } | 6846 } |
| 6835 // 11. Let targetDesc be ? target.[[GetOwnProperty]](P). | 6847 // 11. Let targetDesc be ? target.[[GetOwnProperty]](P). |
| 6836 PropertyDescriptor target_desc; | 6848 PropertyDescriptor target_desc; |
| 6837 Maybe<bool> target_found = | 6849 Maybe<bool> target_found = |
| 6838 JSReceiver::GetOwnPropertyDescriptor(isolate, target, key, &target_desc); | 6850 JSReceiver::GetOwnPropertyDescriptor(isolate, target, key, &target_desc); |
| 6839 MAYBE_RETURN(target_found, Nothing<bool>()); | 6851 MAYBE_RETURN(target_found, Nothing<bool>()); |
| 6840 // 12. Let extensibleTarget be ? IsExtensible(target). | 6852 // 12. Let extensibleTarget be ? IsExtensible(target). |
| 6841 Maybe<bool> maybe_extensible = JSReceiver::IsExtensible(target); | 6853 Maybe<bool> maybe_extensible = JSReceiver::IsExtensible(target); |
| 6842 MAYBE_RETURN(maybe_extensible, Nothing<bool>()); | 6854 MAYBE_RETURN(maybe_extensible, Nothing<bool>()); |
| 6843 bool extensible_target = maybe_extensible.FromJust(); | 6855 bool extensible_target = maybe_extensible.FromJust(); |
| 6844 // 13. If Desc has a [[Configurable]] field and if Desc.[[Configurable]] | 6856 // 13. If Desc has a [[Configurable]] field and if Desc.[[Configurable]] |
| 6845 // is false, then: | 6857 // is false, then: |
| 6846 // 13a. Let settingConfigFalse be true. | 6858 // 13a. Let settingConfigFalse be true. |
| 6847 // 14. Else let settingConfigFalse be false. | 6859 // 14. Else let settingConfigFalse be false. |
| 6848 bool setting_config_false = desc->has_configurable() && !desc->configurable(); | 6860 bool setting_config_false = desc->has_configurable() && !desc->configurable(); |
| 6849 // 15. If targetDesc is undefined, then | 6861 // 15. If targetDesc is undefined, then |
| 6850 if (!target_found.FromJust()) { | 6862 if (!target_found.FromJust()) { |
| 6851 // 15a. If extensibleTarget is false, throw a TypeError exception. | 6863 // 15a. If extensibleTarget is false, throw a TypeError exception. |
| 6852 if (!extensible_target) { | 6864 if (!extensible_target) { |
| 6853 isolate->Throw(*isolate->factory()->NewTypeError( | 6865 isolate->Throw(*isolate->factory()->NewTypeError( |
| 6854 MessageTemplate::kProxyTargetNotExtensible)); | 6866 MessageTemplate::kProxyDefinePropertyNonExtensible, property_name)); |
| 6855 return Nothing<bool>(); | 6867 return Nothing<bool>(); |
| 6856 } | 6868 } |
| 6857 // 15b. If settingConfigFalse is true, throw a TypeError exception. | 6869 // 15b. If settingConfigFalse is true, throw a TypeError exception. |
| 6858 if (setting_config_false) { | 6870 if (setting_config_false) { |
| 6859 // TODO(jkummerow): Better error message? | |
| 6860 isolate->Throw(*isolate->factory()->NewTypeError( | 6871 isolate->Throw(*isolate->factory()->NewTypeError( |
| 6861 MessageTemplate::kRedefineDisallowed, key)); | 6872 MessageTemplate::kProxyDefinePropertyNonConfigurable, property_name)); |
| 6862 return Nothing<bool>(); | 6873 return Nothing<bool>(); |
| 6863 } | 6874 } |
| 6864 } else { | 6875 } else { |
| 6865 // 16. Else targetDesc is not undefined, | 6876 // 16. Else targetDesc is not undefined, |
| 6866 // 16a. If IsCompatiblePropertyDescriptor(extensibleTarget, Desc, | 6877 // 16a. If IsCompatiblePropertyDescriptor(extensibleTarget, Desc, |
| 6867 // targetDesc) is false, throw a TypeError exception. | 6878 // targetDesc) is false, throw a TypeError exception. |
| 6868 Maybe<bool> valid = IsCompatiblePropertyDescriptor( | 6879 Maybe<bool> valid = |
| 6869 isolate, extensible_target, desc, &target_desc, property_name); | 6880 IsCompatiblePropertyDescriptor(isolate, extensible_target, desc, |
| 6881 &target_desc, property_name, DONT_THROW); |
| 6870 MAYBE_RETURN(valid, Nothing<bool>()); | 6882 MAYBE_RETURN(valid, Nothing<bool>()); |
| 6871 DCHECK(valid.FromJust()); | 6883 if (!valid.FromJust()) { |
| 6884 isolate->Throw(*isolate->factory()->NewTypeError( |
| 6885 MessageTemplate::kProxyDefinePropertyIncompatible, property_name)); |
| 6886 return Nothing<bool>(); |
| 6887 } |
| 6872 // 16b. If settingConfigFalse is true and targetDesc.[[Configurable]] is | 6888 // 16b. If settingConfigFalse is true and targetDesc.[[Configurable]] is |
| 6873 // true, throw a TypeError exception. | 6889 // true, throw a TypeError exception. |
| 6874 if (setting_config_false && target_desc.configurable()) { | 6890 if (setting_config_false && target_desc.configurable()) { |
| 6875 // TODO(jkummerow): Better error message? | |
| 6876 isolate->Throw(*isolate->factory()->NewTypeError( | 6891 isolate->Throw(*isolate->factory()->NewTypeError( |
| 6877 MessageTemplate::kRedefineDisallowed, key)); | 6892 MessageTemplate::kProxyDefinePropertyNonConfigurable, property_name)); |
| 6878 return Nothing<bool>(); | 6893 return Nothing<bool>(); |
| 6879 } | 6894 } |
| 6880 } | 6895 } |
| 6881 // 17. Return true. | 6896 // 17. Return true. |
| 6882 return Just(true); | 6897 return Just(true); |
| 6883 } | 6898 } |
| 6884 | 6899 |
| 6885 | 6900 |
| 6886 // static | 6901 // static |
| 6887 Maybe<bool> JSReceiver::GetOwnPropertyDescriptor(Isolate* isolate, | 6902 Maybe<bool> JSReceiver::GetOwnPropertyDescriptor(Isolate* isolate, |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6990 Handle<Object> trap_result_obj; | 7005 Handle<Object> trap_result_obj; |
| 6991 Handle<Object> args[] = {target, name}; | 7006 Handle<Object> args[] = {target, name}; |
| 6992 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 7007 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 6993 isolate, trap_result_obj, | 7008 isolate, trap_result_obj, |
| 6994 Execution::Call(isolate, trap, handler, arraysize(args), args), | 7009 Execution::Call(isolate, trap, handler, arraysize(args), args), |
| 6995 Nothing<bool>()); | 7010 Nothing<bool>()); |
| 6996 // 9. If Type(trapResultObj) is neither Object nor Undefined, throw a | 7011 // 9. If Type(trapResultObj) is neither Object nor Undefined, throw a |
| 6997 // TypeError exception. | 7012 // TypeError exception. |
| 6998 if (!trap_result_obj->IsJSReceiver() && !trap_result_obj->IsUndefined()) { | 7013 if (!trap_result_obj->IsJSReceiver() && !trap_result_obj->IsUndefined()) { |
| 6999 isolate->Throw(*isolate->factory()->NewTypeError( | 7014 isolate->Throw(*isolate->factory()->NewTypeError( |
| 7000 MessageTemplate::kProxyTrapReturnedFalseish, handler, trap_result_obj, | 7015 MessageTemplate::kProxyGetOwnPropertyDescriptorInvalid, name)); |
| 7001 trap_name)); | |
| 7002 return Nothing<bool>(); | 7016 return Nothing<bool>(); |
| 7003 } | 7017 } |
| 7004 // 10. Let targetDesc be ? target.[[GetOwnProperty]](P). | 7018 // 10. Let targetDesc be ? target.[[GetOwnProperty]](P). |
| 7005 PropertyDescriptor target_desc; | 7019 PropertyDescriptor target_desc; |
| 7006 Maybe<bool> found = | 7020 Maybe<bool> found = |
| 7007 JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, &target_desc); | 7021 JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, &target_desc); |
| 7008 MAYBE_RETURN(found, Nothing<bool>()); | 7022 MAYBE_RETURN(found, Nothing<bool>()); |
| 7009 // 11. If trapResultObj is undefined, then | 7023 // 11. If trapResultObj is undefined, then |
| 7010 if (trap_result_obj->IsUndefined()) { | 7024 if (trap_result_obj->IsUndefined()) { |
| 7011 // 11a. If targetDesc is undefined, return undefined. | 7025 // 11a. If targetDesc is undefined, return undefined. |
| 7012 if (!found.FromJust()) return Just(false); | 7026 if (!found.FromJust()) return Just(false); |
| 7013 // 11b. If targetDesc.[[Configurable]] is false, throw a TypeError | 7027 // 11b. If targetDesc.[[Configurable]] is false, throw a TypeError |
| 7014 // exception. | 7028 // exception. |
| 7015 if (!target_desc.configurable()) { | 7029 if (!target_desc.configurable()) { |
| 7016 isolate->Throw(*isolate->factory()->NewTypeError( | 7030 isolate->Throw(*isolate->factory()->NewTypeError( |
| 7017 MessageTemplate::kProxyTargetPropNotConfigurable, name)); | 7031 MessageTemplate::kProxyGetOwnPropertyDescriptorUndefined, name)); |
| 7018 return Nothing<bool>(); | 7032 return Nothing<bool>(); |
| 7019 } | 7033 } |
| 7020 // 11c. Let extensibleTarget be ? IsExtensible(target). | 7034 // 11c. Let extensibleTarget be ? IsExtensible(target). |
| 7021 Maybe<bool> extensible_target = JSReceiver::IsExtensible(target); | 7035 Maybe<bool> extensible_target = JSReceiver::IsExtensible(target); |
| 7022 MAYBE_RETURN(extensible_target, Nothing<bool>()); | 7036 MAYBE_RETURN(extensible_target, Nothing<bool>()); |
| 7023 // 11d. (Assert) | 7037 // 11d. (Assert) |
| 7024 // 11e. If extensibleTarget is false, throw a TypeError exception. | 7038 // 11e. If extensibleTarget is false, throw a TypeError exception. |
| 7025 if (!extensible_target.FromJust()) { | 7039 if (!extensible_target.FromJust()) { |
| 7026 isolate->Throw(*isolate->factory()->NewTypeError( | 7040 isolate->Throw(*isolate->factory()->NewTypeError( |
| 7027 MessageTemplate::kProxyTargetNotExtensible)); | 7041 MessageTemplate::kProxyGetOwnPropertyDescriptorNonExtensible, name)); |
| 7028 return Nothing<bool>(); | 7042 return Nothing<bool>(); |
| 7029 } | 7043 } |
| 7030 // 11f. Return undefined. | 7044 // 11f. Return undefined. |
| 7031 return Just(false); | 7045 return Just(false); |
| 7032 } | 7046 } |
| 7033 // 12. Let extensibleTarget be ? IsExtensible(target). | 7047 // 12. Let extensibleTarget be ? IsExtensible(target). |
| 7034 Maybe<bool> extensible_target = JSReceiver::IsExtensible(target); | 7048 Maybe<bool> extensible_target = JSReceiver::IsExtensible(target); |
| 7035 MAYBE_RETURN(extensible_target, Nothing<bool>()); | 7049 MAYBE_RETURN(extensible_target, Nothing<bool>()); |
| 7036 // 13. Let resultDesc be ? ToPropertyDescriptor(trapResultObj). | 7050 // 13. Let resultDesc be ? ToPropertyDescriptor(trapResultObj). |
| 7037 if (!PropertyDescriptor::ToPropertyDescriptor(isolate, trap_result_obj, | 7051 if (!PropertyDescriptor::ToPropertyDescriptor(isolate, trap_result_obj, |
| 7038 desc)) { | 7052 desc)) { |
| 7039 DCHECK(isolate->has_pending_exception()); | 7053 DCHECK(isolate->has_pending_exception()); |
| 7040 return Nothing<bool>(); | 7054 return Nothing<bool>(); |
| 7041 } | 7055 } |
| 7042 // 14. Call CompletePropertyDescriptor(resultDesc). | 7056 // 14. Call CompletePropertyDescriptor(resultDesc). |
| 7043 PropertyDescriptor::CompletePropertyDescriptor(isolate, desc); | 7057 PropertyDescriptor::CompletePropertyDescriptor(isolate, desc); |
| 7044 // 15. Let valid be IsCompatiblePropertyDescriptor (extensibleTarget, | 7058 // 15. Let valid be IsCompatiblePropertyDescriptor (extensibleTarget, |
| 7045 // resultDesc, targetDesc). | 7059 // resultDesc, targetDesc). |
| 7046 Maybe<bool> valid = IsCompatiblePropertyDescriptor( | 7060 Maybe<bool> valid = |
| 7047 isolate, extensible_target.FromJust(), desc, &target_desc, name); | 7061 IsCompatiblePropertyDescriptor(isolate, extensible_target.FromJust(), |
| 7062 desc, &target_desc, name, DONT_THROW); |
| 7063 MAYBE_RETURN(valid, Nothing<bool>()); |
| 7048 // 16. If valid is false, throw a TypeError exception. | 7064 // 16. If valid is false, throw a TypeError exception. |
| 7049 MAYBE_RETURN(valid, Nothing<bool>()); | 7065 if (!valid.FromJust()) { |
| 7050 DCHECK(valid.FromJust()); | 7066 isolate->Throw(*isolate->factory()->NewTypeError( |
| 7067 MessageTemplate::kProxyGetOwnPropertyDescriptorIncompatible, name)); |
| 7068 return Nothing<bool>(); |
| 7069 } |
| 7051 // 17. If resultDesc.[[Configurable]] is false, then | 7070 // 17. If resultDesc.[[Configurable]] is false, then |
| 7052 if (!desc->configurable()) { | 7071 if (!desc->configurable()) { |
| 7053 // 17a. If targetDesc is undefined or targetDesc.[[Configurable]] is true: | 7072 // 17a. If targetDesc is undefined or targetDesc.[[Configurable]] is true: |
| 7054 if (target_desc.is_empty() || target_desc.configurable()) { | 7073 if (target_desc.is_empty() || target_desc.configurable()) { |
| 7055 // 17a i. Throw a TypeError exception. | 7074 // 17a i. Throw a TypeError exception. |
| 7056 isolate->Throw(*isolate->factory()->NewTypeError( | 7075 isolate->Throw(*isolate->factory()->NewTypeError( |
| 7057 MessageTemplate::kProxyTrapDescriptorNonConfigurable, trap_name, | 7076 MessageTemplate::kProxyGetOwnPropertyDescriptorNonConfigurable, |
| 7058 name)); | 7077 name)); |
| 7059 return Nothing<bool>(); | 7078 return Nothing<bool>(); |
| 7060 } | 7079 } |
| 7061 } | 7080 } |
| 7062 // 18. Return resultDesc. | 7081 // 18. Return resultDesc. |
| 7063 return Just(true); | 7082 return Just(true); |
| 7064 } | 7083 } |
| 7065 | 7084 |
| 7066 | 7085 |
| 7067 bool JSObject::ReferencesObjectFromElements(FixedArray* elements, | 7086 bool JSObject::ReferencesObjectFromElements(FixedArray* elements, |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7330 return JSReceiver::PreventExtensions(target, should_throw); | 7349 return JSReceiver::PreventExtensions(target, should_throw); |
| 7331 } | 7350 } |
| 7332 | 7351 |
| 7333 Handle<Object> trap_result; | 7352 Handle<Object> trap_result; |
| 7334 Handle<Object> args[] = {target}; | 7353 Handle<Object> args[] = {target}; |
| 7335 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 7354 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 7336 isolate, trap_result, | 7355 isolate, trap_result, |
| 7337 Execution::Call(isolate, trap, handler, arraysize(args), args), | 7356 Execution::Call(isolate, trap, handler, arraysize(args), args), |
| 7338 Nothing<bool>()); | 7357 Nothing<bool>()); |
| 7339 if (!trap_result->BooleanValue()) { | 7358 if (!trap_result->BooleanValue()) { |
| 7340 RETURN_FAILURE(isolate, should_throw, | 7359 RETURN_FAILURE( |
| 7341 NewTypeError(MessageTemplate::kProxyTrapReturned, handler, | 7360 isolate, should_throw, |
| 7342 trap_result, trap_name)); | 7361 NewTypeError(MessageTemplate::kProxyTrapReturnedFalsish, trap_name)); |
| 7343 } | 7362 } |
| 7344 | 7363 |
| 7345 // Enforce the invariant. | 7364 // Enforce the invariant. |
| 7346 Maybe<bool> target_result = JSReceiver::IsExtensible(target); | 7365 Maybe<bool> target_result = JSReceiver::IsExtensible(target); |
| 7347 MAYBE_RETURN(target_result, Nothing<bool>()); | 7366 MAYBE_RETURN(target_result, Nothing<bool>()); |
| 7348 if (target_result.FromJust()) { | 7367 if (target_result.FromJust()) { |
| 7349 isolate->Throw(*factory->NewTypeError( | 7368 isolate->Throw(*factory->NewTypeError( |
| 7350 MessageTemplate::kProxyPreventExtensionsViolatesInvariant)); | 7369 MessageTemplate::kProxyPreventExtensionsExtensible)); |
| 7351 return Nothing<bool>(); | 7370 return Nothing<bool>(); |
| 7352 } | 7371 } |
| 7353 return Just(true); | 7372 return Just(true); |
| 7354 } | 7373 } |
| 7355 | 7374 |
| 7356 | 7375 |
| 7357 Maybe<bool> JSObject::PreventExtensions(Handle<JSObject> object, | 7376 Maybe<bool> JSObject::PreventExtensions(Handle<JSObject> object, |
| 7358 ShouldThrow should_throw) { | 7377 ShouldThrow should_throw) { |
| 7359 Isolate* isolate = object->GetIsolate(); | 7378 Isolate* isolate = object->GetIsolate(); |
| 7360 | 7379 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7443 Handle<Object> args[] = {target}; | 7462 Handle<Object> args[] = {target}; |
| 7444 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 7463 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 7445 isolate, trap_result, | 7464 isolate, trap_result, |
| 7446 Execution::Call(isolate, trap, handler, arraysize(args), args), | 7465 Execution::Call(isolate, trap, handler, arraysize(args), args), |
| 7447 Nothing<bool>()); | 7466 Nothing<bool>()); |
| 7448 | 7467 |
| 7449 // Enforce the invariant. | 7468 // Enforce the invariant. |
| 7450 Maybe<bool> target_result = JSReceiver::IsExtensible(target); | 7469 Maybe<bool> target_result = JSReceiver::IsExtensible(target); |
| 7451 MAYBE_RETURN(target_result, Nothing<bool>()); | 7470 MAYBE_RETURN(target_result, Nothing<bool>()); |
| 7452 if (target_result.FromJust() != trap_result->BooleanValue()) { | 7471 if (target_result.FromJust() != trap_result->BooleanValue()) { |
| 7453 isolate->Throw(*factory->NewTypeError( | 7472 isolate->Throw( |
| 7454 MessageTemplate::kProxyTrapViolatesInvariant, trap_name)); | 7473 *factory->NewTypeError(MessageTemplate::kProxyIsExtensibleInconsistent, |
| 7474 factory->ToBoolean(target_result.FromJust()))); |
| 7455 return Nothing<bool>(); | 7475 return Nothing<bool>(); |
| 7456 } | 7476 } |
| 7457 return target_result; | 7477 return target_result; |
| 7458 } | 7478 } |
| 7459 | 7479 |
| 7460 | 7480 |
| 7461 bool JSObject::IsExtensible(Handle<JSObject> object) { | 7481 bool JSObject::IsExtensible(Handle<JSObject> object) { |
| 7462 Isolate* isolate = object->GetIsolate(); | 7482 Isolate* isolate = object->GetIsolate(); |
| 7463 if (object->IsAccessCheckNeeded() && | 7483 if (object->IsAccessCheckNeeded() && |
| 7464 !isolate->MayAccess(handle(isolate->context()), object)) { | 7484 !isolate->MayAccess(handle(isolate->context()), object)) { |
| (...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8571 unchecked_result_keys.Set(trap_result->get(i), kPresent); | 8591 unchecked_result_keys.Set(trap_result->get(i), kPresent); |
| 8572 } | 8592 } |
| 8573 // 17. Repeat, for each key that is an element of targetNonconfigurableKeys: | 8593 // 17. Repeat, for each key that is an element of targetNonconfigurableKeys: |
| 8574 for (int i = 0; i < nonconfigurable_keys_length; ++i) { | 8594 for (int i = 0; i < nonconfigurable_keys_length; ++i) { |
| 8575 Object* key = target_nonconfigurable_keys->get(i); | 8595 Object* key = target_nonconfigurable_keys->get(i); |
| 8576 // 17a. If key is not an element of uncheckedResultKeys, throw a | 8596 // 17a. If key is not an element of uncheckedResultKeys, throw a |
| 8577 // TypeError exception. | 8597 // TypeError exception. |
| 8578 int* found = unchecked_result_keys.Find(key); | 8598 int* found = unchecked_result_keys.Find(key); |
| 8579 if (found == nullptr || *found == kGone) { | 8599 if (found == nullptr || *found == kGone) { |
| 8580 isolate->Throw(*isolate->factory()->NewTypeError( | 8600 isolate->Throw(*isolate->factory()->NewTypeError( |
| 8581 MessageTemplate::kProxyTrapOwnKeysResultMustInclude, | 8601 MessageTemplate::kProxyOwnKeysMissing, handle(key, isolate))); |
| 8582 handle(key, isolate))); | |
| 8583 return Nothing<bool>(); | 8602 return Nothing<bool>(); |
| 8584 } | 8603 } |
| 8585 // 17b. Remove key from uncheckedResultKeys. | 8604 // 17b. Remove key from uncheckedResultKeys. |
| 8586 *found = kGone; | 8605 *found = kGone; |
| 8587 unchecked_result_keys_size--; | 8606 unchecked_result_keys_size--; |
| 8588 } | 8607 } |
| 8589 // 18. If extensibleTarget is true, return trapResult. | 8608 // 18. If extensibleTarget is true, return trapResult. |
| 8590 if (extensible_target) { | 8609 if (extensible_target) { |
| 8591 return accumulator->AddKeysFromProxy(proxy, trap_result); | 8610 return accumulator->AddKeysFromProxy(proxy, trap_result); |
| 8592 } | 8611 } |
| 8593 // 19. Repeat, for each key that is an element of targetConfigurableKeys: | 8612 // 19. Repeat, for each key that is an element of targetConfigurableKeys: |
| 8594 for (int i = 0; i < target_configurable_keys->length(); ++i) { | 8613 for (int i = 0; i < target_configurable_keys->length(); ++i) { |
| 8595 Object* key = target_configurable_keys->get(i); | 8614 Object* key = target_configurable_keys->get(i); |
| 8596 if (key->IsSmi()) continue; // Zapped entry, was nonconfigurable. | 8615 if (key->IsSmi()) continue; // Zapped entry, was nonconfigurable. |
| 8597 // 19a. If key is not an element of uncheckedResultKeys, throw a | 8616 // 19a. If key is not an element of uncheckedResultKeys, throw a |
| 8598 // TypeError exception. | 8617 // TypeError exception. |
| 8599 int* found = unchecked_result_keys.Find(key); | 8618 int* found = unchecked_result_keys.Find(key); |
| 8600 if (found == nullptr || *found == kGone) { | 8619 if (found == nullptr || *found == kGone) { |
| 8601 isolate->Throw(*isolate->factory()->NewTypeError( | 8620 isolate->Throw(*isolate->factory()->NewTypeError( |
| 8602 MessageTemplate::kProxyTrapOwnKeysResultMustInclude, | 8621 MessageTemplate::kProxyOwnKeysMissing, handle(key, isolate))); |
| 8603 handle(key, isolate))); | |
| 8604 return Nothing<bool>(); | 8622 return Nothing<bool>(); |
| 8605 } | 8623 } |
| 8606 // 19b. Remove key from uncheckedResultKeys. | 8624 // 19b. Remove key from uncheckedResultKeys. |
| 8607 *found = kGone; | 8625 *found = kGone; |
| 8608 unchecked_result_keys_size--; | 8626 unchecked_result_keys_size--; |
| 8609 } | 8627 } |
| 8610 // 20. If uncheckedResultKeys is not empty, throw a TypeError exception. | 8628 // 20. If uncheckedResultKeys is not empty, throw a TypeError exception. |
| 8611 if (unchecked_result_keys_size != 0) { | 8629 if (unchecked_result_keys_size != 0) { |
| 8612 DCHECK_GT(unchecked_result_keys_size, 0); | 8630 DCHECK_GT(unchecked_result_keys_size, 0); |
| 8613 isolate->Throw(*isolate->factory()->NewTypeError( | 8631 isolate->Throw(*isolate->factory()->NewTypeError( |
| 8614 MessageTemplate::kProxyTargetNotExtensible)); | 8632 MessageTemplate::kProxyOwnKeysNonExtensible)); |
| 8615 return Nothing<bool>(); | 8633 return Nothing<bool>(); |
| 8616 } | 8634 } |
| 8617 // 21. Return trapResult. | 8635 // 21. Return trapResult. |
| 8618 return accumulator->AddKeysFromProxy(proxy, trap_result); | 8636 return accumulator->AddKeysFromProxy(proxy, trap_result); |
| 8619 } | 8637 } |
| 8620 | 8638 |
| 8621 | 8639 |
| 8622 MaybeHandle<FixedArray> JSReceiver::GetKeys(Handle<JSReceiver> object, | 8640 MaybeHandle<FixedArray> JSReceiver::GetKeys(Handle<JSReceiver> object, |
| 8623 KeyCollectionType type, | 8641 KeyCollectionType type, |
| 8624 PropertyFilter filter, | 8642 PropertyFilter filter, |
| (...skipping 6519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15144 Handle<Object> trap_result; | 15162 Handle<Object> trap_result; |
| 15145 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 15163 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 15146 isolate, trap_result, | 15164 isolate, trap_result, |
| 15147 Execution::Call(isolate, trap, handler, arraysize(argv), argv), | 15165 Execution::Call(isolate, trap, handler, arraysize(argv), argv), |
| 15148 Nothing<bool>()); | 15166 Nothing<bool>()); |
| 15149 bool bool_trap_result = trap_result->BooleanValue(); | 15167 bool bool_trap_result = trap_result->BooleanValue(); |
| 15150 // 9. Let extensibleTarget be ? IsExtensible(target). | 15168 // 9. Let extensibleTarget be ? IsExtensible(target). |
| 15151 Maybe<bool> is_extensible = JSReceiver::IsExtensible(target); | 15169 Maybe<bool> is_extensible = JSReceiver::IsExtensible(target); |
| 15152 if (is_extensible.IsNothing()) return Nothing<bool>(); | 15170 if (is_extensible.IsNothing()) return Nothing<bool>(); |
| 15153 // 10. If extensibleTarget is true, return booleanTrapResult. | 15171 // 10. If extensibleTarget is true, return booleanTrapResult. |
| 15154 if (is_extensible.FromJust()) return Just(bool_trap_result); | 15172 if (is_extensible.FromJust()) { |
| 15173 if (bool_trap_result) return Just(true); |
| 15174 RETURN_FAILURE( |
| 15175 isolate, should_throw, |
| 15176 NewTypeError(MessageTemplate::kProxyTrapReturnedFalsish, trap_name)); |
| 15177 } |
| 15155 // 11. Let targetProto be ? target.[[GetPrototypeOf]](). | 15178 // 11. Let targetProto be ? target.[[GetPrototypeOf]](). |
| 15156 Handle<Object> target_proto; | 15179 Handle<Object> target_proto; |
| 15157 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, target_proto, | 15180 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, target_proto, |
| 15158 Object::GetPrototype(isolate, target), | 15181 Object::GetPrototype(isolate, target), |
| 15159 Nothing<bool>()); | 15182 Nothing<bool>()); |
| 15160 // 12. If booleanTrapResult is true and SameValue(V, targetProto) is false, | 15183 // 12. If booleanTrapResult is true and SameValue(V, targetProto) is false, |
| 15161 // throw a TypeError exception. | 15184 // throw a TypeError exception. |
| 15162 if (bool_trap_result && !value->SameValue(*target_proto)) { | 15185 if (bool_trap_result && !value->SameValue(*target_proto)) { |
| 15163 isolate->Throw(*isolate->factory()->NewTypeError( | 15186 isolate->Throw(*isolate->factory()->NewTypeError( |
| 15164 MessageTemplate::kProxyTrapViolatesInvariant, trap_name)); | 15187 MessageTemplate::kProxySetPrototypeOfNonExtensible)); |
| 15165 return Nothing<bool>(); | 15188 return Nothing<bool>(); |
| 15166 } | 15189 } |
| 15167 // 13. Return booleanTrapResult. | 15190 // 13. Return booleanTrapResult. |
| 15168 return Just(bool_trap_result); | 15191 if (bool_trap_result) return Just(true); |
| 15192 RETURN_FAILURE( |
| 15193 isolate, should_throw, |
| 15194 NewTypeError(MessageTemplate::kProxyTrapReturnedFalsish, trap_name)); |
| 15169 } | 15195 } |
| 15170 | 15196 |
| 15171 | 15197 |
| 15172 Maybe<bool> JSObject::SetPrototype(Handle<JSObject> object, | 15198 Maybe<bool> JSObject::SetPrototype(Handle<JSObject> object, |
| 15173 Handle<Object> value, bool from_javascript, | 15199 Handle<Object> value, bool from_javascript, |
| 15174 ShouldThrow should_throw) { | 15200 ShouldThrow should_throw) { |
| 15175 Isolate* isolate = object->GetIsolate(); | 15201 Isolate* isolate = object->GetIsolate(); |
| 15176 | 15202 |
| 15177 const bool observed = from_javascript && object->map()->is_observed(); | 15203 const bool observed = from_javascript && object->map()->is_observed(); |
| 15178 Handle<Object> old_value; | 15204 Handle<Object> old_value; |
| (...skipping 4105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19284 if (cell->value() != *new_value) { | 19310 if (cell->value() != *new_value) { |
| 19285 cell->set_value(*new_value); | 19311 cell->set_value(*new_value); |
| 19286 Isolate* isolate = cell->GetIsolate(); | 19312 Isolate* isolate = cell->GetIsolate(); |
| 19287 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19313 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 19288 isolate, DependentCode::kPropertyCellChangedGroup); | 19314 isolate, DependentCode::kPropertyCellChangedGroup); |
| 19289 } | 19315 } |
| 19290 } | 19316 } |
| 19291 | 19317 |
| 19292 } // namespace internal | 19318 } // namespace internal |
| 19293 } // namespace v8 | 19319 } // namespace v8 |
| OLD | NEW |