refCount() of a StringImpl could be zero if it's static; in that case we shouldn...
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Aug 2013 22:27:53 +0000 (22:27 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Aug 2013 22:27:53 +0000 (22:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=119870

Reviewed by Mark Hahnenberg.

* wtf/text/StringImpl.h:
(WTF::StringImpl::costDuringGC):
(WTF::StringImpl::isStatic):
(WTF::StringImpl::bufferOwnership):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@154145 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/text/StringImpl.h

index b2322fd..72fbbbf 100644 (file)
@@ -1,3 +1,15 @@
+2013-08-15  Filip Pizlo  <fpizlo@apple.com>
+
+        refCount() of a StringImpl could be zero if it's static; in that case we shouldn't report extra memory cost
+        https://bugs.webkit.org/show_bug.cgi?id=119870
+
+        Reviewed by Mark Hahnenberg.
+
+        * wtf/text/StringImpl.h:
+        (WTF::StringImpl::costDuringGC):
+        (WTF::StringImpl::isStatic):
+        (WTF::StringImpl::bufferOwnership):
+
 2013-08-14  Filip Pizlo  <fpizlo@apple.com>
 
         Typed arrays should be rewritten
index d268265..0e33061 100644 (file)
@@ -519,6 +519,9 @@ public:
     
     size_t costDuringGC()
     {
+        if (isStatic())
+            return 0;
+        
         if (bufferOwnership() == BufferSubstring)
             return divideRoundedUp(m_substringBuffer->costDuringGC(), refCount());
         
@@ -613,6 +616,8 @@ public:
         return hashSlowCase();
     }
     
+    bool isStatic() const { return m_refCount & s_refCountFlagIsStaticString; }
+
     inline size_t refCount() const
     {
         return m_refCount / s_refCountIncrement;
@@ -802,7 +807,6 @@ private:
     static const unsigned s_copyCharsInlineCutOff = 20;
 
     BufferOwnership bufferOwnership() const { return static_cast<BufferOwnership>(m_hashAndFlags & s_hashMaskBufferOwnership); }
-    bool isStatic() const { return m_refCount & s_refCountFlagIsStaticString; }
     template <class UCharPredicate> PassRefPtr<StringImpl> stripMatchedCharacters(UCharPredicate);
     template <typename CharType, class UCharPredicate> PassRefPtr<StringImpl> simplifyMatchedCharactersToSpace(UCharPredicate);
     template <typename CharType> static PassRefPtr<StringImpl> constructInternal(StringImpl*, unsigned);