Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Side by Side Diff: src/objects.cc

Issue 934463003: super.property store (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix arraysize Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/mjsunit/harmony/super.js » ('j') | test/mjsunit/harmony/super.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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);
759 if (attrs == ABSENT) {
760 return JSObject::SetElement(target, index, value, NONE, language_mode,
761 false);
762 }
758 if ((attrs & READ_ONLY) != 0) { 763 if ((attrs & READ_ONLY) != 0) {
759 return WriteToReadOnlyElement(isolate, receiver, index, value, 764 return WriteToReadOnlyElement(isolate, receiver, index, value,
760 language_mode); 765 language_mode);
761 } 766 }
762 PropertyAttributes new_attrs = attrs != ABSENT ? attrs : NONE; 767
763 return JSObject::SetElement(target, index, value, new_attrs, language_mode, 768 return JSObject::SetElement(target, index, value, attrs, language_mode, false,
764 false); 769 DEFINE_PROPERTY);
765 } 770 }
766 771
767 772
768 Map* Object::GetRootMap(Isolate* isolate) { 773 Map* Object::GetRootMap(Isolate* isolate) {
769 DisallowHeapAllocation no_alloc; 774 DisallowHeapAllocation no_alloc;
770 if (IsSmi()) { 775 if (IsSmi()) {
771 Context* context = isolate->context()->native_context(); 776 Context* context = isolate->context()->native_context();
772 return context->number_function()->initial_map(); 777 return context->number_function()->initial_map();
773 } 778 }
774 779
(...skipping 2355 matching lines...) Expand 10 before | Expand all | Expand 10 after
3130 break; 3135 break;
3131 } 3136 }
3132 3137
3133 if (done) break; 3138 if (done) break;
3134 } 3139 }
3135 3140
3136 // If the receiver is the JSGlobalObject, the store was contextual. In case 3141 // 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 3142 // the property did not exist yet on the global object itself, we have to
3138 // throw a reference error in strict mode. 3143 // throw a reference error in strict mode.
3139 if (it->GetReceiver()->IsJSGlobalObject() && is_strict(language_mode)) { 3144 if (it->GetReceiver()->IsJSGlobalObject() && is_strict(language_mode)) {
3140 Handle<Object> args[1] = {it->name()}; 3145 Handle<Object> args[] = {it->name()};
3146 THROW_NEW_ERROR(
3147 it->isolate(),
3148 NewReferenceError("not_defined", HandleVector(args, arraysize(args))),
3149 Object);
3150 }
3151
3152 // super.property = value
3153 // No property was found starting from the prototype of [[HomeObject]].
3154 if (data_store_mode == SUPER_PROPERTY) {
3155 LookupIterator own_lookup(it->GetReceiver(), it->name(),
3156 LookupIterator::OWN);
3157 if (!own_lookup.IsFound()) {
3158 return AddDataProperty(&own_lookup, value, NONE, language_mode,
3159 store_mode);
3160 }
3161
3162 PropertyDetails details = own_lookup.property_details();
3163
3164 // Otherwise reconfigure property with descriptor {value: value}.
3165 if (details.IsConfigurable()) {
3166 return JSObject::SetOwnPropertyIgnoreAttributes(
3167 Handle<JSObject>::cast(it->GetReceiver()), it->name(), value,
3168 details.attributes());
3169 }
3170
3171 if (details.IsReadOnly()) {
3172 return WriteToReadOnlyProperty(&own_lookup, value, language_mode);
3173 }
3174
3175 // Not configurable but writable.
3176 if (details.kind() == kData) {
3177 return SetDataProperty(&own_lookup, value);
3178 }
3179
3180 Handle<Object> args[] = {it->name()};
3141 THROW_NEW_ERROR(it->isolate(), 3181 THROW_NEW_ERROR(it->isolate(),
3142 NewReferenceError("not_defined", HandleVector(args, 1)), 3182 NewTypeError("redefine_disallowed",
3183 HandleVector(args, arraysize(args))),
3143 Object); 3184 Object);
3144 } 3185 }
3145 3186
3146 if (data_store_mode == SUPER_PROPERTY) {
3147 LookupIterator own_lookup(it->GetReceiver(), it->name(),
3148 LookupIterator::OWN);
3149
3150 return JSObject::SetProperty(&own_lookup, value, language_mode, store_mode,
3151 NORMAL_PROPERTY);
3152 }
3153
3154 return AddDataProperty(it, value, NONE, language_mode, store_mode); 3187 return AddDataProperty(it, value, NONE, language_mode, store_mode);
3155 } 3188 }
3156 3189
3157 3190
3158 MaybeHandle<Object> Object::WriteToReadOnlyProperty( 3191 MaybeHandle<Object> Object::WriteToReadOnlyProperty(
3159 LookupIterator* it, Handle<Object> value, LanguageMode language_mode) { 3192 LookupIterator* it, Handle<Object> value, LanguageMode language_mode) {
3160 if (is_sloppy(language_mode)) return value; 3193 if (is_sloppy(language_mode)) return value;
3161 3194
3162 Handle<Object> args[] = {it->name(), it->GetReceiver()}; 3195 Handle<Object> args[] = {it->name(), it->GetReceiver()};
3163 THROW_NEW_ERROR(it->isolate(), 3196 THROW_NEW_ERROR(it->isolate(),
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
3238 // If the receiver is Indexed Exotic object (currently only typed arrays), 3271 // If the receiver is Indexed Exotic object (currently only typed arrays),
3239 // disallow adding properties with numeric names. 3272 // disallow adding properties with numeric names.
3240 if (it->IsSpecialNumericIndex()) return value; 3273 if (it->IsSpecialNumericIndex()) return value;
3241 3274
3242 // Possibly migrate to the most up-to-date map that will be able to store 3275 // Possibly migrate to the most up-to-date map that will be able to store
3243 // |value| under it->name() with |attributes|. 3276 // |value| under it->name() with |attributes|.
3244 it->PrepareTransitionToDataProperty(value, attributes, store_mode); 3277 it->PrepareTransitionToDataProperty(value, attributes, store_mode);
3245 if (it->state() != LookupIterator::TRANSITION) { 3278 if (it->state() != LookupIterator::TRANSITION) {
3246 if (is_sloppy(language_mode)) return value; 3279 if (is_sloppy(language_mode)) return value;
3247 3280
3248 Handle<Object> args[1] = {it->name()}; 3281 Handle<Object> args[] = {it->name()};
3249 THROW_NEW_ERROR(it->isolate(), 3282 THROW_NEW_ERROR(it->isolate(),
3250 NewTypeError("object_not_extensible", 3283 NewTypeError("object_not_extensible",
3251 HandleVector(args, arraysize(args))), 3284 HandleVector(args, arraysize(args))),
3252 Object); 3285 Object);
3253 } 3286 }
3254 it->ApplyTransitionToDataProperty(); 3287 it->ApplyTransitionToDataProperty();
3255 3288
3256 // TODO(verwaest): Encapsulate dictionary handling better. 3289 // TODO(verwaest): Encapsulate dictionary handling better.
3257 if (receiver->map()->is_dictionary_map()) { 3290 if (receiver->map()->is_dictionary_map()) {
3258 // TODO(verwaest): Probably should ensure this is done beforehand. 3291 // TODO(verwaest): Probably should ensure this is done beforehand.
(...skipping 1888 matching lines...) Expand 10 before | Expand all | Expand 10 after
5147 !isolate->MayIndexedAccess(object, index, v8::ACCESS_DELETE)) { 5180 !isolate->MayIndexedAccess(object, index, v8::ACCESS_DELETE)) {
5148 isolate->ReportFailedAccessCheck(object, v8::ACCESS_DELETE); 5181 isolate->ReportFailedAccessCheck(object, v8::ACCESS_DELETE);
5149 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); 5182 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
5150 return factory->false_value(); 5183 return factory->false_value();
5151 } 5184 }
5152 5185
5153 if (object->IsStringObjectWithCharacterAt(index)) { 5186 if (object->IsStringObjectWithCharacterAt(index)) {
5154 if (is_strict(language_mode)) { 5187 if (is_strict(language_mode)) {
5155 // Deleting a non-configurable property in strict mode. 5188 // Deleting a non-configurable property in strict mode.
5156 Handle<Object> name = factory->NewNumberFromUint(index); 5189 Handle<Object> name = factory->NewNumberFromUint(index);
5157 Handle<Object> args[2] = { name, object }; 5190 Handle<Object> args[] = {name, object};
5158 THROW_NEW_ERROR(isolate, NewTypeError("strict_delete_property", 5191 THROW_NEW_ERROR(isolate,
5159 HandleVector(args, 2)), 5192 NewTypeError("strict_delete_property",
5193 HandleVector(args, arraysize(args))),
5160 Object); 5194 Object);
5161 } 5195 }
5162 return factory->false_value(); 5196 return factory->false_value();
5163 } 5197 }
5164 5198
5165 if (object->IsJSGlobalProxy()) { 5199 if (object->IsJSGlobalProxy()) {
5166 PrototypeIterator iter(isolate, object); 5200 PrototypeIterator iter(isolate, object);
5167 if (iter.IsAtEnd()) return factory->false_value(); 5201 if (iter.IsAtEnd()) return factory->false_value();
5168 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); 5202 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject());
5169 return DeleteElement( 5203 return DeleteElement(
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
5280 } 5314 }
5281 case LookupIterator::DATA: 5315 case LookupIterator::DATA:
5282 if (is_observed) { 5316 if (is_observed) {
5283 old_value = it.GetDataValue(); 5317 old_value = it.GetDataValue();
5284 } 5318 }
5285 // Fall through. 5319 // Fall through.
5286 case LookupIterator::ACCESSOR: { 5320 case LookupIterator::ACCESSOR: {
5287 if (!it.IsConfigurable()) { 5321 if (!it.IsConfigurable()) {
5288 // Fail if the property is not configurable. 5322 // Fail if the property is not configurable.
5289 if (is_strict(language_mode)) { 5323 if (is_strict(language_mode)) {
5290 Handle<Object> args[2] = {name, object}; 5324 Handle<Object> args[] = {name, object};
5291 THROW_NEW_ERROR(it.isolate(), 5325 THROW_NEW_ERROR(it.isolate(),
5292 NewTypeError("strict_delete_property", 5326 NewTypeError("strict_delete_property",
5293 HandleVector(args, arraysize(args))), 5327 HandleVector(args, arraysize(args))),
5294 Object); 5328 Object);
5295 } 5329 }
5296 return it.isolate()->factory()->false_value(); 5330 return it.isolate()->factory()->false_value();
5297 } 5331 }
5298 5332
5299 PropertyNormalizationMode mode = object->map()->is_prototype_map() 5333 PropertyNormalizationMode mode = object->map()->is_prototype_map()
5300 ? KEEP_INOBJECT_PROPERTIES 5334 ? KEEP_INOBJECT_PROPERTIES
(...skipping 7337 matching lines...) Expand 10 before | Expand all | Expand 10 after
12638 12672
12639 if (structure->IsAccessorPair()) { 12673 if (structure->IsAccessorPair()) {
12640 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); 12674 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate);
12641 if (setter->IsSpecFunction()) { 12675 if (setter->IsSpecFunction()) {
12642 // TODO(rossberg): nicer would be to cast to some JSCallable here... 12676 // TODO(rossberg): nicer would be to cast to some JSCallable here...
12643 return SetPropertyWithDefinedSetter( 12677 return SetPropertyWithDefinedSetter(
12644 object, Handle<JSReceiver>::cast(setter), value); 12678 object, Handle<JSReceiver>::cast(setter), value);
12645 } else { 12679 } else {
12646 if (is_sloppy(language_mode)) return value; 12680 if (is_sloppy(language_mode)) return value;
12647 Handle<Object> key(isolate->factory()->NewNumberFromUint(index)); 12681 Handle<Object> key(isolate->factory()->NewNumberFromUint(index));
12648 Handle<Object> args[2] = { key, holder }; 12682 Handle<Object> args[] = {key, holder};
12649 THROW_NEW_ERROR( 12683 THROW_NEW_ERROR(isolate,
12650 isolate, NewTypeError("no_setter_in_callback", HandleVector(args, 2)), 12684 NewTypeError("no_setter_in_callback",
12651 Object); 12685 HandleVector(args, arraysize(args))),
12686 Object);
12652 } 12687 }
12653 } 12688 }
12654 12689
12655 UNREACHABLE(); 12690 UNREACHABLE();
12656 return MaybeHandle<Object>(); 12691 return MaybeHandle<Object>();
12657 } 12692 }
12658 12693
12659 12694
12660 bool JSObject::HasFastArgumentsElements() { 12695 bool JSObject::HasFastArgumentsElements() {
12661 Heap* heap = GetHeap(); 12696 Heap* heap = GetHeap();
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
12828 ? SeededNumberDictionary::cast(elements->get(1)) 12863 ? SeededNumberDictionary::cast(elements->get(1))
12829 : SeededNumberDictionary::cast(*elements)); 12864 : SeededNumberDictionary::cast(*elements));
12830 12865
12831 int entry = dictionary->FindEntry(index); 12866 int entry = dictionary->FindEntry(index);
12832 if (entry != SeededNumberDictionary::kNotFound) { 12867 if (entry != SeededNumberDictionary::kNotFound) {
12833 Handle<Object> element(dictionary->ValueAt(entry), isolate); 12868 Handle<Object> element(dictionary->ValueAt(entry), isolate);
12834 PropertyDetails details = dictionary->DetailsAt(entry); 12869 PropertyDetails details = dictionary->DetailsAt(entry);
12835 if (details.type() == ACCESSOR_CONSTANT && set_mode == SET_PROPERTY) { 12870 if (details.type() == ACCESSOR_CONSTANT && set_mode == SET_PROPERTY) {
12836 return SetElementWithCallback(object, element, index, value, object, 12871 return SetElementWithCallback(object, element, index, value, object,
12837 language_mode); 12872 language_mode);
12873 } else if (set_mode == DEFINE_PROPERTY && !details.IsConfigurable() &&
12874 details.kind() == kAccessor) {
12875 Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
12876 Handle<Object> args[] = {number};
12877 THROW_NEW_ERROR(isolate,
12878 NewTypeError("redefine_disallowed",
12879 HandleVector(args, arraysize(args))),
12880 Object);
12838 } else { 12881 } else {
12839 dictionary->UpdateMaxNumberKey(index); 12882 dictionary->UpdateMaxNumberKey(index);
12840 // If a value has not been initialized we allow writing to it even if it 12883 // 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 12884 // is read-only (a declared const that has not been initialized). If a
adamk 2015/02/17 22:47:45 Is this comment still providing value?
arv (Not doing code reviews) 2015/02/17 22:55:05 I believe this is still the case. If there is a no
12842 // value is being defined we skip attribute checks completely. 12885 // value is being defined we skip attribute checks completely.
12843 if (set_mode == DEFINE_PROPERTY) { 12886 if (set_mode == DEFINE_PROPERTY) {
12844 details = PropertyDetails(attributes, DATA, details.dictionary_index()); 12887 details = PropertyDetails(attributes, DATA, details.dictionary_index());
12845 dictionary->DetailsAtPut(entry, details); 12888 dictionary->DetailsAtPut(entry, details);
12846 } else if (details.IsReadOnly() && !element->IsTheHole()) { 12889 } else if (details.IsReadOnly() && !element->IsTheHole()) {
12847 if (is_sloppy(language_mode)) { 12890 if (is_sloppy(language_mode)) {
12848 return isolate->factory()->undefined_value(); 12891 return isolate->factory()->undefined_value();
12849 } else { 12892 } else {
12850 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); 12893 Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
12851 Handle<Object> args[2] = { number, object }; 12894 Handle<Object> args[] = {number, object};
12852 THROW_NEW_ERROR(isolate, NewTypeError("strict_read_only_property", 12895 THROW_NEW_ERROR(isolate,
12853 HandleVector(args, 2)), 12896 NewTypeError("strict_read_only_property",
12897 HandleVector(args, arraysize(args))),
12854 Object); 12898 Object);
12855 } 12899 }
12856 } 12900 }
12857 // Elements of the arguments object in slow mode might be slow aliases. 12901 // Elements of the arguments object in slow mode might be slow aliases.
12858 if (is_arguments && element->IsAliasedArgumentsEntry()) { 12902 if (is_arguments && element->IsAliasedArgumentsEntry()) {
12859 Handle<AliasedArgumentsEntry> entry = 12903 Handle<AliasedArgumentsEntry> entry =
12860 Handle<AliasedArgumentsEntry>::cast(element); 12904 Handle<AliasedArgumentsEntry>::cast(element);
12861 Handle<Context> context(Context::cast(elements->get(0))); 12905 Handle<Context> context(Context::cast(elements->get(0)));
12862 int context_index = entry->aliased_context_slot(); 12906 int context_index = entry->aliased_context_slot();
12863 DCHECK(!context->get(context_index)->IsTheHole()); 12907 DCHECK(!context->get(context_index)->IsTheHole());
(...skipping 14 matching lines...) Expand all
12878 } 12922 }
12879 12923
12880 // When we set the is_extensible flag to false we always force the 12924 // When we set the is_extensible flag to false we always force the
12881 // element into dictionary mode (and force them to stay there). 12925 // element into dictionary mode (and force them to stay there).
12882 if (!object->map()->is_extensible()) { 12926 if (!object->map()->is_extensible()) {
12883 if (is_sloppy(language_mode)) { 12927 if (is_sloppy(language_mode)) {
12884 return isolate->factory()->undefined_value(); 12928 return isolate->factory()->undefined_value();
12885 } else { 12929 } else {
12886 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); 12930 Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
12887 Handle<String> name = isolate->factory()->NumberToString(number); 12931 Handle<String> name = isolate->factory()->NumberToString(number);
12888 Handle<Object> args[1] = { name }; 12932 Handle<Object> args[] = {name};
12889 THROW_NEW_ERROR(isolate, NewTypeError("object_not_extensible", 12933 THROW_NEW_ERROR(isolate,
12890 HandleVector(args, 1)), 12934 NewTypeError("object_not_extensible",
12935 HandleVector(args, arraysize(args))),
12891 Object); 12936 Object);
12892 } 12937 }
12893 } 12938 }
12894 12939
12895 PropertyDetails details(attributes, DATA, 0); 12940 PropertyDetails details(attributes, DATA, 0);
12896 Handle<SeededNumberDictionary> new_dictionary = 12941 Handle<SeededNumberDictionary> new_dictionary =
12897 SeededNumberDictionary::AddNumberEntry(dictionary, index, value, 12942 SeededNumberDictionary::AddNumberEntry(dictionary, index, value,
12898 details); 12943 details);
12899 if (*dictionary != *new_dictionary) { 12944 if (*dictionary != *new_dictionary) {
12900 if (is_arguments) { 12945 if (is_arguments) {
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
13590 uint32_t length = 0; 13635 uint32_t length = 0;
13591 CHECK(array->length()->ToArrayIndex(&length)); 13636 CHECK(array->length()->ToArrayIndex(&length));
13592 if (length <= index) return HasReadOnlyLength(array); 13637 if (length <= index) return HasReadOnlyLength(array);
13593 return false; 13638 return false;
13594 } 13639 }
13595 13640
13596 13641
13597 MaybeHandle<Object> JSArray::ReadOnlyLengthError(Handle<JSArray> array) { 13642 MaybeHandle<Object> JSArray::ReadOnlyLengthError(Handle<JSArray> array) {
13598 Isolate* isolate = array->GetIsolate(); 13643 Isolate* isolate = array->GetIsolate();
13599 Handle<Name> length = isolate->factory()->length_string(); 13644 Handle<Name> length = isolate->factory()->length_string();
13600 Handle<Object> args[2] = { length, array }; 13645 Handle<Object> args[] = {length, array};
13601 THROW_NEW_ERROR(isolate, NewTypeError("strict_read_only_property", 13646 THROW_NEW_ERROR(isolate, NewTypeError("strict_read_only_property",
13602 HandleVector(args, arraysize(args))), 13647 HandleVector(args, arraysize(args))),
13603 Object); 13648 Object);
13604 } 13649 }
13605 13650
13606 13651
13607 MaybeHandle<Object> JSObject::GetElementWithInterceptor(Handle<JSObject> object, 13652 MaybeHandle<Object> JSObject::GetElementWithInterceptor(Handle<JSObject> object,
13608 Handle<Object> receiver, 13653 Handle<Object> receiver,
13609 uint32_t index, 13654 uint32_t index,
13610 bool check_prototype) { 13655 bool check_prototype) {
(...skipping 3601 matching lines...) Expand 10 before | Expand all | Expand 10 after
17212 CompilationInfo* info) { 17257 CompilationInfo* info) {
17213 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( 17258 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo(
17214 handle(cell->dependent_code(), info->isolate()), 17259 handle(cell->dependent_code(), info->isolate()),
17215 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); 17260 DependentCode::kPropertyCellChangedGroup, info->object_wrapper());
17216 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); 17261 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
17217 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 17262 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
17218 cell, info->zone()); 17263 cell, info->zone());
17219 } 17264 }
17220 17265
17221 } } // namespace v8::internal 17266 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/harmony/super.js » ('j') | test/mjsunit/harmony/super.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698