Title: [201784] trunk/Source/WebCore
Revision
201784
Author
[email protected]
Date
2016-06-07 18:53:44 -0700 (Tue, 07 Jun 2016)

Log Message

CachedScript should avoid recomputing its hash multiple times.
<https://webkit.org/b/158506>

Reviewed by Saam Barati.

JSBench was hitting CachedScript::script() hard and spending lots of time hashing scripts.
Since we're already caching the hash in a member variable, don't bother rehashing if we've
already done it before.

This takes total time spent in StringImpl::hashSlowCase() from 1600ms to 77ms on my MBP.

* loader/cache/CachedScript.cpp:
(WebCore::CachedScript::script):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (201783 => 201784)


--- trunk/Source/WebCore/ChangeLog	2016-06-08 01:43:35 UTC (rev 201783)
+++ trunk/Source/WebCore/ChangeLog	2016-06-08 01:53:44 UTC (rev 201784)
@@ -1,3 +1,19 @@
+2016-06-07  Andreas Kling  <[email protected]>
+
+        CachedScript should avoid recomputing its hash multiple times.
+        <https://webkit.org/b/158506>
+
+        Reviewed by Saam Barati.
+
+        JSBench was hitting CachedScript::script() hard and spending lots of time hashing scripts.
+        Since we're already caching the hash in a member variable, don't bother rehashing if we've
+        already done it before.
+
+        This takes total time spent in StringImpl::hashSlowCase() from 1600ms to 77ms on my MBP.
+
+        * loader/cache/CachedScript.cpp:
+        (WebCore::CachedScript::script):
+
 2016-06-07  Keith Rollin  <[email protected]>
 
         Remove all uses of PassRefPtr in WTF

Modified: trunk/Source/WebCore/loader/cache/CachedScript.cpp (201783 => 201784)


--- trunk/Source/WebCore/loader/cache/CachedScript.cpp	2016-06-08 01:43:35 UTC (rev 201783)
+++ trunk/Source/WebCore/loader/cache/CachedScript.cpp	2016-06-08 01:53:44 UTC (rev 201784)
@@ -93,7 +93,9 @@
 
     if (!m_script) {
         m_script = m_decoder->decodeAndFlush(m_data->data(), encodedSize());
-        m_scriptHash = m_script.impl()->hash();
+        ASSERT(!m_scriptHash || m_scriptHash == m_script.impl()->hash());
+        if (m_decodingState == NeverDecoded)
+            m_scriptHash = m_script.impl()->hash();
         m_decodingState = DataAndDecodedStringHaveDifferentBytes;
         setDecodedSize(m_script.sizeInBytes());
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to