Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(737)

Side by Side Diff: src/objects.cc

Issue 18298012: Check for scheduled exceptions after a failed-access-check callback. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comment Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 break; 544 break;
545 } 545 }
546 default: 546 default:
547 UNREACHABLE(); 547 UNREACHABLE();
548 } 548 }
549 } 549 }
550 550
551 // No accessible property found. 551 // No accessible property found.
552 *attributes = ABSENT; 552 *attributes = ABSENT;
553 Heap* heap = name->GetHeap(); 553 Heap* heap = name->GetHeap();
554 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_GET); 554 Isolate* isolate = heap->isolate();
555 isolate->ReportFailedAccessCheck(this, v8::ACCESS_GET);
556 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
555 return heap->undefined_value(); 557 return heap->undefined_value();
556 } 558 }
557 559
558 560
559 PropertyAttributes JSObject::GetPropertyAttributeWithFailedAccessCheck( 561 PropertyAttributes JSObject::GetPropertyAttributeWithFailedAccessCheck(
560 Object* receiver, 562 Object* receiver,
561 LookupResult* result, 563 LookupResult* result,
562 Name* name, 564 Name* name,
563 bool continue_search) { 565 bool continue_search) {
564 if (result->IsProperty()) { 566 if (result->IsProperty()) {
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 // Inline the case for JSObjects. Doing so significantly improves the 920 // Inline the case for JSObjects. Doing so significantly improves the
919 // performance of fetching elements where checking the prototype chain is 921 // performance of fetching elements where checking the prototype chain is
920 // necessary. 922 // necessary.
921 JSObject* js_object = JSObject::cast(holder); 923 JSObject* js_object = JSObject::cast(holder);
922 924
923 // Check access rights if needed. 925 // Check access rights if needed.
924 if (js_object->IsAccessCheckNeeded()) { 926 if (js_object->IsAccessCheckNeeded()) {
925 Isolate* isolate = heap->isolate(); 927 Isolate* isolate = heap->isolate();
926 if (!isolate->MayIndexedAccess(js_object, index, v8::ACCESS_GET)) { 928 if (!isolate->MayIndexedAccess(js_object, index, v8::ACCESS_GET)) {
927 isolate->ReportFailedAccessCheck(js_object, v8::ACCESS_GET); 929 isolate->ReportFailedAccessCheck(js_object, v8::ACCESS_GET);
930 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
928 return heap->undefined_value(); 931 return heap->undefined_value();
929 } 932 }
930 } 933 }
931 934
932 if (js_object->HasIndexedInterceptor()) { 935 if (js_object->HasIndexedInterceptor()) {
933 return js_object->GetElementWithInterceptor(receiver, index); 936 return js_object->GetElementWithInterceptor(receiver, index);
934 } 937 }
935 938
936 if (js_object->elements() != heap->empty_fixed_array()) { 939 if (js_object->elements() != heap->empty_fixed_array()) {
937 MaybeObject* result = js_object->GetElementsAccessor()->Get( 940 MaybeObject* result = js_object->GetElementsAccessor()->Get(
(...skipping 2419 matching lines...) Expand 10 before | Expand all | Expand 10 after
3357 break; 3360 break;
3358 } 3361 }
3359 } 3362 }
3360 } 3363 }
3361 } 3364 }
3362 3365
3363 Isolate* isolate = GetIsolate(); 3366 Isolate* isolate = GetIsolate();
3364 HandleScope scope(isolate); 3367 HandleScope scope(isolate);
3365 Handle<Object> value_handle(value, isolate); 3368 Handle<Object> value_handle(value, isolate);
3366 isolate->ReportFailedAccessCheck(this, v8::ACCESS_SET); 3369 isolate->ReportFailedAccessCheck(this, v8::ACCESS_SET);
3370 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
3367 return *value_handle; 3371 return *value_handle;
3368 } 3372 }
3369 3373
3370 3374
3371 MaybeObject* JSReceiver::SetProperty(LookupResult* result, 3375 MaybeObject* JSReceiver::SetProperty(LookupResult* result,
3372 Name* key, 3376 Name* key,
3373 Object* value, 3377 Object* value,
3374 PropertyAttributes attributes, 3378 PropertyAttributes attributes,
3375 StrictModeFlag strict_mode, 3379 StrictModeFlag strict_mode,
3376 JSReceiver::StoreFromKeyed store_mode) { 3380 JSReceiver::StoreFromKeyed store_mode) {
(...skipping 1675 matching lines...) Expand 10 before | Expand all | Expand 10 after
5052 Object); 5056 Object);
5053 } 5057 }
5054 5058
5055 5059
5056 MaybeObject* JSObject::DeleteElement(uint32_t index, DeleteMode mode) { 5060 MaybeObject* JSObject::DeleteElement(uint32_t index, DeleteMode mode) {
5057 Isolate* isolate = GetIsolate(); 5061 Isolate* isolate = GetIsolate();
5058 // Check access rights if needed. 5062 // Check access rights if needed.
5059 if (IsAccessCheckNeeded() && 5063 if (IsAccessCheckNeeded() &&
5060 !isolate->MayIndexedAccess(this, index, v8::ACCESS_DELETE)) { 5064 !isolate->MayIndexedAccess(this, index, v8::ACCESS_DELETE)) {
5061 isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE); 5065 isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
5066 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
5062 return isolate->heap()->false_value(); 5067 return isolate->heap()->false_value();
5063 } 5068 }
5064 5069
5065 if (IsStringObjectWithCharacterAt(index)) { 5070 if (IsStringObjectWithCharacterAt(index)) {
5066 if (mode == STRICT_DELETION) { 5071 if (mode == STRICT_DELETION) {
5067 // Deleting a non-configurable property in strict mode. 5072 // Deleting a non-configurable property in strict mode.
5068 HandleScope scope(isolate); 5073 HandleScope scope(isolate);
5069 Handle<Object> holder(this, isolate); 5074 Handle<Object> holder(this, isolate);
5070 Handle<Object> name = isolate->factory()->NewNumberFromUint(index); 5075 Handle<Object> name = isolate->factory()->NewNumberFromUint(index);
5071 Handle<Object> args[2] = { name, holder }; 5076 Handle<Object> args[2] = { name, holder };
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
5129 5134
5130 MaybeObject* JSObject::DeleteProperty(Name* name, DeleteMode mode) { 5135 MaybeObject* JSObject::DeleteProperty(Name* name, DeleteMode mode) {
5131 Isolate* isolate = GetIsolate(); 5136 Isolate* isolate = GetIsolate();
5132 // ECMA-262, 3rd, 8.6.2.5 5137 // ECMA-262, 3rd, 8.6.2.5
5133 ASSERT(name->IsName()); 5138 ASSERT(name->IsName());
5134 5139
5135 // Check access rights if needed. 5140 // Check access rights if needed.
5136 if (IsAccessCheckNeeded() && 5141 if (IsAccessCheckNeeded() &&
5137 !isolate->MayNamedAccess(this, name, v8::ACCESS_DELETE)) { 5142 !isolate->MayNamedAccess(this, name, v8::ACCESS_DELETE)) {
5138 isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE); 5143 isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
5144 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
5139 return isolate->heap()->false_value(); 5145 return isolate->heap()->false_value();
5140 } 5146 }
5141 5147
5142 if (IsJSGlobalProxy()) { 5148 if (IsJSGlobalProxy()) {
5143 Object* proto = GetPrototype(); 5149 Object* proto = GetPrototype();
5144 if (proto->IsNull()) return isolate->heap()->false_value(); 5150 if (proto->IsNull()) return isolate->heap()->false_value();
5145 ASSERT(proto->IsJSGlobalObject()); 5151 ASSERT(proto->IsJSGlobalObject());
5146 return JSGlobalObject::cast(proto)->DeleteProperty(name, mode); 5152 return JSGlobalObject::cast(proto)->DeleteProperty(name, mode);
5147 } 5153 }
5148 5154
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
5359 } 5365 }
5360 5366
5361 5367
5362 MaybeObject* JSObject::PreventExtensions() { 5368 MaybeObject* JSObject::PreventExtensions() {
5363 Isolate* isolate = GetIsolate(); 5369 Isolate* isolate = GetIsolate();
5364 if (IsAccessCheckNeeded() && 5370 if (IsAccessCheckNeeded() &&
5365 !isolate->MayNamedAccess(this, 5371 !isolate->MayNamedAccess(this,
5366 isolate->heap()->undefined_value(), 5372 isolate->heap()->undefined_value(),
5367 v8::ACCESS_KEYS)) { 5373 v8::ACCESS_KEYS)) {
5368 isolate->ReportFailedAccessCheck(this, v8::ACCESS_KEYS); 5374 isolate->ReportFailedAccessCheck(this, v8::ACCESS_KEYS);
5375 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
5369 return isolate->heap()->false_value(); 5376 return isolate->heap()->false_value();
5370 } 5377 }
5371 5378
5372 if (IsJSGlobalProxy()) { 5379 if (IsJSGlobalProxy()) {
5373 Object* proto = GetPrototype(); 5380 Object* proto = GetPrototype();
5374 if (proto->IsNull()) return this; 5381 if (proto->IsNull()) return this;
5375 ASSERT(proto->IsJSGlobalObject()); 5382 ASSERT(proto->IsJSGlobalObject());
5376 return JSObject::cast(proto)->PreventExtensions(); 5383 return JSObject::cast(proto)->PreventExtensions();
5377 } 5384 }
5378 5385
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
5437 5444
5438 Heap* heap = isolate->heap(); 5445 Heap* heap = isolate->heap();
5439 5446
5440 if (map()->is_frozen()) return this; 5447 if (map()->is_frozen()) return this;
5441 5448
5442 if (IsAccessCheckNeeded() && 5449 if (IsAccessCheckNeeded() &&
5443 !isolate->MayNamedAccess(this, 5450 !isolate->MayNamedAccess(this,
5444 heap->undefined_value(), 5451 heap->undefined_value(),
5445 v8::ACCESS_KEYS)) { 5452 v8::ACCESS_KEYS)) {
5446 isolate->ReportFailedAccessCheck(this, v8::ACCESS_KEYS); 5453 isolate->ReportFailedAccessCheck(this, v8::ACCESS_KEYS);
5454 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
5447 return heap->false_value(); 5455 return heap->false_value();
5448 } 5456 }
5449 5457
5450 if (IsJSGlobalProxy()) { 5458 if (IsJSGlobalProxy()) {
5451 Object* proto = GetPrototype(); 5459 Object* proto = GetPrototype();
5452 if (proto->IsNull()) return this; 5460 if (proto->IsNull()) return this;
5453 ASSERT(proto->IsJSGlobalObject()); 5461 ASSERT(proto->IsJSGlobalObject());
5454 return JSObject::cast(proto)->Freeze(isolate); 5462 return JSObject::cast(proto)->Freeze(isolate);
5455 } 5463 }
5456 5464
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
6250 } 6258 }
6251 6259
6252 6260
6253 MaybeObject* JSObject::DefineAccessor(AccessorInfo* info) { 6261 MaybeObject* JSObject::DefineAccessor(AccessorInfo* info) {
6254 Isolate* isolate = GetIsolate(); 6262 Isolate* isolate = GetIsolate();
6255 Name* name = Name::cast(info->name()); 6263 Name* name = Name::cast(info->name());
6256 // Check access rights if needed. 6264 // Check access rights if needed.
6257 if (IsAccessCheckNeeded() && 6265 if (IsAccessCheckNeeded() &&
6258 !isolate->MayNamedAccess(this, name, v8::ACCESS_SET)) { 6266 !isolate->MayNamedAccess(this, name, v8::ACCESS_SET)) {
6259 isolate->ReportFailedAccessCheck(this, v8::ACCESS_SET); 6267 isolate->ReportFailedAccessCheck(this, v8::ACCESS_SET);
6268 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
6260 return isolate->heap()->undefined_value(); 6269 return isolate->heap()->undefined_value();
6261 } 6270 }
6262 6271
6263 if (IsJSGlobalProxy()) { 6272 if (IsJSGlobalProxy()) {
6264 Object* proto = GetPrototype(); 6273 Object* proto = GetPrototype();
6265 if (proto->IsNull()) return this; 6274 if (proto->IsNull()) return this;
6266 ASSERT(proto->IsJSGlobalObject()); 6275 ASSERT(proto->IsJSGlobalObject());
6267 return JSObject::cast(proto)->DefineAccessor(info); 6276 return JSObject::cast(proto)->DefineAccessor(info);
6268 } 6277 }
6269 6278
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
6325 6334
6326 MaybeObject* maybe_ok = 6335 MaybeObject* maybe_ok =
6327 SetPropertyCallback(name, info, info->property_attributes()); 6336 SetPropertyCallback(name, info, info->property_attributes());
6328 if (maybe_ok->IsFailure()) return maybe_ok; 6337 if (maybe_ok->IsFailure()) return maybe_ok;
6329 } 6338 }
6330 6339
6331 return this; 6340 return this;
6332 } 6341 }
6333 6342
6334 6343
6335 Object* JSObject::LookupAccessor(Name* name, AccessorComponent component) { 6344 MaybeObject* JSObject::LookupAccessor(Name* name, AccessorComponent component) {
6336 Heap* heap = GetHeap(); 6345 Heap* heap = GetHeap();
6337 6346
6338 // Make sure that the top context does not change when doing callbacks or 6347 // Make sure that the top context does not change when doing callbacks or
6339 // interceptor calls. 6348 // interceptor calls.
6340 AssertNoContextChange ncc; 6349 AssertNoContextChange ncc;
6341 6350
6342 // Check access rights if needed. 6351 // Check access rights if needed.
6343 if (IsAccessCheckNeeded() && 6352 if (IsAccessCheckNeeded() &&
6344 !heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_HAS)) { 6353 !heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_HAS)) {
6345 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); 6354 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
6355 RETURN_IF_SCHEDULED_EXCEPTION(heap->isolate());
6346 return heap->undefined_value(); 6356 return heap->undefined_value();
6347 } 6357 }
6348 6358
6349 // Make the lookup and include prototypes. 6359 // Make the lookup and include prototypes.
6350 uint32_t index = 0; 6360 uint32_t index = 0;
6351 if (name->AsArrayIndex(&index)) { 6361 if (name->AsArrayIndex(&index)) {
6352 for (Object* obj = this; 6362 for (Object* obj = this;
6353 obj != heap->null_value(); 6363 obj != heap->null_value();
6354 obj = JSReceiver::cast(obj)->GetPrototype()) { 6364 obj = JSReceiver::cast(obj)->GetPrototype()) {
6355 if (obj->IsJSObject() && JSObject::cast(obj)->HasDictionaryElements()) { 6365 if (obj->IsJSObject() && JSObject::cast(obj)->HasDictionaryElements()) {
(...skipping 5702 matching lines...) Expand 10 before | Expand all | Expand 10 after
12058 PropertyAttributes attributes, 12068 PropertyAttributes attributes,
12059 StrictModeFlag strict_mode, 12069 StrictModeFlag strict_mode,
12060 bool check_prototype, 12070 bool check_prototype,
12061 SetPropertyMode set_mode) { 12071 SetPropertyMode set_mode) {
12062 Isolate* isolate = GetIsolate(); 12072 Isolate* isolate = GetIsolate();
12063 12073
12064 // Check access rights if needed. 12074 // Check access rights if needed.
12065 if (IsAccessCheckNeeded()) { 12075 if (IsAccessCheckNeeded()) {
12066 if (!isolate->MayIndexedAccess(this, index, v8::ACCESS_SET)) { 12076 if (!isolate->MayIndexedAccess(this, index, v8::ACCESS_SET)) {
12067 isolate->ReportFailedAccessCheck(this, v8::ACCESS_SET); 12077 isolate->ReportFailedAccessCheck(this, v8::ACCESS_SET);
12078 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
12068 return value_raw; 12079 return value_raw;
12069 } 12080 }
12070 } 12081 }
12071 12082
12072 if (IsJSGlobalProxy()) { 12083 if (IsJSGlobalProxy()) {
12073 Object* proto = GetPrototype(); 12084 Object* proto = GetPrototype();
12074 if (proto->IsNull()) return value_raw; 12085 if (proto->IsNull()) return value_raw;
12075 ASSERT(proto->IsJSGlobalObject()); 12086 ASSERT(proto->IsJSGlobalObject());
12076 return JSObject::cast(proto)->SetElement(index, 12087 return JSObject::cast(proto)->SetElement(index,
12077 value_raw, 12088 value_raw,
(...skipping 3792 matching lines...) Expand 10 before | Expand all | Expand 10 after
15870 15881
15871 void PropertyCell::AddDependentCode(Handle<Code> code) { 15882 void PropertyCell::AddDependentCode(Handle<Code> code) {
15872 Handle<DependentCode> codes = DependentCode::Insert( 15883 Handle<DependentCode> codes = DependentCode::Insert(
15873 Handle<DependentCode>(dependent_code()), 15884 Handle<DependentCode>(dependent_code()),
15874 DependentCode::kPropertyCellChangedGroup, code); 15885 DependentCode::kPropertyCellChangedGroup, code);
15875 if (*codes != dependent_code()) set_dependent_code(*codes); 15886 if (*codes != dependent_code()) set_dependent_code(*codes);
15876 } 15887 }
15877 15888
15878 15889
15879 } } // namespace v8::internal 15890 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698