Handlify JSObject::HasReal*Property.

R=ulan@chromium.org
BUG=

Review URL: https://codereview.chromium.org/27518002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17272 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
yangguo@chromium.org 2013-10-18 12:52:07 +00:00
parent b50be9ff12
commit a428465819
4 changed files with 50 additions and 41 deletions

View File

@ -3526,9 +3526,8 @@ bool v8::Object::HasRealNamedProperty(Handle<String> key) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ON_BAILOUT(isolate, "v8::Object::HasRealNamedProperty()",
return false);
return Utils::OpenHandle(this)->HasRealNamedProperty(
isolate,
*Utils::OpenHandle(*key));
return i::JSObject::HasRealNamedProperty(Utils::OpenHandle(this),
Utils::OpenHandle(*key));
}
@ -3536,7 +3535,7 @@ bool v8::Object::HasRealIndexedProperty(uint32_t index) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ON_BAILOUT(isolate, "v8::Object::HasRealIndexedProperty()",
return false);
return Utils::OpenHandle(this)->HasRealElementProperty(isolate, index);
return i::JSObject::HasRealElementProperty(Utils::OpenHandle(this), index);
}
@ -3546,9 +3545,8 @@ bool v8::Object::HasRealNamedCallbackProperty(Handle<String> key) {
"v8::Object::HasRealNamedCallbackProperty()",
return false);
ENTER_V8(isolate);
return Utils::OpenHandle(this)->HasRealNamedCallbackProperty(
isolate,
*Utils::OpenHandle(*key));
return i::JSObject::HasRealNamedCallbackProperty(Utils::OpenHandle(this),
Utils::OpenHandle(*key));
}

View File

