From 5d87a6c8e06cd2e9c9121e7b0c58bceeb8fb354d Mon Sep 17 00:00:00 2001 From: "mstarzinger@chromium.org" Date: Fri, 30 Aug 2013 13:28:52 +0000 Subject: [PATCH] Handlify JSObject::DeleteHiddenProperty method. R=yangguo@chromium.org Review URL: https://codereview.chromium.org/23600011 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16453 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/api.cc | 2 +- src/objects.cc | 29 +++++++++++++---------------- src/objects.h | 3 ++- src/runtime.cc | 10 +++++----- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/api.cc b/src/api.cc index 643a5b4100..6628a82c1b 100644 --- a/src/api.cc +++ b/src/api.cc @@ -3851,7 +3851,7 @@ bool v8::Object::DeleteHiddenValue(v8::Handle key) { i::Handle key_obj = Utils::OpenHandle(*key); i::Handle key_string = isolate->factory()->InternalizeString(key_obj); - self->DeleteHiddenProperty(*key_string); + i::JSObject::DeleteHiddenProperty(self, key_string); return true; } diff --git a/src/objects.cc b/src/objects.cc index 71d2602dc0..ed2eafdb10 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -4849,30 +4849,27 @@ MaybeObject* JSObject::SetHiddenProperty(Name* key, Object* value) { } -void JSObject::DeleteHiddenProperty(Name* key) { +void JSObject::DeleteHiddenProperty(Handle object, Handle key) { + Isolate* isolate = object->GetIsolate(); ASSERT(key->IsUniqueName()); - if (IsJSGlobalProxy()) { - // For a proxy, use the prototype as target object. - Object* proxy_parent = GetPrototype(); - // If the proxy is detached, return immediately. - if (proxy_parent->IsNull()) return; - ASSERT(proxy_parent->IsJSGlobalObject()); - JSObject::cast(proxy_parent)->DeleteHiddenProperty(key); - return; + + if (object->IsJSGlobalProxy()) { + Handle proto(object->GetPrototype(), isolate); + if (proto->IsNull()) return; + ASSERT(proto->IsJSGlobalObject()); + return DeleteHiddenProperty(Handle::cast(proto), key); } - ASSERT(!IsJSGlobalProxy()); + MaybeObject* hidden_lookup = - GetHiddenPropertiesHashTable(ONLY_RETURN_INLINE_VALUE); + object->GetHiddenPropertiesHashTable(ONLY_RETURN_INLINE_VALUE); Object* inline_value = hidden_lookup->ToObjectUnchecked(); // We never delete (inline-stored) identity hashes. - ASSERT(key != GetHeap()->identity_hash_string()); + ASSERT(*key != isolate->heap()->identity_hash_string()); if (inline_value->IsUndefined() || inline_value->IsSmi()) return; - ObjectHashTable* hashtable = ObjectHashTable::cast(inline_value); - MaybeObject* delete_result = hashtable->Put(key, GetHeap()->the_hole_value()); - USE(delete_result); - ASSERT(!delete_result->IsFailure()); // Delete does not cause GC. + Handle hashtable(ObjectHashTable::cast(inline_value)); + PutIntoObjectHashTable(hashtable, key, isolate->factory()->the_hole_value()); } diff --git a/src/objects.h b/src/objects.h index 3778ecbfd9..9fa133df20 100644 --- a/src/objects.h +++ b/src/objects.h @@ -2294,7 +2294,8 @@ class JSObject: public JSReceiver { Object* GetHiddenProperty(Name* key); // Deletes a hidden property. Deleting a non-existing property is // considered successful. - void DeleteHiddenProperty(Name* key); + static void DeleteHiddenProperty(Handle object, + Handle key); // Returns true if the object has a property with the hidden string as name. bool HasHiddenProperties(); diff --git a/src/runtime.cc b/src/runtime.cc index 376df5308b..513c73881b 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -14156,13 +14156,13 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectStackTrace) { RUNTIME_FUNCTION(MaybeObject*, Runtime_GetAndClearOverflowedStackTrace) { HandleScope scope(isolate); ASSERT_EQ(args.length(), 1); - CONVERT_ARG_CHECKED(JSObject, error_object, 0); - String* key = isolate->heap()->hidden_stack_trace_string(); - Object* result = error_object->GetHiddenProperty(key); + CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0); + Handle key = isolate->factory()->hidden_stack_trace_string(); + Handle result(error_object->GetHiddenProperty(*key), isolate); if (result->IsTheHole()) return isolate->heap()->undefined_value(); RUNTIME_ASSERT(result->IsJSArray() || result->IsUndefined()); - error_object->DeleteHiddenProperty(key); - return result; + JSObject::DeleteHiddenProperty(error_object, key); + return *result; }