Chromium Code Reviews| 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 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 751 MaybeHandle<Object> JSProxy::GetProperty(Isolate* isolate, | 751 MaybeHandle<Object> JSProxy::GetProperty(Isolate* isolate, |
| 752 Handle<JSProxy> proxy, | 752 Handle<JSProxy> proxy, |
| 753 Handle<Name> name, | 753 Handle<Name> name, |
| 754 Handle<Object> receiver, | 754 Handle<Object> receiver, |
| 755 LanguageMode language_mode) { | 755 LanguageMode language_mode) { |
| 756 Handle<Name> trap_name = isolate->factory()->get_string(); | 756 Handle<Name> trap_name = isolate->factory()->get_string(); |
| 757 // 1. Assert: IsPropertyKey(P) is true. | 757 // 1. Assert: IsPropertyKey(P) is true. |
| 758 // 2. Let handler be the value of the [[ProxyHandler]] internal slot of O. | 758 // 2. Let handler be the value of the [[ProxyHandler]] internal slot of O. |
| 759 Handle<Object> handler(proxy->handler(), isolate); | 759 Handle<Object> handler(proxy->handler(), isolate); |
| 760 // 3. If handler is null, throw a TypeError exception. | 760 // 3. If handler is null, throw a TypeError exception. |
| 761 // 4. Assert: Type(handler) is Object. | |
| 761 if (proxy->IsRevoked()) { | 762 if (proxy->IsRevoked()) { |
| 762 THROW_NEW_ERROR(isolate, | 763 THROW_NEW_ERROR(isolate, |
| 763 NewTypeError(MessageTemplate::kProxyRevoked, trap_name), | 764 NewTypeError(MessageTemplate::kProxyRevoked, trap_name), |
| 764 Object); | 765 Object); |
| 765 } | 766 } |
| 766 // 4. Assert: Type(handler) is Object. | |
| 767 DCHECK(handler->IsJSReceiver()); | |
| 768 DCHECK(proxy->target()->IsJSReceiver()); | |
| 769 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. | 767 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. |
| 770 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate); | 768 Handle<JSReceiver> target(proxy->target(), isolate); |
| 771 // 6. Let trap be ? GetMethod(handler, "get"). | 769 // 6. Let trap be ? GetMethod(handler, "get"). |
| 772 Handle<Object> trap; | 770 Handle<Object> trap; |
| 773 ASSIGN_RETURN_ON_EXCEPTION( | 771 ASSIGN_RETURN_ON_EXCEPTION( |
| 774 isolate, trap, | 772 isolate, trap, |
| 775 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), Object); | 773 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), Object); |
| 776 // 7. If trap is undefined, then | 774 // 7. If trap is undefined, then |
| 777 if (trap->IsUndefined()) { | 775 if (trap->IsUndefined()) { |
| 778 // 7.a Return target.[[Get]](P, Receiver). | 776 // 7.a Return target.[[Get]](P, Receiver). |
| 779 LookupIterator it = | 777 LookupIterator it = |
| 780 LookupIterator::PropertyOrElement(isolate, receiver, name, target); | 778 LookupIterator::PropertyOrElement(isolate, receiver, name, target); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 950 object->set_elements(*writable_elems); | 948 object->set_elements(*writable_elems); |
| 951 isolate->counters()->cow_arrays_converted()->Increment(); | 949 isolate->counters()->cow_arrays_converted()->Increment(); |
| 952 return writable_elems; | 950 return writable_elems; |
| 953 } | 951 } |
| 954 | 952 |
| 955 | 953 |
| 956 // ES6 9.5.1 | 954 // ES6 9.5.1 |
| 957 // static | 955 // static |
| 958 MaybeHandle<Object> JSProxy::GetPrototype(Handle<JSProxy> proxy) { | 956 MaybeHandle<Object> JSProxy::GetPrototype(Handle<JSProxy> proxy) { |
| 959 Isolate* isolate = proxy->GetIsolate(); | 957 Isolate* isolate = proxy->GetIsolate(); |
| 958 Handle<String> trap_name = isolate->factory()->getPrototypeOf_string(); | |
| 959 | |
| 960 // 1. Let handler be the value of the [[ProxyHandler]] internal slot. | 960 // 1. Let handler be the value of the [[ProxyHandler]] internal slot. |
| 961 Handle<Object> raw_handler(proxy->handler(), isolate); | |
| 962 // 2. If handler is null, throw a TypeError exception. | 961 // 2. If handler is null, throw a TypeError exception. |
| 963 // 3. Assert: Type(handler) is Object. | 962 // 3. Assert: Type(handler) is Object. |
| 964 if (!raw_handler->IsJSReceiver()) { | 963 // 4. Let target be the value of the [[ProxyTarget]] internal slot. |
| 965 // TODO(cbruni): Throw correct error message. | 964 if (proxy->IsRevoked()) { |
| 966 THROW_NEW_ERROR( | 965 THROW_NEW_ERROR(isolate, |
| 967 isolate, NewTypeError(MessageTemplate::kProxyHandlerNonObject), Object); | 966 NewTypeError(MessageTemplate::kProxyRevoked, trap_name), |
| 967 Object); | |
| 968 } | 968 } |
| 969 Handle<JSReceiver> handler = Handle<JSReceiver>::cast(raw_handler); | 969 Handle<JSReceiver> target(proxy->target(), isolate); |
| 970 // 4. Let target be the value of the [[ProxyTarget]] internal slot. | 970 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); |
| 971 // TODO(cbruni): Change target type to JSReceiver by default. | 971 |
| 972 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate); | |
| 973 // 5. Let trap be ? GetMethod(handler, "getPrototypeOf"). | 972 // 5. Let trap be ? GetMethod(handler, "getPrototypeOf"). |
| 974 Handle<Object> trap; | 973 Handle<Object> trap; |
| 975 Handle<String> trap_name = isolate->factory()->getPrototypeOf_string(); | |
| 976 ASSIGN_RETURN_ON_EXCEPTION(isolate, trap, GetMethod(handler, trap_name), | 974 ASSIGN_RETURN_ON_EXCEPTION(isolate, trap, GetMethod(handler, trap_name), |
| 977 Object); | 975 Object); |
| 978 // 6. If trap is undefined, then return target.[[GetPrototypeOf]](). | 976 // 6. If trap is undefined, then return target.[[GetPrototypeOf]](). |
| 979 if (trap->IsUndefined()) { | 977 if (trap->IsUndefined()) { |
| 980 return Object::GetPrototype(isolate, target); | 978 return Object::GetPrototype(isolate, target); |
| 981 } | 979 } |
| 982 // 7. Let handlerProto be ? Call(trap, handler, «target»). | 980 // 7. Let handlerProto be ? Call(trap, handler, «target»). |
| 983 Handle<Object> argv[] = {target}; | 981 Handle<Object> argv[] = {target}; |
| 984 Handle<Object> handler_proto; | 982 Handle<Object> handler_proto; |
| 985 ASSIGN_RETURN_ON_EXCEPTION( | 983 ASSIGN_RETURN_ON_EXCEPTION( |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1006 THROW_NEW_ERROR(isolate, | 1004 THROW_NEW_ERROR(isolate, |
| 1007 NewTypeError(MessageTemplate::kProxyHandlerTrapMissing, | 1005 NewTypeError(MessageTemplate::kProxyHandlerTrapMissing, |
| 1008 handler, trap_name), | 1006 handler, trap_name), |
| 1009 Object); | 1007 Object); |
| 1010 } | 1008 } |
| 1011 // 13. Return handlerProto. | 1009 // 13. Return handlerProto. |
| 1012 return handler_proto; | 1010 return handler_proto; |
| 1013 } | 1011 } |
| 1014 | 1012 |
| 1015 | 1013 |
| 1016 bool JSProxy::IsRevoked() const { | |
| 1017 // TODO(neis): Decide on how to represent revocation. For now, revocation is | |
| 1018 // unsupported. | |
| 1019 DCHECK(target()->IsJSReceiver()); | |
| 1020 DCHECK(handler()->IsJSReceiver()); | |
| 1021 return false; | |
| 1022 } | |
| 1023 | |
| 1024 | |
| 1025 MaybeHandle<Object> Object::GetPropertyWithAccessor( | 1014 MaybeHandle<Object> Object::GetPropertyWithAccessor( |
| 1026 LookupIterator* it, LanguageMode language_mode) { | 1015 LookupIterator* it, LanguageMode language_mode) { |
| 1027 Isolate* isolate = it->isolate(); | 1016 Isolate* isolate = it->isolate(); |
| 1028 Handle<Object> structure = it->GetAccessors(); | 1017 Handle<Object> structure = it->GetAccessors(); |
| 1029 Handle<Object> receiver = it->GetReceiver(); | 1018 Handle<Object> receiver = it->GetReceiver(); |
| 1030 | 1019 |
| 1031 // We should never get here to initialize a const with the hole value since a | 1020 // We should never get here to initialize a const with the hole value since a |
| 1032 // const declaration would conflict with the getter. | 1021 // const declaration would conflict with the getter. |
| 1033 DCHECK(!structure->IsForeign()); | 1022 DCHECK(!structure->IsForeign()); |
| 1034 | 1023 |
| (...skipping 3578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4613 } | 4602 } |
| 4614 | 4603 |
| 4615 | 4604 |
| 4616 Handle<Map> JSObject::GetElementsTransitionMap(Handle<JSObject> object, | 4605 Handle<Map> JSObject::GetElementsTransitionMap(Handle<JSObject> object, |
| 4617 ElementsKind to_kind) { | 4606 ElementsKind to_kind) { |
| 4618 Handle<Map> map(object->map()); | 4607 Handle<Map> map(object->map()); |
| 4619 return Map::TransitionElementsTo(map, to_kind); | 4608 return Map::TransitionElementsTo(map, to_kind); |
| 4620 } | 4609 } |
| 4621 | 4610 |
| 4622 | 4611 |
| 4612 Handle<Object> JSProxy::Revoke(Handle<JSProxy> proxy) { | |
| 4613 auto isolate = proxy->GetIsolate(); | |
|
Jakob Kummerow
2015/12/04 09:51:30
nit: I'd prefer s/auto/Isolate*/.
The rule of thu
| |
| 4614 if (!proxy->IsRevoked()) { | |
| 4615 proxy->set_handler(isolate->heap()->null_value()); | |
| 4616 } | |
| 4617 DCHECK(proxy->IsRevoked()); | |
| 4618 return isolate->factory()->undefined_value(); | |
|
Jakob Kummerow
2015/12/04 09:51:30
Is there a reason this method doesn't return void?
| |
| 4619 } | |
| 4620 | |
| 4621 | |
| 4623 Maybe<bool> JSProxy::HasProperty(Isolate* isolate, Handle<JSProxy> proxy, | 4622 Maybe<bool> JSProxy::HasProperty(Isolate* isolate, Handle<JSProxy> proxy, |
| 4624 Handle<Name> name) { | 4623 Handle<Name> name) { |
| 4625 // 1. (Assert) | 4624 // 1. (Assert) |
| 4626 // 2. Let handler be the value of the [[ProxyHandler]] internal slot of O. | 4625 // 2. Let handler be the value of the [[ProxyHandler]] internal slot of O. |
| 4627 Handle<Object> handler(proxy->handler(), isolate); | 4626 Handle<Object> handler(proxy->handler(), isolate); |
| 4628 // 3. If handler is null, throw a TypeError exception. | 4627 // 3. If handler is null, throw a TypeError exception. |
| 4628 // 4. Assert: Type(handler) is Object. | |
| 4629 if (proxy->IsRevoked()) { | 4629 if (proxy->IsRevoked()) { |
| 4630 isolate->Throw(*isolate->factory()->NewTypeError( | 4630 isolate->Throw(*isolate->factory()->NewTypeError( |
| 4631 MessageTemplate::kProxyRevoked, isolate->factory()->has_string())); | 4631 MessageTemplate::kProxyRevoked, isolate->factory()->has_string())); |
| 4632 return Nothing<bool>(); | 4632 return Nothing<bool>(); |
| 4633 } | 4633 } |
| 4634 // 4. Assert: Type(handler) is Object. | |
| 4635 DCHECK(handler->IsJSReceiver()); | |
| 4636 DCHECK(proxy->target()->IsJSReceiver()); | |
| 4637 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. | 4634 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. |
| 4638 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate); | 4635 Handle<JSReceiver> target(proxy->target(), isolate); |
| 4639 // 6. Let trap be ? GetMethod(handler, "has"). | 4636 // 6. Let trap be ? GetMethod(handler, "has"). |
| 4640 Handle<Object> trap; | 4637 Handle<Object> trap; |
| 4641 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 4638 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 4642 isolate, trap, Object::GetMethod(Handle<JSReceiver>::cast(handler), | 4639 isolate, trap, Object::GetMethod(Handle<JSReceiver>::cast(handler), |
| 4643 isolate->factory()->has_string()), | 4640 isolate->factory()->has_string()), |
| 4644 Nothing<bool>()); | 4641 Nothing<bool>()); |
| 4645 // 7. If trap is undefined, then | 4642 // 7. If trap is undefined, then |
| 4646 if (trap->IsUndefined()) { | 4643 if (trap->IsUndefined()) { |
| 4647 // 7a. Return target.[[HasProperty]](P). | 4644 // 7a. Return target.[[HasProperty]](P). |
| 4648 return JSReceiver::HasProperty(target, name); | 4645 return JSReceiver::HasProperty(target, name); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4693 Factory* factory = isolate->factory(); | 4690 Factory* factory = isolate->factory(); |
| 4694 Handle<String> trap_name = factory->set_string(); | 4691 Handle<String> trap_name = factory->set_string(); |
| 4695 ShouldThrow should_throw = | 4692 ShouldThrow should_throw = |
| 4696 is_sloppy(language_mode) ? DONT_THROW : THROW_ON_ERROR; | 4693 is_sloppy(language_mode) ? DONT_THROW : THROW_ON_ERROR; |
| 4697 | 4694 |
| 4698 if (proxy->IsRevoked()) { | 4695 if (proxy->IsRevoked()) { |
| 4699 isolate->Throw( | 4696 isolate->Throw( |
| 4700 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); | 4697 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); |
| 4701 return Nothing<bool>(); | 4698 return Nothing<bool>(); |
| 4702 } | 4699 } |
| 4703 | 4700 Handle<JSReceiver> target(proxy->target(), isolate); |
| 4704 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate); | |
| 4705 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); | 4701 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); |
| 4706 | 4702 |
| 4707 Handle<Object> trap; | 4703 Handle<Object> trap; |
| 4708 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, trap, GetTrap(proxy, trap_name), | 4704 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, trap, GetTrap(proxy, trap_name), |
| 4709 Nothing<bool>()); | 4705 Nothing<bool>()); |
| 4710 if (trap->IsUndefined()) { | 4706 if (trap->IsUndefined()) { |
| 4711 LookupIterator it = | 4707 LookupIterator it = |
| 4712 LookupIterator::PropertyOrElement(isolate, receiver, name, target); | 4708 LookupIterator::PropertyOrElement(isolate, receiver, name, target); |
| 4713 return Object::SetSuperProperty(&it, value, language_mode, | 4709 return Object::SetSuperProperty(&it, value, language_mode, |
| 4714 Object::MAY_BE_STORE_FROM_KEYED); | 4710 Object::MAY_BE_STORE_FROM_KEYED); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4755 is_sloppy(language_mode) ? DONT_THROW : THROW_ON_ERROR; | 4751 is_sloppy(language_mode) ? DONT_THROW : THROW_ON_ERROR; |
| 4756 Isolate* isolate = proxy->GetIsolate(); | 4752 Isolate* isolate = proxy->GetIsolate(); |
| 4757 Factory* factory = isolate->factory(); | 4753 Factory* factory = isolate->factory(); |
| 4758 Handle<String> trap_name = factory->deleteProperty_string(); | 4754 Handle<String> trap_name = factory->deleteProperty_string(); |
| 4759 | 4755 |
| 4760 if (proxy->IsRevoked()) { | 4756 if (proxy->IsRevoked()) { |
| 4761 isolate->Throw( | 4757 isolate->Throw( |
| 4762 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); | 4758 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); |
| 4763 return Nothing<bool>(); | 4759 return Nothing<bool>(); |
| 4764 } | 4760 } |
| 4765 | 4761 Handle<JSReceiver> target(proxy->target(), isolate); |
| 4766 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate); | |
| 4767 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); | 4762 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); |
| 4768 | 4763 |
| 4769 Handle<Object> trap; | 4764 Handle<Object> trap; |
| 4770 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, trap, GetTrap(proxy, trap_name), | 4765 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, trap, GetTrap(proxy, trap_name), |
| 4771 Nothing<bool>()); | 4766 Nothing<bool>()); |
| 4772 if (trap->IsUndefined()) { | 4767 if (trap->IsUndefined()) { |
| 4773 return JSReceiver::DeletePropertyOrElement(target, name, language_mode); | 4768 return JSReceiver::DeletePropertyOrElement(target, name, language_mode); |
| 4774 } | 4769 } |
| 4775 | 4770 |
| 4776 Handle<Object> trap_result; | 4771 Handle<Object> trap_result; |
| (...skipping 2051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6828 // static | 6823 // static |
| 6829 bool JSProxy::DefineOwnProperty(Isolate* isolate, Handle<JSProxy> proxy, | 6824 bool JSProxy::DefineOwnProperty(Isolate* isolate, Handle<JSProxy> proxy, |
| 6830 Handle<Object> key, PropertyDescriptor* desc, | 6825 Handle<Object> key, PropertyDescriptor* desc, |
| 6831 ShouldThrow should_throw) { | 6826 ShouldThrow should_throw) { |
| 6832 Handle<String> trap_name = isolate->factory()->defineProperty_string(); | 6827 Handle<String> trap_name = isolate->factory()->defineProperty_string(); |
| 6833 // 1. Assert: IsPropertyKey(P) is true. | 6828 // 1. Assert: IsPropertyKey(P) is true. |
| 6834 DCHECK(key->IsName() || key->IsNumber()); | 6829 DCHECK(key->IsName() || key->IsNumber()); |
| 6835 // 2. Let handler be the value of the [[ProxyHandler]] internal slot of O. | 6830 // 2. Let handler be the value of the [[ProxyHandler]] internal slot of O. |
| 6836 Handle<Object> handler(proxy->handler(), isolate); | 6831 Handle<Object> handler(proxy->handler(), isolate); |
| 6837 // 3. If handler is null, throw a TypeError exception. | 6832 // 3. If handler is null, throw a TypeError exception. |
| 6833 // 4. Assert: Type(handler) is Object. | |
| 6838 if (proxy->IsRevoked()) { | 6834 if (proxy->IsRevoked()) { |
| 6839 isolate->Throw(*isolate->factory()->NewTypeError( | 6835 isolate->Throw(*isolate->factory()->NewTypeError( |
| 6840 MessageTemplate::kProxyRevoked, trap_name)); | 6836 MessageTemplate::kProxyRevoked, trap_name)); |
| 6841 return false; | 6837 return false; |
| 6842 } | 6838 } |
| 6843 // 4. Assert: Type(handler) is Object. | |
| 6844 DCHECK(handler->IsJSReceiver()); | |
| 6845 // If the handler is not null, the target can't be null either. | |
| 6846 DCHECK(proxy->target()->IsJSReceiver()); | |
| 6847 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. | 6839 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. |
| 6848 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate); | 6840 Handle<JSReceiver> target(proxy->target(), isolate); |
| 6849 // 6. Let trap be ? GetMethod(handler, "defineProperty"). | 6841 // 6. Let trap be ? GetMethod(handler, "defineProperty"). |
| 6850 Handle<Object> trap; | 6842 Handle<Object> trap; |
| 6851 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 6843 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 6852 isolate, trap, | 6844 isolate, trap, |
| 6853 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), false); | 6845 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), false); |
| 6854 // 7. If trap is undefined, then: | 6846 // 7. If trap is undefined, then: |
| 6855 if (trap->IsUndefined()) { | 6847 if (trap->IsUndefined()) { |
| 6856 // 7a. Return target.[[DefineOwnProperty]](P, Desc). | 6848 // 7a. Return target.[[DefineOwnProperty]](P, Desc). |
| 6857 return JSReceiver::DefineOwnProperty(isolate, target, key, desc, | 6849 return JSReceiver::DefineOwnProperty(isolate, target, key, desc, |
| 6858 should_throw); | 6850 should_throw); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7012 // static | 7004 // static |
| 7013 bool JSProxy::GetOwnPropertyDescriptor(Isolate* isolate, Handle<JSProxy> proxy, | 7005 bool JSProxy::GetOwnPropertyDescriptor(Isolate* isolate, Handle<JSProxy> proxy, |
| 7014 Handle<Name> name, | 7006 Handle<Name> name, |
| 7015 PropertyDescriptor* desc) { | 7007 PropertyDescriptor* desc) { |
| 7016 Handle<String> trap_name = | 7008 Handle<String> trap_name = |
| 7017 isolate->factory()->getOwnPropertyDescriptor_string(); | 7009 isolate->factory()->getOwnPropertyDescriptor_string(); |
| 7018 // 1. (Assert) | 7010 // 1. (Assert) |
| 7019 // 2. Let handler be the value of the [[ProxyHandler]] internal slot of O. | 7011 // 2. Let handler be the value of the [[ProxyHandler]] internal slot of O. |
| 7020 Handle<Object> handler(proxy->handler(), isolate); | 7012 Handle<Object> handler(proxy->handler(), isolate); |
| 7021 // 3. If handler is null, throw a TypeError exception. | 7013 // 3. If handler is null, throw a TypeError exception. |
| 7014 // 4. Assert: Type(handler) is Object. | |
| 7022 if (proxy->IsRevoked()) { | 7015 if (proxy->IsRevoked()) { |
| 7023 isolate->Throw(*isolate->factory()->NewTypeError( | 7016 isolate->Throw(*isolate->factory()->NewTypeError( |
| 7024 MessageTemplate::kProxyRevoked, trap_name)); | 7017 MessageTemplate::kProxyRevoked, trap_name)); |
| 7025 return false; | 7018 return false; |
| 7026 } | 7019 } |
| 7027 // 4. Assert: Type(handler) is Object. | |
| 7028 DCHECK(handler->IsJSReceiver()); | |
| 7029 // If the handler is not null, the target can't be null either. | |
| 7030 DCHECK(proxy->target()->IsJSReceiver()); | |
| 7031 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. | 7020 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. |
| 7032 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate); | 7021 Handle<JSReceiver> target(proxy->target(), isolate); |
| 7033 // 6. Let trap be ? GetMethod(handler, "getOwnPropertyDescriptor"). | 7022 // 6. Let trap be ? GetMethod(handler, "getOwnPropertyDescriptor"). |
| 7034 Handle<Object> trap; | 7023 Handle<Object> trap; |
| 7035 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 7024 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 7036 isolate, trap, | 7025 isolate, trap, |
| 7037 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), false); | 7026 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), false); |
| 7038 // 7. If trap is undefined, then | 7027 // 7. If trap is undefined, then |
| 7039 if (trap->IsUndefined()) { | 7028 if (trap->IsUndefined()) { |
| 7040 // 7a. Return target.[[GetOwnProperty]](P). | 7029 // 7a. Return target.[[GetOwnProperty]](P). |
| 7041 return JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, desc); | 7030 return JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, desc); |
| 7042 } | 7031 } |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7270 ShouldThrow should_throw) { | 7259 ShouldThrow should_throw) { |
| 7271 Isolate* isolate = proxy->GetIsolate(); | 7260 Isolate* isolate = proxy->GetIsolate(); |
| 7272 Factory* factory = isolate->factory(); | 7261 Factory* factory = isolate->factory(); |
| 7273 Handle<String> trap_name = factory->preventExtensions_string(); | 7262 Handle<String> trap_name = factory->preventExtensions_string(); |
| 7274 | 7263 |
| 7275 if (proxy->IsRevoked()) { | 7264 if (proxy->IsRevoked()) { |
| 7276 isolate->Throw( | 7265 isolate->Throw( |
| 7277 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); | 7266 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); |
| 7278 return Nothing<bool>(); | 7267 return Nothing<bool>(); |
| 7279 } | 7268 } |
| 7280 | 7269 Handle<JSReceiver> target(proxy->target(), isolate); |
| 7281 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate); | |
| 7282 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); | 7270 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); |
| 7283 | 7271 |
| 7284 Handle<Object> trap; | 7272 Handle<Object> trap; |
| 7285 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, trap, GetTrap(proxy, trap_name), | 7273 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, trap, GetTrap(proxy, trap_name), |
| 7286 Nothing<bool>()); | 7274 Nothing<bool>()); |
| 7287 if (trap->IsUndefined()) { | 7275 if (trap->IsUndefined()) { |
| 7288 return JSReceiver::PreventExtensions(target, should_throw); | 7276 return JSReceiver::PreventExtensions(target, should_throw); |
| 7289 } | 7277 } |
| 7290 | 7278 |
| 7291 Handle<Object> trap_result; | 7279 Handle<Object> trap_result; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7380 Maybe<bool> JSProxy::IsExtensible(Handle<JSProxy> proxy) { | 7368 Maybe<bool> JSProxy::IsExtensible(Handle<JSProxy> proxy) { |
| 7381 Isolate* isolate = proxy->GetIsolate(); | 7369 Isolate* isolate = proxy->GetIsolate(); |
| 7382 Factory* factory = isolate->factory(); | 7370 Factory* factory = isolate->factory(); |
| 7383 Handle<String> trap_name = factory->isExtensible_string(); | 7371 Handle<String> trap_name = factory->isExtensible_string(); |
| 7384 | 7372 |
| 7385 if (proxy->IsRevoked()) { | 7373 if (proxy->IsRevoked()) { |
| 7386 isolate->Throw( | 7374 isolate->Throw( |
| 7387 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); | 7375 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); |
| 7388 return Nothing<bool>(); | 7376 return Nothing<bool>(); |
| 7389 } | 7377 } |
| 7390 | 7378 Handle<JSReceiver> target(proxy->target(), isolate); |
| 7391 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate); | |
| 7392 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); | 7379 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); |
| 7393 | 7380 |
| 7394 Handle<Object> trap; | 7381 Handle<Object> trap; |
| 7395 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, trap, GetTrap(proxy, trap_name), | 7382 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, trap, GetTrap(proxy, trap_name), |
| 7396 Nothing<bool>()); | 7383 Nothing<bool>()); |
| 7397 if (trap->IsUndefined()) { | 7384 if (trap->IsUndefined()) { |
| 7398 return JSReceiver::IsExtensible(target); | 7385 return JSReceiver::IsExtensible(target); |
| 7399 } | 7386 } |
| 7400 | 7387 |
| 7401 Handle<Object> trap_result; | 7388 Handle<Object> trap_result; |
| (...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8289 | 8276 |
| 8290 | 8277 |
| 8291 // ES6 9.5.11 | 8278 // ES6 9.5.11 |
| 8292 // Returns false in case of exception. | 8279 // Returns false in case of exception. |
| 8293 // static | 8280 // static |
| 8294 bool JSProxy::Enumerate(Isolate* isolate, Handle<JSReceiver> receiver, | 8281 bool JSProxy::Enumerate(Isolate* isolate, Handle<JSReceiver> receiver, |
| 8295 Handle<JSProxy> proxy, KeyAccumulator* accumulator) { | 8282 Handle<JSProxy> proxy, KeyAccumulator* accumulator) { |
| 8296 // 1. Let handler be the value of the [[ProxyHandler]] internal slot of O. | 8283 // 1. Let handler be the value of the [[ProxyHandler]] internal slot of O. |
| 8297 Handle<Object> handler(proxy->handler(), isolate); | 8284 Handle<Object> handler(proxy->handler(), isolate); |
| 8298 // 2. If handler is null, throw a TypeError exception. | 8285 // 2. If handler is null, throw a TypeError exception. |
| 8286 // 3. Assert: Type(handler) is Object. | |
| 8299 if (proxy->IsRevoked()) { | 8287 if (proxy->IsRevoked()) { |
| 8300 isolate->Throw(*isolate->factory()->NewTypeError( | 8288 isolate->Throw(*isolate->factory()->NewTypeError( |
| 8301 MessageTemplate::kProxyRevoked, | 8289 MessageTemplate::kProxyRevoked, |
| 8302 isolate->factory()->enumerate_string())); | 8290 isolate->factory()->enumerate_string())); |
| 8303 return false; | 8291 return false; |
| 8304 } | 8292 } |
| 8305 // 3. Assert: Type(handler) is Object. | |
| 8306 DCHECK(handler->IsJSReceiver()); | |
| 8307 // 4. Let target be the value of the [[ProxyTarget]] internal slot of O. | 8293 // 4. Let target be the value of the [[ProxyTarget]] internal slot of O. |
| 8308 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate); | 8294 Handle<JSReceiver> target(proxy->target(), isolate); |
| 8309 // 5. Let trap be ? GetMethod(handler, "enumerate"). | 8295 // 5. Let trap be ? GetMethod(handler, "enumerate"). |
| 8310 Handle<Object> trap; | 8296 Handle<Object> trap; |
| 8311 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 8297 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 8312 isolate, trap, Object::GetMethod(Handle<JSReceiver>::cast(handler), | 8298 isolate, trap, Object::GetMethod(Handle<JSReceiver>::cast(handler), |
| 8313 isolate->factory()->enumerate_string()), | 8299 isolate->factory()->enumerate_string()), |
| 8314 false); | 8300 false); |
| 8315 // 6. If trap is undefined, then | 8301 // 6. If trap is undefined, then |
| 8316 if (trap->IsUndefined()) { | 8302 if (trap->IsUndefined()) { |
| 8317 // 6a. Return target.[[Enumerate]](). | 8303 // 6a. Return target.[[Enumerate]](). |
| 8318 return GetKeys_Internal(isolate, receiver, target, INCLUDE_PROTOS, | 8304 return GetKeys_Internal(isolate, receiver, target, INCLUDE_PROTOS, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8395 | 8381 |
| 8396 // ES6 9.5.12 | 8382 // ES6 9.5.12 |
| 8397 // Returns "false" in case of exception. | 8383 // Returns "false" in case of exception. |
| 8398 // static | 8384 // static |
| 8399 bool JSProxy::OwnPropertyKeys(Isolate* isolate, Handle<JSReceiver> receiver, | 8385 bool JSProxy::OwnPropertyKeys(Isolate* isolate, Handle<JSReceiver> receiver, |
| 8400 Handle<JSProxy> proxy, PropertyFilter filter, | 8386 Handle<JSProxy> proxy, PropertyFilter filter, |
| 8401 KeyAccumulator* accumulator) { | 8387 KeyAccumulator* accumulator) { |
| 8402 // 1. Let handler be the value of the [[ProxyHandler]] internal slot of O. | 8388 // 1. Let handler be the value of the [[ProxyHandler]] internal slot of O. |
| 8403 Handle<Object> handler(proxy->handler(), isolate); | 8389 Handle<Object> handler(proxy->handler(), isolate); |
| 8404 // 2. If handler is null, throw a TypeError exception. | 8390 // 2. If handler is null, throw a TypeError exception. |
| 8391 // 3. Assert: Type(handler) is Object. | |
| 8405 if (proxy->IsRevoked()) { | 8392 if (proxy->IsRevoked()) { |
| 8406 isolate->Throw(*isolate->factory()->NewTypeError( | 8393 isolate->Throw(*isolate->factory()->NewTypeError( |
| 8407 MessageTemplate::kProxyRevoked, isolate->factory()->ownKeys_string())); | 8394 MessageTemplate::kProxyRevoked, isolate->factory()->ownKeys_string())); |
| 8408 return false; | 8395 return false; |
| 8409 } | 8396 } |
| 8410 // 3. Assert: Type(handler) is Object. | |
| 8411 DCHECK(handler->IsJSReceiver()); | |
| 8412 // 4. Let target be the value of the [[ProxyTarget]] internal slot of O. | 8397 // 4. Let target be the value of the [[ProxyTarget]] internal slot of O. |
| 8413 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate); | 8398 Handle<JSReceiver> target(proxy->target(), isolate); |
| 8414 // 5. Let trap be ? GetMethod(handler, "ownKeys"). | 8399 // 5. Let trap be ? GetMethod(handler, "ownKeys"). |
| 8415 Handle<Object> trap; | 8400 Handle<Object> trap; |
| 8416 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 8401 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 8417 isolate, trap, Object::GetMethod(Handle<JSReceiver>::cast(handler), | 8402 isolate, trap, Object::GetMethod(Handle<JSReceiver>::cast(handler), |
| 8418 isolate->factory()->ownKeys_string()), | 8403 isolate->factory()->ownKeys_string()), |
| 8419 false); | 8404 false); |
| 8420 // 6. If trap is undefined, then | 8405 // 6. If trap is undefined, then |
| 8421 if (trap->IsUndefined()) { | 8406 if (trap->IsUndefined()) { |
| 8422 // 6a. Return target.[[OwnPropertyKeys]](). | 8407 // 6a. Return target.[[OwnPropertyKeys]](). |
| 8423 return GetKeys_Internal(isolate, receiver, target, OWN_ONLY, filter, | 8408 return GetKeys_Internal(isolate, receiver, target, OWN_ONLY, filter, |
| (...skipping 6460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 14884 from_javascript, should_throw); | 14869 from_javascript, should_throw); |
| 14885 } | 14870 } |
| 14886 | 14871 |
| 14887 | 14872 |
| 14888 // ES6: 9.5.2 [[SetPrototypeOf]] (V) | 14873 // ES6: 9.5.2 [[SetPrototypeOf]] (V) |
| 14889 // static | 14874 // static |
| 14890 Maybe<bool> JSProxy::SetPrototype(Handle<JSProxy> proxy, Handle<Object> value, | 14875 Maybe<bool> JSProxy::SetPrototype(Handle<JSProxy> proxy, Handle<Object> value, |
| 14891 bool from_javascript, | 14876 bool from_javascript, |
| 14892 ShouldThrow should_throw) { | 14877 ShouldThrow should_throw) { |
| 14893 Isolate* isolate = proxy->GetIsolate(); | 14878 Isolate* isolate = proxy->GetIsolate(); |
| 14894 Handle<JSReceiver> handle; | |
| 14895 Handle<Name> trap_name = isolate->factory()->setPrototypeOf_string(); | 14879 Handle<Name> trap_name = isolate->factory()->setPrototypeOf_string(); |
| 14896 // 1. Assert: Either Type(V) is Object or Type(V) is Null. | 14880 // 1. Assert: Either Type(V) is Object or Type(V) is Null. |
| 14897 DCHECK(value->IsJSReceiver() || value->IsNull()); | 14881 DCHECK(value->IsJSReceiver() || value->IsNull()); |
| 14898 // 2. Let handler be the value of the [[ProxyHandler]] internal slot of O. | 14882 // 2. Let handler be the value of the [[ProxyHandler]] internal slot of O. |
| 14899 Handle<Object> raw_handler(proxy->handler(), isolate); | 14883 Handle<Object> handler(proxy->handler(), isolate); |
| 14900 // 3. If handler is null, throw a TypeError exception. | 14884 // 3. If handler is null, throw a TypeError exception. |
| 14901 // 4. Assert: Type(handler) is Object. | 14885 // 4. Assert: Type(handler) is Object. |
| 14902 if (proxy->IsRevoked()) { | 14886 if (proxy->IsRevoked()) { |
| 14903 DCHECK(raw_handler->IsNull()); | 14887 isolate->Throw(*isolate->factory()->NewTypeError( |
| 14904 DCHECK(proxy->target()->IsNull()); | 14888 MessageTemplate::kProxyRevoked, trap_name)); |
| 14905 isolate->Throw( | |
| 14906 *isolate->factory()->NewTypeError(MessageTemplate::kProxyRevoked)); | |
| 14907 return Nothing<bool>(); | 14889 return Nothing<bool>(); |
| 14908 } | 14890 } |
| 14909 Handle<JSReceiver> handler = Handle<JSReceiver>::cast(raw_handler); | |
| 14910 // 5. Let target be the value of the [[ProxyTarget]] internal slot. | 14891 // 5. Let target be the value of the [[ProxyTarget]] internal slot. |
| 14911 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate); | 14892 Handle<JSReceiver> target(proxy->target(), isolate); |
| 14912 // 6. Let trap be ? GetMethod(handler, "getPrototypeOf"). | 14893 // 6. Let trap be ? GetMethod(handler, "getPrototypeOf"). |
| 14913 Handle<Object> trap; | 14894 Handle<Object> trap; |
| 14914 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 14895 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 14915 isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>()); | 14896 isolate, trap, |
| 14897 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), | |
| 14898 Nothing<bool>()); | |
| 14916 // 7. If trap is undefined, then return target.[[SetPrototypeOf]](). | 14899 // 7. If trap is undefined, then return target.[[SetPrototypeOf]](). |
| 14917 if (trap->IsUndefined()) { | 14900 if (trap->IsUndefined()) { |
| 14918 return JSReceiver::SetPrototype(target, value, from_javascript, | 14901 return JSReceiver::SetPrototype(target, value, from_javascript, |
| 14919 should_throw); | 14902 should_throw); |
| 14920 } | 14903 } |
| 14921 // 8. Let booleanTrapResult be ToBoolean(? Call(trap, handler, «target, V»)). | 14904 // 8. Let booleanTrapResult be ToBoolean(? Call(trap, handler, «target, V»)). |
| 14922 Handle<Object> argv[] = {target, value}; | 14905 Handle<Object> argv[] = {target, value}; |
| 14923 Handle<Object> trap_result; | 14906 Handle<Object> trap_result; |
| 14924 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 14907 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 14925 isolate, trap_result, | 14908 isolate, trap_result, |
| (...skipping 4203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 19129 if (cell->value() != *new_value) { | 19112 if (cell->value() != *new_value) { |
| 19130 cell->set_value(*new_value); | 19113 cell->set_value(*new_value); |
| 19131 Isolate* isolate = cell->GetIsolate(); | 19114 Isolate* isolate = cell->GetIsolate(); |
| 19132 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19115 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 19133 isolate, DependentCode::kPropertyCellChangedGroup); | 19116 isolate, DependentCode::kPropertyCellChangedGroup); |
| 19134 } | 19117 } |
| 19135 } | 19118 } |
| 19136 | 19119 |
| 19137 } // namespace internal | 19120 } // namespace internal |
| 19138 } // namespace v8 | 19121 } // namespace v8 |
| OLD | NEW |