Changeset 143384 in webkit


Ignore:
Timestamp:
Feb 19, 2013 2:29:03 PM (11 years ago)
Author:
ggaren@apple.com
Message:

Unreviewed, rolling in r143348.
http://trac.webkit.org/changeset/143348
https://bugs.webkit.org/show_bug.cgi?id=110242

The bug was that isEmptyValue() was returning true for the deleted value.
Fixed this and simplified things further by delegating to m_sourceCode
for both isNull() and isHashTableDeletedValue(), so they can't be out of
sync.

  • runtime/CodeCache.cpp:

(JSC::CodeCache::getFunctionExecutableFromGlobalCode):

  • runtime/CodeCache.h:

(JSC::SourceCodeKey::SourceCodeKey):
(JSC::SourceCodeKey::isHashTableDeletedValue):
(JSC::SourceCodeKey::hash):
(JSC::SourceCodeKey::length):
(JSC::SourceCodeKey::isNull):
(JSC::SourceCodeKey::operator==):
(SourceCodeKey):

Location:
trunk/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r143381 r143384  
     12013-02-18  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Unreviewed, rolling in r143348.
     4        http://trac.webkit.org/changeset/143348
     5        https://bugs.webkit.org/show_bug.cgi?id=110242
     6
     7        The bug was that isEmptyValue() was returning true for the deleted value.
     8        Fixed this and simplified things further by delegating to m_sourceCode
     9        for both isNull() and isHashTableDeletedValue(), so they can't be out of
     10        sync.
     11
     12        * runtime/CodeCache.cpp:
     13        (JSC::CodeCache::getFunctionExecutableFromGlobalCode):
     14        * runtime/CodeCache.h:
     15        (JSC::SourceCodeKey::SourceCodeKey):
     16        (JSC::SourceCodeKey::isHashTableDeletedValue):
     17        (JSC::SourceCodeKey::hash):
     18        (JSC::SourceCodeKey::length):
     19        (JSC::SourceCodeKey::isNull):
     20        (JSC::SourceCodeKey::operator==):
     21        (SourceCodeKey):
     22
    1232013-02-15  Martin Robinson  <mrobinson@igalia.com>
    224
  • trunk/Source/JavaScriptCore/parser/SourceCode.h

    r128542 r143384  
    4545        }
    4646
     47        SourceCode(WTF::HashTableDeletedValueType)
     48            : m_provider(WTF::HashTableDeletedValue)
     49        {
     50        }
     51
    4752        SourceCode(PassRefPtr<SourceProvider> provider, int firstLine = 1)
    4853            : m_provider(provider)
     
    6065        {
    6166        }
     67
     68        bool isHashTableDeletedValue() const { return m_provider.isHashTableDeletedValue(); }
    6269
    6370        String toString() const
  • trunk/Source/JavaScriptCore/runtime/CodeCache.cpp

    r143366 r143384  
    106106UnlinkedFunctionExecutable* CodeCache::getFunctionExecutableFromGlobalCode(JSGlobalData& globalData, const Identifier& name, const SourceCode& source, ParserError& error)
    107107{
    108     SourceCodeKey key = SourceCodeKey(source, name.string(), SourceCodeKey::FunctionCallType, JSParseNormal);
     108    SourceCodeKey key = SourceCodeKey(source, name.string(), SourceCodeKey::FunctionType, JSParseNormal);
    109109    const Strong<JSCell>* result = m_sourceCode.find(key);
    110110    if (result)
  • trunk/Source/JavaScriptCore/runtime/CodeCache.h

    r143366 r143384  
    5656class SourceCodeKey {
    5757public:
    58     enum CodeType { EvalType, ProgramType, FunctionCallType, FunctionConstructType };
     58    enum CodeType { EvalType, ProgramType, FunctionType };
    5959
    6060    SourceCodeKey()
    61         : m_flags(0)
    6261    {
    6362    }
    6463
    6564    SourceCodeKey(const SourceCode& sourceCode, const String& name, CodeType codeType, JSParserStrictness jsParserStrictness)
    66         : m_sourceString(sourceCode.toString())
     65        : m_sourceCode(sourceCode)
    6766        , m_name(name)
    6867        , m_flags((codeType << 1) | jsParserStrictness)
     68        , m_hash(string().impl()->hash())
    6969    {
    7070    }
    7171
    7272    SourceCodeKey(WTF::HashTableDeletedValueType)
    73         : m_sourceString(WTF::HashTableDeletedValue)
     73        : m_sourceCode(WTF::HashTableDeletedValue)
    7474    {
    7575    }
    7676
    77     bool isHashTableDeletedValue() const { return m_sourceString.isHashTableDeletedValue(); }
     77    bool isHashTableDeletedValue() const { return m_sourceCode.isHashTableDeletedValue(); }
    7878
    79     unsigned hash() const { return m_sourceString.impl()->hash(); }
     79    unsigned hash() const { return m_hash; }
    8080
    81     size_t length() const { return m_sourceString.length(); }
     81    size_t length() const { return m_sourceCode.length(); }
    8282
    83     bool isNull() const { return m_sourceString.isNull(); }
     83    bool isNull() const { return m_sourceCode.isNull(); }
     84
     85    // To save memory, we compute our string on demand. It's expected that source
     86    // providers cache their strings to make this efficient.
     87    String string() const { return m_sourceCode.toString(); }
    8488
    8589    bool operator==(const SourceCodeKey& other) const
    8690    {
    87         return m_flags == other.m_flags
     91        return m_hash == other.m_hash
     92            && length() == other.length()
     93            && m_flags == other.m_flags
    8894            && m_name == other.m_name
    89             && m_sourceString == other.m_sourceString;
     95            && string() == other.string();
    9096    }
    9197
    9298private:
    93     String m_sourceString;
     99    SourceCode m_sourceCode;
    94100    String m_name;
    95101    unsigned m_flags;
     102    unsigned m_hash;
    96103};
    97104
Note: See TracChangeset for help on using the changeset viewer.