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 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 CALL_HEAP_FUNCTION_PASS_EXCEPTION( | 800 CALL_HEAP_FUNCTION_PASS_EXCEPTION( |
801 isolate, | 801 isolate, |
802 object->GetProperty(*receiver, result, *key, attributes)); | 802 object->GetProperty(*receiver, result, *key, attributes)); |
803 } | 803 } |
804 | 804 |
805 | 805 |
806 MaybeObject* Object::GetProperty(Object* receiver, | 806 MaybeObject* Object::GetProperty(Object* receiver, |
807 LookupResult* result, | 807 LookupResult* result, |
808 Name* name, | 808 Name* name, |
809 PropertyAttributes* attributes) { | 809 PropertyAttributes* attributes) { |
| 810 Isolate* isolate = name->GetIsolate(); |
| 811 Heap* heap = isolate->heap(); |
| 812 |
| 813 #ifdef DEBUG |
| 814 // TODO(mstarzinger): Only because of the AssertNoContextChange, drop as soon |
| 815 // as this method has been fully handlified. |
| 816 HandleScope scope(isolate); |
| 817 #endif |
| 818 |
810 // Make sure that the top context does not change when doing | 819 // Make sure that the top context does not change when doing |
811 // callbacks or interceptor calls. | 820 // callbacks or interceptor calls. |
812 AssertNoContextChangeWithHandleScope ncc; | 821 AssertNoContextChange ncc(isolate); |
813 | |
814 Isolate* isolate = name->GetIsolate(); | |
815 Heap* heap = isolate->heap(); | |
816 | 822 |
817 // Traverse the prototype chain from the current object (this) to | 823 // Traverse the prototype chain from the current object (this) to |
818 // the holder and check for access rights. This avoids traversing the | 824 // the holder and check for access rights. This avoids traversing the |
819 // objects more than once in case of interceptors, because the | 825 // objects more than once in case of interceptors, because the |
820 // holder will always be the interceptor holder and the search may | 826 // holder will always be the interceptor holder and the search may |
821 // only continue with a current object just after the interceptor | 827 // only continue with a current object just after the interceptor |
822 // holder in the prototype chain. | 828 // holder in the prototype chain. |
823 // Proxy handlers do not use the proxy's prototype, so we can skip this. | 829 // Proxy handlers do not use the proxy's prototype, so we can skip this. |
824 if (!result->IsHandler()) { | 830 if (!result->IsHandler()) { |
825 Object* last = result->IsProperty() | 831 Object* last = result->IsProperty() |
(...skipping 3077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3903 LookupResult* lookup, | 3909 LookupResult* lookup, |
3904 Handle<Name> name, | 3910 Handle<Name> name, |
3905 Handle<Object> value, | 3911 Handle<Object> value, |
3906 PropertyAttributes attributes, | 3912 PropertyAttributes attributes, |
3907 StrictModeFlag strict_mode, | 3913 StrictModeFlag strict_mode, |
3908 StoreFromKeyed store_mode) { | 3914 StoreFromKeyed store_mode) { |
3909 Isolate* isolate = object->GetIsolate(); | 3915 Isolate* isolate = object->GetIsolate(); |
3910 | 3916 |
3911 // Make sure that the top context does not change when doing callbacks or | 3917 // Make sure that the top context does not change when doing callbacks or |
3912 // interceptor calls. | 3918 // interceptor calls. |
3913 AssertNoContextChange ncc; | 3919 AssertNoContextChange ncc(isolate); |
3914 | 3920 |
3915 // Optimization for 2-byte strings often used as keys in a decompression | 3921 // Optimization for 2-byte strings often used as keys in a decompression |
3916 // dictionary. We internalize these short keys to avoid constantly | 3922 // dictionary. We internalize these short keys to avoid constantly |
3917 // reallocating them. | 3923 // reallocating them. |
3918 if (name->IsString() && !name->IsInternalizedString() && | 3924 if (name->IsString() && !name->IsInternalizedString() && |
3919 Handle<String>::cast(name)->length() <= 2) { | 3925 Handle<String>::cast(name)->length() <= 2) { |
3920 name = isolate->factory()->InternalizeString(Handle<String>::cast(name)); | 3926 name = isolate->factory()->InternalizeString(Handle<String>::cast(name)); |
3921 } | 3927 } |
3922 | 3928 |
3923 // Check access rights if needed. | 3929 // Check access rights if needed. |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4061 Handle<Name> name, | 4067 Handle<Name> name, |
4062 Handle<Object> value, | 4068 Handle<Object> value, |
4063 PropertyAttributes attributes, | 4069 PropertyAttributes attributes, |
4064 ValueType value_type, | 4070 ValueType value_type, |
4065 StoreMode mode, | 4071 StoreMode mode, |
4066 ExtensibilityCheck extensibility_check) { | 4072 ExtensibilityCheck extensibility_check) { |
4067 Isolate* isolate = object->GetIsolate(); | 4073 Isolate* isolate = object->GetIsolate(); |
4068 | 4074 |
4069 // Make sure that the top context does not change when doing callbacks or | 4075 // Make sure that the top context does not change when doing callbacks or |
4070 // interceptor calls. | 4076 // interceptor calls. |
4071 AssertNoContextChange ncc; | 4077 AssertNoContextChange ncc(isolate); |
4072 | 4078 |
4073 LookupResult lookup(isolate); | 4079 LookupResult lookup(isolate); |
4074 object->LocalLookup(*name, &lookup, true); | 4080 object->LocalLookup(*name, &lookup, true); |
4075 if (!lookup.IsFound()) { | 4081 if (!lookup.IsFound()) { |
4076 object->map()->LookupTransition(*object, *name, &lookup); | 4082 object->map()->LookupTransition(*object, *name, &lookup); |
4077 } | 4083 } |
4078 | 4084 |
4079 // Check access rights if needed. | 4085 // Check access rights if needed. |
4080 if (object->IsAccessCheckNeeded()) { | 4086 if (object->IsAccessCheckNeeded()) { |
4081 if (!isolate->MayNamedAccess(*object, *name, v8::ACCESS_SET)) { | 4087 if (!isolate->MayNamedAccess(*object, *name, v8::ACCESS_SET)) { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4195 Name* name, | 4201 Name* name, |
4196 bool continue_search) { | 4202 bool continue_search) { |
4197 // TODO(rossberg): Support symbols in the API. | 4203 // TODO(rossberg): Support symbols in the API. |
4198 if (name->IsSymbol()) return ABSENT; | 4204 if (name->IsSymbol()) return ABSENT; |
4199 | 4205 |
4200 Isolate* isolate = GetIsolate(); | 4206 Isolate* isolate = GetIsolate(); |
4201 HandleScope scope(isolate); | 4207 HandleScope scope(isolate); |
4202 | 4208 |
4203 // Make sure that the top context does not change when doing | 4209 // Make sure that the top context does not change when doing |
4204 // callbacks or interceptor calls. | 4210 // callbacks or interceptor calls. |
4205 AssertNoContextChange ncc; | 4211 AssertNoContextChange ncc(isolate); |
4206 | 4212 |
4207 Handle<InterceptorInfo> interceptor(GetNamedInterceptor()); | 4213 Handle<InterceptorInfo> interceptor(GetNamedInterceptor()); |
4208 Handle<JSObject> receiver_handle(receiver); | 4214 Handle<JSObject> receiver_handle(receiver); |
4209 Handle<JSObject> holder_handle(this); | 4215 Handle<JSObject> holder_handle(this); |
4210 Handle<String> name_handle(String::cast(name)); | 4216 Handle<String> name_handle(String::cast(name)); |
4211 PropertyCallbackArguments args(isolate, interceptor->data(), receiver, this); | 4217 PropertyCallbackArguments args(isolate, interceptor->data(), receiver, this); |
4212 if (!interceptor->query()->IsUndefined()) { | 4218 if (!interceptor->query()->IsUndefined()) { |
4213 v8::NamedPropertyQueryCallback query = | 4219 v8::NamedPropertyQueryCallback query = |
4214 v8::ToCData<v8::NamedPropertyQueryCallback>(interceptor->query()); | 4220 v8::ToCData<v8::NamedPropertyQueryCallback>(interceptor->query()); |
4215 LOG(isolate, | 4221 LOG(isolate, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4330 } | 4336 } |
4331 | 4337 |
4332 | 4338 |
4333 PropertyAttributes JSObject::GetElementAttributeWithInterceptor( | 4339 PropertyAttributes JSObject::GetElementAttributeWithInterceptor( |
4334 JSReceiver* receiver, uint32_t index, bool continue_search) { | 4340 JSReceiver* receiver, uint32_t index, bool continue_search) { |
4335 Isolate* isolate = GetIsolate(); | 4341 Isolate* isolate = GetIsolate(); |
4336 HandleScope scope(isolate); | 4342 HandleScope scope(isolate); |
4337 | 4343 |
4338 // Make sure that the top context does not change when doing | 4344 // Make sure that the top context does not change when doing |
4339 // callbacks or interceptor calls. | 4345 // callbacks or interceptor calls. |
4340 AssertNoContextChange ncc; | 4346 AssertNoContextChange ncc(isolate); |
4341 | 4347 |
4342 Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); | 4348 Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); |
4343 Handle<JSReceiver> hreceiver(receiver); | 4349 Handle<JSReceiver> hreceiver(receiver); |
4344 Handle<JSObject> holder(this); | 4350 Handle<JSObject> holder(this); |
4345 PropertyCallbackArguments args(isolate, interceptor->data(), receiver, this); | 4351 PropertyCallbackArguments args(isolate, interceptor->data(), receiver, this); |
4346 if (!interceptor->query()->IsUndefined()) { | 4352 if (!interceptor->query()->IsUndefined()) { |
4347 v8::IndexedPropertyQueryCallback query = | 4353 v8::IndexedPropertyQueryCallback query = |
4348 v8::ToCData<v8::IndexedPropertyQueryCallback>(interceptor->query()); | 4354 v8::ToCData<v8::IndexedPropertyQueryCallback>(interceptor->query()); |
4349 LOG(isolate, | 4355 LOG(isolate, |
4350 ApiIndexedPropertyAccess("interceptor-indexed-has", this, index)); | 4356 ApiIndexedPropertyAccess("interceptor-indexed-has", this, index)); |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5040 } | 5046 } |
5041 | 5047 |
5042 | 5048 |
5043 Handle<Object> JSObject::DeleteElementWithInterceptor(Handle<JSObject> object, | 5049 Handle<Object> JSObject::DeleteElementWithInterceptor(Handle<JSObject> object, |
5044 uint32_t index) { | 5050 uint32_t index) { |
5045 Isolate* isolate = object->GetIsolate(); | 5051 Isolate* isolate = object->GetIsolate(); |
5046 Factory* factory = isolate->factory(); | 5052 Factory* factory = isolate->factory(); |
5047 | 5053 |
5048 // Make sure that the top context does not change when doing | 5054 // Make sure that the top context does not change when doing |
5049 // callbacks or interceptor calls. | 5055 // callbacks or interceptor calls. |
5050 AssertNoContextChange ncc; | 5056 AssertNoContextChange ncc(isolate); |
5051 | 5057 |
5052 Handle<InterceptorInfo> interceptor(object->GetIndexedInterceptor()); | 5058 Handle<InterceptorInfo> interceptor(object->GetIndexedInterceptor()); |
5053 if (interceptor->deleter()->IsUndefined()) return factory->false_value(); | 5059 if (interceptor->deleter()->IsUndefined()) return factory->false_value(); |
5054 v8::IndexedPropertyDeleterCallback deleter = | 5060 v8::IndexedPropertyDeleterCallback deleter = |
5055 v8::ToCData<v8::IndexedPropertyDeleterCallback>(interceptor->deleter()); | 5061 v8::ToCData<v8::IndexedPropertyDeleterCallback>(interceptor->deleter()); |
5056 LOG(isolate, | 5062 LOG(isolate, |
5057 ApiIndexedPropertyAccess("interceptor-indexed-delete", *object, index)); | 5063 ApiIndexedPropertyAccess("interceptor-indexed-delete", *object, index)); |
5058 PropertyCallbackArguments args( | 5064 PropertyCallbackArguments args( |
5059 isolate, interceptor->data(), *object, *object); | 5065 isolate, interceptor->data(), *object, *object); |
5060 v8::Handle<v8::Boolean> result = args.Call(deleter, index); | 5066 v8::Handle<v8::Boolean> result = args.Call(deleter, index); |
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6170 name, | 6176 name, |
6171 getter, | 6177 getter, |
6172 setter, | 6178 setter, |
6173 attributes, | 6179 attributes, |
6174 access_control); | 6180 access_control); |
6175 return; | 6181 return; |
6176 } | 6182 } |
6177 | 6183 |
6178 // Make sure that the top context does not change when doing callbacks or | 6184 // Make sure that the top context does not change when doing callbacks or |
6179 // interceptor calls. | 6185 // interceptor calls. |
6180 AssertNoContextChange ncc; | 6186 AssertNoContextChange ncc(isolate); |
6181 | 6187 |
6182 // Try to flatten before operating on the string. | 6188 // Try to flatten before operating on the string. |
6183 if (name->IsString()) String::cast(*name)->TryFlatten(); | 6189 if (name->IsString()) String::cast(*name)->TryFlatten(); |
6184 | 6190 |
6185 if (!object->CanSetCallback(*name)) return; | 6191 if (!object->CanSetCallback(*name)) return; |
6186 | 6192 |
6187 uint32_t index = 0; | 6193 uint32_t index = 0; |
6188 bool is_element = name->AsArrayIndex(&index); | 6194 bool is_element = name->AsArrayIndex(&index); |
6189 | 6195 |
6190 Handle<Object> old_value = isolate->factory()->the_hole_value(); | 6196 Handle<Object> old_value = isolate->factory()->the_hole_value(); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6356 | 6362 |
6357 if (object->IsJSGlobalProxy()) { | 6363 if (object->IsJSGlobalProxy()) { |
6358 Handle<Object> proto(object->GetPrototype(), isolate); | 6364 Handle<Object> proto(object->GetPrototype(), isolate); |
6359 if (proto->IsNull()) return object; | 6365 if (proto->IsNull()) return object; |
6360 ASSERT(proto->IsJSGlobalObject()); | 6366 ASSERT(proto->IsJSGlobalObject()); |
6361 return SetAccessor(Handle<JSObject>::cast(proto), info); | 6367 return SetAccessor(Handle<JSObject>::cast(proto), info); |
6362 } | 6368 } |
6363 | 6369 |
6364 // Make sure that the top context does not change when doing callbacks or | 6370 // Make sure that the top context does not change when doing callbacks or |
6365 // interceptor calls. | 6371 // interceptor calls. |
6366 AssertNoContextChange ncc; | 6372 AssertNoContextChange ncc(isolate); |
6367 | 6373 |
6368 // Try to flatten before operating on the string. | 6374 // Try to flatten before operating on the string. |
6369 if (name->IsString()) FlattenString(Handle<String>::cast(name)); | 6375 if (name->IsString()) FlattenString(Handle<String>::cast(name)); |
6370 | 6376 |
6371 if (!object->CanSetCallback(*name)) return factory->undefined_value(); | 6377 if (!object->CanSetCallback(*name)) return factory->undefined_value(); |
6372 | 6378 |
6373 uint32_t index = 0; | 6379 uint32_t index = 0; |
6374 bool is_element = name->AsArrayIndex(&index); | 6380 bool is_element = name->AsArrayIndex(&index); |
6375 | 6381 |
6376 if (is_element) { | 6382 if (is_element) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6422 } | 6428 } |
6423 | 6429 |
6424 | 6430 |
6425 Handle<Object> JSObject::GetAccessor(Handle<JSObject> object, | 6431 Handle<Object> JSObject::GetAccessor(Handle<JSObject> object, |
6426 Handle<Name> name, | 6432 Handle<Name> name, |
6427 AccessorComponent component) { | 6433 AccessorComponent component) { |
6428 Isolate* isolate = object->GetIsolate(); | 6434 Isolate* isolate = object->GetIsolate(); |
6429 | 6435 |
6430 // Make sure that the top context does not change when doing callbacks or | 6436 // Make sure that the top context does not change when doing callbacks or |
6431 // interceptor calls. | 6437 // interceptor calls. |
6432 AssertNoContextChange ncc; | 6438 AssertNoContextChange ncc(isolate); |
6433 | 6439 |
6434 // Check access rights if needed. | 6440 // Check access rights if needed. |
6435 if (object->IsAccessCheckNeeded() && | 6441 if (object->IsAccessCheckNeeded() && |
6436 !isolate->MayNamedAccess(*object, *name, v8::ACCESS_HAS)) { | 6442 !isolate->MayNamedAccess(*object, *name, v8::ACCESS_HAS)) { |
6437 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_HAS); | 6443 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_HAS); |
6438 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 6444 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
6439 return isolate->factory()->undefined_value(); | 6445 return isolate->factory()->undefined_value(); |
6440 } | 6446 } |
6441 | 6447 |
6442 // Make the lookup and include prototypes. | 6448 // Make the lookup and include prototypes. |
(...skipping 5235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11678 Object* value, | 11684 Object* value, |
11679 PropertyAttributes attributes, | 11685 PropertyAttributes attributes, |
11680 StrictModeFlag strict_mode, | 11686 StrictModeFlag strict_mode, |
11681 bool check_prototype, | 11687 bool check_prototype, |
11682 SetPropertyMode set_mode) { | 11688 SetPropertyMode set_mode) { |
11683 Isolate* isolate = GetIsolate(); | 11689 Isolate* isolate = GetIsolate(); |
11684 HandleScope scope(isolate); | 11690 HandleScope scope(isolate); |
11685 | 11691 |
11686 // Make sure that the top context does not change when doing | 11692 // Make sure that the top context does not change when doing |
11687 // callbacks or interceptor calls. | 11693 // callbacks or interceptor calls. |
11688 AssertNoContextChange ncc; | 11694 AssertNoContextChange ncc(isolate); |
11689 | 11695 |
11690 Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); | 11696 Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); |
11691 Handle<JSObject> this_handle(this); | 11697 Handle<JSObject> this_handle(this); |
11692 Handle<Object> value_handle(value, isolate); | 11698 Handle<Object> value_handle(value, isolate); |
11693 if (!interceptor->setter()->IsUndefined()) { | 11699 if (!interceptor->setter()->IsUndefined()) { |
11694 v8::IndexedPropertySetterCallback setter = | 11700 v8::IndexedPropertySetterCallback setter = |
11695 v8::ToCData<v8::IndexedPropertySetterCallback>(interceptor->setter()); | 11701 v8::ToCData<v8::IndexedPropertySetterCallback>(interceptor->setter()); |
11696 LOG(isolate, | 11702 LOG(isolate, |
11697 ApiIndexedPropertyAccess("interceptor-indexed-set", this, index)); | 11703 ApiIndexedPropertyAccess("interceptor-indexed-set", this, index)); |
11698 PropertyCallbackArguments args(isolate, interceptor->data(), this, this); | 11704 PropertyCallbackArguments args(isolate, interceptor->data(), this, this); |
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12690 } | 12696 } |
12691 | 12697 |
12692 | 12698 |
12693 MaybeObject* JSObject::GetElementWithInterceptor(Object* receiver, | 12699 MaybeObject* JSObject::GetElementWithInterceptor(Object* receiver, |
12694 uint32_t index) { | 12700 uint32_t index) { |
12695 Isolate* isolate = GetIsolate(); | 12701 Isolate* isolate = GetIsolate(); |
12696 HandleScope scope(isolate); | 12702 HandleScope scope(isolate); |
12697 | 12703 |
12698 // Make sure that the top context does not change when doing | 12704 // Make sure that the top context does not change when doing |
12699 // callbacks or interceptor calls. | 12705 // callbacks or interceptor calls. |
12700 AssertNoContextChange ncc; | 12706 AssertNoContextChange ncc(isolate); |
12701 | 12707 |
12702 Handle<InterceptorInfo> interceptor(GetIndexedInterceptor(), isolate); | 12708 Handle<InterceptorInfo> interceptor(GetIndexedInterceptor(), isolate); |
12703 Handle<Object> this_handle(receiver, isolate); | 12709 Handle<Object> this_handle(receiver, isolate); |
12704 Handle<JSObject> holder_handle(this, isolate); | 12710 Handle<JSObject> holder_handle(this, isolate); |
12705 if (!interceptor->getter()->IsUndefined()) { | 12711 if (!interceptor->getter()->IsUndefined()) { |
12706 v8::IndexedPropertyGetterCallback getter = | 12712 v8::IndexedPropertyGetterCallback getter = |
12707 v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter()); | 12713 v8::ToCData<v8::IndexedPropertyGetterCallback>(interceptor->getter()); |
12708 LOG(isolate, | 12714 LOG(isolate, |
12709 ApiIndexedPropertyAccess("interceptor-indexed-get", this, index)); | 12715 ApiIndexedPropertyAccess("interceptor-indexed-get", this, index)); |
12710 PropertyCallbackArguments | 12716 PropertyCallbackArguments |
(...skipping 3481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16192 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16198 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16193 static const char* error_messages_[] = { | 16199 static const char* error_messages_[] = { |
16194 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16200 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16195 }; | 16201 }; |
16196 #undef ERROR_MESSAGES_TEXTS | 16202 #undef ERROR_MESSAGES_TEXTS |
16197 return error_messages_[reason]; | 16203 return error_messages_[reason]; |
16198 } | 16204 } |
16199 | 16205 |
16200 | 16206 |
16201 } } // namespace v8::internal | 16207 } } // namespace v8::internal |
OLD | NEW |