| 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 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 } | 608 } |
| 609 break; | 609 break; |
| 610 } | 610 } |
| 611 default: | 611 default: |
| 612 UNREACHABLE(); | 612 UNREACHABLE(); |
| 613 } | 613 } |
| 614 } | 614 } |
| 615 | 615 |
| 616 // No accessible property found. | 616 // No accessible property found. |
| 617 *attributes = ABSENT; | 617 *attributes = ABSENT; |
| 618 isolate->ReportFailedAccessCheck(*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 Object* receiver, |
| 626 LookupResult* result, | 626 LookupResult* result, |
| 627 Name* name, | 627 Name* name, |
| 628 bool continue_search) { | 628 bool continue_search) { |
| (...skipping 2748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3377 | 3377 |
| 3378 if (closest_map->elements_kind() == kind) { | 3378 if (closest_map->elements_kind() == kind) { |
| 3379 return closest_map; | 3379 return closest_map; |
| 3380 } | 3380 } |
| 3381 | 3381 |
| 3382 return AddMissingElementsTransitions(closest_map, kind); | 3382 return AddMissingElementsTransitions(closest_map, kind); |
| 3383 } | 3383 } |
| 3384 | 3384 |
| 3385 | 3385 |
| 3386 void JSObject::LocalLookupRealNamedProperty(Name* name, LookupResult* result) { | 3386 void JSObject::LocalLookupRealNamedProperty(Name* name, LookupResult* result) { |
| 3387 DisallowHeapAllocation no_gc; |
| 3387 if (IsJSGlobalProxy()) { | 3388 if (IsJSGlobalProxy()) { |
| 3388 Object* proto = GetPrototype(); | 3389 Object* proto = GetPrototype(); |
| 3389 if (proto->IsNull()) return result->NotFound(); | 3390 if (proto->IsNull()) return result->NotFound(); |
| 3390 ASSERT(proto->IsJSGlobalObject()); | 3391 ASSERT(proto->IsJSGlobalObject()); |
| 3391 return JSObject::cast(proto)->LocalLookupRealNamedProperty(name, result); | 3392 return JSObject::cast(proto)->LocalLookupRealNamedProperty(name, result); |
| 3392 } | 3393 } |
| 3393 | 3394 |
| 3394 if (HasFastProperties()) { | 3395 if (HasFastProperties()) { |
| 3395 map()->LookupDescriptor(this, name, result); | 3396 map()->LookupDescriptor(this, name, result); |
| 3396 // A property or a map transition was found. We return all of these result | 3397 // A property or a map transition was found. We return all of these result |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3512 break; | 3513 break; |
| 3513 } | 3514 } |
| 3514 default: { | 3515 default: { |
| 3515 break; | 3516 break; |
| 3516 } | 3517 } |
| 3517 } | 3518 } |
| 3518 } | 3519 } |
| 3519 } | 3520 } |
| 3520 | 3521 |
| 3521 Isolate* isolate = object->GetIsolate(); | 3522 Isolate* isolate = object->GetIsolate(); |
| 3522 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_SET); | 3523 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_SET); |
| 3523 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 3524 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 3524 return value; | 3525 return value; |
| 3525 } | 3526 } |
| 3526 | 3527 |
| 3527 | 3528 |
| 3528 Handle<Object> JSReceiver::SetProperty(Handle<JSReceiver> object, | 3529 Handle<Object> JSReceiver::SetProperty(Handle<JSReceiver> object, |
| 3529 LookupResult* result, | 3530 LookupResult* result, |
| 3530 Handle<Name> key, | 3531 Handle<Name> key, |
| 3531 Handle<Object> value, | 3532 Handle<Object> value, |
| 3532 PropertyAttributes attributes, | 3533 PropertyAttributes attributes, |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4042 // Optimization for 2-byte strings often used as keys in a decompression | 4043 // Optimization for 2-byte strings often used as keys in a decompression |
| 4043 // dictionary. We internalize these short keys to avoid constantly | 4044 // dictionary. We internalize these short keys to avoid constantly |
| 4044 // reallocating them. | 4045 // reallocating them. |
| 4045 if (name->IsString() && !name->IsInternalizedString() && | 4046 if (name->IsString() && !name->IsInternalizedString() && |
| 4046 Handle<String>::cast(name)->length() <= 2) { | 4047 Handle<String>::cast(name)->length() <= 2) { |
| 4047 name = isolate->factory()->InternalizeString(Handle<String>::cast(name)); | 4048 name = isolate->factory()->InternalizeString(Handle<String>::cast(name)); |
| 4048 } | 4049 } |
| 4049 | 4050 |
| 4050 // Check access rights if needed. | 4051 // Check access rights if needed. |
| 4051 if (object->IsAccessCheckNeeded()) { | 4052 if (object->IsAccessCheckNeeded()) { |
| 4052 if (!isolate->MayNamedAccess(*object, *name, v8::ACCESS_SET)) { | 4053 if (!isolate->MayNamedAccessWrapper(object, name, v8::ACCESS_SET)) { |
| 4053 return SetPropertyWithFailedAccessCheck(object, lookup, name, value, | 4054 return SetPropertyWithFailedAccessCheck(object, lookup, name, value, |
| 4054 true, strict_mode); | 4055 true, strict_mode); |
| 4055 } | 4056 } |
| 4056 } | 4057 } |
| 4057 | 4058 |
| 4058 if (object->IsJSGlobalProxy()) { | 4059 if (object->IsJSGlobalProxy()) { |
| 4059 Handle<Object> proto(object->GetPrototype(), isolate); | 4060 Handle<Object> proto(object->GetPrototype(), isolate); |
| 4060 if (proto->IsNull()) return value; | 4061 if (proto->IsNull()) return value; |
| 4061 ASSERT(proto->IsJSGlobalObject()); | 4062 ASSERT(proto->IsJSGlobalObject()); |
| 4062 return SetPropertyForResult(Handle<JSObject>::cast(proto), | 4063 return SetPropertyForResult(Handle<JSObject>::cast(proto), |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4177 AssertNoContextChange ncc(isolate); | 4178 AssertNoContextChange ncc(isolate); |
| 4178 | 4179 |
| 4179 LookupResult lookup(isolate); | 4180 LookupResult lookup(isolate); |
| 4180 object->LocalLookup(*name, &lookup, true); | 4181 object->LocalLookup(*name, &lookup, true); |
| 4181 if (!lookup.IsFound()) { | 4182 if (!lookup.IsFound()) { |
| 4182 object->map()->LookupTransition(*object, *name, &lookup); | 4183 object->map()->LookupTransition(*object, *name, &lookup); |
| 4183 } | 4184 } |
| 4184 | 4185 |
| 4185 // Check access rights if needed. | 4186 // Check access rights if needed. |
| 4186 if (object->IsAccessCheckNeeded()) { | 4187 if (object->IsAccessCheckNeeded()) { |
| 4187 if (!isolate->MayNamedAccess(*object, *name, v8::ACCESS_SET)) { | 4188 if (!isolate->MayNamedAccessWrapper(object, name, v8::ACCESS_SET)) { |
| 4188 return SetPropertyWithFailedAccessCheck(object, &lookup, name, value, | 4189 return SetPropertyWithFailedAccessCheck(object, &lookup, name, value, |
| 4189 false, kNonStrictMode); | 4190 false, kNonStrictMode); |
| 4190 } | 4191 } |
| 4191 } | 4192 } |
| 4192 | 4193 |
| 4193 if (object->IsJSGlobalProxy()) { | 4194 if (object->IsJSGlobalProxy()) { |
| 4194 Handle<Object> proto(object->GetPrototype(), isolate); | 4195 Handle<Object> proto(object->GetPrototype(), isolate); |
| 4195 if (proto->IsNull()) return value; | 4196 if (proto->IsNull()) return value; |
| 4196 ASSERT(proto->IsJSGlobalObject()); | 4197 ASSERT(proto->IsJSGlobalObject()); |
| 4197 return SetLocalPropertyIgnoreAttributes(Handle<JSObject>::cast(proto), | 4198 return SetLocalPropertyIgnoreAttributes(Handle<JSObject>::cast(proto), |
| (...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5162 | 5163 |
| 5163 | 5164 |
| 5164 Handle<Object> JSObject::DeleteElement(Handle<JSObject> object, | 5165 Handle<Object> JSObject::DeleteElement(Handle<JSObject> object, |
| 5165 uint32_t index, | 5166 uint32_t index, |
| 5166 DeleteMode mode) { | 5167 DeleteMode mode) { |
| 5167 Isolate* isolate = object->GetIsolate(); | 5168 Isolate* isolate = object->GetIsolate(); |
| 5168 Factory* factory = isolate->factory(); | 5169 Factory* factory = isolate->factory(); |
| 5169 | 5170 |
| 5170 // Check access rights if needed. | 5171 // Check access rights if needed. |
| 5171 if (object->IsAccessCheckNeeded() && | 5172 if (object->IsAccessCheckNeeded() && |
| 5172 !isolate->MayIndexedAccess(*object, index, v8::ACCESS_DELETE)) { | 5173 !isolate->MayIndexedAccessWrapper(object, index, v8::ACCESS_DELETE)) { |
| 5173 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_DELETE); | 5174 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_DELETE); |
| 5174 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 5175 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 5175 return factory->false_value(); | 5176 return factory->false_value(); |
| 5176 } | 5177 } |
| 5177 | 5178 |
| 5178 if (object->IsStringObjectWithCharacterAt(index)) { | 5179 if (object->IsStringObjectWithCharacterAt(index)) { |
| 5179 if (mode == STRICT_DELETION) { | 5180 if (mode == STRICT_DELETION) { |
| 5180 // Deleting a non-configurable property in strict mode. | 5181 // Deleting a non-configurable property in strict mode. |
| 5181 Handle<Object> name = factory->NewNumberFromUint(index); | 5182 Handle<Object> name = factory->NewNumberFromUint(index); |
| 5182 Handle<Object> args[2] = { name, object }; | 5183 Handle<Object> args[2] = { name, object }; |
| 5183 Handle<Object> error = | 5184 Handle<Object> error = |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5226 | 5227 |
| 5227 Handle<Object> JSObject::DeleteProperty(Handle<JSObject> object, | 5228 Handle<Object> JSObject::DeleteProperty(Handle<JSObject> object, |
| 5228 Handle<Name> name, | 5229 Handle<Name> name, |
| 5229 DeleteMode mode) { | 5230 DeleteMode mode) { |
| 5230 Isolate* isolate = object->GetIsolate(); | 5231 Isolate* isolate = object->GetIsolate(); |
| 5231 // ECMA-262, 3rd, 8.6.2.5 | 5232 // ECMA-262, 3rd, 8.6.2.5 |
| 5232 ASSERT(name->IsName()); | 5233 ASSERT(name->IsName()); |
| 5233 | 5234 |
| 5234 // Check access rights if needed. | 5235 // Check access rights if needed. |
| 5235 if (object->IsAccessCheckNeeded() && | 5236 if (object->IsAccessCheckNeeded() && |
| 5236 !isolate->MayNamedAccess(*object, *name, v8::ACCESS_DELETE)) { | 5237 !isolate->MayNamedAccessWrapper(object, name, v8::ACCESS_DELETE)) { |
| 5237 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_DELETE); | 5238 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_DELETE); |
| 5238 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 5239 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 5239 return isolate->factory()->false_value(); | 5240 return isolate->factory()->false_value(); |
| 5240 } | 5241 } |
| 5241 | 5242 |
| 5242 if (object->IsJSGlobalProxy()) { | 5243 if (object->IsJSGlobalProxy()) { |
| 5243 Object* proto = object->GetPrototype(); | 5244 Object* proto = object->GetPrototype(); |
| 5244 if (proto->IsNull()) return isolate->factory()->false_value(); | 5245 if (proto->IsNull()) return isolate->factory()->false_value(); |
| 5245 ASSERT(proto->IsJSGlobalObject()); | 5246 ASSERT(proto->IsJSGlobalObject()); |
| 5246 return JSGlobalObject::DeleteProperty( | 5247 return JSGlobalObject::DeleteProperty( |
| 5247 handle(JSGlobalObject::cast(proto)), name, mode); | 5248 handle(JSGlobalObject::cast(proto)), name, mode); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5451 return false; | 5452 return false; |
| 5452 } | 5453 } |
| 5453 | 5454 |
| 5454 | 5455 |
| 5455 Handle<Object> JSObject::PreventExtensions(Handle<JSObject> object) { | 5456 Handle<Object> JSObject::PreventExtensions(Handle<JSObject> object) { |
| 5456 Isolate* isolate = object->GetIsolate(); | 5457 Isolate* isolate = object->GetIsolate(); |
| 5457 | 5458 |
| 5458 if (!object->map()->is_extensible()) return object; | 5459 if (!object->map()->is_extensible()) return object; |
| 5459 | 5460 |
| 5460 if (object->IsAccessCheckNeeded() && | 5461 if (object->IsAccessCheckNeeded() && |
| 5461 !isolate->MayNamedAccess(*object, | 5462 !isolate->MayNamedAccessWrapper(object, |
| 5462 isolate->heap()->undefined_value(), | 5463 isolate->factory()->undefined_value(), |
| 5463 v8::ACCESS_KEYS)) { | 5464 v8::ACCESS_KEYS)) { |
| 5464 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_KEYS); | 5465 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_KEYS); |
| 5465 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 5466 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 5466 return isolate->factory()->false_value(); | 5467 return isolate->factory()->false_value(); |
| 5467 } | 5468 } |
| 5468 | 5469 |
| 5469 if (object->IsJSGlobalProxy()) { | 5470 if (object->IsJSGlobalProxy()) { |
| 5470 Handle<Object> proto(object->GetPrototype(), isolate); | 5471 Handle<Object> proto(object->GetPrototype(), isolate); |
| 5471 if (proto->IsNull()) return object; | 5472 if (proto->IsNull()) return object; |
| 5472 ASSERT(proto->IsJSGlobalObject()); | 5473 ASSERT(proto->IsJSGlobalObject()); |
| 5473 return PreventExtensions(Handle<JSObject>::cast(proto)); | 5474 return PreventExtensions(Handle<JSObject>::cast(proto)); |
| 5474 } | 5475 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5531 | 5532 |
| 5532 Handle<Object> JSObject::Freeze(Handle<JSObject> object) { | 5533 Handle<Object> JSObject::Freeze(Handle<JSObject> object) { |
| 5533 // Freezing non-strict arguments should be handled elsewhere. | 5534 // Freezing non-strict arguments should be handled elsewhere. |
| 5534 ASSERT(!object->HasNonStrictArgumentsElements()); | 5535 ASSERT(!object->HasNonStrictArgumentsElements()); |
| 5535 ASSERT(!object->map()->is_observed()); | 5536 ASSERT(!object->map()->is_observed()); |
| 5536 | 5537 |
| 5537 if (object->map()->is_frozen()) return object; | 5538 if (object->map()->is_frozen()) return object; |
| 5538 | 5539 |
| 5539 Isolate* isolate = object->GetIsolate(); | 5540 Isolate* isolate = object->GetIsolate(); |
| 5540 if (object->IsAccessCheckNeeded() && | 5541 if (object->IsAccessCheckNeeded() && |
| 5541 !isolate->MayNamedAccess(*object, | 5542 !isolate->MayNamedAccessWrapper(object, |
| 5542 isolate->heap()->undefined_value(), | 5543 isolate->factory()->undefined_value(), |
| 5543 v8::ACCESS_KEYS)) { | 5544 v8::ACCESS_KEYS)) { |
| 5544 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_KEYS); | 5545 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_KEYS); |
| 5545 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 5546 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 5546 return isolate->factory()->false_value(); | 5547 return isolate->factory()->false_value(); |
| 5547 } | 5548 } |
| 5548 | 5549 |
| 5549 if (object->IsJSGlobalProxy()) { | 5550 if (object->IsJSGlobalProxy()) { |
| 5550 Handle<Object> proto(object->GetPrototype(), isolate); | 5551 Handle<Object> proto(object->GetPrototype(), isolate); |
| 5551 if (proto->IsNull()) return object; | 5552 if (proto->IsNull()) return object; |
| 5552 ASSERT(proto->IsJSGlobalObject()); | 5553 ASSERT(proto->IsJSGlobalObject()); |
| 5553 return Freeze(Handle<JSObject>::cast(proto)); | 5554 return Freeze(Handle<JSObject>::cast(proto)); |
| 5554 } | 5555 } |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6194 } | 6195 } |
| 6195 | 6196 |
| 6196 Handle<AccessorPair> accessors = CreateAccessorPairFor(object, name); | 6197 Handle<AccessorPair> accessors = CreateAccessorPairFor(object, name); |
| 6197 accessors->SetComponents(*getter, *setter); | 6198 accessors->SetComponents(*getter, *setter); |
| 6198 accessors->set_access_flags(access_control); | 6199 accessors->set_access_flags(access_control); |
| 6199 | 6200 |
| 6200 SetPropertyCallback(object, name, accessors, attributes); | 6201 SetPropertyCallback(object, name, accessors, attributes); |
| 6201 } | 6202 } |
| 6202 | 6203 |
| 6203 | 6204 |
| 6204 bool JSObject::CanSetCallback(Name* name) { | 6205 bool JSObject::CanSetCallback(Handle<JSObject> object, Handle<Name> name) { |
| 6205 ASSERT(!IsAccessCheckNeeded() || | 6206 Isolate* isolate = object->GetIsolate(); |
| 6206 GetIsolate()->MayNamedAccess(this, name, v8::ACCESS_SET)); | 6207 ASSERT(!object->IsAccessCheckNeeded() || |
| 6208 isolate->MayNamedAccessWrapper(object, name, v8::ACCESS_SET)); |
| 6207 | 6209 |
| 6208 // Check if there is an API defined callback object which prohibits | 6210 // Check if there is an API defined callback object which prohibits |
| 6209 // callback overwriting in this object or its prototype chain. | 6211 // callback overwriting in this object or its prototype chain. |
| 6210 // This mechanism is needed for instance in a browser setting, where | 6212 // This mechanism is needed for instance in a browser setting, where |
| 6211 // certain accessors such as window.location should not be allowed | 6213 // certain accessors such as window.location should not be allowed |
| 6212 // to be overwritten because allowing overwriting could potentially | 6214 // to be overwritten because allowing overwriting could potentially |
| 6213 // cause security problems. | 6215 // cause security problems. |
| 6214 LookupResult callback_result(GetIsolate()); | 6216 LookupResult callback_result(isolate); |
| 6215 LookupCallbackProperty(name, &callback_result); | 6217 object->LookupCallbackProperty(*name, &callback_result); |
| 6216 if (callback_result.IsFound()) { | 6218 if (callback_result.IsFound()) { |
| 6217 Object* obj = callback_result.GetCallbackObject(); | 6219 Object* callback_obj = callback_result.GetCallbackObject(); |
| 6218 if (obj->IsAccessorInfo()) { | 6220 if (callback_obj->IsAccessorInfo()) { |
| 6219 return !AccessorInfo::cast(obj)->prohibits_overwriting(); | 6221 return !AccessorInfo::cast(callback_obj)->prohibits_overwriting(); |
| 6220 } | 6222 } |
| 6221 if (obj->IsAccessorPair()) { | 6223 if (callback_obj->IsAccessorPair()) { |
| 6222 return !AccessorPair::cast(obj)->prohibits_overwriting(); | 6224 return !AccessorPair::cast(callback_obj)->prohibits_overwriting(); |
| 6223 } | 6225 } |
| 6224 } | 6226 } |
| 6225 return true; | 6227 return true; |
| 6226 } | 6228 } |
| 6227 | 6229 |
| 6228 | 6230 |
| 6229 bool Map::DictionaryElementsInPrototypeChainOnly() { | 6231 bool Map::DictionaryElementsInPrototypeChainOnly() { |
| 6230 Heap* heap = GetHeap(); | 6232 Heap* heap = GetHeap(); |
| 6231 | 6233 |
| 6232 if (IsDictionaryElementsKind(elements_kind())) { | 6234 if (IsDictionaryElementsKind(elements_kind())) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6319 | 6321 |
| 6320 void JSObject::DefineAccessor(Handle<JSObject> object, | 6322 void JSObject::DefineAccessor(Handle<JSObject> object, |
| 6321 Handle<Name> name, | 6323 Handle<Name> name, |
| 6322 Handle<Object> getter, | 6324 Handle<Object> getter, |
| 6323 Handle<Object> setter, | 6325 Handle<Object> setter, |
| 6324 PropertyAttributes attributes, | 6326 PropertyAttributes attributes, |
| 6325 v8::AccessControl access_control) { | 6327 v8::AccessControl access_control) { |
| 6326 Isolate* isolate = object->GetIsolate(); | 6328 Isolate* isolate = object->GetIsolate(); |
| 6327 // Check access rights if needed. | 6329 // Check access rights if needed. |
| 6328 if (object->IsAccessCheckNeeded() && | 6330 if (object->IsAccessCheckNeeded() && |
| 6329 !isolate->MayNamedAccess(*object, *name, v8::ACCESS_SET)) { | 6331 !isolate->MayNamedAccessWrapper(object, name, v8::ACCESS_SET)) { |
| 6330 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_SET); | 6332 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_SET); |
| 6331 return; | 6333 return; |
| 6332 } | 6334 } |
| 6333 | 6335 |
| 6334 if (object->IsJSGlobalProxy()) { | 6336 if (object->IsJSGlobalProxy()) { |
| 6335 Handle<Object> proto(object->GetPrototype(), isolate); | 6337 Handle<Object> proto(object->GetPrototype(), isolate); |
| 6336 if (proto->IsNull()) return; | 6338 if (proto->IsNull()) return; |
| 6337 ASSERT(proto->IsJSGlobalObject()); | 6339 ASSERT(proto->IsJSGlobalObject()); |
| 6338 DefineAccessor(Handle<JSObject>::cast(proto), | 6340 DefineAccessor(Handle<JSObject>::cast(proto), |
| 6339 name, | 6341 name, |
| 6340 getter, | 6342 getter, |
| 6341 setter, | 6343 setter, |
| 6342 attributes, | 6344 attributes, |
| 6343 access_control); | 6345 access_control); |
| 6344 return; | 6346 return; |
| 6345 } | 6347 } |
| 6346 | 6348 |
| 6347 // Make sure that the top context does not change when doing callbacks or | 6349 // Make sure that the top context does not change when doing callbacks or |
| 6348 // interceptor calls. | 6350 // interceptor calls. |
| 6349 AssertNoContextChange ncc(isolate); | 6351 AssertNoContextChange ncc(isolate); |
| 6350 | 6352 |
| 6351 // Try to flatten before operating on the string. | 6353 // Try to flatten before operating on the string. |
| 6352 if (name->IsString()) String::cast(*name)->TryFlatten(); | 6354 if (name->IsString()) String::cast(*name)->TryFlatten(); |
| 6353 | 6355 |
| 6354 if (!object->CanSetCallback(*name)) return; | 6356 if (!JSObject::CanSetCallback(object, name)) return; |
| 6355 | 6357 |
| 6356 uint32_t index = 0; | 6358 uint32_t index = 0; |
| 6357 bool is_element = name->AsArrayIndex(&index); | 6359 bool is_element = name->AsArrayIndex(&index); |
| 6358 | 6360 |
| 6359 Handle<Object> old_value = isolate->factory()->the_hole_value(); | 6361 Handle<Object> old_value = isolate->factory()->the_hole_value(); |
| 6360 bool is_observed = FLAG_harmony_observation && | 6362 bool is_observed = FLAG_harmony_observation && |
| 6361 object->map()->is_observed() && | 6363 object->map()->is_observed() && |
| 6362 *name != isolate->heap()->hidden_string(); | 6364 *name != isolate->heap()->hidden_string(); |
| 6363 bool preexists = false; | 6365 bool preexists = false; |
| 6364 if (is_observed) { | 6366 if (is_observed) { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6512 | 6514 |
| 6513 | 6515 |
| 6514 Handle<Object> JSObject::SetAccessor(Handle<JSObject> object, | 6516 Handle<Object> JSObject::SetAccessor(Handle<JSObject> object, |
| 6515 Handle<AccessorInfo> info) { | 6517 Handle<AccessorInfo> info) { |
| 6516 Isolate* isolate = object->GetIsolate(); | 6518 Isolate* isolate = object->GetIsolate(); |
| 6517 Factory* factory = isolate->factory(); | 6519 Factory* factory = isolate->factory(); |
| 6518 Handle<Name> name(Name::cast(info->name())); | 6520 Handle<Name> name(Name::cast(info->name())); |
| 6519 | 6521 |
| 6520 // Check access rights if needed. | 6522 // Check access rights if needed. |
| 6521 if (object->IsAccessCheckNeeded() && | 6523 if (object->IsAccessCheckNeeded() && |
| 6522 !isolate->MayNamedAccess(*object, *name, v8::ACCESS_SET)) { | 6524 !isolate->MayNamedAccessWrapper(object, name, v8::ACCESS_SET)) { |
| 6523 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_SET); | 6525 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_SET); |
| 6524 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 6526 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 6525 return factory->undefined_value(); | 6527 return factory->undefined_value(); |
| 6526 } | 6528 } |
| 6527 | 6529 |
| 6528 if (object->IsJSGlobalProxy()) { | 6530 if (object->IsJSGlobalProxy()) { |
| 6529 Handle<Object> proto(object->GetPrototype(), isolate); | 6531 Handle<Object> proto(object->GetPrototype(), isolate); |
| 6530 if (proto->IsNull()) return object; | 6532 if (proto->IsNull()) return object; |
| 6531 ASSERT(proto->IsJSGlobalObject()); | 6533 ASSERT(proto->IsJSGlobalObject()); |
| 6532 return SetAccessor(Handle<JSObject>::cast(proto), info); | 6534 return SetAccessor(Handle<JSObject>::cast(proto), info); |
| 6533 } | 6535 } |
| 6534 | 6536 |
| 6535 // Make sure that the top context does not change when doing callbacks or | 6537 // Make sure that the top context does not change when doing callbacks or |
| 6536 // interceptor calls. | 6538 // interceptor calls. |
| 6537 AssertNoContextChange ncc(isolate); | 6539 AssertNoContextChange ncc(isolate); |
| 6538 | 6540 |
| 6539 // Try to flatten before operating on the string. | 6541 // Try to flatten before operating on the string. |
| 6540 if (name->IsString()) FlattenString(Handle<String>::cast(name)); | 6542 if (name->IsString()) FlattenString(Handle<String>::cast(name)); |
| 6541 | 6543 |
| 6542 if (!object->CanSetCallback(*name)) return factory->undefined_value(); | 6544 if (!JSObject::CanSetCallback(object, name)) { |
| 6545 return factory->undefined_value(); |
| 6546 } |
| 6543 | 6547 |
| 6544 uint32_t index = 0; | 6548 uint32_t index = 0; |
| 6545 bool is_element = name->AsArrayIndex(&index); | 6549 bool is_element = name->AsArrayIndex(&index); |
| 6546 | 6550 |
| 6547 if (is_element) { | 6551 if (is_element) { |
| 6548 if (object->IsJSArray()) return factory->undefined_value(); | 6552 if (object->IsJSArray()) return factory->undefined_value(); |
| 6549 | 6553 |
| 6550 // Accessors overwrite previous callbacks (cf. with getters/setters). | 6554 // Accessors overwrite previous callbacks (cf. with getters/setters). |
| 6551 switch (object->GetElementsKind()) { | 6555 switch (object->GetElementsKind()) { |
| 6552 case FAST_SMI_ELEMENTS: | 6556 case FAST_SMI_ELEMENTS: |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6596 Handle<Name> name, | 6600 Handle<Name> name, |
| 6597 AccessorComponent component) { | 6601 AccessorComponent component) { |
| 6598 Isolate* isolate = object->GetIsolate(); | 6602 Isolate* isolate = object->GetIsolate(); |
| 6599 | 6603 |
| 6600 // Make sure that the top context does not change when doing callbacks or | 6604 // Make sure that the top context does not change when doing callbacks or |
| 6601 // interceptor calls. | 6605 // interceptor calls. |
| 6602 AssertNoContextChange ncc(isolate); | 6606 AssertNoContextChange ncc(isolate); |
| 6603 | 6607 |
| 6604 // Check access rights if needed. | 6608 // Check access rights if needed. |
| 6605 if (object->IsAccessCheckNeeded() && | 6609 if (object->IsAccessCheckNeeded() && |
| 6606 !isolate->MayNamedAccess(*object, *name, v8::ACCESS_HAS)) { | 6610 !isolate->MayNamedAccessWrapper(object, name, v8::ACCESS_HAS)) { |
| 6607 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_HAS); | 6611 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_HAS); |
| 6608 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 6612 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 6609 return isolate->factory()->undefined_value(); | 6613 return isolate->factory()->undefined_value(); |
| 6610 } | 6614 } |
| 6611 | 6615 |
| 6612 // Make the lookup and include prototypes. | 6616 // Make the lookup and include prototypes. |
| 6613 uint32_t index = 0; | 6617 uint32_t index = 0; |
| 6614 if (name->AsArrayIndex(&index)) { | 6618 if (name->AsArrayIndex(&index)) { |
| 6615 for (Handle<Object> obj = object; | 6619 for (Handle<Object> obj = object; |
| 6616 !obj->IsNull(); | 6620 !obj->IsNull(); |
| 6617 obj = handle(JSReceiver::cast(*obj)->GetPrototype(), isolate)) { | 6621 obj = handle(JSReceiver::cast(*obj)->GetPrototype(), isolate)) { |
| (...skipping 5887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12505 bool has_exception; | 12509 bool has_exception; |
| 12506 Handle<Object> number = | 12510 Handle<Object> number = |
| 12507 Execution::ToNumber(isolate, value, &has_exception); | 12511 Execution::ToNumber(isolate, value, &has_exception); |
| 12508 if (has_exception) return Handle<Object>(); | 12512 if (has_exception) return Handle<Object>(); |
| 12509 value = number; | 12513 value = number; |
| 12510 } | 12514 } |
| 12511 } | 12515 } |
| 12512 | 12516 |
| 12513 // Check access rights if needed. | 12517 // Check access rights if needed. |
| 12514 if (object->IsAccessCheckNeeded()) { | 12518 if (object->IsAccessCheckNeeded()) { |
| 12515 if (!isolate->MayIndexedAccess(*object, index, v8::ACCESS_SET)) { | 12519 if (!isolate->MayIndexedAccessWrapper(object, index, v8::ACCESS_SET)) { |
| 12516 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_SET); | 12520 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_SET); |
| 12517 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 12521 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 12518 return value; | 12522 return value; |
| 12519 } | 12523 } |
| 12520 } | 12524 } |
| 12521 | 12525 |
| 12522 if (object->IsJSGlobalProxy()) { | 12526 if (object->IsJSGlobalProxy()) { |
| 12523 Handle<Object> proto(object->GetPrototype(), isolate); | 12527 Handle<Object> proto(object->GetPrototype(), isolate); |
| 12524 if (proto->IsNull()) return value; | 12528 if (proto->IsNull()) return value; |
| 12525 ASSERT(proto->IsJSGlobalObject()); | 12529 ASSERT(proto->IsJSGlobalObject()); |
| 12526 return SetElement(Handle<JSObject>::cast(proto), index, value, attributes, | 12530 return SetElement(Handle<JSObject>::cast(proto), index, value, attributes, |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13318 return GetPropertyPostInterceptor(object, receiver, name, attributes); | 13322 return GetPropertyPostInterceptor(object, receiver, name, attributes); |
| 13319 } | 13323 } |
| 13320 | 13324 |
| 13321 | 13325 |
| 13322 bool JSObject::HasRealNamedProperty(Handle<JSObject> object, | 13326 bool JSObject::HasRealNamedProperty(Handle<JSObject> object, |
| 13323 Handle<Name> key) { | 13327 Handle<Name> key) { |
| 13324 Isolate* isolate = object->GetIsolate(); | 13328 Isolate* isolate = object->GetIsolate(); |
| 13325 SealHandleScope shs(isolate); | 13329 SealHandleScope shs(isolate); |
| 13326 // Check access rights if needed. | 13330 // Check access rights if needed. |
| 13327 if (object->IsAccessCheckNeeded()) { | 13331 if (object->IsAccessCheckNeeded()) { |
| 13328 if (!isolate->MayNamedAccess(*object, *key, v8::ACCESS_HAS)) { | 13332 if (!isolate->MayNamedAccessWrapper(object, key, v8::ACCESS_HAS)) { |
| 13329 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_HAS); | 13333 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_HAS); |
| 13330 return false; | 13334 return false; |
| 13331 } | 13335 } |
| 13332 } | 13336 } |
| 13333 | 13337 |
| 13334 LookupResult result(isolate); | 13338 LookupResult result(isolate); |
| 13335 object->LocalLookupRealNamedProperty(*key, &result); | 13339 object->LocalLookupRealNamedProperty(*key, &result); |
| 13336 return result.IsFound() && !result.IsInterceptor(); | 13340 return result.IsFound() && !result.IsInterceptor(); |
| 13337 } | 13341 } |
| 13338 | 13342 |
| 13339 | 13343 |
| 13340 bool JSObject::HasRealElementProperty(Handle<JSObject> object, uint32_t index) { | 13344 bool JSObject::HasRealElementProperty(Handle<JSObject> object, uint32_t index) { |
| 13341 Isolate* isolate = object->GetIsolate(); | 13345 Isolate* isolate = object->GetIsolate(); |
| 13342 SealHandleScope shs(isolate); | 13346 SealHandleScope shs(isolate); |
| 13343 // Check access rights if needed. | 13347 // Check access rights if needed. |
| 13344 if (object->IsAccessCheckNeeded()) { | 13348 if (object->IsAccessCheckNeeded()) { |
| 13345 if (!isolate->MayIndexedAccess(*object, index, v8::ACCESS_HAS)) { | 13349 if (!isolate->MayIndexedAccessWrapper(object, index, v8::ACCESS_HAS)) { |
| 13346 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_HAS); | 13350 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_HAS); |
| 13347 return false; | 13351 return false; |
| 13348 } | 13352 } |
| 13349 } | 13353 } |
| 13350 | 13354 |
| 13351 if (object->IsJSGlobalProxy()) { | 13355 if (object->IsJSGlobalProxy()) { |
| 13352 HandleScope scope(isolate); | 13356 HandleScope scope(isolate); |
| 13353 Handle<Object> proto(object->GetPrototype(), isolate); | 13357 Handle<Object> proto(object->GetPrototype(), isolate); |
| 13354 if (proto->IsNull()) return false; | 13358 if (proto->IsNull()) return false; |
| 13355 ASSERT(proto->IsJSGlobalObject()); | 13359 ASSERT(proto->IsJSGlobalObject()); |
| 13356 return HasRealElementProperty(Handle<JSObject>::cast(proto), index); | 13360 return HasRealElementProperty(Handle<JSObject>::cast(proto), index); |
| 13357 } | 13361 } |
| 13358 | 13362 |
| 13359 return object->GetElementAttributeWithoutInterceptor( | 13363 return object->GetElementAttributeWithoutInterceptor( |
| 13360 *object, index, false) != ABSENT; | 13364 *object, index, false) != ABSENT; |
| 13361 } | 13365 } |
| 13362 | 13366 |
| 13363 | 13367 |
| 13364 bool JSObject::HasRealNamedCallbackProperty(Handle<JSObject> object, | 13368 bool JSObject::HasRealNamedCallbackProperty(Handle<JSObject> object, |
| 13365 Handle<Name> key) { | 13369 Handle<Name> key) { |
| 13366 Isolate* isolate = object->GetIsolate(); | 13370 Isolate* isolate = object->GetIsolate(); |
| 13367 SealHandleScope shs(isolate); | 13371 SealHandleScope shs(isolate); |
| 13368 // Check access rights if needed. | 13372 // Check access rights if needed. |
| 13369 if (object->IsAccessCheckNeeded()) { | 13373 if (object->IsAccessCheckNeeded()) { |
| 13370 if (!isolate->MayNamedAccess(*object, *key, v8::ACCESS_HAS)) { | 13374 if (!isolate->MayNamedAccessWrapper(object, key, v8::ACCESS_HAS)) { |
| 13371 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_HAS); | 13375 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_HAS); |
| 13372 return false; | 13376 return false; |
| 13373 } | 13377 } |
| 13374 } | 13378 } |
| 13375 | 13379 |
| 13376 LookupResult result(isolate); | 13380 LookupResult result(isolate); |
| 13377 object->LocalLookupRealNamedProperty(*key, &result); | 13381 object->LocalLookupRealNamedProperty(*key, &result); |
| 13378 return result.IsPropertyCallbacks(); | 13382 return result.IsPropertyCallbacks(); |
| 13379 } | 13383 } |
| 13380 | 13384 |
| 13381 | 13385 |
| (...skipping 3098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16480 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16484 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16481 static const char* error_messages_[] = { | 16485 static const char* error_messages_[] = { |
| 16482 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16486 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16483 }; | 16487 }; |
| 16484 #undef ERROR_MESSAGES_TEXTS | 16488 #undef ERROR_MESSAGES_TEXTS |
| 16485 return error_messages_[reason]; | 16489 return error_messages_[reason]; |
| 16486 } | 16490 } |
| 16487 | 16491 |
| 16488 | 16492 |
| 16489 } } // namespace v8::internal | 16493 } } // namespace v8::internal |
| OLD | NEW |