[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

barraclough at apple.com barraclough at apple.com
Thu Apr 8 01:04:17 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 7f61c0bb77968503b4b3747f8a149d17dac891e5
Author: barraclough at apple.com <barraclough at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Jan 14 01:20:52 2010 +0000

    Rubber stamped by Sam Weinig & Darin Adler.
    
    Three quick fixes to UStringImpl.
        - The destroy() method can be switched back to a normal destructor; since we've switched
          the way we protect static strings to be using an odd ref-count the destroy() won't abort.
        - The cost() calculation logic was wrong.  If you have multiple JSStrings wrapping substrings
          of a base string, they would each report the full cost of the base string to the heap.
          Instead we should only be reporting once for the base string.
        - Remove the overloaded new operator calling fastMalloc, replace this with a 'using' to pick
          up the implementation from the parent class.
    
    * JavaScriptCore.exp:
    * runtime/UStringImpl.cpp:
    (JSC::UStringImpl::~UStringImpl):
    * runtime/UStringImpl.h:
    (JSC::UStringImpl::cost):
    (JSC::UStringImpl::deref):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53221 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 6f5eda5..d3ee866 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,23 @@
+2010-01-13  Gavin Barraclough  <barraclough at apple.com>
+
+        Rubber stamped by Sam Weinig & Darin Adler.
+
+        Three quick fixes to UStringImpl.
+            - The destroy() method can be switched back to a normal destructor; since we've switched
+              the way we protect static strings to be using an odd ref-count the destroy() won't abort.
+            - The cost() calculation logic was wrong.  If you have multiple JSStrings wrapping substrings
+              of a base string, they would each report the full cost of the base string to the heap.
+              Instead we should only be reporting once for the base string.
+            - Remove the overloaded new operator calling fastMalloc, replace this with a 'using' to pick
+              up the implementation from the parent class.
+
+        * JavaScriptCore.exp:
+        * runtime/UStringImpl.cpp:
+        (JSC::UStringImpl::~UStringImpl):
+        * runtime/UStringImpl.h:
+        (JSC::UStringImpl::cost):
+        (JSC::UStringImpl::deref):
+
 2010-01-13  Jocelyn Turcotte  <jocelyn.turcotte at nokia.com>
 
         Reviewed by Simon Hausmann.
diff --git a/JavaScriptCore/JavaScriptCore.exp b/JavaScriptCore/JavaScriptCore.exp
index 39285b9..e13e2e1 100644
--- a/JavaScriptCore/JavaScriptCore.exp
+++ b/JavaScriptCore/JavaScriptCore.exp
@@ -105,7 +105,7 @@ __ZN3JSC11JSByteArrayC1EPNS_9ExecStateEN3WTF17NonNullPassRefPtrINS_9StructureEEE
 __ZN3JSC11ParserArena5resetEv
 __ZN3JSC11UStringImpl12sharedBufferEv
 __ZN3JSC11UStringImpl6s_nullE
-__ZN3JSC11UStringImpl7destroyEv
+__ZN3JSC11UStringImplD1Ev
 __ZN3JSC11checkSyntaxEPNS_9ExecStateERKNS_10SourceCodeE
 __ZN3JSC12DateInstance4infoE
 __ZN3JSC12DateInstanceC1EPNS_9ExecStateEd
diff --git a/JavaScriptCore/runtime/UStringImpl.cpp b/JavaScriptCore/runtime/UStringImpl.cpp
index af9720b..4b0d1c9 100644
--- a/JavaScriptCore/runtime/UStringImpl.cpp
+++ b/JavaScriptCore/runtime/UStringImpl.cpp
@@ -59,7 +59,7 @@ SharedUChar* UStringImpl::sharedBuffer()
     return owner->baseSharedBuffer();
 }
 
-void UStringImpl::destroy()
+UStringImpl::~UStringImpl()
 {
     ASSERT(!isStatic());
     checkConsistency();
@@ -77,8 +77,6 @@ void UStringImpl::destroy()
             m_dataBuffer.asPtr<SharedUChar*>()->deref();
         }
     }
-
-    delete this;
 }
 
 }
diff --git a/JavaScriptCore/runtime/UStringImpl.h b/JavaScriptCore/runtime/UStringImpl.h
index e610e29..05b75cb 100644
--- a/JavaScriptCore/runtime/UStringImpl.h
+++ b/JavaScriptCore/runtime/UStringImpl.h
@@ -128,11 +128,14 @@ public:
     int size() const { return m_length; }
     size_t cost()
     {
-        UStringImpl* base = bufferOwnerString();
+        // For substrings, return the cost of the base string.
+        if (bufferOwnership() == BufferSubstring)
+            return m_dataBuffer.asPtr<UStringImpl*>()->cost();
+
         if (m_dataBuffer & s_reportedCostBit)
             return 0;
         m_dataBuffer |= s_reportedCostBit;
-        return base->m_length;
+        return m_length;
     }
     unsigned hash() const { if (!m_hash) m_hash = computeHash(data(), m_length); return m_hash; }
     unsigned computedHash() const { ASSERT(m_hash); return m_hash; } // fast path for Identifiers
@@ -141,7 +144,7 @@ public:
     void setIsIdentifier(bool isIdentifier) { m_isIdentifier = isIdentifier; }
 
     UStringImpl* ref() { m_refCount += s_refCountIncrement; return this; }
-    ALWAYS_INLINE void deref() { if (!(m_refCount -= s_refCountIncrement)) destroy(); }
+    ALWAYS_INLINE void deref() { if (!(m_refCount -= s_refCountIncrement)) delete this; }
 
     static WTF::PossiblyNull<UChar*> allocChars(size_t length)
     {
@@ -243,9 +246,11 @@ private:
         checkConsistency();
     }
 
-    void* operator new(size_t size) { return fastMalloc(size); }
+    using Noncopyable::operator new;
     void* operator new(size_t, void* inPlace) { return inPlace; }
 
+    ~UStringImpl();
+
     // This number must be at least 2 to avoid sharing empty, null as well as 1 character strings from SmallStrings.
     static const int s_minLengthToShare = 10;
     static const unsigned s_copyCharsInlineCutOff = 20;
@@ -256,7 +261,6 @@ private:
     static const int s_refCountIncrement = 2;
     static const int s_staticRefCountInitialValue = 1;
 
-    void destroy();
     UStringImpl* bufferOwnerString() { return (bufferOwnership() == BufferSubstring) ? m_dataBuffer.asPtr<UStringImpl*>() :  this; }
     const UStringImpl* bufferOwnerString() const { return (bufferOwnership() == BufferSubstring) ? m_dataBuffer.asPtr<UStringImpl*>() :  this; }
     SharedUChar* baseSharedBuffer();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list