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 12047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12944 InterceptorInfo* JSObject::GetIndexedInterceptor() { | 12966 InterceptorInfo* JSObject::GetIndexedInterceptor() { |
12945 ASSERT(map()->has_indexed_interceptor()); | 12967 ASSERT(map()->has_indexed_interceptor()); |
12946 JSFunction* constructor = JSFunction::cast(map()->constructor()); | 12968 JSFunction* constructor = JSFunction::cast(map()->constructor()); |
12947 ASSERT(constructor->shared()->IsApiFunction()); | 12969 ASSERT(constructor->shared()->IsApiFunction()); |
12948 Object* result = | 12970 Object* result = |
12949 constructor->shared()->get_api_func_data()->indexed_property_handler(); | 12971 constructor->shared()->get_api_func_data()->indexed_property_handler(); |
12950 return InterceptorInfo::cast(result); | 12972 return InterceptorInfo::cast(result); |
12951 } | 12973 } |
12952 | 12974 |
12953 | 12975 |
12954 MaybeObject* JSObject::GetPropertyPostInterceptor( | 12976 Handle<Object> JSObject::GetPropertyPostInterceptor( |
12955 Object* receiver, | 12977 Handle<JSObject> object, |
12956 Name* name, | 12978 Handle<Object> receiver, |
| 12979 Handle<Name> name, |
12957 PropertyAttributes* attributes) { | 12980 PropertyAttributes* attributes) { |
12958 // Check local property in holder, ignore interceptor. | 12981 // Check local property in holder, ignore interceptor. |
12959 LookupResult result(GetIsolate()); | 12982 Isolate* isolate = object->GetIsolate(); |
12960 LocalLookupRealNamedProperty(name, &result); | 12983 LookupResult lookup(isolate); |
12961 if (result.IsFound()) { | 12984 object->LocalLookupRealNamedProperty(*name, &lookup); |
12962 return GetProperty(receiver, &result, name, attributes); | 12985 Handle<Object> result; |
| 12986 if (lookup.IsFound()) { |
| 12987 result = GetProperty(object, receiver, &lookup, name, attributes); |
| 12988 } else { |
| 12989 // Continue searching via the prototype chain. |
| 12990 Handle<Object> prototype(object->GetPrototype(), isolate); |
| 12991 *attributes = ABSENT; |
| 12992 if (prototype->IsNull()) return isolate->factory()->undefined_value(); |
| 12993 result = GetPropertyWithReceiver(prototype, receiver, name, attributes); |
12963 } | 12994 } |
12964 // Continue searching via the prototype chain. | 12995 return result; |
12965 Object* pt = GetPrototype(); | |
12966 *attributes = ABSENT; | |
12967 if (pt->IsNull()) return GetHeap()->undefined_value(); | |
12968 return pt->GetPropertyWithReceiver(receiver, name, attributes); | |
12969 } | 12996 } |
12970 | 12997 |
12971 | 12998 |
12972 MaybeObject* JSObject::GetLocalPropertyPostInterceptor( | 12999 MaybeObject* JSObject::GetLocalPropertyPostInterceptor( |
12973 Object* receiver, | 13000 Object* receiver, |
12974 Name* name, | 13001 Name* name, |
12975 PropertyAttributes* attributes) { | 13002 PropertyAttributes* attributes) { |
12976 // Check local property in holder, ignore interceptor. | 13003 // Check local property in holder, ignore interceptor. |
12977 LookupResult result(GetIsolate()); | 13004 LookupResult result(GetIsolate()); |
12978 LocalLookupRealNamedProperty(name, &result); | 13005 LocalLookupRealNamedProperty(name, &result); |
12979 if (result.IsFound()) { | 13006 if (result.IsFound()) { |
12980 return GetProperty(receiver, &result, name, attributes); | 13007 return GetProperty(receiver, &result, name, attributes); |
12981 } | 13008 } |
12982 return GetHeap()->undefined_value(); | 13009 return GetHeap()->undefined_value(); |
12983 } | 13010 } |
12984 | 13011 |
12985 | 13012 |
12986 MaybeObject* JSObject::GetPropertyWithInterceptor( | 13013 Handle<Object> JSObject::GetPropertyWithInterceptor( |
12987 Object* receiver, | 13014 Handle<JSObject> object, |
12988 Name* name, | 13015 Handle<Object> receiver, |
| 13016 Handle<Name> name, |
12989 PropertyAttributes* attributes) { | 13017 PropertyAttributes* attributes) { |
| 13018 Isolate* isolate = object->GetIsolate(); |
| 13019 |
12990 // TODO(rossberg): Support symbols in the API. | 13020 // TODO(rossberg): Support symbols in the API. |
12991 if (name->IsSymbol()) return GetHeap()->undefined_value(); | 13021 if (name->IsSymbol()) return isolate->factory()->undefined_value(); |
12992 | 13022 |
12993 Isolate* isolate = GetIsolate(); | 13023 Handle<InterceptorInfo> interceptor(object->GetNamedInterceptor(), isolate); |
12994 InterceptorInfo* interceptor = GetNamedInterceptor(); | 13024 Handle<String> name_string = Handle<String>::cast(name); |
12995 HandleScope scope(isolate); | |
12996 Handle<Object> receiver_handle(receiver, isolate); | |
12997 Handle<JSObject> holder_handle(this); | |
12998 Handle<String> name_handle(String::cast(name)); | |
12999 | 13025 |
13000 if (!interceptor->getter()->IsUndefined()) { | 13026 if (!interceptor->getter()->IsUndefined()) { |
13001 v8::NamedPropertyGetterCallback getter = | 13027 v8::NamedPropertyGetterCallback getter = |
13002 v8::ToCData<v8::NamedPropertyGetterCallback>(interceptor->getter()); | 13028 v8::ToCData<v8::NamedPropertyGetterCallback>(interceptor->getter()); |
13003 LOG(isolate, | 13029 LOG(isolate, |
13004 ApiNamedPropertyAccess("interceptor-named-get", *holder_handle, name)); | 13030 ApiNamedPropertyAccess("interceptor-named-get", *object, *name)); |
13005 PropertyCallbackArguments | 13031 PropertyCallbackArguments |
13006 args(isolate, interceptor->data(), receiver, this); | 13032 args(isolate, interceptor->data(), *receiver, *object); |
13007 v8::Handle<v8::Value> result = | 13033 v8::Handle<v8::Value> result = |
13008 args.Call(getter, v8::Utils::ToLocal(name_handle)); | 13034 args.Call(getter, v8::Utils::ToLocal(name_string)); |
13009 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 13035 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
13010 if (!result.IsEmpty()) { | 13036 if (!result.IsEmpty()) { |
13011 *attributes = NONE; | 13037 *attributes = NONE; |
13012 Handle<Object> result_internal = v8::Utils::OpenHandle(*result); | 13038 Handle<Object> result_internal = v8::Utils::OpenHandle(*result); |
13013 result_internal->VerifyApiCallResultType(); | 13039 result_internal->VerifyApiCallResultType(); |
13014 return *result_internal; | 13040 // Rebox handle to escape this scope. |
| 13041 return handle(*result_internal, isolate); |
13015 } | 13042 } |
13016 } | 13043 } |
13017 | 13044 |
13018 MaybeObject* result = holder_handle->GetPropertyPostInterceptor( | 13045 return GetPropertyPostInterceptor(object, receiver, name, attributes); |
13019 *receiver_handle, | |
13020 *name_handle, | |
13021 attributes); | |
13022 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | |
13023 return result; | |
13024 } | 13046 } |
13025 | 13047 |
13026 | 13048 |
13027 bool JSObject::HasRealNamedProperty(Isolate* isolate, Name* key) { | 13049 bool JSObject::HasRealNamedProperty(Isolate* isolate, Name* key) { |
13028 // Check access rights if needed. | 13050 // Check access rights if needed. |
13029 if (IsAccessCheckNeeded()) { | 13051 if (IsAccessCheckNeeded()) { |
13030 if (!isolate->MayNamedAccess(this, key, v8::ACCESS_HAS)) { | 13052 if (!isolate->MayNamedAccess(this, key, v8::ACCESS_HAS)) { |
13031 isolate->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 13053 isolate->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
13032 return false; | 13054 return false; |
13033 } | 13055 } |
(...skipping 3187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16221 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16243 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16222 static const char* error_messages_[] = { | 16244 static const char* error_messages_[] = { |
16223 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16245 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16224 }; | 16246 }; |
16225 #undef ERROR_MESSAGES_TEXTS | 16247 #undef ERROR_MESSAGES_TEXTS |
16226 return error_messages_[reason]; | 16248 return error_messages_[reason]; |
16227 } | 16249 } |
16228 | 16250 |
16229 | 16251 |
16230 } } // namespace v8::internal | 16252 } } // namespace v8::internal |
OLD | NEW |