Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: src/objects.cc

Issue 1486553002: [proxies] Use IsRevoked where possible, remove has_handler. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 THROW_NEW_ERROR(isolate, 903 THROW_NEW_ERROR(isolate,
904 NewTypeError(MessageTemplate::kProxyHandlerTrapMissing, 904 NewTypeError(MessageTemplate::kProxyHandlerTrapMissing,
905 handler, trap_name), 905 handler, trap_name),
906 Object); 906 Object);
907 } 907 }
908 // 13. Return handlerProto. 908 // 13. Return handlerProto.
909 return handler_proto; 909 return handler_proto;
910 } 910 }
911 911
912 912
913 bool JSProxy::IsRevoked(Handle<JSProxy> proxy) { 913 bool JSProxy::IsRevoked() {
914 // TODO(neis): Decide on how to represent revocation. For now, revocation is 914 // TODO(neis): Decide on how to represent revocation. For now, revocation is
915 // unsupported. 915 // unsupported.
916 DCHECK(proxy->target()->IsJSReceiver()); 916 DCHECK(target()->IsJSReceiver());
917 DCHECK(proxy->handler()->IsJSReceiver()); 917 DCHECK(handler()->IsJSReceiver());
918 return false; 918 return false;
919 } 919 }
920 920
921 921
922 MaybeHandle<Object> JSProxy::GetPropertyWithHandler(Handle<JSProxy> proxy, 922 MaybeHandle<Object> JSProxy::GetPropertyWithHandler(Handle<JSProxy> proxy,
923 Handle<Object> receiver, 923 Handle<Object> receiver,
924 Handle<Name> name) { 924 Handle<Name> name) {
925 Isolate* isolate = proxy->GetIsolate(); 925 Isolate* isolate = proxy->GetIsolate();
926 926
927 // TODO(rossberg): adjust once there is a story for symbols vs proxies. 927 // TODO(rossberg): adjust once there is a story for symbols vs proxies.
(...skipping 3594 matching lines...) Expand 10 before | Expand all | Expand 10 after
4522 return Map::TransitionElementsTo(map, to_kind); 4522 return Map::TransitionElementsTo(map, to_kind);
4523 } 4523 }
4524 4524
4525 4525
4526 Maybe<bool> JSProxy::HasProperty(Isolate* isolate, Handle<JSProxy> proxy, 4526 Maybe<bool> JSProxy::HasProperty(Isolate* isolate, Handle<JSProxy> proxy,
4527 Handle<Name> name) { 4527 Handle<Name> name) {
4528 // 1. (Assert) 4528 // 1. (Assert)
4529 // 2. Let handler be the value of the [[ProxyHandler]] internal slot of O. 4529 // 2. Let handler be the value of the [[ProxyHandler]] internal slot of O.
4530 Handle<Object> handler(proxy->handler(), isolate); 4530 Handle<Object> handler(proxy->handler(), isolate);
4531 // 3. If handler is null, throw a TypeError exception. 4531 // 3. If handler is null, throw a TypeError exception.
4532 if (JSProxy::IsRevoked(proxy)) { 4532 if (proxy->IsRevoked()) {
4533 isolate->Throw(*isolate->factory()->NewTypeError( 4533 isolate->Throw(*isolate->factory()->NewTypeError(
4534 MessageTemplate::kProxyRevoked, isolate->factory()->has_string())); 4534 MessageTemplate::kProxyRevoked, isolate->factory()->has_string()));
4535 return Nothing<bool>(); 4535 return Nothing<bool>();
4536 } 4536 }
4537 // 4. Assert: Type(handler) is Object. 4537 // 4. Assert: Type(handler) is Object.
4538 DCHECK(handler->IsJSReceiver()); 4538 DCHECK(handler->IsJSReceiver());
4539 DCHECK(proxy->target()->IsJSReceiver()); 4539 DCHECK(proxy->target()->IsJSReceiver());
4540 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. 4540 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O.
4541 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate); 4541 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate);
4542 // 6. Let trap be ? GetMethod(handler, "has"). 4542 // 6. Let trap be ? GetMethod(handler, "has").
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
4698 4698
4699 Maybe<bool> JSProxy::DeletePropertyOrElement(Handle<JSProxy> proxy, 4699 Maybe<bool> JSProxy::DeletePropertyOrElement(Handle<JSProxy> proxy,
4700 Handle<Name> name, 4700 Handle<Name> name,
4701 LanguageMode language_mode) { 4701 LanguageMode language_mode) {
4702 ShouldThrow should_throw = 4702 ShouldThrow should_throw =
4703 is_sloppy(language_mode) ? DONT_THROW : THROW_ON_ERROR; 4703 is_sloppy(language_mode) ? DONT_THROW : THROW_ON_ERROR;
4704 Isolate* isolate = proxy->GetIsolate(); 4704 Isolate* isolate = proxy->GetIsolate();
4705 Factory* factory = isolate->factory(); 4705 Factory* factory = isolate->factory();
4706 Handle<String> trap_name = factory->deleteProperty_string(); 4706 Handle<String> trap_name = factory->deleteProperty_string();
4707 4707
4708 if (IsRevoked(proxy)) { 4708 if (proxy->IsRevoked()) {
4709 isolate->Throw( 4709 isolate->Throw(
4710 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); 4710 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name));
4711 return Nothing<bool>(); 4711 return Nothing<bool>();
4712 } 4712 }
4713 4713
4714 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate); 4714 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate);
4715 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); 4715 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate);
4716 4716
4717 Handle<Object> trap; 4717 Handle<Object> trap;
4718 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, trap, GetTrap(proxy, trap_name), 4718 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, trap, GetTrap(proxy, trap_name),
(...skipping 24 matching lines...) Expand all
4743 MessageTemplate::kProxyDeletePropertyViolatesInvariant, name)); 4743 MessageTemplate::kProxyDeletePropertyViolatesInvariant, name));
4744 return Nothing<bool>(); 4744 return Nothing<bool>();
4745 } 4745 }
4746 return Just(true); 4746 return Just(true);
4747 } 4747 }
4748 4748
4749 4749
4750 // static 4750 // static
4751 MaybeHandle<Context> JSProxy::GetFunctionRealm(Handle<JSProxy> proxy) { 4751 MaybeHandle<Context> JSProxy::GetFunctionRealm(Handle<JSProxy> proxy) {
4752 DCHECK(proxy->map()->is_constructor()); 4752 DCHECK(proxy->map()->is_constructor());
4753 if (JSProxy::IsRevoked(proxy)) { 4753 if (proxy->IsRevoked()) {
4754 THROW_NEW_ERROR(proxy->GetIsolate(), 4754 THROW_NEW_ERROR(proxy->GetIsolate(),
4755 NewTypeError(MessageTemplate::kProxyRevoked), Context); 4755 NewTypeError(MessageTemplate::kProxyRevoked), Context);
4756 } 4756 }
4757 4757
4758 // TODO(verwaest): Get rid of JSFunctionProxies. 4758 // TODO(verwaest): Get rid of JSFunctionProxies.
4759 Object* target = proxy->IsJSFunctionProxy() 4759 Object* target = proxy->IsJSFunctionProxy()
4760 ? JSFunctionProxy::cast(*proxy)->construct_trap() 4760 ? JSFunctionProxy::cast(*proxy)->construct_trap()
4761 : proxy->target(); 4761 : proxy->target();
4762 return JSReceiver::GetFunctionRealm(handle(JSReceiver::cast(target))); 4762 return JSReceiver::GetFunctionRealm(handle(JSReceiver::cast(target)));
4763 } 4763 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
4798 PropertyDescriptor desc; 4798 PropertyDescriptor desc;
4799 bool found = JSProxy::GetOwnPropertyDescriptor(it, &desc); 4799 bool found = JSProxy::GetOwnPropertyDescriptor(it, &desc);
4800 if (isolate->has_pending_exception()) return Nothing<PropertyAttributes>(); 4800 if (isolate->has_pending_exception()) return Nothing<PropertyAttributes>();
4801 if (!found) return Just(ABSENT); 4801 if (!found) return Just(ABSENT);
4802 return Just(desc.ToAttributes()); 4802 return Just(desc.ToAttributes());
4803 } 4803 }
4804 4804
4805 4805
4806 MaybeHandle<Object> JSProxy::GetTrap(Handle<JSProxy> proxy, 4806 MaybeHandle<Object> JSProxy::GetTrap(Handle<JSProxy> proxy,
4807 Handle<String> trap) { 4807 Handle<String> trap) {
4808 DCHECK(!IsRevoked(proxy)); 4808 DCHECK(!proxy->IsRevoked());
4809 Isolate* isolate = proxy->GetIsolate(); 4809 Isolate* isolate = proxy->GetIsolate();
4810 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); 4810 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate);
4811 return Object::GetMethod(handler, trap); 4811 return Object::GetMethod(handler, trap);
4812 } 4812 }
4813 4813
4814 4814
4815 MaybeHandle<Object> JSProxy::CallTrap(Handle<JSProxy> proxy, 4815 MaybeHandle<Object> JSProxy::CallTrap(Handle<JSProxy> proxy,
4816 const char* name, 4816 const char* name,
4817 Handle<Object> derived, 4817 Handle<Object> derived,
4818 int argc, 4818 int argc,
(...skipping 1955 matching lines...) Expand 10 before | Expand all | Expand 10 after
6774 isolate->Throw(*isolate->factory()->NewTypeError( 6774 isolate->Throw(*isolate->factory()->NewTypeError(
6775 MessageTemplate::kStrictDeleteProperty, 6775 MessageTemplate::kStrictDeleteProperty,
6776 isolate->factory()->NewNumberFromUint(actual_new_len - 1), a)); 6776 isolate->factory()->NewNumberFromUint(actual_new_len - 1), a));
6777 } 6777 }
6778 return success; 6778 return success;
6779 } 6779 }
6780 6780
6781 6781
6782 // ES6 9.5.6 6782 // ES6 9.5.6
6783 // static 6783 // static
6784 bool JSProxy::DefineOwnProperty(Isolate* isolate, Handle<JSProxy> object, 6784 bool JSProxy::DefineOwnProperty(Isolate* isolate, Handle<JSProxy> proxy,
6785 Handle<Object> key, PropertyDescriptor* desc, 6785 Handle<Object> key, PropertyDescriptor* desc,
6786 ShouldThrow should_throw) { 6786 ShouldThrow should_throw) {
6787 Handle<String> trap_name = isolate->factory()->defineProperty_string();
6787 // 1. Assert: IsPropertyKey(P) is true. 6788 // 1. Assert: IsPropertyKey(P) is true.
6788 DCHECK(key->IsName() || key->IsNumber()); 6789 DCHECK(key->IsName() || key->IsNumber());
6789 // 2. Let handler be the value of the [[ProxyHandler]] internal slot of O. 6790 // 2. Let handler be the value of the [[ProxyHandler]] internal slot of O.
6790 Handle<Object> handler(object->handler(), isolate); 6791 Handle<Object> handler(proxy->handler(), isolate);
6791 // 3. If handler is null, throw a TypeError exception. 6792 // 3. If handler is null, throw a TypeError exception.
6792 // TODO(jkummerow): Use "IsRevoked()" instead once we have it. 6793 if (proxy->IsRevoked()) {
6793 if (handler->IsNull()) {
6794 isolate->Throw(*isolate->factory()->NewTypeError( 6794 isolate->Throw(*isolate->factory()->NewTypeError(
6795 MessageTemplate::kProxyHandlerNonObject)); 6795 MessageTemplate::kProxyRevoked, trap_name));
6796 return false; 6796 return false;
6797 } 6797 }
6798 // 4. Assert: Type(handler) is Object. 6798 // 4. Assert: Type(handler) is Object.
6799 DCHECK(handler->IsJSReceiver()); 6799 DCHECK(handler->IsJSReceiver());
6800 // If the handler is not null, the target can't be null either. 6800 // If the handler is not null, the target can't be null either.
6801 DCHECK(object->target()->IsSpecObject()); 6801 DCHECK(proxy->target()->IsSpecObject());
6802 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. 6802 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O.
6803 Handle<JSReceiver> target(JSReceiver::cast(object->target()), isolate); 6803 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate);
6804 // 6. Let trap be ? GetMethod(handler, "defineProperty"). 6804 // 6. Let trap be ? GetMethod(handler, "defineProperty").
6805 Handle<Object> trap; 6805 Handle<Object> trap;
6806 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 6806 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
6807 isolate, trap, 6807 isolate, trap,
6808 Object::GetMethod(Handle<JSReceiver>::cast(handler), 6808 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), false);
6809 isolate->factory()->defineProperty_string()),
6810 false);
6811 // 7. If trap is undefined, then: 6809 // 7. If trap is undefined, then:
6812 if (trap->IsUndefined()) { 6810 if (trap->IsUndefined()) {
6813 // 7a. Return target.[[DefineOwnProperty]](P, Desc). 6811 // 7a. Return target.[[DefineOwnProperty]](P, Desc).
6814 return JSReceiver::DefineOwnProperty(isolate, target, key, desc, 6812 return JSReceiver::DefineOwnProperty(isolate, target, key, desc,
6815 should_throw); 6813 should_throw);
6816 } 6814 }
6817 // 8. Let descObj be FromPropertyDescriptor(Desc). 6815 // 8. Let descObj be FromPropertyDescriptor(Desc).
6818 Handle<Object> desc_obj = desc->ToObject(isolate); 6816 Handle<Object> desc_obj = desc->ToObject(isolate);
6819 // 9. Let booleanTrapResult be 6817 // 9. Let booleanTrapResult be
6820 // ToBoolean(? Call(trap, handler, «target, P, descObj»)). 6818 // ToBoolean(? Call(trap, handler, «target, P, descObj»)).
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
6961 DCHECK(PropertyDescriptor::IsAccessorDescriptor(desc) != 6959 DCHECK(PropertyDescriptor::IsAccessorDescriptor(desc) !=
6962 PropertyDescriptor::IsDataDescriptor(desc)); 6960 PropertyDescriptor::IsDataDescriptor(desc));
6963 return true; 6961 return true;
6964 } 6962 }
6965 6963
6966 6964
6967 // ES6 9.5.5 6965 // ES6 9.5.5
6968 // static 6966 // static
6969 bool JSProxy::GetOwnPropertyDescriptor(LookupIterator* it, 6967 bool JSProxy::GetOwnPropertyDescriptor(LookupIterator* it,
6970 PropertyDescriptor* desc) { 6968 PropertyDescriptor* desc) {
6971 DCHECK(it->GetHolder<Object>()->IsJSProxy()); 6969 Handle<JSProxy> proxy = it->GetHolder<JSProxy>();
6972 Isolate* isolate = it->isolate(); 6970 Isolate* isolate = it->isolate();
6971 Handle<String> trap_name =
6972 isolate->factory()->getOwnPropertyDescriptor_string();
6973 Handle<Name> property_name = it->GetName(); 6973 Handle<Name> property_name = it->GetName();
6974 // 1. (Assert) 6974 // 1. (Assert)
6975 // 2. Let handler be the value of the [[ProxyHandler]] internal slot of O. 6975 // 2. Let handler be the value of the [[ProxyHandler]] internal slot of O.
6976 Handle<Object> handler(it->GetHolder<JSProxy>()->handler(), isolate); 6976 Handle<Object> handler(proxy->handler(), isolate);
6977 // 3. If handler is null, throw a TypeError exception. 6977 // 3. If handler is null, throw a TypeError exception.
6978 if (handler->IsNull()) { 6978 if (proxy->IsRevoked()) {
6979 isolate->Throw(*isolate->factory()->NewTypeError( 6979 isolate->Throw(*isolate->factory()->NewTypeError(
6980 MessageTemplate::kProxyHandlerNonObject)); 6980 MessageTemplate::kProxyRevoked, trap_name));
6981 return false; 6981 return false;
6982 } 6982 }
6983 // 4. Assert: Type(handler) is Object. 6983 // 4. Assert: Type(handler) is Object.
6984 DCHECK(handler->IsSpecObject()); 6984 DCHECK(handler->IsSpecObject());
6985 // If the handler is not null, the target can't be null either. 6985 // If the handler is not null, the target can't be null either.
6986 DCHECK(it->GetHolder<JSProxy>()->target()->IsSpecObject()); 6986 DCHECK(it->GetHolder<JSProxy>()->target()->IsSpecObject());
6987 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O. 6987 // 5. Let target be the value of the [[ProxyTarget]] internal slot of O.
6988 Handle<JSReceiver> target( 6988 Handle<JSReceiver> target(
6989 JSReceiver::cast(it->GetHolder<JSProxy>()->target()), isolate); 6989 JSReceiver::cast(it->GetHolder<JSProxy>()->target()), isolate);
6990 // 6. Let trap be ? GetMethod(handler, "getOwnPropertyDescriptor"). 6990 // 6. Let trap be ? GetMethod(handler, "getOwnPropertyDescriptor").
6991 Handle<Object> trap; 6991 Handle<Object> trap;
6992 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 6992 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
6993 isolate, trap, 6993 isolate, trap,
6994 Object::GetMethod(Handle<JSReceiver>::cast(handler), 6994 Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), false);
6995 isolate->factory()->getOwnPropertyDescriptor_string()),
6996 false);
6997 // 7. If trap is undefined, then 6995 // 7. If trap is undefined, then
6998 if (trap->IsUndefined()) { 6996 if (trap->IsUndefined()) {
6999 // 7a. Return target.[[GetOwnProperty]](P). 6997 // 7a. Return target.[[GetOwnProperty]](P).
7000 return JSReceiver::GetOwnPropertyDescriptor(isolate, target, property_name, 6998 return JSReceiver::GetOwnPropertyDescriptor(isolate, target, property_name,
7001 desc); 6999 desc);
7002 } 7000 }
7003 // 8. Let trapResultObj be ? Call(trap, handler, «target, P»). 7001 // 8. Let trapResultObj be ? Call(trap, handler, «target, P»).
7004 Handle<Object> trap_result_obj; 7002 Handle<Object> trap_result_obj;
7005 Handle<Object> args[] = {target, property_name}; 7003 Handle<Object> args[] = {target, property_name};
7006 ASSIGN_RETURN_ON_EXCEPTION_VALUE( 7004 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
7226 should_throw); 7224 should_throw);
7227 } 7225 }
7228 7226
7229 7227
7230 Maybe<bool> JSProxy::PreventExtensions(Handle<JSProxy> proxy, 7228 Maybe<bool> JSProxy::PreventExtensions(Handle<JSProxy> proxy,
7231 ShouldThrow should_throw) { 7229 ShouldThrow should_throw) {
7232 Isolate* isolate = proxy->GetIsolate(); 7230 Isolate* isolate = proxy->GetIsolate();
7233 Factory* factory = isolate->factory(); 7231 Factory* factory = isolate->factory();
7234 Handle<String> trap_name = factory->preventExtensions_string(); 7232 Handle<String> trap_name = factory->preventExtensions_string();
7235 7233
7236 if (IsRevoked(proxy)) { 7234 if (proxy->IsRevoked()) {
7237 isolate->Throw( 7235 isolate->Throw(
7238 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); 7236 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name));
7239 return Nothing<bool>(); 7237 return Nothing<bool>();
7240 } 7238 }
7241 7239
7242 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate); 7240 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate);
7243 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); 7241 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate);
7244 7242
7245 Handle<Object> trap; 7243 Handle<Object> trap;
7246 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, trap, GetTrap(proxy, trap_name), 7244 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, trap, GetTrap(proxy, trap_name),
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
7336 } 7334 }
7337 return Just(JSObject::IsExtensible(Handle<JSObject>::cast(object))); 7335 return Just(JSObject::IsExtensible(Handle<JSObject>::cast(object)));
7338 } 7336 }
7339 7337
7340 7338
7341 Maybe<bool> JSProxy::IsExtensible(Handle<JSProxy> proxy) { 7339 Maybe<bool> JSProxy::IsExtensible(Handle<JSProxy> proxy) {
7342 Isolate* isolate = proxy->GetIsolate(); 7340 Isolate* isolate = proxy->GetIsolate();
7343 Factory* factory = isolate->factory(); 7341 Factory* factory = isolate->factory();
7344 Handle<String> trap_name = factory->isExtensible_string(); 7342 Handle<String> trap_name = factory->isExtensible_string();
7345 7343
7346 if (IsRevoked(proxy)) { 7344 if (proxy->IsRevoked()) {
7347 isolate->Throw( 7345 isolate->Throw(
7348 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name)); 7346 *factory->NewTypeError(MessageTemplate::kProxyRevoked, trap_name));
7349 return Nothing<bool>(); 7347 return Nothing<bool>();
7350 } 7348 }
7351 7349
7352 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate); 7350 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate);
7353 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate); 7351 Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate);
7354 7352
7355 Handle<Object> trap; 7353 Handle<Object> trap;
7356 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, trap, GetTrap(proxy, trap_name), 7354 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, trap, GetTrap(proxy, trap_name),
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
8201 8199
8202 8200
8203 // ES6 9.5.11 8201 // ES6 9.5.11
8204 // Returns false in case of exception. 8202 // Returns false in case of exception.
8205 // static 8203 // static
8206 bool JSProxy::Enumerate(Isolate* isolate, Handle<JSReceiver> receiver, 8204 bool JSProxy::Enumerate(Isolate* isolate, Handle<JSReceiver> receiver,
8207 Handle<JSProxy> proxy, KeyAccumulator* accumulator) { 8205 Handle<JSProxy> proxy, KeyAccumulator* accumulator) {
8208 // 1. Let handler be the value of the [[ProxyHandler]] internal slot of O. 8206 // 1. Let handler be the value of the [[ProxyHandler]] internal slot of O.
8209 Handle<Object> handler(proxy->handler(), isolate); 8207 Handle<Object> handler(proxy->handler(), isolate);
8210 // 2. If handler is null, throw a TypeError exception. 8208 // 2. If handler is null, throw a TypeError exception.
8211 if (IsRevoked(proxy)) { 8209 if (proxy->IsRevoked()) {
8212 isolate->Throw(*isolate->factory()->NewTypeError( 8210 isolate->Throw(*isolate->factory()->NewTypeError(
8213 MessageTemplate::kProxyRevoked, 8211 MessageTemplate::kProxyRevoked,
8214 isolate->factory()->enumerate_string())); 8212 isolate->factory()->enumerate_string()));
8215 return false; 8213 return false;
8216 } 8214 }
8217 // 3. Assert: Type(handler) is Object. 8215 // 3. Assert: Type(handler) is Object.
8218 DCHECK(handler->IsJSReceiver()); 8216 DCHECK(handler->IsJSReceiver());
8219 // 4. Let target be the value of the [[ProxyTarget]] internal slot of O. 8217 // 4. Let target be the value of the [[ProxyTarget]] internal slot of O.
8220 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate); 8218 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate);
8221 // 5. Let trap be ? GetMethod(handler, "enumerate"). 8219 // 5. Let trap be ? GetMethod(handler, "enumerate").
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
8309 // Returns "false" in case of exception. 8307 // Returns "false" in case of exception.
8310 // TODO(jkummerow): |filter| and |enum_policy| are currently ignored. 8308 // TODO(jkummerow): |filter| and |enum_policy| are currently ignored.
8311 // static 8309 // static
8312 bool JSProxy::OwnPropertyKeys(Isolate* isolate, Handle<JSReceiver> receiver, 8310 bool JSProxy::OwnPropertyKeys(Isolate* isolate, Handle<JSReceiver> receiver,
8313 Handle<JSProxy> proxy, KeyFilter filter, 8311 Handle<JSProxy> proxy, KeyFilter filter,
8314 Enumerability enum_policy, 8312 Enumerability enum_policy,
8315 KeyAccumulator* accumulator) { 8313 KeyAccumulator* accumulator) {
8316 // 1. Let handler be the value of the [[ProxyHandler]] internal slot of O. 8314 // 1. Let handler be the value of the [[ProxyHandler]] internal slot of O.
8317 Handle<Object> handler(proxy->handler(), isolate); 8315 Handle<Object> handler(proxy->handler(), isolate);
8318 // 2. If handler is null, throw a TypeError exception. 8316 // 2. If handler is null, throw a TypeError exception.
8319 if (IsRevoked(proxy)) { 8317 if (proxy->IsRevoked()) {
8320 isolate->Throw(*isolate->factory()->NewTypeError( 8318 isolate->Throw(*isolate->factory()->NewTypeError(
8321 MessageTemplate::kProxyRevoked, isolate->factory()->ownKeys_string())); 8319 MessageTemplate::kProxyRevoked, isolate->factory()->ownKeys_string()));
8322 return false; 8320 return false;
8323 } 8321 }
8324 // 3. Assert: Type(handler) is Object. 8322 // 3. Assert: Type(handler) is Object.
8325 DCHECK(handler->IsJSReceiver()); 8323 DCHECK(handler->IsJSReceiver());
8326 // 4. Let target be the value of the [[ProxyTarget]] internal slot of O. 8324 // 4. Let target be the value of the [[ProxyTarget]] internal slot of O.
8327 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate); 8325 Handle<JSReceiver> target(JSReceiver::cast(proxy->target()), isolate);
8328 // 5. Let trap be ? GetMethod(handler, "ownKeys"). 8326 // 5. Let trap be ? GetMethod(handler, "ownKeys").
8329 Handle<Object> trap; 8327 Handle<Object> trap;
(...skipping 10661 matching lines...) Expand 10 before | Expand all | Expand 10 after
18991 if (cell->value() != *new_value) { 18989 if (cell->value() != *new_value) {
18992 cell->set_value(*new_value); 18990 cell->set_value(*new_value);
18993 Isolate* isolate = cell->GetIsolate(); 18991 Isolate* isolate = cell->GetIsolate();
18994 cell->dependent_code()->DeoptimizeDependentCodeGroup( 18992 cell->dependent_code()->DeoptimizeDependentCodeGroup(
18995 isolate, DependentCode::kPropertyCellChangedGroup); 18993 isolate, DependentCode::kPropertyCellChangedGroup);
18996 } 18994 }
18997 } 18995 }
18998 18996
18999 } // namespace internal 18997 } // namespace internal
19000 } // namespace v8 18998 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698