Title: [143384] trunk/Source/_javascript_Core
Revision
143384
Author
[email protected]
Date
2013-02-19 14:29:03 -0800 (Tue, 19 Feb 2013)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (143383 => 143384)


--- trunk/Source/_javascript_Core/ChangeLog	2013-02-19 22:15:58 UTC (rev 143383)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-02-19 22:29:03 UTC (rev 143384)
@@ -1,3 +1,25 @@
+2013-02-18  Geoffrey Garen  <[email protected]>
+
+        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):
+
 2013-02-15  Martin Robinson  <[email protected]>
 
         [GTK] Improve gyp build _javascript_Core code generation

Modified: trunk/Source/_javascript_Core/parser/SourceCode.h (143383 => 143384)


--- trunk/Source/_javascript_Core/parser/SourceCode.h	2013-02-19 22:15:58 UTC (rev 143383)
+++ trunk/Source/_javascript_Core/parser/SourceCode.h	2013-02-19 22:29:03 UTC (rev 143384)
@@ -44,6 +44,11 @@
         {
         }
 
+        SourceCode(WTF::HashTableDeletedValueType)
+            : m_provider(WTF::HashTableDeletedValue)
+        {
+        }
+
         SourceCode(PassRefPtr<SourceProvider> provider, int firstLine = 1)
             : m_provider(provider)
             , m_startChar(0)
@@ -60,6 +65,8 @@
         {
         }
 
+        bool isHashTableDeletedValue() const { return m_provider.isHashTableDeletedValue(); }
+
         String toString() const
         {
             if (!m_provider)

Modified: trunk/Source/_javascript_Core/runtime/CodeCache.cpp (143383 => 143384)


--- trunk/Source/_javascript_Core/runtime/CodeCache.cpp	2013-02-19 22:15:58 UTC (rev 143383)
+++ trunk/Source/_javascript_Core/runtime/CodeCache.cpp	2013-02-19 22:29:03 UTC (rev 143384)
@@ -105,7 +105,7 @@
 
 UnlinkedFunctionExecutable* CodeCache::getFunctionExecutableFromGlobalCode(JSGlobalData& globalData, const Identifier& name, const SourceCode& source, ParserError& error)
 {
-    SourceCodeKey key = SourceCodeKey(source, name.string(), SourceCodeKey::FunctionCallType, JSParseNormal);
+    SourceCodeKey key = SourceCodeKey(source, name.string(), SourceCodeKey::FunctionType, JSParseNormal);
     const Strong<JSCell>* result = m_sourceCode.find(key);
     if (result)
         return jsCast<UnlinkedFunctionExecutable*>(result->get());

Modified: trunk/Source/_javascript_Core/runtime/CodeCache.h (143383 => 143384)


--- trunk/Source/_javascript_Core/runtime/CodeCache.h	2013-02-19 22:15:58 UTC (rev 143383)
+++ trunk/Source/_javascript_Core/runtime/CodeCache.h	2013-02-19 22:29:03 UTC (rev 143384)
@@ -55,44 +55,51 @@
 
 class SourceCodeKey {
 public:
-    enum CodeType { EvalType, ProgramType, FunctionCallType, FunctionConstructType };
+    enum CodeType { EvalType, ProgramType, FunctionType };
 
     SourceCodeKey()
-        : m_flags(0)
     {
     }
 
     SourceCodeKey(const SourceCode& sourceCode, const String& name, CodeType codeType, JSParserStrictness jsParserStrictness)
-        : m_sourceString(sourceCode.toString())
+        : m_sourceCode(sourceCode)
         , m_name(name)
         , m_flags((codeType << 1) | jsParserStrictness)
+        , m_hash(string().impl()->hash())
     {
     }
 
     SourceCodeKey(WTF::HashTableDeletedValueType)
-        : m_sourceString(WTF::HashTableDeletedValue)
+        : m_sourceCode(WTF::HashTableDeletedValue)
     {
     }
 
-    bool isHashTableDeletedValue() const { return m_sourceString.isHashTableDeletedValue(); }
+    bool isHashTableDeletedValue() const { return m_sourceCode.isHashTableDeletedValue(); }
 
-    unsigned hash() const { return m_sourceString.impl()->hash(); }
+    unsigned hash() const { return m_hash; }
 
-    size_t length() const { return m_sourceString.length(); }
+    size_t length() const { return m_sourceCode.length(); }
 
-    bool isNull() const { return m_sourceString.isNull(); }
+    bool isNull() const { return m_sourceCode.isNull(); }
 
+    // To save memory, we compute our string on demand. It's expected that source
+    // providers cache their strings to make this efficient.
+    String string() const { return m_sourceCode.toString(); }
+
     bool operator==(const SourceCodeKey& other) const
     {
-        return m_flags == other.m_flags
+        return m_hash == other.m_hash
+            && length() == other.length()
+            && m_flags == other.m_flags
             && m_name == other.m_name
-            && m_sourceString == other.m_sourceString;
+            && string() == other.string();
     }
 
 private:
-    String m_sourceString;
+    SourceCode m_sourceCode;
     String m_name;
     unsigned m_flags;
+    unsigned m_hash;
 };
 
 struct SourceCodeKeyHash {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to