| 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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 } | 545 } |
| 546 break; | 546 break; |
| 547 } | 547 } |
| 548 default: | 548 default: |
| 549 UNREACHABLE(); | 549 UNREACHABLE(); |
| 550 } | 550 } |
| 551 } | 551 } |
| 552 | 552 |
| 553 // No accessible property found. | 553 // No accessible property found. |
| 554 *attributes = ABSENT; | 554 *attributes = ABSENT; |
| 555 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_GET); | 555 isolate->ReportFailedAccessCheck(object, v8::ACCESS_GET); |
| 556 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 556 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 557 return isolate->factory()->undefined_value(); | 557 return isolate->factory()->undefined_value(); |
| 558 } | 558 } |
| 559 | 559 |
| 560 | 560 |
| 561 PropertyAttributes JSObject::GetPropertyAttributeWithFailedAccessCheck( | 561 PropertyAttributes JSObject::GetPropertyAttributeWithFailedAccessCheck( |
| 562 Handle<JSObject> object, | 562 Handle<JSObject> object, |
| 563 LookupResult* result, | 563 LookupResult* result, |
| 564 Handle<Name> name, | 564 Handle<Name> name, |
| 565 bool continue_search) { | 565 bool continue_search) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 return GetPropertyAttributeWithFailedAccessCheck( | 609 return GetPropertyAttributeWithFailedAccessCheck( |
| 610 object, &r, name, continue_search); | 610 object, &r, name, continue_search); |
| 611 } | 611 } |
| 612 | 612 |
| 613 case HANDLER: | 613 case HANDLER: |
| 614 case NONEXISTENT: | 614 case NONEXISTENT: |
| 615 UNREACHABLE(); | 615 UNREACHABLE(); |
| 616 } | 616 } |
| 617 } | 617 } |
| 618 | 618 |
| 619 object->GetIsolate()->ReportFailedAccessCheckWrapper(object, v8::ACCESS_HAS); | 619 object->GetIsolate()->ReportFailedAccessCheck(object, v8::ACCESS_HAS); |
| 620 // TODO(yangguo): Issue 3269, check for scheduled exception missing? |
| 620 return ABSENT; | 621 return ABSENT; |
| 621 } | 622 } |
| 622 | 623 |
| 623 | 624 |
| 624 Object* JSObject::GetNormalizedProperty(const LookupResult* result) { | 625 Object* JSObject::GetNormalizedProperty(const LookupResult* result) { |
| 625 ASSERT(!HasFastProperties()); | 626 ASSERT(!HasFastProperties()); |
| 626 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); | 627 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); |
| 627 if (IsGlobalObject()) { | 628 if (IsGlobalObject()) { |
| 628 value = PropertyCell::cast(value)->value(); | 629 value = PropertyCell::cast(value)->value(); |
| 629 } | 630 } |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 : Handle<Object>::cast(factory->null_value()); | 797 : Handle<Object>::cast(factory->null_value()); |
| 797 for (Handle<Object> current = object; | 798 for (Handle<Object> current = object; |
| 798 true; | 799 true; |
| 799 current = Handle<Object>(current->GetPrototype(isolate), isolate)) { | 800 current = Handle<Object>(current->GetPrototype(isolate), isolate)) { |
| 800 if (current->IsAccessCheckNeeded()) { | 801 if (current->IsAccessCheckNeeded()) { |
| 801 // Check if we're allowed to read from the current object. Note | 802 // Check if we're allowed to read from the current object. Note |
| 802 // that even though we may not actually end up loading the named | 803 // that even though we may not actually end up loading the named |
| 803 // property from the current object, we still check that we have | 804 // property from the current object, we still check that we have |
| 804 // access to it. | 805 // access to it. |
| 805 Handle<JSObject> checked = Handle<JSObject>::cast(current); | 806 Handle<JSObject> checked = Handle<JSObject>::cast(current); |
| 806 if (!isolate->MayNamedAccessWrapper(checked, name, v8::ACCESS_GET)) { | 807 if (!isolate->MayNamedAccess(checked, name, v8::ACCESS_GET)) { |
| 807 return JSObject::GetPropertyWithFailedAccessCheck( | 808 return JSObject::GetPropertyWithFailedAccessCheck( |
| 808 checked, receiver, result, name, attributes); | 809 checked, receiver, result, name, attributes); |
| 809 } | 810 } |
| 810 } | 811 } |
| 811 // Stop traversing the chain once we reach the last object in the | 812 // Stop traversing the chain once we reach the last object in the |
| 812 // chain; either the holder of the result or null in case of an | 813 // chain; either the holder of the result or null in case of an |
| 813 // absent property. | 814 // absent property. |
| 814 if (current.is_identical_to(last)) break; | 815 if (current.is_identical_to(last)) break; |
| 815 } | 816 } |
| 816 } | 817 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 } | 893 } |
| 893 } | 894 } |
| 894 | 895 |
| 895 // Inline the case for JSObjects. Doing so significantly improves the | 896 // Inline the case for JSObjects. Doing so significantly improves the |
| 896 // performance of fetching elements where checking the prototype chain is | 897 // performance of fetching elements where checking the prototype chain is |
| 897 // necessary. | 898 // necessary. |
| 898 Handle<JSObject> js_object = Handle<JSObject>::cast(holder); | 899 Handle<JSObject> js_object = Handle<JSObject>::cast(holder); |
| 899 | 900 |
| 900 // Check access rights if needed. | 901 // Check access rights if needed. |
| 901 if (js_object->IsAccessCheckNeeded()) { | 902 if (js_object->IsAccessCheckNeeded()) { |
| 902 if (!isolate->MayIndexedAccessWrapper(js_object, index, v8::ACCESS_GET)) { | 903 if (!isolate->MayIndexedAccess(js_object, index, v8::ACCESS_GET)) { |
| 903 isolate->ReportFailedAccessCheckWrapper(js_object, v8::ACCESS_GET); | 904 isolate->ReportFailedAccessCheck(js_object, v8::ACCESS_GET); |
| 904 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 905 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 905 return isolate->factory()->undefined_value(); | 906 return isolate->factory()->undefined_value(); |
| 906 } | 907 } |
| 907 } | 908 } |
| 908 | 909 |
| 909 if (js_object->HasIndexedInterceptor()) { | 910 if (js_object->HasIndexedInterceptor()) { |
| 910 return JSObject::GetElementWithInterceptor(js_object, receiver, index); | 911 return JSObject::GetElementWithInterceptor(js_object, receiver, index); |
| 911 } | 912 } |
| 912 | 913 |
| 913 if (js_object->elements() != isolate->heap()->empty_fixed_array()) { | 914 if (js_object->elements() != isolate->heap()->empty_fixed_array()) { |
| (...skipping 2474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3388 break; | 3389 break; |
| 3389 } | 3390 } |
| 3390 default: { | 3391 default: { |
| 3391 break; | 3392 break; |
| 3392 } | 3393 } |
| 3393 } | 3394 } |
| 3394 } | 3395 } |
| 3395 } | 3396 } |
| 3396 | 3397 |
| 3397 Isolate* isolate = object->GetIsolate(); | 3398 Isolate* isolate = object->GetIsolate(); |
| 3398 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_SET); | 3399 isolate->ReportFailedAccessCheck(object, v8::ACCESS_SET); |
| 3399 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | 3400 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 3400 return value; | 3401 return value; |
| 3401 } | 3402 } |
| 3402 | 3403 |
| 3403 | 3404 |
| 3404 MaybeHandle<Object> JSReceiver::SetProperty(Handle<JSReceiver> object, | 3405 MaybeHandle<Object> JSReceiver::SetProperty(Handle<JSReceiver> object, |
| 3405 LookupResult* result, | 3406 LookupResult* result, |
| 3406 Handle<Name> key, | 3407 Handle<Name> key, |
| 3407 Handle<Object> value, | 3408 Handle<Object> value, |
| 3408 PropertyAttributes attributes, | 3409 PropertyAttributes attributes, |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3938 // Optimization for 2-byte strings often used as keys in a decompression | 3939 // Optimization for 2-byte strings often used as keys in a decompression |
| 3939 // dictionary. We internalize these short keys to avoid constantly | 3940 // dictionary. We internalize these short keys to avoid constantly |
| 3940 // reallocating them. | 3941 // reallocating them. |
| 3941 if (name->IsString() && !name->IsInternalizedString() && | 3942 if (name->IsString() && !name->IsInternalizedString() && |
| 3942 Handle<String>::cast(name)->length() <= 2) { | 3943 Handle<String>::cast(name)->length() <= 2) { |
| 3943 name = isolate->factory()->InternalizeString(Handle<String>::cast(name)); | 3944 name = isolate->factory()->InternalizeString(Handle<String>::cast(name)); |
| 3944 } | 3945 } |
| 3945 | 3946 |
| 3946 // Check access rights if needed. | 3947 // Check access rights if needed. |
| 3947 if (object->IsAccessCheckNeeded()) { | 3948 if (object->IsAccessCheckNeeded()) { |
| 3948 if (!isolate->MayNamedAccessWrapper(object, name, v8::ACCESS_SET)) { | 3949 if (!isolate->MayNamedAccess(object, name, v8::ACCESS_SET)) { |
| 3949 return SetPropertyWithFailedAccessCheck(object, lookup, name, value, | 3950 return SetPropertyWithFailedAccessCheck(object, lookup, name, value, |
| 3950 true, strict_mode); | 3951 true, strict_mode); |
| 3951 } | 3952 } |
| 3952 } | 3953 } |
| 3953 | 3954 |
| 3954 if (object->IsJSGlobalProxy()) { | 3955 if (object->IsJSGlobalProxy()) { |
| 3955 Handle<Object> proto(object->GetPrototype(), isolate); | 3956 Handle<Object> proto(object->GetPrototype(), isolate); |
| 3956 if (proto->IsNull()) return value; | 3957 if (proto->IsNull()) return value; |
| 3957 ASSERT(proto->IsJSGlobalObject()); | 3958 ASSERT(proto->IsJSGlobalObject()); |
| 3958 return SetPropertyForResult(Handle<JSObject>::cast(proto), | 3959 return SetPropertyForResult(Handle<JSObject>::cast(proto), |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4078 AssertNoContextChange ncc(isolate); | 4079 AssertNoContextChange ncc(isolate); |
| 4079 | 4080 |
| 4080 LookupResult lookup(isolate); | 4081 LookupResult lookup(isolate); |
| 4081 object->LocalLookup(*name, &lookup, true); | 4082 object->LocalLookup(*name, &lookup, true); |
| 4082 if (!lookup.IsFound()) { | 4083 if (!lookup.IsFound()) { |
| 4083 object->map()->LookupTransition(*object, *name, &lookup); | 4084 object->map()->LookupTransition(*object, *name, &lookup); |
| 4084 } | 4085 } |
| 4085 | 4086 |
| 4086 // Check access rights if needed. | 4087 // Check access rights if needed. |
| 4087 if (object->IsAccessCheckNeeded()) { | 4088 if (object->IsAccessCheckNeeded()) { |
| 4088 if (!isolate->MayNamedAccessWrapper(object, name, v8::ACCESS_SET)) { | 4089 if (!isolate->MayNamedAccess(object, name, v8::ACCESS_SET)) { |
| 4089 return SetPropertyWithFailedAccessCheck(object, &lookup, name, value, | 4090 return SetPropertyWithFailedAccessCheck(object, &lookup, name, value, |
| 4090 false, SLOPPY); | 4091 false, SLOPPY); |
| 4091 } | 4092 } |
| 4092 } | 4093 } |
| 4093 | 4094 |
| 4094 if (object->IsJSGlobalProxy()) { | 4095 if (object->IsJSGlobalProxy()) { |
| 4095 Handle<Object> proto(object->GetPrototype(), isolate); | 4096 Handle<Object> proto(object->GetPrototype(), isolate); |
| 4096 if (proto->IsNull()) return value; | 4097 if (proto->IsNull()) return value; |
| 4097 ASSERT(proto->IsJSGlobalObject()); | 4098 ASSERT(proto->IsJSGlobalObject()); |
| 4098 return SetLocalPropertyIgnoreAttributes(Handle<JSObject>::cast(proto), | 4099 return SetLocalPropertyIgnoreAttributes(Handle<JSObject>::cast(proto), |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4270 PropertyAttributes JSReceiver::GetPropertyAttributeForResult( | 4271 PropertyAttributes JSReceiver::GetPropertyAttributeForResult( |
| 4271 Handle<JSReceiver> object, | 4272 Handle<JSReceiver> object, |
| 4272 Handle<JSReceiver> receiver, | 4273 Handle<JSReceiver> receiver, |
| 4273 LookupResult* lookup, | 4274 LookupResult* lookup, |
| 4274 Handle<Name> name, | 4275 Handle<Name> name, |
| 4275 bool continue_search) { | 4276 bool continue_search) { |
| 4276 // Check access rights if needed. | 4277 // Check access rights if needed. |
| 4277 if (object->IsAccessCheckNeeded()) { | 4278 if (object->IsAccessCheckNeeded()) { |
| 4278 Heap* heap = object->GetHeap(); | 4279 Heap* heap = object->GetHeap(); |
| 4279 Handle<JSObject> obj = Handle<JSObject>::cast(object); | 4280 Handle<JSObject> obj = Handle<JSObject>::cast(object); |
| 4280 if (!heap->isolate()->MayNamedAccessWrapper(obj, name, v8::ACCESS_HAS)) { | 4281 if (!heap->isolate()->MayNamedAccess(obj, name, v8::ACCESS_HAS)) { |
| 4281 return JSObject::GetPropertyAttributeWithFailedAccessCheck( | 4282 return JSObject::GetPropertyAttributeWithFailedAccessCheck( |
| 4282 obj, lookup, name, continue_search); | 4283 obj, lookup, name, continue_search); |
| 4283 } | 4284 } |
| 4284 } | 4285 } |
| 4285 if (lookup->IsFound()) { | 4286 if (lookup->IsFound()) { |
| 4286 switch (lookup->type()) { | 4287 switch (lookup->type()) { |
| 4287 case NORMAL: // fall through | 4288 case NORMAL: // fall through |
| 4288 case FIELD: | 4289 case FIELD: |
| 4289 case CONSTANT: | 4290 case CONSTANT: |
| 4290 case CALLBACKS: | 4291 case CALLBACKS: |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4323 | 4324 |
| 4324 PropertyAttributes JSObject::GetElementAttributeWithReceiver( | 4325 PropertyAttributes JSObject::GetElementAttributeWithReceiver( |
| 4325 Handle<JSObject> object, | 4326 Handle<JSObject> object, |
| 4326 Handle<JSReceiver> receiver, | 4327 Handle<JSReceiver> receiver, |
| 4327 uint32_t index, | 4328 uint32_t index, |
| 4328 bool continue_search) { | 4329 bool continue_search) { |
| 4329 Isolate* isolate = object->GetIsolate(); | 4330 Isolate* isolate = object->GetIsolate(); |
| 4330 | 4331 |
| 4331 // Check access rights if needed. | 4332 // Check access rights if needed. |
| 4332 if (object->IsAccessCheckNeeded()) { | 4333 if (object->IsAccessCheckNeeded()) { |
| 4333 if (!isolate->MayIndexedAccessWrapper(object, index, v8::ACCESS_HAS)) { | 4334 if (!isolate->MayIndexedAccess(object, index, v8::ACCESS_HAS)) { |
| 4334 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_HAS); | 4335 isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS); |
| 4336 // TODO(yangguo): Issue 3269, check for scheduled exception missing? |
| 4335 return ABSENT; | 4337 return ABSENT; |
| 4336 } | 4338 } |
| 4337 } | 4339 } |
| 4338 | 4340 |
| 4339 if (object->IsJSGlobalProxy()) { | 4341 if (object->IsJSGlobalProxy()) { |
| 4340 Handle<Object> proto(object->GetPrototype(), isolate); | 4342 Handle<Object> proto(object->GetPrototype(), isolate); |
| 4341 if (proto->IsNull()) return ABSENT; | 4343 if (proto->IsNull()) return ABSENT; |
| 4342 ASSERT(proto->IsJSGlobalObject()); | 4344 ASSERT(proto->IsJSGlobalObject()); |
| 4343 return JSObject::GetElementAttributeWithReceiver( | 4345 return JSObject::GetElementAttributeWithReceiver( |
| 4344 Handle<JSObject>::cast(proto), receiver, index, continue_search); | 4346 Handle<JSObject>::cast(proto), receiver, index, continue_search); |
| (...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5200 | 5202 |
| 5201 | 5203 |
| 5202 MaybeHandle<Object> JSObject::DeleteElement(Handle<JSObject> object, | 5204 MaybeHandle<Object> JSObject::DeleteElement(Handle<JSObject> object, |
| 5203 uint32_t index, | 5205 uint32_t index, |
| 5204 DeleteMode mode) { | 5206 DeleteMode mode) { |
| 5205 Isolate* isolate = object->GetIsolate(); | 5207 Isolate* isolate = object->GetIsolate(); |
| 5206 Factory* factory = isolate->factory(); | 5208 Factory* factory = isolate->factory(); |
| 5207 | 5209 |
| 5208 // Check access rights if needed. | 5210 // Check access rights if needed. |
| 5209 if (object->IsAccessCheckNeeded() && | 5211 if (object->IsAccessCheckNeeded() && |
| 5210 !isolate->MayIndexedAccessWrapper(object, index, v8::ACCESS_DELETE)) { | 5212 !isolate->MayIndexedAccess(object, index, v8::ACCESS_DELETE)) { |
| 5211 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_DELETE); | 5213 isolate->ReportFailedAccessCheck(object, v8::ACCESS_DELETE); |
| 5212 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 5214 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 5213 return factory->false_value(); | 5215 return factory->false_value(); |
| 5214 } | 5216 } |
| 5215 | 5217 |
| 5216 if (object->IsStringObjectWithCharacterAt(index)) { | 5218 if (object->IsStringObjectWithCharacterAt(index)) { |
| 5217 if (mode == STRICT_DELETION) { | 5219 if (mode == STRICT_DELETION) { |
| 5218 // Deleting a non-configurable property in strict mode. | 5220 // Deleting a non-configurable property in strict mode. |
| 5219 Handle<Object> name = factory->NewNumberFromUint(index); | 5221 Handle<Object> name = factory->NewNumberFromUint(index); |
| 5220 Handle<Object> args[2] = { name, object }; | 5222 Handle<Object> args[2] = { name, object }; |
| 5221 Handle<Object> error = | 5223 Handle<Object> error = |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5269 | 5271 |
| 5270 MaybeHandle<Object> JSObject::DeleteProperty(Handle<JSObject> object, | 5272 MaybeHandle<Object> JSObject::DeleteProperty(Handle<JSObject> object, |
| 5271 Handle<Name> name, | 5273 Handle<Name> name, |
| 5272 DeleteMode mode) { | 5274 DeleteMode mode) { |
| 5273 Isolate* isolate = object->GetIsolate(); | 5275 Isolate* isolate = object->GetIsolate(); |
| 5274 // ECMA-262, 3rd, 8.6.2.5 | 5276 // ECMA-262, 3rd, 8.6.2.5 |
| 5275 ASSERT(name->IsName()); | 5277 ASSERT(name->IsName()); |
| 5276 | 5278 |
| 5277 // Check access rights if needed. | 5279 // Check access rights if needed. |
| 5278 if (object->IsAccessCheckNeeded() && | 5280 if (object->IsAccessCheckNeeded() && |
| 5279 !isolate->MayNamedAccessWrapper(object, name, v8::ACCESS_DELETE)) { | 5281 !isolate->MayNamedAccess(object, name, v8::ACCESS_DELETE)) { |
| 5280 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_DELETE); | 5282 isolate->ReportFailedAccessCheck(object, v8::ACCESS_DELETE); |
| 5281 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 5283 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 5282 return isolate->factory()->false_value(); | 5284 return isolate->factory()->false_value(); |
| 5283 } | 5285 } |
| 5284 | 5286 |
| 5285 if (object->IsJSGlobalProxy()) { | 5287 if (object->IsJSGlobalProxy()) { |
| 5286 Object* proto = object->GetPrototype(); | 5288 Object* proto = object->GetPrototype(); |
| 5287 if (proto->IsNull()) return isolate->factory()->false_value(); | 5289 if (proto->IsNull()) return isolate->factory()->false_value(); |
| 5288 ASSERT(proto->IsJSGlobalObject()); | 5290 ASSERT(proto->IsJSGlobalObject()); |
| 5289 return JSGlobalObject::DeleteProperty( | 5291 return JSGlobalObject::DeleteProperty( |
| 5290 handle(JSGlobalObject::cast(proto)), name, mode); | 5292 handle(JSGlobalObject::cast(proto)), name, mode); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5499 return false; | 5501 return false; |
| 5500 } | 5502 } |
| 5501 | 5503 |
| 5502 | 5504 |
| 5503 Handle<Object> JSObject::PreventExtensions(Handle<JSObject> object) { | 5505 Handle<Object> JSObject::PreventExtensions(Handle<JSObject> object) { |
| 5504 Isolate* isolate = object->GetIsolate(); | 5506 Isolate* isolate = object->GetIsolate(); |
| 5505 | 5507 |
| 5506 if (!object->map()->is_extensible()) return object; | 5508 if (!object->map()->is_extensible()) return object; |
| 5507 | 5509 |
| 5508 if (object->IsAccessCheckNeeded() && | 5510 if (object->IsAccessCheckNeeded() && |
| 5509 !isolate->MayNamedAccessWrapper(object, | 5511 !isolate->MayNamedAccess( |
| 5510 isolate->factory()->undefined_value(), | 5512 object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { |
| 5511 v8::ACCESS_KEYS)) { | 5513 isolate->ReportFailedAccessCheck(object, v8::ACCESS_KEYS); |
| 5512 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_KEYS); | |
| 5513 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 5514 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 5514 return isolate->factory()->false_value(); | 5515 return isolate->factory()->false_value(); |
| 5515 } | 5516 } |
| 5516 | 5517 |
| 5517 if (object->IsJSGlobalProxy()) { | 5518 if (object->IsJSGlobalProxy()) { |
| 5518 Handle<Object> proto(object->GetPrototype(), isolate); | 5519 Handle<Object> proto(object->GetPrototype(), isolate); |
| 5519 if (proto->IsNull()) return object; | 5520 if (proto->IsNull()) return object; |
| 5520 ASSERT(proto->IsJSGlobalObject()); | 5521 ASSERT(proto->IsJSGlobalObject()); |
| 5521 return PreventExtensions(Handle<JSObject>::cast(proto)); | 5522 return PreventExtensions(Handle<JSObject>::cast(proto)); |
| 5522 } | 5523 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5583 | 5584 |
| 5584 MaybeHandle<Object> JSObject::Freeze(Handle<JSObject> object) { | 5585 MaybeHandle<Object> JSObject::Freeze(Handle<JSObject> object) { |
| 5585 // Freezing sloppy arguments should be handled elsewhere. | 5586 // Freezing sloppy arguments should be handled elsewhere. |
| 5586 ASSERT(!object->HasSloppyArgumentsElements()); | 5587 ASSERT(!object->HasSloppyArgumentsElements()); |
| 5587 ASSERT(!object->map()->is_observed()); | 5588 ASSERT(!object->map()->is_observed()); |
| 5588 | 5589 |
| 5589 if (object->map()->is_frozen()) return object; | 5590 if (object->map()->is_frozen()) return object; |
| 5590 | 5591 |
| 5591 Isolate* isolate = object->GetIsolate(); | 5592 Isolate* isolate = object->GetIsolate(); |
| 5592 if (object->IsAccessCheckNeeded() && | 5593 if (object->IsAccessCheckNeeded() && |
| 5593 !isolate->MayNamedAccessWrapper(object, | 5594 !isolate->MayNamedAccess( |
| 5594 isolate->factory()->undefined_value(), | 5595 object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { |
| 5595 v8::ACCESS_KEYS)) { | 5596 isolate->ReportFailedAccessCheck(object, v8::ACCESS_KEYS); |
| 5596 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_KEYS); | |
| 5597 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | 5597 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 5598 return isolate->factory()->false_value(); | 5598 return isolate->factory()->false_value(); |
| 5599 } | 5599 } |
| 5600 | 5600 |
| 5601 if (object->IsJSGlobalProxy()) { | 5601 if (object->IsJSGlobalProxy()) { |
| 5602 Handle<Object> proto(object->GetPrototype(), isolate); | 5602 Handle<Object> proto(object->GetPrototype(), isolate); |
| 5603 if (proto->IsNull()) return object; | 5603 if (proto->IsNull()) return object; |
| 5604 ASSERT(proto->IsJSGlobalObject()); | 5604 ASSERT(proto->IsJSGlobalObject()); |
| 5605 return Freeze(Handle<JSObject>::cast(proto)); | 5605 return Freeze(Handle<JSObject>::cast(proto)); |
| 5606 } | 5606 } |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6240 accessors->SetComponents(*getter, *setter); | 6240 accessors->SetComponents(*getter, *setter); |
| 6241 accessors->set_access_flags(access_control); | 6241 accessors->set_access_flags(access_control); |
| 6242 | 6242 |
| 6243 SetPropertyCallback(object, name, accessors, attributes); | 6243 SetPropertyCallback(object, name, accessors, attributes); |
| 6244 } | 6244 } |
| 6245 | 6245 |
| 6246 | 6246 |
| 6247 bool JSObject::CanSetCallback(Handle<JSObject> object, Handle<Name> name) { | 6247 bool JSObject::CanSetCallback(Handle<JSObject> object, Handle<Name> name) { |
| 6248 Isolate* isolate = object->GetIsolate(); | 6248 Isolate* isolate = object->GetIsolate(); |
| 6249 ASSERT(!object->IsAccessCheckNeeded() || | 6249 ASSERT(!object->IsAccessCheckNeeded() || |
| 6250 isolate->MayNamedAccessWrapper(object, name, v8::ACCESS_SET)); | 6250 isolate->MayNamedAccess(object, name, v8::ACCESS_SET)); |
| 6251 | 6251 |
| 6252 // Check if there is an API defined callback object which prohibits | 6252 // Check if there is an API defined callback object which prohibits |
| 6253 // callback overwriting in this object or its prototype chain. | 6253 // callback overwriting in this object or its prototype chain. |
| 6254 // This mechanism is needed for instance in a browser setting, where | 6254 // This mechanism is needed for instance in a browser setting, where |
| 6255 // certain accessors such as window.location should not be allowed | 6255 // certain accessors such as window.location should not be allowed |
| 6256 // to be overwritten because allowing overwriting could potentially | 6256 // to be overwritten because allowing overwriting could potentially |
| 6257 // cause security problems. | 6257 // cause security problems. |
| 6258 LookupResult callback_result(isolate); | 6258 LookupResult callback_result(isolate); |
| 6259 object->LookupCallbackProperty(*name, &callback_result); | 6259 object->LookupCallbackProperty(*name, &callback_result); |
| 6260 if (callback_result.IsFound()) { | 6260 if (callback_result.IsFound()) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6363 | 6363 |
| 6364 void JSObject::DefineAccessor(Handle<JSObject> object, | 6364 void JSObject::DefineAccessor(Handle<JSObject> object, |
| 6365 Handle<Name> name, | 6365 Handle<Name> name, |
| 6366 Handle<Object> getter, | 6366 Handle<Object> getter, |
| 6367 Handle<Object> setter, | 6367 Handle<Object> setter, |
| 6368 PropertyAttributes attributes, | 6368 PropertyAttributes attributes, |
| 6369 v8::AccessControl access_control) { | 6369 v8::AccessControl access_control) { |
| 6370 Isolate* isolate = object->GetIsolate(); | 6370 Isolate* isolate = object->GetIsolate(); |
| 6371 // Check access rights if needed. | 6371 // Check access rights if needed. |
| 6372 if (object->IsAccessCheckNeeded() && | 6372 if (object->IsAccessCheckNeeded() && |
| 6373 !isolate->MayNamedAccessWrapper(object, name, v8::ACCESS_SET)) { | 6373 !isolate->MayNamedAccess(object, name, v8::ACCESS_SET)) { |
| 6374 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_SET); | 6374 isolate->ReportFailedAccessCheck(object, v8::ACCESS_SET); |
| 6375 // TODO(yangguo): Issue 3269, check for scheduled exception missing? |
| 6375 return; | 6376 return; |
| 6376 } | 6377 } |
| 6377 | 6378 |
| 6378 if (object->IsJSGlobalProxy()) { | 6379 if (object->IsJSGlobalProxy()) { |
| 6379 Handle<Object> proto(object->GetPrototype(), isolate); | 6380 Handle<Object> proto(object->GetPrototype(), isolate); |
| 6380 if (proto->IsNull()) return; | 6381 if (proto->IsNull()) return; |
| 6381 ASSERT(proto->IsJSGlobalObject()); | 6382 ASSERT(proto->IsJSGlobalObject()); |
| 6382 DefineAccessor(Handle<JSObject>::cast(proto), | 6383 DefineAccessor(Handle<JSObject>::cast(proto), |
| 6383 name, | 6384 name, |
| 6384 getter, | 6385 getter, |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6547 | 6548 |
| 6548 | 6549 |
| 6549 Handle<Object> JSObject::SetAccessor(Handle<JSObject> object, | 6550 Handle<Object> JSObject::SetAccessor(Handle<JSObject> object, |
| 6550 Handle<AccessorInfo> info) { | 6551 Handle<AccessorInfo> info) { |
| 6551 Isolate* isolate = object->GetIsolate(); | 6552 Isolate* isolate = object->GetIsolate(); |
| 6552 Factory* factory = isolate->factory(); | 6553 Factory* factory = isolate->factory(); |
| 6553 Handle<Name> name(Name::cast(info->name())); | 6554 Handle<Name> name(Name::cast(info->name())); |
| 6554 | 6555 |
| 6555 // Check access rights if needed. | 6556 // Check access rights if needed. |
| 6556 if (object->IsAccessCheckNeeded() && | 6557 if (object->IsAccessCheckNeeded() && |
| 6557 !isolate->MayNamedAccessWrapper(object, name, v8::ACCESS_SET)) { | 6558 !isolate->MayNamedAccess(object, name, v8::ACCESS_SET)) { |
| 6558 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_SET); | 6559 isolate->ReportFailedAccessCheck(object, v8::ACCESS_SET); |
| 6559 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 6560 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 6560 return factory->undefined_value(); | 6561 return factory->undefined_value(); |
| 6561 } | 6562 } |
| 6562 | 6563 |
| 6563 if (object->IsJSGlobalProxy()) { | 6564 if (object->IsJSGlobalProxy()) { |
| 6564 Handle<Object> proto(object->GetPrototype(), isolate); | 6565 Handle<Object> proto(object->GetPrototype(), isolate); |
| 6565 if (proto->IsNull()) return object; | 6566 if (proto->IsNull()) return object; |
| 6566 ASSERT(proto->IsJSGlobalObject()); | 6567 ASSERT(proto->IsJSGlobalObject()); |
| 6567 return SetAccessor(Handle<JSObject>::cast(proto), info); | 6568 return SetAccessor(Handle<JSObject>::cast(proto), info); |
| 6568 } | 6569 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6633 Handle<Name> name, | 6634 Handle<Name> name, |
| 6634 AccessorComponent component) { | 6635 AccessorComponent component) { |
| 6635 Isolate* isolate = object->GetIsolate(); | 6636 Isolate* isolate = object->GetIsolate(); |
| 6636 | 6637 |
| 6637 // Make sure that the top context does not change when doing callbacks or | 6638 // Make sure that the top context does not change when doing callbacks or |
| 6638 // interceptor calls. | 6639 // interceptor calls. |
| 6639 AssertNoContextChange ncc(isolate); | 6640 AssertNoContextChange ncc(isolate); |
| 6640 | 6641 |
| 6641 // Check access rights if needed. | 6642 // Check access rights if needed. |
| 6642 if (object->IsAccessCheckNeeded() && | 6643 if (object->IsAccessCheckNeeded() && |
| 6643 !isolate->MayNamedAccessWrapper(object, name, v8::ACCESS_HAS)) { | 6644 !isolate->MayNamedAccess(object, name, v8::ACCESS_HAS)) { |
| 6644 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_HAS); | 6645 isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS); |
| 6645 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); | 6646 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 6646 return isolate->factory()->undefined_value(); | 6647 return isolate->factory()->undefined_value(); |
| 6647 } | 6648 } |
| 6648 | 6649 |
| 6649 // Make the lookup and include prototypes. | 6650 // Make the lookup and include prototypes. |
| 6650 uint32_t index = 0; | 6651 uint32_t index = 0; |
| 6651 if (name->AsArrayIndex(&index)) { | 6652 if (name->AsArrayIndex(&index)) { |
| 6652 for (Handle<Object> obj = object; | 6653 for (Handle<Object> obj = object; |
| 6653 !obj->IsNull(); | 6654 !obj->IsNull(); |
| 6654 obj = handle(JSReceiver::cast(*obj)->GetPrototype(), isolate)) { | 6655 obj = handle(JSReceiver::cast(*obj)->GetPrototype(), isolate)) { |
| (...skipping 5847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12502 object->HasFixedTypedArrayElements()) { | 12503 object->HasFixedTypedArrayElements()) { |
| 12503 if (!value->IsNumber() && !value->IsUndefined()) { | 12504 if (!value->IsNumber() && !value->IsUndefined()) { |
| 12504 ASSIGN_RETURN_ON_EXCEPTION( | 12505 ASSIGN_RETURN_ON_EXCEPTION( |
| 12505 isolate, value, | 12506 isolate, value, |
| 12506 Execution::ToNumber(isolate, value), Object); | 12507 Execution::ToNumber(isolate, value), Object); |
| 12507 } | 12508 } |
| 12508 } | 12509 } |
| 12509 | 12510 |
| 12510 // Check access rights if needed. | 12511 // Check access rights if needed. |
| 12511 if (object->IsAccessCheckNeeded()) { | 12512 if (object->IsAccessCheckNeeded()) { |
| 12512 if (!isolate->MayIndexedAccessWrapper(object, index, v8::ACCESS_SET)) { | 12513 if (!isolate->MayIndexedAccess(object, index, v8::ACCESS_SET)) { |
| 12513 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_SET); | 12514 isolate->ReportFailedAccessCheck(object, v8::ACCESS_SET); |
| 12514 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | 12515 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 12515 return value; | 12516 return value; |
| 12516 } | 12517 } |
| 12517 } | 12518 } |
| 12518 | 12519 |
| 12519 if (object->IsJSGlobalProxy()) { | 12520 if (object->IsJSGlobalProxy()) { |
| 12520 Handle<Object> proto(object->GetPrototype(), isolate); | 12521 Handle<Object> proto(object->GetPrototype(), isolate); |
| 12521 if (proto->IsNull()) return value; | 12522 if (proto->IsNull()) return value; |
| 12522 ASSERT(proto->IsJSGlobalObject()); | 12523 ASSERT(proto->IsJSGlobalObject()); |
| 12523 return SetElement(Handle<JSObject>::cast(proto), index, value, attributes, | 12524 return SetElement(Handle<JSObject>::cast(proto), index, value, attributes, |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13281 return GetPropertyPostInterceptor(object, receiver, name, attributes); | 13282 return GetPropertyPostInterceptor(object, receiver, name, attributes); |
| 13282 } | 13283 } |
| 13283 | 13284 |
| 13284 | 13285 |
| 13285 bool JSObject::HasRealNamedProperty(Handle<JSObject> object, | 13286 bool JSObject::HasRealNamedProperty(Handle<JSObject> object, |
| 13286 Handle<Name> key) { | 13287 Handle<Name> key) { |
| 13287 Isolate* isolate = object->GetIsolate(); | 13288 Isolate* isolate = object->GetIsolate(); |
| 13288 SealHandleScope shs(isolate); | 13289 SealHandleScope shs(isolate); |
| 13289 // Check access rights if needed. | 13290 // Check access rights if needed. |
| 13290 if (object->IsAccessCheckNeeded()) { | 13291 if (object->IsAccessCheckNeeded()) { |
| 13291 if (!isolate->MayNamedAccessWrapper(object, key, v8::ACCESS_HAS)) { | 13292 if (!isolate->MayNamedAccess(object, key, v8::ACCESS_HAS)) { |
| 13292 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_HAS); | 13293 isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS); |
| 13294 // TODO(yangguo): Issue 3269, check for scheduled exception missing? |
| 13293 return false; | 13295 return false; |
| 13294 } | 13296 } |
| 13295 } | 13297 } |
| 13296 | 13298 |
| 13297 LookupResult result(isolate); | 13299 LookupResult result(isolate); |
| 13298 object->LocalLookupRealNamedProperty(*key, &result); | 13300 object->LocalLookupRealNamedProperty(*key, &result); |
| 13299 return result.IsFound() && !result.IsInterceptor(); | 13301 return result.IsFound() && !result.IsInterceptor(); |
| 13300 } | 13302 } |
| 13301 | 13303 |
| 13302 | 13304 |
| 13303 bool JSObject::HasRealElementProperty(Handle<JSObject> object, uint32_t index) { | 13305 bool JSObject::HasRealElementProperty(Handle<JSObject> object, uint32_t index) { |
| 13304 Isolate* isolate = object->GetIsolate(); | 13306 Isolate* isolate = object->GetIsolate(); |
| 13305 HandleScope scope(isolate); | 13307 HandleScope scope(isolate); |
| 13306 // Check access rights if needed. | 13308 // Check access rights if needed. |
| 13307 if (object->IsAccessCheckNeeded()) { | 13309 if (object->IsAccessCheckNeeded()) { |
| 13308 if (!isolate->MayIndexedAccessWrapper(object, index, v8::ACCESS_HAS)) { | 13310 if (!isolate->MayIndexedAccess(object, index, v8::ACCESS_HAS)) { |
| 13309 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_HAS); | 13311 isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS); |
| 13312 // TODO(yangguo): Issue 3269, check for scheduled exception missing? |
| 13310 return false; | 13313 return false; |
| 13311 } | 13314 } |
| 13312 } | 13315 } |
| 13313 | 13316 |
| 13314 if (object->IsJSGlobalProxy()) { | 13317 if (object->IsJSGlobalProxy()) { |
| 13315 HandleScope scope(isolate); | 13318 HandleScope scope(isolate); |
| 13316 Handle<Object> proto(object->GetPrototype(), isolate); | 13319 Handle<Object> proto(object->GetPrototype(), isolate); |
| 13317 if (proto->IsNull()) return false; | 13320 if (proto->IsNull()) return false; |
| 13318 ASSERT(proto->IsJSGlobalObject()); | 13321 ASSERT(proto->IsJSGlobalObject()); |
| 13319 return HasRealElementProperty(Handle<JSObject>::cast(proto), index); | 13322 return HasRealElementProperty(Handle<JSObject>::cast(proto), index); |
| 13320 } | 13323 } |
| 13321 | 13324 |
| 13322 return GetElementAttributeWithoutInterceptor( | 13325 return GetElementAttributeWithoutInterceptor( |
| 13323 object, object, index, false) != ABSENT; | 13326 object, object, index, false) != ABSENT; |
| 13324 } | 13327 } |
| 13325 | 13328 |
| 13326 | 13329 |
| 13327 bool JSObject::HasRealNamedCallbackProperty(Handle<JSObject> object, | 13330 bool JSObject::HasRealNamedCallbackProperty(Handle<JSObject> object, |
| 13328 Handle<Name> key) { | 13331 Handle<Name> key) { |
| 13329 Isolate* isolate = object->GetIsolate(); | 13332 Isolate* isolate = object->GetIsolate(); |
| 13330 SealHandleScope shs(isolate); | 13333 SealHandleScope shs(isolate); |
| 13331 // Check access rights if needed. | 13334 // Check access rights if needed. |
| 13332 if (object->IsAccessCheckNeeded()) { | 13335 if (object->IsAccessCheckNeeded()) { |
| 13333 if (!isolate->MayNamedAccessWrapper(object, key, v8::ACCESS_HAS)) { | 13336 if (!isolate->MayNamedAccess(object, key, v8::ACCESS_HAS)) { |
| 13334 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_HAS); | 13337 isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS); |
| 13338 // TODO(yangguo): Issue 3269, check for scheduled exception missing? |
| 13335 return false; | 13339 return false; |
| 13336 } | 13340 } |
| 13337 } | 13341 } |
| 13338 | 13342 |
| 13339 LookupResult result(isolate); | 13343 LookupResult result(isolate); |
| 13340 object->LocalLookupRealNamedProperty(*key, &result); | 13344 object->LocalLookupRealNamedProperty(*key, &result); |
| 13341 return result.IsPropertyCallbacks(); | 13345 return result.IsPropertyCallbacks(); |
| 13342 } | 13346 } |
| 13343 | 13347 |
| 13344 | 13348 |
| (...skipping 3134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16479 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16483 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16480 static const char* error_messages_[] = { | 16484 static const char* error_messages_[] = { |
| 16481 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16485 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16482 }; | 16486 }; |
| 16483 #undef ERROR_MESSAGES_TEXTS | 16487 #undef ERROR_MESSAGES_TEXTS |
| 16484 return error_messages_[reason]; | 16488 return error_messages_[reason]; |
| 16485 } | 16489 } |
| 16486 | 16490 |
| 16487 | 16491 |
| 16488 } } // namespace v8::internal | 16492 } } // namespace v8::internal |
| OLD | NEW |