| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 | 615 |
| 616 // No accessible property found. | 616 // No accessible property found. |
| 617 *attributes = ABSENT; | 617 *attributes = ABSENT; |
| 618 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_GET); | 618 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_GET); |
| 619 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 619 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 620 return isolate->factory()->undefined_value(); | 620 return isolate->factory()->undefined_value(); |
| 621 } | 621 } |
| 622 | 622 |
| 623 | 623 |
| 624 PropertyAttributes JSObject::GetPropertyAttributeWithFailedAccessCheck( | 624 PropertyAttributes JSObject::GetPropertyAttributeWithFailedAccessCheck( |
| 625 Object* receiver, | 625 Handle<JSObject> object, |
| 626 LookupResult* result, | 626 LookupResult* result, |
| 627 Name* name, | 627 Handle<Name> name, |
| 628 bool continue_search) { | 628 bool continue_search) { |
| 629 if (result->IsProperty()) { | 629 if (result->IsProperty()) { |
| 630 switch (result->type()) { | 630 switch (result->type()) { |
| 631 case CALLBACKS: { | 631 case CALLBACKS: { |
| 632 // Only allow API accessors. | 632 // Only allow API accessors. |
| 633 Object* obj = result->GetCallbackObject(); | 633 Handle<Object> obj(result->GetCallbackObject(), object->GetIsolate()); |
| 634 if (obj->IsAccessorInfo()) { | 634 if (obj->IsAccessorInfo()) { |
| 635 AccessorInfo* info = AccessorInfo::cast(obj); | 635 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(obj); |
| 636 if (info->all_can_read()) { | 636 if (info->all_can_read()) { |
| 637 return result->GetAttributes(); | 637 return result->GetAttributes(); |
| 638 } | 638 } |
| 639 } else if (obj->IsAccessorPair()) { | 639 } else if (obj->IsAccessorPair()) { |
| 640 AccessorPair* pair = AccessorPair::cast(obj); | 640 Handle<AccessorPair> pair = Handle<AccessorPair>::cast(obj); |
| 641 if (pair->all_can_read()) { | 641 if (pair->all_can_read()) { |
| 642 return result->GetAttributes(); | 642 return result->GetAttributes(); |
| 643 } | 643 } |
| 644 } | 644 } |
| 645 break; | 645 break; |
| 646 } | 646 } |
| 647 | 647 |
| 648 case NORMAL: | 648 case NORMAL: |
| 649 case FIELD: | 649 case FIELD: |
| 650 case CONSTANT: { | 650 case CONSTANT: { |
| 651 if (!continue_search) break; | 651 if (!continue_search) break; |
| 652 // Search ALL_CAN_READ accessors in prototype chain. | 652 // Search ALL_CAN_READ accessors in prototype chain. |
| 653 LookupResult r(GetIsolate()); | 653 LookupResult r(object->GetIsolate()); |
| 654 result->holder()->LookupRealNamedPropertyInPrototypes(name, &r); | 654 result->holder()->LookupRealNamedPropertyInPrototypes(*name, &r); |
| 655 if (r.IsProperty()) { | 655 if (r.IsProperty()) { |
| 656 return GetPropertyAttributeWithFailedAccessCheck(receiver, | 656 return GetPropertyAttributeWithFailedAccessCheck( |
| 657 &r, | 657 object, &r, name, continue_search); |
| 658 name, | |
| 659 continue_search); | |
| 660 } | 658 } |
| 661 break; | 659 break; |
| 662 } | 660 } |
| 663 | 661 |
| 664 case INTERCEPTOR: { | 662 case INTERCEPTOR: { |
| 665 // If the object has an interceptor, try real named properties. | 663 // If the object has an interceptor, try real named properties. |
| 666 // No access check in GetPropertyAttributeWithInterceptor. | 664 // No access check in GetPropertyAttributeWithInterceptor. |
| 667 LookupResult r(GetIsolate()); | 665 LookupResult r(object->GetIsolate()); |
| 668 if (continue_search) { | 666 if (continue_search) { |
| 669 result->holder()->LookupRealNamedProperty(name, &r); | 667 result->holder()->LookupRealNamedProperty(*name, &r); |
| 670 } else { | 668 } else { |
| 671 result->holder()->LocalLookupRealNamedProperty(name, &r); | 669 result->holder()->LocalLookupRealNamedProperty(*name, &r); |
| 672 } | 670 } |
| 673 if (!r.IsFound()) break; | 671 if (!r.IsFound()) break; |
| 674 return GetPropertyAttributeWithFailedAccessCheck(receiver, | 672 return GetPropertyAttributeWithFailedAccessCheck( |
| 675 &r, | 673 object, &r, name, continue_search); |
| 676 name, | |
| 677 continue_search); | |
| 678 } | 674 } |
| 679 | 675 |
| 680 case HANDLER: | 676 case HANDLER: |
| 681 case TRANSITION: | 677 case TRANSITION: |
| 682 case NONEXISTENT: | 678 case NONEXISTENT: |
| 683 UNREACHABLE(); | 679 UNREACHABLE(); |
| 684 } | 680 } |
| 685 } | 681 } |
| 686 | 682 |
| 687 GetIsolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 683 object->GetIsolate()->ReportFailedAccessCheckWrapper(object, v8::ACCESS_HAS); |
| 688 return ABSENT; | 684 return ABSENT; |
| 689 } | 685 } |
| 690 | 686 |
| 691 | 687 |
| 692 Object* JSObject::GetNormalizedProperty(const LookupResult* result) { | 688 Object* JSObject::GetNormalizedProperty(const LookupResult* result) { |
| 693 ASSERT(!HasFastProperties()); | 689 ASSERT(!HasFastProperties()); |
| 694 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); | 690 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); |
| 695 if (IsGlobalObject()) { | 691 if (IsGlobalObject()) { |
| 696 value = PropertyCell::cast(value)->value(); | 692 value = PropertyCell::cast(value)->value(); |
| 697 } | 693 } |
| (...skipping 2358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3056 LookupResult result(isolate); | 3052 LookupResult result(isolate); |
| 3057 object->LookupRealNamedPropertyInPrototypes(*name, &result); | 3053 object->LookupRealNamedPropertyInPrototypes(*name, &result); |
| 3058 if (result.IsFound()) { | 3054 if (result.IsFound()) { |
| 3059 switch (result.type()) { | 3055 switch (result.type()) { |
| 3060 case NORMAL: | 3056 case NORMAL: |
| 3061 case FIELD: | 3057 case FIELD: |
| 3062 case CONSTANT: | 3058 case CONSTANT: |
| 3063 *done = result.IsReadOnly(); | 3059 *done = result.IsReadOnly(); |
| 3064 break; | 3060 break; |
| 3065 case INTERCEPTOR: { | 3061 case INTERCEPTOR: { |
| 3066 PropertyAttributes attr = | 3062 PropertyAttributes attr = GetPropertyAttributeWithInterceptor( |
| 3067 result.holder()->GetPropertyAttributeWithInterceptor( | 3063 handle(result.holder()), object, name, true); |
| 3068 *object, *name, true); | |
| 3069 *done = !!(attr & READ_ONLY); | 3064 *done = !!(attr & READ_ONLY); |
| 3070 break; | 3065 break; |
| 3071 } | 3066 } |
| 3072 case CALLBACKS: { | 3067 case CALLBACKS: { |
| 3073 *done = true; | 3068 *done = true; |
| 3074 Handle<Object> callback_object(result.GetCallbackObject(), isolate); | 3069 Handle<Object> callback_object(result.GetCallbackObject(), isolate); |
| 3075 return SetPropertyWithCallback(object, callback_object, name, value, | 3070 return SetPropertyWithCallback(object, callback_object, name, value, |
| 3076 handle(result.holder()), strict_mode); | 3071 handle(result.holder()), strict_mode); |
| 3077 } | 3072 } |
| 3078 case HANDLER: { | 3073 case HANDLER: { |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3701 | 3696 |
| 3702 | 3697 |
| 3703 Handle<Object> JSProxy::DeleteElementWithHandler( | 3698 Handle<Object> JSProxy::DeleteElementWithHandler( |
| 3704 Handle<JSProxy> proxy, uint32_t index, DeleteMode mode) { | 3699 Handle<JSProxy> proxy, uint32_t index, DeleteMode mode) { |
| 3705 Isolate* isolate = proxy->GetIsolate(); | 3700 Isolate* isolate = proxy->GetIsolate(); |
| 3706 Handle<String> name = isolate->factory()->Uint32ToString(index); | 3701 Handle<String> name = isolate->factory()->Uint32ToString(index); |
| 3707 return JSProxy::DeletePropertyWithHandler(proxy, name, mode); | 3702 return JSProxy::DeletePropertyWithHandler(proxy, name, mode); |
| 3708 } | 3703 } |
| 3709 | 3704 |
| 3710 | 3705 |
| 3711 MUST_USE_RESULT PropertyAttributes JSProxy::GetPropertyAttributeWithHandler( | 3706 PropertyAttributes JSProxy::GetPropertyAttributeWithHandler( |
| 3712 JSReceiver* receiver_raw, | 3707 Handle<JSProxy> proxy, |
| 3713 Name* name_raw) { | 3708 Handle<JSReceiver> receiver, |
| 3714 Isolate* isolate = GetIsolate(); | 3709 Handle<Name> name) { |
| 3710 Isolate* isolate = proxy->GetIsolate(); |
| 3715 HandleScope scope(isolate); | 3711 HandleScope scope(isolate); |
| 3716 Handle<JSProxy> proxy(this); | |
| 3717 Handle<Object> handler(this->handler(), isolate); // Trap might morph proxy. | |
| 3718 Handle<JSReceiver> receiver(receiver_raw); | |
| 3719 Handle<Object> name(name_raw, isolate); | |
| 3720 | 3712 |
| 3721 // TODO(rossberg): adjust once there is a story for symbols vs proxies. | 3713 // TODO(rossberg): adjust once there is a story for symbols vs proxies. |
| 3722 if (name->IsSymbol()) return ABSENT; | 3714 if (name->IsSymbol()) return ABSENT; |
| 3723 | 3715 |
| 3724 Handle<Object> args[] = { name }; | 3716 Handle<Object> args[] = { name }; |
| 3725 Handle<Object> result = CallTrap( | 3717 Handle<Object> result = proxy->CallTrap( |
| 3726 "getPropertyDescriptor", Handle<Object>(), ARRAY_SIZE(args), args); | 3718 "getPropertyDescriptor", Handle<Object>(), ARRAY_SIZE(args), args); |
| 3727 if (isolate->has_pending_exception()) return NONE; | 3719 if (isolate->has_pending_exception()) return NONE; |
| 3728 | 3720 |
| 3729 if (result->IsUndefined()) return ABSENT; | 3721 if (result->IsUndefined()) return ABSENT; |
| 3730 | 3722 |
| 3731 bool has_pending_exception; | 3723 bool has_pending_exception; |
| 3732 Handle<Object> argv[] = { result }; | 3724 Handle<Object> argv[] = { result }; |
| 3733 Handle<Object> desc = Execution::Call( | 3725 Handle<Object> desc = Execution::Call( |
| 3734 isolate, isolate->to_complete_property_descriptor(), result, | 3726 isolate, isolate->to_complete_property_descriptor(), result, |
| 3735 ARRAY_SIZE(argv), argv, &has_pending_exception); | 3727 ARRAY_SIZE(argv), argv, &has_pending_exception); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3750 if (isolate->has_pending_exception()) return NONE; | 3742 if (isolate->has_pending_exception()) return NONE; |
| 3751 if (!writable->BooleanValue()) { | 3743 if (!writable->BooleanValue()) { |
| 3752 Handle<String> set_n = isolate->factory()->InternalizeOneByteString( | 3744 Handle<String> set_n = isolate->factory()->InternalizeOneByteString( |
| 3753 STATIC_ASCII_VECTOR("set_")); | 3745 STATIC_ASCII_VECTOR("set_")); |
| 3754 Handle<Object> setter(v8::internal::GetProperty(isolate, desc, set_n)); | 3746 Handle<Object> setter(v8::internal::GetProperty(isolate, desc, set_n)); |
| 3755 if (isolate->has_pending_exception()) return NONE; | 3747 if (isolate->has_pending_exception()) return NONE; |
| 3756 writable = isolate->factory()->ToBoolean(!setter->IsUndefined()); | 3748 writable = isolate->factory()->ToBoolean(!setter->IsUndefined()); |
| 3757 } | 3749 } |
| 3758 | 3750 |
| 3759 if (configurable->IsFalse()) { | 3751 if (configurable->IsFalse()) { |
| 3752 Handle<Object> handler(proxy->handler(), isolate); |
| 3760 Handle<String> trap = isolate->factory()->InternalizeOneByteString( | 3753 Handle<String> trap = isolate->factory()->InternalizeOneByteString( |
| 3761 STATIC_ASCII_VECTOR("getPropertyDescriptor")); | 3754 STATIC_ASCII_VECTOR("getPropertyDescriptor")); |
| 3762 Handle<Object> args[] = { handler, trap, name }; | 3755 Handle<Object> args[] = { handler, trap, name }; |
| 3763 Handle<Object> error = isolate->factory()->NewTypeError( | 3756 Handle<Object> error = isolate->factory()->NewTypeError( |
| 3764 "proxy_prop_not_configurable", HandleVector(args, ARRAY_SIZE(args))); | 3757 "proxy_prop_not_configurable", HandleVector(args, ARRAY_SIZE(args))); |
| 3765 isolate->Throw(*error); | 3758 isolate->Throw(*error); |
| 3766 return NONE; | 3759 return NONE; |
| 3767 } | 3760 } |
| 3768 | 3761 |
| 3769 int attributes = NONE; | 3762 int attributes = NONE; |
| 3770 if (!enumerable->BooleanValue()) attributes |= DONT_ENUM; | 3763 if (!enumerable->BooleanValue()) attributes |= DONT_ENUM; |
| 3771 if (!configurable->BooleanValue()) attributes |= DONT_DELETE; | 3764 if (!configurable->BooleanValue()) attributes |= DONT_DELETE; |
| 3772 if (!writable->BooleanValue()) attributes |= READ_ONLY; | 3765 if (!writable->BooleanValue()) attributes |= READ_ONLY; |
| 3773 return static_cast<PropertyAttributes>(attributes); | 3766 return static_cast<PropertyAttributes>(attributes); |
| 3774 } | 3767 } |
| 3775 | 3768 |
| 3776 | 3769 |
| 3777 MUST_USE_RESULT PropertyAttributes JSProxy::GetElementAttributeWithHandler( | 3770 PropertyAttributes JSProxy::GetElementAttributeWithHandler( |
| 3778 JSReceiver* receiver_raw, | 3771 Handle<JSProxy> proxy, |
| 3772 Handle<JSReceiver> receiver, |
| 3779 uint32_t index) { | 3773 uint32_t index) { |
| 3780 Isolate* isolate = GetIsolate(); | 3774 Isolate* isolate = proxy->GetIsolate(); |
| 3781 HandleScope scope(isolate); | |
| 3782 Handle<JSProxy> proxy(this); | |
| 3783 Handle<JSReceiver> receiver(receiver_raw); | |
| 3784 Handle<String> name = isolate->factory()->Uint32ToString(index); | 3775 Handle<String> name = isolate->factory()->Uint32ToString(index); |
| 3785 return proxy->GetPropertyAttributeWithHandler(*receiver, *name); | 3776 return GetPropertyAttributeWithHandler(proxy, receiver, name); |
| 3786 } | 3777 } |
| 3787 | 3778 |
| 3788 | 3779 |
| 3789 void JSProxy::Fix(Handle<JSProxy> proxy) { | 3780 void JSProxy::Fix(Handle<JSProxy> proxy) { |
| 3790 Isolate* isolate = proxy->GetIsolate(); | 3781 Isolate* isolate = proxy->GetIsolate(); |
| 3791 | 3782 |
| 3792 // Save identity hash. | 3783 // Save identity hash. |
| 3793 Handle<Object> hash(proxy->GetIdentityHash(), isolate); | 3784 Handle<Object> hash(proxy->GetIdentityHash(), isolate); |
| 3794 | 3785 |
| 3795 if (proxy->IsJSFunctionProxy()) { | 3786 if (proxy->IsJSFunctionProxy()) { |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4262 EnqueueChangeRecord(object, "update", name, old_value); | 4253 EnqueueChangeRecord(object, "update", name, old_value); |
| 4263 } | 4254 } |
| 4264 } | 4255 } |
| 4265 } | 4256 } |
| 4266 | 4257 |
| 4267 return value; | 4258 return value; |
| 4268 } | 4259 } |
| 4269 | 4260 |
| 4270 | 4261 |
| 4271 PropertyAttributes JSObject::GetPropertyAttributePostInterceptor( | 4262 PropertyAttributes JSObject::GetPropertyAttributePostInterceptor( |
| 4272 JSObject* receiver, | 4263 Handle<JSObject> object, |
| 4273 Name* name, | 4264 Handle<JSObject> receiver, |
| 4274 bool continue_search) { | 4265 Handle<Name> name, |
| 4266 bool continue_search) { |
| 4275 // Check local property, ignore interceptor. | 4267 // Check local property, ignore interceptor. |
| 4276 LookupResult result(GetIsolate()); | 4268 Isolate* isolate = object->GetIsolate(); |
| 4277 LocalLookupRealNamedProperty(name, &result); | 4269 LookupResult result(isolate); |
| 4270 object->LocalLookupRealNamedProperty(*name, &result); |
| 4278 if (result.IsFound()) return result.GetAttributes(); | 4271 if (result.IsFound()) return result.GetAttributes(); |
| 4279 | 4272 |
| 4280 if (continue_search) { | 4273 if (continue_search) { |
| 4281 // Continue searching via the prototype chain. | 4274 // Continue searching via the prototype chain. |
| 4282 Object* pt = GetPrototype(); | 4275 Handle<Object> proto(object->GetPrototype(), isolate); |
| 4283 if (!pt->IsNull()) { | 4276 if (!proto->IsNull()) { |
| 4284 return JSObject::cast(pt)-> | 4277 return JSReceiver::GetPropertyAttributeWithReceiver( |
| 4285 GetPropertyAttributeWithReceiver(receiver, name); | 4278 Handle<JSObject>::cast(proto), receiver, name); |
| 4286 } | 4279 } |
| 4287 } | 4280 } |
| 4288 return ABSENT; | 4281 return ABSENT; |
| 4289 } | 4282 } |
| 4290 | 4283 |
| 4291 | 4284 |
| 4292 PropertyAttributes JSObject::GetPropertyAttributeWithInterceptor( | 4285 PropertyAttributes JSObject::GetPropertyAttributeWithInterceptor( |
| 4293 JSObject* receiver, | 4286 Handle<JSObject> object, |
| 4294 Name* name, | 4287 Handle<JSObject> receiver, |
| 4295 bool continue_search) { | 4288 Handle<Name> name, |
| 4289 bool continue_search) { |
| 4296 // TODO(rossberg): Support symbols in the API. | 4290 // TODO(rossberg): Support symbols in the API. |
| 4297 if (name->IsSymbol()) return ABSENT; | 4291 if (name->IsSymbol()) return ABSENT; |
| 4298 | 4292 |
| 4299 Isolate* isolate = GetIsolate(); | 4293 Isolate* isolate = object->GetIsolate(); |
| 4300 HandleScope scope(isolate); | 4294 HandleScope scope(isolate); |
| 4301 | 4295 |
| 4302 // Make sure that the top context does not change when doing | 4296 // Make sure that the top context does not change when doing |
| 4303 // callbacks or interceptor calls. | 4297 // callbacks or interceptor calls. |
| 4304 AssertNoContextChange ncc(isolate); | 4298 AssertNoContextChange ncc(isolate); |
| 4305 | 4299 |
| 4306 Handle<InterceptorInfo> interceptor(GetNamedInterceptor()); | 4300 Handle<InterceptorInfo> interceptor(object->GetNamedInterceptor()); |
| 4307 Handle<JSObject> receiver_handle(receiver); | 4301 PropertyCallbackArguments args( |
| 4308 Handle<JSObject> holder_handle(this); | 4302 isolate, interceptor->data(), *receiver, *object); |
| 4309 Handle<String> name_handle(String::cast(name)); | |
| 4310 PropertyCallbackArguments args(isolate, interceptor->data(), receiver, this); | |
| 4311 if (!interceptor->query()->IsUndefined()) { | 4303 if (!interceptor->query()->IsUndefined()) { |
| 4312 v8::NamedPropertyQueryCallback query = | 4304 v8::NamedPropertyQueryCallback query = |
| 4313 v8::ToCData<v8::NamedPropertyQueryCallback>(interceptor->query()); | 4305 v8::ToCData<v8::NamedPropertyQueryCallback>(interceptor->query()); |
| 4314 LOG(isolate, | 4306 LOG(isolate, |
| 4315 ApiNamedPropertyAccess("interceptor-named-has", *holder_handle, name)); | 4307 ApiNamedPropertyAccess("interceptor-named-has", *object, *name)); |
| 4316 v8::Handle<v8::Integer> result = | 4308 v8::Handle<v8::Integer> result = |
| 4317 args.Call(query, v8::Utils::ToLocal(name_handle)); | 4309 args.Call(query, v8::Utils::ToLocal(Handle<String>::cast(name))); |
| 4318 if (!result.IsEmpty()) { | 4310 if (!result.IsEmpty()) { |
| 4319 ASSERT(result->IsInt32()); | 4311 ASSERT(result->IsInt32()); |
| 4320 return static_cast<PropertyAttributes>(result->Int32Value()); | 4312 return static_cast<PropertyAttributes>(result->Int32Value()); |
| 4321 } | 4313 } |
| 4322 } else if (!interceptor->getter()->IsUndefined()) { | 4314 } else if (!interceptor->getter()->IsUndefined()) { |
| 4323 v8::NamedPropertyGetterCallback getter = | 4315 v8::NamedPropertyGetterCallback getter = |
| 4324 v8::ToCData<v8::NamedPropertyGetterCallback>(interceptor->getter()); | 4316 v8::ToCData<v8::NamedPropertyGetterCallback>(interceptor->getter()); |
| 4325 LOG(isolate, | 4317 LOG(isolate, |
| 4326 ApiNamedPropertyAccess("interceptor-named-get-has", this, name)); | 4318 ApiNamedPropertyAccess("interceptor-named-get-has", *object, *name)); |
| 4327 v8::Handle<v8::Value> result = | 4319 v8::Handle<v8::Value> result = |
| 4328 args.Call(getter, v8::Utils::ToLocal(name_handle)); | 4320 args.Call(getter, v8::Utils::ToLocal(Handle<String>::cast(name))); |
| 4329 if (!result.IsEmpty()) return DONT_ENUM; | 4321 if (!result.IsEmpty()) return DONT_ENUM; |
| 4330 } | 4322 } |
| 4331 return holder_handle->GetPropertyAttributePostInterceptor(*receiver_handle, | 4323 return GetPropertyAttributePostInterceptor( |
| 4332 *name_handle, | 4324 object, receiver, name, continue_search); |
| 4333 continue_search); | |
| 4334 } | 4325 } |
| 4335 | 4326 |
| 4336 | 4327 |
| 4337 PropertyAttributes JSReceiver::GetPropertyAttributeWithReceiver( | 4328 PropertyAttributes JSReceiver::GetPropertyAttributeWithReceiver( |
| 4338 JSReceiver* receiver, | 4329 Handle<JSReceiver> object, |
| 4339 Name* key) { | 4330 Handle<JSReceiver> receiver, |
| 4331 Handle<Name> key) { |
| 4340 uint32_t index = 0; | 4332 uint32_t index = 0; |
| 4341 if (IsJSObject() && key->AsArrayIndex(&index)) { | 4333 if (object->IsJSObject() && key->AsArrayIndex(&index)) { |
| 4342 return JSObject::cast(this)->GetElementAttributeWithReceiver( | 4334 return JSObject::GetElementAttributeWithReceiver( |
| 4343 receiver, index, true); | 4335 Handle<JSObject>::cast(object), receiver, index, true); |
| 4344 } | 4336 } |
| 4345 // Named property. | 4337 // Named property. |
| 4346 LookupResult lookup(GetIsolate()); | 4338 LookupResult lookup(object->GetIsolate()); |
| 4347 Lookup(key, &lookup); | 4339 object->Lookup(*key, &lookup); |
| 4348 return GetPropertyAttributeForResult(receiver, &lookup, key, true); | 4340 return GetPropertyAttributeForResult(object, receiver, &lookup, key, true); |
| 4349 } | 4341 } |
| 4350 | 4342 |
| 4351 | 4343 |
| 4352 PropertyAttributes JSReceiver::GetPropertyAttributeForResult( | 4344 PropertyAttributes JSReceiver::GetPropertyAttributeForResult( |
| 4353 JSReceiver* receiver, | 4345 Handle<JSReceiver> object, |
| 4346 Handle<JSReceiver> receiver, |
| 4354 LookupResult* lookup, | 4347 LookupResult* lookup, |
| 4355 Name* name, | 4348 Handle<Name> name, |
| 4356 bool continue_search) { | 4349 bool continue_search) { |
| 4357 // Check access rights if needed. | 4350 // Check access rights if needed. |
| 4358 if (IsAccessCheckNeeded()) { | 4351 if (object->IsAccessCheckNeeded()) { |
| 4359 JSObject* this_obj = JSObject::cast(this); | 4352 Heap* heap = object->GetHeap(); |
| 4360 Heap* heap = GetHeap(); | 4353 Handle<JSObject> obj = Handle<JSObject>::cast(object); |
| 4361 if (!heap->isolate()->MayNamedAccess(this_obj, name, v8::ACCESS_HAS)) { | 4354 if (!heap->isolate()->MayNamedAccessWrapper(obj, name, v8::ACCESS_HAS)) { |
| 4362 return this_obj->GetPropertyAttributeWithFailedAccessCheck( | 4355 return JSObject::GetPropertyAttributeWithFailedAccessCheck( |
| 4363 receiver, lookup, name, continue_search); | 4356 obj, lookup, name, continue_search); |
| 4364 } | 4357 } |
| 4365 } | 4358 } |
| 4366 if (lookup->IsFound()) { | 4359 if (lookup->IsFound()) { |
| 4367 switch (lookup->type()) { | 4360 switch (lookup->type()) { |
| 4368 case NORMAL: // fall through | 4361 case NORMAL: // fall through |
| 4369 case FIELD: | 4362 case FIELD: |
| 4370 case CONSTANT: | 4363 case CONSTANT: |
| 4371 case CALLBACKS: | 4364 case CALLBACKS: |
| 4372 return lookup->GetAttributes(); | 4365 return lookup->GetAttributes(); |
| 4373 case HANDLER: { | 4366 case HANDLER: { |
| 4374 return JSProxy::cast(lookup->proxy())->GetPropertyAttributeWithHandler( | 4367 return JSProxy::GetPropertyAttributeWithHandler( |
| 4375 receiver, name); | 4368 handle(lookup->proxy()), receiver, name); |
| 4376 } | 4369 } |
| 4377 case INTERCEPTOR: | 4370 case INTERCEPTOR: |
| 4378 return lookup->holder()->GetPropertyAttributeWithInterceptor( | 4371 return JSObject::GetPropertyAttributeWithInterceptor( |
| 4379 JSObject::cast(receiver), name, continue_search); | 4372 handle(lookup->holder()), |
| 4373 Handle<JSObject>::cast(receiver), |
| 4374 name, |
| 4375 continue_search); |
| 4380 case TRANSITION: | 4376 case TRANSITION: |
| 4381 case NONEXISTENT: | 4377 case NONEXISTENT: |
| 4382 UNREACHABLE(); | 4378 UNREACHABLE(); |
| 4383 } | 4379 } |
| 4384 } | 4380 } |
| 4385 return ABSENT; | 4381 return ABSENT; |
| 4386 } | 4382 } |
| 4387 | 4383 |
| 4388 | 4384 |
| 4389 PropertyAttributes JSReceiver::GetLocalPropertyAttribute(Name* name) { | 4385 PropertyAttributes JSReceiver::GetLocalPropertyAttribute( |
| 4386 Handle<JSReceiver> object, Handle<Name> name) { |
| 4390 // Check whether the name is an array index. | 4387 // Check whether the name is an array index. |
| 4391 uint32_t index = 0; | 4388 uint32_t index = 0; |
| 4392 if (IsJSObject() && name->AsArrayIndex(&index)) { | 4389 if (object->IsJSObject() && name->AsArrayIndex(&index)) { |
| 4393 return GetLocalElementAttribute(index); | 4390 return GetLocalElementAttribute(object, index); |
| 4394 } | 4391 } |
| 4395 // Named property. | 4392 // Named property. |
| 4396 LookupResult lookup(GetIsolate()); | 4393 LookupResult lookup(object->GetIsolate()); |
| 4397 LocalLookup(name, &lookup, true); | 4394 object->LocalLookup(*name, &lookup, true); |
| 4398 return GetPropertyAttributeForResult(this, &lookup, name, false); | 4395 return GetPropertyAttributeForResult(object, object, &lookup, name, false); |
| 4399 } | 4396 } |
| 4400 | 4397 |
| 4401 | 4398 |
| 4402 PropertyAttributes JSObject::GetElementAttributeWithReceiver( | 4399 PropertyAttributes JSObject::GetElementAttributeWithReceiver( |
| 4403 JSReceiver* receiver, uint32_t index, bool continue_search) { | 4400 Handle<JSObject> object, |
| 4404 Isolate* isolate = GetIsolate(); | 4401 Handle<JSReceiver> receiver, |
| 4402 uint32_t index, |
| 4403 bool continue_search) { |
| 4404 Isolate* isolate = object->GetIsolate(); |
| 4405 | 4405 |
| 4406 // Check access rights if needed. | 4406 // Check access rights if needed. |
| 4407 if (IsAccessCheckNeeded()) { | 4407 if (object->IsAccessCheckNeeded()) { |
| 4408 if (!isolate->MayIndexedAccess(this, index, v8::ACCESS_HAS)) { | 4408 if (!isolate->MayIndexedAccessWrapper(object, index, v8::ACCESS_HAS)) { |
| 4409 isolate->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 4409 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_HAS); |
| 4410 return ABSENT; | 4410 return ABSENT; |
| 4411 } | 4411 } |
| 4412 } | 4412 } |
| 4413 | 4413 |
| 4414 if (IsJSGlobalProxy()) { | 4414 if (object->IsJSGlobalProxy()) { |
| 4415 Object* proto = GetPrototype(); | 4415 Handle<Object> proto(object->GetPrototype(), isolate); |
| 4416 if (proto->IsNull()) return ABSENT; | 4416 if (proto->IsNull()) return ABSENT; |
| 4417 ASSERT(proto->IsJSGlobalObject()); | 4417 ASSERT(proto->IsJSGlobalObject()); |
| 4418 return JSObject::cast(proto)->GetElementAttributeWithReceiver( | 4418 return JSObject::GetElementAttributeWithReceiver( |
| 4419 receiver, index, continue_search); | 4419 Handle<JSObject>::cast(proto), receiver, index, continue_search); |
| 4420 } | 4420 } |
| 4421 | 4421 |
| 4422 // Check for lookup interceptor except when bootstrapping. | 4422 // Check for lookup interceptor except when bootstrapping. |
| 4423 if (HasIndexedInterceptor() && !isolate->bootstrapper()->IsActive()) { | 4423 if (object->HasIndexedInterceptor() && !isolate->bootstrapper()->IsActive()) { |
| 4424 return GetElementAttributeWithInterceptor(receiver, index, continue_search); | 4424 return JSObject::GetElementAttributeWithInterceptor( |
| 4425 object, receiver, index, continue_search); |
| 4425 } | 4426 } |
| 4426 | 4427 |
| 4427 return GetElementAttributeWithoutInterceptor( | 4428 return GetElementAttributeWithoutInterceptor( |
| 4428 receiver, index, continue_search); | 4429 object, receiver, index, continue_search); |
| 4429 } | 4430 } |
| 4430 | 4431 |
| 4431 | 4432 |
| 4432 PropertyAttributes JSObject::GetElementAttributeWithInterceptor( | 4433 PropertyAttributes JSObject::GetElementAttributeWithInterceptor( |
| 4433 JSReceiver* receiver, uint32_t index, bool continue_search) { | 4434 Handle<JSObject> object, |
| 4434 Isolate* isolate = GetIsolate(); | 4435 Handle<JSReceiver> receiver, |
| 4436 uint32_t index, |
| 4437 bool continue_search) { |
| 4438 Isolate* isolate = object->GetIsolate(); |
| 4435 HandleScope scope(isolate); | 4439 HandleScope scope(isolate); |
| 4436 | 4440 |
| 4437 // Make sure that the top context does not change when doing | 4441 // Make sure that the top context does not change when doing |
| 4438 // callbacks or interceptor calls. | 4442 // callbacks or interceptor calls. |
| 4439 AssertNoContextChange ncc(isolate); | 4443 AssertNoContextChange ncc(isolate); |
| 4440 | 4444 |
| 4441 Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); | 4445 Handle<InterceptorInfo> interceptor(object->GetIndexedInterceptor()); |
| 4442 Handle<JSReceiver> hreceiver(receiver); | 4446 PropertyCallbackArguments args( |
| 4443 Handle<JSObject> holder(this); | 4447 isolate, interceptor->data(), *receiver, *object); |
| 4444 PropertyCallbackArguments args(isolate, interceptor->data(), receiver, this); | |
| 4445 if (!interceptor->query()->IsUndefined()) { | 4448 if (!interceptor->query()->IsUndefined()) { |
| 4446 v8::IndexedPropertyQueryCallback query = | 4449 v8::IndexedPropertyQueryCallback query = |
| 4447 v8::ToCData<v8::IndexedPropertyQueryCallback>(interceptor->query()); | 4450 v8::ToCData<v8::IndexedPropertyQueryCallback>(interceptor->query()); |
| 4448 LOG(isolate, | 4451 LOG(isolate, |
| 4449 ApiIndexedPropertyAccess("interceptor-indexed-has", this, index)); | 4452 ApiIndexedPropertyAccess("interceptor-indexed-has", *object, index)); |
| 4450 v8::Handle<v8::Integer> result = args.Call(query, index); | 4453 v8::Handle<v8::Integer> result = args.Call(query, index); |
| 4451 if (!result.IsEmpty()) | 4454 if (!result.IsEmpty()) |
| 4452 return static_cast<PropertyAttributes>(result->Int32Value()); | 4455 return static_cast<PropertyAttributes>(result->Int32Value()); |
| 4453 } else if (!interceptor->getter()->IsUndefined()) { | 4456 } else if (!interceptor->getter()->IsUndefined()) { |
| 4454 v8::IndexedPropertyGetterCallback getter = | 4457 v8::IndexedPropertyGetterCallback getter = |
| 4455 v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter()); | 4458 v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter()); |
| 4456 LOG(isolate, | 4459 LOG(isolate, |
| 4457 ApiIndexedPropertyAccess("interceptor-indexed-get-has", this, index)); | 4460 ApiIndexedPropertyAccess( |
| 4461 "interceptor-indexed-get-has", *object, index)); |
| 4458 v8::Handle<v8::Value> result = args.Call(getter, index); | 4462 v8::Handle<v8::Value> result = args.Call(getter, index); |
| 4459 if (!result.IsEmpty()) return NONE; | 4463 if (!result.IsEmpty()) return NONE; |
| 4460 } | 4464 } |
| 4461 | 4465 |
| 4462 return holder->GetElementAttributeWithoutInterceptor( | 4466 return GetElementAttributeWithoutInterceptor( |
| 4463 *hreceiver, index, continue_search); | 4467 object, receiver, index, continue_search); |
| 4464 } | 4468 } |
| 4465 | 4469 |
| 4466 | 4470 |
| 4467 PropertyAttributes JSObject::GetElementAttributeWithoutInterceptor( | 4471 PropertyAttributes JSObject::GetElementAttributeWithoutInterceptor( |
| 4468 JSReceiver* receiver, uint32_t index, bool continue_search) { | 4472 Handle<JSObject> object, |
| 4469 PropertyAttributes attr = GetElementsAccessor()->GetAttributes( | 4473 Handle<JSReceiver> receiver, |
| 4470 receiver, this, index); | 4474 uint32_t index, |
| 4475 bool continue_search) { |
| 4476 PropertyAttributes attr = object->GetElementsAccessor()->GetAttributes( |
| 4477 *receiver, *object, index); |
| 4471 if (attr != ABSENT) return attr; | 4478 if (attr != ABSENT) return attr; |
| 4472 | 4479 |
| 4473 // Handle [] on String objects. | 4480 // Handle [] on String objects. |
| 4474 if (IsStringObjectWithCharacterAt(index)) { | 4481 if (object->IsStringObjectWithCharacterAt(index)) { |
| 4475 return static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); | 4482 return static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); |
| 4476 } | 4483 } |
| 4477 | 4484 |
| 4478 if (!continue_search) return ABSENT; | 4485 if (!continue_search) return ABSENT; |
| 4479 | 4486 |
| 4480 Object* pt = GetPrototype(); | 4487 Handle<Object> proto(object->GetPrototype(), object->GetIsolate()); |
| 4481 if (pt->IsJSProxy()) { | 4488 if (proto->IsJSProxy()) { |
| 4482 // We need to follow the spec and simulate a call to [[GetOwnProperty]]. | 4489 // We need to follow the spec and simulate a call to [[GetOwnProperty]]. |
| 4483 return JSProxy::cast(pt)->GetElementAttributeWithHandler(receiver, index); | 4490 return JSProxy::GetElementAttributeWithHandler( |
| 4491 Handle<JSProxy>::cast(proto), receiver, index); |
| 4484 } | 4492 } |
| 4485 if (pt->IsNull()) return ABSENT; | 4493 if (proto->IsNull()) return ABSENT; |
| 4486 return JSObject::cast(pt)->GetElementAttributeWithReceiver( | 4494 return GetElementAttributeWithReceiver( |
| 4487 receiver, index, true); | 4495 Handle<JSObject>::cast(proto), receiver, index, true); |
| 4488 } | 4496 } |
| 4489 | 4497 |
| 4490 | 4498 |
| 4491 Handle<Map> NormalizedMapCache::Get(Handle<NormalizedMapCache> cache, | 4499 Handle<Map> NormalizedMapCache::Get(Handle<NormalizedMapCache> cache, |
| 4492 Handle<JSObject> obj, | 4500 Handle<JSObject> obj, |
| 4493 PropertyNormalizationMode mode) { | 4501 PropertyNormalizationMode mode) { |
| 4494 int index = obj->map()->Hash() % kEntries; | 4502 int index = obj->map()->Hash() % kEntries; |
| 4495 Handle<Object> result = handle(cache->get(index), cache->GetIsolate()); | 4503 Handle<Object> result = handle(cache->get(index), cache->GetIsolate()); |
| 4496 if (result->IsMap() && | 4504 if (result->IsMap() && |
| 4497 Handle<Map>::cast(result)->EquivalentToForNormalization(obj->map(), | 4505 Handle<Map>::cast(result)->EquivalentToForNormalization(obj->map(), |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4936 | 4944 |
| 4937 // We never delete (inline-stored) identity hashes. | 4945 // We never delete (inline-stored) identity hashes. |
| 4938 ASSERT(*key != *isolate->factory()->identity_hash_string()); | 4946 ASSERT(*key != *isolate->factory()->identity_hash_string()); |
| 4939 if (inline_value->IsUndefined() || inline_value->IsSmi()) return; | 4947 if (inline_value->IsUndefined() || inline_value->IsSmi()) return; |
| 4940 | 4948 |
| 4941 Handle<ObjectHashTable> hashtable(ObjectHashTable::cast(inline_value)); | 4949 Handle<ObjectHashTable> hashtable(ObjectHashTable::cast(inline_value)); |
| 4942 ObjectHashTable::Put(hashtable, key, isolate->factory()->the_hole_value()); | 4950 ObjectHashTable::Put(hashtable, key, isolate->factory()->the_hole_value()); |
| 4943 } | 4951 } |
| 4944 | 4952 |
| 4945 | 4953 |
| 4946 bool JSObject::HasHiddenProperties() { | 4954 bool JSObject::HasHiddenProperties(Handle<JSObject> object) { |
| 4947 return GetPropertyAttributePostInterceptor(this, | 4955 Handle<Name> hidden = object->GetIsolate()->factory()->hidden_string(); |
| 4948 GetHeap()->hidden_string(), | 4956 return GetPropertyAttributePostInterceptor( |
| 4949 false) != ABSENT; | 4957 object, object, hidden, false) != ABSENT; |
| 4950 } | 4958 } |
| 4951 | 4959 |
| 4952 | 4960 |
| 4953 Object* JSObject::GetHiddenPropertiesHashTable() { | 4961 Object* JSObject::GetHiddenPropertiesHashTable() { |
| 4954 ASSERT(!IsJSGlobalProxy()); | 4962 ASSERT(!IsJSGlobalProxy()); |
| 4955 if (HasFastProperties()) { | 4963 if (HasFastProperties()) { |
| 4956 // If the object has fast properties, check whether the first slot | 4964 // If the object has fast properties, check whether the first slot |
| 4957 // in the descriptor array matches the hidden string. Since the | 4965 // in the descriptor array matches the hidden string. Since the |
| 4958 // hidden strings hash code is zero (and no other name has hash | 4966 // hidden strings hash code is zero (and no other name has hash |
| 4959 // code zero) it will always occupy the first entry if present. | 4967 // code zero) it will always occupy the first entry if present. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5020 | 5028 |
| 5021 | 5029 |
| 5022 Handle<Object> JSObject::SetHiddenPropertiesHashTable(Handle<JSObject> object, | 5030 Handle<Object> JSObject::SetHiddenPropertiesHashTable(Handle<JSObject> object, |
| 5023 Handle<Object> value) { | 5031 Handle<Object> value) { |
| 5024 ASSERT(!object->IsJSGlobalProxy()); | 5032 ASSERT(!object->IsJSGlobalProxy()); |
| 5025 | 5033 |
| 5026 Isolate* isolate = object->GetIsolate(); | 5034 Isolate* isolate = object->GetIsolate(); |
| 5027 | 5035 |
| 5028 // We can store the identity hash inline iff there is no backing store | 5036 // We can store the identity hash inline iff there is no backing store |
| 5029 // for hidden properties yet. | 5037 // for hidden properties yet. |
| 5030 ASSERT(object->HasHiddenProperties() != value->IsSmi()); | 5038 ASSERT(JSObject::HasHiddenProperties(object) != value->IsSmi()); |
| 5031 if (object->HasFastProperties()) { | 5039 if (object->HasFastProperties()) { |
| 5032 // If the object has fast properties, check whether the first slot | 5040 // If the object has fast properties, check whether the first slot |
| 5033 // in the descriptor array matches the hidden string. Since the | 5041 // in the descriptor array matches the hidden string. Since the |
| 5034 // hidden strings hash code is zero (and no other name has hash | 5042 // hidden strings hash code is zero (and no other name has hash |
| 5035 // code zero) it will always occupy the first entry if present. | 5043 // code zero) it will always occupy the first entry if present. |
| 5036 DescriptorArray* descriptors = object->map()->instance_descriptors(); | 5044 DescriptorArray* descriptors = object->map()->instance_descriptors(); |
| 5037 if (descriptors->number_of_descriptors() > 0) { | 5045 if (descriptors->number_of_descriptors() > 0) { |
| 5038 int sorted_index = descriptors->GetSortedKeyIndex(0); | 5046 int sorted_index = descriptors->GetSortedKeyIndex(0); |
| 5039 if (descriptors->GetKey(sorted_index) == isolate->heap()->hidden_string() | 5047 if (descriptors->GetKey(sorted_index) == isolate->heap()->hidden_string() |
| 5040 && sorted_index < object->map()->NumberOfOwnDescriptors()) { | 5048 && sorted_index < object->map()->NumberOfOwnDescriptors()) { |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5771 } | 5779 } |
| 5772 } | 5780 } |
| 5773 } else { | 5781 } else { |
| 5774 Handle<FixedArray> names = | 5782 Handle<FixedArray> names = |
| 5775 isolate->factory()->NewFixedArray(copy->NumberOfLocalProperties()); | 5783 isolate->factory()->NewFixedArray(copy->NumberOfLocalProperties()); |
| 5776 copy->GetLocalPropertyNames(*names, 0); | 5784 copy->GetLocalPropertyNames(*names, 0); |
| 5777 for (int i = 0; i < names->length(); i++) { | 5785 for (int i = 0; i < names->length(); i++) { |
| 5778 ASSERT(names->get(i)->IsString()); | 5786 ASSERT(names->get(i)->IsString()); |
| 5779 Handle<String> key_string(String::cast(names->get(i))); | 5787 Handle<String> key_string(String::cast(names->get(i))); |
| 5780 PropertyAttributes attributes = | 5788 PropertyAttributes attributes = |
| 5781 copy->GetLocalPropertyAttribute(*key_string); | 5789 JSReceiver::GetLocalPropertyAttribute(copy, key_string); |
| 5782 // Only deep copy fields from the object literal expression. | 5790 // Only deep copy fields from the object literal expression. |
| 5783 // In particular, don't try to copy the length attribute of | 5791 // In particular, don't try to copy the length attribute of |
| 5784 // an array. | 5792 // an array. |
| 5785 if (attributes != NONE) continue; | 5793 if (attributes != NONE) continue; |
| 5786 Handle<Object> value( | 5794 Handle<Object> value( |
| 5787 copy->GetProperty(*key_string, &attributes)->ToObjectUnchecked(), | 5795 copy->GetProperty(*key_string, &attributes)->ToObjectUnchecked(), |
| 5788 isolate); | 5796 isolate); |
| 5789 if (value->IsJSObject()) { | 5797 if (value->IsJSObject()) { |
| 5790 Handle<JSObject> result = VisitElementOrProperty( | 5798 Handle<JSObject> result = VisitElementOrProperty( |
| 5791 copy, Handle<JSObject>::cast(value)); | 5799 copy, Handle<JSObject>::cast(value)); |
| (...skipping 5553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11345 | 11353 |
| 11346 | 11354 |
| 11347 // Returns false if the passed-in index is marked non-configurable, | 11355 // Returns false if the passed-in index is marked non-configurable, |
| 11348 // which will cause the ES5 truncation operation to halt, and thus | 11356 // which will cause the ES5 truncation operation to halt, and thus |
| 11349 // no further old values need be collected. | 11357 // no further old values need be collected. |
| 11350 static bool GetOldValue(Isolate* isolate, | 11358 static bool GetOldValue(Isolate* isolate, |
| 11351 Handle<JSObject> object, | 11359 Handle<JSObject> object, |
| 11352 uint32_t index, | 11360 uint32_t index, |
| 11353 List<Handle<Object> >* old_values, | 11361 List<Handle<Object> >* old_values, |
| 11354 List<uint32_t>* indices) { | 11362 List<uint32_t>* indices) { |
| 11355 PropertyAttributes attributes = object->GetLocalElementAttribute(index); | 11363 PropertyAttributes attributes = |
| 11364 JSReceiver::GetLocalElementAttribute(object, index); |
| 11356 ASSERT(attributes != ABSENT); | 11365 ASSERT(attributes != ABSENT); |
| 11357 if (attributes == DONT_DELETE) return false; | 11366 if (attributes == DONT_DELETE) return false; |
| 11358 old_values->Add(object->GetLocalElementAccessorPair(index) == NULL | 11367 old_values->Add(object->GetLocalElementAccessorPair(index) == NULL |
| 11359 ? Object::GetElement(isolate, object, index) | 11368 ? Object::GetElement(isolate, object, index) |
| 11360 : Handle<Object>::cast(isolate->factory()->the_hole_value())); | 11369 : Handle<Object>::cast(isolate->factory()->the_hole_value())); |
| 11361 indices->Add(index); | 11370 indices->Add(index); |
| 11362 return true; | 11371 return true; |
| 11363 } | 11372 } |
| 11364 | 11373 |
| 11365 static void EnqueueSpliceRecord(Handle<JSArray> object, | 11374 static void EnqueueSpliceRecord(Handle<JSArray> object, |
| (...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12548 return object->HasIndexedInterceptor() | 12557 return object->HasIndexedInterceptor() |
| 12549 ? SetElementWithInterceptor(object, index, value, attributes, strict_mode, | 12558 ? SetElementWithInterceptor(object, index, value, attributes, strict_mode, |
| 12550 check_prototype, | 12559 check_prototype, |
| 12551 set_mode) | 12560 set_mode) |
| 12552 : SetElementWithoutInterceptor(object, index, value, attributes, | 12561 : SetElementWithoutInterceptor(object, index, value, attributes, |
| 12553 strict_mode, | 12562 strict_mode, |
| 12554 check_prototype, | 12563 check_prototype, |
| 12555 set_mode); | 12564 set_mode); |
| 12556 } | 12565 } |
| 12557 | 12566 |
| 12558 PropertyAttributes old_attributes = object->GetLocalElementAttribute(index); | 12567 PropertyAttributes old_attributes = |
| 12568 JSReceiver::GetLocalElementAttribute(object, index); |
| 12559 Handle<Object> old_value = isolate->factory()->the_hole_value(); | 12569 Handle<Object> old_value = isolate->factory()->the_hole_value(); |
| 12560 Handle<Object> old_length_handle; | 12570 Handle<Object> old_length_handle; |
| 12561 Handle<Object> new_length_handle; | 12571 Handle<Object> new_length_handle; |
| 12562 | 12572 |
| 12563 if (old_attributes != ABSENT) { | 12573 if (old_attributes != ABSENT) { |
| 12564 if (object->GetLocalElementAccessorPair(index) == NULL) | 12574 if (object->GetLocalElementAccessorPair(index) == NULL) |
| 12565 old_value = Object::GetElement(isolate, object, index); | 12575 old_value = Object::GetElement(isolate, object, index); |
| 12566 } else if (object->IsJSArray()) { | 12576 } else if (object->IsJSArray()) { |
| 12567 // Store old array length in case adding an element grows the array. | 12577 // Store old array length in case adding an element grows the array. |
| 12568 old_length_handle = handle(Handle<JSArray>::cast(object)->length(), | 12578 old_length_handle = handle(Handle<JSArray>::cast(object)->length(), |
| 12569 isolate); | 12579 isolate); |
| 12570 } | 12580 } |
| 12571 | 12581 |
| 12572 // Check for lookup interceptor | 12582 // Check for lookup interceptor |
| 12573 Handle<Object> result = object->HasIndexedInterceptor() | 12583 Handle<Object> result = object->HasIndexedInterceptor() |
| 12574 ? SetElementWithInterceptor(object, index, value, attributes, strict_mode, | 12584 ? SetElementWithInterceptor(object, index, value, attributes, strict_mode, |
| 12575 check_prototype, | 12585 check_prototype, |
| 12576 set_mode) | 12586 set_mode) |
| 12577 : SetElementWithoutInterceptor(object, index, value, attributes, | 12587 : SetElementWithoutInterceptor(object, index, value, attributes, |
| 12578 strict_mode, | 12588 strict_mode, |
| 12579 check_prototype, | 12589 check_prototype, |
| 12580 set_mode); | 12590 set_mode); |
| 12581 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, result, Handle<Object>()); | 12591 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, result, Handle<Object>()); |
| 12582 | 12592 |
| 12583 Handle<String> name = isolate->factory()->Uint32ToString(index); | 12593 Handle<String> name = isolate->factory()->Uint32ToString(index); |
| 12584 PropertyAttributes new_attributes = object->GetLocalElementAttribute(index); | 12594 PropertyAttributes new_attributes = GetLocalElementAttribute(object, index); |
| 12585 if (old_attributes == ABSENT) { | 12595 if (old_attributes == ABSENT) { |
| 12586 if (object->IsJSArray() && | 12596 if (object->IsJSArray() && |
| 12587 !old_length_handle->SameValue( | 12597 !old_length_handle->SameValue( |
| 12588 Handle<JSArray>::cast(object)->length())) { | 12598 Handle<JSArray>::cast(object)->length())) { |
| 12589 new_length_handle = handle(Handle<JSArray>::cast(object)->length(), | 12599 new_length_handle = handle(Handle<JSArray>::cast(object)->length(), |
| 12590 isolate); | 12600 isolate); |
| 12591 uint32_t old_length = 0; | 12601 uint32_t old_length = 0; |
| 12592 uint32_t new_length = 0; | 12602 uint32_t new_length = 0; |
| 12593 CHECK(old_length_handle->ToArrayIndex(&old_length)); | 12603 CHECK(old_length_handle->ToArrayIndex(&old_length)); |
| 12594 CHECK(new_length_handle->ToArrayIndex(&new_length)); | 12604 CHECK(new_length_handle->ToArrayIndex(&new_length)); |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13347 } | 13357 } |
| 13348 | 13358 |
| 13349 LookupResult result(isolate); | 13359 LookupResult result(isolate); |
| 13350 object->LocalLookupRealNamedProperty(*key, &result); | 13360 object->LocalLookupRealNamedProperty(*key, &result); |
| 13351 return result.IsFound() && !result.IsInterceptor(); | 13361 return result.IsFound() && !result.IsInterceptor(); |
| 13352 } | 13362 } |
| 13353 | 13363 |
| 13354 | 13364 |
| 13355 bool JSObject::HasRealElementProperty(Handle<JSObject> object, uint32_t index) { | 13365 bool JSObject::HasRealElementProperty(Handle<JSObject> object, uint32_t index) { |
| 13356 Isolate* isolate = object->GetIsolate(); | 13366 Isolate* isolate = object->GetIsolate(); |
| 13357 SealHandleScope shs(isolate); | 13367 HandleScope scope(isolate); |
| 13358 // Check access rights if needed. | 13368 // Check access rights if needed. |
| 13359 if (object->IsAccessCheckNeeded()) { | 13369 if (object->IsAccessCheckNeeded()) { |
| 13360 if (!isolate->MayIndexedAccessWrapper(object, index, v8::ACCESS_HAS)) { | 13370 if (!isolate->MayIndexedAccessWrapper(object, index, v8::ACCESS_HAS)) { |
| 13361 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_HAS); | 13371 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_HAS); |
| 13362 return false; | 13372 return false; |
| 13363 } | 13373 } |
| 13364 } | 13374 } |
| 13365 | 13375 |
| 13366 if (object->IsJSGlobalProxy()) { | 13376 if (object->IsJSGlobalProxy()) { |
| 13367 HandleScope scope(isolate); | 13377 HandleScope scope(isolate); |
| 13368 Handle<Object> proto(object->GetPrototype(), isolate); | 13378 Handle<Object> proto(object->GetPrototype(), isolate); |
| 13369 if (proto->IsNull()) return false; | 13379 if (proto->IsNull()) return false; |
| 13370 ASSERT(proto->IsJSGlobalObject()); | 13380 ASSERT(proto->IsJSGlobalObject()); |
| 13371 return HasRealElementProperty(Handle<JSObject>::cast(proto), index); | 13381 return HasRealElementProperty(Handle<JSObject>::cast(proto), index); |
| 13372 } | 13382 } |
| 13373 | 13383 |
| 13374 return object->GetElementAttributeWithoutInterceptor( | 13384 return GetElementAttributeWithoutInterceptor( |
| 13375 *object, index, false) != ABSENT; | 13385 object, object, index, false) != ABSENT; |
| 13376 } | 13386 } |
| 13377 | 13387 |
| 13378 | 13388 |
| 13379 bool JSObject::HasRealNamedCallbackProperty(Handle<JSObject> object, | 13389 bool JSObject::HasRealNamedCallbackProperty(Handle<JSObject> object, |
| 13380 Handle<Name> key) { | 13390 Handle<Name> key) { |
| 13381 Isolate* isolate = object->GetIsolate(); | 13391 Isolate* isolate = object->GetIsolate(); |
| 13382 SealHandleScope shs(isolate); | 13392 SealHandleScope shs(isolate); |
| 13383 // Check access rights if needed. | 13393 // Check access rights if needed. |
| 13384 if (object->IsAccessCheckNeeded()) { | 13394 if (object->IsAccessCheckNeeded()) { |
| 13385 if (!isolate->MayNamedAccessWrapper(object, key, v8::ACCESS_HAS)) { | 13395 if (!isolate->MayNamedAccessWrapper(object, key, v8::ACCESS_HAS)) { |
| (...skipping 3094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16480 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16490 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16481 static const char* error_messages_[] = { | 16491 static const char* error_messages_[] = { |
| 16482 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16492 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16483 }; | 16493 }; |
| 16484 #undef ERROR_MESSAGES_TEXTS | 16494 #undef ERROR_MESSAGES_TEXTS |
| 16485 return error_messages_[reason]; | 16495 return error_messages_[reason]; |
| 16486 } | 16496 } |
| 16487 | 16497 |
| 16488 | 16498 |
| 16489 } } // namespace v8::internal | 16499 } } // namespace v8::internal |
| OLD | NEW |