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
This commit is contained in:
mstarzinger@chromium.org 2013-08-30 13:28:52 +00:00
parent 8b97a1c5d2
commit 5d87a6c8e0
4 changed files with 21 additions and 23 deletions

View File

@ -3851,7 +3851,7 @@ bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) {
i::Handle<i::String> key_obj = Utils::OpenHandle(*key); i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
i::Handle<i::String> key_string = i::Handle<i::String> key_string =
isolate->factory()->InternalizeString(key_obj); isolate->factory()->InternalizeString(key_obj);
self->DeleteHiddenProperty(*key_string); i::JSObject::DeleteHiddenProperty(self, key_string);
return true; return true;
} }

View File

@ -4849,30 +4849,27 @@ MaybeObject* JSObject::SetHiddenProperty(Name* key, Object* value) {
} }
void JSObject::DeleteHiddenProperty(Name* key) { void JSObject::DeleteHiddenProperty(Handle<JSObject> object, Handle<Name> key) {
Isolate* isolate = object->GetIsolate();
ASSERT(key->IsUniqueName()); ASSERT(key->IsUniqueName());
if (IsJSGlobalProxy()) {
// For a proxy, use the prototype as target object. if (object->IsJSGlobalProxy()) {
Object* proxy_parent = GetPrototype(); Handle<Object> proto(object->GetPrototype(), isolate);
// If the proxy is detached, return immediately. if (proto->IsNull()) return;
if (proxy_parent->IsNull()) return; ASSERT(proto->IsJSGlobalObject());
ASSERT(proxy_parent->IsJSGlobalObject()); return DeleteHiddenProperty(Handle<JSObject>::cast(proto), key);
JSObject::cast(proxy_parent)->DeleteHiddenProperty(key);
return;
} }
ASSERT(!IsJSGlobalProxy());
MaybeObject* hidden_lookup = MaybeObject* hidden_lookup =
GetHiddenPropertiesHashTable(ONLY_RETURN_INLINE_VALUE); object->GetHiddenPropertiesHashTable(ONLY_RETURN_INLINE_VALUE);
Object* inline_value = hidden_lookup->ToObjectUnchecked(); Object* inline_value = hidden_lookup->ToObjectUnchecked();
// We never delete (inline-stored) identity hashes. // 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; if (inline_value->IsUndefined() || inline_value->IsSmi()) return;
ObjectHashTable* hashtable = ObjectHashTable::cast(inline_value); Handle<ObjectHashTable> hashtable(ObjectHashTable::cast(inline_value));
MaybeObject* delete_result = hashtable->Put(key, GetHeap()->the_hole_value()); PutIntoObjectHashTable(hashtable, key, isolate->factory()->the_hole_value());
USE(delete_result);
ASSERT(!delete_result->IsFailure()); // Delete does not cause GC.
} }

View File

@ -2294,7 +2294,8 @@ class JSObject: public JSReceiver {
Object* GetHiddenProperty(Name* key); Object* GetHiddenProperty(Name* key);
// Deletes a hidden property. Deleting a non-existing property is // Deletes a hidden property. Deleting a non-existing property is
// considered successful. // considered successful.
void DeleteHiddenProperty(Name* key); static void DeleteHiddenProperty(Handle<JSObject> object,
Handle<Name> key);
// Returns true if the object has a property with the hidden string as name. // Returns true if the object has a property with the hidden string as name.
bool HasHiddenProperties(); bool HasHiddenProperties();

View File

@ -14156,13 +14156,13 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectStackTrace) {
RUNTIME_FUNCTION(MaybeObject*, Runtime_GetAndClearOverflowedStackTrace) { RUNTIME_FUNCTION(MaybeObject*, Runtime_GetAndClearOverflowedStackTrace) {
HandleScope scope(isolate); HandleScope scope(isolate);
ASSERT_EQ(args.length(), 1); ASSERT_EQ(args.length(), 1);
CONVERT_ARG_CHECKED(JSObject, error_object, 0); CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0);
String* key = isolate->heap()->hidden_stack_trace_string(); Handle<String> key = isolate->factory()->hidden_stack_trace_string();
Object* result = error_object->GetHiddenProperty(key); Handle<Object> result(error_object->GetHiddenProperty(*key), isolate);
if (result->IsTheHole()) return isolate->heap()->undefined_value(); if (result->IsTheHole()) return isolate->heap()->undefined_value();
RUNTIME_ASSERT(result->IsJSArray() || result->IsUndefined()); RUNTIME_ASSERT(result->IsJSArray() || result->IsUndefined());
error_object->DeleteHiddenProperty(key); JSObject::DeleteHiddenProperty(error_object, key);
return result; return *result;
} }