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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
(...skipping 6847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6858 | 6858 |
6859 MaybeHandle<Object> JSObject::GetAccessor(Handle<JSObject> object, | 6859 MaybeHandle<Object> JSObject::GetAccessor(Handle<JSObject> object, |
6860 Handle<Name> name, | 6860 Handle<Name> name, |
6861 AccessorComponent component) { | 6861 AccessorComponent component) { |
6862 Isolate* isolate = object->GetIsolate(); | 6862 Isolate* isolate = object->GetIsolate(); |
6863 | 6863 |
6864 // Make sure that the top context does not change when doing callbacks or | 6864 // Make sure that the top context does not change when doing callbacks or |
6865 // interceptor calls. | 6865 // interceptor calls. |
6866 AssertNoContextChange ncc(isolate); | 6866 AssertNoContextChange ncc(isolate); |
6867 | 6867 |
6868 // Check access rights if needed. | |
6869 if (object->IsAccessCheckNeeded() && | |
6870 !isolate->MayNamedAccess(object, name, v8::ACCESS_HAS)) { | |
6871 isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS); | |
6872 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | |
6873 return isolate->factory()->undefined_value(); | |
6874 } | |
6875 | |
6876 // Make the lookup and include prototypes. | 6868 // Make the lookup and include prototypes. |
6877 uint32_t index = 0; | 6869 uint32_t index = 0; |
6878 if (name->AsArrayIndex(&index)) { | 6870 if (name->AsArrayIndex(&index)) { |
6879 for (PrototypeIterator iter(isolate, object, | 6871 for (PrototypeIterator iter(isolate, object, |
6880 PrototypeIterator::START_AT_RECEIVER); | 6872 PrototypeIterator::START_AT_RECEIVER); |
6881 !iter.IsAtEnd(); iter.Advance()) { | 6873 !iter.IsAtEnd(); iter.Advance()) { |
6882 if (PrototypeIterator::GetCurrent(iter)->IsJSObject() && | 6874 Handle<Object> current = PrototypeIterator::GetCurrent(iter); |
6883 JSObject::cast(*PrototypeIterator::GetCurrent(iter)) | 6875 // Check access rights if needed. |
6884 ->HasDictionaryElements()) { | 6876 if (current->IsAccessCheckNeeded() && |
6885 JSObject* js_object = | 6877 !isolate->MayNamedAccess(Handle<JSObject>::cast(current), name, |
6886 JSObject::cast(*PrototypeIterator::GetCurrent(iter)); | 6878 v8::ACCESS_HAS)) { |
| 6879 isolate->ReportFailedAccessCheck(Handle<JSObject>::cast(current), |
| 6880 v8::ACCESS_HAS); |
| 6881 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 6882 return isolate->factory()->undefined_value(); |
| 6883 } |
| 6884 |
| 6885 if (current->IsJSObject() && |
| 6886 Handle<JSObject>::cast(current)->HasDictionaryElements()) { |
| 6887 JSObject* js_object = JSObject::cast(*current); |
6887 SeededNumberDictionary* dictionary = js_object->element_dictionary(); | 6888 SeededNumberDictionary* dictionary = js_object->element_dictionary(); |
6888 int entry = dictionary->FindEntry(index); | 6889 int entry = dictionary->FindEntry(index); |
6889 if (entry != SeededNumberDictionary::kNotFound) { | 6890 if (entry != SeededNumberDictionary::kNotFound) { |
6890 Object* element = dictionary->ValueAt(entry); | 6891 Object* element = dictionary->ValueAt(entry); |
6891 if (dictionary->DetailsAt(entry).type() == CALLBACKS && | 6892 if (dictionary->DetailsAt(entry).type() == CALLBACKS && |
6892 element->IsAccessorPair()) { | 6893 element->IsAccessorPair()) { |
6893 return handle(AccessorPair::cast(element)->GetComponent(component), | 6894 return handle(AccessorPair::cast(element)->GetComponent(component), |
6894 isolate); | 6895 isolate); |
6895 } | 6896 } |
6896 } | 6897 } |
6897 } | 6898 } |
6898 } | 6899 } |
6899 } else { | 6900 } else { |
6900 for (PrototypeIterator iter(isolate, object, | 6901 LookupIterator it(object, name, LookupIterator::SKIP_INTERCEPTOR); |
6901 PrototypeIterator::START_AT_RECEIVER); | 6902 for (; it.IsFound(); it.Next()) { |
6902 !iter.IsAtEnd(); iter.Advance()) { | 6903 switch (it.state()) { |
6903 LookupResult result(isolate); | 6904 case LookupIterator::NOT_FOUND: |
6904 JSReceiver::cast(*PrototypeIterator::GetCurrent(iter)) | 6905 case LookupIterator::INTERCEPTOR: |
6905 ->LookupOwn(name, &result); | 6906 UNREACHABLE(); |
6906 if (result.IsFound()) { | 6907 |
6907 if (result.IsReadOnly()) return isolate->factory()->undefined_value(); | 6908 case LookupIterator::ACCESS_CHECK: |
6908 if (result.IsPropertyCallbacks()) { | 6909 if (it.HasAccess(v8::ACCESS_HAS)) continue; |
6909 Object* obj = result.GetCallbackObject(); | 6910 isolate->ReportFailedAccessCheck(it.GetHolder<JSObject>(), |
6910 if (obj->IsAccessorPair()) { | 6911 v8::ACCESS_HAS); |
6911 return handle(AccessorPair::cast(obj)->GetComponent(component), | 6912 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
6912 isolate); | 6913 return isolate->factory()->undefined_value(); |
| 6914 |
| 6915 case LookupIterator::JSPROXY: |
| 6916 return isolate->factory()->undefined_value(); |
| 6917 |
| 6918 case LookupIterator::PROPERTY: |
| 6919 if (!it.HasProperty()) continue; |
| 6920 switch (it.property_kind()) { |
| 6921 case LookupIterator::DATA: |
| 6922 continue; |
| 6923 case LookupIterator::ACCESSOR: { |
| 6924 Handle<Object> maybe_pair = it.GetAccessors(); |
| 6925 if (maybe_pair->IsAccessorPair()) { |
| 6926 return handle( |
| 6927 AccessorPair::cast(*maybe_pair)->GetComponent(component), |
| 6928 isolate); |
| 6929 } |
| 6930 } |
6913 } | 6931 } |
6914 } | |
6915 } | 6932 } |
6916 } | 6933 } |
6917 } | 6934 } |
6918 return isolate->factory()->undefined_value(); | 6935 return isolate->factory()->undefined_value(); |
6919 } | 6936 } |
6920 | 6937 |
6921 | 6938 |
6922 Object* JSObject::SlowReverseLookup(Object* value) { | 6939 Object* JSObject::SlowReverseLookup(Object* value) { |
6923 if (HasFastProperties()) { | 6940 if (HasFastProperties()) { |
6924 int number_of_own_descriptors = map()->NumberOfOwnDescriptors(); | 6941 int number_of_own_descriptors = map()->NumberOfOwnDescriptors(); |
(...skipping 9995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16920 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16937 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16921 static const char* error_messages_[] = { | 16938 static const char* error_messages_[] = { |
16922 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16939 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16923 }; | 16940 }; |
16924 #undef ERROR_MESSAGES_TEXTS | 16941 #undef ERROR_MESSAGES_TEXTS |
16925 return error_messages_[reason]; | 16942 return error_messages_[reason]; |
16926 } | 16943 } |
16927 | 16944 |
16928 | 16945 |
16929 } } // namespace v8::internal | 16946 } } // namespace v8::internal |
OLD | NEW |