2008-09-24 Maciej Stachowiak <mjs@apple.com>
authormjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Sep 2008 08:11:35 +0000 (08:11 +0000)
committermjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Sep 2008 08:11:35 +0000 (08:11 +0000)
        Reviewed by Oliver Hunt.

        - inline PropertyMap::getOffset to speed up polymorphic lookups

        ~1.5% speedup on v8 benchmark
        no effect on SunSpider

        * JavaScriptCore.exp:
        * kjs/PropertyMap.cpp:
        * kjs/PropertyMap.h:
        (JSC::PropertyMap::getOffset):

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

JavaScriptCore/ChangeLog
JavaScriptCore/JavaScriptCore.exp
JavaScriptCore/kjs/PropertyMap.cpp
JavaScriptCore/kjs/PropertyMap.h

index e268b3951a7d46fbf26261a9c5416b90a32a8eb1..78c6a70799639c60c92862e5ccc8b3c43d4b131c 100644 (file)
@@ -1,3 +1,17 @@
+2008-09-24  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Oliver Hunt.
+        
+        - inline PropertyMap::getOffset to speed up polymorphic lookups
+        
+        ~1.5% speedup on v8 benchmark
+        no effect on SunSpider
+
+        * JavaScriptCore.exp:
+        * kjs/PropertyMap.cpp:
+        * kjs/PropertyMap.h:
+        (JSC::PropertyMap::getOffset):
+
 2008-09-24  Jan Michael Alonzo  <jmalonzo@webkit.org>
 
         Reviewed by Alp Toker.
index 7043e41f4ab08b499ca616e5adb3c4b047ededa9..d48d6e325980b8281c43b27d454426ca6bcde5b0 100644 (file)
@@ -109,7 +109,6 @@ __ZN3JSC11JSImmediate9prototypeEPKNS_7JSValueEPNS_9ExecStateE
 __ZN3JSC11ProfileNode4sortEPFbRKN3WTF6RefPtrIS0_EES5_E
 __ZN3JSC11ProgramNode6createEPNS_12JSGlobalDataEPNS_14SourceElementsEPN3WTF6VectorISt4pairINS_10IdentifierEjELm16EEEPNS6_INS5_6RefPtrINS_12FuncDeclNodeEEELm16EEEPNS_14SourceProviderEbbi
 __ZN3JSC11PropertyMap3putERKNS_10IdentifierEPNS_7JSValueEjbPNS_8JSObjectERNS_15PutPropertySlotERPS5_
-__ZN3JSC11PropertyMap9getOffsetERKNS_10IdentifierE
 __ZN3JSC11PropertyMap9getOffsetERKNS_10IdentifierERj
 __ZN3JSC11PropertyMapD1Ev
 __ZN3JSC11StructureID21addPropertyTransitionEPS0_RKNS_10IdentifierEPNS_7JSValueEjPNS_8JSObjectERNS_15PutPropertySlotERPS6_
index fa0f15261b7fc80e5f32499e23e1923a36a4ec57..1c33d2da3828a394a947cdb38a7c5e687d88087c 100644 (file)
@@ -35,10 +35,8 @@ using WTF::doubleHash;
 
 #ifndef NDEBUG
 #define DO_PROPERTYMAP_CONSTENCY_CHECK 0
-#define DUMP_PROPERTYMAP_STATS 0
 #else
 #define DO_PROPERTYMAP_CONSTENCY_CHECK 0
