[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:54:44 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit c5fed09f26a4ee11d4b3992bcea27d55fbf3c711
Author: barraclough at apple.com <barraclough at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Feb 22 06:50:44 2010 +0000

    JavaScriptCore: Make UString::m_data be const, and make the UChar owned/ref-counted by CrossThreadRefCounted be const too.
    
    Reviewed by Oliver Hunt.
    
    * runtime/UStringImpl.cpp:
    (JSC::UStringImpl::baseSharedBuffer):
    (JSC::UStringImpl::~UStringImpl):
    * runtime/UStringImpl.h:
    (JSC::UStringImpl::create):
    (JSC::UStringImpl::data):
    (JSC::UStringImpl::UStringImpl):
    * wtf/OwnFastMallocPtr.h:
    (WTF::OwnFastMallocPtr::~OwnFastMallocPtr):
    
    WebCore: Make the UChar owned/ref-counted by StringImpl::CrossThreadRefCounted be const.
    
    Reviewed by Oliver Hunt.
    
    * platform/text/StringImpl.cpp:
    (WebCore::StringImpl::sharedBuffer):
    * platform/text/StringImpl.h:
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55069 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 821ef95..62485e8 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,19 @@
+2010-02-21  Gavin Barraclough  <barraclough at apple.com>
+
+        Reviewed by Oliver Hunt.
+
+        Make UString::m_data be const, and make the UChar owned/ref-counted by CrossThreadRefCounted be const too.
+
+        * runtime/UStringImpl.cpp:
+        (JSC::UStringImpl::baseSharedBuffer):
+        (JSC::UStringImpl::~UStringImpl):
+        * runtime/UStringImpl.h:
+        (JSC::UStringImpl::create):
+        (JSC::UStringImpl::data):
+        (JSC::UStringImpl::UStringImpl):
+        * wtf/OwnFastMallocPtr.h:
+        (WTF::OwnFastMallocPtr::~OwnFastMallocPtr):
+
 2010-02-21  Yuta Kitamura  <yutak at chromium.org>
 
         Reviewed by Darin Adler.
diff --git a/JavaScriptCore/runtime/UStringImpl.cpp b/JavaScriptCore/runtime/UStringImpl.cpp
index aeecf47..1fe3eb2 100644
--- a/JavaScriptCore/runtime/UStringImpl.cpp
+++ b/JavaScriptCore/runtime/UStringImpl.cpp
@@ -79,7 +79,7 @@ SharedUChar* UStringImpl::baseSharedBuffer()
 
     if (bufferOwnership() != BufferShared) {
         m_refCountAndFlags = (m_refCountAndFlags & ~s_refCountMaskBufferOwnership) | BufferShared;
-        m_bufferShared = SharedUChar::create(new OwnFastMallocPtr<UChar>(m_data)).releaseRef();
+        m_bufferShared = SharedUChar::create(new SharableUChar(m_data)).releaseRef();
     }
 
     return m_bufferShared;
@@ -108,7 +108,7 @@ UStringImpl::~UStringImpl()
 
     if (bufferOwnership() != BufferInternal) {
         if (bufferOwnership() == BufferOwned)
-            fastFree(m_data);
+            fastFree(const_cast<UChar*>(m_data));
         else if (bufferOwnership() == BufferSubstring)
             m_bufferSubstring->deref();
         else {
diff --git a/JavaScriptCore/runtime/UStringImpl.h b/JavaScriptCore/runtime/UStringImpl.h
index 718cea4..cfc2c74 100644
--- a/JavaScriptCore/runtime/UStringImpl.h
+++ b/JavaScriptCore/runtime/UStringImpl.h
@@ -37,8 +37,9 @@
 namespace JSC {
 
 class IdentifierTable;
-  
-typedef CrossThreadRefCounted<OwnFastMallocPtr<UChar> > SharedUChar;
+
+typedef OwnFastMallocPtr<const UChar> SharableUChar;
+typedef CrossThreadRefCounted<SharableUChar> SharedUChar;
 
 class UStringOrRopeImpl : public Noncopyable {
 public:
@@ -126,7 +127,7 @@ public:
         return adoptRef(new UStringImpl(rep->m_data + offset, length, rep->bufferOwnerString()));
     }
 
-    static PassRefPtr<UStringImpl> create(PassRefPtr<SharedUChar> sharedBuffer, UChar* buffer, unsigned length)
+    static PassRefPtr<UStringImpl> create(PassRefPtr<SharedUChar> sharedBuffer, const UChar* buffer, unsigned length)
     {
         return adoptRef(new UStringImpl(buffer, length, sharedBuffer));
     }
@@ -162,7 +163,7 @@ public:
     }
 
     SharedUChar* sharedBuffer();
-    UChar* data() const { return m_data; }
+    const UChar* data() const { return m_data; }
     size_t cost()
     {
         // For substrings, return the cost of the base string.
@@ -229,7 +230,7 @@ private:
     }
 
     // Used to construct normal strings with an external buffer.
-    UStringImpl(UChar* data, unsigned length)
+    UStringImpl(const UChar* data, unsigned length)
         : UStringOrRopeImpl(length, BufferOwned)
         , m_data(data)
         , m_buffer(0)
@@ -241,7 +242,7 @@ private:
     // Used to construct static strings, which have an special refCount that can never hit zero.
     // This means that the static string will never be destroyed, which is important because
     // static strings will be shared across threads & ref-counted in a non-threadsafe manner.
-    UStringImpl(UChar* data, unsigned length, StaticStringConstructType)
+    UStringImpl(const UChar* data, unsigned length, StaticStringConstructType)
         : UStringOrRopeImpl(length, ConstructStaticString)
         , m_data(data)
         , m_buffer(0)
@@ -251,7 +252,7 @@ private:
     }
 
     // Used to create new strings that are a substring of an existing string.
-    UStringImpl(UChar* data, unsigned length, PassRefPtr<UStringImpl> base)
+    UStringImpl(const UChar* data, unsigned length, PassRefPtr<UStringImpl> base)
         : UStringOrRopeImpl(length, BufferSubstring)
         , m_data(data)
         , m_bufferSubstring(base.releaseRef())
@@ -266,7 +267,7 @@ private:
     }
 
     // Used to construct new strings sharing an existing shared buffer.
-    UStringImpl(UChar* data, unsigned length, PassRefPtr<SharedUChar> sharedBuffer)
+    UStringImpl(const UChar* data, unsigned length, PassRefPtr<SharedUChar> sharedBuffer)
         : UStringOrRopeImpl(length, BufferShared)
         , m_data(data)
         , m_bufferShared(sharedBuffer.releaseRef())
@@ -288,7 +289,7 @@ private:
     bool isStatic() const { return m_refCountAndFlags & s_refCountFlagStatic; }
 
     // unshared data
-    UChar* m_data;
+    const UChar* m_data;
     union {
         void* m_buffer;
         UStringImpl* m_bufferSubstring;
diff --git a/JavaScriptCore/wtf/OwnFastMallocPtr.h b/JavaScriptCore/wtf/OwnFastMallocPtr.h
index c88235a..8b6cbf4 100644
--- a/JavaScriptCore/wtf/OwnFastMallocPtr.h
+++ b/JavaScriptCore/wtf/OwnFastMallocPtr.h
@@ -35,7 +35,7 @@ namespace WTF {
 
         ~OwnFastMallocPtr()
         {
-            fastFree(m_ptr);
+            fastFree(const_cast<void*>(static_cast<const void*>(const_cast<const T*>(m_ptr))));
         }
 
         T* get() const { return m_ptr; }
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 8ff957e..b9639c1 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,13 @@
+2010-02-21  Gavin Barraclough  <barraclough at apple.com>
+
+        Reviewed by Oliver Hunt.
+
+        Make the UChar owned/ref-counted by StringImpl::CrossThreadRefCounted be const.
+
+        * platform/text/StringImpl.cpp:
+        (WebCore::StringImpl::sharedBuffer):
+        * platform/text/StringImpl.h:
+
 2010-02-07  Yuzo Fujishima  <yuzo at google.com>
 
         Reviewed by Eric Seidel.
diff --git a/WebCore/platform/text/StringImpl.cpp b/WebCore/platform/text/StringImpl.cpp
index 3704c4e..abb33b0 100644
--- a/WebCore/platform/text/StringImpl.cpp
+++ b/WebCore/platform/text/StringImpl.cpp
@@ -1031,7 +1031,7 @@ StringImpl::SharedUChar* StringImpl::sharedBuffer()
 
     if (ownership == BufferOwned) {
         ASSERT(!m_sharedBuffer);
-        m_sharedBuffer = SharedUChar::create(new OwnFastMallocPtr<UChar>(const_cast<UChar*>(m_data))).releaseRef();
+        m_sharedBuffer = SharedUChar::create(new SharableUChar(const_cast<UChar*>(m_data))).releaseRef();
         m_refCountAndFlags = (m_refCountAndFlags & ~s_refCountMaskBufferOwnership) | BufferShared;
     }
 
diff --git a/WebCore/platform/text/StringImpl.h b/WebCore/platform/text/StringImpl.h
index 65848bb..2c66019 100644
--- a/WebCore/platform/text/StringImpl.h
+++ b/WebCore/platform/text/StringImpl.h
@@ -71,7 +71,8 @@ private:
         BufferShared,
     };
 
-    typedef CrossThreadRefCounted<OwnFastMallocPtr<UChar> > SharedUChar;
+    typedef OwnFastMallocPtr<const UChar> SharableUChar;
+    typedef CrossThreadRefCounted<SharableUChar> SharedUChar;
 
     // Used to create the empty string (""), automatically hashes.
     StringImpl();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list