Changeset 201784 in webkit


Ignore:
Timestamp:
Jun 7, 2016 6:53:44 PM (8 years ago)
Author:
akling@apple.com
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):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r201782 r201784  
     12016-06-07  Andreas Kling  <akling@apple.com>
     2
     3        CachedScript should avoid recomputing its hash multiple times.
     4        <https://webkit.org/b/158506>
     5
     6        Reviewed by Saam Barati.
     7
     8        JSBench was hitting CachedScript::script() hard and spending lots of time hashing scripts.
     9        Since we're already caching the hash in a member variable, don't bother rehashing if we've
     10        already done it before.
     11
     12        This takes total time spent in StringImpl::hashSlowCase() from 1600ms to 77ms on my MBP.
     13
     14        * loader/cache/CachedScript.cpp:
     15        (WebCore::CachedScript::script):
     16
    1172016-06-07  Keith Rollin  <krollin@apple.com>
    218
  • trunk/Source/WebCore/loader/cache/CachedScript.cpp

    r197628 r201784  
    9494    if (!m_script) {
    9595        m_script = m_decoder->decodeAndFlush(m_data->data(), encodedSize());
    96         m_scriptHash = m_script.impl()->hash();
     96        ASSERT(!m_scriptHash || m_scriptHash == m_script.impl()->hash());
     97        if (m_decodingState == NeverDecoded)
     98            m_scriptHash = m_script.impl()->hash();
    9799        m_decodingState = DataAndDecodedStringHaveDifferentBytes;
    98100        setDecodedSize(m_script.sizeInBytes());
Note: See TracChangeset for help on using the changeset viewer.