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 2993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3004 | 3004 |
3005 case LookupIterator::ACCESS_CHECK: | 3005 case LookupIterator::ACCESS_CHECK: |
3006 // TODO(verwaest): Remove the distinction. This is mostly bogus since we | 3006 // TODO(verwaest): Remove the distinction. This is mostly bogus since we |
3007 // don't know whether we'll want to fetch attributes or call a setter | 3007 // don't know whether we'll want to fetch attributes or call a setter |
3008 // until we find the property. | 3008 // until we find the property. |
3009 if (it->HasAccess(v8::ACCESS_SET)) break; | 3009 if (it->HasAccess(v8::ACCESS_SET)) break; |
3010 return JSObject::SetPropertyWithFailedAccessCheck(it, value, | 3010 return JSObject::SetPropertyWithFailedAccessCheck(it, value, |
3011 strict_mode); | 3011 strict_mode); |
3012 | 3012 |
3013 case LookupIterator::JSPROXY: | 3013 case LookupIterator::JSPROXY: |
3014 if (it->HolderIsReceiver()) { | 3014 if (it->HolderIsReceiverOrHiddenPrototype()) { |
3015 return JSProxy::SetPropertyWithHandler(it->GetHolder<JSProxy>(), | 3015 return JSProxy::SetPropertyWithHandler(it->GetHolder<JSProxy>(), |
3016 it->GetReceiver(), it->name(), | 3016 it->GetReceiver(), it->name(), |
3017 value, strict_mode); | 3017 value, strict_mode); |
3018 } else { | 3018 } else { |
3019 // TODO(verwaest): Use the MaybeHandle to indicate result. | 3019 // TODO(verwaest): Use the MaybeHandle to indicate result. |
3020 bool has_result = false; | 3020 bool has_result = false; |
3021 MaybeHandle<Object> maybe_result = | 3021 MaybeHandle<Object> maybe_result = |
3022 JSProxy::SetPropertyViaPrototypesWithHandler( | 3022 JSProxy::SetPropertyViaPrototypesWithHandler( |
3023 it->GetHolder<JSProxy>(), it->GetReceiver(), it->name(), | 3023 it->GetHolder<JSProxy>(), it->GetReceiver(), it->name(), |
3024 value, strict_mode, &has_result); | 3024 value, strict_mode, &has_result); |
3025 if (has_result) return maybe_result; | 3025 if (has_result) return maybe_result; |
3026 done = true; | 3026 done = true; |
3027 } | 3027 } |
3028 break; | 3028 break; |
3029 | 3029 |
3030 case LookupIterator::INTERCEPTOR: | 3030 case LookupIterator::INTERCEPTOR: |
3031 if (it->HolderIsReceiver()) { | 3031 if (it->HolderIsReceiverOrHiddenPrototype()) { |
3032 MaybeHandle<Object> maybe_result = | 3032 MaybeHandle<Object> maybe_result = |
3033 JSObject::SetPropertyWithInterceptor(it, value); | 3033 JSObject::SetPropertyWithInterceptor(it, value); |
3034 if (!maybe_result.is_null()) return maybe_result; | 3034 if (!maybe_result.is_null()) return maybe_result; |
3035 if (it->isolate()->has_pending_exception()) return maybe_result; | 3035 if (it->isolate()->has_pending_exception()) return maybe_result; |
3036 } else { | 3036 } else { |
3037 Maybe<PropertyAttributes> maybe_attributes = | 3037 Maybe<PropertyAttributes> maybe_attributes = |
3038 JSObject::GetPropertyAttributesWithInterceptor( | 3038 JSObject::GetPropertyAttributesWithInterceptor( |
3039 it->GetHolder<JSObject>(), it->GetReceiver(), it->name()); | 3039 it->GetHolder<JSObject>(), it->GetReceiver(), it->name()); |
3040 if (!maybe_attributes.has_value) return MaybeHandle<Object>(); | 3040 if (!maybe_attributes.has_value) return MaybeHandle<Object>(); |
3041 done = maybe_attributes.value != ABSENT; | 3041 done = maybe_attributes.value != ABSENT; |
3042 if (done && (maybe_attributes.value & READ_ONLY) != 0) { | 3042 if (done && (maybe_attributes.value & READ_ONLY) != 0) { |
3043 return WriteToReadOnlyProperty(it, value, strict_mode); | 3043 return WriteToReadOnlyProperty(it, value, strict_mode); |
3044 } | 3044 } |
3045 } | 3045 } |
3046 break; | 3046 break; |
3047 | 3047 |
3048 case LookupIterator::PROPERTY: | 3048 case LookupIterator::PROPERTY: |
3049 if (!it->HasProperty()) break; | 3049 if (!it->HasProperty()) break; |
3050 if (it->property_details().IsReadOnly()) { | 3050 if (it->property_details().IsReadOnly()) { |
3051 return WriteToReadOnlyProperty(it, value, strict_mode); | 3051 return WriteToReadOnlyProperty(it, value, strict_mode); |
3052 } | 3052 } |
3053 switch (it->property_kind()) { | 3053 switch (it->property_kind()) { |
3054 case LookupIterator::ACCESSOR: | 3054 case LookupIterator::ACCESSOR: |
3055 if (it->HolderIsReceiver() || | 3055 if (it->HolderIsReceiverOrHiddenPrototype() || |
3056 !it->GetAccessors()->IsDeclaredAccessorInfo()) { | 3056 !it->GetAccessors()->IsDeclaredAccessorInfo()) { |
3057 return SetPropertyWithAccessor(it->GetReceiver(), it->name(), | 3057 return SetPropertyWithAccessor(it->GetReceiver(), it->name(), |
3058 value, it->GetHolder<JSObject>(), | 3058 value, it->GetHolder<JSObject>(), |
3059 it->GetAccessors(), strict_mode); | 3059 it->GetAccessors(), strict_mode); |
3060 } | 3060 } |
3061 break; | 3061 break; |
3062 case LookupIterator::DATA: | 3062 case LookupIterator::DATA: |
3063 if (it->HolderIsReceiver()) return SetDataProperty(it, value); | 3063 if (it->HolderIsReceiverOrHiddenPrototype()) { |
| 3064 return SetDataProperty(it, value); |
| 3065 } |
3064 } | 3066 } |
3065 done = true; | 3067 done = true; |
3066 break; | 3068 break; |
3067 } | 3069 } |
3068 | 3070 |
3069 if (done) break; | 3071 if (done) break; |
3070 } | 3072 } |
3071 | 3073 |
3072 return AddDataProperty(it, value, NONE, strict_mode, store_mode); | 3074 return AddDataProperty(it, value, NONE, strict_mode, store_mode); |
3073 } | 3075 } |
(...skipping 11 matching lines...) Expand all Loading... |
3085 } | 3087 } |
3086 | 3088 |
3087 | 3089 |
3088 MaybeHandle<Object> Object::SetDataProperty(LookupIterator* it, | 3090 MaybeHandle<Object> Object::SetDataProperty(LookupIterator* it, |
3089 Handle<Object> value) { | 3091 Handle<Object> value) { |
3090 // Proxies are handled on the WithHandler path. Other non-JSObjects cannot | 3092 // Proxies are handled on the WithHandler path. Other non-JSObjects cannot |
3091 // have own properties. | 3093 // have own properties. |
3092 Handle<JSObject> receiver = Handle<JSObject>::cast(it->GetReceiver()); | 3094 Handle<JSObject> receiver = Handle<JSObject>::cast(it->GetReceiver()); |
3093 | 3095 |
3094 // Store on the holder which may be hidden behind the receiver. | 3096 // Store on the holder which may be hidden behind the receiver. |
3095 ASSERT(it->HolderIsReceiver()); | 3097 ASSERT(it->HolderIsReceiverOrHiddenPrototype()); |
3096 | 3098 |
3097 // Old value for the observation change record. | 3099 // Old value for the observation change record. |
3098 // Fetch before transforming the object since the encoding may become | 3100 // Fetch before transforming the object since the encoding may become |
3099 // incompatible with what's cached in |it|. | 3101 // incompatible with what's cached in |it|. |
3100 bool is_observed = | 3102 bool is_observed = |
3101 receiver->map()->is_observed() && | 3103 receiver->map()->is_observed() && |
3102 !it->name().is_identical_to(it->factory()->hidden_string()); | 3104 !it->name().is_identical_to(it->factory()->hidden_string()); |
3103 MaybeHandle<Object> maybe_old; | 3105 MaybeHandle<Object> maybe_old; |
3104 if (is_observed) maybe_old = it->GetDataValue(); | 3106 if (is_observed) maybe_old = it->GetDataValue(); |
3105 | 3107 |
(...skipping 13910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17016 #define ERROR_MESSAGES_TEXTS(C, T) T, | 17018 #define ERROR_MESSAGES_TEXTS(C, T) T, |
17017 static const char* error_messages_[] = { | 17019 static const char* error_messages_[] = { |
17018 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 17020 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
17019 }; | 17021 }; |
17020 #undef ERROR_MESSAGES_TEXTS | 17022 #undef ERROR_MESSAGES_TEXTS |
17021 return error_messages_[reason]; | 17023 return error_messages_[reason]; |
17022 } | 17024 } |
17023 | 17025 |
17024 | 17026 |
17025 } } // namespace v8::internal | 17027 } } // namespace v8::internal |
OLD | NEW |