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

Side by Side Diff: src/objects.cc

Issue 25732002: Handlify GetPropertyWithFailedAccessCheck. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 7 years, 2 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') | no next file » | 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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 499
500 bool has_pending_exception; 500 bool has_pending_exception;
501 Handle<Object> result = Execution::Call( 501 Handle<Object> result = Execution::Call(
502 isolate, fun, self, 0, NULL, &has_pending_exception, true); 502 isolate, fun, self, 0, NULL, &has_pending_exception, true);
503 // Check for pending exception and return the result. 503 // Check for pending exception and return the result.
504 if (has_pending_exception) return Failure::Exception(); 504 if (has_pending_exception) return Failure::Exception();
505 return *result; 505 return *result;
506 } 506 }
507 507
508 508
509 // TODO(yangguo): this should eventually replace the non-handlified version.
510 Handle<Object> JSObject::GetPropertyWithCallback(Handle<JSObject> object,
511 Handle<Object> receiver,
512 Handle<Object> structure,
513 Handle<Name> name) {
514 CALL_HEAP_FUNCTION(object->GetIsolate(),
515 object->GetPropertyWithCallback(*receiver,
516 *structure,
517 *name),
518 Object);
519 }
520
521
509 // Only deal with CALLBACKS and INTERCEPTOR 522 // Only deal with CALLBACKS and INTERCEPTOR
510 MaybeObject* JSObject::GetPropertyWithFailedAccessCheck( 523 Handle<Object> JSObject::GetPropertyWithFailedAccessCheck(
511 Object* receiver, 524 Handle<JSObject> object,
525 Handle<Object> receiver,
512 LookupResult* result, 526 LookupResult* result,
513 Name* name, 527 Handle<Name> name,
514 PropertyAttributes* attributes) { 528 PropertyAttributes* attributes) {
529 Isolate* isolate = name->GetIsolate();
515 if (result->IsProperty()) { 530 if (result->IsProperty()) {
516 switch (result->type()) { 531 switch (result->type()) {
517 case CALLBACKS: { 532 case CALLBACKS: {
518 // Only allow API accessors. 533 // Only allow API accessors.
519 Object* obj = result->GetCallbackObject(); 534 Handle<Object> callback_obj(result->GetCallbackObject(), isolate);
520 if (obj->IsAccessorInfo()) { 535 if (callback_obj->IsAccessorInfo()) {
521 AccessorInfo* info = AccessorInfo::cast(obj); 536 if (!AccessorInfo::cast(*callback_obj)->all_can_read()) break;
522 if (info->all_can_read()) { 537 *attributes = result->GetAttributes();
523 *attributes = result->GetAttributes(); 538 // Fall through to GetPropertyWithCallback.
524 return result->holder()->GetPropertyWithCallback( 539 } else if (callback_obj->IsAccessorPair()) {
525 receiver, result->GetCallbackObject(), name); 540 if (!AccessorPair::cast(*callback_obj)->all_can_read()) break;
526 } 541 // Fall through to GetPropertyWithCallback.
527 } else if (obj->IsAccessorPair()) { 542 } else {
528 AccessorPair* pair = AccessorPair::cast(obj); 543 break;
529 if (pair->all_can_read()) {
530 return result->holder()->GetPropertyWithCallback(
531 receiver, result->GetCallbackObject(), name);
532 }
533 } 544 }
534 break; 545 Handle<JSObject> holder(result->holder(), isolate);
546 return GetPropertyWithCallback(holder, receiver, callback_obj, name);
535 } 547 }
536 case NORMAL: 548 case NORMAL:
537 case FIELD: 549 case FIELD:
538 case CONSTANT: { 550 case CONSTANT: {
539 // Search ALL_CAN_READ accessors in prototype chain. 551 // Search ALL_CAN_READ accessors in prototype chain.
540 LookupResult r(GetIsolate()); 552 LookupResult r(isolate);
541 result->holder()->LookupRealNamedPropertyInPrototypes(name, &r); 553 result->holder()->LookupRealNamedPropertyInPrototypes(*name, &r);
542 if (r.IsProperty()) { 554 if (r.IsProperty()) {
543 return GetPropertyWithFailedAccessCheck(receiver, 555 return GetPropertyWithFailedAccessCheck(
544 &r, 556 object, receiver, &r, name, attributes);
545 name,
546 attributes);
547 } 557 }
548 break; 558 break;
549 } 559 }
550 case INTERCEPTOR: { 560 case INTERCEPTOR: {
551 // If the object has an interceptor, try real named properties. 561 // If the object has an interceptor, try real named properties.
552 // No access check in GetPropertyAttributeWithInterceptor. 562 // No access check in GetPropertyAttributeWithInterceptor.
553 LookupResult r(GetIsolate()); 563 LookupResult r(isolate);
554 result->holder()->LookupRealNamedProperty(name, &r); 564 result->holder()->LookupRealNamedProperty(*name, &r);
555 if (r.IsProperty()) { 565 if (r.IsProperty()) {
556 return GetPropertyWithFailedAccessCheck(receiver, 566 return GetPropertyWithFailedAccessCheck(
557 &r, 567 object, receiver, &r, name, attributes);
558 name,
559 attributes);
560 } 568 }
561 break; 569 break;
562 } 570 }
563 default: 571 default:
564 UNREACHABLE(); 572 UNREACHABLE();
565 } 573 }
566 } 574 }
567 575
568 // No accessible property found. 576 // No accessible property found.
569 *attributes = ABSENT; 577 *attributes = ABSENT;
570 Heap* heap = name->GetHeap(); 578 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_GET);
571 Isolate* isolate = heap->isolate(); 579 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
572 isolate->ReportFailedAccessCheck(this, v8::ACCESS_GET); 580 return isolate->factory()->undefined_value();
573 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
574 return heap->undefined_value();
575 } 581 }
576 582
577 583
578 PropertyAttributes JSObject::GetPropertyAttributeWithFailedAccessCheck( 584 PropertyAttributes JSObject::GetPropertyAttributeWithFailedAccessCheck(
579 Object* receiver, 585 Object* receiver,
580 LookupResult* result, 586 LookupResult* result,
581 Name* name, 587 Name* name,
582 bool continue_search) { 588 bool continue_search) {
583 if (result->IsProperty()) { 589 if (result->IsProperty()) {
584 switch (result->type()) { 590 switch (result->type()) {
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 ASSERT(this != this->GetPrototype(isolate)); 855 ASSERT(this != this->GetPrototype(isolate));
850 for (Object* current = this; 856 for (Object* current = this;
851 true; 857 true;
852 current = current->GetPrototype(isolate)) { 858 current = current->GetPrototype(isolate)) {
853 if (current->IsAccessCheckNeeded()) { 859 if (current->IsAccessCheckNeeded()) {
854 // Check if we're allowed to read from the current object. Note 860 // Check if we're allowed to read from the current object. Note
855 // that even though we may not actually end up loading the named 861 // that even though we may not actually end up loading the named
856 // property from the current object, we still check that we have 862 // property from the current object, we still check that we have
857 // access to it. 863 // access to it.
858 JSObject* checked = JSObject::cast(current); 864 JSObject* checked = JSObject::cast(current);
859 if (!heap->isolate()->MayNamedAccess(checked, name, v8::ACCESS_GET)) { 865 if (!isolate->MayNamedAccess(checked, name, v8::ACCESS_GET)) {
860 return checked->GetPropertyWithFailedAccessCheck(receiver, 866 HandleScope scope(isolate);
861 result, 867 Handle<Object> value = JSObject::GetPropertyWithFailedAccessCheck(
862 name, 868 handle(checked, isolate),
863 attributes); 869 handle(receiver, isolate),
870 result,
871 handle(name, isolate),
872 attributes);
873 RETURN_IF_EMPTY_HANDLE(isolate, value);
874 return *value;
864 } 875 }
865 } 876 }
866 // Stop traversing the chain once we reach the last object in the 877 // Stop traversing the chain once we reach the last object in the
867 // chain; either the holder of the result or null in case of an 878 // chain; either the holder of the result or null in case of an
868 // absent property. 879 // absent property.
869 if (current == last) break; 880 if (current == last) break;
870 } 881 }
871 } 882 }
872 883
873 if (!result->IsProperty()) { 884 if (!result->IsProperty()) {
(...skipping 15369 matching lines...) Expand 10 before | Expand all | Expand 10 after
16243 #define ERROR_MESSAGES_TEXTS(C, T) T, 16254 #define ERROR_MESSAGES_TEXTS(C, T) T,
16244 static const char* error_messages_[] = { 16255 static const char* error_messages_[] = {
16245 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16256 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16246 }; 16257 };
16247 #undef ERROR_MESSAGES_TEXTS 16258 #undef ERROR_MESSAGES_TEXTS
16248 return error_messages_[reason]; 16259 return error_messages_[reason];
16249 } 16260 }
16250 16261
16251 16262
16252 } } // namespace v8::internal 16263 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698