| 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/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 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 if (!func->IsCallable()) { | 634 if (!func->IsCallable()) { |
| 635 // TODO(bmeurer): Better error message here? | 635 // TODO(bmeurer): Better error message here? |
| 636 THROW_NEW_ERROR(isolate, | 636 THROW_NEW_ERROR(isolate, |
| 637 NewTypeError(MessageTemplate::kCalledNonCallable, func), | 637 NewTypeError(MessageTemplate::kCalledNonCallable, func), |
| 638 Object); | 638 Object); |
| 639 } | 639 } |
| 640 return func; | 640 return func; |
| 641 } | 641 } |
| 642 | 642 |
| 643 | 643 |
| 644 // static |
| 645 Maybe<bool> JSReceiver::HasProperty(LookupIterator* it) { |
| 646 for (; it->IsFound(); it->Next()) { |
| 647 switch (it->state()) { |
| 648 case LookupIterator::NOT_FOUND: |
| 649 case LookupIterator::TRANSITION: |
| 650 UNREACHABLE(); |
| 651 case LookupIterator::JSPROXY: |
| 652 // Call the "has" trap on proxies. |
| 653 return JSProxy::HasPropertyWithHandler(it->GetHolder<JSProxy>(), |
| 654 it->GetName()); |
| 655 case LookupIterator::INTERCEPTOR: { |
| 656 Maybe<PropertyAttributes> result = |
| 657 JSObject::GetPropertyAttributesWithInterceptor(it); |
| 658 if (!result.IsJust()) return Nothing<bool>(); |
| 659 if (result.FromJust() != ABSENT) return Just(true); |
| 660 break; |
| 661 } |
| 662 case LookupIterator::ACCESS_CHECK: { |
| 663 if (it->HasAccess()) break; |
| 664 Maybe<PropertyAttributes> result = |
| 665 JSObject::GetPropertyAttributesWithFailedAccessCheck(it); |
| 666 if (!result.IsJust()) return Nothing<bool>(); |
| 667 return Just(result.FromJust() != ABSENT); |
| 668 } |
| 669 case LookupIterator::INTEGER_INDEXED_EXOTIC: |
| 670 // TypedArray out-of-bounds access. |
| 671 return Just(false); |
| 672 case LookupIterator::ACCESSOR: |
| 673 case LookupIterator::DATA: |
| 674 return Just(true); |
| 675 } |
| 676 } |
| 677 return Just(false); |
| 678 } |
| 679 |
| 680 |
| 681 // static |
| 644 MaybeHandle<Object> Object::GetProperty(LookupIterator* it, | 682 MaybeHandle<Object> Object::GetProperty(LookupIterator* it, |
| 645 LanguageMode language_mode) { | 683 LanguageMode language_mode) { |
| 646 for (; it->IsFound(); it->Next()) { | 684 for (; it->IsFound(); it->Next()) { |
| 647 switch (it->state()) { | 685 switch (it->state()) { |
| 648 case LookupIterator::NOT_FOUND: | 686 case LookupIterator::NOT_FOUND: |
| 649 case LookupIterator::TRANSITION: | 687 case LookupIterator::TRANSITION: |
| 650 UNREACHABLE(); | 688 UNREACHABLE(); |
| 651 case LookupIterator::JSPROXY: | 689 case LookupIterator::JSPROXY: |
| 652 return JSProxy::GetPropertyWithHandler( | 690 return JSProxy::GetPropertyWithHandler( |
| 653 it->GetHolder<JSProxy>(), it->GetReceiver(), it->GetName()); | 691 it->GetHolder<JSProxy>(), it->GetReceiver(), it->GetName()); |
| (...skipping 14197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14851 v8::Utils::OpenHandle(*result)->HasSloppyArgumentsElements()); | 14889 v8::Utils::OpenHandle(*result)->HasSloppyArgumentsElements()); |
| 14852 // Rebox before returning. | 14890 // Rebox before returning. |
| 14853 return handle(*v8::Utils::OpenHandle(*result), isolate); | 14891 return handle(*v8::Utils::OpenHandle(*result), isolate); |
| 14854 } | 14892 } |
| 14855 | 14893 |
| 14856 | 14894 |
| 14857 Maybe<bool> JSObject::HasRealNamedProperty(Handle<JSObject> object, | 14895 Maybe<bool> JSObject::HasRealNamedProperty(Handle<JSObject> object, |
| 14858 Handle<Name> name) { | 14896 Handle<Name> name) { |
| 14859 LookupIterator it = LookupIterator::PropertyOrElement( | 14897 LookupIterator it = LookupIterator::PropertyOrElement( |
| 14860 name->GetIsolate(), object, name, LookupIterator::OWN_SKIP_INTERCEPTOR); | 14898 name->GetIsolate(), object, name, LookupIterator::OWN_SKIP_INTERCEPTOR); |
| 14861 Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it); | 14899 return HasProperty(&it); |
| 14862 if (!maybe_result.IsJust()) return Nothing<bool>(); | |
| 14863 return Just(it.IsFound()); | |
| 14864 } | 14900 } |
| 14865 | 14901 |
| 14866 | 14902 |
| 14867 Maybe<bool> JSObject::HasRealElementProperty(Handle<JSObject> object, | 14903 Maybe<bool> JSObject::HasRealElementProperty(Handle<JSObject> object, |
| 14868 uint32_t index) { | 14904 uint32_t index) { |
| 14869 Isolate* isolate = object->GetIsolate(); | 14905 Isolate* isolate = object->GetIsolate(); |
| 14870 LookupIterator it(isolate, object, index, | 14906 LookupIterator it(isolate, object, index, |
| 14871 LookupIterator::OWN_SKIP_INTERCEPTOR); | 14907 LookupIterator::OWN_SKIP_INTERCEPTOR); |
| 14872 Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it); | 14908 return HasProperty(&it); |
| 14873 if (!maybe_result.IsJust()) return Nothing<bool>(); | |
| 14874 return Just(it.IsFound()); | |
| 14875 } | 14909 } |
| 14876 | 14910 |
| 14877 | 14911 |
| 14878 Maybe<bool> JSObject::HasRealNamedCallbackProperty(Handle<JSObject> object, | 14912 Maybe<bool> JSObject::HasRealNamedCallbackProperty(Handle<JSObject> object, |
| 14879 Handle<Name> name) { | 14913 Handle<Name> name) { |
| 14880 LookupIterator it = LookupIterator::PropertyOrElement( | 14914 LookupIterator it = LookupIterator::PropertyOrElement( |
| 14881 name->GetIsolate(), object, name, LookupIterator::OWN_SKIP_INTERCEPTOR); | 14915 name->GetIsolate(), object, name, LookupIterator::OWN_SKIP_INTERCEPTOR); |
| 14882 Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it); | 14916 Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it); |
| 14883 return maybe_result.IsJust() ? Just(it.state() == LookupIterator::ACCESSOR) | 14917 return maybe_result.IsJust() ? Just(it.state() == LookupIterator::ACCESSOR) |
| 14884 : Nothing<bool>(); | 14918 : Nothing<bool>(); |
| (...skipping 3148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18033 if (cell->value() != *new_value) { | 18067 if (cell->value() != *new_value) { |
| 18034 cell->set_value(*new_value); | 18068 cell->set_value(*new_value); |
| 18035 Isolate* isolate = cell->GetIsolate(); | 18069 Isolate* isolate = cell->GetIsolate(); |
| 18036 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 18070 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 18037 isolate, DependentCode::kPropertyCellChangedGroup); | 18071 isolate, DependentCode::kPropertyCellChangedGroup); |
| 18038 } | 18072 } |
| 18039 } | 18073 } |
| 18040 | 18074 |
| 18041 } // namespace internal | 18075 } // namespace internal |
| 18042 } // namespace v8 | 18076 } // namespace v8 |
| OLD | NEW |