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 3853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3864 box->set_value(value->Number()); | 3864 box->set_value(value->Number()); |
3865 } else { | 3865 } else { |
3866 FastPropertyAtPut(index, value); | 3866 FastPropertyAtPut(index, value); |
3867 } | 3867 } |
3868 } | 3868 } |
3869 | 3869 |
3870 | 3870 |
3871 void JSObject::AddProperty(Handle<JSObject> object, Handle<Name> name, | 3871 void JSObject::AddProperty(Handle<JSObject> object, Handle<Name> name, |
3872 Handle<Object> value, | 3872 Handle<Object> value, |
3873 PropertyAttributes attributes) { | 3873 PropertyAttributes attributes) { |
3874 LookupIterator it(object, name, LookupIterator::CHECK_OWN_REAL); | 3874 LookupIterator it(object, name, LookupIterator::CHECK_PROPERTY); |
3875 #ifdef DEBUG | 3875 #ifdef DEBUG |
3876 uint32_t index; | 3876 uint32_t index; |
3877 DCHECK(!object->IsJSProxy()); | 3877 DCHECK(!object->IsJSProxy()); |
3878 DCHECK(!name->AsArrayIndex(&index)); | 3878 DCHECK(!name->AsArrayIndex(&index)); |
3879 Maybe<PropertyAttributes> maybe = GetPropertyAttributes(&it); | 3879 Maybe<PropertyAttributes> maybe = GetPropertyAttributes(&it); |
3880 DCHECK(maybe.has_value); | 3880 DCHECK(maybe.has_value); |
3881 DCHECK(!it.IsFound()); | 3881 DCHECK(!it.IsFound()); |
3882 DCHECK(object->map()->is_extensible() || | 3882 DCHECK(object->map()->is_extensible() || |
3883 name.is_identical_to(it.isolate()->factory()->hidden_string())); | 3883 name.is_identical_to(it.isolate()->factory()->hidden_string())); |
3884 #endif | 3884 #endif |
3885 AddDataProperty(&it, value, attributes, STRICT, | 3885 AddDataProperty(&it, value, attributes, STRICT, |
3886 CERTAINLY_NOT_STORE_FROM_KEYED).Check(); | 3886 CERTAINLY_NOT_STORE_FROM_KEYED).Check(); |
3887 } | 3887 } |
3888 | 3888 |
3889 | 3889 |
3890 // Reconfigures a property to a data property with attributes, even if it is not | 3890 // Reconfigures a property to a data property with attributes, even if it is not |
3891 // reconfigurable. | 3891 // reconfigurable. |
3892 MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes( | 3892 MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes( |
3893 Handle<JSObject> object, | 3893 Handle<JSObject> object, |
3894 Handle<Name> name, | 3894 Handle<Name> name, |
3895 Handle<Object> value, | 3895 Handle<Object> value, |
3896 PropertyAttributes attributes, | 3896 PropertyAttributes attributes, |
3897 ExecutableAccessorInfoHandling handling) { | 3897 ExecutableAccessorInfoHandling handling) { |
3898 DCHECK(!value->IsTheHole()); | 3898 DCHECK(!value->IsTheHole()); |
3899 LookupIterator it(object, name, LookupIterator::CHECK_HIDDEN_ACCESS); | 3899 LookupIterator it(object, name, |
| 3900 LookupIterator::CHECK_HIDDEN_SKIP_INTERCEPTOR); |
3900 bool is_observed = object->map()->is_observed() && | 3901 bool is_observed = object->map()->is_observed() && |
3901 *name != it.isolate()->heap()->hidden_string(); | 3902 *name != it.isolate()->heap()->hidden_string(); |
3902 for (; it.IsFound(); it.Next()) { | 3903 for (; it.IsFound(); it.Next()) { |
3903 switch (it.state()) { | 3904 switch (it.state()) { |
3904 case LookupIterator::NOT_FOUND: | 3905 case LookupIterator::NOT_FOUND: |
3905 case LookupIterator::JSPROXY: | 3906 case LookupIterator::JSPROXY: |
3906 case LookupIterator::INTERCEPTOR: | 3907 case LookupIterator::INTERCEPTOR: |
3907 UNREACHABLE(); | 3908 UNREACHABLE(); |
3908 | 3909 |
3909 case LookupIterator::ACCESS_CHECK: | 3910 case LookupIterator::ACCESS_CHECK: |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4059 } | 4060 } |
4060 | 4061 |
4061 | 4062 |
4062 Maybe<PropertyAttributes> JSReceiver::GetOwnPropertyAttributes( | 4063 Maybe<PropertyAttributes> JSReceiver::GetOwnPropertyAttributes( |
4063 Handle<JSReceiver> object, Handle<Name> name) { | 4064 Handle<JSReceiver> object, Handle<Name> name) { |
4064 // Check whether the name is an array index. | 4065 // Check whether the name is an array index. |
4065 uint32_t index = 0; | 4066 uint32_t index = 0; |
4066 if (object->IsJSObject() && name->AsArrayIndex(&index)) { | 4067 if (object->IsJSObject() && name->AsArrayIndex(&index)) { |
4067 return GetOwnElementAttribute(object, index); | 4068 return GetOwnElementAttribute(object, index); |
4068 } | 4069 } |
4069 LookupIterator it(object, name, LookupIterator::CHECK_OWN); | 4070 LookupIterator it(object, name, LookupIterator::CHECK_HIDDEN); |
4070 return GetPropertyAttributes(&it); | 4071 return GetPropertyAttributes(&it); |
4071 } | 4072 } |
4072 | 4073 |
4073 | 4074 |
4074 Maybe<PropertyAttributes> JSReceiver::GetPropertyAttributes( | 4075 Maybe<PropertyAttributes> JSReceiver::GetPropertyAttributes( |
4075 LookupIterator* it) { | 4076 LookupIterator* it) { |
4076 for (; it->IsFound(); it->Next()) { | 4077 for (; it->IsFound(); it->Next()) { |
4077 switch (it->state()) { | 4078 switch (it->state()) { |
4078 case LookupIterator::NOT_FOUND: | 4079 case LookupIterator::NOT_FOUND: |
4079 UNREACHABLE(); | 4080 UNREACHABLE(); |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4767 if (inline_value->IsUndefined() || inline_value->IsSmi()) return; | 4768 if (inline_value->IsUndefined() || inline_value->IsSmi()) return; |
4768 | 4769 |
4769 Handle<ObjectHashTable> hashtable(ObjectHashTable::cast(inline_value)); | 4770 Handle<ObjectHashTable> hashtable(ObjectHashTable::cast(inline_value)); |
4770 bool was_present = false; | 4771 bool was_present = false; |
4771 ObjectHashTable::Remove(hashtable, key, &was_present); | 4772 ObjectHashTable::Remove(hashtable, key, &was_present); |
4772 } | 4773 } |
4773 | 4774 |
4774 | 4775 |
4775 bool JSObject::HasHiddenProperties(Handle<JSObject> object) { | 4776 bool JSObject::HasHiddenProperties(Handle<JSObject> object) { |
4776 Handle<Name> hidden = object->GetIsolate()->factory()->hidden_string(); | 4777 Handle<Name> hidden = object->GetIsolate()->factory()->hidden_string(); |
4777 LookupIterator it(object, hidden, LookupIterator::CHECK_OWN_REAL); | 4778 LookupIterator it(object, hidden, LookupIterator::CHECK_PROPERTY); |
4778 Maybe<PropertyAttributes> maybe = GetPropertyAttributes(&it); | 4779 Maybe<PropertyAttributes> maybe = GetPropertyAttributes(&it); |
4779 // Cannot get an exception since the hidden_string isn't accessible to JS. | 4780 // Cannot get an exception since the hidden_string isn't accessible to JS. |
4780 DCHECK(maybe.has_value); | 4781 DCHECK(maybe.has_value); |
4781 return maybe.value != ABSENT; | 4782 return maybe.value != ABSENT; |
4782 } | 4783 } |
4783 | 4784 |
4784 | 4785 |
4785 Object* JSObject::GetHiddenPropertiesHashTable() { | 4786 Object* JSObject::GetHiddenPropertiesHashTable() { |
4786 DCHECK(!IsJSGlobalProxy()); | 4787 DCHECK(!IsJSGlobalProxy()); |
4787 if (HasFastProperties()) { | 4788 if (HasFastProperties()) { |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5020 // ECMA-262, 3rd, 8.6.2.5 | 5021 // ECMA-262, 3rd, 8.6.2.5 |
5021 DCHECK(name->IsName()); | 5022 DCHECK(name->IsName()); |
5022 | 5023 |
5023 uint32_t index = 0; | 5024 uint32_t index = 0; |
5024 if (name->AsArrayIndex(&index)) { | 5025 if (name->AsArrayIndex(&index)) { |
5025 return DeleteElement(object, index, delete_mode); | 5026 return DeleteElement(object, index, delete_mode); |
5026 } | 5027 } |
5027 | 5028 |
5028 // Skip interceptors on FORCE_DELETION. | 5029 // Skip interceptors on FORCE_DELETION. |
5029 LookupIterator::Configuration config = | 5030 LookupIterator::Configuration config = |
5030 delete_mode == FORCE_DELETION ? LookupIterator::CHECK_HIDDEN_ACCESS | 5031 delete_mode == FORCE_DELETION |
5031 : LookupIterator::CHECK_OWN; | 5032 ? LookupIterator::CHECK_HIDDEN_SKIP_INTERCEPTOR |
| 5033 : LookupIterator::CHECK_HIDDEN; |
5032 | 5034 |
5033 LookupIterator it(object, name, config); | 5035 LookupIterator it(object, name, config); |
5034 | 5036 |
5035 bool is_observed = object->map()->is_observed() && | 5037 bool is_observed = object->map()->is_observed() && |
5036 *name != it.isolate()->heap()->hidden_string(); | 5038 *name != it.isolate()->heap()->hidden_string(); |
5037 | 5039 |
5038 for (; it.IsFound(); it.Next()) { | 5040 for (; it.IsFound(); it.Next()) { |
5039 switch (it.state()) { | 5041 switch (it.state()) { |
5040 case LookupIterator::NOT_FOUND: | 5042 case LookupIterator::NOT_FOUND: |
5041 case LookupIterator::JSPROXY: | 5043 case LookupIterator::JSPROXY: |
(...skipping 11636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16678 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16680 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16679 static const char* error_messages_[] = { | 16681 static const char* error_messages_[] = { |
16680 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16682 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16681 }; | 16683 }; |
16682 #undef ERROR_MESSAGES_TEXTS | 16684 #undef ERROR_MESSAGES_TEXTS |
16683 return error_messages_[reason]; | 16685 return error_messages_[reason]; |
16684 } | 16686 } |
16685 | 16687 |
16686 | 16688 |
16687 } } // namespace v8::internal | 16689 } } // namespace v8::internal |
OLD | NEW |