Replace DEPRECATED_DEFINE_STATIC_LOCAL by static NeverDestroyed<T> in bridge/
authorsvillar@igalia.com <svillar@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Mar 2014 17:32:09 +0000 (17:32 +0000)
committersvillar@igalia.com <svillar@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Mar 2014 17:32:09 +0000 (17:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=130601

Reviewed by Darin Adler.

* bridge/IdentifierRep.cpp:
(WebCore::identifierSet):
(WebCore::intIdentifierMap):
(WebCore::stringIdentifierMap):
* bridge/NP_jsobject.cpp:
(objectMap):
* bridge/runtime_root.cpp:
(JSC::Bindings::rootObjectSet): Return a reference instead of
a pointer.
(JSC::Bindings::findProtectingRootObject):
(JSC::Bindings::findRootObject):
(JSC::Bindings::RootObject::RootObject):
(JSC::Bindings::RootObject::invalidate):

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

Source/WebCore/ChangeLog
Source/WebCore/bridge/IdentifierRep.cpp
Source/WebCore/bridge/NP_jsobject.cpp
Source/WebCore/bridge/runtime_root.cpp

index 01e3c87..5d05f63 100644 (file)
@@ -1,3 +1,24 @@
+2014-03-21  Sergio Villar Senin  <svillar@igalia.com>
+
+        Replace DEPRECATED_DEFINE_STATIC_LOCAL by static NeverDestroyed<T> in bridge/
+        https://bugs.webkit.org/show_bug.cgi?id=130601
+
+        Reviewed by Darin Adler.
+
+        * bridge/IdentifierRep.cpp:
+        (WebCore::identifierSet):
+        (WebCore::intIdentifierMap):
+        (WebCore::stringIdentifierMap):
+        * bridge/NP_jsobject.cpp:
+        (objectMap):
+        * bridge/runtime_root.cpp:
+        (JSC::Bindings::rootObjectSet): Return a reference instead of
+        a pointer.
+        (JSC::Bindings::findProtectingRootObject):
+        (JSC::Bindings::findRootObject):
+        (JSC::Bindings::RootObject::RootObject):
+        (JSC::Bindings::RootObject::invalidate):
+
 2014-03-21  Michael Saboff  <msaboff@apple.com>
 
         Change CodeGeneratorJS.pm special cases for "DOMWindow" to be general purpose
index 253e489..3037701 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "JSDOMBinding.h"
 #include <wtf/HashMap.h>
+#include <wtf/NeverDestroyed.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/text/WTFString.h>
 
@@ -39,7 +40,7 @@ typedef HashSet<IdentifierRep*> IdentifierSet;
 
 static IdentifierSet& identifierSet()
 {
-    DEPRECATED_DEFINE_STATIC_LOCAL(IdentifierSet, identifierSet, ());
+    static NeverDestroyed<IdentifierSet> identifierSet;
     return identifierSet;
 }
     
@@ -47,7 +48,7 @@ typedef HashMap<int, IdentifierRep*> IntIdentifierMap;
 
 static IntIdentifierMap& intIdentifierMap()
 {
-    DEPRECATED_DEFINE_STATIC_LOCAL(IntIdentifierMap, intIdentifierMap, ());
+    static NeverDestroyed<IntIdentifierMap> intIdentifierMap;
     return intIdentifierMap;
 }
 
@@ -81,7 +82,7 @@ typedef HashMap<RefPtr<StringImpl>, IdentifierRep*> StringIdentifierMap;
 
 static StringIdentifierMap& stringIdentifierMap()
 {
-    DEPRECATED_DEFINE_STATIC_LOCAL(StringIdentifierMap, stringIdentifierMap, ());
+    static NeverDestroyed<StringIdentifierMap> stringIdentifierMap;
     return stringIdentifierMap;
 }
 
index eead9e2..2323c76 100644 (file)
@@ -43,6 +43,7 @@
 #include <runtime/PropertyNameArray.h>
 #include <parser/SourceCode.h>
 #include <runtime/Completion.h>
+#include <wtf/NeverDestroyed.h>
 #include <wtf/text/WTFString.h>
 
 using namespace JSC;
@@ -97,7 +98,7 @@ private:
 
 static ObjectMap& objectMap()
 {
-    DEPRECATED_DEFINE_STATIC_LOCAL(ObjectMap, map, ());
+    static NeverDestroyed<ObjectMap> map;
     return map;
 }
 
index a49fa73..9b5d8cf 100644 (file)
@@ -34,6 +34,7 @@
 #include <runtime/JSGlobalObject.h>
 #include <wtf/HashCountedSet.h>
 #include <wtf/HashSet.h>
+#include <wtf/NeverDestroyed.h>
 #include <wtf/Ref.h>
 #include <wtf/StdLibExtras.h>
 
@@ -46,10 +47,10 @@ namespace JSC { namespace Bindings {
 
 typedef HashSet<RootObject*> RootObjectSet;
 
-static RootObjectSet* rootObjectSet()
+static RootObjectSet& rootObjectSet()
 {
-    DEPRECATED_DEFINE_STATIC_LOCAL(RootObjectSet, staticRootObjectSet, ());
-    return &staticRootObjectSet;
+    static NeverDestroyed<RootObjectSet> staticRootObjectSet;
+    return staticRootObjectSet;
 }
 
 // FIXME:  These two functions are a potential performance problem.  We could 
@@ -57,8 +58,8 @@ static RootObjectSet* rootObjectSet()
 
 RootObject* findProtectingRootObject(JSObject* jsObject)
 {
-    RootObjectSet::const_iterator end = rootObjectSet()->end();
-    for (RootObjectSet::const_iterator it = rootObjectSet()->begin(); it != end; ++it) {
+    RootObjectSet::const_iterator end = rootObjectSet().end();
+    for (RootObjectSet::const_iterator it = rootObjectSet().begin(); it != end; ++it) {
         if ((*it)->gcIsProtected(jsObject))
             return *it;
     }
@@ -67,8 +68,8 @@ RootObject* findProtectingRootObject(JSObject* jsObject)
 
 RootObject* findRootObject(JSGlobalObject* globalObject)
 {
-    RootObjectSet::const_iterator end = rootObjectSet()->end();
-    for (RootObjectSet::const_iterator it = rootObjectSet()->begin(); it != end; ++it) {
+    RootObjectSet::const_iterator end = rootObjectSet().end();
+    for (RootObjectSet::const_iterator it = rootObjectSet().begin(); it != end; ++it) {
         if ((*it)->globalObject() == globalObject)
             return *it;
     }
@@ -90,7 +91,7 @@ RootObject::RootObject(const void* nativeHandle, JSGlobalObject* globalObject)
     , m_globalObject(globalObject->vm(), globalObject)
 {
     ASSERT(globalObject);
-    rootObjectSet()->add(this);
+    rootObjectSet().add(this);
 }
 
 RootObject::~RootObject()
@@ -134,7 +135,7 @@ void RootObject::invalidate()
         JSC::gcUnprotect(it->key);
     m_protectCountSet.clear();
 
-    rootObjectSet()->remove(this);
+    rootObjectSet().remove(this);
 }
 
 void RootObject::gcProtect(JSObject* jsObject)