| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 3638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3649 uint32_t index) { | 3649 uint32_t index) { |
| 3650 Isolate* isolate = GetIsolate(); | 3650 Isolate* isolate = GetIsolate(); |
| 3651 HandleScope scope(isolate); | 3651 HandleScope scope(isolate); |
| 3652 Handle<JSProxy> proxy(this); | 3652 Handle<JSProxy> proxy(this); |
| 3653 Handle<JSReceiver> receiver(receiver_raw); | 3653 Handle<JSReceiver> receiver(receiver_raw); |
| 3654 Handle<String> name = isolate->factory()->Uint32ToString(index); | 3654 Handle<String> name = isolate->factory()->Uint32ToString(index); |
| 3655 return proxy->GetPropertyAttributeWithHandler(*receiver, *name); | 3655 return proxy->GetPropertyAttributeWithHandler(*receiver, *name); |
| 3656 } | 3656 } |
| 3657 | 3657 |
| 3658 | 3658 |
| 3659 void JSProxy::Fix() { | 3659 void JSProxy::Fix(Handle<JSProxy> proxy) { |
| 3660 Isolate* isolate = GetIsolate(); | 3660 Isolate* isolate = proxy->GetIsolate(); |
| 3661 HandleScope scope(isolate); | |
| 3662 Handle<JSProxy> self(this); | |
| 3663 | 3661 |
| 3664 // Save identity hash. | 3662 // Save identity hash. |
| 3665 MaybeObject* maybe_hash = GetIdentityHash(OMIT_CREATION); | 3663 Handle<Object> hash = JSProxy::GetIdentityHash(proxy, OMIT_CREATION); |
| 3666 | 3664 |
| 3667 if (IsJSFunctionProxy()) { | 3665 if (proxy->IsJSFunctionProxy()) { |
| 3668 isolate->factory()->BecomeJSFunction(self); | 3666 isolate->factory()->BecomeJSFunction(proxy); |
| 3669 // Code will be set on the JavaScript side. | 3667 // Code will be set on the JavaScript side. |
| 3670 } else { | 3668 } else { |
| 3671 isolate->factory()->BecomeJSObject(self); | 3669 isolate->factory()->BecomeJSObject(proxy); |
| 3672 } | 3670 } |
| 3673 ASSERT(self->IsJSObject()); | 3671 ASSERT(proxy->IsJSObject()); |
| 3674 | 3672 |
| 3675 // Inherit identity, if it was present. | 3673 // Inherit identity, if it was present. |
| 3676 Object* hash; | 3674 if (hash->IsSmi()) { |
| 3677 if (maybe_hash->To<Object>(&hash) && hash->IsSmi()) { | 3675 isolate->factory()->SetIdentityHash( |
| 3678 Handle<JSObject> new_self(JSObject::cast(*self)); | 3676 Handle<JSObject>::cast(proxy), Smi::cast(*hash)); |
| 3679 isolate->factory()->SetIdentityHash(new_self, Smi::cast(hash)); | |
| 3680 } | 3677 } |
| 3681 } | 3678 } |
| 3682 | 3679 |
| 3683 | 3680 |
| 3684 MUST_USE_RESULT Handle<Object> JSProxy::CallTrap(const char* name, | 3681 MUST_USE_RESULT Handle<Object> JSProxy::CallTrap(const char* name, |
| 3685 Handle<Object> derived, | 3682 Handle<Object> derived, |
| 3686 int argc, | 3683 int argc, |
| 3687 Handle<Object> argv[]) { | 3684 Handle<Object> argv[]) { |
| 3688 Isolate* isolate = GetIsolate(); | 3685 Isolate* isolate = GetIsolate(); |
| 3689 Handle<Object> handler(this->handler(), isolate); | 3686 Handle<Object> handler(this->handler(), isolate); |
| (...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4747 hash); | 4744 hash); |
| 4748 if (result->IsFailure()) return result; | 4745 if (result->IsFailure()) return result; |
| 4749 if (result->ToObjectUnchecked()->IsUndefined()) { | 4746 if (result->ToObjectUnchecked()->IsUndefined()) { |
| 4750 // Trying to get hash of detached proxy. | 4747 // Trying to get hash of detached proxy. |
| 4751 return Smi::FromInt(0); | 4748 return Smi::FromInt(0); |
| 4752 } | 4749 } |
| 4753 return hash; | 4750 return hash; |
| 4754 } | 4751 } |
| 4755 | 4752 |
| 4756 | 4753 |
| 4754 Handle<Object> JSProxy::GetIdentityHash(Handle<JSProxy> proxy, |
| 4755 CreationFlag flag) { |
| 4756 CALL_HEAP_FUNCTION(proxy->GetIsolate(), proxy->GetIdentityHash(flag), Object); |
| 4757 } |
| 4758 |
| 4759 |
| 4757 MaybeObject* JSProxy::GetIdentityHash(CreationFlag flag) { | 4760 MaybeObject* JSProxy::GetIdentityHash(CreationFlag flag) { |
| 4758 Object* hash = this->hash(); | 4761 Object* hash = this->hash(); |
| 4759 if (!hash->IsSmi() && flag == ALLOW_CREATION) { | 4762 if (!hash->IsSmi() && flag == ALLOW_CREATION) { |
| 4760 hash = GenerateIdentityHash(); | 4763 hash = GenerateIdentityHash(); |
| 4761 set_hash(hash); | 4764 set_hash(hash); |
| 4762 } | 4765 } |
| 4763 return hash; | 4766 return hash; |
| 4764 } | 4767 } |
| 4765 | 4768 |
| 4766 | 4769 |
| (...skipping 11227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15994 #define ERROR_MESSAGES_TEXTS(C, T) T, | 15997 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 15995 static const char* error_messages_[] = { | 15998 static const char* error_messages_[] = { |
| 15996 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 15999 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 15997 }; | 16000 }; |
| 15998 #undef ERROR_MESSAGES_TEXTS | 16001 #undef ERROR_MESSAGES_TEXTS |
| 15999 return error_messages_[reason]; | 16002 return error_messages_[reason]; |
| 16000 } | 16003 } |
| 16001 | 16004 |
| 16002 | 16005 |
| 16003 } } // namespace v8::internal | 16006 } } // namespace v8::internal |
| OLD | NEW |