Add static version of JSCell::deleteProperty
authormhahnenberg@apple.com <mhahnenberg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 8 Oct 2011 06:37:45 +0000 (06:37 +0000)
committermhahnenberg@apple.com <mhahnenberg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 8 Oct 2011 06:37:45 +0000 (06:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=69659

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

Added static version of both versions of put to all classes that
override them and changed the virtual versions to call the static
versions.  This is the first step in de-virtualizing JSCell::deleteProperty.

* API/JSCallbackObject.h:
* API/JSCallbackObjectFunctions.h:
(JSC::::deleteProperty):
* debugger/DebuggerActivation.cpp:
(JSC::DebuggerActivation::deleteProperty):
* debugger/DebuggerActivation.h:
* runtime/Arguments.cpp:
(JSC::Arguments::deleteProperty):
* runtime/Arguments.h:
* runtime/JSActivation.cpp:
(JSC::JSActivation::deleteProperty):
* runtime/JSActivation.h:
* runtime/JSArray.cpp:
(JSC::JSArray::deleteProperty):
* runtime/JSArray.h:
* runtime/JSCell.cpp:
(JSC::JSCell::deleteProperty):
* runtime/JSCell.h:
* runtime/JSFunction.cpp:
(JSC::JSFunction::deleteProperty):
* runtime/JSFunction.h:
* runtime/JSNotAnObject.cpp:
(JSC::JSNotAnObject::deleteProperty):
* runtime/JSNotAnObject.h:
* runtime/JSObject.cpp:
(JSC::JSObject::deleteProperty):
* runtime/JSObject.h:
* runtime/JSVariableObject.cpp:
(JSC::JSVariableObject::deleteProperty):
* runtime/JSVariableObject.h:
* runtime/RegExpMatchesArray.h:
(JSC::RegExpMatchesArray::deleteProperty):
* runtime/StrictEvalActivation.cpp:
(JSC::StrictEvalActivation::deleteProperty):
* runtime/StrictEvalActivation.h:
* runtime/StringObject.cpp:
(JSC::StringObject::deleteProperty):
* runtime/StringObject.h:

Source/WebCore:

No new tests.

Added static version of both versions of put to all classes that
override them and changed the virtual versions to call the static
versions.  This is the first step in de-virtualizing JSCell::deleteProperty.

* bridge/objc/objc_runtime.h:
* bridge/objc/objc_runtime.mm:
(JSC::Bindings::ObjcFallbackObjectImp::deleteProperty):
* bridge/runtime_array.cpp:
(JSC::RuntimeArray::deleteProperty):
* bridge/runtime_array.h:
* bridge/runtime_object.cpp:
(JSC::Bindings::RuntimeObject::deleteProperty):
* bridge/runtime_object.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@97002 268f45cc-cd09-0410-ab3c-d52691b4dbfc

33 files changed:
Source/JavaScriptCore/API/JSCallbackObject.h
Source/JavaScriptCore/API/JSCallbackObjectFunctions.h
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/debugger/DebuggerActivation.cpp
Source/JavaScriptCore/debugger/DebuggerActivation.h
Source/JavaScriptCore/runtime/Arguments.cpp
Source/JavaScriptCore/runtime/Arguments.h
Source/JavaScriptCore/runtime/JSActivation.cpp
Source/JavaScriptCore/runtime/JSActivation.h
Source/JavaScriptCore/runtime/JSArray.cpp
Source/JavaScriptCore/runtime/JSArray.h
Source/JavaScriptCore/runtime/JSCell.cpp
Source/JavaScriptCore/runtime/JSCell.h
Source/JavaScriptCore/runtime/JSFunction.cpp
Source/JavaScriptCore/runtime/JSFunction.h
Source/JavaScriptCore/runtime/JSNotAnObject.cpp
Source/JavaScriptCore/runtime/JSNotAnObject.h
Source/JavaScriptCore/runtime/JSObject.cpp
Source/JavaScriptCore/runtime/JSObject.h
Source/JavaScriptCore/runtime/JSVariableObject.cpp
Source/JavaScriptCore/runtime/JSVariableObject.h
Source/JavaScriptCore/runtime/RegExpMatchesArray.h
Source/JavaScriptCore/runtime/StrictEvalActivation.cpp
Source/JavaScriptCore/runtime/StrictEvalActivation.h
Source/JavaScriptCore/runtime/StringObject.cpp
Source/JavaScriptCore/runtime/StringObject.h
Source/WebCore/ChangeLog
Source/WebCore/bridge/objc/objc_runtime.h
Source/WebCore/bridge/objc/objc_runtime.mm
Source/WebCore/bridge/runtime_array.cpp
Source/WebCore/bridge/runtime_array.h
Source/WebCore/bridge/runtime_object.cpp
Source/WebCore/bridge/runtime_object.h

index 77d23cb..2397e5e 100644 (file)
@@ -185,7 +185,9 @@ private:
     static void put(JSCell*, ExecState*, const Identifier&, JSValue, PutPropertySlot&);
 
     virtual bool deleteProperty(ExecState*, const Identifier&);
+    static bool deleteProperty(JSCell*, ExecState*, const Identifier&);
     virtual bool deleteProperty(ExecState*, unsigned);
+    static bool deleteProperty(JSCell*, ExecState*, unsigned);
 
     virtual bool hasInstance(ExecState* exec, JSValue value, JSValue proto);
 
index aa56191..714d1a8 100644 (file)
@@ -268,11 +268,18 @@ void JSCallbackObject<Parent>::put(JSCell* cell, ExecState* exec, const Identifi
 template <class Parent>
 bool JSCallbackObject<Parent>::deleteProperty(ExecState* exec, const Identifier& propertyName)
 {
+    return deleteProperty(this, exec, propertyName);
+}
+
+template <class Parent>
+bool JSCallbackObject<Parent>::deleteProperty(JSCell* cell, ExecState* exec, const Identifier& propertyName)
+{
+    JSCallbackObject* thisObject = static_cast<JSCallbackObject*>(cell);
     JSContextRef ctx = toRef(exec);
-    JSObjectRef thisRef = toRef(this);
+    JSObjectRef thisRef = toRef(thisObject);
     RefPtr<OpaqueJSString> propertyNameRef;
     
-    for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
+    for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) {
         if (JSObjectDeletePropertyCallback deleteProperty = jsClass->deleteProperty) {
             if (!propertyNameRef)
                 propertyNameRef = OpaqueJSString::create(propertyName.ustring());
@@ -305,13 +312,19 @@ bool JSCallbackObject<Parent>::deleteProperty(ExecState* exec, const Identifier&
         }
     }
     
-    return Parent::deleteProperty(exec, propertyName);
+    return Parent::deleteProperty(thisObject, exec, propertyName);
 }
 
 template <class Parent>
 bool JSCallbackObject<Parent>::deleteProperty(ExecState* exec, unsigned propertyName)
 {
-    return deleteProperty(exec, Identifier::from(exec, propertyName));
+    return deleteProperty(this, exec, propertyName);
+}
+
+template <class Parent>
+bool JSCallbackObject<Parent>::deleteProperty(JSCell* cell, ExecState* exec, unsigned propertyName)
+{
+    return static_cast<JSCallbackObject*>(cell)->deleteProperty(exec, Identifier::from(exec, propertyName));
 }
 
 template <class Parent>
index 26f8a1d..3e223f1 100644 (file)
@@ -1,5 +1,55 @@
 2011-10-07  Mark Hahnenberg  <mhahnenberg@apple.com>
 
+        Add static version of JSCell::deleteProperty
+        https://bugs.webkit.org/show_bug.cgi?id=69659
+
+        Reviewed by Geoffrey Garen.
+
+        Added static version of both versions of put to all classes that 
+        override them and changed the virtual versions to call the static 
+        versions.  This is the first step in de-virtualizing JSCell::deleteProperty.
+
+        * API/JSCallbackObject.h:
+        * API/JSCallbackObjectFunctions.h:
+        (JSC::::deleteProperty):
+        * debugger/DebuggerActivation.cpp:
+        (JSC::DebuggerActivation::deleteProperty):
+        * debugger/DebuggerActivation.h:
+        * runtime/Arguments.cpp:
+        (JSC::Arguments::deleteProperty):
+        * runtime/Arguments.h:
+        * runtime/JSActivation.cpp:
+        (JSC::JSActivation::deleteProperty):
+        * runtime/JSActivation.h:
+        * runtime/JSArray.cpp:
+        (JSC::JSArray::deleteProperty):
+        * runtime/JSArray.h:
+        * runtime/JSCell.cpp:
+        (JSC::JSCell::deleteProperty):
+        * runtime/JSCell.h:
+        * runtime/JSFunction.cpp:
+        (JSC::JSFunction::deleteProperty):
+        * runtime/JSFunction.h:
+        * runtime/JSNotAnObject.cpp:
+        (JSC::JSNotAnObject::deleteProperty):
+        * runtime/JSNotAnObject.h:
+        * runtime/JSObject.cpp:
+        (JSC::JSObject::deleteProperty):
+        * runtime/JSObject.h:
+        * runtime/JSVariableObject.cpp:
+        (JSC::JSVariableObject::deleteProperty):
+        * runtime/JSVariableObject.h:
+        * runtime/RegExpMatchesArray.h:
+        (JSC::RegExpMatchesArray::deleteProperty):
+        * runtime/StrictEvalActivation.cpp:
+        (JSC::StrictEvalActivation::deleteProperty):
+        * runtime/StrictEvalActivation.h:
+        * runtime/StringObject.cpp:
+        (JSC::StringObject::deleteProperty):
+        * runtime/StringObject.h:
+
+2011-10-07  Mark Hahnenberg  <mhahnenberg@apple.com>
+
         Remove getCallDataVirtual methods
         https://bugs.webkit.org/show_bug.cgi?id=69186
 
index d8b1d47..2a534f9 100644 (file)
@@ -82,7 +82,12 @@ void DebuggerActivation::putWithAttributes(ExecState* exec, const Identifier& pr
 
 bool DebuggerActivation::deleteProperty(ExecState* exec, const Identifier& propertyName)
 {
-    return m_activation->deleteProperty(exec, propertyName);
+    return deleteProperty(this, exec, propertyName);
+}
+
+bool DebuggerActivation::deleteProperty(JSCell* cell, ExecState* exec, const Identifier& propertyName)
+{
+    return static_cast<DebuggerActivation*>(cell)->m_activation->deleteProperty(exec, propertyName);
 }
 
 void DebuggerActivation::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
index 2de9eef..a9aa7b4 100644 (file)
@@ -48,6 +48,7 @@ namespace JSC {
         static void put(JSCell*, ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
         virtual void putWithAttributes(ExecState*, const Identifier& propertyName, JSValue, unsigned attributes);
         virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
+        static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
         virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
         virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
         virtual void defineGetter(ExecState*, const Identifier& propertyName, JSObject* getterFunction, unsigned attributes);
index 910613a..35f86d3 100644 (file)
@@ -318,52 +318,64 @@ void Arguments::put(JSCell* cell, ExecState* exec, const Identifier& propertyNam
 
 bool Arguments::deleteProperty(ExecState* exec, unsigned i) 
 {
-    if (i < d->numArguments) {
-        if (!d->deletedArguments) {
-            d->deletedArguments = adoptArrayPtr(new bool[d->numArguments]);
-            memset(d->deletedArguments.get(), 0, sizeof(bool) * d->numArguments);
+    return deleteProperty(this, exec, i);
+}
+
+bool Arguments::deleteProperty(JSCell* cell, ExecState* exec, unsigned i) 
+{
+    Arguments* thisObject = static_cast<Arguments*>(cell);
+    if (i < thisObject->d->numArguments) {
+        if (!thisObject->d->deletedArguments) {
+            thisObject->d->deletedArguments = adoptArrayPtr(new bool[thisObject->d->numArguments]);
+            memset(thisObject->d->deletedArguments.get(), 0, sizeof(bool) * thisObject->d->numArguments);
         }
-        if (!d->deletedArguments[i]) {
-            d->deletedArguments[i] = true;
+        if (!thisObject->d->deletedArguments[i]) {
+            thisObject->d->deletedArguments[i] = true;
             return true;
         }
     }
 
-    return JSObject::deleteProperty(exec, Identifier(exec, UString::number(i)));
+    return JSObject::deleteProperty(thisObject, exec, Identifier(exec, UString::number(i)));
 }
 
 bool Arguments::deleteProperty(ExecState* exec, const Identifier& propertyName) 
 {
+    return deleteProperty(this, exec, propertyName);
+}
+
+bool Arguments::deleteProperty(JSCell* cell, ExecState* exec, const Identifier& propertyName) 
+{
+    Arguments* thisObject = static_cast<Arguments*>(cell);
     bool isArrayIndex;
     unsigned i = propertyName.toArrayIndex(isArrayIndex);
-    if (isArrayIndex && i < d->numArguments) {
-        if (!d->deletedArguments) {
-            d->deletedArguments = adoptArrayPtr(new bool[d->numArguments]);
-            memset(d->deletedArguments.get(), 0, sizeof(bool) * d->numArguments);
+    if (isArrayIndex && i < thisObject->d->numArguments) {
+        if (!thisObject->d->deletedArguments) {
+            thisObject->d->deletedArguments = adoptArrayPtr(new bool[thisObject->d->numArguments]);
+            memset(thisObject->d->deletedArguments.get(), 0, sizeof(bool) * thisObject->d->numArguments);
         }
-        if (!d->deletedArguments[i]) {
-            d->deletedArguments[i] = true;
+        if (!thisObject->d->deletedArguments[i]) {
+            thisObject->d->deletedArguments[i] = true;
             return true;
         }
     }
 
-    if (propertyName == exec->propertyNames().length && !d->overrodeLength) {
-        d->overrodeLength = true;
+    if (propertyName == exec->propertyNames().length && !thisObject->d->overrodeLength) {
+        thisObject->d->overrodeLength = true;
         return true;
     }
 
-    if (propertyName == exec->propertyNames().callee && !d->overrodeCallee) {
-        if (!d->isStrictMode) {
-            d->overrodeCallee = true;
+    if (propertyName == exec->propertyNames().callee && !thisObject->d->overrodeCallee) {
+        if (!thisObject->d->isStrictMode) {
+            thisObject->d->overrodeCallee = true;
             return true;
         }
-        createStrictModeCalleeIfNecessary(exec);
+        thisObject->createStrictModeCalleeIfNecessary(exec);
     }
     
-    if (propertyName == exec->propertyNames().caller && !d->isStrictMode)
-        createStrictModeCallerIfNecessary(exec);
+    if (propertyName == exec->propertyNames().caller && !thisObject->d->isStrictMode)
+        thisObject->createStrictModeCallerIfNecessary(exec);
 
-    return JSObject::deleteProperty(exec, propertyName);
+    return JSObject::deleteProperty(thisObject, exec, propertyName);
 }
 
 } // namespace JSC
index f3df3fb..df6ac22 100644 (file)
@@ -133,7 +133,9 @@ namespace JSC {
         virtual void put(ExecState*, unsigned propertyName, JSValue);
         static void put(JSCell*, ExecState*, unsigned propertyName, JSValue);
         virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
+        static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
         virtual bool deleteProperty(ExecState*, unsigned propertyName);
+        static bool deleteProperty(JSCell*, ExecState*, unsigned propertyName);
         void createStrictModeCallerIfNecessary(ExecState*);
         void createStrictModeCalleeIfNecessary(ExecState*);
 
index b5add6c..22659e2 100644 (file)
@@ -201,10 +201,15 @@ void JSActivation::putWithAttributes(ExecState* exec, const Identifier& property
 
 bool JSActivation::deleteProperty(ExecState* exec, const Identifier& propertyName)
 {
+    return deleteProperty(this, exec, propertyName);
+}
+
+bool JSActivation::deleteProperty(JSCell* cell, ExecState* exec, const Identifier& propertyName)
+{
     if (propertyName == exec->propertyNames().arguments)
         return false;
 
-    return Base::deleteProperty(exec, propertyName);
+    return Base::deleteProperty(cell, exec, propertyName);
 }
 
 JSObject* JSActivation::toThisObject(ExecState* exec) const
index 8fbbf0d..48afec3 100644 (file)
@@ -69,6 +69,7 @@ namespace JSC {
 
         virtual void putWithAttributes(ExecState*, const Identifier&, JSValue, unsigned attributes);
         virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
+        static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
 
         virtual JSObject* toThisObject(ExecState*) const;
 
index ac6138b..b04662d 100644 (file)
@@ -497,32 +497,44 @@ NEVER_INLINE void JSArray::putSlowCase(ExecState* exec, unsigned i, JSValue valu
 
 bool JSArray::deleteProperty(ExecState* exec, const Identifier& propertyName)
 {
+    return deleteProperty(this, exec, propertyName);
+}
+
+bool JSArray::deleteProperty(JSCell* cell, ExecState* exec, const Identifier& propertyName)
+{
+    JSArray* thisObject = static_cast<JSArray*>(cell);
     bool isArrayIndex;
     unsigned i = propertyName.toArrayIndex(isArrayIndex);
     if (isArrayIndex)
-        return deleteProperty(exec, i);
+        return thisObject->deleteProperty(exec, i);
 
     if (propertyName == exec->propertyNames().length)
         return false;
 
-    return JSObject::deleteProperty(exec, propertyName);
+    return JSObject::deleteProperty(thisObject, exec, propertyName);
 }
 
 bool JSArray::deleteProperty(ExecState* exec, unsigned i)
 {
-    checkConsistency();
+    return deleteProperty(this, exec, i);
+}
 
-    ArrayStorage* storage = m_storage;
+bool JSArray::deleteProperty(JSCell* cell, ExecState* exec, unsigned i)
+{
+    JSArray* thisObject = static_cast<JSArray*>(cell);
+    thisObject->checkConsistency();
+
+    ArrayStorage* storage = thisObject->m_storage;
     
-    if (i < m_vectorLength) {
+    if (i < thisObject->m_vectorLength) {
         WriteBarrier<Unknown>& valueSlot = storage->m_vector[i];
         if (!valueSlot) {
-            checkConsistency();
+            thisObject->checkConsistency();
             return false;
         }
         valueSlot.clear();
         --storage->m_numValuesInVector;
-        checkConsistency();
+        thisObject->checkConsistency();
         return true;
     }
 
@@ -531,16 +543,16 @@ bool JSArray::deleteProperty(ExecState* exec, unsigned i)
             SparseArrayValueMap::iterator it = map->find(i);
             if (it != map->end()) {
                 map->remove(it);
-                checkConsistency();
+                thisObject->checkConsistency();
                 return true;
             }
         }
     }
 
-    checkConsistency();
+    thisObject->checkConsistency();
 
     if (i > MAX_ARRAY_INDEX)
-        return deleteProperty(exec, Identifier::from(exec, i));
+        return thisObject->deleteProperty(exec, Identifier::from(exec, i));
 
     return false;
 }
index 4523533..6770f52 100644 (file)
@@ -173,7 +173,9 @@ namespace JSC {
         static void put(JSCell*, ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
 
         virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
+        static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
         virtual bool deleteProperty(ExecState*, unsigned propertyName);
+        static bool deleteProperty(JSCell*, ExecState*, unsigned propertyName);
         virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
         static void visitChildren(JSCell*, SlotVisitor&);
 
index e5c117b..f5d5b9b 100644 (file)
@@ -110,12 +110,22 @@ void JSCell::put(JSCell* cell, ExecState* exec, unsigned identifier, JSValue val
 
 bool JSCell::deleteProperty(ExecState* exec, const Identifier& identifier)
 {
-    return toObject(exec, exec->lexicalGlobalObject())->deleteProperty(exec, identifier);
+    return deleteProperty(this, exec, identifier);
+}
+
+bool JSCell::deleteProperty(JSCell* cell, ExecState* exec, const Identifier& identifier)
+{
+    return cell->toObject(exec, exec->lexicalGlobalObject())->deleteProperty(exec, identifier);
 }
 
 bool JSCell::deleteProperty(ExecState* exec, unsigned identifier)
 {
-    return toObject(exec, exec->lexicalGlobalObject())->deleteProperty(exec, identifier);
+    return deleteProperty(this, exec, identifier);
+}
+
+bool JSCell::deleteProperty(JSCell* cell, ExecState* exec, unsigned identifier)
+{
+    return cell->toObject(exec, exec->lexicalGlobalObject())->deleteProperty(exec, identifier);
 }
 
 JSObject* JSCell::toThisObject(ExecState* exec) const
index fbb6563..24fe79f 100644 (file)
@@ -95,7 +95,9 @@ namespace JSC {
         static void put(JSCell*, ExecState*, unsigned propertyName, JSValue);
         
         virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
+        static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
         virtual bool deleteProperty(ExecState*, unsigned propertyName);
+        static bool deleteProperty(JSCell*, ExecState*, unsigned propertyName);
 
         virtual JSObject* toThisObject(ExecState*) const;
 
index d589296..4403c85 100644 (file)
@@ -329,11 +329,17 @@ void JSFunction::put(JSCell* cell, ExecState* exec, const Identifier& propertyNa
 
 bool JSFunction::deleteProperty(ExecState* exec, const Identifier& propertyName)
 {
-    if (isHostFunction())
-        return Base::deleteProperty(exec, propertyName);
+    return deleteProperty(this, exec, propertyName);
+}
+
+bool JSFunction::deleteProperty(JSCell* cell, ExecState* exec, const Identifier& propertyName)
+{
+    JSFunction* thisObject = static_cast<JSFunction*>(cell);
+    if (thisObject->isHostFunction())
+        return Base::deleteProperty(thisObject, exec, propertyName);
     if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length)
         return false;
-    return Base::deleteProperty(exec, propertyName);
+    return Base::deleteProperty(thisObject, exec, propertyName);
 }
 
 // ECMA 13.2.2 [[Construct]]
index 930b1b1..8863aa3 100644 (file)
@@ -145,6 +145,7 @@ namespace JSC {
         static void put(JSCell*, ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
 
         virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
+        static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
 
         static JSValue argumentsGetter(ExecState*, JSValue, const Identifier&);
         static JSValue callerGetter(ExecState*, JSValue, const Identifier&);
index b2cd606..db442fa 100644 (file)
@@ -96,13 +96,23 @@ void JSNotAnObject::put(JSCell*, ExecState* exec, unsigned, JSValue)
     ASSERT_UNUSED(exec, exec->hadException());
 }
 
-bool JSNotAnObject::deleteProperty(ExecState* exec, const Identifier&)
+bool JSNotAnObject::deleteProperty(ExecState* exec, const Identifier& propertyName)
+{
+    return deleteProperty(this, exec, propertyName);
+}
+
+bool JSNotAnObject::deleteProperty(JSCell*, ExecState* exec, const Identifier&)
 {
     ASSERT_UNUSED(exec, exec->hadException());
     return false;
 }
 
-bool JSNotAnObject::deleteProperty(ExecState* exec, unsigned)
+bool JSNotAnObject::deleteProperty(ExecState* exec, unsigned propertyName)
+{
+    return deleteProperty(this, exec, propertyName);
+}
+
+bool JSNotAnObject::deleteProperty(JSCell*, ExecState* exec, unsigned)
 {
     ASSERT_UNUSED(exec, exec->hadException());
     return false;
index 03b933c..13947d9 100644 (file)
@@ -81,7 +81,9 @@ namespace JSC {
         static void put(JSCell*, ExecState*, unsigned propertyName, JSValue);
 
         virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
+        static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
         virtual bool deleteProperty(ExecState*, unsigned propertyName);
+        static bool deleteProperty(JSCell*, ExecState*, unsigned propertyName);
 
         virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
     };
index b0dfd2e..c429674 100644 (file)
@@ -242,20 +242,26 @@ bool JSObject::hasProperty(ExecState* exec, unsigned propertyName) const
     return const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot);
 }
 
-// ECMA 8.6.2.5
 bool JSObject::deleteProperty(ExecState* exec, const Identifier& propertyName)
 {
+    return deleteProperty(this, exec, propertyName);
+}
+
+// ECMA 8.6.2.5
+bool JSObject::deleteProperty(JSCell* cell, ExecState* exec, const Identifier& propertyName)
+{
+    JSObject* thisObject = static_cast<JSObject*>(cell);
     unsigned attributes;
     JSCell* specificValue;
-    if (structure()->get(exec->globalData(), propertyName, attributes, specificValue) != WTF::notFound) {
+    if (thisObject->structure()->get(exec->globalData(), propertyName, attributes, specificValue) != WTF::notFound) {
         if ((attributes & DontDelete))
             return false;
-        removeDirect(exec->globalData(), propertyName);
+        thisObject->removeDirect(exec->globalData(), propertyName);
         return true;
     }
 
     // Look in the static hashtable of properties
-    const HashEntry* entry = findPropertyHashEntry(exec, propertyName);
+    const HashEntry* entry = thisObject->findPropertyHashEntry(exec, propertyName);
     if (entry && entry->attributes() & DontDelete)
         return false; // this builtin property can't be deleted
 
@@ -271,7 +277,12 @@ bool JSObject::hasOwnProperty(ExecState* exec, const Identifier& propertyName) c
 
 bool JSObject::deleteProperty(ExecState* exec, unsigned propertyName)
 {
-    return deleteProperty(exec, Identifier::from(exec, propertyName));
+    return deleteProperty(this, exec, propertyName);
+}
+
+bool JSObject::deleteProperty(JSCell* cell, ExecState* exec, unsigned propertyName)
+{
+    return static_cast<JSObject*>(cell)->deleteProperty(exec, Identifier::from(exec, propertyName));
 }
 
 static ALWAYS_INLINE JSValue callDefaultValueFunction(ExecState* exec, const JSObject* object, const Identifier& propertyName)
index 0a19386..308ce2b 100644 (file)
@@ -124,7 +124,9 @@ namespace JSC {
         bool hasOwnProperty(ExecState*, const Identifier& propertyName) const;
 
         virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
+        static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
         virtual bool deleteProperty(ExecState*, unsigned propertyName);
+        static bool deleteProperty(JSCell*, ExecState*, unsigned propertyName);
 
         virtual JSValue defaultValue(ExecState*, PreferredPrimitiveType) const;
 
index abe9bbb..d2238a2 100644 (file)
@@ -36,10 +36,16 @@ namespace JSC {
 
 bool JSVariableObject::deleteProperty(ExecState* exec, const Identifier& propertyName)
 {
-    if (symbolTable().contains(propertyName.impl()))
+    return deleteProperty(this, exec, propertyName);
+}
+
+bool JSVariableObject::deleteProperty(JSCell* cell, ExecState* exec, const Identifier& propertyName)
+{
+    JSVariableObject* thisObject = static_cast<JSVariableObject*>(cell);
+    if (thisObject->symbolTable().contains(propertyName.impl()))
         return false;
 
-    return JSObject::deleteProperty(exec, propertyName);
+    return JSObject::deleteProperty(thisObject, exec, propertyName);
 }
 
 void JSVariableObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
index c26dc7e..76d6a34 100644 (file)
@@ -51,6 +51,7 @@ namespace JSC {
         virtual void putWithAttributes(ExecState*, const Identifier&, JSValue, unsigned attributes) = 0;
 
         virtual bool deleteProperty(ExecState*, const Identifier&);
+        static bool deleteProperty(JSCell*, ExecState*, const Identifier&);
         virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
         
         virtual bool isVariableObject() const;
index 3a3375b..b61c4ec 100644 (file)
@@ -92,16 +92,28 @@ namespace JSC {
 
         virtual bool deleteProperty(ExecState* exec, const Identifier& propertyName)
         {
-            if (subclassData())
-                fillArrayInstance(exec);
-            return JSArray::deleteProperty(exec, propertyName);
+            return deleteProperty(this, exec, propertyName);
+        }
+
+        static bool deleteProperty(JSCell* cell, ExecState* exec, const Identifier& propertyName)
+        {
+            RegExpMatchesArray* thisObject = static_cast<RegExpMatchesArray*>(cell);
+            if (thisObject->subclassData())
+                thisObject->fillArrayInstance(exec);
+            return JSArray::deleteProperty(thisObject, exec, propertyName);
         }
 
         virtual bool deleteProperty(ExecState* exec, unsigned propertyName)
         {
-            if (subclassData())
-                fillArrayInstance(exec);
-            return JSArray::deleteProperty(exec, propertyName);
+            return deleteProperty(this, exec, propertyName);
+        }
+
+        static bool deleteProperty(JSCell* cell, ExecState* exec, unsigned propertyName)
+        {
+            RegExpMatchesArray* thisObject = static_cast<RegExpMatchesArray*>(cell);
+            if (thisObject->subclassData())
+                thisObject->fillArrayInstance(exec);
+            return JSArray::deleteProperty(thisObject, exec, propertyName);
         }
 
         virtual void getOwnPropertyNames(ExecState* exec, PropertyNameArray& arr, EnumerationMode mode = ExcludeDontEnumProperties)
index 3d62e14..e99cd69 100644 (file)
@@ -35,7 +35,12 @@ StrictEvalActivation::StrictEvalActivation(ExecState* exec)
 {
 }
 
-bool StrictEvalActivation::deleteProperty(ExecState*, const Identifier&)
+bool StrictEvalActivation::deleteProperty(ExecState* exec, const Identifier& identifier)
+{
+    return deleteProperty(this, exec, identifier);
+}
+
+bool StrictEvalActivation::deleteProperty(JSCell*, ExecState*, const Identifier&)
 {
     return false;
 }
index 087442f..f1d8d6f 100644 (file)
@@ -42,6 +42,7 @@ public:
     }
 
     virtual bool deleteProperty(ExecState*, const Identifier&);
+    static bool deleteProperty(JSCell*, ExecState*, const Identifier&);
     virtual JSObject* toThisObject(ExecState*) const;
 
     static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
index 62b1f3a..3800d46 100644 (file)
@@ -76,13 +76,19 @@ void StringObject::put(JSCell* cell, ExecState* exec, const Identifier& property
 
 bool StringObject::deleteProperty(ExecState* exec, const Identifier& propertyName)
 {
+    return deleteProperty(this, exec, propertyName);
+}
+
+bool StringObject::deleteProperty(JSCell* cell, ExecState* exec, const Identifier& propertyName)
+{
+    StringObject* thisObject = static_cast<StringObject*>(cell);
     if (propertyName == exec->propertyNames().length)
         return false;
     bool isStrictUInt32;
     unsigned i = propertyName.toUInt32(isStrictUInt32);
-    if (isStrictUInt32 && internalValue()->canGetIndex(i))
+    if (isStrictUInt32 && thisObject->internalValue()->canGetIndex(i))
         return false;
-    return JSObject::deleteProperty(exec, propertyName);
+    return JSObject::deleteProperty(thisObject, exec, propertyName);
 }
 
 void StringObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
index 16d99b6..6dab5cc 100644 (file)
@@ -54,6 +54,7 @@ namespace JSC {
         static void put(JSCell*, ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
 
         virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
+        static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
         virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
 
         static const JS_EXPORTDATA ClassInfo s_info;
index 3fd025b..7f5feca 100644 (file)
@@ -1,3 +1,26 @@
+2011-10-07  Mark Hahnenberg  <mhahnenberg@apple.com>
+
+        Add static version of JSCell::deleteProperty
+        https://bugs.webkit.org/show_bug.cgi?id=69659
+
+        Reviewed by Geoffrey Garen.
+
+        No new tests.
+
+        Added static version of both versions of put to all classes that 
+        override them and changed the virtual versions to call the static 
+        versions.  This is the first step in de-virtualizing JSCell::deleteProperty.
+
+        * bridge/objc/objc_runtime.h:
+        * bridge/objc/objc_runtime.mm:
+        (JSC::Bindings::ObjcFallbackObjectImp::deleteProperty):
+        * bridge/runtime_array.cpp:
+        (JSC::RuntimeArray::deleteProperty):
+        * bridge/runtime_array.h:
+        * bridge/runtime_object.cpp:
+        (JSC::Bindings::RuntimeObject::deleteProperty):
+        * bridge/runtime_object.h:
+
 2011-10-07  Justin Schuh  <jschuh@chromium.org>
 
         Make isXMLMIMEType regex use TLS
index f1e02c3..ec7ae6f 100644 (file)
@@ -129,6 +129,7 @@ private:
     static void put(JSCell*, ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
     static CallType getCallData(JSCell*, CallData&);
     virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
+    static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
     virtual JSValue defaultValue(ExecState*, PreferredPrimitiveType) const;
 
     virtual bool toBoolean(ExecState*) const;
index 0b8fb57..2fe4460 100644 (file)
@@ -269,7 +269,12 @@ CallType ObjcFallbackObjectImp::getCallData(JSCell* cell, CallData& callData)
     return CallTypeHost;
 }
 
-bool ObjcFallbackObjectImp::deleteProperty(ExecState*, const Identifier&)
+bool ObjcFallbackObjectImp::deleteProperty(ExecState* exec, const Identifier& identifier)
+{
+    return deleteProperty(this, exec, identifier);
+}
+
+bool ObjcFallbackObjectImp::deleteProperty(JSCell*, ExecState*, const Identifier&)
 {
     return false;
 }
index 0dd4b68..c6d1e9c 100644 (file)
@@ -169,12 +169,22 @@ void RuntimeArray::put(JSCell* cell, ExecState* exec, unsigned index, JSValue va
     thisObject->getConcreteArray()->setValueAt(exec, index, value);
 }
 
-bool RuntimeArray::deleteProperty(ExecState*, const Identifier&)
+bool RuntimeArray::deleteProperty(ExecState* exec, const Identifier& propertyName)
+{
+    return deleteProperty(this, exec, propertyName);
+}
+
+bool RuntimeArray::deleteProperty(JSCell*, ExecState*, const Identifier&)
 {
     return false;
 }
 
-bool RuntimeArray::deleteProperty(ExecState*, unsigned)
+bool RuntimeArray::deleteProperty(ExecState* exec, unsigned propertyName)
+{
+    return deleteProperty(this, exec, propertyName);
+}
+
+bool RuntimeArray::deleteProperty(JSCell*, ExecState*, unsigned)
 {
     return false;
 }
index 2955743..532b9d7 100644 (file)
@@ -59,7 +59,9 @@ public:
     static void put(JSCell*, ExecState*, unsigned propertyName, JSValue);
     
     virtual bool deleteProperty(ExecState* exec, const Identifier &propertyName);
+    static bool deleteProperty(JSCell*, ExecState*, const Identifier &propertyName);
     virtual bool deleteProperty(ExecState* exec, unsigned propertyName);
+    static bool deleteProperty(JSCell*, ExecState*, unsigned propertyName);
     
     unsigned getLength() const { return getConcreteArray()->getLength(); }
     
index ffaa20c..baca351 100644 (file)
@@ -236,7 +236,12 @@ void RuntimeObject::put(JSCell* cell, ExecState* exec, const Identifier& propert
     instance->end();
 }
 
-bool RuntimeObject::deleteProperty(ExecState*, const Identifier&)
+bool RuntimeObject::deleteProperty(ExecState* exec, const Identifier& propertyName)
+{
+    return deleteProperty(this, exec, propertyName);
+}
+
+bool RuntimeObject::deleteProperty(JSCell*, ExecState*, const Identifier&)
 {
     // Can never remove a property of a RuntimeObject.
     return false;
index f5d9828..8c43107 100644 (file)
@@ -50,6 +50,7 @@ public:
     virtual void put(ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
     static void put(JSCell*, ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
     virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
+    static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
     virtual JSValue defaultValue(ExecState*, PreferredPrimitiveType) const;
     static CallType getCallData(JSCell*, CallData&);
     virtual ConstructType getConstructData(ConstructData&);