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:
parent
8b97a1c5d2
commit
5d87a6c8e0
@ -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_string =
|
||||
isolate->factory()->InternalizeString(key_obj);
|
||||
self->DeleteHiddenProperty(*key_string);
|
||||
i::JSObject::DeleteHiddenProperty(self, key_string);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
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<Object> proto(object->GetPrototype(), isolate);
|
||||
if (proto->IsNull()) return;
|
||||
ASSERT(proto->IsJSGlobalObject());
|
||||
return DeleteHiddenProperty(Handle<JSObject>::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<ObjectHashTable> hashtable(ObjectHashTable::cast(inline_value));
|
||||
PutIntoObjectHashTable(hashtable, key, isolate->factory()->the_hole_value());
|
||||
}
|
||||
|
||||
|
||||
|
@ -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<JSObject> object,
|
||||
Handle<Name> key);
|
||||
// Returns true if the object has a property with the hidden string as name.
|
||||
bool HasHiddenProperties();
|
||||
|
||||
|
@ -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<String> key = isolate->factory()->hidden_stack_trace_string();
|
||||
Handle<Object> 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;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user