Stop using fastNew/fastDelete in JavaScriptCore
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Sep 2013 22:32:08 +0000 (22:32 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Sep 2013 22:32:08 +0000 (22:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=120898

Reviewed by Oliver Hunt.

Source/JavaScriptCore:

Change all the hash table members in ExecState to be OwnPtrs and use
adoptPtr instead. Also, since none of the hash tables can be null, change their getters
to return references and propagate the reference types wherever we know that a HashTable can't be null.

* interpreter/CallFrame.h:
(JSC::ExecState::arrayConstructorTable):
(JSC::ExecState::arrayPrototypeTable):
(JSC::ExecState::booleanPrototypeTable):
(JSC::ExecState::dataViewTable):
(JSC::ExecState::dateTable):
(JSC::ExecState::dateConstructorTable):
(JSC::ExecState::errorPrototypeTable):
(JSC::ExecState::globalObjectTable):
(JSC::ExecState::jsonTable):
(JSC::ExecState::numberConstructorTable):
(JSC::ExecState::numberPrototypeTable):
(JSC::ExecState::objectConstructorTable):
(JSC::ExecState::privateNamePrototypeTable):
(JSC::ExecState::regExpTable):
(JSC::ExecState::regExpConstructorTable):
(JSC::ExecState::regExpPrototypeTable):
(JSC::ExecState::stringConstructorTable):
(JSC::ExecState::promisePrototypeTable):
(JSC::ExecState::promiseConstructorTable):
(JSC::ExecState::promiseResolverPrototypeTable):
* runtime/ClassInfo.h:
(JSC::ClassInfo::propHashTable):
* runtime/Lookup.h:
(JSC::getStaticPropertySlot):
(JSC::getStaticFunctionSlot):
(JSC::getStaticValueSlot):
(JSC::lookupPut):
* runtime/VM.cpp:
(JSC::VM::VM):
(JSC::VM::~VM):
* runtime/VM.h:

Source/WebCore:

Update for changes to JavaScriptCore.

* bindings/js/DOMObjectHashTableMap.h:
(WebCore::DOMObjectHashTableMap::get):
* bindings/js/JSDOMBinding.cpp:
(WebCore::getHashTableForGlobalData):
* bindings/js/JSDOMBinding.h:
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::put):
* bindings/js/JSPluginElementFunctions.h:
(WebCore::pluginElementCustomGetOwnPropertySlot):
* bindings/js/JSStorageCustom.cpp:
(WebCore::JSStorage::deleteProperty):
(WebCore::JSStorage::putDelegate):
* bindings/scripts/CodeGeneratorJS.pm:
(hashTableAccessor):
(prototypeHashTableAccessor):
(constructorHashTableAccessor):
(GenerateGetOwnPropertySlotBody):
(GenerateImplementation):
(GenerateConstructorHelperMethods):

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

14 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/interpreter/CallFrame.h
Source/JavaScriptCore/runtime/ClassInfo.h
Source/JavaScriptCore/runtime/Lookup.h
Source/JavaScriptCore/runtime/VM.cpp
Source/JavaScriptCore/runtime/VM.h
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/DOMObjectHashTableMap.h
Source/WebCore/bindings/js/JSDOMBinding.cpp
Source/WebCore/bindings/js/JSDOMBinding.h
Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
Source/WebCore/bindings/js/JSPluginElementFunctions.h
Source/WebCore/bindings/js/JSStorageCustom.cpp
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

index 39dc8b3..607a2cd 100644 (file)
@@ -1,3 +1,47 @@
+2013-09-06  Anders Carlsson  <andersca@apple.com>
+
+        Stop using fastNew/fastDelete in JavaScriptCore
+        https://bugs.webkit.org/show_bug.cgi?id=120898
+
+        Reviewed by Oliver Hunt.
+
+        Change all the hash table members in ExecState to be OwnPtrs and use
+        adoptPtr instead. Also, since none of the hash tables can be null, change their getters
+        to return references and propagate the reference types wherever we know that a HashTable can't be null.
+
+        * interpreter/CallFrame.h:
+        (JSC::ExecState::arrayConstructorTable):
+        (JSC::ExecState::arrayPrototypeTable):
+        (JSC::ExecState::booleanPrototypeTable):
+        (JSC::ExecState::dataViewTable):
+        (JSC::ExecState::dateTable):
+        (JSC::ExecState::dateConstructorTable):
+        (JSC::ExecState::errorPrototypeTable):
+        (JSC::ExecState::globalObjectTable):
+        (JSC::ExecState::jsonTable):
+        (JSC::ExecState::numberConstructorTable):
+        (JSC::ExecState::numberPrototypeTable):
+        (JSC::ExecState::objectConstructorTable):
+        (JSC::ExecState::privateNamePrototypeTable):
+        (JSC::ExecState::regExpTable):
+        (JSC::ExecState::regExpConstructorTable):
+        (JSC::ExecState::regExpPrototypeTable):
+        (JSC::ExecState::stringConstructorTable):
+        (JSC::ExecState::promisePrototypeTable):
+        (JSC::ExecState::promiseConstructorTable):
+        (JSC::ExecState::promiseResolverPrototypeTable):
+        * runtime/ClassInfo.h:
+        (JSC::ClassInfo::propHashTable):
+        * runtime/Lookup.h:
+        (JSC::getStaticPropertySlot):
+        (JSC::getStaticFunctionSlot):
+        (JSC::getStaticValueSlot):
+        (JSC::lookupPut):
+        * runtime/VM.cpp:
+        (JSC::VM::VM):
+        (JSC::VM::~VM):
+        * runtime/VM.h:
+
 2013-09-06  Filip Pizlo  <fpizlo@apple.com>
 
         Concurrent FTL causes !hasOptimizedReplacement() asserts in cti_optimize
index d6c02ff..a122164 100644 (file)
@@ -84,27 +84,27 @@ namespace JSC  {
 #ifndef NDEBUG
         void dumpCaller();
 #endif
-        static const HashTable* arrayConstructorTable(CallFrame* callFrame) { return callFrame->vm().arrayConstructorTable; }
-        static const HashTable* arrayPrototypeTable(CallFrame* callFrame) { return callFrame->vm().arrayPrototypeTable; }
-        static const HashTable* booleanPrototypeTable(CallFrame* callFrame) { return callFrame->vm().booleanPrototypeTable; }
-        static const HashTable* dataViewTable(CallFrame* callFrame) { return callFrame->vm().dataViewTable; }
-        static const HashTable* dateTable(CallFrame* callFrame) { return callFrame->vm().dateTable; }
-        static const HashTable* dateConstructorTable(CallFrame* callFrame) { return callFrame->vm().dateConstructorTable; }
-        static const HashTable* errorPrototypeTable(CallFrame* callFrame) { return callFrame->vm().errorPrototypeTable; }
-        static const HashTable* globalObjectTable(CallFrame* callFrame) { return callFrame->vm().globalObjectTable; }
-        static const HashTable* jsonTable(CallFrame* callFrame) { return callFrame->vm().jsonTable; }
-        static const HashTable* numberConstructorTable(CallFrame* callFrame) { return callFrame->vm().numberConstructorTable; }
-        static const HashTable* numberPrototypeTable(CallFrame* callFrame) { return callFrame->vm().numberPrototypeTable; }
-        static const HashTable* objectConstructorTable(CallFrame* callFrame) { return callFrame->vm().objectConstructorTable; }
-        static const HashTable* privateNamePrototypeTable(CallFrame* callFrame) { return callFrame->vm().privateNamePrototypeTable; }
-        static const HashTable* regExpTable(CallFrame* callFrame) { return callFrame->vm().regExpTable; }
-        static const HashTable* regExpConstructorTable(CallFrame* callFrame) { return callFrame->vm().regExpConstructorTable; }
-        static const HashTable* regExpPrototypeTable(CallFrame* callFrame) { return callFrame->vm().regExpPrototypeTable; }
-        static const HashTable* stringConstructorTable(CallFrame* callFrame) { return callFrame->vm().stringConstructorTable; }
+        static const HashTable& arrayConstructorTable(CallFrame* callFrame) { return *callFrame->vm().arrayConstructorTable; }
+        static const HashTable& arrayPrototypeTable(CallFrame* callFrame) { return *callFrame->vm().arrayPrototypeTable; }
+        static const HashTable& booleanPrototypeTable(CallFrame* callFrame) { return *callFrame->vm().booleanPrototypeTable; }
+        static const HashTable& dataViewTable(CallFrame* callFrame) { return *callFrame->vm().dataViewTable; }
+        static const HashTable& dateTable(CallFrame* callFrame) { return *callFrame->vm().dateTable; }
+        static const HashTable& dateConstructorTable(CallFrame* callFrame) { return *callFrame->vm().dateConstructorTable; }
+        static const HashTable& errorPrototypeTable(CallFrame* callFrame) { return *callFrame->vm().errorPrototypeTable; }
+        static const HashTable& globalObjectTable(CallFrame* callFrame) { return *callFrame->vm().globalObjectTable; }
+        static const HashTable& jsonTable(CallFrame* callFrame) { return *callFrame->vm().jsonTable; }
+        static const HashTable& numberConstructorTable(CallFrame* callFrame) { return *callFrame->vm().numberConstructorTable; }
+        static const HashTable& numberPrototypeTable(CallFrame* callFrame) { return *callFrame->vm().numberPrototypeTable; }
+        static const HashTable& objectConstructorTable(CallFrame* callFrame) { return *callFrame->vm().objectConstructorTable; }
+        static const HashTable& privateNamePrototypeTable(CallFrame* callFrame) { return *callFrame->vm().privateNamePrototypeTable; }
+        static const HashTable& regExpTable(CallFrame* callFrame) { return *callFrame->vm().regExpTable; }
+        static const HashTable& regExpConstructorTable(CallFrame* callFrame) { return *callFrame->vm().regExpConstructorTable; }
+        static const HashTable& regExpPrototypeTable(CallFrame* callFrame) { return *callFrame->vm().regExpPrototypeTable; }
+        static const HashTable& stringConstructorTable(CallFrame* callFrame) { return *callFrame->vm().stringConstructorTable; }
 #if ENABLE(PROMISES)
-        static const HashTable* promisePrototypeTable(CallFrame* callFrame) { return callFrame->vm().promisePrototypeTable; }
-        static const HashTable* promiseConstructorTable(CallFrame* callFrame) { return callFrame->vm().promiseConstructorTable; }
-        static const HashTable* promiseResolverPrototypeTable(CallFrame* callFrame) { return callFrame->vm().promiseResolverPrototypeTable; }
+        static const HashTable& promisePrototypeTable(CallFrame* callFrame) { return *callFrame->vm().promisePrototypeTable; }
+        static const HashTable& promiseConstructorTable(CallFrame* callFrame) { return *callFrame->vm().promiseConstructorTable; }
+        static const HashTable& promiseResolverPrototypeTable(CallFrame* callFrame) { return *callFrame->vm().promiseResolverPrototypeTable; }
 #endif
 
         static CallFrame* create(Register* callFrameBase) { return static_cast<CallFrame*>(callFrameBase); }
index edd2cd8..f0de0bd 100644 (file)
@@ -144,24 +144,21 @@ struct MethodTable {
     ClassName::TypedArrayStorageType
 
 struct ClassInfo {
-    /**
-     * A string denoting the class name. Example: "Window".
-     */
+    // A string denoting the class name. Example: "Window".
     const char* className;
 
-    /**
-     * Pointer to the class information of the base class.
-     * 0L if there is none.
-     */
+    // Pointer to the class information of the base class.
+    // nullptrif there is none.
     const ClassInfo* parentClass;
-    /**
-     * Static hash-table of properties.
-     * For classes that can be used from multiple threads, it is accessed via a getter function that would typically return a pointer to thread-specific value.
-     */
+
+    // Static hash-table of properties.
+    // For classes that can be used from multiple threads, it is accessed via a getter function
+    // that would typically return a pointer to a thread-specific value.
     const HashTable* propHashTable(ExecState* exec) const
     {
         if (classPropHashTableGetterFunction)
-            return classPropHashTableGetterFunction(exec);
+            return &classPropHashTableGetterFunction(exec);
+
         return staticPropHashTable;
     }
         
@@ -184,7 +181,7 @@ struct ClassInfo {
     }
 
     const HashTable* staticPropHashTable;
-    typedef const HashTable* (*ClassPropHashTableGetterFunction)(ExecState*);
+    typedef const HashTable& (*ClassPropHashTableGetterFunction)(ExecState*);
     const ClassPropHashTableGetterFunction classPropHashTableGetterFunction;
 
     MethodTable methodTable;
index 5ee998f..5790305 100644 (file)
@@ -241,9 +241,9 @@ namespace JSC {
      * unknown property).
      */
     template <class ThisImp, class ParentImp>
-    inline bool getStaticPropertySlot(ExecState* exec, const HashTable* table, ThisImp* thisObj, PropertyName propertyName, PropertySlot& slot)
+    inline bool getStaticPropertySlot(ExecState* exec, const HashTable& table, ThisImp* thisObj, PropertyName propertyName, PropertySlot& slot)
     {
-        const HashEntry* entry = table->entry(exec, propertyName);
+        const HashEntry* entry = table.entry(exec, propertyName);
 
         if (!entry) // not found, forward to parent
             return ParentImp::getOwnPropertySlot(thisObj, exec, propertyName, slot);
@@ -261,12 +261,12 @@ namespace JSC {
      * a dummy getValueProperty.
      */
     template <class ParentImp>
-    inline bool getStaticFunctionSlot(ExecState* exec, const HashTable* table, JSObject* thisObj, PropertyName propertyName, PropertySlot& slot)
+    inline bool getStaticFunctionSlot(ExecState* exec, const HashTable& table, JSObject* thisObj, PropertyName propertyName, PropertySlot& slot)
     {
         if (ParentImp::getOwnPropertySlot(thisObj, exec, propertyName, slot))
             return true;
 
-        const HashEntry* entry = table->entry(exec, propertyName);
+        const HashEntry* entry = table.entry(exec, propertyName);
         if (!entry)
             return false;
 
@@ -278,9 +278,9 @@ namespace JSC {
      * Using this instead of getStaticPropertySlot removes the need for a FuncImp class.
      */
     template <class ThisImp, class ParentImp>
-    inline bool getStaticValueSlot(ExecState* exec, const HashTable* table, ThisImp* thisObj, PropertyName propertyName, PropertySlot& slot)
+    inline bool getStaticValueSlot(ExecState* exec, const HashTable& table, ThisImp* thisObj, PropertyName propertyName, PropertySlot& slot)
     {
-        const HashEntry* entry = table->entry(exec, propertyName);
+        const HashEntry* entry = table.entry(exec, propertyName);
 
         if (!entry) // not found, forward to parent
             return ParentImp::getOwnPropertySlot(thisObj, exec, propertyName, slot);
@@ -309,9 +309,9 @@ namespace JSC {
      * is found it sets the value and returns true, else it returns false.
      */
     template <class ThisImp>
-    inline bool lookupPut(ExecState* exec, PropertyName propertyName, JSValue value, const HashTable* table, ThisImp* thisObj, bool shouldThrow = false)
+    inline bool lookupPut(ExecState* exec, PropertyName propertyName, JSValue value, const HashTable& table, ThisImp* thisObj, bool shouldThrow = false)
     {
-        const HashEntry* entry = table->entry(exec, propertyName);
+        const HashEntry* entry = table.entry(exec, propertyName);
         
         if (!entry)
             return false;
@@ -327,7 +327,7 @@ namespace JSC {
      * then it calls put() on the ParentImp class.
      */
     template <class ThisImp, class ParentImp>
-    inline void lookupPut(ExecState* exec, PropertyName propertyName, JSValue value, const HashTable* table, ThisImp* thisObj, PutPropertySlot& slot)
+    inline void lookupPut(ExecState* exec, PropertyName propertyName, JSValue value, const HashTable& table, ThisImp* thisObj, PutPropertySlot& slot)
     {
         if (!lookupPut<ThisImp>(exec, propertyName, value, table, thisObj, slot.isStrictMode()))
             ParentImp::put(thisObj, exec, propertyName, value, slot); // not found: forward to parent
index 9beeb2f..974d39b 100644 (file)
@@ -155,27 +155,27 @@ VM::VM(VMType vmType, HeapType heapType)
     , vmType(vmType)
     , clientData(0)
     , topCallFrame(CallFrame::noCaller()->removeHostCallFrameFlag())
-    , arrayConstructorTable(fastNew<HashTable>(JSC::arrayConstructorTable))
-    , arrayPrototypeTable(fastNew<HashTable>(JSC::arrayPrototypeTable))
-    , booleanPrototypeTable(fastNew<HashTable>(JSC::booleanPrototypeTable))
-    , dataViewTable(fastNew<HashTable>(JSC::dataViewTable))
-    , dateTable(fastNew<HashTable>(JSC::dateTable))
-    , dateConstructorTable(fastNew<HashTable>(JSC::dateConstructorTable))
-    , errorPrototypeTable(fastNew<HashTable>(JSC::errorPrototypeTable))
-    , globalObjectTable(fastNew<HashTable>(JSC::globalObjectTable))
-    , jsonTable(fastNew<HashTable>(JSC::jsonTable))
-    , numberConstructorTable(fastNew<HashTable>(JSC::numberConstructorTable))
-    , numberPrototypeTable(fastNew<HashTable>(JSC::numberPrototypeTable))
-    , objectConstructorTable(fastNew<HashTable>(JSC::objectConstructorTable))
-    , privateNamePrototypeTable(fastNew<HashTable>(JSC::privateNamePrototypeTable))
-    , regExpTable(fastNew<HashTable>(JSC::regExpTable))
-    , regExpConstructorTable(fastNew<HashTable>(JSC::regExpConstructorTable))
-    , regExpPrototypeTable(fastNew<HashTable>(JSC::regExpPrototypeTable))
-    , stringConstructorTable(fastNew<HashTable>(JSC::stringConstructorTable))
+    , arrayConstructorTable(adoptPtr(new HashTable(JSC::arrayConstructorTable)))
+    , arrayPrototypeTable(adoptPtr(new HashTable(JSC::arrayPrototypeTable)))
+    , booleanPrototypeTable(adoptPtr(new HashTable(JSC::booleanPrototypeTable)))
+    , dataViewTable(adoptPtr(new HashTable(JSC::dataViewTable)))
+    , dateTable(adoptPtr(new HashTable(JSC::dateTable)))
+    , dateConstructorTable(adoptPtr(new HashTable(JSC::dateConstructorTable)))
+    , errorPrototypeTable(adoptPtr(new HashTable(JSC::errorPrototypeTable)))
+    , globalObjectTable(adoptPtr(new HashTable(JSC::globalObjectTable)))
+    , jsonTable(adoptPtr(new HashTable(JSC::jsonTable)))
+    , numberConstructorTable(adoptPtr(new HashTable(JSC::numberConstructorTable)))
+    , numberPrototypeTable(adoptPtr(new HashTable(JSC::numberPrototypeTable)))
+    , objectConstructorTable(adoptPtr(new HashTable(JSC::objectConstructorTable)))
+    , privateNamePrototypeTable(adoptPtr(new HashTable(JSC::privateNamePrototypeTable)))
+    , regExpTable(adoptPtr(new HashTable(JSC::regExpTable)))
+    , regExpConstructorTable(adoptPtr(new HashTable(JSC::regExpConstructorTable)))
+    , regExpPrototypeTable(adoptPtr(new HashTable(JSC::regExpPrototypeTable)))
+    , stringConstructorTable(adoptPtr(new HashTable(JSC::stringConstructorTable)))
 #if ENABLE(PROMISES)
-    , promisePrototypeTable(fastNew<HashTable>(JSC::promisePrototypeTable))
-    , promiseConstructorTable(fastNew<HashTable>(JSC::promiseConstructorTable))
-    , promiseResolverPrototypeTable(fastNew<HashTable>(JSC::promiseResolverPrototypeTable))
+    , promisePrototypeTable(adoptPtr(new HashTable(JSC::promisePrototypeTable)))
+    , promiseConstructorTable(adoptPtr(new HashTable(JSC::promiseConstructorTable)))
+    , promiseResolverPrototypeTable(adoptPtr(new HashTable(JSC::promiseResolverPrototypeTable)))
 #endif
     , identifierTable(vmType == Default ? wtfThreadData().currentIdentifierTable() : createIdentifierTable())
     , propertyNames(new CommonIdentifiers(this))
@@ -332,29 +332,6 @@ VM::~VM()
     promiseResolverPrototypeTable->deleteTable();
 #endif
 
-    fastDelete(const_cast<HashTable*>(arrayConstructorTable));
-    fastDelete(const_cast<HashTable*>(arrayPrototypeTable));
-    fastDelete(const_cast<HashTable*>(booleanPrototypeTable));
-    fastDelete(const_cast<HashTable*>(dataViewTable));
-    fastDelete(const_cast<HashTable*>(dateTable));
-    fastDelete(const_cast<HashTable*>(dateConstructorTable));
-    fastDelete(const_cast<HashTable*>(errorPrototypeTable));
-    fastDelete(const_cast<HashTable*>(globalObjectTable));
-    fastDelete(const_cast<HashTable*>(jsonTable));
-    fastDelete(const_cast<HashTable*>(numberConstructorTable));
-    fastDelete(const_cast<HashTable*>(numberPrototypeTable));
-    fastDelete(const_cast<HashTable*>(objectConstructorTable));
-    fastDelete(const_cast<HashTable*>(privateNamePrototypeTable));
-    fastDelete(const_cast<HashTable*>(regExpTable));
-    fastDelete(const_cast<HashTable*>(regExpConstructorTable));
-    fastDelete(const_cast<HashTable*>(regExpPrototypeTable));
-    fastDelete(const_cast<HashTable*>(stringConstructorTable));
-#if ENABLE(PROMISES)
-    fastDelete(const_cast<HashTable*>(promisePrototypeTable));
-    fastDelete(const_cast<HashTable*>(promiseConstructorTable));
-    fastDelete(const_cast<HashTable*>(promiseResolverPrototypeTable));
-#endif
-
     delete emptyList;
 
     delete propertyNames;
index ac6f8ed..875f326 100644 (file)
@@ -222,27 +222,27 @@ namespace JSC {
         ExecState* topCallFrame;
         Watchdog watchdog;
 
-        const HashTable* arrayConstructorTable;
-        const HashTable* arrayPrototypeTable;
-        const HashTable* booleanPrototypeTable;
-        const HashTable* dataViewTable;
-        const HashTable* dateTable;
-        const HashTable* dateConstructorTable;
-        const HashTable* errorPrototypeTable;
-        const HashTable* globalObjectTable;
-        const HashTable* jsonTable;
-        const HashTable* numberConstructorTable;
-        const HashTable* numberPrototypeTable;
-        const HashTable* objectConstructorTable;
-        const HashTable* privateNamePrototypeTable;
-        const HashTable* regExpTable;
-        const HashTable* regExpConstructorTable;
-        const HashTable* regExpPrototypeTable;
-        const HashTable* stringConstructorTable;
+        const OwnPtr<const HashTable> arrayConstructorTable;
+        const OwnPtr<const HashTable> arrayPrototypeTable;
+        const OwnPtr<const HashTable> booleanPrototypeTable;
+        const OwnPtr<const HashTable> dataViewTable;
+        const OwnPtr<const HashTable> dateTable;
+        const OwnPtr<const HashTable> dateConstructorTable;
+        const OwnPtr<const HashTable> errorPrototypeTable;
+        const OwnPtr<const HashTable> globalObjectTable;
+        const OwnPtr<const HashTable> jsonTable;
+        const OwnPtr<const HashTable> numberConstructorTable;
+        const OwnPtr<const HashTable> numberPrototypeTable;
+        const OwnPtr<const HashTable> objectConstructorTable;
+        const OwnPtr<const HashTable> privateNamePrototypeTable;
+        const OwnPtr<const HashTable> regExpTable;
+        const OwnPtr<const HashTable> regExpConstructorTable;
+        const OwnPtr<const HashTable> regExpPrototypeTable;
+        const OwnPtr<const HashTable> stringConstructorTable;
 #if ENABLE(PROMISES)
-        const HashTable* promisePrototypeTable;
-        const HashTable* promiseConstructorTable;
-        const HashTable* promiseResolverPrototypeTable;
+        const OwnPtr<const HashTable> promisePrototypeTable;
+        const OwnPtr<const HashTable> promiseConstructorTable;
+        const OwnPtr<const HashTable> promiseResolverPrototypeTable;
 #endif
 
         Strong<Structure> structureStructure;
index 50d4aa0..86d6b75 100644 (file)
@@ -1,3 +1,32 @@
+2013-09-06  Anders Carlsson  <andersca@apple.com>
+
+        Stop using fastNew/fastDelete in JavaScriptCore
+        https://bugs.webkit.org/show_bug.cgi?id=120898
+
+        Reviewed by Oliver Hunt.
+
+        Update for changes to JavaScriptCore.
+
+        * bindings/js/DOMObjectHashTableMap.h:
+        (WebCore::DOMObjectHashTableMap::get):
+        * bindings/js/JSDOMBinding.cpp:
+        (WebCore::getHashTableForGlobalData):
+        * bindings/js/JSDOMBinding.h:
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::JSDOMWindow::put):
+        * bindings/js/JSPluginElementFunctions.h:
+        (WebCore::pluginElementCustomGetOwnPropertySlot):
+        * bindings/js/JSStorageCustom.cpp:
+        (WebCore::JSStorage::deleteProperty):
+        (WebCore::JSStorage::putDelegate):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (hashTableAccessor):
+        (prototypeHashTableAccessor):
+        (constructorHashTableAccessor):
+        (GenerateGetOwnPropertySlotBody):
+        (GenerateImplementation):
+        (GenerateConstructorHelperMethods):
+
 2013-09-06  Andreas Kling  <akling@apple.com>
 
         Include Frame.h in fewer places.
index a3a0a2a..13bf207 100644 (file)
@@ -42,12 +42,12 @@ public:
             iter->value.deleteTable();
     }
 
-    const JSC::HashTable* get(const JSC::HashTable* staticTable)
+    const JSC::HashTable& get(const JSC::HashTable& staticTable)
     {
-        HashMap<const JSC::HashTable*, JSC::HashTable>::iterator iter = m_map.find(staticTable);
+        HashMap<const JSC::HashTable*, JSC::HashTable>::iterator iter = m_map.find(&staticTable);
         if (iter != m_map.end())
-            return &iter->value;
-        return &m_map.set(staticTable, staticTable->copy()).iterator->value;
+            return iter->value;
+        return m_map.set(&staticTable, staticTable.copy()).iterator->value;
     }
 
 private:
index 216a7d8..6a5f14f 100644 (file)
@@ -48,7 +48,7 @@ namespace WebCore {
 STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(DOMConstructorObject);
 STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(DOMConstructorWithDocument);
 
-const JSC::HashTable* getHashTableForGlobalData(VM& vm, const JSC::HashTable* staticTable)
+const JSC::HashTable& getHashTableForGlobalData(VM& vm, const JSC::HashTable& staticTable)
 {
     return DOMObjectHashTableMap::mapFor(vm).get(staticTable);
 }
index b05bb9f..6f07f42 100644 (file)
@@ -257,7 +257,7 @@ class DOMStringList;
         return index >= exec->argumentCount() ? JSC::JSValue() : exec->argument(index);
     }
 
-    const JSC::HashTable* getHashTableForGlobalData(JSC::VM&, const JSC::HashTable* staticTable);
+    const JSC::HashTable& getHashTableForGlobalData(JSC::VM&, const JSC::HashTable& staticTable);
 
     void reportException(JSC::ExecState*, JSC::JSValue exception, CachedScript* = 0);
     void reportCurrentException(JSC::ExecState*);
index 0e688a1..1afd17d 100644 (file)
@@ -344,7 +344,7 @@ void JSDOMWindow::put(JSCell* cell, ExecState* exec, PropertyName propertyName,
         return;
     }
 
-    if (lookupPut<JSDOMWindow>(exec, propertyName, value, s_info.propHashTable(exec), thisObject))
+    if (lookupPut<JSDOMWindow>(exec, propertyName, value, *s_info.propHashTable(exec), thisObject))
         return;
 
     if (BindingSecurity::shouldAllowAccessToDOMWindow(exec, thisObject->impl()))
index e2a52df..138c60c 100644 (file)
@@ -46,7 +46,7 @@ namespace WebCore {
     template <class Type, class Base> bool pluginElementCustomGetOwnPropertySlot(JSC::ExecState* exec, JSC::PropertyName propertyName, JSC::PropertySlot& slot, Type* element)
     {
         if (!element->globalObject()->world()->isNormal()) {
-            if (JSC::getStaticValueSlot<Type, Base>(exec, Type::info()->staticPropHashTable, element, propertyName, slot))
+            if (JSC::getStaticValueSlot<Type, Base>(exec, *Type::info()->staticPropHashTable, element, propertyName, slot))
                 return true;
 
             JSC::JSValue proto = element->prototype();
index 19a39c8..3014821 100644 (file)
@@ -63,7 +63,7 @@ bool JSStorage::deleteProperty(JSCell* cell, ExecState* exec, PropertyName prope
     // Since hasProperty() would end up calling canGetItemsForName() and be fooled, we need to check
     // the native property slots manually.
     PropertySlot slot(thisObject);
-    if (getStaticValueSlot<JSStorage, Base>(exec, s_info.propHashTable(exec), thisObject, propertyName, slot))
+    if (getStaticValueSlot<JSStorage, Base>(exec, *s_info.propHashTable(exec), thisObject, propertyName, slot))
         return false;
         
     JSValue prototype = thisObject->prototype();
@@ -105,7 +105,7 @@ bool JSStorage::putDelegate(ExecState* exec, PropertyName propertyName, JSValue
     // Since hasProperty() would end up calling canGetItemsForName() and be fooled, we need to check
     // the native property slots manually.
     PropertySlot slot(this);
-    if (getStaticValueSlot<JSStorage, Base>(exec, s_info.propHashTable(exec), this, propertyName, slot))
+    if (getStaticValueSlot<JSStorage, Base>(exec, *s_info.propHashTable(exec), this, propertyName, slot))
         return false;
         
     JSValue prototype = this->prototype();
index 579516d..36c888a 100644 (file)
@@ -295,7 +295,7 @@ sub hashTableAccessor
     if ($noStaticTables) {
         return "get${className}Table(exec)";
     } else {
-        return "&${className}Table";
+        return "${className}Table";
     }
 }
 
@@ -306,7 +306,7 @@ sub prototypeHashTableAccessor
     if ($noStaticTables) {
         return "get${className}PrototypeTable(exec)";
     } else {
-        return "&${className}PrototypeTable";
+        return "${className}PrototypeTable";
     }
 }
 
@@ -317,7 +317,7 @@ sub constructorHashTableAccessor
     if ($noStaticTables) {
         return "get${constructorClassName}Table(exec)";
     } else {
-        return "&${constructorClassName}Table";
+        return "${constructorClassName}Table";
     }
 }
 
@@ -420,7 +420,7 @@ sub GenerateGetOwnPropertySlotBody
     if ($hasAttributes) {
         if ($inlined) {
             die "Cannot inline if NoStaticTables is set." if ($interface->extendedAttributes->{"JSNoStaticTables"});
-            push(@getOwnPropertySlotImpl, "    return ${namespaceMaybe}getStaticValueSlot<$className, Base>(exec, info()->staticPropHashTable, thisObject, propertyName, slot);\n");
+            push(@getOwnPropertySlotImpl, "    return ${namespaceMaybe}getStaticValueSlot<$className, Base>(exec, *info()->staticPropHashTable, thisObject, propertyName, slot);\n");
         } else {
             push(@getOwnPropertySlotImpl, "    return ${namespaceMaybe}getStaticValueSlot<$className, Base>(exec, " . hashTableAccessor($interface->extendedAttributes->{"JSNoStaticTables"}, $className) . ", thisObject, propertyName, slot);\n");
         }
@@ -1625,9 +1625,9 @@ sub GenerateImplementation
                                \%conditionals);
 
     if ($interface->extendedAttributes->{"JSNoStaticTables"}) {
-        push(@implContent, "static const HashTable* get${className}PrototypeTable(ExecState* exec)\n");
+        push(@implContent, "static const HashTable& get${className}PrototypeTable(ExecState* exec)\n");
         push(@implContent, "{\n");
-        push(@implContent, "    return getHashTableForGlobalData(exec->vm(), &${className}PrototypeTable);\n");
+        push(@implContent, "    return getHashTableForGlobalData(exec->vm(), ${className}PrototypeTable);\n");
         push(@implContent, "}\n\n");
         push(@implContent, "const ClassInfo ${className}Prototype::s_info = { \"${visibleInterfaceName}Prototype\", &Base::s_info, 0, get${className}PrototypeTable, CREATE_METHOD_TABLE(${className}Prototype) };\n\n");
     } else {
@@ -1669,9 +1669,9 @@ sub GenerateImplementation
 
     # - Initialize static ClassInfo object
     if ($numAttributes > 0 && $interface->extendedAttributes->{"JSNoStaticTables"}) {
-        push(@implContent, "static const HashTable* get${className}Table(ExecState* exec)\n");
+        push(@implContent, "static const HashTable& get${className}Table(ExecState* exec)\n");
         push(@implContent, "{\n");
-        push(@implContent, "    return getHashTableForGlobalData(exec->vm(), &${className}Table);\n");
+        push(@implContent, "    return getHashTableForGlobalData(exec->vm(), ${className}Table);\n");
         push(@implContent, "}\n\n");
     }
 
@@ -4060,9 +4060,9 @@ sub GenerateConstructorHelperMethods
         push(@$outputArray, "}\n\n");
     } else {
         if ($interface->extendedAttributes->{"JSNoStaticTables"}) {
-            push(@$outputArray, "static const HashTable* get${constructorClassName}Table(ExecState* exec)\n");
+            push(@$outputArray, "static const HashTable& get${constructorClassName}Table(ExecState* exec)\n");
             push(@$outputArray, "{\n");
-            push(@$outputArray, "    return getHashTableForGlobalData(exec->vm(), &${constructorClassName}Table);\n");
+            push(@$outputArray, "    return getHashTableForGlobalData(exec->vm(), ${constructorClassName}Table);\n");
             push(@$outputArray, "}\n\n");
             push(@$outputArray, "const ClassInfo ${constructorClassName}::s_info = { \"${visibleInterfaceName}Constructor\", &Base::s_info, 0, get${constructorClassName}Table, CREATE_METHOD_TABLE($constructorClassName) };\n\n");
         } else {