Title: [88394] trunk/Source/_javascript_Core
Revision
88394
Author
[email protected]
Date
2011-06-08 14:54:15 -0700 (Wed, 08 Jun 2011)

Log Message

2011-06-08  Oliver Hunt  <[email protected]>

        Reviewed by Geoffrey Garen.

        Add faster lookup cache for multi character identifiers
        https://bugs.webkit.org/show_bug.cgi?id=62327

        Add a non-hash lookup for mutiple character identifiers.  This saves us from
        adding repeated identifiers to the ParserArena's identifier list as people
        tend to not start all their variables and properties with the same character
        and happily identifier locality works in our favour.

        * parser/ParserArena.h:
        (JSC::IdentifierArena::isEmpty):
        (JSC::IdentifierArena::clear):
        (JSC::IdentifierArena::makeIdentifier):

Modified Paths

Property Changed

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (88393 => 88394)


--- trunk/Source/_javascript_Core/ChangeLog	2011-06-08 21:53:45 UTC (rev 88393)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-06-08 21:54:15 UTC (rev 88394)
@@ -1,3 +1,20 @@
+2011-06-08  Oliver Hunt  <[email protected]>
+
+        Reviewed by Geoffrey Garen.
+
+        Add faster lookup cache for multi character identifiers
+        https://bugs.webkit.org/show_bug.cgi?id=62327
+
+        Add a non-hash lookup for mutiple character identifiers.  This saves us from
+        adding repeated identifiers to the ParserArena's identifier list as people
+        tend to not start all their variables and properties with the same character
+        and happily identifier locality works in our favour.
+
+        * parser/ParserArena.h:
+        (JSC::IdentifierArena::isEmpty):
+        (JSC::IdentifierArena::clear):
+        (JSC::IdentifierArena::makeIdentifier):
+
 2011-06-08  Geoffrey Garen  <[email protected]>
 
         Reviewed by Oliver Hunt.
Property changes on: trunk/Source/_javascript_Core/ChangeLog
___________________________________________________________________

Deleted: svn:executable

Modified: trunk/Source/_javascript_Core/parser/ParserArena.h (88393 => 88394)


--- trunk/Source/_javascript_Core/parser/ParserArena.h	2011-06-08 21:53:45 UTC (rev 88393)
+++ trunk/Source/_javascript_Core/parser/ParserArena.h	2011-06-08 21:54:15 UTC (rev 88394)
@@ -45,31 +45,44 @@
         ALWAYS_INLINE const Identifier& makeIdentifier(JSGlobalData*, const UChar* characters, size_t length);
         const Identifier& makeNumericIdentifier(JSGlobalData*, double number);
 
+        bool isEmpty() const { return m_identifiers.isEmpty(); }
+
+    public:
+        static const int MaximumCachableCharacter = 128;
+        typedef SegmentedVector<Identifier, 64> IdentifierVector;
         void clear()
         {
             m_identifiers.clear();
-            for (unsigned  i = 0; i < 128; i++)
+            for (int i = 0; i < MaximumCachableCharacter; i++)
                 m_shortIdentifiers[i] = 0;
+            for (int i = 0; i < MaximumCachableCharacter; i++)
+                m_recentIdentifiers[i] = 0;
         }
-        bool isEmpty() const { return m_identifiers.isEmpty(); }
 
     private:
-        static const int MaximumCachableCharacter = 128;
-        typedef SegmentedVector<Identifier, 64> IdentifierVector;
         IdentifierVector m_identifiers;
         FixedArray<Identifier*, MaximumCachableCharacter> m_shortIdentifiers;
+        FixedArray<Identifier*, MaximumCachableCharacter> m_recentIdentifiers;
     };
 
     ALWAYS_INLINE const Identifier& IdentifierArena::makeIdentifier(JSGlobalData* globalData, const UChar* characters, size_t length)
     {
-        if (length == 1 && characters[0] < MaximumCachableCharacter) {
+        if (characters[0] >= MaximumCachableCharacter) {
+            m_identifiers.append(Identifier(globalData, characters, length));
+            return m_identifiers.last();
+        }
+        if (length == 1) {
             if (Identifier* ident = m_shortIdentifiers[characters[0]])
                 return *ident;
             m_identifiers.append(Identifier(globalData, characters, length));
             m_shortIdentifiers[characters[0]] = &m_identifiers.last();
             return m_identifiers.last();
         }
+        Identifier* ident = m_recentIdentifiers[characters[0]];
+        if (ident && Identifier::equal(ident->impl(), characters, length))
+            return *ident;
         m_identifiers.append(Identifier(globalData, characters, length));
+        m_recentIdentifiers[characters[0]] = &m_identifiers.last();
         return m_identifiers.last();
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to