 Chromium Code Reviews
 Chromium Code Reviews Issue 934463003:
  super.property store  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master
    
  
    Issue 934463003:
  super.property store  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master| 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 <sstream> | 5 #include <sstream> | 
| 6 | 6 | 
| 7 #include "src/v8.h" | 7 #include "src/v8.h" | 
| 8 | 8 | 
| 9 #include "src/accessors.h" | 9 #include "src/accessors.h" | 
| 10 #include "src/allocation-site-scopes.h" | 10 #include "src/allocation-site-scopes.h" | 
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 284 MaybeHandle<Object> Object::GetPropertyWithAccessor(Handle<Object> receiver, | 284 MaybeHandle<Object> Object::GetPropertyWithAccessor(Handle<Object> receiver, | 
| 285 Handle<Name> name, | 285 Handle<Name> name, | 
| 286 Handle<JSObject> holder, | 286 Handle<JSObject> holder, | 
| 287 Handle<Object> structure) { | 287 Handle<Object> structure) { | 
| 288 Isolate* isolate = name->GetIsolate(); | 288 Isolate* isolate = name->GetIsolate(); | 
| 289 DCHECK(!structure->IsForeign()); | 289 DCHECK(!structure->IsForeign()); | 
| 290 // api style callbacks. | 290 // api style callbacks. | 
| 291 if (structure->IsAccessorInfo()) { | 291 if (structure->IsAccessorInfo()) { | 
| 292 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure); | 292 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure); | 
| 293 if (!info->IsCompatibleReceiver(*receiver)) { | 293 if (!info->IsCompatibleReceiver(*receiver)) { | 
| 294 Handle<Object> args[2] = { name, receiver }; | 294 Handle<Object> args[] = {name, receiver}; | 
| 295 THROW_NEW_ERROR(isolate, | 295 THROW_NEW_ERROR(isolate, | 
| 296 NewTypeError("incompatible_method_receiver", | 296 NewTypeError("incompatible_method_receiver", | 
| 297 HandleVector(args, arraysize(args))), | 297 HandleVector(args, arraysize(args))), | 
| 298 Object); | 298 Object); | 
| 299 } | 299 } | 
| 300 | 300 | 
| 301 Handle<ExecutableAccessorInfo> data = | 301 Handle<ExecutableAccessorInfo> data = | 
| 302 Handle<ExecutableAccessorInfo>::cast(structure); | 302 Handle<ExecutableAccessorInfo>::cast(structure); | 
| 303 v8::AccessorNameGetterCallback call_fun = | 303 v8::AccessorNameGetterCallback call_fun = | 
| 304 v8::ToCData<v8::AccessorNameGetterCallback>(data->getter()); | 304 v8::ToCData<v8::AccessorNameGetterCallback>(data->getter()); | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 | 349 | 
| 350 // We should never get here to initialize a const with the hole | 350 // We should never get here to initialize a const with the hole | 
| 351 // value since a const declaration would conflict with the setter. | 351 // value since a const declaration would conflict with the setter. | 
| 352 DCHECK(!structure->IsForeign()); | 352 DCHECK(!structure->IsForeign()); | 
| 353 if (structure->IsExecutableAccessorInfo()) { | 353 if (structure->IsExecutableAccessorInfo()) { | 
| 354 // Don't call executable accessor setters with non-JSObject receivers. | 354 // Don't call executable accessor setters with non-JSObject receivers. | 
| 355 if (!receiver->IsJSObject()) return value; | 355 if (!receiver->IsJSObject()) return value; | 
| 356 // api style callbacks | 356 // api style callbacks | 
| 357 ExecutableAccessorInfo* info = ExecutableAccessorInfo::cast(*structure); | 357 ExecutableAccessorInfo* info = ExecutableAccessorInfo::cast(*structure); | 
| 358 if (!info->IsCompatibleReceiver(*receiver)) { | 358 if (!info->IsCompatibleReceiver(*receiver)) { | 
| 359 Handle<Object> args[2] = { name, receiver }; | 359 Handle<Object> args[] = {name, receiver}; | 
| 360 THROW_NEW_ERROR(isolate, | 360 THROW_NEW_ERROR(isolate, | 
| 361 NewTypeError("incompatible_method_receiver", | 361 NewTypeError("incompatible_method_receiver", | 
| 362 HandleVector(args, arraysize(args))), | 362 HandleVector(args, arraysize(args))), | 
| 363 Object); | 363 Object); | 
| 364 } | 364 } | 
| 365 Object* call_obj = info->setter(); | 365 Object* call_obj = info->setter(); | 
| 366 v8::AccessorNameSetterCallback call_fun = | 366 v8::AccessorNameSetterCallback call_fun = | 
| 367 v8::ToCData<v8::AccessorNameSetterCallback>(call_obj); | 367 v8::ToCData<v8::AccessorNameSetterCallback>(call_obj); | 
| 368 if (call_fun == NULL) return value; | 368 if (call_fun == NULL) return value; | 
| 369 LOG(isolate, ApiNamedPropertyAccess("store", *holder, *name)); | 369 LOG(isolate, ApiNamedPropertyAccess("store", *holder, *name)); | 
| 370 PropertyCallbackArguments args(isolate, info->data(), *receiver, *holder); | 370 PropertyCallbackArguments args(isolate, info->data(), *receiver, *holder); | 
| 371 args.Call(call_fun, | 371 args.Call(call_fun, | 
| 372 v8::Utils::ToLocal(name), | 372 v8::Utils::ToLocal(name), | 
| 373 v8::Utils::ToLocal(value)); | 373 v8::Utils::ToLocal(value)); | 
| 374 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | 374 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | 
| 375 return value; | 375 return value; | 
| 376 } | 376 } | 
| 377 | 377 | 
| 378 if (structure->IsAccessorPair()) { | 378 if (structure->IsAccessorPair()) { | 
| 379 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); | 379 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); | 
| 380 if (setter->IsSpecFunction()) { | 380 if (setter->IsSpecFunction()) { | 
| 381 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 381 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 
| 382 return SetPropertyWithDefinedSetter( | 382 return SetPropertyWithDefinedSetter( | 
| 383 receiver, Handle<JSReceiver>::cast(setter), value); | 383 receiver, Handle<JSReceiver>::cast(setter), value); | 
| 384 } else { | 384 } else { | 
| 385 if (is_sloppy(language_mode)) return value; | 385 if (is_sloppy(language_mode)) return value; | 
| 386 Handle<Object> args[2] = { name, holder }; | 386 Handle<Object> args[] = {name, holder}; | 
| 387 THROW_NEW_ERROR( | 387 THROW_NEW_ERROR(isolate, | 
| 388 isolate, NewTypeError("no_setter_in_callback", HandleVector(args, 2)), | 388 NewTypeError("no_setter_in_callback", | 
| 389 Object); | 389 HandleVector(args, arraysize(args))), | 
| 390 Object); | |
| 390 } | 391 } | 
| 391 } | 392 } | 
| 392 | 393 | 
| 393 UNREACHABLE(); | 394 UNREACHABLE(); | 
| 394 return MaybeHandle<Object>(); | 395 return MaybeHandle<Object>(); | 
| 395 } | 396 } | 
| 396 | 397 | 
| 397 | 398 | 
| 398 MaybeHandle<Object> Object::GetPropertyWithDefinedGetter( | 399 MaybeHandle<Object> Object::GetPropertyWithDefinedGetter( | 
| 399 Handle<Object> receiver, | 400 Handle<Object> receiver, | 
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 748 } | 749 } | 
| 749 } | 750 } | 
| 750 | 751 | 
| 751 if (!receiver->IsJSObject()) { | 752 if (!receiver->IsJSObject()) { | 
| 752 return WriteToReadOnlyElement(isolate, receiver, index, value, | 753 return WriteToReadOnlyElement(isolate, receiver, index, value, | 
| 753 language_mode); | 754 language_mode); | 
| 754 } | 755 } | 
| 755 Handle<JSObject> target = Handle<JSObject>::cast(receiver); | 756 Handle<JSObject> target = Handle<JSObject>::cast(receiver); | 
| 756 ElementsAccessor* accessor = target->GetElementsAccessor(); | 757 ElementsAccessor* accessor = target->GetElementsAccessor(); | 
| 757 PropertyAttributes attrs = accessor->GetAttributes(receiver, target, index); | 758 PropertyAttributes attrs = accessor->GetAttributes(receiver, target, index); | 
| 758 if ((attrs & READ_ONLY) != 0) { | 759 if (attrs == ABSENT) { | 
| 759 return WriteToReadOnlyElement(isolate, receiver, index, value, | 760 return JSObject::SetElement(target, index, value, NONE, language_mode, | 
| 760 language_mode); | 761 false); | 
| 761 } | 762 } | 
| 762 PropertyAttributes new_attrs = attrs != ABSENT ? attrs : NONE; | 763 return JSObject::SetElement(target, index, value, attrs, language_mode, false, | 
| 763 return JSObject::SetElement(target, index, value, new_attrs, language_mode, | 764 DEFINE_PROPERTY); | 
| 764 false); | |
| 765 } | 765 } | 
| 766 | 766 | 
| 767 | 767 | 
| 768 Map* Object::GetRootMap(Isolate* isolate) { | 768 Map* Object::GetRootMap(Isolate* isolate) { | 
| 769 DisallowHeapAllocation no_alloc; | 769 DisallowHeapAllocation no_alloc; | 
| 770 if (IsSmi()) { | 770 if (IsSmi()) { | 
| 771 Context* context = isolate->context()->native_context(); | 771 Context* context = isolate->context()->native_context(); | 
| 772 return context->number_function()->initial_map(); | 772 return context->number_function()->initial_map(); | 
| 773 } | 773 } | 
| 774 | 774 | 
| (...skipping 2267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3042 | 3042 | 
| 3043 MaybeHandle<Object> Object::SetProperty(Handle<Object> object, | 3043 MaybeHandle<Object> Object::SetProperty(Handle<Object> object, | 
| 3044 Handle<Name> name, Handle<Object> value, | 3044 Handle<Name> name, Handle<Object> value, | 
| 3045 LanguageMode language_mode, | 3045 LanguageMode language_mode, | 
| 3046 StoreFromKeyed store_mode) { | 3046 StoreFromKeyed store_mode) { | 
| 3047 LookupIterator it(object, name); | 3047 LookupIterator it(object, name); | 
| 3048 return SetProperty(&it, value, language_mode, store_mode); | 3048 return SetProperty(&it, value, language_mode, store_mode); | 
| 3049 } | 3049 } | 
| 3050 | 3050 | 
| 3051 | 3051 | 
| 3052 MaybeHandle<Object> Object::SetProperty(LookupIterator* it, | 3052 MaybeHandle<Object> Object::SetPropertyInternal(LookupIterator* it, | 
| 3053 Handle<Object> value, | 3053 Handle<Object> value, | 
| 3054 LanguageMode language_mode, | 3054 LanguageMode language_mode, | 
| 3055 StoreFromKeyed store_mode, | 3055 StoreFromKeyed store_mode, | 
| 3056 StorePropertyMode data_store_mode) { | 3056 bool* found) { | 
| 3057 // Make sure that the top context does not change when doing callbacks or | 3057 // Make sure that the top context does not change when doing callbacks or | 
| 3058 // interceptor calls. | 3058 // interceptor calls. | 
| 3059 AssertNoContextChange ncc(it->isolate()); | 3059 AssertNoContextChange ncc(it->isolate()); | 
| 3060 | 3060 | 
| 3061 *found = true; | |
| 3062 | |
| 3061 bool done = false; | 3063 bool done = false; | 
| 3062 for (; it->IsFound(); it->Next()) { | 3064 for (; it->IsFound(); it->Next()) { | 
| 3063 switch (it->state()) { | 3065 switch (it->state()) { | 
| 3064 case LookupIterator::NOT_FOUND: | 3066 case LookupIterator::NOT_FOUND: | 
| 3065 UNREACHABLE(); | 3067 UNREACHABLE(); | 
| 3066 | 3068 | 
| 3067 case LookupIterator::ACCESS_CHECK: | 3069 case LookupIterator::ACCESS_CHECK: | 
| 3068 // TODO(verwaest): Remove the distinction. This is mostly bogus since we | 3070 // TODO(verwaest): Remove the distinction. This is mostly bogus since we | 
| 3069 // don't know whether we'll want to fetch attributes or call a setter | 3071 // don't know whether we'll want to fetch attributes or call a setter | 
| 3070 // until we find the property. | 3072 // until we find the property. | 
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3130 break; | 3132 break; | 
| 3131 } | 3133 } | 
| 3132 | 3134 | 
| 3133 if (done) break; | 3135 if (done) break; | 
| 3134 } | 3136 } | 
| 3135 | 3137 | 
| 3136 // If the receiver is the JSGlobalObject, the store was contextual. In case | 3138 // If the receiver is the JSGlobalObject, the store was contextual. In case | 
| 3137 // the property did not exist yet on the global object itself, we have to | 3139 // the property did not exist yet on the global object itself, we have to | 
| 3138 // throw a reference error in strict mode. | 3140 // throw a reference error in strict mode. | 
| 3139 if (it->GetReceiver()->IsJSGlobalObject() && is_strict(language_mode)) { | 3141 if (it->GetReceiver()->IsJSGlobalObject() && is_strict(language_mode)) { | 
| 3140 Handle<Object> args[1] = {it->name()}; | 3142 Handle<Object> args[] = {it->name()}; | 
| 3141 THROW_NEW_ERROR(it->isolate(), | 3143 THROW_NEW_ERROR( | 
| 3142 NewReferenceError("not_defined", HandleVector(args, 1)), | 3144 it->isolate(), | 
| 3143 Object); | 3145 NewReferenceError("not_defined", HandleVector(args, arraysize(args))), | 
| 3146 Object); | |
| 3144 } | 3147 } | 
| 3145 | 3148 | 
| 3146 if (data_store_mode == SUPER_PROPERTY) { | 3149 *found = false; | 
| 3147 LookupIterator own_lookup(it->GetReceiver(), it->name(), | 3150 return MaybeHandle<Object>(); | 
| 3148 LookupIterator::OWN); | 3151 } | 
| 3149 | 3152 | 
| 3150 return JSObject::SetProperty(&own_lookup, value, language_mode, store_mode, | 3153 | 
| 3151 NORMAL_PROPERTY); | 3154 MaybeHandle<Object> Object::SetProperty(LookupIterator* it, | 
| 3155 Handle<Object> value, | |
| 3156 LanguageMode language_mode, | |
| 3157 StoreFromKeyed store_mode) { | |
| 3158 bool found = false; | |
| 3159 MaybeHandle<Object> result = | |
| 3160 SetPropertyInternal(it, value, language_mode, store_mode, &found); | |
| 3161 if (found) return result; | |
| 3162 return AddDataProperty(it, value, NONE, language_mode, store_mode); | |
| 3163 } | |
| 3164 | |
| 3165 | |
| 3166 MaybeHandle<Object> Object::SetSuperProperty(LookupIterator* it, | |
| 3167 Handle<Object> value, | |
| 3168 LanguageMode language_mode, | |
| 3169 StoreFromKeyed store_mode) { | |
| 3170 bool found = false; | |
| 3171 MaybeHandle<Object> result = | |
| 3172 SetPropertyInternal(it, value, language_mode, store_mode, &found); | |
| 3173 if (found) return result; | |
| 3174 | |
| 3175 LookupIterator own_lookup(it->GetReceiver(), it->name(), LookupIterator::OWN); | |
| 3176 PropertyDetails details = own_lookup.property_details(); | |
| 3177 | |
| 3178 switch (own_lookup.state()) { | |
| 3179 case LookupIterator::NOT_FOUND: | |
| 3180 return JSObject::AddDataProperty(&own_lookup, value, NONE, language_mode, | |
| 3181 store_mode); | |
| 3182 | |
| 3183 case LookupIterator::DATA: | |
| 3184 if (details.IsConfigurable() || !details.IsReadOnly()) { | |
| 3185 return JSObject::SetOwnPropertyIgnoreAttributes( | |
| 3186 Handle<JSObject>::cast(it->GetReceiver()), it->name(), value, | |
| 3187 details.attributes()); | |
| 3188 } | |
| 3189 return WriteToReadOnlyProperty(&own_lookup, value, language_mode); | |
| 3190 | |
| 3191 | |
| 
adamk
2015/02/18 18:39:07
Nit: extra blank line?
 | |
| 3192 case LookupIterator::ACCESSOR: | |
| 3193 if (details.IsConfigurable()) { | |
| 3194 return JSObject::SetOwnPropertyIgnoreAttributes( | |
| 3195 Handle<JSObject>::cast(it->GetReceiver()), it->name(), value, | |
| 3196 details.attributes()); | |
| 3197 } | |
| 3198 | |
| 3199 return RedefineNonconfigurableProperty(it->isolate(), it->name(), value, | |
| 3200 language_mode); | |
| 3201 | |
| 3202 | |
| 
adamk
2015/02/18 18:39:07
Ditto
 | |
| 3203 case LookupIterator::INTERCEPTOR: | |
| 3204 case LookupIterator::JSPROXY: | |
| 3205 case LookupIterator::ACCESS_CHECK: | |
| 3206 case LookupIterator::TRANSITION: { | |
| 3207 bool found = false; | |
| 3208 MaybeHandle<Object> result = SetPropertyInternal( | |
| 3209 &own_lookup, value, language_mode, store_mode, &found); | |
| 3210 if (found) return result; | |
| 3211 return SetDataProperty(&own_lookup, value); | |
| 3212 } | |
| 3152 } | 3213 } | 
| 3153 | 3214 | 
| 3154 return AddDataProperty(it, value, NONE, language_mode, store_mode); | 3215 UNREACHABLE(); | 
| 3216 return MaybeHandle<Object>(); | |
| 3155 } | 3217 } | 
| 3156 | 3218 | 
| 3157 | 3219 | 
| 3158 MaybeHandle<Object> Object::WriteToReadOnlyProperty( | 3220 MaybeHandle<Object> Object::WriteToReadOnlyProperty( | 
| 3159 LookupIterator* it, Handle<Object> value, LanguageMode language_mode) { | 3221 LookupIterator* it, Handle<Object> value, LanguageMode language_mode) { | 
| 3222 return WriteToReadOnlyProperty(it->isolate(), it->GetReceiver(), it->name(), | |
| 3223 value, language_mode); | |
| 3224 } | |
| 3225 | |
| 3226 | |
| 3227 MaybeHandle<Object> Object::WriteToReadOnlyProperty( | |
| 3228 Isolate* isolate, Handle<Object> receiver, Handle<Object> name, | |
| 3229 Handle<Object> value, LanguageMode language_mode) { | |
| 3160 if (is_sloppy(language_mode)) return value; | 3230 if (is_sloppy(language_mode)) return value; | 
| 3161 | 3231 Handle<Object> args[] = {name, receiver}; | 
| 3162 Handle<Object> args[] = {it->name(), it->GetReceiver()}; | 3232 THROW_NEW_ERROR(isolate, NewTypeError("strict_read_only_property", | 
| 3163 THROW_NEW_ERROR(it->isolate(), | 3233 HandleVector(args, arraysize(args))), | 
| 3164 NewTypeError("strict_read_only_property", | |
| 3165 HandleVector(args, arraysize(args))), | |
| 3166 Object); | 3234 Object); | 
| 3167 } | 3235 } | 
| 3168 | 3236 | 
| 3169 | 3237 | 
| 3170 MaybeHandle<Object> Object::WriteToReadOnlyElement(Isolate* isolate, | 3238 MaybeHandle<Object> Object::WriteToReadOnlyElement(Isolate* isolate, | 
| 3171 Handle<Object> receiver, | 3239 Handle<Object> receiver, | 
| 3172 uint32_t index, | 3240 uint32_t index, | 
| 3173 Handle<Object> value, | 3241 Handle<Object> value, | 
| 3174 LanguageMode language_mode) { | 3242 LanguageMode language_mode) { | 
| 3243 return WriteToReadOnlyProperty(isolate, receiver, | |
| 3244 isolate->factory()->NewNumberFromUint(index), | |
| 3245 value, language_mode); | |
| 3246 } | |
| 3247 | |
| 3248 | |
| 3249 MaybeHandle<Object> Object::RedefineNonconfigurableProperty( | |
| 3250 Isolate* isolate, Handle<Object> name, Handle<Object> value, | |
| 3251 LanguageMode language_mode) { | |
| 3175 if (is_sloppy(language_mode)) return value; | 3252 if (is_sloppy(language_mode)) return value; | 
| 3176 | 3253 Handle<Object> args[] = {name}; | 
| 3177 Handle<Object> args[] = {isolate->factory()->NewNumberFromUint(index), | 3254 THROW_NEW_ERROR(isolate, NewTypeError("redefine_disallowed", | 
| 3178 receiver}; | |
| 3179 THROW_NEW_ERROR(isolate, NewTypeError("strict_read_only_property", | |
| 3180 HandleVector(args, arraysize(args))), | 3255 HandleVector(args, arraysize(args))), | 
| 3181 Object); | 3256 Object); | 
| 3182 } | 3257 } | 
| 3183 | 3258 | 
| 3184 | 3259 | 
| 3185 MaybeHandle<Object> Object::SetDataProperty(LookupIterator* it, | 3260 MaybeHandle<Object> Object::SetDataProperty(LookupIterator* it, | 
| 3186 Handle<Object> value) { | 3261 Handle<Object> value) { | 
| 3187 // Proxies are handled on the WithHandler path. Other non-JSObjects cannot | 3262 // Proxies are handled on the WithHandler path. Other non-JSObjects cannot | 
| 3188 // have own properties. | 3263 // have own properties. | 
| 3189 Handle<JSObject> receiver = Handle<JSObject>::cast(it->GetReceiver()); | 3264 Handle<JSObject> receiver = Handle<JSObject>::cast(it->GetReceiver()); | 
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3238 // If the receiver is Indexed Exotic object (currently only typed arrays), | 3313 // If the receiver is Indexed Exotic object (currently only typed arrays), | 
| 3239 // disallow adding properties with numeric names. | 3314 // disallow adding properties with numeric names. | 
| 3240 if (it->IsSpecialNumericIndex()) return value; | 3315 if (it->IsSpecialNumericIndex()) return value; | 
| 3241 | 3316 | 
| 3242 // Possibly migrate to the most up-to-date map that will be able to store | 3317 // Possibly migrate to the most up-to-date map that will be able to store | 
| 3243 // |value| under it->name() with |attributes|. | 3318 // |value| under it->name() with |attributes|. | 
| 3244 it->PrepareTransitionToDataProperty(value, attributes, store_mode); | 3319 it->PrepareTransitionToDataProperty(value, attributes, store_mode); | 
| 3245 if (it->state() != LookupIterator::TRANSITION) { | 3320 if (it->state() != LookupIterator::TRANSITION) { | 
| 3246 if (is_sloppy(language_mode)) return value; | 3321 if (is_sloppy(language_mode)) return value; | 
| 3247 | 3322 | 
| 3248 Handle<Object> args[1] = {it->name()}; | 3323 Handle<Object> args[] = {it->name()}; | 
| 3249 THROW_NEW_ERROR(it->isolate(), | 3324 THROW_NEW_ERROR(it->isolate(), | 
| 3250 NewTypeError("object_not_extensible", | 3325 NewTypeError("object_not_extensible", | 
| 3251 HandleVector(args, arraysize(args))), | 3326 HandleVector(args, arraysize(args))), | 
| 3252 Object); | 3327 Object); | 
| 3253 } | 3328 } | 
| 3254 it->ApplyTransitionToDataProperty(); | 3329 it->ApplyTransitionToDataProperty(); | 
| 3255 | 3330 | 
| 3256 // TODO(verwaest): Encapsulate dictionary handling better. | 3331 // TODO(verwaest): Encapsulate dictionary handling better. | 
| 3257 if (receiver->map()->is_dictionary_map()) { | 3332 if (receiver->map()->is_dictionary_map()) { | 
| 3258 // TODO(verwaest): Probably should ensure this is done beforehand. | 3333 // TODO(verwaest): Probably should ensure this is done beforehand. | 
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3784 Object::GetProperty(desc, hasWritable_name).ToHandleChecked(); | 3859 Object::GetProperty(desc, hasWritable_name).ToHandleChecked(); | 
| 3785 DCHECK(hasWritable->IsBoolean()); | 3860 DCHECK(hasWritable->IsBoolean()); | 
| 3786 if (hasWritable->IsTrue()) { | 3861 if (hasWritable->IsTrue()) { | 
| 3787 Handle<String> writable_name = isolate->factory()->InternalizeOneByteString( | 3862 Handle<String> writable_name = isolate->factory()->InternalizeOneByteString( | 
| 3788 STATIC_CHAR_VECTOR("writable_")); | 3863 STATIC_CHAR_VECTOR("writable_")); | 
| 3789 Handle<Object> writable = | 3864 Handle<Object> writable = | 
| 3790 Object::GetProperty(desc, writable_name).ToHandleChecked(); | 3865 Object::GetProperty(desc, writable_name).ToHandleChecked(); | 
| 3791 DCHECK(writable->IsBoolean()); | 3866 DCHECK(writable->IsBoolean()); | 
| 3792 *done = writable->IsFalse(); | 3867 *done = writable->IsFalse(); | 
| 3793 if (!*done) return isolate->factory()->the_hole_value(); | 3868 if (!*done) return isolate->factory()->the_hole_value(); | 
| 3794 if (is_sloppy(language_mode)) return value; | 3869 return WriteToReadOnlyProperty(isolate, receiver, name, value, | 
| 3795 Handle<Object> args[] = { name, receiver }; | 3870 language_mode); | 
| 3796 THROW_NEW_ERROR(isolate, NewTypeError("strict_read_only_property", | |
| 3797 HandleVector(args, arraysize(args))), | |
| 3798 Object); | |
| 3799 } | 3871 } | 
| 3800 | 3872 | 
| 3801 // We have an AccessorDescriptor. | 3873 // We have an AccessorDescriptor. | 
| 3802 Handle<String> set_name = | 3874 Handle<String> set_name = | 
| 3803 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("set_")); | 3875 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("set_")); | 
| 3804 Handle<Object> setter = Object::GetProperty(desc, set_name).ToHandleChecked(); | 3876 Handle<Object> setter = Object::GetProperty(desc, set_name).ToHandleChecked(); | 
| 3805 if (!setter->IsUndefined()) { | 3877 if (!setter->IsUndefined()) { | 
| 3806 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 3878 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 
| 3807 return SetPropertyWithDefinedSetter( | 3879 return SetPropertyWithDefinedSetter( | 
| 3808 receiver, Handle<JSReceiver>::cast(setter), value); | 3880 receiver, Handle<JSReceiver>::cast(setter), value); | 
| (...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5147 !isolate->MayIndexedAccess(object, index, v8::ACCESS_DELETE)) { | 5219 !isolate->MayIndexedAccess(object, index, v8::ACCESS_DELETE)) { | 
| 5148 isolate->ReportFailedAccessCheck(object, v8::ACCESS_DELETE); | 5220 isolate->ReportFailedAccessCheck(object, v8::ACCESS_DELETE); | 
| 5149 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | 5221 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | 
| 5150 return factory->false_value(); | 5222 return factory->false_value(); | 
| 5151 } | 5223 } | 
| 5152 | 5224 | 
| 5153 if (object->IsStringObjectWithCharacterAt(index)) { | 5225 if (object->IsStringObjectWithCharacterAt(index)) { | 
| 5154 if (is_strict(language_mode)) { | 5226 if (is_strict(language_mode)) { | 
| 5155 // Deleting a non-configurable property in strict mode. | 5227 // Deleting a non-configurable property in strict mode. | 
| 5156 Handle<Object> name = factory->NewNumberFromUint(index); | 5228 Handle<Object> name = factory->NewNumberFromUint(index); | 
| 5157 Handle<Object> args[2] = { name, object }; | 5229 Handle<Object> args[] = {name, object}; | 
| 5158 THROW_NEW_ERROR(isolate, NewTypeError("strict_delete_property", | 5230 THROW_NEW_ERROR(isolate, | 
| 5159 HandleVector(args, 2)), | 5231 NewTypeError("strict_delete_property", | 
| 5232 HandleVector(args, arraysize(args))), | |
| 5160 Object); | 5233 Object); | 
| 5161 } | 5234 } | 
| 5162 return factory->false_value(); | 5235 return factory->false_value(); | 
| 5163 } | 5236 } | 
| 5164 | 5237 | 
| 5165 if (object->IsJSGlobalProxy()) { | 5238 if (object->IsJSGlobalProxy()) { | 
| 5166 PrototypeIterator iter(isolate, object); | 5239 PrototypeIterator iter(isolate, object); | 
| 5167 if (iter.IsAtEnd()) return factory->false_value(); | 5240 if (iter.IsAtEnd()) return factory->false_value(); | 
| 5168 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); | 5241 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); | 
| 5169 return DeleteElement( | 5242 return DeleteElement( | 
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5280 } | 5353 } | 
| 5281 case LookupIterator::DATA: | 5354 case LookupIterator::DATA: | 
| 5282 if (is_observed) { | 5355 if (is_observed) { | 
| 5283 old_value = it.GetDataValue(); | 5356 old_value = it.GetDataValue(); | 
| 5284 } | 5357 } | 
| 5285 // Fall through. | 5358 // Fall through. | 
| 5286 case LookupIterator::ACCESSOR: { | 5359 case LookupIterator::ACCESSOR: { | 
| 5287 if (!it.IsConfigurable()) { | 5360 if (!it.IsConfigurable()) { | 
| 5288 // Fail if the property is not configurable. | 5361 // Fail if the property is not configurable. | 
| 5289 if (is_strict(language_mode)) { | 5362 if (is_strict(language_mode)) { | 
| 5290 Handle<Object> args[2] = {name, object}; | 5363 Handle<Object> args[] = {name, object}; | 
| 5291 THROW_NEW_ERROR(it.isolate(), | 5364 THROW_NEW_ERROR(it.isolate(), | 
| 5292 NewTypeError("strict_delete_property", | 5365 NewTypeError("strict_delete_property", | 
| 5293 HandleVector(args, arraysize(args))), | 5366 HandleVector(args, arraysize(args))), | 
| 5294 Object); | 5367 Object); | 
| 5295 } | 5368 } | 
| 5296 return it.isolate()->factory()->false_value(); | 5369 return it.isolate()->factory()->false_value(); | 
| 5297 } | 5370 } | 
| 5298 | 5371 | 
| 5299 PropertyNormalizationMode mode = object->map()->is_prototype_map() | 5372 PropertyNormalizationMode mode = object->map()->is_prototype_map() | 
| 5300 ? KEEP_INOBJECT_PROPERTIES | 5373 ? KEEP_INOBJECT_PROPERTIES | 
| (...skipping 7337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12638 | 12711 | 
| 12639 if (structure->IsAccessorPair()) { | 12712 if (structure->IsAccessorPair()) { | 
| 12640 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); | 12713 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); | 
| 12641 if (setter->IsSpecFunction()) { | 12714 if (setter->IsSpecFunction()) { | 
| 12642 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 12715 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 
| 12643 return SetPropertyWithDefinedSetter( | 12716 return SetPropertyWithDefinedSetter( | 
| 12644 object, Handle<JSReceiver>::cast(setter), value); | 12717 object, Handle<JSReceiver>::cast(setter), value); | 
| 12645 } else { | 12718 } else { | 
| 12646 if (is_sloppy(language_mode)) return value; | 12719 if (is_sloppy(language_mode)) return value; | 
| 12647 Handle<Object> key(isolate->factory()->NewNumberFromUint(index)); | 12720 Handle<Object> key(isolate->factory()->NewNumberFromUint(index)); | 
| 12648 Handle<Object> args[2] = { key, holder }; | 12721 Handle<Object> args[] = {key, holder}; | 
| 12649 THROW_NEW_ERROR( | 12722 THROW_NEW_ERROR(isolate, | 
| 12650 isolate, NewTypeError("no_setter_in_callback", HandleVector(args, 2)), | 12723 NewTypeError("no_setter_in_callback", | 
| 12651 Object); | 12724 HandleVector(args, arraysize(args))), | 
| 12725 Object); | |
| 12652 } | 12726 } | 
| 12653 } | 12727 } | 
| 12654 | 12728 | 
| 12655 UNREACHABLE(); | 12729 UNREACHABLE(); | 
| 12656 return MaybeHandle<Object>(); | 12730 return MaybeHandle<Object>(); | 
| 12657 } | 12731 } | 
| 12658 | 12732 | 
| 12659 | 12733 | 
| 12660 bool JSObject::HasFastArgumentsElements() { | 12734 bool JSObject::HasFastArgumentsElements() { | 
| 12661 Heap* heap = GetHeap(); | 12735 Heap* heap = GetHeap(); | 
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12828 ? SeededNumberDictionary::cast(elements->get(1)) | 12902 ? SeededNumberDictionary::cast(elements->get(1)) | 
| 12829 : SeededNumberDictionary::cast(*elements)); | 12903 : SeededNumberDictionary::cast(*elements)); | 
| 12830 | 12904 | 
| 12831 int entry = dictionary->FindEntry(index); | 12905 int entry = dictionary->FindEntry(index); | 
| 12832 if (entry != SeededNumberDictionary::kNotFound) { | 12906 if (entry != SeededNumberDictionary::kNotFound) { | 
| 12833 Handle<Object> element(dictionary->ValueAt(entry), isolate); | 12907 Handle<Object> element(dictionary->ValueAt(entry), isolate); | 
| 12834 PropertyDetails details = dictionary->DetailsAt(entry); | 12908 PropertyDetails details = dictionary->DetailsAt(entry); | 
| 12835 if (details.type() == ACCESSOR_CONSTANT && set_mode == SET_PROPERTY) { | 12909 if (details.type() == ACCESSOR_CONSTANT && set_mode == SET_PROPERTY) { | 
| 12836 return SetElementWithCallback(object, element, index, value, object, | 12910 return SetElementWithCallback(object, element, index, value, object, | 
| 12837 language_mode); | 12911 language_mode); | 
| 12912 } else if (set_mode == DEFINE_PROPERTY && !details.IsConfigurable() && | |
| 12913 details.kind() == kAccessor) { | |
| 12914 return RedefineNonconfigurableProperty( | |
| 12915 isolate, isolate->factory()->NewNumberFromUint(index), | |
| 12916 isolate->factory()->undefined_value(), language_mode); | |
| 12917 | |
| 12918 } else if ((set_mode == DEFINE_PROPERTY && !details.IsConfigurable() && | |
| 12919 details.IsReadOnly()) || | |
| 12920 (set_mode == SET_PROPERTY && details.IsReadOnly() && | |
| 12921 !element->IsTheHole())) { | |
| 12922 // If a value has not been initialized we allow writing to it even if it | |
| 12923 // is read-only (a declared const that has not been initialized). | |
| 12924 return WriteToReadOnlyProperty( | |
| 12925 isolate, object, isolate->factory()->NewNumberFromUint(index), | |
| 12926 isolate->factory()->undefined_value(), language_mode); | |
| 12838 } else { | 12927 } else { | 
| 12928 DCHECK(details.IsConfigurable() || !details.IsReadOnly() || | |
| 12929 element->IsTheHole()); | |
| 12839 dictionary->UpdateMaxNumberKey(index); | 12930 dictionary->UpdateMaxNumberKey(index); | 
| 12840 // If a value has not been initialized we allow writing to it even if it | |
| 12841 // is read-only (a declared const that has not been initialized). If a | |
| 12842 // value is being defined we skip attribute checks completely. | |
| 12843 if (set_mode == DEFINE_PROPERTY) { | 12931 if (set_mode == DEFINE_PROPERTY) { | 
| 12844 details = PropertyDetails(attributes, DATA, details.dictionary_index()); | 12932 details = PropertyDetails(attributes, DATA, details.dictionary_index()); | 
| 12845 dictionary->DetailsAtPut(entry, details); | 12933 dictionary->DetailsAtPut(entry, details); | 
| 12846 } else if (details.IsReadOnly() && !element->IsTheHole()) { | |
| 12847 if (is_sloppy(language_mode)) { | |
| 12848 return isolate->factory()->undefined_value(); | |
| 12849 } else { | |
| 12850 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); | |
| 12851 Handle<Object> args[2] = { number, object }; | |
| 12852 THROW_NEW_ERROR(isolate, NewTypeError("strict_read_only_property", | |
| 12853 HandleVector(args, 2)), | |
| 12854 Object); | |
| 12855 } | |
| 12856 } | 12934 } | 
| 12935 | |
| 12857 // Elements of the arguments object in slow mode might be slow aliases. | 12936 // Elements of the arguments object in slow mode might be slow aliases. | 
| 12858 if (is_arguments && element->IsAliasedArgumentsEntry()) { | 12937 if (is_arguments && element->IsAliasedArgumentsEntry()) { | 
| 12859 Handle<AliasedArgumentsEntry> entry = | 12938 Handle<AliasedArgumentsEntry> entry = | 
| 12860 Handle<AliasedArgumentsEntry>::cast(element); | 12939 Handle<AliasedArgumentsEntry>::cast(element); | 
| 12861 Handle<Context> context(Context::cast(elements->get(0))); | 12940 Handle<Context> context(Context::cast(elements->get(0))); | 
| 12862 int context_index = entry->aliased_context_slot(); | 12941 int context_index = entry->aliased_context_slot(); | 
| 12863 DCHECK(!context->get(context_index)->IsTheHole()); | 12942 DCHECK(!context->get(context_index)->IsTheHole()); | 
| 12864 context->set(context_index, *value); | 12943 context->set(context_index, *value); | 
| 12865 // For elements that are still writable we keep slow aliasing. | 12944 // For elements that are still writable we keep slow aliasing. | 
| 12866 if (!details.IsReadOnly()) value = element; | 12945 if (!details.IsReadOnly()) value = element; | 
| (...skipping 11 matching lines...) Expand all Loading... | |
| 12878 } | 12957 } | 
| 12879 | 12958 | 
| 12880 // When we set the is_extensible flag to false we always force the | 12959 // When we set the is_extensible flag to false we always force the | 
| 12881 // element into dictionary mode (and force them to stay there). | 12960 // element into dictionary mode (and force them to stay there). | 
| 12882 if (!object->map()->is_extensible()) { | 12961 if (!object->map()->is_extensible()) { | 
| 12883 if (is_sloppy(language_mode)) { | 12962 if (is_sloppy(language_mode)) { | 
| 12884 return isolate->factory()->undefined_value(); | 12963 return isolate->factory()->undefined_value(); | 
| 12885 } else { | 12964 } else { | 
| 12886 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); | 12965 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); | 
| 12887 Handle<String> name = isolate->factory()->NumberToString(number); | 12966 Handle<String> name = isolate->factory()->NumberToString(number); | 
| 12888 Handle<Object> args[1] = { name }; | 12967 Handle<Object> args[] = {name}; | 
| 12889 THROW_NEW_ERROR(isolate, NewTypeError("object_not_extensible", | 12968 THROW_NEW_ERROR(isolate, | 
| 12890 HandleVector(args, 1)), | 12969 NewTypeError("object_not_extensible", | 
| 12970 HandleVector(args, arraysize(args))), | |
| 12891 Object); | 12971 Object); | 
| 12892 } | 12972 } | 
| 12893 } | 12973 } | 
| 12894 | 12974 | 
| 12895 PropertyDetails details(attributes, DATA, 0); | 12975 PropertyDetails details(attributes, DATA, 0); | 
| 12896 Handle<SeededNumberDictionary> new_dictionary = | 12976 Handle<SeededNumberDictionary> new_dictionary = | 
| 12897 SeededNumberDictionary::AddNumberEntry(dictionary, index, value, | 12977 SeededNumberDictionary::AddNumberEntry(dictionary, index, value, | 
| 12898 details); | 12978 details); | 
| 12899 if (*dictionary != *new_dictionary) { | 12979 if (*dictionary != *new_dictionary) { | 
| 12900 if (is_arguments) { | 12980 if (is_arguments) { | 
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13590 uint32_t length = 0; | 13670 uint32_t length = 0; | 
| 13591 CHECK(array->length()->ToArrayIndex(&length)); | 13671 CHECK(array->length()->ToArrayIndex(&length)); | 
| 13592 if (length <= index) return HasReadOnlyLength(array); | 13672 if (length <= index) return HasReadOnlyLength(array); | 
| 13593 return false; | 13673 return false; | 
| 13594 } | 13674 } | 
| 13595 | 13675 | 
| 13596 | 13676 | 
| 13597 MaybeHandle<Object> JSArray::ReadOnlyLengthError(Handle<JSArray> array) { | 13677 MaybeHandle<Object> JSArray::ReadOnlyLengthError(Handle<JSArray> array) { | 
| 13598 Isolate* isolate = array->GetIsolate(); | 13678 Isolate* isolate = array->GetIsolate(); | 
| 13599 Handle<Name> length = isolate->factory()->length_string(); | 13679 Handle<Name> length = isolate->factory()->length_string(); | 
| 13600 Handle<Object> args[2] = { length, array }; | 13680 Handle<Object> args[] = {length, array}; | 
| 13601 THROW_NEW_ERROR(isolate, NewTypeError("strict_read_only_property", | 13681 THROW_NEW_ERROR(isolate, NewTypeError("strict_read_only_property", | 
| 13602 HandleVector(args, arraysize(args))), | 13682 HandleVector(args, arraysize(args))), | 
| 13603 Object); | 13683 Object); | 
| 13604 } | 13684 } | 
| 13605 | 13685 | 
| 13606 | 13686 | 
| 13607 MaybeHandle<Object> JSObject::GetElementWithInterceptor(Handle<JSObject> object, | 13687 MaybeHandle<Object> JSObject::GetElementWithInterceptor(Handle<JSObject> object, | 
| 13608 Handle<Object> receiver, | 13688 Handle<Object> receiver, | 
| 13609 uint32_t index, | 13689 uint32_t index, | 
| 13610 bool check_prototype) { | 13690 bool check_prototype) { | 
| (...skipping 3601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 17212 CompilationInfo* info) { | 17292 CompilationInfo* info) { | 
| 17213 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( | 17293 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( | 
| 17214 handle(cell->dependent_code(), info->isolate()), | 17294 handle(cell->dependent_code(), info->isolate()), | 
| 17215 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); | 17295 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); | 
| 17216 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 17296 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 
| 17217 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 17297 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 
| 17218 cell, info->zone()); | 17298 cell, info->zone()); | 
| 17219 } | 17299 } | 
| 17220 | 17300 | 
| 17221 } } // namespace v8::internal | 17301 } } // namespace v8::internal | 
| OLD | NEW |