Handlify JSReceiver/JSObject::DeleteProperty method.

R=verwaest@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15730 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent b1373531
......@@ -124,6 +124,15 @@ typedef ZoneList<Handle<Object> > ZoneObjectList;
} \
} while (false)
#define RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, T) \
do { \
Isolate* __isolate__ = (isolate); \
if (__isolate__->has_scheduled_exception()) { \
__isolate__->PromoteScheduledException(); \
return Handle<T>::null(); \
} \
} while (false)
#define RETURN_IF_EMPTY_HANDLE_VALUE(isolate, call, value) \
do { \
if ((call).is_null()) { \
......
This diff is collapsed.
......@@ -1666,8 +1666,12 @@ class JSReceiver: public HeapObject {
MUST_USE_RESULT MaybeObject* SetPropertyWithDefinedSetter(JSReceiver* setter,
Object* value);
MUST_USE_RESULT MaybeObject* DeleteProperty(Name* name, DeleteMode mode);
MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode);
static Handle<Object> DeleteProperty(Handle<JSReceiver> object,
Handle<Name> name,
DeleteMode mode = NORMAL_DELETION);
static Handle<Object> DeleteElement(Handle<JSReceiver> object,
uint32_t index,
DeleteMode mode);
// Set the index'th array element.
// Can cause GC, or return failure if GC is required.
......@@ -1911,10 +1915,6 @@ class JSObject: public JSReceiver {
Object* value,
PropertyDetails details);
// Deletes the named property in a normalized object.
MUST_USE_RESULT MaybeObject* DeleteNormalizedProperty(Name* name,
DeleteMode mode);
static void OptimizeAsPrototype(Handle<JSObject> object);
MUST_USE_RESULT MaybeObject* OptimizeAsPrototype();
......@@ -2005,12 +2005,9 @@ class JSObject: public JSReceiver {
MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag);
MUST_USE_RESULT MaybeObject* SetIdentityHash(Smi* hash, CreationFlag flag);
static Handle<Object> DeleteProperty(Handle<JSObject> obj,
Handle<Name> name);
// Can cause GC.
MUST_USE_RESULT MaybeObject* DeleteProperty(Name* name, DeleteMode mode);
static Handle<Object> DeleteElement(Handle<JSObject> obj, uint32_t index);
static Handle<Object> DeleteElement(Handle<JSObject> obj,
uint32_t index,
DeleteMode mode = NORMAL_DELETION);
MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode);
inline void ValidateElements();
......@@ -2443,6 +2440,7 @@ class JSObject: public JSReceiver {
private:
friend class DictionaryElementsAccessor;
friend class JSReceiver;
MUST_USE_RESULT MaybeObject* GetElementWithCallback(Object* receiver,
Object* structure,
......@@ -2488,9 +2486,19 @@ class JSObject: public JSReceiver {
StrictModeFlag strict_mode,
bool* done);
MUST_USE_RESULT MaybeObject* DeletePropertyPostInterceptor(Name* name,
DeleteMode mode);
MUST_USE_RESULT MaybeObject* DeletePropertyWithInterceptor(Name* name);
static Handle<Object> DeleteProperty(Handle<JSObject> object,
Handle<Name> name,
DeleteMode mode);
static Handle<Object> DeletePropertyPostInterceptor(Handle<JSObject> object,
Handle<Name> name,
DeleteMode mode);
static Handle<Object> DeletePropertyWithInterceptor(Handle<JSObject> object,
Handle<Name> name);
// Deletes the named property in a normalized object.
static Handle<Object> DeleteNormalizedProperty(Handle<JSObject> object,
Handle<Name> name,
DeleteMode mode);
MUST_USE_RESULT MaybeObject* DeleteElementWithInterceptor(uint32_t index);
......@@ -5460,6 +5468,7 @@ class Map: public HeapObject {
MUST_USE_RESULT MaybeObject* RawCopy(int instance_size);
MUST_USE_RESULT MaybeObject* CopyWithPreallocatedFieldDescriptors();
static Handle<Map> CopyDropDescriptors(Handle<Map> map);
MUST_USE_RESULT MaybeObject* CopyDropDescriptors();
MUST_USE_RESULT MaybeObject* CopyReplaceDescriptors(
DescriptorArray* descriptors,
......@@ -8739,13 +8748,6 @@ class JSProxy: public JSReceiver {
StrictModeFlag strict_mode,
bool* done);
MUST_USE_RESULT MaybeObject* DeletePropertyWithHandler(
Name* name,
DeleteMode mode);
MUST_USE_RESULT MaybeObject* DeleteElementWithHandler(
uint32_t index,
DeleteMode mode);
MUST_USE_RESULT PropertyAttributes GetPropertyAttributeWithHandler(
JSReceiver* receiver,
Name* name);
......@@ -8789,6 +8791,15 @@ class JSProxy: public JSReceiver {
kSize> BodyDescriptor;
private:
friend class JSReceiver;
static Handle<Object> DeletePropertyWithHandler(Handle<JSProxy> object,
Handle<Name> name,
DeleteMode mode);
static Handle<Object> DeleteElementWithHandler(Handle<JSProxy> object,
uint32_t index,
DeleteMode mode);
DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy);
};
......
......@@ -5159,7 +5159,9 @@ MaybeObject* Runtime::DeleteObjectProperty(Isolate* isolate,
return isolate->heap()->true_value();
}
return receiver->DeleteElement(index, mode);
Handle<Object> result = JSReceiver::DeleteElement(receiver, index, mode);
RETURN_IF_EMPTY_HANDLE(isolate, result);
return *result;
}
Handle<Name> name;
......@@ -5174,7 +5176,9 @@ MaybeObject* Runtime::DeleteObjectProperty(Isolate* isolate,
}
if (name->IsString()) Handle<String>::cast(name)->TryFlatten();
return receiver->DeleteProperty(*name, mode);
Handle<Object> result = JSReceiver::DeleteProperty(receiver, name, mode);
RETURN_IF_EMPTY_HANDLE(isolate, result);
return *result;
}
......@@ -5387,15 +5391,16 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_IgnoreAttributesAndSetProperty) {
RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) {
SealHandleScope shs(isolate);
HandleScope scope(isolate);
ASSERT(args.length() == 3);
CONVERT_ARG_CHECKED(JSReceiver, object, 0);
CONVERT_ARG_CHECKED(Name, key, 1);
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0);
CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2);
return object->DeleteProperty(key, (strict_mode == kStrictMode)
? JSReceiver::STRICT_DELETION
: JSReceiver::NORMAL_DELETION);
JSReceiver::DeleteMode delete_mode = (strict_mode == kStrictMode)
? JSReceiver::STRICT_DELETION : JSReceiver::NORMAL_DELETION;
Handle<Object> result = JSReceiver::DeleteProperty(object, key, delete_mode);
RETURN_IF_EMPTY_HANDLE(isolate, result);
return *result;
}
......@@ -8968,7 +8973,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteContextSlot) {
// the global object, or the subject of a with. Try to delete it
// (respecting DONT_DELETE).
Handle<JSObject> object = Handle<JSObject>::cast(holder);
return object->DeleteProperty(*name, JSReceiver::NORMAL_DELETION);
Handle<Object> result = JSReceiver::DeleteProperty(object, name);
RETURN_IF_EMPTY_HANDLE(isolate, result);
return *result;
}
......
......@@ -661,7 +661,7 @@ TEST(ObjectProperties) {
CHECK(obj->HasLocalProperty(*first));
// delete first
CHECK(obj->DeleteProperty(*first, JSObject::NORMAL_DELETION));
JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION);
CHECK(!obj->HasLocalProperty(*first));
// add first and then second
......@@ -673,9 +673,9 @@ TEST(ObjectProperties) {
CHECK(obj->HasLocalProperty(*second));
// delete first and then second
CHECK(obj->DeleteProperty(*first, JSObject::NORMAL_DELETION));
JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION);
CHECK(obj->HasLocalProperty(*second));
CHECK(obj->DeleteProperty(*second, JSObject::NORMAL_DELETION));
JSReceiver::DeleteProperty(obj, second, JSReceiver::NORMAL_DELETION);
CHECK(!obj->HasLocalProperty(*first));
CHECK(!obj->HasLocalProperty(*second));
......@@ -688,9 +688,9 @@ TEST(ObjectProperties) {
CHECK(obj->HasLocalProperty(*second));
// delete second and then first
CHECK(obj->DeleteProperty(*second, JSObject::NORMAL_DELETION));
JSReceiver::DeleteProperty(obj, second, JSReceiver::NORMAL_DELETION);
CHECK(obj->HasLocalProperty(*first));
CHECK(obj->DeleteProperty(*first, JSObject::NORMAL_DELETION));
JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION);
CHECK(!obj->HasLocalProperty(*first));
CHECK(!obj->HasLocalProperty(*second));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment