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 <iomanip> | 5 #include <iomanip> |
6 #include <sstream> | 6 #include <sstream> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 case LookupIterator::INTEGER_INDEXED_EXOTIC: | 138 case LookupIterator::INTEGER_INDEXED_EXOTIC: |
139 return it->factory()->undefined_value(); | 139 return it->factory()->undefined_value(); |
140 case LookupIterator::DATA: | 140 case LookupIterator::DATA: |
141 return it->GetDataValue(); | 141 return it->GetDataValue(); |
142 } | 142 } |
143 } | 143 } |
144 return it->factory()->undefined_value(); | 144 return it->factory()->undefined_value(); |
145 } | 145 } |
146 | 146 |
147 | 147 |
148 Handle<Object> JSReceiver::GetDataProperty(Handle<JSReceiver> object, | 148 Handle<Object> JSObject::GetDataProperty(Handle<JSObject> object, |
149 Handle<Name> key) { | 149 Handle<Name> key) { |
150 LookupIterator it(object, key, | 150 LookupIterator it(object, key, |
151 LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 151 LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
152 return GetDataProperty(&it); | 152 return GetDataProperty(&it); |
153 } | 153 } |
154 | 154 |
155 | 155 |
156 Handle<Object> JSReceiver::GetDataProperty(LookupIterator* it) { | 156 Handle<Object> JSObject::GetDataProperty(LookupIterator* it) { |
157 for (; it->IsFound(); it->Next()) { | 157 for (; it->IsFound(); it->Next()) { |
158 switch (it->state()) { | 158 switch (it->state()) { |
159 case LookupIterator::INTERCEPTOR: | 159 case LookupIterator::INTERCEPTOR: |
160 case LookupIterator::NOT_FOUND: | 160 case LookupIterator::NOT_FOUND: |
161 case LookupIterator::TRANSITION: | 161 case LookupIterator::TRANSITION: |
162 UNREACHABLE(); | 162 UNREACHABLE(); |
163 case LookupIterator::ACCESS_CHECK: | 163 case LookupIterator::ACCESS_CHECK: |
164 if (it->HasAccess()) continue; | 164 if (it->HasAccess()) continue; |
165 // Fall through. | 165 // Fall through. |
166 case LookupIterator::JSPROXY: | 166 case LookupIterator::JSPROXY: |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 } | 382 } |
383 | 383 |
384 if (structure->IsAccessorPair()) { | 384 if (structure->IsAccessorPair()) { |
385 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); | 385 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); |
386 if (setter->IsSpecFunction()) { | 386 if (setter->IsSpecFunction()) { |
387 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 387 // TODO(rossberg): nicer would be to cast to some JSCallable here... |
388 return SetPropertyWithDefinedSetter( | 388 return SetPropertyWithDefinedSetter( |
389 receiver, Handle<JSReceiver>::cast(setter), value); | 389 receiver, Handle<JSReceiver>::cast(setter), value); |
390 } else { | 390 } else { |
391 if (is_sloppy(language_mode)) return value; | 391 if (is_sloppy(language_mode)) return value; |
392 THROW_NEW_ERROR( | 392 Handle<Object> args[] = {name, holder}; |
393 isolate, | 393 THROW_NEW_ERROR(isolate, |
394 NewTypeError(MessageTemplate::kNoSetterInCallback, name, holder), | 394 NewTypeError("no_setter_in_callback", |
395 Object); | 395 HandleVector(args, arraysize(args))), |
| 396 Object); |
396 } | 397 } |
397 } | 398 } |
398 | 399 |
399 UNREACHABLE(); | 400 UNREACHABLE(); |
400 return MaybeHandle<Object>(); | 401 return MaybeHandle<Object>(); |
401 } | 402 } |
402 | 403 |
403 | 404 |
404 MaybeHandle<Object> Object::GetPropertyWithDefinedGetter( | 405 MaybeHandle<Object> Object::GetPropertyWithDefinedGetter( |
405 Handle<Object> receiver, | 406 Handle<Object> receiver, |
(...skipping 2908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3314 LookupIterator* it, Handle<Object> value, LanguageMode language_mode) { | 3315 LookupIterator* it, Handle<Object> value, LanguageMode language_mode) { |
3315 return WriteToReadOnlyProperty(it->isolate(), it->GetReceiver(), it->name(), | 3316 return WriteToReadOnlyProperty(it->isolate(), it->GetReceiver(), it->name(), |
3316 value, language_mode); | 3317 value, language_mode); |
3317 } | 3318 } |
3318 | 3319 |
3319 | 3320 |
3320 MaybeHandle<Object> Object::WriteToReadOnlyProperty( | 3321 MaybeHandle<Object> Object::WriteToReadOnlyProperty( |
3321 Isolate* isolate, Handle<Object> receiver, Handle<Object> name, | 3322 Isolate* isolate, Handle<Object> receiver, Handle<Object> name, |
3322 Handle<Object> value, LanguageMode language_mode) { | 3323 Handle<Object> value, LanguageMode language_mode) { |
3323 if (is_sloppy(language_mode)) return value; | 3324 if (is_sloppy(language_mode)) return value; |
3324 THROW_NEW_ERROR( | 3325 Handle<Object> args[] = {name, receiver}; |
3325 isolate, | 3326 THROW_NEW_ERROR(isolate, NewTypeError("strict_read_only_property", |
3326 NewTypeError(MessageTemplate::kStrictReadOnlyProperty, name, receiver), | 3327 HandleVector(args, arraysize(args))), |
3327 Object); | 3328 Object); |
3328 } | 3329 } |
3329 | 3330 |
3330 | 3331 |
3331 MaybeHandle<Object> Object::WriteToReadOnlyElement(Isolate* isolate, | 3332 MaybeHandle<Object> Object::WriteToReadOnlyElement(Isolate* isolate, |
3332 Handle<Object> receiver, | 3333 Handle<Object> receiver, |
3333 uint32_t index, | 3334 uint32_t index, |
3334 Handle<Object> value, | 3335 Handle<Object> value, |
3335 LanguageMode language_mode) { | 3336 LanguageMode language_mode) { |
3336 return WriteToReadOnlyProperty(isolate, receiver, | 3337 return WriteToReadOnlyProperty(isolate, receiver, |
3337 isolate->factory()->NewNumberFromUint(index), | 3338 isolate->factory()->NewNumberFromUint(index), |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3402 | 3403 |
3403 // If the receiver is a JSGlobalProxy, store on the prototype (JSGlobalObject) | 3404 // If the receiver is a JSGlobalProxy, store on the prototype (JSGlobalObject) |
3404 // instead. If the prototype is Null, the proxy is detached. | 3405 // instead. If the prototype is Null, the proxy is detached. |
3405 if (receiver->IsJSGlobalProxy()) return value; | 3406 if (receiver->IsJSGlobalProxy()) return value; |
3406 | 3407 |
3407 // Possibly migrate to the most up-to-date map that will be able to store | 3408 // Possibly migrate to the most up-to-date map that will be able to store |
3408 // |value| under it->name() with |attributes|. | 3409 // |value| under it->name() with |attributes|. |
3409 it->PrepareTransitionToDataProperty(value, attributes, store_mode); | 3410 it->PrepareTransitionToDataProperty(value, attributes, store_mode); |
3410 if (it->state() != LookupIterator::TRANSITION) { | 3411 if (it->state() != LookupIterator::TRANSITION) { |
3411 if (is_sloppy(language_mode)) return value; | 3412 if (is_sloppy(language_mode)) return value; |
3412 THROW_NEW_ERROR( | 3413 |
3413 it->isolate(), | 3414 Handle<Object> args[] = {it->name()}; |
3414 NewTypeError(MessageTemplate::kObjectNotExtensible, it->name()), | 3415 THROW_NEW_ERROR(it->isolate(), |
3415 Object); | 3416 NewTypeError("object_not_extensible", |
| 3417 HandleVector(args, arraysize(args))), |
| 3418 Object); |
3416 } | 3419 } |
3417 it->ApplyTransitionToDataProperty(); | 3420 it->ApplyTransitionToDataProperty(); |
3418 | 3421 |
3419 // TODO(verwaest): Encapsulate dictionary handling better. | 3422 // TODO(verwaest): Encapsulate dictionary handling better. |
3420 if (receiver->map()->is_dictionary_map()) { | 3423 if (receiver->map()->is_dictionary_map()) { |
3421 // TODO(verwaest): Probably should ensure this is done beforehand. | 3424 // TODO(verwaest): Probably should ensure this is done beforehand. |
3422 it->InternalizeName(); | 3425 it->InternalizeName(); |
3423 // TODO(dcarney): just populate TransitionPropertyCell here? | 3426 // TODO(dcarney): just populate TransitionPropertyCell here? |
3424 JSObject::AddSlowProperty(receiver, it->name(), value, attributes); | 3427 JSObject::AddSlowProperty(receiver, it->name(), value, attributes); |
3425 } else { | 3428 } else { |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3959 Handle<String> set_name = | 3962 Handle<String> set_name = |
3960 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("set_")); | 3963 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("set_")); |
3961 Handle<Object> setter = Object::GetProperty(desc, set_name).ToHandleChecked(); | 3964 Handle<Object> setter = Object::GetProperty(desc, set_name).ToHandleChecked(); |
3962 if (!setter->IsUndefined()) { | 3965 if (!setter->IsUndefined()) { |
3963 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 3966 // TODO(rossberg): nicer would be to cast to some JSCallable here... |
3964 return SetPropertyWithDefinedSetter( | 3967 return SetPropertyWithDefinedSetter( |
3965 receiver, Handle<JSReceiver>::cast(setter), value); | 3968 receiver, Handle<JSReceiver>::cast(setter), value); |
3966 } | 3969 } |
3967 | 3970 |
3968 if (is_sloppy(language_mode)) return value; | 3971 if (is_sloppy(language_mode)) return value; |
3969 THROW_NEW_ERROR( | 3972 Handle<Object> args2[] = { name, proxy }; |
3970 isolate, NewTypeError(MessageTemplate::kNoSetterInCallback, name, proxy), | 3973 THROW_NEW_ERROR(isolate, NewTypeError("no_setter_in_callback", |
3971 Object); | 3974 HandleVector(args2, arraysize(args2))), |
| 3975 Object); |
3972 } | 3976 } |
3973 | 3977 |
3974 | 3978 |
3975 MaybeHandle<Object> JSProxy::DeletePropertyWithHandler( | 3979 MaybeHandle<Object> JSProxy::DeletePropertyWithHandler( |
3976 Handle<JSProxy> proxy, Handle<Name> name, LanguageMode language_mode) { | 3980 Handle<JSProxy> proxy, Handle<Name> name, LanguageMode language_mode) { |
3977 Isolate* isolate = proxy->GetIsolate(); | 3981 Isolate* isolate = proxy->GetIsolate(); |
3978 | 3982 |
3979 // TODO(rossberg): adjust once there is a story for symbols vs proxies. | 3983 // TODO(rossberg): adjust once there is a story for symbols vs proxies. |
3980 if (name->IsSymbol()) return isolate->factory()->false_value(); | 3984 if (name->IsSymbol()) return isolate->factory()->false_value(); |
3981 | 3985 |
3982 Handle<Object> args[] = { name }; | 3986 Handle<Object> args[] = { name }; |
3983 Handle<Object> result; | 3987 Handle<Object> result; |
3984 ASSIGN_RETURN_ON_EXCEPTION( | 3988 ASSIGN_RETURN_ON_EXCEPTION( |
3985 isolate, result, | 3989 isolate, result, |
3986 CallTrap(proxy, | 3990 CallTrap(proxy, |
3987 "delete", | 3991 "delete", |
3988 Handle<Object>(), | 3992 Handle<Object>(), |
3989 arraysize(args), | 3993 arraysize(args), |
3990 args), | 3994 args), |
3991 Object); | 3995 Object); |
3992 | 3996 |
3993 bool result_bool = result->BooleanValue(); | 3997 bool result_bool = result->BooleanValue(); |
3994 if (is_strict(language_mode) && !result_bool) { | 3998 if (is_strict(language_mode) && !result_bool) { |
3995 Handle<Object> handler(proxy->handler(), isolate); | 3999 Handle<Object> handler(proxy->handler(), isolate); |
3996 THROW_NEW_ERROR( | 4000 Handle<String> trap_name = isolate->factory()->InternalizeOneByteString( |
3997 isolate, | 4001 STATIC_CHAR_VECTOR("delete")); |
3998 NewTypeError(MessageTemplate::kProxyHandlerDeleteFailed, handler), | 4002 Handle<Object> args[] = { handler, trap_name }; |
3999 Object); | 4003 THROW_NEW_ERROR(isolate, NewTypeError("handler_failed", |
| 4004 HandleVector(args, arraysize(args))), |
| 4005 Object); |
4000 } | 4006 } |
4001 return isolate->factory()->ToBoolean(result_bool); | 4007 return isolate->factory()->ToBoolean(result_bool); |
4002 } | 4008 } |
4003 | 4009 |
4004 | 4010 |
4005 MaybeHandle<Object> JSProxy::DeleteElementWithHandler( | 4011 MaybeHandle<Object> JSProxy::DeleteElementWithHandler( |
4006 Handle<JSProxy> proxy, uint32_t index, LanguageMode language_mode) { | 4012 Handle<JSProxy> proxy, uint32_t index, LanguageMode language_mode) { |
4007 Isolate* isolate = proxy->GetIsolate(); | 4013 Isolate* isolate = proxy->GetIsolate(); |
4008 Handle<String> name = isolate->factory()->Uint32ToString(index); | 4014 Handle<String> name = isolate->factory()->Uint32ToString(index); |
4009 return JSProxy::DeletePropertyWithHandler(proxy, name, language_mode); | 4015 return JSProxy::DeletePropertyWithHandler(proxy, name, language_mode); |
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5300 if (object->IsAccessCheckNeeded() && !isolate->MayAccess(object)) { | 5306 if (object->IsAccessCheckNeeded() && !isolate->MayAccess(object)) { |
5301 isolate->ReportFailedAccessCheck(object); | 5307 isolate->ReportFailedAccessCheck(object); |
5302 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | 5308 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
5303 return factory->false_value(); | 5309 return factory->false_value(); |
5304 } | 5310 } |
5305 | 5311 |
5306 if (object->IsStringObjectWithCharacterAt(index)) { | 5312 if (object->IsStringObjectWithCharacterAt(index)) { |
5307 if (is_strict(language_mode)) { | 5313 if (is_strict(language_mode)) { |
5308 // Deleting a non-configurable property in strict mode. | 5314 // Deleting a non-configurable property in strict mode. |
5309 Handle<Object> name = factory->NewNumberFromUint(index); | 5315 Handle<Object> name = factory->NewNumberFromUint(index); |
5310 THROW_NEW_ERROR( | 5316 Handle<Object> args[] = {name, object}; |
5311 isolate, | 5317 THROW_NEW_ERROR(isolate, |
5312 NewTypeError(MessageTemplate::kStrictDeleteProperty, name, object), | 5318 NewTypeError("strict_delete_property", |
5313 Object); | 5319 HandleVector(args, arraysize(args))), |
| 5320 Object); |
5314 } | 5321 } |
5315 return factory->false_value(); | 5322 return factory->false_value(); |
5316 } | 5323 } |
5317 | 5324 |
5318 if (object->IsJSGlobalProxy()) { | 5325 if (object->IsJSGlobalProxy()) { |
5319 PrototypeIterator iter(isolate, object); | 5326 PrototypeIterator iter(isolate, object); |
5320 if (iter.IsAtEnd()) return factory->false_value(); | 5327 if (iter.IsAtEnd()) return factory->false_value(); |
5321 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); | 5328 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); |
5322 return DeleteElement( | 5329 return DeleteElement( |
5323 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), index, | 5330 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), index, |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5433 return it.isolate()->factory()->true_value(); | 5440 return it.isolate()->factory()->true_value(); |
5434 case LookupIterator::DATA: | 5441 case LookupIterator::DATA: |
5435 if (is_observed) { | 5442 if (is_observed) { |
5436 old_value = it.GetDataValue(); | 5443 old_value = it.GetDataValue(); |
5437 } | 5444 } |
5438 // Fall through. | 5445 // Fall through. |
5439 case LookupIterator::ACCESSOR: { | 5446 case LookupIterator::ACCESSOR: { |
5440 if (!it.IsConfigurable()) { | 5447 if (!it.IsConfigurable()) { |
5441 // Fail if the property is not configurable. | 5448 // Fail if the property is not configurable. |
5442 if (is_strict(language_mode)) { | 5449 if (is_strict(language_mode)) { |
| 5450 Handle<Object> args[] = {name, object}; |
5443 THROW_NEW_ERROR(it.isolate(), | 5451 THROW_NEW_ERROR(it.isolate(), |
5444 NewTypeError(MessageTemplate::kStrictDeleteProperty, | 5452 NewTypeError("strict_delete_property", |
5445 name, object), | 5453 HandleVector(args, arraysize(args))), |
5446 Object); | 5454 Object); |
5447 } | 5455 } |
5448 return it.isolate()->factory()->false_value(); | 5456 return it.isolate()->factory()->false_value(); |
5449 } | 5457 } |
5450 | 5458 |
5451 PropertyNormalizationMode mode = object->map()->is_prototype_map() | 5459 PropertyNormalizationMode mode = object->map()->is_prototype_map() |
5452 ? KEEP_INOBJECT_PROPERTIES | 5460 ? KEEP_INOBJECT_PROPERTIES |
5453 : CLEAR_INOBJECT_PROPERTIES; | 5461 : CLEAR_INOBJECT_PROPERTIES; |
5454 Handle<JSObject> holder = it.GetHolder<JSObject>(); | 5462 Handle<JSObject> holder = it.GetHolder<JSObject>(); |
5455 // TODO(verwaest): Remove this temporary compatibility hack when blink | 5463 // TODO(verwaest): Remove this temporary compatibility hack when blink |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5656 PrototypeIterator iter(isolate, object); | 5664 PrototypeIterator iter(isolate, object); |
5657 if (iter.IsAtEnd()) return object; | 5665 if (iter.IsAtEnd()) return object; |
5658 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); | 5666 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); |
5659 return PreventExtensions( | 5667 return PreventExtensions( |
5660 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter))); | 5668 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter))); |
5661 } | 5669 } |
5662 | 5670 |
5663 // It's not possible to seal objects with external array elements | 5671 // It's not possible to seal objects with external array elements |
5664 if (object->HasExternalArrayElements() || | 5672 if (object->HasExternalArrayElements() || |
5665 object->HasFixedTypedArrayElements()) { | 5673 object->HasFixedTypedArrayElements()) { |
5666 THROW_NEW_ERROR( | 5674 THROW_NEW_ERROR(isolate, |
5667 isolate, NewTypeError(MessageTemplate::kCannotPreventExtExternalArray), | 5675 NewTypeError("cant_prevent_ext_external_array_elements", |
5668 Object); | 5676 HandleVector(&object, 1)), |
| 5677 Object); |
5669 } | 5678 } |
5670 | 5679 |
5671 // If there are fast elements we normalize. | 5680 // If there are fast elements we normalize. |
5672 Handle<SeededNumberDictionary> dictionary = NormalizeElements(object); | 5681 Handle<SeededNumberDictionary> dictionary = NormalizeElements(object); |
5673 DCHECK(object->HasDictionaryElements() || | 5682 DCHECK(object->HasDictionaryElements() || |
5674 object->HasDictionaryArgumentsElements()); | 5683 object->HasDictionaryArgumentsElements()); |
5675 | 5684 |
5676 // Make sure that we never go back to fast case. | 5685 // Make sure that we never go back to fast case. |
5677 dictionary->set_requires_slow_elements(); | 5686 dictionary->set_requires_slow_elements(); |
5678 | 5687 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5764 PrototypeIterator iter(isolate, object); | 5773 PrototypeIterator iter(isolate, object); |
5765 if (iter.IsAtEnd()) return object; | 5774 if (iter.IsAtEnd()) return object; |
5766 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); | 5775 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); |
5767 return PreventExtensionsWithTransition<attrs>( | 5776 return PreventExtensionsWithTransition<attrs>( |
5768 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter))); | 5777 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter))); |
5769 } | 5778 } |
5770 | 5779 |
5771 // It's not possible to seal or freeze objects with external array elements | 5780 // It's not possible to seal or freeze objects with external array elements |
5772 if (object->HasExternalArrayElements() || | 5781 if (object->HasExternalArrayElements() || |
5773 object->HasFixedTypedArrayElements()) { | 5782 object->HasFixedTypedArrayElements()) { |
5774 THROW_NEW_ERROR( | 5783 THROW_NEW_ERROR(isolate, |
5775 isolate, NewTypeError(MessageTemplate::kCannotPreventExtExternalArray), | 5784 NewTypeError("cant_prevent_ext_external_array_elements", |
5776 Object); | 5785 HandleVector(&object, 1)), |
| 5786 Object); |
5777 } | 5787 } |
5778 | 5788 |
5779 Handle<SeededNumberDictionary> new_element_dictionary; | 5789 Handle<SeededNumberDictionary> new_element_dictionary; |
5780 if (!object->elements()->IsDictionary()) { | 5790 if (!object->elements()->IsDictionary()) { |
5781 new_element_dictionary = GetNormalizedElementDictionary(object); | 5791 new_element_dictionary = GetNormalizedElementDictionary(object); |
5782 isolate->UpdateArrayProtectorOnNormalizeElements(object); | 5792 isolate->UpdateArrayProtectorOnNormalizeElements(object); |
5783 } | 5793 } |
5784 | 5794 |
5785 Handle<Symbol> transition_marker; | 5795 Handle<Symbol> transition_marker; |
5786 if (attrs == NONE) { | 5796 if (attrs == NONE) { |
(...skipping 4718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10505 name->IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) { | 10515 name->IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) { |
10506 return true; | 10516 return true; |
10507 } | 10517 } |
10508 return false; | 10518 return false; |
10509 } | 10519 } |
10510 | 10520 |
10511 | 10521 |
10512 Handle<String> JSFunction::GetDebugName(Handle<JSFunction> function) { | 10522 Handle<String> JSFunction::GetDebugName(Handle<JSFunction> function) { |
10513 Isolate* isolate = function->GetIsolate(); | 10523 Isolate* isolate = function->GetIsolate(); |
10514 Handle<Object> name = | 10524 Handle<Object> name = |
10515 JSReceiver::GetDataProperty(function, isolate->factory()->name_string()); | 10525 JSObject::GetDataProperty(function, isolate->factory()->name_string()); |
10516 if (name->IsString()) return Handle<String>::cast(name); | 10526 if (name->IsString()) return Handle<String>::cast(name); |
10517 return handle(function->shared()->DebugName(), isolate); | 10527 return handle(function->shared()->DebugName(), isolate); |
10518 } | 10528 } |
10519 | 10529 |
10520 | 10530 |
10521 void Oddball::Initialize(Isolate* isolate, | 10531 void Oddball::Initialize(Isolate* isolate, |
10522 Handle<Oddball> oddball, | 10532 Handle<Oddball> oddball, |
10523 const char* to_string, | 10533 const char* to_string, |
10524 Handle<Object> to_number, | 10534 Handle<Object> to_number, |
10525 byte kind) { | 10535 byte kind) { |
(...skipping 2053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12579 | 12589 |
12580 // From 8.6.2 Object Internal Methods | 12590 // From 8.6.2 Object Internal Methods |
12581 // ... | 12591 // ... |
12582 // In addition, if [[Extensible]] is false the value of the [[Class]] and | 12592 // In addition, if [[Extensible]] is false the value of the [[Class]] and |
12583 // [[Prototype]] internal properties of the object may not be modified. | 12593 // [[Prototype]] internal properties of the object may not be modified. |
12584 // ... | 12594 // ... |
12585 // Implementation specific extensions that modify [[Class]], [[Prototype]] | 12595 // Implementation specific extensions that modify [[Class]], [[Prototype]] |
12586 // or [[Extensible]] must not violate the invariants defined in the preceding | 12596 // or [[Extensible]] must not violate the invariants defined in the preceding |
12587 // paragraph. | 12597 // paragraph. |
12588 if (!object->map()->is_extensible()) { | 12598 if (!object->map()->is_extensible()) { |
12589 THROW_NEW_ERROR(isolate, | 12599 Handle<Object> args[] = { object }; |
12590 NewTypeError(MessageTemplate::kNonExtensibleProto, object), | 12600 THROW_NEW_ERROR(isolate, NewTypeError("non_extensible_proto", |
| 12601 HandleVector(args, arraysize(args))), |
12591 Object); | 12602 Object); |
12592 } | 12603 } |
12593 | 12604 |
12594 // Before we can set the prototype we need to be sure | 12605 // Before we can set the prototype we need to be sure |
12595 // prototype cycles are prevented. | 12606 // prototype cycles are prevented. |
12596 // It is sufficient to validate that the receiver is not in the new prototype | 12607 // It is sufficient to validate that the receiver is not in the new prototype |
12597 // chain. | 12608 // chain. |
12598 for (PrototypeIterator iter(isolate, *value, | 12609 for (PrototypeIterator iter(isolate, *value, |
12599 PrototypeIterator::START_AT_RECEIVER); | 12610 PrototypeIterator::START_AT_RECEIVER); |
12600 !iter.IsAtEnd(); iter.Advance()) { | 12611 !iter.IsAtEnd(); iter.Advance()) { |
12601 if (JSReceiver::cast(iter.GetCurrent()) == *object) { | 12612 if (JSReceiver::cast(iter.GetCurrent()) == *object) { |
12602 // Cycle detected. | 12613 // Cycle detected. |
12603 THROW_NEW_ERROR(isolate, NewError(MessageTemplate::kCyclicProto), Object); | 12614 THROW_NEW_ERROR(isolate, NewError(MessageTemplate::kCyclicProto), Object); |
12604 } | 12615 } |
12605 } | 12616 } |
12606 | 12617 |
12607 bool dictionary_elements_in_chain = | 12618 bool dictionary_elements_in_chain = |
12608 object->map()->DictionaryElementsInPrototypeChainOnly(); | 12619 object->map()->DictionaryElementsInPrototypeChainOnly(); |
12609 Handle<JSObject> real_receiver = object; | 12620 Handle<JSObject> real_receiver = object; |
12610 | 12621 |
12611 if (from_javascript) { | 12622 if (from_javascript) { |
12612 // Find the first object in the chain whose prototype object is not | 12623 // Find the first object in the chain whose prototype object is not |
12613 // hidden and set the new prototype on that object. | 12624 // hidden and set the new prototype on that object. |
12614 PrototypeIterator iter(isolate, real_receiver); | 12625 PrototypeIterator iter(isolate, real_receiver); |
12615 while (!iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN)) { | 12626 while (!iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN)) { |
12616 real_receiver = | 12627 real_receiver = |
12617 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)); | 12628 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)); |
12618 iter.Advance(); | 12629 iter.Advance(); |
12619 if (!real_receiver->map()->is_extensible()) { | 12630 if (!real_receiver->map()->is_extensible()) { |
12620 THROW_NEW_ERROR( | 12631 Handle<Object> args[] = {object}; |
12621 isolate, NewTypeError(MessageTemplate::kNonExtensibleProto, object), | 12632 THROW_NEW_ERROR(isolate, |
12622 Object); | 12633 NewTypeError("non_extensible_proto", |
| 12634 HandleVector(args, arraysize(args))), |
| 12635 Object); |
12623 } | 12636 } |
12624 } | 12637 } |
12625 } | 12638 } |
12626 | 12639 |
12627 // Set the new prototype of the object. | 12640 // Set the new prototype of the object. |
12628 Handle<Map> map(real_receiver->map()); | 12641 Handle<Map> map(real_receiver->map()); |
12629 | 12642 |
12630 // Nothing to do if prototype is already set. | 12643 // Nothing to do if prototype is already set. |
12631 if (map->prototype() == *value) return value; | 12644 if (map->prototype() == *value) return value; |
12632 | 12645 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12792 | 12805 |
12793 if (structure->IsAccessorPair()) { | 12806 if (structure->IsAccessorPair()) { |
12794 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); | 12807 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); |
12795 if (setter->IsSpecFunction()) { | 12808 if (setter->IsSpecFunction()) { |
12796 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 12809 // TODO(rossberg): nicer would be to cast to some JSCallable here... |
12797 return SetPropertyWithDefinedSetter( | 12810 return SetPropertyWithDefinedSetter( |
12798 object, Handle<JSReceiver>::cast(setter), value); | 12811 object, Handle<JSReceiver>::cast(setter), value); |
12799 } else { | 12812 } else { |
12800 if (is_sloppy(language_mode)) return value; | 12813 if (is_sloppy(language_mode)) return value; |
12801 Handle<Object> key(isolate->factory()->NewNumberFromUint(index)); | 12814 Handle<Object> key(isolate->factory()->NewNumberFromUint(index)); |
12802 THROW_NEW_ERROR( | 12815 Handle<Object> args[] = {key, holder}; |
12803 isolate, | 12816 THROW_NEW_ERROR(isolate, |
12804 NewTypeError(MessageTemplate::kNoSetterInCallback, key, holder), | 12817 NewTypeError("no_setter_in_callback", |
12805 Object); | 12818 HandleVector(args, arraysize(args))), |
| 12819 Object); |
12806 } | 12820 } |
12807 } | 12821 } |
12808 | 12822 |
12809 UNREACHABLE(); | 12823 UNREACHABLE(); |
12810 return MaybeHandle<Object>(); | 12824 return MaybeHandle<Object>(); |
12811 } | 12825 } |
12812 | 12826 |
12813 | 12827 |
12814 bool JSObject::HasFastArgumentsElements() { | 12828 bool JSObject::HasFastArgumentsElements() { |
12815 Heap* heap = GetHeap(); | 12829 Heap* heap = GetHeap(); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13034 } | 13048 } |
13035 | 13049 |
13036 // When we set the is_extensible flag to false we always force the | 13050 // When we set the is_extensible flag to false we always force the |
13037 // element into dictionary mode (and force them to stay there). | 13051 // element into dictionary mode (and force them to stay there). |
13038 if (!object->map()->is_extensible()) { | 13052 if (!object->map()->is_extensible()) { |
13039 if (is_sloppy(language_mode)) { | 13053 if (is_sloppy(language_mode)) { |
13040 return isolate->factory()->undefined_value(); | 13054 return isolate->factory()->undefined_value(); |
13041 } else { | 13055 } else { |
13042 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); | 13056 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); |
13043 Handle<String> name = isolate->factory()->NumberToString(number); | 13057 Handle<String> name = isolate->factory()->NumberToString(number); |
13044 THROW_NEW_ERROR( | 13058 Handle<Object> args[] = {name}; |
13045 isolate, NewTypeError(MessageTemplate::kObjectNotExtensible, name), | 13059 THROW_NEW_ERROR(isolate, |
13046 Object); | 13060 NewTypeError("object_not_extensible", |
| 13061 HandleVector(args, arraysize(args))), |
| 13062 Object); |
13047 } | 13063 } |
13048 } | 13064 } |
13049 | 13065 |
13050 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); | 13066 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); |
13051 Handle<SeededNumberDictionary> new_dictionary = | 13067 Handle<SeededNumberDictionary> new_dictionary = |
13052 SeededNumberDictionary::AddNumberEntry(dictionary, index, value, | 13068 SeededNumberDictionary::AddNumberEntry(dictionary, index, value, |
13053 details); | 13069 details); |
13054 if (*dictionary != *new_dictionary) { | 13070 if (*dictionary != *new_dictionary) { |
13055 if (is_arguments) { | 13071 if (is_arguments) { |
13056 elements->set(1, *new_dictionary); | 13072 elements->set(1, *new_dictionary); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13253 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); | 13269 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); |
13254 return SetElement( | 13270 return SetElement( |
13255 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), index, | 13271 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), index, |
13256 value, attributes, language_mode, check_prototype, set_mode); | 13272 value, attributes, language_mode, check_prototype, set_mode); |
13257 } | 13273 } |
13258 | 13274 |
13259 // Don't allow element properties to be redefined for external arrays. | 13275 // Don't allow element properties to be redefined for external arrays. |
13260 if ((object->HasExternalArrayElements() || | 13276 if ((object->HasExternalArrayElements() || |
13261 object->HasFixedTypedArrayElements()) && | 13277 object->HasFixedTypedArrayElements()) && |
13262 set_mode == DEFINE_PROPERTY) { | 13278 set_mode == DEFINE_PROPERTY) { |
13263 THROW_NEW_ERROR( | 13279 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); |
13264 isolate, NewTypeError(MessageTemplate::kRedefineExternalArray), Object); | 13280 Handle<Object> args[] = { object, number }; |
| 13281 THROW_NEW_ERROR(isolate, NewTypeError("redef_external_array_element", |
| 13282 HandleVector(args, arraysize(args))), |
| 13283 Object); |
13265 } | 13284 } |
13266 | 13285 |
13267 // Normalize the elements to enable attributes on the property. | 13286 // Normalize the elements to enable attributes on the property. |
13268 if ((attributes & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0) { | 13287 if ((attributes & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0) { |
13269 Handle<SeededNumberDictionary> dictionary = NormalizeElements(object); | 13288 Handle<SeededNumberDictionary> dictionary = NormalizeElements(object); |
13270 // Make sure that we never go back to fast case. | 13289 // Make sure that we never go back to fast case. |
13271 dictionary->set_requires_slow_elements(); | 13290 dictionary->set_requires_slow_elements(); |
13272 } | 13291 } |
13273 | 13292 |
13274 if (!object->map()->is_observed()) { | 13293 if (!object->map()->is_observed()) { |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13697 uint32_t length = 0; | 13716 uint32_t length = 0; |
13698 CHECK(array->length()->ToArrayIndex(&length)); | 13717 CHECK(array->length()->ToArrayIndex(&length)); |
13699 if (length <= index) return HasReadOnlyLength(array); | 13718 if (length <= index) return HasReadOnlyLength(array); |
13700 return false; | 13719 return false; |
13701 } | 13720 } |
13702 | 13721 |
13703 | 13722 |
13704 MaybeHandle<Object> JSArray::ReadOnlyLengthError(Handle<JSArray> array) { | 13723 MaybeHandle<Object> JSArray::ReadOnlyLengthError(Handle<JSArray> array) { |
13705 Isolate* isolate = array->GetIsolate(); | 13724 Isolate* isolate = array->GetIsolate(); |
13706 Handle<Name> length = isolate->factory()->length_string(); | 13725 Handle<Name> length = isolate->factory()->length_string(); |
13707 THROW_NEW_ERROR( | 13726 Handle<Object> args[] = {length, array}; |
13708 isolate, | 13727 THROW_NEW_ERROR(isolate, NewTypeError("strict_read_only_property", |
13709 NewTypeError(MessageTemplate::kStrictReadOnlyProperty, length, array), | 13728 HandleVector(args, arraysize(args))), |
13710 Object); | 13729 Object); |
13711 } | 13730 } |
13712 | 13731 |
13713 | 13732 |
13714 MaybeHandle<Object> JSObject::GetElementWithInterceptor(Handle<JSObject> object, | 13733 MaybeHandle<Object> JSObject::GetElementWithInterceptor(Handle<JSObject> object, |
13715 Handle<Object> receiver, | 13734 Handle<Object> receiver, |
13716 uint32_t index, | 13735 uint32_t index, |
13717 bool check_prototype) { | 13736 bool check_prototype) { |
13718 Isolate* isolate = object->GetIsolate(); | 13737 Isolate* isolate = object->GetIsolate(); |
13719 | 13738 |
13720 // Make sure that the top context does not change when doing | 13739 // Make sure that the top context does not change when doing |
(...skipping 3497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17218 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell, | 17237 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell, |
17219 Handle<Object> new_value) { | 17238 Handle<Object> new_value) { |
17220 if (cell->value() != *new_value) { | 17239 if (cell->value() != *new_value) { |
17221 cell->set_value(*new_value); | 17240 cell->set_value(*new_value); |
17222 Isolate* isolate = cell->GetIsolate(); | 17241 Isolate* isolate = cell->GetIsolate(); |
17223 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 17242 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
17224 isolate, DependentCode::kPropertyCellChangedGroup); | 17243 isolate, DependentCode::kPropertyCellChangedGroup); |
17225 } | 17244 } |
17226 } | 17245 } |
17227 } } // namespace v8::internal | 17246 } } // namespace v8::internal |
OLD | NEW |