@ -6557,7 +6557,7 @@ Handle<Object> JSObject::GetAccessor(Handle<JSObject> object,
uint32_t index = 0;
if (name->AsArrayIndex(&index)) {
for (Handle<Object> obj = object;
*obj != isolate->heap()->null_value();
!obj->IsNull();
obj = handle(JSReceiver::cast(*obj)->GetPrototype(), isolate)) {
if (obj->IsJSObject() && JSObject::cast(*obj)->HasDictionaryElements()) {
JSObject* js_object = JSObject::cast(*obj);
@ -6575,7 +6575,7 @@ Handle<Object> JSObject::GetAccessor(Handle<JSObject> object,
}
} else {
for (Handle<Object> obj = object;
*obj != isolate->heap()->null_value();
!obj->IsNull();
obj = handle(JSReceiver::cast(*obj)->GetPrototype(), isolate)) {
LookupResult result(isolate);
JSReceiver::cast(*obj)->LocalLookup(*name, &result);
@ -13177,52 +13177,62 @@ Handle<Object> JSObject::GetPropertyWithInterceptor(
}
bool JSObject::HasRealNamedProperty(Isolate* isolate, Name* key) {
bool JSObject::HasRealNamedProperty(Handle<JSObject> object,
Handle<Name> key) {
Isolate* isolate = object->GetIsolate();
SealHandleScope shs(isolate);
// Check access rights if needed.
if (IsAccessCheckNeeded()) {
if (!isolate->MayNamedAccess(this, key, v8::ACCESS_HAS)) {
isolate->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
if (object->IsAccessCheckNeeded()) {
if (!isolate->MayNamedAccess(*object, *key, v8::ACCESS_HAS)) {
isolate->ReportFailedAccessCheck(*object, v8::ACCESS_HAS);
return false;
}
}
LookupResult result(isolate);
LocalLookupRealNamedProperty(key, &result);
object->LocalLookupRealNamedProperty(*key, &result);
return result.IsFound() && !result.IsInterceptor();
}
bool JSObject::HasRealElementProperty(Isolate* isolate, uint32_t index) {
bool JSObject::HasRealElementProperty(Handle<JSObject> object, uint32_t index) {
Isolate* isolate = object->GetIsolate();
SealHandleScope shs(isolate);
// Check access rights if needed.
if (IsAccessCheckNeeded()) {
if (!isolate->MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
isolate->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
if (object->IsAccessCheckNeeded()) {
if (!isolate->MayIndexedAccess(*object, index, v8::ACCESS_HAS)) {
isolate->ReportFailedAccessCheck(*object, v8::ACCESS_HAS);
return false;
}
}
if (IsJSGlobalProxy()) {
Object* proto = GetPrototype();
if (object->IsJSGlobalProxy()) {
HandleScope scope(isolate);
Handle<Object> proto(object->GetPrototype(), isolate);
if (proto->IsNull()) return false;
ASSERT(proto->IsJSGlobalObject());
return JSObject::cast(proto)->HasRealElementProperty(isolate, index);
return HasRealElementProperty(Handle<JSObject>::cast(proto), index);
}
return GetElementAttributeWithoutInterceptor(this, index, false) != ABSENT;
return object->GetElementAttributeWithoutInterceptor(
*object, index, false) != ABSENT;
}
bool JSObject::HasRealNamedCallbackProperty(Isolate* isolate, Name* key) {
bool JSObject::HasRealNamedCallbackProperty(Handle<JSObject> object,
Handle<Name> key) {
Isolate* isolate = object->GetIsolate();
SealHandleScope shs(isolate);
// Check access rights if needed.
if (IsAccessCheckNeeded()) {
if (!isolate->MayNamedAccess(this, key, v8::ACCESS_HAS)) {
isolate->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
if (object->IsAccessCheckNeeded()) {
if (!isolate->MayNamedAccess(*object, *key, v8::ACCESS_HAS)) {
isolate->ReportFailedAccessCheck(*object, v8::ACCESS_HAS);
return false;
}
}
LookupResult result(isolate);
LocalLookupRealNamedProperty(key, &result);
object->LocalLookupRealNamedProperty(*key, &result);
return result.IsPropertyCallbacks();
}

View File

@ -2414,9 +2414,11 @@ class JSObject: public JSReceiver {
inline bool HasIndexedInterceptor();
// Support functions for v8 api (needed for correct interceptor behavior).
bool HasRealNamedProperty(Isolate* isolate, Name* key);
bool HasRealElementProperty(Isolate* isolate, uint32_t index);
bool HasRealNamedCallbackProperty(Isolate* isolate, Name* key);
static bool HasRealNamedProperty(Handle<JSObject> object,
Handle<Name> key);
static bool HasRealElementProperty(Handle<JSObject> object, uint32_t index);
static bool HasRealNamedCallbackProperty(Handle<JSObject> object,
Handle<Name> key);
// Get the header size for a JSObject. Used to compute the index of
// internal fields as well as the number of internal fields.

View File

@ -5582,40 +5582,39 @@ static MaybeObject* HasLocalPropertyImplementation(Isolate* isolate,
RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) {
SealHandleScope shs(isolate);
HandleScope scope(isolate);
ASSERT(args.length() == 2);
CONVERT_ARG_CHECKED(Name, key, 1);
CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
Handle<Object> object = args.at<Object>(0);
uint32_t index;
const bool key_is_array_index = key->AsArrayIndex(&index);
Object* obj = args[0];
// Only JS objects can have properties.
if (obj->IsJSObject()) {
JSObject* object = JSObject::cast(obj);
if (object->IsJSObject()) {
Handle<JSObject> js_obj = Handle<JSObject>::cast(object);
// Fast case: either the key is a real named property or it is not
// an array index and there are no interceptors or hidden
// prototypes.
if (object->HasRealNamedProperty(isolate, key)) {
if (JSObject::HasRealNamedProperty(js_obj, key)) {
ASSERT(!isolate->has_scheduled_exception());
return isolate->heap()->true_value();
} else {
RETURN_IF_SCHEDULED_EXCEPTION(isolate);
}
Map* map = object->map();
Map* map = js_obj->map();
if (!key_is_array_index &&
!map->has_named_interceptor() &&
!HeapObject::cast(map->prototype())->map()->is_hidden_prototype()) {
return isolate->heap()->false_value();
}
// Slow case.
HandleScope scope(isolate);
return HasLocalPropertyImplementation(isolate,
Handle<JSObject>(object),
Handle<JSObject>(js_obj),
Handle<Name>(key));
} else if (obj->IsString() && key_is_array_index) {
} else if (object->IsString() && key_is_array_index) {
// Well, there is one exception: Handle [] on strings.
String* string = String::cast(obj);
Handle<String> string = Handle<String>::cast(object);
if (index < static_cast<uint32_t>(string->length())) {
return isolate->heap()->true_value();
}