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