OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 Handle<Name> name, | 417 Handle<Name> name, |
418 Handle<JSObject> holder, | 418 Handle<JSObject> holder, |
419 Handle<Object> structure) { | 419 Handle<Object> structure) { |
420 Isolate* isolate = name->GetIsolate(); | 420 Isolate* isolate = name->GetIsolate(); |
421 DCHECK(!structure->IsForeign()); | 421 DCHECK(!structure->IsForeign()); |
422 // api style callbacks. | 422 // api style callbacks. |
423 if (structure->IsAccessorInfo()) { | 423 if (structure->IsAccessorInfo()) { |
424 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure); | 424 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure); |
425 if (!info->IsCompatibleReceiver(*receiver)) { | 425 if (!info->IsCompatibleReceiver(*receiver)) { |
426 Handle<Object> args[2] = { name, receiver }; | 426 Handle<Object> args[2] = { name, receiver }; |
427 Handle<Object> error = | 427 THROW_NEW_ERROR(isolate, |
428 isolate->factory()->NewTypeError("incompatible_method_receiver", | 428 NewTypeError("incompatible_method_receiver", |
429 HandleVector(args, | 429 HandleVector(args, arraysize(args))), |
430 arraysize(args))); | 430 Object); |
431 return isolate->Throw<Object>(error); | |
432 } | 431 } |
433 if (structure->IsDeclaredAccessorInfo()) { | 432 if (structure->IsDeclaredAccessorInfo()) { |
434 return GetDeclaredAccessorProperty( | 433 return GetDeclaredAccessorProperty( |
435 receiver, | 434 receiver, |
436 Handle<DeclaredAccessorInfo>::cast(structure), | 435 Handle<DeclaredAccessorInfo>::cast(structure), |
437 isolate); | 436 isolate); |
438 } | 437 } |
439 | 438 |
440 Handle<ExecutableAccessorInfo> data = | 439 Handle<ExecutableAccessorInfo> data = |
441 Handle<ExecutableAccessorInfo>::cast(structure); | 440 Handle<ExecutableAccessorInfo>::cast(structure); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 // We should never get here to initialize a const with the hole | 488 // We should never get here to initialize a const with the hole |
490 // value since a const declaration would conflict with the setter. | 489 // value since a const declaration would conflict with the setter. |
491 DCHECK(!structure->IsForeign()); | 490 DCHECK(!structure->IsForeign()); |
492 if (structure->IsExecutableAccessorInfo()) { | 491 if (structure->IsExecutableAccessorInfo()) { |
493 // Don't call executable accessor setters with non-JSObject receivers. | 492 // Don't call executable accessor setters with non-JSObject receivers. |
494 if (!receiver->IsJSObject()) return value; | 493 if (!receiver->IsJSObject()) return value; |
495 // api style callbacks | 494 // api style callbacks |
496 ExecutableAccessorInfo* info = ExecutableAccessorInfo::cast(*structure); | 495 ExecutableAccessorInfo* info = ExecutableAccessorInfo::cast(*structure); |
497 if (!info->IsCompatibleReceiver(*receiver)) { | 496 if (!info->IsCompatibleReceiver(*receiver)) { |
498 Handle<Object> args[2] = { name, receiver }; | 497 Handle<Object> args[2] = { name, receiver }; |
499 Handle<Object> error = | 498 THROW_NEW_ERROR(isolate, |
500 isolate->factory()->NewTypeError("incompatible_method_receiver", | 499 NewTypeError("incompatible_method_receiver", |
501 HandleVector(args, | 500 HandleVector(args, arraysize(args))), |
502 arraysize(args))); | 501 Object); |
503 return isolate->Throw<Object>(error); | |
504 } | 502 } |
505 Object* call_obj = info->setter(); | 503 Object* call_obj = info->setter(); |
506 v8::AccessorNameSetterCallback call_fun = | 504 v8::AccessorNameSetterCallback call_fun = |
507 v8::ToCData<v8::AccessorNameSetterCallback>(call_obj); | 505 v8::ToCData<v8::AccessorNameSetterCallback>(call_obj); |
508 if (call_fun == NULL) return value; | 506 if (call_fun == NULL) return value; |
509 LOG(isolate, ApiNamedPropertyAccess("store", *holder, *name)); | 507 LOG(isolate, ApiNamedPropertyAccess("store", *holder, *name)); |
510 PropertyCallbackArguments args(isolate, info->data(), *receiver, *holder); | 508 PropertyCallbackArguments args(isolate, info->data(), *receiver, *holder); |
511 args.Call(call_fun, | 509 args.Call(call_fun, |
512 v8::Utils::ToLocal(name), | 510 v8::Utils::ToLocal(name), |
513 v8::Utils::ToLocal(value)); | 511 v8::Utils::ToLocal(value)); |
514 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | 512 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
515 return value; | 513 return value; |
516 } | 514 } |
517 | 515 |
518 if (structure->IsAccessorPair()) { | 516 if (structure->IsAccessorPair()) { |
519 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); | 517 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); |
520 if (setter->IsSpecFunction()) { | 518 if (setter->IsSpecFunction()) { |
521 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 519 // TODO(rossberg): nicer would be to cast to some JSCallable here... |
522 return SetPropertyWithDefinedSetter( | 520 return SetPropertyWithDefinedSetter( |
523 receiver, Handle<JSReceiver>::cast(setter), value); | 521 receiver, Handle<JSReceiver>::cast(setter), value); |
524 } else { | 522 } else { |
525 if (strict_mode == SLOPPY) return value; | 523 if (strict_mode == SLOPPY) return value; |
526 Handle<Object> args[2] = { name, holder }; | 524 Handle<Object> args[2] = { name, holder }; |
527 Handle<Object> error = | 525 THROW_NEW_ERROR( |
528 isolate->factory()->NewTypeError("no_setter_in_callback", | 526 isolate, NewTypeError("no_setter_in_callback", HandleVector(args, 2)), |
529 HandleVector(args, 2)); | 527 Object); |
530 return isolate->Throw<Object>(error); | |
531 } | 528 } |
532 } | 529 } |
533 | 530 |
534 // TODO(dcarney): Handle correctly. | 531 // TODO(dcarney): Handle correctly. |
535 if (structure->IsDeclaredAccessorInfo()) { | 532 if (structure->IsDeclaredAccessorInfo()) { |
536 return value; | 533 return value; |
537 } | 534 } |
538 | 535 |
539 UNREACHABLE(); | 536 UNREACHABLE(); |
540 return MaybeHandle<Object>(); | 537 return MaybeHandle<Object>(); |
(...skipping 2361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2902 } | 2899 } |
2903 | 2900 |
2904 if (done) break; | 2901 if (done) break; |
2905 } | 2902 } |
2906 | 2903 |
2907 // If the receiver is the JSGlobalObject, the store was contextual. In case | 2904 // If the receiver is the JSGlobalObject, the store was contextual. In case |
2908 // the property did not exist yet on the global object itself, we have to | 2905 // the property did not exist yet on the global object itself, we have to |
2909 // throw a reference error in strict mode. | 2906 // throw a reference error in strict mode. |
2910 if (it->GetReceiver()->IsJSGlobalObject() && strict_mode == STRICT) { | 2907 if (it->GetReceiver()->IsJSGlobalObject() && strict_mode == STRICT) { |
2911 Handle<Object> args[1] = {it->name()}; | 2908 Handle<Object> args[1] = {it->name()}; |
2912 Handle<Object> error = it->isolate()->factory()->NewReferenceError( | 2909 THROW_NEW_ERROR(it->isolate(), |
2913 "not_defined", HandleVector(args, 1)); | 2910 NewReferenceError("not_defined", HandleVector(args, 1)), |
2914 return it->isolate()->Throw<Object>(error); | 2911 Object); |
2915 } | 2912 } |
2916 | 2913 |
2917 return AddDataProperty(it, value, NONE, strict_mode, store_mode); | 2914 return AddDataProperty(it, value, NONE, strict_mode, store_mode); |
2918 } | 2915 } |
2919 | 2916 |
2920 | 2917 |
2921 MaybeHandle<Object> Object::WriteToReadOnlyProperty(LookupIterator* it, | 2918 MaybeHandle<Object> Object::WriteToReadOnlyProperty(LookupIterator* it, |
2922 Handle<Object> value, | 2919 Handle<Object> value, |
2923 StrictMode strict_mode) { | 2920 StrictMode strict_mode) { |
2924 if (strict_mode != STRICT) return value; | 2921 if (strict_mode != STRICT) return value; |
2925 | 2922 |
2926 Handle<Object> args[] = {it->name(), it->GetReceiver()}; | 2923 Handle<Object> args[] = {it->name(), it->GetReceiver()}; |
2927 Handle<Object> error = it->factory()->NewTypeError( | 2924 THROW_NEW_ERROR(it->isolate(), |
2928 "strict_read_only_property", HandleVector(args, arraysize(args))); | 2925 NewTypeError("strict_read_only_property", |
2929 return it->isolate()->Throw<Object>(error); | 2926 HandleVector(args, arraysize(args))), |
| 2927 Object); |
2930 } | 2928 } |
2931 | 2929 |
2932 | 2930 |
2933 Handle<Object> Object::SetDataProperty(LookupIterator* it, | 2931 Handle<Object> Object::SetDataProperty(LookupIterator* it, |
2934 Handle<Object> value) { | 2932 Handle<Object> value) { |
2935 // Proxies are handled on the WithHandler path. Other non-JSObjects cannot | 2933 // Proxies are handled on the WithHandler path. Other non-JSObjects cannot |
2936 // have own properties. | 2934 // have own properties. |
2937 Handle<JSObject> receiver = Handle<JSObject>::cast(it->GetReceiver()); | 2935 Handle<JSObject> receiver = Handle<JSObject>::cast(it->GetReceiver()); |
2938 | 2936 |
2939 // Store on the holder which may be hidden behind the receiver. | 2937 // Store on the holder which may be hidden behind the receiver. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2982 // instead. If the prototype is Null, the proxy is detached. | 2980 // instead. If the prototype is Null, the proxy is detached. |
2983 if (receiver->IsJSGlobalProxy()) return value; | 2981 if (receiver->IsJSGlobalProxy()) return value; |
2984 | 2982 |
2985 // Possibly migrate to the most up-to-date map that will be able to store | 2983 // Possibly migrate to the most up-to-date map that will be able to store |
2986 // |value| under it->name() with |attributes|. | 2984 // |value| under it->name() with |attributes|. |
2987 it->PrepareTransitionToDataProperty(value, attributes, store_mode); | 2985 it->PrepareTransitionToDataProperty(value, attributes, store_mode); |
2988 if (it->state() != LookupIterator::TRANSITION) { | 2986 if (it->state() != LookupIterator::TRANSITION) { |
2989 if (strict_mode == SLOPPY) return value; | 2987 if (strict_mode == SLOPPY) return value; |
2990 | 2988 |
2991 Handle<Object> args[1] = {it->name()}; | 2989 Handle<Object> args[1] = {it->name()}; |
2992 Handle<Object> error = it->factory()->NewTypeError( | 2990 THROW_NEW_ERROR(it->isolate(), |
2993 "object_not_extensible", HandleVector(args, arraysize(args))); | 2991 NewTypeError("object_not_extensible", |
2994 return it->isolate()->Throw<Object>(error); | 2992 HandleVector(args, arraysize(args))), |
| 2993 Object); |
2995 } | 2994 } |
2996 it->ApplyTransitionToDataProperty(); | 2995 it->ApplyTransitionToDataProperty(); |
2997 | 2996 |
2998 // TODO(verwaest): Encapsulate dictionary handling better. | 2997 // TODO(verwaest): Encapsulate dictionary handling better. |
2999 if (receiver->map()->is_dictionary_map()) { | 2998 if (receiver->map()->is_dictionary_map()) { |
3000 // TODO(verwaest): Probably should ensure this is done beforehand. | 2999 // TODO(verwaest): Probably should ensure this is done beforehand. |
3001 it->InternalizeName(); | 3000 it->InternalizeName(); |
3002 JSObject::AddSlowProperty(receiver, it->name(), value, attributes); | 3001 JSObject::AddSlowProperty(receiver, it->name(), value, attributes); |
3003 } else { | 3002 } else { |
3004 // Write the property value. | 3003 // Write the property value. |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3476 isolate->factory()->InternalizeOneByteString( | 3475 isolate->factory()->InternalizeOneByteString( |
3477 STATIC_ASCII_VECTOR("configurable_")); | 3476 STATIC_ASCII_VECTOR("configurable_")); |
3478 Handle<Object> configurable = | 3477 Handle<Object> configurable = |
3479 Object::GetProperty(desc, configurable_name).ToHandleChecked(); | 3478 Object::GetProperty(desc, configurable_name).ToHandleChecked(); |
3480 DCHECK(configurable->IsBoolean()); | 3479 DCHECK(configurable->IsBoolean()); |
3481 if (configurable->IsFalse()) { | 3480 if (configurable->IsFalse()) { |
3482 Handle<String> trap = | 3481 Handle<String> trap = |
3483 isolate->factory()->InternalizeOneByteString( | 3482 isolate->factory()->InternalizeOneByteString( |
3484 STATIC_ASCII_VECTOR("getPropertyDescriptor")); | 3483 STATIC_ASCII_VECTOR("getPropertyDescriptor")); |
3485 Handle<Object> args[] = { handler, trap, name }; | 3484 Handle<Object> args[] = { handler, trap, name }; |
3486 Handle<Object> error = isolate->factory()->NewTypeError( | 3485 THROW_NEW_ERROR(isolate, NewTypeError("proxy_prop_not_configurable", |
3487 "proxy_prop_not_configurable", HandleVector(args, arraysize(args))); | 3486 HandleVector(args, arraysize(args))), |
3488 return isolate->Throw<Object>(error); | 3487 Object); |
3489 } | 3488 } |
3490 DCHECK(configurable->IsTrue()); | 3489 DCHECK(configurable->IsTrue()); |
3491 | 3490 |
3492 // Check for DataDescriptor. | 3491 // Check for DataDescriptor. |
3493 Handle<String> hasWritable_name = | 3492 Handle<String> hasWritable_name = |
3494 isolate->factory()->InternalizeOneByteString( | 3493 isolate->factory()->InternalizeOneByteString( |
3495 STATIC_ASCII_VECTOR("hasWritable_")); | 3494 STATIC_ASCII_VECTOR("hasWritable_")); |
3496 Handle<Object> hasWritable = | 3495 Handle<Object> hasWritable = |
3497 Object::GetProperty(desc, hasWritable_name).ToHandleChecked(); | 3496 Object::GetProperty(desc, hasWritable_name).ToHandleChecked(); |
3498 DCHECK(hasWritable->IsBoolean()); | 3497 DCHECK(hasWritable->IsBoolean()); |
3499 if (hasWritable->IsTrue()) { | 3498 if (hasWritable->IsTrue()) { |
3500 Handle<String> writable_name = | 3499 Handle<String> writable_name = |
3501 isolate->factory()->InternalizeOneByteString( | 3500 isolate->factory()->InternalizeOneByteString( |
3502 STATIC_ASCII_VECTOR("writable_")); | 3501 STATIC_ASCII_VECTOR("writable_")); |
3503 Handle<Object> writable = | 3502 Handle<Object> writable = |
3504 Object::GetProperty(desc, writable_name).ToHandleChecked(); | 3503 Object::GetProperty(desc, writable_name).ToHandleChecked(); |
3505 DCHECK(writable->IsBoolean()); | 3504 DCHECK(writable->IsBoolean()); |
3506 *done = writable->IsFalse(); | 3505 *done = writable->IsFalse(); |
3507 if (!*done) return isolate->factory()->the_hole_value(); | 3506 if (!*done) return isolate->factory()->the_hole_value(); |
3508 if (strict_mode == SLOPPY) return value; | 3507 if (strict_mode == SLOPPY) return value; |
3509 Handle<Object> args[] = { name, receiver }; | 3508 Handle<Object> args[] = { name, receiver }; |
3510 Handle<Object> error = isolate->factory()->NewTypeError( | 3509 THROW_NEW_ERROR(isolate, NewTypeError("strict_read_only_property", |
3511 "strict_read_only_property", HandleVector(args, arraysize(args))); | 3510 HandleVector(args, arraysize(args))), |
3512 return isolate->Throw<Object>(error); | 3511 Object); |
3513 } | 3512 } |
3514 | 3513 |
3515 // We have an AccessorDescriptor. | 3514 // We have an AccessorDescriptor. |
3516 Handle<String> set_name = isolate->factory()->InternalizeOneByteString( | 3515 Handle<String> set_name = isolate->factory()->InternalizeOneByteString( |
3517 STATIC_ASCII_VECTOR("set_")); | 3516 STATIC_ASCII_VECTOR("set_")); |
3518 Handle<Object> setter = Object::GetProperty(desc, set_name).ToHandleChecked(); | 3517 Handle<Object> setter = Object::GetProperty(desc, set_name).ToHandleChecked(); |
3519 if (!setter->IsUndefined()) { | 3518 if (!setter->IsUndefined()) { |
3520 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 3519 // TODO(rossberg): nicer would be to cast to some JSCallable here... |
3521 return SetPropertyWithDefinedSetter( | 3520 return SetPropertyWithDefinedSetter( |
3522 receiver, Handle<JSReceiver>::cast(setter), value); | 3521 receiver, Handle<JSReceiver>::cast(setter), value); |
3523 } | 3522 } |
3524 | 3523 |
3525 if (strict_mode == SLOPPY) return value; | 3524 if (strict_mode == SLOPPY) return value; |
3526 Handle<Object> args2[] = { name, proxy }; | 3525 Handle<Object> args2[] = { name, proxy }; |
3527 Handle<Object> error = isolate->factory()->NewTypeError( | 3526 THROW_NEW_ERROR(isolate, NewTypeError("no_setter_in_callback", |
3528 "no_setter_in_callback", HandleVector(args2, arraysize(args2))); | 3527 HandleVector(args2, arraysize(args2))), |
3529 return isolate->Throw<Object>(error); | 3528 Object); |
3530 } | 3529 } |
3531 | 3530 |
3532 | 3531 |
3533 MaybeHandle<Object> JSProxy::DeletePropertyWithHandler( | 3532 MaybeHandle<Object> JSProxy::DeletePropertyWithHandler( |
3534 Handle<JSProxy> proxy, Handle<Name> name, DeleteMode mode) { | 3533 Handle<JSProxy> proxy, Handle<Name> name, DeleteMode mode) { |
3535 Isolate* isolate = proxy->GetIsolate(); | 3534 Isolate* isolate = proxy->GetIsolate(); |
3536 | 3535 |
3537 // TODO(rossberg): adjust once there is a story for symbols vs proxies. | 3536 // TODO(rossberg): adjust once there is a story for symbols vs proxies. |
3538 if (name->IsSymbol()) return isolate->factory()->false_value(); | 3537 if (name->IsSymbol()) return isolate->factory()->false_value(); |
3539 | 3538 |
3540 Handle<Object> args[] = { name }; | 3539 Handle<Object> args[] = { name }; |
3541 Handle<Object> result; | 3540 Handle<Object> result; |
3542 ASSIGN_RETURN_ON_EXCEPTION( | 3541 ASSIGN_RETURN_ON_EXCEPTION( |
3543 isolate, result, | 3542 isolate, result, |
3544 CallTrap(proxy, | 3543 CallTrap(proxy, |
3545 "delete", | 3544 "delete", |
3546 Handle<Object>(), | 3545 Handle<Object>(), |
3547 arraysize(args), | 3546 arraysize(args), |
3548 args), | 3547 args), |
3549 Object); | 3548 Object); |
3550 | 3549 |
3551 bool result_bool = result->BooleanValue(); | 3550 bool result_bool = result->BooleanValue(); |
3552 if (mode == STRICT_DELETION && !result_bool) { | 3551 if (mode == STRICT_DELETION && !result_bool) { |
3553 Handle<Object> handler(proxy->handler(), isolate); | 3552 Handle<Object> handler(proxy->handler(), isolate); |
3554 Handle<String> trap_name = isolate->factory()->InternalizeOneByteString( | 3553 Handle<String> trap_name = isolate->factory()->InternalizeOneByteString( |
3555 STATIC_ASCII_VECTOR("delete")); | 3554 STATIC_ASCII_VECTOR("delete")); |
3556 Handle<Object> args[] = { handler, trap_name }; | 3555 Handle<Object> args[] = { handler, trap_name }; |
3557 Handle<Object> error = isolate->factory()->NewTypeError( | 3556 THROW_NEW_ERROR(isolate, NewTypeError("handler_failed", |
3558 "handler_failed", HandleVector(args, arraysize(args))); | 3557 HandleVector(args, arraysize(args))), |
3559 return isolate->Throw<Object>(error); | 3558 Object); |
3560 } | 3559 } |
3561 return isolate->factory()->ToBoolean(result_bool); | 3560 return isolate->factory()->ToBoolean(result_bool); |
3562 } | 3561 } |
3563 | 3562 |
3564 | 3563 |
3565 MaybeHandle<Object> JSProxy::DeleteElementWithHandler( | 3564 MaybeHandle<Object> JSProxy::DeleteElementWithHandler( |
3566 Handle<JSProxy> proxy, uint32_t index, DeleteMode mode) { | 3565 Handle<JSProxy> proxy, uint32_t index, DeleteMode mode) { |
3567 Isolate* isolate = proxy->GetIsolate(); | 3566 Isolate* isolate = proxy->GetIsolate(); |
3568 Handle<String> name = isolate->factory()->Uint32ToString(index); | 3567 Handle<String> name = isolate->factory()->Uint32ToString(index); |
3569 return JSProxy::DeletePropertyWithHandler(proxy, name, mode); | 3568 return JSProxy::DeletePropertyWithHandler(proxy, name, mode); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3623 Object::GetProperty(desc, set_n), | 3622 Object::GetProperty(desc, set_n), |
3624 Maybe<PropertyAttributes>()); | 3623 Maybe<PropertyAttributes>()); |
3625 writable = isolate->factory()->ToBoolean(!setter->IsUndefined()); | 3624 writable = isolate->factory()->ToBoolean(!setter->IsUndefined()); |
3626 } | 3625 } |
3627 | 3626 |
3628 if (configurable->IsFalse()) { | 3627 if (configurable->IsFalse()) { |
3629 Handle<Object> handler(proxy->handler(), isolate); | 3628 Handle<Object> handler(proxy->handler(), isolate); |
3630 Handle<String> trap = isolate->factory()->InternalizeOneByteString( | 3629 Handle<String> trap = isolate->factory()->InternalizeOneByteString( |
3631 STATIC_ASCII_VECTOR("getPropertyDescriptor")); | 3630 STATIC_ASCII_VECTOR("getPropertyDescriptor")); |
3632 Handle<Object> args[] = { handler, trap, name }; | 3631 Handle<Object> args[] = { handler, trap, name }; |
3633 Handle<Object> error = isolate->factory()->NewTypeError( | 3632 Handle<Object> error; |
| 3633 MaybeHandle<Object> maybe_error = isolate->factory()->NewTypeError( |
3634 "proxy_prop_not_configurable", HandleVector(args, arraysize(args))); | 3634 "proxy_prop_not_configurable", HandleVector(args, arraysize(args))); |
3635 isolate->Throw(*error); | 3635 if (maybe_error.ToHandle(&error)) isolate->Throw(*error); |
3636 return maybe(NONE); | 3636 return maybe(NONE); |
3637 } | 3637 } |
3638 | 3638 |
3639 int attributes = NONE; | 3639 int attributes = NONE; |
3640 if (!enumerable->BooleanValue()) attributes |= DONT_ENUM; | 3640 if (!enumerable->BooleanValue()) attributes |= DONT_ENUM; |
3641 if (!configurable->BooleanValue()) attributes |= DONT_DELETE; | 3641 if (!configurable->BooleanValue()) attributes |= DONT_DELETE; |
3642 if (!writable->BooleanValue()) attributes |= READ_ONLY; | 3642 if (!writable->BooleanValue()) attributes |= READ_ONLY; |
3643 return maybe(static_cast<PropertyAttributes>(attributes)); | 3643 return maybe(static_cast<PropertyAttributes>(attributes)); |
3644 } | 3644 } |
3645 | 3645 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3685 Handle<String> trap_name = isolate->factory()->InternalizeUtf8String(name); | 3685 Handle<String> trap_name = isolate->factory()->InternalizeUtf8String(name); |
3686 Handle<Object> trap; | 3686 Handle<Object> trap; |
3687 ASSIGN_RETURN_ON_EXCEPTION( | 3687 ASSIGN_RETURN_ON_EXCEPTION( |
3688 isolate, trap, | 3688 isolate, trap, |
3689 Object::GetPropertyOrElement(handler, trap_name), | 3689 Object::GetPropertyOrElement(handler, trap_name), |
3690 Object); | 3690 Object); |
3691 | 3691 |
3692 if (trap->IsUndefined()) { | 3692 if (trap->IsUndefined()) { |
3693 if (derived.is_null()) { | 3693 if (derived.is_null()) { |
3694 Handle<Object> args[] = { handler, trap_name }; | 3694 Handle<Object> args[] = { handler, trap_name }; |
3695 Handle<Object> error = isolate->factory()->NewTypeError( | 3695 THROW_NEW_ERROR(isolate, |
3696 "handler_trap_missing", HandleVector(args, arraysize(args))); | 3696 NewTypeError("handler_trap_missing", |
3697 return isolate->Throw<Object>(error); | 3697 HandleVector(args, arraysize(args))), |
| 3698 Object); |
3698 } | 3699 } |
3699 trap = Handle<Object>(derived); | 3700 trap = Handle<Object>(derived); |
3700 } | 3701 } |
3701 | 3702 |
3702 return Execution::Call(isolate, trap, handler, argc, argv); | 3703 return Execution::Call(isolate, trap, handler, argc, argv); |
3703 } | 3704 } |
3704 | 3705 |
3705 | 3706 |
3706 void JSObject::AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map) { | 3707 void JSObject::AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map) { |
3707 DCHECK(object->map()->inobject_properties() == map->inobject_properties()); | 3708 DCHECK(object->map()->inobject_properties() == map->inobject_properties()); |
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4839 isolate->ReportFailedAccessCheck(object, v8::ACCESS_DELETE); | 4840 isolate->ReportFailedAccessCheck(object, v8::ACCESS_DELETE); |
4840 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | 4841 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
4841 return factory->false_value(); | 4842 return factory->false_value(); |
4842 } | 4843 } |
4843 | 4844 |
4844 if (object->IsStringObjectWithCharacterAt(index)) { | 4845 if (object->IsStringObjectWithCharacterAt(index)) { |
4845 if (mode == STRICT_DELETION) { | 4846 if (mode == STRICT_DELETION) { |
4846 // Deleting a non-configurable property in strict mode. | 4847 // Deleting a non-configurable property in strict mode. |
4847 Handle<Object> name = factory->NewNumberFromUint(index); | 4848 Handle<Object> name = factory->NewNumberFromUint(index); |
4848 Handle<Object> args[2] = { name, object }; | 4849 Handle<Object> args[2] = { name, object }; |
4849 Handle<Object> error = | 4850 THROW_NEW_ERROR(isolate, NewTypeError("strict_delete_property", |
4850 factory->NewTypeError("strict_delete_property", | 4851 HandleVector(args, 2)), |
4851 HandleVector(args, 2)); | 4852 Object); |
4852 isolate->Throw(*error); | |
4853 return Handle<Object>(); | |
4854 } | 4853 } |
4855 return factory->false_value(); | 4854 return factory->false_value(); |
4856 } | 4855 } |
4857 | 4856 |
4858 if (object->IsJSGlobalProxy()) { | 4857 if (object->IsJSGlobalProxy()) { |
4859 PrototypeIterator iter(isolate, object); | 4858 PrototypeIterator iter(isolate, object); |
4860 if (iter.IsAtEnd()) return factory->false_value(); | 4859 if (iter.IsAtEnd()) return factory->false_value(); |
4861 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); | 4860 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); |
4862 return DeleteElement( | 4861 return DeleteElement( |
4863 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), index, | 4862 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), index, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4945 // An exception was thrown in the interceptor. Propagate. | 4944 // An exception was thrown in the interceptor. Propagate. |
4946 if (it.isolate()->has_pending_exception()) return maybe_result; | 4945 if (it.isolate()->has_pending_exception()) return maybe_result; |
4947 break; | 4946 break; |
4948 } | 4947 } |
4949 case LookupIterator::PROPERTY: { | 4948 case LookupIterator::PROPERTY: { |
4950 if (!it.HasProperty()) continue; | 4949 if (!it.HasProperty()) continue; |
4951 if (delete_mode != FORCE_DELETION && !it.IsConfigurable()) { | 4950 if (delete_mode != FORCE_DELETION && !it.IsConfigurable()) { |
4952 // Fail if the property is not configurable. | 4951 // Fail if the property is not configurable. |
4953 if (delete_mode == STRICT_DELETION) { | 4952 if (delete_mode == STRICT_DELETION) { |
4954 Handle<Object> args[2] = {name, object}; | 4953 Handle<Object> args[2] = {name, object}; |
4955 Handle<Object> error = it.isolate()->factory()->NewTypeError( | 4954 THROW_NEW_ERROR(it.isolate(), |
4956 "strict_delete_property", HandleVector(args, arraysize(args))); | 4955 NewTypeError("strict_delete_property", |
4957 it.isolate()->Throw(*error); | 4956 HandleVector(args, arraysize(args))), |
4958 return Handle<Object>(); | 4957 Object); |
4959 } | 4958 } |
4960 return it.isolate()->factory()->false_value(); | 4959 return it.isolate()->factory()->false_value(); |
4961 } | 4960 } |
4962 | 4961 |
4963 Handle<Object> old_value; | 4962 Handle<Object> old_value; |
4964 if (is_observed) { | 4963 if (is_observed) { |
4965 switch (it.property_kind()) { | 4964 switch (it.property_kind()) { |
4966 case LookupIterator::ACCESSOR: | 4965 case LookupIterator::ACCESSOR: |
4967 old_value = it.isolate()->factory()->the_hole_value(); | 4966 old_value = it.isolate()->factory()->the_hole_value(); |
4968 break; | 4967 break; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5173 PrototypeIterator iter(isolate, object); | 5172 PrototypeIterator iter(isolate, object); |
5174 if (iter.IsAtEnd()) return object; | 5173 if (iter.IsAtEnd()) return object; |
5175 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); | 5174 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); |
5176 return PreventExtensions( | 5175 return PreventExtensions( |
5177 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter))); | 5176 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter))); |
5178 } | 5177 } |
5179 | 5178 |
5180 // It's not possible to seal objects with external array elements | 5179 // It's not possible to seal objects with external array elements |
5181 if (object->HasExternalArrayElements() || | 5180 if (object->HasExternalArrayElements() || |
5182 object->HasFixedTypedArrayElements()) { | 5181 object->HasFixedTypedArrayElements()) { |
5183 Handle<Object> error = | 5182 THROW_NEW_ERROR(isolate, |
5184 isolate->factory()->NewTypeError( | 5183 NewTypeError("cant_prevent_ext_external_array_elements", |
5185 "cant_prevent_ext_external_array_elements", | 5184 HandleVector(&object, 1)), |
5186 HandleVector(&object, 1)); | 5185 Object); |
5187 return isolate->Throw<Object>(error); | |
5188 } | 5186 } |
5189 | 5187 |
5190 // If there are fast elements we normalize. | 5188 // If there are fast elements we normalize. |
5191 Handle<SeededNumberDictionary> dictionary = NormalizeElements(object); | 5189 Handle<SeededNumberDictionary> dictionary = NormalizeElements(object); |
5192 DCHECK(object->HasDictionaryElements() || | 5190 DCHECK(object->HasDictionaryElements() || |
5193 object->HasDictionaryArgumentsElements()); | 5191 object->HasDictionaryArgumentsElements()); |
5194 | 5192 |
5195 // Make sure that we never go back to fast case. | 5193 // Make sure that we never go back to fast case. |
5196 dictionary->set_requires_slow_elements(); | 5194 dictionary->set_requires_slow_elements(); |
5197 | 5195 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5256 if (object->IsJSGlobalProxy()) { | 5254 if (object->IsJSGlobalProxy()) { |
5257 PrototypeIterator iter(isolate, object); | 5255 PrototypeIterator iter(isolate, object); |
5258 if (iter.IsAtEnd()) return object; | 5256 if (iter.IsAtEnd()) return object; |
5259 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); | 5257 DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); |
5260 return Freeze(Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter))); | 5258 return Freeze(Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter))); |
5261 } | 5259 } |
5262 | 5260 |
5263 // It's not possible to freeze objects with external array elements | 5261 // It's not possible to freeze objects with external array elements |
5264 if (object->HasExternalArrayElements() || | 5262 if (object->HasExternalArrayElements() || |
5265 object->HasFixedTypedArrayElements()) { | 5263 object->HasFixedTypedArrayElements()) { |
5266 Handle<Object> error = | 5264 THROW_NEW_ERROR(isolate, |
5267 isolate->factory()->NewTypeError( | 5265 NewTypeError("cant_prevent_ext_external_array_elements", |
5268 "cant_prevent_ext_external_array_elements", | 5266 HandleVector(&object, 1)), |
5269 HandleVector(&object, 1)); | 5267 Object); |
5270 return isolate->Throw<Object>(error); | |
5271 } | 5268 } |
5272 | 5269 |
5273 Handle<SeededNumberDictionary> new_element_dictionary; | 5270 Handle<SeededNumberDictionary> new_element_dictionary; |
5274 if (!object->elements()->IsDictionary()) { | 5271 if (!object->elements()->IsDictionary()) { |
5275 int length = object->IsJSArray() | 5272 int length = object->IsJSArray() |
5276 ? Smi::cast(Handle<JSArray>::cast(object)->length())->value() | 5273 ? Smi::cast(Handle<JSArray>::cast(object)->length())->value() |
5277 : object->elements()->length(); | 5274 : object->elements()->length(); |
5278 if (length > 0) { | 5275 if (length > 0) { |
5279 int capacity = 0; | 5276 int capacity = 0; |
5280 int used = 0; | 5277 int used = 0; |
(...skipping 6422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11703 // From 8.6.2 Object Internal Methods | 11700 // From 8.6.2 Object Internal Methods |
11704 // ... | 11701 // ... |
11705 // In addition, if [[Extensible]] is false the value of the [[Class]] and | 11702 // In addition, if [[Extensible]] is false the value of the [[Class]] and |
11706 // [[Prototype]] internal properties of the object may not be modified. | 11703 // [[Prototype]] internal properties of the object may not be modified. |
11707 // ... | 11704 // ... |
11708 // Implementation specific extensions that modify [[Class]], [[Prototype]] | 11705 // Implementation specific extensions that modify [[Class]], [[Prototype]] |
11709 // or [[Extensible]] must not violate the invariants defined in the preceding | 11706 // or [[Extensible]] must not violate the invariants defined in the preceding |
11710 // paragraph. | 11707 // paragraph. |
11711 if (!object->map()->is_extensible()) { | 11708 if (!object->map()->is_extensible()) { |
11712 Handle<Object> args[] = { object }; | 11709 Handle<Object> args[] = { object }; |
11713 Handle<Object> error = isolate->factory()->NewTypeError( | 11710 THROW_NEW_ERROR(isolate, NewTypeError("non_extensible_proto", |
11714 "non_extensible_proto", HandleVector(args, arraysize(args))); | 11711 HandleVector(args, arraysize(args))), |
11715 return isolate->Throw<Object>(error); | 11712 Object); |
11716 } | 11713 } |
11717 | 11714 |
11718 // Before we can set the prototype we need to be sure | 11715 // Before we can set the prototype we need to be sure |
11719 // prototype cycles are prevented. | 11716 // prototype cycles are prevented. |
11720 // It is sufficient to validate that the receiver is not in the new prototype | 11717 // It is sufficient to validate that the receiver is not in the new prototype |
11721 // chain. | 11718 // chain. |
11722 for (PrototypeIterator iter(isolate, *value, | 11719 for (PrototypeIterator iter(isolate, *value, |
11723 PrototypeIterator::START_AT_RECEIVER); | 11720 PrototypeIterator::START_AT_RECEIVER); |
11724 !iter.IsAtEnd(); iter.Advance()) { | 11721 !iter.IsAtEnd(); iter.Advance()) { |
11725 if (JSReceiver::cast(iter.GetCurrent()) == *object) { | 11722 if (JSReceiver::cast(iter.GetCurrent()) == *object) { |
11726 // Cycle detected. | 11723 // Cycle detected. |
11727 Handle<Object> error = isolate->factory()->NewError( | 11724 THROW_NEW_ERROR(isolate, |
11728 "cyclic_proto", HandleVector<Object>(NULL, 0)); | 11725 NewError("cyclic_proto", HandleVector<Object>(NULL, 0)), |
11729 return isolate->Throw<Object>(error); | 11726 Object); |
11730 } | 11727 } |
11731 } | 11728 } |
11732 | 11729 |
11733 bool dictionary_elements_in_chain = | 11730 bool dictionary_elements_in_chain = |
11734 object->map()->DictionaryElementsInPrototypeChainOnly(); | 11731 object->map()->DictionaryElementsInPrototypeChainOnly(); |
11735 Handle<JSObject> real_receiver = object; | 11732 Handle<JSObject> real_receiver = object; |
11736 | 11733 |
11737 if (from_javascript) { | 11734 if (from_javascript) { |
11738 // Find the first object in the chain whose prototype object is not | 11735 // Find the first object in the chain whose prototype object is not |
11739 // hidden and set the new prototype on that object. | 11736 // hidden and set the new prototype on that object. |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11930 if (structure->IsAccessorPair()) { | 11927 if (structure->IsAccessorPair()) { |
11931 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); | 11928 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); |
11932 if (setter->IsSpecFunction()) { | 11929 if (setter->IsSpecFunction()) { |
11933 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 11930 // TODO(rossberg): nicer would be to cast to some JSCallable here... |
11934 return SetPropertyWithDefinedSetter( | 11931 return SetPropertyWithDefinedSetter( |
11935 object, Handle<JSReceiver>::cast(setter), value); | 11932 object, Handle<JSReceiver>::cast(setter), value); |
11936 } else { | 11933 } else { |
11937 if (strict_mode == SLOPPY) return value; | 11934 if (strict_mode == SLOPPY) return value; |
11938 Handle<Object> key(isolate->factory()->NewNumberFromUint(index)); | 11935 Handle<Object> key(isolate->factory()->NewNumberFromUint(index)); |
11939 Handle<Object> args[2] = { key, holder }; | 11936 Handle<Object> args[2] = { key, holder }; |
11940 Handle<Object> error = isolate->factory()->NewTypeError( | 11937 THROW_NEW_ERROR( |
11941 "no_setter_in_callback", HandleVector(args, 2)); | 11938 isolate, NewTypeError("no_setter_in_callback", HandleVector(args, 2)), |
11942 return isolate->Throw<Object>(error); | 11939 Object); |
11943 } | 11940 } |
11944 } | 11941 } |
11945 | 11942 |
11946 // TODO(dcarney): Handle correctly. | 11943 // TODO(dcarney): Handle correctly. |
11947 if (structure->IsDeclaredAccessorInfo()) return value; | 11944 if (structure->IsDeclaredAccessorInfo()) return value; |
11948 | 11945 |
11949 UNREACHABLE(); | 11946 UNREACHABLE(); |
11950 return MaybeHandle<Object>(); | 11947 return MaybeHandle<Object>(); |
11951 } | 11948 } |
11952 | 11949 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12141 if (set_mode == DEFINE_PROPERTY) { | 12138 if (set_mode == DEFINE_PROPERTY) { |
12142 details = PropertyDetails( | 12139 details = PropertyDetails( |
12143 attributes, NORMAL, details.dictionary_index()); | 12140 attributes, NORMAL, details.dictionary_index()); |
12144 dictionary->DetailsAtPut(entry, details); | 12141 dictionary->DetailsAtPut(entry, details); |
12145 } else if (details.IsReadOnly() && !element->IsTheHole()) { | 12142 } else if (details.IsReadOnly() && !element->IsTheHole()) { |
12146 if (strict_mode == SLOPPY) { | 12143 if (strict_mode == SLOPPY) { |
12147 return isolate->factory()->undefined_value(); | 12144 return isolate->factory()->undefined_value(); |
12148 } else { | 12145 } else { |
12149 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); | 12146 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); |
12150 Handle<Object> args[2] = { number, object }; | 12147 Handle<Object> args[2] = { number, object }; |
12151 Handle<Object> error = | 12148 THROW_NEW_ERROR(isolate, NewTypeError("strict_read_only_property", |
12152 isolate->factory()->NewTypeError("strict_read_only_property", | 12149 HandleVector(args, 2)), |
12153 HandleVector(args, 2)); | 12150 Object); |
12154 return isolate->Throw<Object>(error); | |
12155 } | 12151 } |
12156 } | 12152 } |
12157 // Elements of the arguments object in slow mode might be slow aliases. | 12153 // Elements of the arguments object in slow mode might be slow aliases. |
12158 if (is_arguments && element->IsAliasedArgumentsEntry()) { | 12154 if (is_arguments && element->IsAliasedArgumentsEntry()) { |
12159 Handle<AliasedArgumentsEntry> entry = | 12155 Handle<AliasedArgumentsEntry> entry = |
12160 Handle<AliasedArgumentsEntry>::cast(element); | 12156 Handle<AliasedArgumentsEntry>::cast(element); |
12161 Handle<Context> context(Context::cast(elements->get(0))); | 12157 Handle<Context> context(Context::cast(elements->get(0))); |
12162 int context_index = entry->aliased_context_slot(); | 12158 int context_index = entry->aliased_context_slot(); |
12163 DCHECK(!context->get(context_index)->IsTheHole()); | 12159 DCHECK(!context->get(context_index)->IsTheHole()); |
12164 context->set(context_index, *value); | 12160 context->set(context_index, *value); |
(...skipping 14 matching lines...) Expand all Loading... |
12179 | 12175 |
12180 // When we set the is_extensible flag to false we always force the | 12176 // When we set the is_extensible flag to false we always force the |
12181 // element into dictionary mode (and force them to stay there). | 12177 // element into dictionary mode (and force them to stay there). |
12182 if (!object->map()->is_extensible()) { | 12178 if (!object->map()->is_extensible()) { |
12183 if (strict_mode == SLOPPY) { | 12179 if (strict_mode == SLOPPY) { |
12184 return isolate->factory()->undefined_value(); | 12180 return isolate->factory()->undefined_value(); |
12185 } else { | 12181 } else { |
12186 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); | 12182 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); |
12187 Handle<String> name = isolate->factory()->NumberToString(number); | 12183 Handle<String> name = isolate->factory()->NumberToString(number); |
12188 Handle<Object> args[1] = { name }; | 12184 Handle<Object> args[1] = { name }; |
12189 Handle<Object> error = | 12185 THROW_NEW_ERROR(isolate, NewTypeError("object_not_extensible", |
12190 isolate->factory()->NewTypeError("object_not_extensible", | 12186 HandleVector(args, 1)), |
12191 HandleVector(args, 1)); | 12187 Object); |
12192 return isolate->Throw<Object>(error); | |
12193 } | 12188 } |
12194 } | 12189 } |
12195 | 12190 |
12196 PropertyDetails details = PropertyDetails(attributes, NORMAL, 0); | 12191 PropertyDetails details = PropertyDetails(attributes, NORMAL, 0); |
12197 Handle<SeededNumberDictionary> new_dictionary = | 12192 Handle<SeededNumberDictionary> new_dictionary = |
12198 SeededNumberDictionary::AddNumberEntry(dictionary, index, value, | 12193 SeededNumberDictionary::AddNumberEntry(dictionary, index, value, |
12199 details); | 12194 details); |
12200 if (*dictionary != *new_dictionary) { | 12195 if (*dictionary != *new_dictionary) { |
12201 if (is_arguments) { | 12196 if (is_arguments) { |
12202 elements->set(1, *new_dictionary); | 12197 elements->set(1, *new_dictionary); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12402 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), index, | 12397 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), index, |
12403 value, attributes, strict_mode, check_prototype, set_mode); | 12398 value, attributes, strict_mode, check_prototype, set_mode); |
12404 } | 12399 } |
12405 | 12400 |
12406 // Don't allow element properties to be redefined for external arrays. | 12401 // Don't allow element properties to be redefined for external arrays. |
12407 if ((object->HasExternalArrayElements() || | 12402 if ((object->HasExternalArrayElements() || |
12408 object->HasFixedTypedArrayElements()) && | 12403 object->HasFixedTypedArrayElements()) && |
12409 set_mode == DEFINE_PROPERTY) { | 12404 set_mode == DEFINE_PROPERTY) { |
12410 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); | 12405 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); |
12411 Handle<Object> args[] = { object, number }; | 12406 Handle<Object> args[] = { object, number }; |
12412 Handle<Object> error = isolate->factory()->NewTypeError( | 12407 THROW_NEW_ERROR(isolate, NewTypeError("redef_external_array_element", |
12413 "redef_external_array_element", HandleVector(args, arraysize(args))); | 12408 HandleVector(args, arraysize(args))), |
12414 return isolate->Throw<Object>(error); | 12409 Object); |
12415 } | 12410 } |
12416 | 12411 |
12417 // Normalize the elements to enable attributes on the property. | 12412 // Normalize the elements to enable attributes on the property. |
12418 if ((attributes & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0) { | 12413 if ((attributes & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0) { |
12419 Handle<SeededNumberDictionary> dictionary = NormalizeElements(object); | 12414 Handle<SeededNumberDictionary> dictionary = NormalizeElements(object); |
12420 // Make sure that we never go back to fast case. | 12415 // Make sure that we never go back to fast case. |
12421 dictionary->set_requires_slow_elements(); | 12416 dictionary->set_requires_slow_elements(); |
12422 } | 12417 } |
12423 | 12418 |
12424 if (!object->map()->is_observed()) { | 12419 if (!object->map()->is_observed()) { |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12856 return it.IsReadOnly(); | 12851 return it.IsReadOnly(); |
12857 } | 12852 } |
12858 return false; | 12853 return false; |
12859 } | 12854 } |
12860 | 12855 |
12861 | 12856 |
12862 MaybeHandle<Object> JSArray::ReadOnlyLengthError(Handle<JSArray> array) { | 12857 MaybeHandle<Object> JSArray::ReadOnlyLengthError(Handle<JSArray> array) { |
12863 Isolate* isolate = array->GetIsolate(); | 12858 Isolate* isolate = array->GetIsolate(); |
12864 Handle<Name> length = isolate->factory()->length_string(); | 12859 Handle<Name> length = isolate->factory()->length_string(); |
12865 Handle<Object> args[2] = { length, array }; | 12860 Handle<Object> args[2] = { length, array }; |
12866 Handle<Object> error = isolate->factory()->NewTypeError( | 12861 THROW_NEW_ERROR(isolate, NewTypeError("strict_read_only_property", |
12867 "strict_read_only_property", HandleVector(args, arraysize(args))); | 12862 HandleVector(args, arraysize(args))), |
12868 return isolate->Throw<Object>(error); | 12863 Object); |
12869 } | 12864 } |
12870 | 12865 |
12871 | 12866 |
12872 MaybeHandle<Object> JSObject::GetElementWithInterceptor( | 12867 MaybeHandle<Object> JSObject::GetElementWithInterceptor( |
12873 Handle<JSObject> object, | 12868 Handle<JSObject> object, |
12874 Handle<Object> receiver, | 12869 Handle<Object> receiver, |
12875 uint32_t index) { | 12870 uint32_t index) { |
12876 Isolate* isolate = object->GetIsolate(); | 12871 Isolate* isolate = object->GetIsolate(); |
12877 | 12872 |
12878 // Make sure that the top context does not change when doing | 12873 // Make sure that the top context does not change when doing |
(...skipping 3546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16425 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16420 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16426 static const char* error_messages_[] = { | 16421 static const char* error_messages_[] = { |
16427 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16422 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16428 }; | 16423 }; |
16429 #undef ERROR_MESSAGES_TEXTS | 16424 #undef ERROR_MESSAGES_TEXTS |
16430 return error_messages_[reason]; | 16425 return error_messages_[reason]; |
16431 } | 16426 } |
16432 | 16427 |
16433 | 16428 |
16434 } } // namespace v8::internal | 16429 } } // namespace v8::internal |
OLD | NEW |