[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.17-1283-gcf603cf

barraclough at apple.com barraclough at apple.com
Tue Jan 5 23:58:39 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 7f6d8275956297394b583118461a0871bfedd107
Author: barraclough at apple.com <barraclough at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Dec 22 22:05:17 2009 +0000

    Fix a couple of problems with UntypedPtrAndBitfield.
    
    Reviewed by Sam Weinig.
    
    Add a m_leaksPtr to reduce false positives from leaks in debug builds
    (this isn't perfect because we'd like a solution for release builds,
    but this is now at least as good as a PtrAndFlags would be).
    
    Switch SmallStringsto use a regular string for the base, rather than
    a static one.  UntypedPtrAndBitfield assumes all strings are at least
    8 byte aligned; this migt not be true of static strings.  Shared buffers
    are heap allocated, as are all UStringImpls other than static strings.
    Static strings cannot end up being the owner string of substrings,
    since the only static strings are length 0.
    
    * runtime/SmallStrings.cpp:
    (JSC::SmallStringsStorage::SmallStringsStorage):
    * runtime/UStringImpl.h:
    (JSC::UntypedPtrAndBitfield::UntypedPtrAndBitfield):
    (JSC::UStringImpl::UStringImpl):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52500 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 1d34bff..a8b7453 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,26 @@
+2009-12-22  Gavin Barraclough  <barraclough at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Fix a couple of problems with UntypedPtrAndBitfield.
+
+        Add a m_leaksPtr to reduce false positives from leaks in debug builds
+        (this isn't perfect because we'd like a solution for release builds,
+        but this is now at least as good as a PtrAndFlags would be).
+
+        Switch SmallStringsto use a regular string for the base, rather than
+        a static one.  UntypedPtrAndBitfield assumes all strings are at least
+        8 byte aligned; this migt not be true of static strings.  Shared buffers
+        are heap allocated, as are all UStringImpls other than static strings.
+        Static strings cannot end up being the owner string of substrings,
+        since the only static strings are length 0.
+
+        * runtime/SmallStrings.cpp:
+        (JSC::SmallStringsStorage::SmallStringsStorage):
+        * runtime/UStringImpl.h:
+        (JSC::UntypedPtrAndBitfield::UntypedPtrAndBitfield):
+        (JSC::UStringImpl::UStringImpl):
+
 2009-12-22  Kwang Yul Seo  <skyul at company100.net>
 
         Reviewed by Darin Adler.
diff --git a/JavaScriptCore/runtime/SmallStrings.cpp b/JavaScriptCore/runtime/SmallStrings.cpp
index 068c81e..ac71735 100644
--- a/JavaScriptCore/runtime/SmallStrings.cpp
+++ b/JavaScriptCore/runtime/SmallStrings.cpp
@@ -41,22 +41,17 @@ public:
     UString::Rep* rep(unsigned char character) { return &m_reps[character]; }
 
 private:
-    UChar m_characters[numCharactersToStore];
-    UString::Rep m_base;
     UString::Rep m_reps[numCharactersToStore];
 };
 
 SmallStringsStorage::SmallStringsStorage()
-    : m_base(m_characters, numCharactersToStore, UStringImpl::ConstructStaticString)
 {
-    m_base.checkConsistency();
-
-    for (unsigned i = 0; i < numCharactersToStore; ++i)
-        m_characters[i] = i;
-
-    memset(&m_reps, 0, sizeof(m_reps));
-    for (unsigned i = 0; i < numCharactersToStore; ++i)
-        new (&m_reps[i]) UString::Rep(m_base.data() + i, 1, &m_base);
+    UChar* characterBuffer = 0;
+    RefPtr<UStringImpl> baseString = UStringImpl::createUninitialized(numCharactersToStore, characterBuffer);
+    for (unsigned i = 0; i < numCharactersToStore; ++i) {
+        characterBuffer[i] = i;
+        new (&m_reps[i]) UString::Rep(&characterBuffer[i], 1, PassRefPtr<UStringImpl>(baseString));
+    }
 }
 
 SmallStrings::SmallStrings()
diff --git a/JavaScriptCore/runtime/UStringImpl.h b/JavaScriptCore/runtime/UStringImpl.h
index eee6210..792b25a 100644
--- a/JavaScriptCore/runtime/UStringImpl.h
+++ b/JavaScriptCore/runtime/UStringImpl.h
@@ -44,6 +44,9 @@ public:
 
     UntypedPtrAndBitfield(void* ptrValue, uintptr_t bitValue)
         : m_value(reinterpret_cast<uintptr_t>(ptrValue) | bitValue)
+#ifndef NDEBUG
+        , m_leaksPtr(ptrValue)
+#endif
     {
         ASSERT(ptrValue == asPtr<void*>());
         ASSERT((*this & ~s_alignmentMask) == bitValue);
@@ -72,6 +75,9 @@ public:
 private:
     static const uintptr_t s_alignmentMask = ~static_cast<uintptr_t>(0x7);
     uintptr_t m_value;
+#ifndef NDEBUG
+        void* m_leaksPtr; // Only used to allow tools like leaks on OSX to detect that the memory is referenced.
+#endif
 };
 
 class UStringImpl : Noncopyable {
@@ -216,6 +222,11 @@ private:
         , m_identifierTable(0)
         , m_dataBuffer(base.releaseRef(), BufferSubstring)
     {
+        // Do use static strings as a base for substrings; UntypedPtrAndBitfield assumes
+        // that all pointers will be at least 8-byte aligned, we cannot guarantee that of
+        // UStringImpls that are not heap allocated.
+        ASSERT(m_dataBuffer.asPtr<UStringImpl*>()->size());
+        ASSERT(!m_dataBuffer.asPtr<UStringImpl*>()->isStatic());
         checkConsistency();
     }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list