-#define DUMP_PROPERTYMAP_STATS 0
 #endif
 
 namespace JSC {
@@ -75,7 +73,6 @@ PropertyMapStatisticsExitLogger::~PropertyMapStatisticsExitLogger()
 
 #endif
 
-static const unsigned emptyEntryIndex = 0;
 static const unsigned deletedSentinelIndex = 1;
 
 #if !DO_PROPERTYMAP_CONSTENCY_CHECK
@@ -270,50 +267,6 @@ void PropertyMap::remove(const Identifier& propertyName, PropertyStorage& proper
     checkConsistency(propertyStorage);
 }
 
-size_t PropertyMap::getOffset(const Identifier& propertyName)
-{
-    ASSERT(!propertyName.isNull());
-
-    if (!m_table)
-        return WTF::notFound;
-
-    UString::Rep* rep = propertyName._ustring.rep();
-
-    unsigned i = rep->computedHash();
-
-#if DUMP_PROPERTYMAP_STATS
-    ++numProbes;
-#endif
-
-    unsigned entryIndex = m_table->entryIndices[i & m_table->sizeMask];
-    if (entryIndex == emptyEntryIndex)
-        return WTF::notFound;
-
-    if (rep == m_table->entries()[entryIndex - 1].key)
-        return entryIndex - 2;
-
-#if DUMP_PROPERTYMAP_STATS
-    ++numCollisions;
-#endif
-
-    unsigned k = 1 | doubleHash(rep->computedHash());
-
-    while (1) {
-        i += k;
-
-#if DUMP_PROPERTYMAP_STATS
-        ++numRehashes;
-#endif
-
-        entryIndex = m_table->entryIndices[i & m_table->sizeMask];
-        if (entryIndex == emptyEntryIndex)
-            return WTF::notFound;
-
-        if (rep == m_table->entries()[entryIndex - 1].key)
-            return entryIndex - 2;
-    }
-}
-
 size_t PropertyMap::getOffset(const Identifier& propertyName, unsigned& attributes)
 {
     ASSERT(!propertyName.isNull());
index 0fe6b36ea29ede09a799b4dceff17983098de611..46077aa2696e2a9a255726f79137f806e2307b06 100644 (file)
 #include <wtf/OwnArrayPtr.h>
 #include <wtf/NotFound.h>
 
+#ifndef NDEBUG
+#define DUMP_PROPERTYMAP_STATS 0
+#else
+#define DUMP_PROPERTYMAP_STATS 0
+#endif
+
 namespace JSC {
 
     class JSObject;
@@ -102,6 +108,8 @@ namespace JSC {
         unsigned size() const { return m_table ? m_table->size : 0; }
         unsigned storageSize() const { return m_table ? m_table->keyCount + m_table->deletedSentinelCount : 0; }
 
+        static const unsigned emptyEntryIndex = 0;
+
     private:
         typedef PropertyMapEntry Entry;
         typedef PropertyMapHashTable Table;
@@ -125,6 +133,50 @@ namespace JSC {
     {
     }
 
+    inline size_t PropertyMap::getOffset(const Identifier& propertyName)
+    {
+        ASSERT(!propertyName.isNull());
+
+        if (!m_table)
+            return WTF::notFound;
+
+        UString::Rep* rep = propertyName._ustring.rep();
+
+        unsigned i = rep->computedHash();
+
+#if DUMP_PROPERTYMAP_STATS
+        ++numProbes;
+#endif
+
+        unsigned entryIndex = m_table->entryIndices[i & m_table->sizeMask];
+        if (entryIndex == emptyEntryIndex)
+            return WTF::notFound;
+
+        if (rep == m_table->entries()[entryIndex - 1].key)
+            return entryIndex - 2;
+
+#if DUMP_PROPERTYMAP_STATS
+        ++numCollisions;
+#endif
+
+        unsigned k = 1 | WTF::doubleHash(rep->computedHash());
+
+        while (1) {
+            i += k;
+
+#if DUMP_PROPERTYMAP_STATS
+            ++numRehashes;
+#endif
+
+            entryIndex = m_table->entryIndices[i & m_table->sizeMask];
+            if (entryIndex == emptyEntryIndex)
+                return WTF::notFound;
+
+            if (rep == m_table->entries()[entryIndex - 1].key)
+                return entryIndex - 2;
+        }
+    }
+
 } // namespace JSC
 
 #endif // PropertyMap_h