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

Side by Side Diff: src/objects.cc

Issue 27518002: Handlify JSObject::HasReal*Property. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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') | 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 6529 matching lines...) Expand 10 before | Expand all | Expand 10 after
6540 !isolate->MayNamedAccess(*object, *name, v8::ACCESS_HAS)) { 6540 !isolate->MayNamedAccess(*object, *name, v8::ACCESS_HAS)) {
6541 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_HAS); 6541 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_HAS);
6542 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); 6542 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
6543 return isolate->factory()->undefined_value(); 6543 return isolate->factory()->undefined_value();
6544 } 6544 }
6545 6545
6546 // Make the lookup and include prototypes. 6546 // Make the lookup and include prototypes.
6547 uint32_t index = 0; 6547 uint32_t index = 0;
6548 if (name->AsArrayIndex(&index)) { 6548 if (name->AsArrayIndex(&index)) {
6549 for (Handle<Object> obj = object; 6549 for (Handle<Object> obj = object;
6550 *obj != isolate->heap()->null_value(); 6550 !obj->IsNull();
6551 obj = handle(JSReceiver::cast(*obj)->GetPrototype(), isolate)) { 6551 obj = handle(JSReceiver::cast(*obj)->GetPrototype(), isolate)) {
6552 if (obj->IsJSObject() && JSObject::cast(*obj)->HasDictionaryElements()) { 6552 if (obj->IsJSObject() && JSObject::cast(*obj)->HasDictionaryElements()) {
6553 JSObject* js_object = JSObject::cast(*obj); 6553 JSObject* js_object = JSObject::cast(*obj);
6554 SeededNumberDictionary* dictionary = js_object->element_dictionary(); 6554 SeededNumberDictionary* dictionary = js_object->element_dictionary();
6555 int entry = dictionary->FindEntry(index); 6555 int entry = dictionary->FindEntry(index);
6556 if (entry != SeededNumberDictionary::kNotFound) { 6556 if (entry != SeededNumberDictionary::kNotFound) {
6557 Object* element = dictionary->ValueAt(entry); 6557 Object* element = dictionary->ValueAt(entry);
6558 if (dictionary->DetailsAt(entry).type() == CALLBACKS && 6558 if (dictionary->DetailsAt(entry).type() == CALLBACKS &&
6559 element->IsAccessorPair()) { 6559 element->IsAccessorPair()) {
6560 return handle(AccessorPair::cast(element)->GetComponent(component), 6560 return handle(AccessorPair::cast(element)->GetComponent(component),
6561 isolate); 6561 isolate);
6562 } 6562 }
6563 } 6563 }
6564 } 6564 }
6565 } 6565 }
6566 } else { 6566 } else {
6567 for (Handle<Object> obj = object; 6567 for (Handle<Object> obj = object;
6568 *obj != isolate->heap()->null_value(); 6568 !obj->IsNull();
6569 obj = handle(JSReceiver::cast(*obj)->GetPrototype(), isolate)) { 6569 obj = handle(JSReceiver::cast(*obj)->GetPrototype(), isolate)) {
6570 LookupResult result(isolate); 6570 LookupResult result(isolate);
6571 JSReceiver::cast(*obj)->LocalLookup(*name, &result); 6571 JSReceiver::cast(*obj)->LocalLookup(*name, &result);
6572 if (result.IsFound()) { 6572 if (result.IsFound()) {
6573 if (result.IsReadOnly()) return isolate->factory()->undefined_value(); 6573 if (result.IsReadOnly()) return isolate->factory()->undefined_value();
6574 if (result.IsPropertyCallbacks()) { 6574 if (result.IsPropertyCallbacks()) {
6575 Object* obj = result.GetCallbackObject(); 6575 Object* obj = result.GetCallbackObject();
6576 if (obj->IsAccessorPair()) { 6576 if (obj->IsAccessorPair()) {
6577 return handle(AccessorPair::cast(obj)->GetComponent(component), 6577 return handle(AccessorPair::cast(obj)->GetComponent(component),
6578 isolate); 6578 isolate);
(...skipping 6581 matching lines...) Expand 10 before | Expand all | Expand 10 after
13160 result_internal->VerifyApiCallResultType(); 13160 result_internal->VerifyApiCallResultType();
13161 // Rebox handle to escape this scope. 13161 // Rebox handle to escape this scope.
13162 return handle(*result_internal, isolate); 13162 return handle(*result_internal, isolate);
13163 } 13163 }
13164 } 13164 }
13165 13165
13166 return GetPropertyPostInterceptor(object, receiver, name, attributes); 13166 return GetPropertyPostInterceptor(object, receiver, name, attributes);
13167 } 13167 }
13168 13168
13169 13169
13170 bool JSObject::HasRealNamedProperty(Isolate* isolate, Name* key) { 13170 bool JSObject::HasRealNamedProperty(Handle<JSObject> object,
13171 Handle<Name> key) {
13172 Isolate* isolate = object->GetIsolate();
13173 SealHandleScope shs(isolate);
13171 // Check access rights if needed. 13174 // Check access rights if needed.
13172 if (IsAccessCheckNeeded()) { 13175 if (object->IsAccessCheckNeeded()) {
13173 if (!isolate->MayNamedAccess(this, key, v8::ACCESS_HAS)) { 13176 if (!isolate->MayNamedAccess(*object, *key, v8::ACCESS_HAS)) {
13174 isolate->ReportFailedAccessCheck(this, v8::ACCESS_HAS); 13177 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_HAS);
13175 return false; 13178 return false;
13176 } 13179 }
13177 } 13180 }
13178 13181
13179 LookupResult result(isolate); 13182 LookupResult result(isolate);
13180 LocalLookupRealNamedProperty(key, &result); 13183 object->LocalLookupRealNamedProperty(*key, &result);
13181 return result.IsFound() && !result.IsInterceptor(); 13184 return result.IsFound() && !result.IsInterceptor();
13182 } 13185 }
13183 13186
13184 13187
13185 bool JSObject::HasRealElementProperty(Isolate* isolate, uint32_t index) { 13188 bool JSObject::HasRealElementProperty(Handle<JSObject> object, uint32_t index) {
13189 Isolate* isolate = object->GetIsolate();
13190 SealHandleScope shs(isolate);
13186 // Check access rights if needed. 13191 // Check access rights if needed.
13187 if (IsAccessCheckNeeded()) { 13192 if (object->IsAccessCheckNeeded()) {
13188 if (!isolate->MayIndexedAccess(this, index, v8::ACCESS_HAS)) { 13193 if (!isolate->MayIndexedAccess(*object, index, v8::ACCESS_HAS)) {
13189 isolate->ReportFailedAccessCheck(this, v8::ACCESS_HAS); 13194 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_HAS);
13190 return false; 13195 return false;
13191 } 13196 }
13192 } 13197 }
13193 13198
13194 if (IsJSGlobalProxy()) { 13199 if (object->IsJSGlobalProxy()) {
13195 Object* proto = GetPrototype(); 13200 HandleScope scope(isolate);
13201 Handle<Object> proto(object->GetPrototype(), isolate);
13196 if (proto->IsNull()) return false; 13202 if (proto->IsNull()) return false;
13197 ASSERT(proto->IsJSGlobalObject()); 13203 ASSERT(proto->IsJSGlobalObject());
13198 return JSObject::cast(proto)->HasRealElementProperty(isolate, index); 13204 return HasRealElementProperty(Handle<JSObject>::cast(proto), index);
13199 } 13205 }
13200 13206
13201 return GetElementAttributeWithoutInterceptor(this, index, false) != ABSENT; 13207 return object->GetElementAttributeWithoutInterceptor(
13208 *object, index, false) != ABSENT;
13202 } 13209 }
13203 13210
13204 13211
13205 bool JSObject::HasRealNamedCallbackProperty(Isolate* isolate, Name* key) { 13212 bool JSObject::HasRealNamedCallbackProperty(Handle<JSObject> object,
13213 Handle<Name> key) {
13214 Isolate* isolate = object->GetIsolate();
13215 SealHandleScope shs(isolate);
13206 // Check access rights if needed. 13216 // Check access rights if needed.
13207 if (IsAccessCheckNeeded()) { 13217 if (object->IsAccessCheckNeeded()) {
13208 if (!isolate->MayNamedAccess(this, key, v8::ACCESS_HAS)) { 13218 if (!isolate->MayNamedAccess(*object, *key, v8::ACCESS_HAS)) {
13209 isolate->ReportFailedAccessCheck(this, v8::ACCESS_HAS); 13219 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_HAS);
13210 return false; 13220 return false;
13211 } 13221 }
13212 } 13222 }
13213 13223
13214 LookupResult result(isolate); 13224 LookupResult result(isolate);
13215 LocalLookupRealNamedProperty(key, &result); 13225 object->LocalLookupRealNamedProperty(*key, &result);
13216 return result.IsPropertyCallbacks(); 13226 return result.IsPropertyCallbacks();
13217 } 13227 }
13218 13228
13219 13229
13220 int JSObject::NumberOfLocalProperties(PropertyAttributes filter) { 13230 int JSObject::NumberOfLocalProperties(PropertyAttributes filter) {
13221 if (HasFastProperties()) { 13231 if (HasFastProperties()) {
13222 Map* map = this->map(); 13232 Map* map = this->map();
13223 if (filter == NONE) return map->NumberOfOwnDescriptors(); 13233 if (filter == NONE) return map->NumberOfOwnDescriptors();
13224 if (filter & DONT_ENUM) { 13234 if (filter & DONT_ENUM) {
13225 int result = map->EnumLength(); 13235 int result = map->EnumLength();
(...skipping 3138 matching lines...) Expand 10 before | Expand all | Expand 10 after
16364 #define ERROR_MESSAGES_TEXTS(C, T) T, 16374 #define ERROR_MESSAGES_TEXTS(C, T) T,
16365 static const char* error_messages_[] = { 16375 static const char* error_messages_[] = {
16366 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16376 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16367 }; 16377 };
16368 #undef ERROR_MESSAGES_TEXTS 16378 #undef ERROR_MESSAGES_TEXTS
16369 return error_messages_[reason]; 16379 return error_messages_[reason];
16370 } 16380 }
16371 16381
16372 16382
16373 } } // namespace v8::internal 16383 } } // 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