Optimize V8 getDOMNodeMap(), a hot function in Dromaeo DOM tests, by increasing inlining.
authorsnej@chromium.org <snej@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Nov 2009 19:19:50 +0000 (19:19 +0000)
committersnej@chromium.org <snej@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Nov 2009 19:19:50 +0000 (19:19 +0000)
Reviewed by Dimitri Glazkov.

* bindings/v8/DOMData.cpp:
(WebCore::DOMData::getCurrent):  Moved getCurrentMainThread to MainThreadDOMData::getCurrent
    so it can be inlined by its caller.
* bindings/v8/DOMData.h:
* bindings/v8/MainThreadDOMData.cpp:
(WebCore::MainThreadDOMData::getCurrent):  Moved here from DOMData.cpp.
(WebCore::MainThreadDOMData::getMainThreadStore):  Added UNLIKELY macro to improve codegen.
(WebCore::MainThreadDOMData::getCurrentMainThreadStore):  Combination of getCurrentMainThread
    and getStore, which inline both calls together.
* bindings/v8/MainThreadDOMData.h:
(WebCore::MainThreadDOMData::getStore):  Broke out nonvirtual getMainThreadStore for inlineability.
* bindings/v8/V8DOMMap.cpp:
(WebCore::getDOMNodeMap):  Call new getCurrentMainThreadStore, which is faster.

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

WebCore/ChangeLog
WebCore/bindings/v8/DOMData.cpp
WebCore/bindings/v8/DOMData.h
WebCore/bindings/v8/MainThreadDOMData.cpp
WebCore/bindings/v8/MainThreadDOMData.h
WebCore/bindings/v8/V8DOMMap.cpp

index 434cb2af3ef1e05e34dfc16910b228073d4f31a9..f43053d152d9b828c06ff3476ba3cf9c0dd114dc 100644 (file)
@@ -1,3 +1,23 @@
+2009-11-11  Jens Alfke  <snej@chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        Optimize V8 getDOMNodeMap(), a hot function in Dromaeo DOM tests, by increasing inlining.
+
+        * bindings/v8/DOMData.cpp:
+        (WebCore::DOMData::getCurrent):  Moved getCurrentMainThread to MainThreadDOMData::getCurrent
+            so it can be inlined by its caller.
+        * bindings/v8/DOMData.h:
+        * bindings/v8/MainThreadDOMData.cpp:
+        (WebCore::MainThreadDOMData::getCurrent):  Moved here from DOMData.cpp.
+        (WebCore::MainThreadDOMData::getMainThreadStore):  Added UNLIKELY macro to improve codegen.
+        (WebCore::MainThreadDOMData::getCurrentMainThreadStore):  Combination of getCurrentMainThread
+            and getStore, which inline both calls together.
+        * bindings/v8/MainThreadDOMData.h:
+        (WebCore::MainThreadDOMData::getStore):  Broke out nonvirtual getMainThreadStore for inlineability.
+        * bindings/v8/V8DOMMap.cpp:
+        (WebCore::getDOMNodeMap):  Call new getCurrentMainThreadStore, which is faster.
+
 2009-11-11  Nate Chapin  <japhet@chromium.org>
 
         Reviewed by Dimitri Glazkov.
index 07254fe40d030d944567f542b1ff98440f6c04e0..08d4561fbf9b33fa3145b472a7d03fa0315db13b 100644 (file)
@@ -46,19 +46,12 @@ DOMData::DOMData()
 DOMData* DOMData::getCurrent()
 {
     if (WTF::isMainThread())
-        return getCurrentMainThread();
+        return MainThreadDOMData::getCurrent();
 
     DEFINE_STATIC_LOCAL(WTF::ThreadSpecific<ChildThreadDOMData>, childThreadDOMData, ());
     return childThreadDOMData;
 }
 
