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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 } else { | 135 } else { |
136 result->isolate()->PushStackTraceAndDie( | 136 result->isolate()->PushStackTraceAndDie( |
137 0xDEAD0000, this, JSReceiver::cast(this)->map(), 0xDEAD0001); | 137 0xDEAD0000, this, JSReceiver::cast(this)->map(), 0xDEAD0001); |
138 } | 138 } |
139 } | 139 } |
140 ASSERT(holder != NULL); // Cannot handle null or undefined. | 140 ASSERT(holder != NULL); // Cannot handle null or undefined. |
141 JSReceiver::cast(holder)->Lookup(name, result); | 141 JSReceiver::cast(holder)->Lookup(name, result); |
142 } | 142 } |
143 | 143 |
144 | 144 |
145 Handle<Object> Object::GetPropertyWithReceiver( | |
146 Handle<Object> object, | |
147 Handle<Object> receiver, | |
148 Handle<Name> name, | |
149 PropertyAttributes* attributes) { | |
150 LookupResult lookup(name->GetIsolate()); | |
151 object->Lookup(*name, &lookup); | |
152 Handle<Object> result = | |
153 GetProperty(object, receiver, &lookup, name, attributes); | |
154 ASSERT(*attributes <= ABSENT); | |
155 return result; | |
156 } | |
157 | |
158 | |
145 MaybeObject* Object::GetPropertyWithReceiver(Object* receiver, | 159 MaybeObject* Object::GetPropertyWithReceiver(Object* receiver, |
146 Name* name, | 160 Name* name, |
147 PropertyAttributes* attributes) { | 161 PropertyAttributes* attributes) { |
148 LookupResult result(name->GetIsolate()); | 162 LookupResult result(name->GetIsolate()); |
149 Lookup(name, &result); | 163 Lookup(name, &result); |
150 MaybeObject* value = GetProperty(receiver, &result, name, attributes); | 164 MaybeObject* value = GetProperty(receiver, &result, name, attributes); |
151 ASSERT(*attributes <= ABSENT); | 165 ASSERT(*attributes <= ABSENT); |
152 return value; | 166 return value; |
153 } | 167 } |
154 | 168 |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
796 LookupResult* result, | 810 LookupResult* result, |
797 Handle<Name> key, | 811 Handle<Name> key, |
798 PropertyAttributes* attributes) { | 812 PropertyAttributes* attributes) { |
799 Isolate* isolate = result->isolate(); | 813 Isolate* isolate = result->isolate(); |
800 CALL_HEAP_FUNCTION_PASS_EXCEPTION( | 814 CALL_HEAP_FUNCTION_PASS_EXCEPTION( |
801 isolate, | 815 isolate, |
802 object->GetProperty(*receiver, result, *key, attributes)); | 816 object->GetProperty(*receiver, result, *key, attributes)); |
803 } | 817 } |
804 | 818 |
805 | 819 |
820 // TODO(yangguo): handlify this and get rid of. | |
806 MaybeObject* Object::GetProperty(Object* receiver, | 821 MaybeObject* Object::GetProperty(Object* receiver, |
807 LookupResult* result, | 822 LookupResult* result, |
808 Name* name, | 823 Name* name, |
809 PropertyAttributes* attributes) { | 824 PropertyAttributes* attributes) { |
810 Isolate* isolate = name->GetIsolate(); | 825 Isolate* isolate = name->GetIsolate(); |
811 Heap* heap = isolate->heap(); | 826 Heap* heap = isolate->heap(); |
812 | 827 |
813 #ifdef DEBUG | 828 #ifdef DEBUG |
814 // TODO(mstarzinger): Only because of the AssertNoContextChange, drop as soon | 829 // TODO(mstarzinger): Only because of the AssertNoContextChange, drop as soon |
815 // as this method has been fully handlified. | 830 // as this method has been fully handlified. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
874 ASSERT(!value->IsTheHole() || result->IsReadOnly()); | 889 ASSERT(!value->IsTheHole() || result->IsReadOnly()); |
875 return value->IsTheHole() ? heap->undefined_value() : value; | 890 return value->IsTheHole() ? heap->undefined_value() : value; |
876 } | 891 } |
877 case CONSTANT: | 892 case CONSTANT: |
878 return result->GetConstant(); | 893 return result->GetConstant(); |
879 case CALLBACKS: | 894 case CALLBACKS: |
880 return result->holder()->GetPropertyWithCallback( | 895 return result->holder()->GetPropertyWithCallback( |
881 receiver, result->GetCallbackObject(), name); | 896 receiver, result->GetCallbackObject(), name); |
882 case HANDLER: | 897 case HANDLER: |
883 return result->proxy()->GetPropertyWithHandler(receiver, name); | 898 return result->proxy()->GetPropertyWithHandler(receiver, name); |
884 case INTERCEPTOR: | 899 case INTERCEPTOR: { |
885 return result->holder()->GetPropertyWithInterceptor( | 900 HandleScope scope(isolate); |
886 receiver, name, attributes); | 901 Handle<Object> value = JSObject::GetPropertyWithInterceptor( |
902 handle(result->holder(), isolate), | |
903 handle(receiver, isolate), | |
904 handle(name, isolate), | |
905 attributes); | |
906 RETURN_IF_EMPTY_HANDLE(isolate, value); | |
907 return *value; | |
908 } | |
887 case TRANSITION: | 909 case TRANSITION: |
888 case NONEXISTENT: | 910 case NONEXISTENT: |
889 UNREACHABLE(); | 911 UNREACHABLE(); |
890 break; | 912 break; |
891 } | 913 } |
892 UNREACHABLE(); | 914 UNREACHABLE(); |
893 return NULL; | 915 return NULL; |
894 } | 916 } |
895 | 917 |
896 | 918 |
(...skipping 12034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12931 InterceptorInfo* JSObject::GetIndexedInterceptor() { | 12953 InterceptorInfo* JSObject::GetIndexedInterceptor() { |
12932 ASSERT(map()->has_indexed_interceptor()); | 12954 ASSERT(map()->has_indexed_interceptor()); |
12933 JSFunction* constructor = JSFunction::cast(map()->constructor()); | 12955 JSFunction* constructor = JSFunction::cast(map()->constructor()); |
12934 ASSERT(constructor->shared()->IsApiFunction()); | 12956 ASSERT(constructor->shared()->IsApiFunction()); |
12935 Object* result = | 12957 Object* result = |
12936 constructor->shared()->get_api_func_data()->indexed_property_handler(); | 12958 constructor->shared()->get_api_func_data()->indexed_property_handler(); |
12937 return InterceptorInfo::cast(result); | 12959 return InterceptorInfo::cast(result); |
12938 } | 12960 } |
12939 | 12961 |
12940 | 12962 |
12941 MaybeObject* JSObject::GetPropertyPostInterceptor( | 12963 Handle<Object> JSObject::GetPropertyPostInterceptor( |
12942 Object* receiver, | 12964 Handle<JSObject> holder, |
Michael Starzinger
2013/10/02 18:56:24
nit: s/holder/object/ for consistency.
| |
12943 Name* name, | 12965 Handle<Object> receiver, |
12966 Handle<Name> name, | |
12944 PropertyAttributes* attributes) { | 12967 PropertyAttributes* attributes) { |
12945 // Check local property in holder, ignore interceptor. | 12968 // Check local property in holder, ignore interceptor. |
12946 LookupResult result(GetIsolate()); | 12969 Isolate* isolate = holder->GetIsolate(); |
12947 LocalLookupRealNamedProperty(name, &result); | 12970 LookupResult lookup(isolate); |
12948 if (result.IsFound()) { | 12971 holder->LocalLookupRealNamedProperty(*name, &lookup); |
12949 return GetProperty(receiver, &result, name, attributes); | 12972 Handle<Object> result; |
12973 if (lookup.IsFound()) { | |
12974 result = GetProperty(holder, receiver, &lookup, name, attributes); | |
12975 } else { | |
12976 // Continue searching via the prototype chain. | |
12977 Handle<Object> prototype(holder->GetPrototype(), isolate); | |
12978 *attributes = ABSENT; | |
12979 if (prototype->IsNull()) return isolate->factory()->undefined_value(); | |
12980 result = GetPropertyWithReceiver(prototype, receiver, name, attributes); | |
12950 } | 12981 } |
12951 // Continue searching via the prototype chain. | 12982 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
Michael Starzinger
2013/10/02 18:56:24
This check should be obsolete, if there is a sched
| |
12952 Object* pt = GetPrototype(); | 12983 return result; |
12953 *attributes = ABSENT; | |
12954 if (pt->IsNull()) return GetHeap()->undefined_value(); | |
12955 return pt->GetPropertyWithReceiver(receiver, name, attributes); | |
12956 } | 12984 } |
12957 | 12985 |
12958 | 12986 |
12959 MaybeObject* JSObject::GetLocalPropertyPostInterceptor( | 12987 MaybeObject* JSObject::GetLocalPropertyPostInterceptor( |
12960 Object* receiver, | 12988 Object* receiver, |
12961 Name* name, | 12989 Name* name, |
12962 PropertyAttributes* attributes) { | 12990 PropertyAttributes* attributes) { |
12963 // Check local property in holder, ignore interceptor. | 12991 // Check local property in holder, ignore interceptor. |
12964 LookupResult result(GetIsolate()); | 12992 LookupResult result(GetIsolate()); |
12965 LocalLookupRealNamedProperty(name, &result); | 12993 LocalLookupRealNamedProperty(name, &result); |
12966 if (result.IsFound()) { | 12994 if (result.IsFound()) { |
12967 return GetProperty(receiver, &result, name, attributes); | 12995 return GetProperty(receiver, &result, name, attributes); |
12968 } | 12996 } |
12969 return GetHeap()->undefined_value(); | 12997 return GetHeap()->undefined_value(); |
12970 } | 12998 } |
12971 | 12999 |
12972 | 13000 |
12973 MaybeObject* JSObject::GetPropertyWithInterceptor( | 13001 Handle<Object> JSObject::GetPropertyWithInterceptor( |
12974 Object* receiver, | 13002 Handle<JSObject> holder, |
12975 Name* name, | 13003 Handle<Object> receiver, |
13004 Handle<Name> name, | |
12976 PropertyAttributes* attributes) { | 13005 PropertyAttributes* attributes) { |
13006 Isolate* isolate = holder->GetIsolate(); | |
13007 | |
12977 // TODO(rossberg): Support symbols in the API. | 13008 // TODO(rossberg): Support symbols in the API. |
12978 if (name->IsSymbol()) return GetHeap()->undefined_value(); | 13009 if (name->IsSymbol()) return isolate->factory()->undefined_value(); |
12979 | 13010 |
12980 Isolate* isolate = GetIsolate(); | 13011 Handle<InterceptorInfo> interceptor(holder->GetNamedInterceptor(), isolate); |
12981 InterceptorInfo* interceptor = GetNamedInterceptor(); | 13012 Handle<String> name_string = Handle<String>::cast(name); |
12982 HandleScope scope(isolate); | |
12983 Handle<Object> receiver_handle(receiver, isolate); | |
12984 Handle<JSObject> holder_handle(this); | |
12985 Handle<String> name_handle(String::cast(name)); | |
12986 | 13013 |
12987 if (!interceptor->getter()->IsUndefined()) { | 13014 if (!interceptor->getter()->IsUndefined()) { |
12988 v8::NamedPropertyGetterCallback getter = | 13015 v8::NamedPropertyGetterCallback getter = |
12989 v8::ToCData<v8::NamedPropertyGetterCallback>(interceptor->getter()); | 13016 v8::ToCData<v8::NamedPropertyGetterCallback>(interceptor->getter()); |
12990 LOG(isolate, | 13017 LOG(isolate, |
12991 ApiNamedPropertyAccess("interceptor-named-get", *holder_handle, name)); | 13018 ApiNamedPropertyAccess("interceptor-named-get", *holder, *name)); |
12992 PropertyCallbackArguments | 13019 PropertyCallbackArguments |
12993 args(isolate, interceptor->data(), receiver, this); | 13020 args(isolate, interceptor->data(), *receiver, *holder); |
12994 v8::Handle<v8::Value> result = | 13021 v8::Handle<v8::Value> result = |
12995 args.Call(getter, v8::Utils::ToLocal(name_handle)); | 13022 args.Call(getter, v8::Utils::ToLocal(name_string)); |
12996 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 13023 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
12997 if (!result.IsEmpty()) { | 13024 if (!result.IsEmpty()) { |
12998 *attributes = NONE; | 13025 *attributes = NONE; |
12999 Handle<Object> result_internal = v8::Utils::OpenHandle(*result); | 13026 Handle<Object> result_internal = v8::Utils::OpenHandle(*result); |
13000 result_internal->VerifyApiCallResultType(); | 13027 result_internal->VerifyApiCallResultType(); |
13001 return *result_internal; | 13028 // Rebox handle to escape this scope. |
13029 return handle(*result_internal, isolate); | |
13002 } | 13030 } |
13003 } | 13031 } |
13004 | 13032 |
13005 MaybeObject* result = holder_handle->GetPropertyPostInterceptor( | 13033 return GetPropertyPostInterceptor(holder, receiver, name, attributes); |
13006 *receiver_handle, | |
13007 *name_handle, | |
13008 attributes); | |
13009 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | |
13010 return result; | |
13011 } | 13034 } |
13012 | 13035 |
13013 | 13036 |
13014 bool JSObject::HasRealNamedProperty(Isolate* isolate, Name* key) { | 13037 bool JSObject::HasRealNamedProperty(Isolate* isolate, Name* key) { |
13015 // Check access rights if needed. | 13038 // Check access rights if needed. |
13016 if (IsAccessCheckNeeded()) { | 13039 if (IsAccessCheckNeeded()) { |
13017 if (!isolate->MayNamedAccess(this, key, v8::ACCESS_HAS)) { | 13040 if (!isolate->MayNamedAccess(this, key, v8::ACCESS_HAS)) { |
13018 isolate->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 13041 isolate->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
13019 return false; | 13042 return false; |
13020 } | 13043 } |
(...skipping 3148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16169 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16192 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16170 static const char* error_messages_[] = { | 16193 static const char* error_messages_[] = { |
16171 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16194 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16172 }; | 16195 }; |
16173 #undef ERROR_MESSAGES_TEXTS | 16196 #undef ERROR_MESSAGES_TEXTS |
16174 return error_messages_[reason]; | 16197 return error_messages_[reason]; |
16175 } | 16198 } |
16176 | 16199 |
16177 | 16200 |
16178 } } // namespace v8::internal | 16201 } } // namespace v8::internal |
OLD | NEW |