-DOMData* DOMData::getCurrentMainThread()
-{
-    ASSERT(WTF::isMainThread());
-    DEFINE_STATIC_LOCAL(MainThreadDOMData, mainThreadDOMData, ());
-    return &mainThreadDOMData;
-}
-
 void DOMData::ensureDeref(V8ClassIndex::V8WrapperType type, void* domObject)
 {
     if (m_owningThread == WTF::currentThread()) {
index 855242623be57629a8783b597653da4a2b83eb85..65fe8fcbbb67568047b84f63c364c9c23f2fc1db 100644 (file)
@@ -47,7 +47,6 @@ namespace WebCore {
         DOMData();
 
         static DOMData* getCurrent();
-        static DOMData* getCurrentMainThread(); // Caller must be on the main thread.
         virtual DOMDataStore& getStore() = 0;
 
         template<typename T>
index ea344443fb2ea0bd20d4bf8111b59d21ac897d91..b1b63bff67adb5375e2aa0e848436ce0303b8f62 100644 (file)
@@ -39,14 +39,30 @@ MainThreadDOMData::MainThreadDOMData()
     : m_defaultStore(this)
 {
 }
+    
+MainThreadDOMData* MainThreadDOMData::getCurrent()
+{
+    ASSERT(WTF::isMainThread());
+    DEFINE_STATIC_LOCAL(MainThreadDOMData, mainThreadDOMData, ());
+    return &mainThreadDOMData;
+}
 
-DOMDataStore& MainThreadDOMData::getStore()
+DOMDataStore& MainThreadDOMData::getMainThreadStore()
 {
+    // This is broken out as a separate non-virtual method from getStore()
+    // so that it can be inlined by getCurrentMainThreadStore, which is
+    // a hot spot in Dromaeo DOM tests.
     ASSERT(WTF::isMainThread());
     V8IsolatedWorld* world = V8IsolatedWorld::getEntered();
-    if (world)
+    if (UNLIKELY(world != 0))
         return *world->getDOMDataStore();
     return m_defaultStore;
 }
 
+DOMDataStore& MainThreadDOMData::getCurrentMainThreadStore()
+{
+    return getCurrent()->getMainThreadStore();
+}
+
+
 } // namespace WebCore
index 5c78cec3749f4392b10f1c9b86499d8f40e3688d..e8f99c9f0ae89173f0cff0d05da98e083388a1c4 100644 (file)
@@ -38,10 +38,16 @@ namespace WebCore {
 
     class MainThreadDOMData : public DOMData {
     public:
-        MainThreadDOMData();
-        DOMDataStore& getStore();
+        static MainThreadDOMData* getCurrent(); // Caller must be on the main thread.
+        static DOMDataStore& getCurrentMainThreadStore();
+                
+        virtual DOMDataStore& getStore() { return getMainThreadStore(); }
+        
 
     private:
+        MainThreadDOMData();
+        DOMDataStore& getMainThreadStore();
+
         StaticDOMDataStore m_defaultStore;
         // Note: The DOMDataStores for isolated world are owned by the world object.
     };
index 1bd68f72f0e5b40fedae092739163e6a1157f90e..7512dff51090076402797dda58d9e372f9f820b0 100644 (file)
@@ -34,6 +34,7 @@
 #include "DOMData.h"
 #include "DOMDataStore.h"
 #include "DOMObjectsInclude.h"
+#include "MainThreadDOMData.h"
 #include "ScopedDOMDataStore.h"
 
 namespace WebCore {
@@ -49,8 +50,7 @@ DOMDataStoreHandle::~DOMDataStoreHandle()
 
 DOMWrapperMap<Node>& getDOMNodeMap()
 {
-    // Nodes only exist on the main thread.
-    return DOMData::getCurrentMainThread()->getStore().domNodeMap();
+    return MainThreadDOMData::getCurrentMainThreadStore().domNodeMap();
 }
 
 DOMWrapperMap<void>& getDOMObjectMap()