Diff
Modified: trunk/Source/WTF/ChangeLog (155241 => 155242)
--- trunk/Source/WTF/ChangeLog 2013-09-07 05:34:54 UTC (rev 155241)
+++ trunk/Source/WTF/ChangeLog 2013-09-07 05:36:45 UTC (rev 155242)
@@ -1,3 +1,26 @@
+2013-09-06 Anders Carlsson <ander...@apple.com>
+
+ Add a new smart pointer type for fastMalloc'ed memory
+ https://bugs.webkit.org/show_bug.cgi?id=120911
+
+ Reviewed by Andreas Kling.
+
+ Due to an oversight on my part, Vector::releaseBuffer() currently returns an OwnPtr
+ which means that its data will be freed with operator delete instead of fastFree.
+
+ Fix this by introducing a new MllocPtr smart pointer class and change Vector::releaseBuffer() to return it instead.
+
+ * WTF.pro:
+ * WTF.vcxproj/WTF.vcxproj:
+ * WTF.vcxproj/WTF.vcxproj.filters:
+ * WTF.xcodeproj/project.pbxproj:
+ * wtf/CMakeLists.txt:
+ * wtf/FastAllocBase.h:
+ * wtf/MallocPtr.h: Added.
+ * wtf/Vector.h:
+ * wtf/text/StringBuffer.h:
+ * wtf/text/StringImpl.h:
+
2013-09-06 Andreas Kling <akl...@apple.com>
Remove old workaround for Nokia's Harmattan GCC on Qt/ARM.
Modified: trunk/Source/WTF/WTF.pro (155241 => 155242)
--- trunk/Source/WTF/WTF.pro 2013-09-07 05:34:54 UTC (rev 155241)
+++ trunk/Source/WTF/WTF.pro 2013-09-07 05:36:45 UTC (rev 155242)
@@ -79,6 +79,7 @@
ListHashSet.h \
Locker.h \
MainThread.h \
+ MallocPtr.h \
MathExtras.h \
MD5.h \
MediaTime.h \
Modified: trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj (155241 => 155242)
--- trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj 2013-09-07 05:34:54 UTC (rev 155241)
+++ trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj 2013-09-07 05:36:45 UTC (rev 155242)
@@ -184,6 +184,7 @@
<ClInclude Include="..\wtf\ListHashSet.h" />
<ClInclude Include="..\wtf\Locker.h" />
<ClInclude Include="..\wtf\MainThread.h" />
+ <ClInclude Include="..\wtf\MallocPtr.h" />
<ClInclude Include="..\wtf\MathExtras.h" />
<ClInclude Include="..\wtf\MD5.h" />
<ClInclude Include="..\wtf\MediaTime.h" />
Modified: trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters (155241 => 155242)
--- trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters 2013-09-07 05:34:54 UTC (rev 155241)
+++ trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters 2013-09-07 05:36:45 UTC (rev 155242)
@@ -473,6 +473,9 @@
<ClInclude Include="..\wtf\MainThread.h">
<Filter>wtf</Filter>
</ClInclude>
+ <ClInclude Include="..\wtf\MallocPtr.h">
+ <Filter>wtf</Filter>
+ </ClInclude>
<ClInclude Include="..\wtf\MathExtras.h">
<Filter>wtf</Filter>
</ClInclude>
Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (155241 => 155242)
--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2013-09-07 05:34:54 UTC (rev 155241)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2013-09-07 05:36:45 UTC (rev 155242)
@@ -50,6 +50,7 @@
14F3B0F715E45E4600210069 /* SaturatedArithmetic.h in Headers */ = {isa = PBXBuildFile; fileRef = 14F3B0F615E45E4600210069 /* SaturatedArithmetic.h */; settings = {ATTRIBUTES = (); }; };
1A1D8B9C173186CE00141DA4 /* FunctionDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A1D8B9B173186CE00141DA4 /* FunctionDispatcher.h */; };
1A1D8B9E1731879800141DA4 /* FunctionDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A1D8B9D1731879800141DA4 /* FunctionDispatcher.cpp */; };
+ 1A233C7D17DAA6E300A93ACF /* MallocPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A233C7C17DAA6E300A93ACF /* MallocPtr.h */; };
1A6BB769162F300500DD16DB /* StreamBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6BB768162F300500DD16DB /* StreamBuffer.h */; };
1FA47C8A152502DA00568D1B /* WebCoreThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1FA47C88152502DA00568D1B /* WebCoreThread.cpp */; };
1FA47C8B152502DA00568D1B /* WebCoreThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FA47C89152502DA00568D1B /* WebCoreThread.h */; };
@@ -315,6 +316,7 @@
14F3B0F615E45E4600210069 /* SaturatedArithmetic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SaturatedArithmetic.h; sourceTree = "<group>"; };
1A1D8B9B173186CE00141DA4 /* FunctionDispatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FunctionDispatcher.h; sourceTree = "<group>"; };
1A1D8B9D1731879800141DA4 /* FunctionDispatcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FunctionDispatcher.cpp; sourceTree = "<group>"; };
+ 1A233C7C17DAA6E300A93ACF /* MallocPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MallocPtr.h; sourceTree = "<group>"; };
1A3F6BE6174ADA2100B2EEA7 /* NeverDestroyed.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NeverDestroyed.h; sourceTree = "<group>"; };
1A6BB768162F300500DD16DB /* StreamBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StreamBuffer.h; sourceTree = "<group>"; };
1FA47C88152502DA00568D1B /* WebCoreThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCoreThread.cpp; sourceTree = "<group>"; };
@@ -696,11 +698,12 @@
A8A472C1151A825A004123FF /* ListHashSet.h */,
A736B3581799E11A00C6F05E /* LLVMHeaders.h */,
A8A472C3151A825A004123FF /* Locker.h */,
+ A8A472CA151A825B004123FF /* MD5.cpp */,
+ A8A472CB151A825B004123FF /* MD5.h */,
A8A472C6151A825A004123FF /* MainThread.cpp */,
A8A472C7151A825B004123FF /* MainThread.h */,
+ 1A233C7C17DAA6E300A93ACF /* MallocPtr.h */,
A8A472C9151A825B004123FF /* MathExtras.h */,
- A8A472CA151A825B004123FF /* MD5.cpp */,
- A8A472CB151A825B004123FF /* MD5.h */,
CD5497AA15857D0300B5BC30 /* MediaTime.cpp */,
CD5497AB15857D0300B5BC30 /* MediaTime.h */,
A8A472CC151A825B004123FF /* MessageQueue.h */,
@@ -996,6 +999,7 @@
A8A473D4151A825B004123FF /* HashFunctions.h in Headers */,
A8A473D5151A825B004123FF /* HashIterators.h in Headers */,
A8A473D6151A825B004123FF /* HashMap.h in Headers */,
+ 1A233C7D17DAA6E300A93ACF /* MallocPtr.h in Headers */,
A8A473D7151A825B004123FF /* HashSet.h in Headers */,
A8A473D9151A825B004123FF /* HashTable.h in Headers */,
A8A473DA151A825B004123FF /* HashTraits.h in Headers */,
Modified: trunk/Source/WTF/wtf/CMakeLists.txt (155241 => 155242)
--- trunk/Source/WTF/wtf/CMakeLists.txt 2013-09-07 05:34:54 UTC (rev 155241)
+++ trunk/Source/WTF/wtf/CMakeLists.txt 2013-09-07 05:36:45 UTC (rev 155242)
@@ -48,6 +48,7 @@
Locker.h
MD5.h
MainThread.h
+ MallocPtr.h
MathExtras.h
MediaTime.h
MessageQueue.h
Added: trunk/Source/WTF/wtf/MallocPtr.h (0 => 155242)
--- trunk/Source/WTF/wtf/MallocPtr.h (rev 0)
+++ trunk/Source/WTF/wtf/MallocPtr.h 2013-09-07 05:36:45 UTC (rev 155242)
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MallocPtr_h
+#define MallocPtr_h
+
+// MallocPtr is a smart pointer class that calls fastFree in its destructor.
+// It is intended to be used for pointers where the C++ lifetime semantics
+// (calling constructors and destructors) is not desired.
+
+namespace WTF {
+
+template<typename T> class MallocPtr {
+public:
+ MallocPtr()
+ : m_ptr(nullptr)
+ {
+ }
+
+ MallocPtr(std::nullptr_t)
+ : m_ptr(nullptr)
+ {
+ }
+
+ MallocPtr(MallocPtr&& other)
+ : m_ptr(other.leakPtr())
+ {
+ }
+
+ ~MallocPtr()
+ {
+ fastFree(m_ptr);
+ }
+
+ T* get() const
+ {
+ return m_ptr;
+ }
+
+ T *leakPtr() WARN_UNUSED_RETURN
+ {
+ T* ptr = m_ptr;
+ m_ptr = nullptr;
+ return ptr;
+ }
+
+ bool operator!() const
+ {
+ return !m_ptr;
+ }
+
+ MallocPtr& operator=(MallocPtr&& other)
+ {
+ MallocPtr ptr = std::move(other);
+ swap(ptr);
+
+ return *this;
+ }
+
+ void swap(MallocPtr& other)
+ {
+ std::swap(m_ptr, other.m_ptr);
+ }
+
+ template<typename U> friend MallocPtr<U> adoptMallocPtr(U*);
+
+private:
+ explicit MallocPtr(T* ptr)
+ : m_ptr(ptr)
+ {
+ }
+
+ T* m_ptr;
+};
+
+template<typename U> MallocPtr<U> adoptMallocPtr(U* ptr)
+{
+ return MallocPtr<U>(ptr);
+}
+
+} // namespace WTF
+
+using WTF::MallocPtr;
+using WTF::adoptMallocPtr;
+
+#endif // MallocPtr_h
Modified: trunk/Source/WTF/wtf/Vector.h (155241 => 155242)
--- trunk/Source/WTF/wtf/Vector.h 2013-09-07 05:34:54 UTC (rev 155241)
+++ trunk/Source/WTF/wtf/Vector.h 2013-09-07 05:36:45 UTC (rev 155242)
@@ -24,6 +24,7 @@
#include <wtf/Alignment.h>
#include <wtf/CheckedArithmetic.h>
#include <wtf/FastAllocBase.h>
+#include <wtf/MallocPtr.h>
#include <wtf/Noncopyable.h>
#include <wtf/NotFound.h>
#include <wtf/OwnPtr.h>
@@ -308,12 +309,12 @@
const T* buffer() const { return m_buffer; }
size_t capacity() const { return m_capacity; }
- OwnPtr<T> releaseBuffer()
+ MallocPtr<T> releaseBuffer()
{
T* buffer = m_buffer;
m_buffer = 0;
m_capacity = 0;
- return adoptPtr(buffer);
+ return adoptMallocPtr(buffer);
}
protected:
@@ -488,7 +489,7 @@
using Base::buffer;
using Base::capacity;
- OwnPtr<T> releaseBuffer()
+ MallocPtr<T> releaseBuffer()
{
if (buffer() == inlineBuffer())
return nullptr;
@@ -666,7 +667,7 @@
template<typename Iterator> void appendRange(Iterator start, Iterator end);
- OwnPtr<T> releaseBuffer();
+ MallocPtr<T> releaseBuffer();
void swap(Vector<T, inlineCapacity, OverflowHandler>& other)
{
@@ -1153,19 +1154,19 @@
}
template<typename T, size_t inlineCapacity, typename OverflowHandler>
-inline OwnPtr<T> Vector<T, inlineCapacity, OverflowHandler>::releaseBuffer()
+inline MallocPtr<T> Vector<T, inlineCapacity, OverflowHandler>::releaseBuffer()
{
- OwnPtr<T> buffer = Base::releaseBuffer();
+ auto buffer = Base::releaseBuffer();
if (inlineCapacity && !buffer && m_size) {
// If the vector had some data, but no buffer to release,
// that means it was using the inline buffer. In that case,
// we create a brand new buffer so the caller always gets one.
size_t bytes = m_size * sizeof(T);
- buffer = adoptPtr(static_cast<T*>(fastMalloc(bytes)));
+ buffer = adoptMallocPtr(static_cast<T*>(fastMalloc(bytes)));
memcpy(buffer.get(), data(), bytes);
}
m_size = 0;
- return buffer.release();
+ return buffer;
}
template<typename T, size_t inlineCapacity, typename OverflowHandler>
Modified: trunk/Source/WTF/wtf/text/StringBuffer.h (155241 => 155242)
--- trunk/Source/WTF/wtf/text/StringBuffer.h 2013-09-07 05:34:54 UTC (rev 155241)
+++ trunk/Source/WTF/wtf/text/StringBuffer.h 2013-09-07 05:36:45 UTC (rev 155242)
@@ -73,11 +73,11 @@
CharType& operator[](unsigned i) { ASSERT_WITH_SECURITY_IMPLICATION(i < m_length); return m_data[i]; }
- PassOwnPtr<CharType> release()
+ MallocPtr<CharType> release()
{
CharType* data = ""
m_data = 0;
- return adoptPtr(data);
+ return adoptMallocPtr(data);
}
private:
Modified: trunk/Source/WTF/wtf/text/StringImpl.h (155241 => 155242)
--- trunk/Source/WTF/wtf/text/StringImpl.h 2013-09-07 05:34:54 UTC (rev 155241)
+++ trunk/Source/WTF/wtf/text/StringImpl.h 2013-09-07 05:36:45 UTC (rev 155242)
@@ -28,7 +28,6 @@
#include <wtf/CompilationThread.h>
#include <wtf/Forward.h>
#include <wtf/MathExtras.h>
-#include <wtf/PassOwnPtr.h>
#include <wtf/StdLibExtras.h>
#include <wtf/StringHasher.h>
#include <wtf/Vector.h>
@@ -233,7 +232,7 @@
}
// Create a StringImpl adopting ownership of the provided buffer (BufferOwned)
- StringImpl(PassOwnPtr<LChar> characters, unsigned length)
+ StringImpl(MallocPtr<LChar> characters, unsigned length)
: m_refCount(s_refCountIncrement)
, m_length(length)
, m_data8(characters.leakPtr())
@@ -274,7 +273,7 @@
}
// Create a StringImpl adopting ownership of the provided buffer (BufferOwned)
- StringImpl(PassOwnPtr<UChar> characters, unsigned length)
+ StringImpl(MallocPtr<UChar> characters, unsigned length)
: m_refCount(s_refCountIncrement)
, m_length(length)
, m_data16(characters.leakPtr())
@@ -473,7 +472,7 @@
ASSERT(vector.data());
if (size > std::numeric_limits<unsigned>::max())
CRASH();
- return adoptRef(new StringImpl(vector.releaseBuffer().release(), size));
+ return adoptRef(new StringImpl(vector.releaseBuffer(), size));
}
return empty();
}
Modified: trunk/Source/WebCore/ChangeLog (155241 => 155242)
--- trunk/Source/WebCore/ChangeLog 2013-09-07 05:34:54 UTC (rev 155241)
+++ trunk/Source/WebCore/ChangeLog 2013-09-07 05:36:45 UTC (rev 155242)
@@ -1,3 +1,15 @@
+2013-09-06 Anders Carlsson <ander...@apple.com>
+
+ Add a new smart pointer type for fastMalloc'ed memory
+ https://bugs.webkit.org/show_bug.cgi?id=120911
+
+ Reviewed by Andreas Kling.
+
+ Update for WTF changes.
+
+ * platform/network/cf/FormDataStreamCFNet.cpp:
+ (WebCore::advanceCurrentStream):
+
2013-09-06 Dirk Schulze <k...@webkit.org>
Interpolate between CSS filter() and cached images
Modified: trunk/Source/WebCore/platform/network/cf/FormDataStreamCFNet.cpp (155241 => 155242)
--- trunk/Source/WebCore/platform/network/cf/FormDataStreamCFNet.cpp 2013-09-07 05:34:54 UTC (rev 155241)
+++ trunk/Source/WebCore/platform/network/cf/FormDataStreamCFNet.cpp 2013-09-07 05:36:45 UTC (rev 155242)
@@ -107,7 +107,7 @@
#if ENABLE(BLOB)
long long currentStreamRangeLength;
#endif
- OwnPtr<char> currentData;
+ MallocPtr<char> currentData;
CFReadStreamRef formStream;
unsigned long long streamLength;
unsigned long long bytesSent;
@@ -141,9 +141,9 @@
if (nextInput.m_type == FormDataElement::data) {
size_t size = nextInput.m_data.size();
- OwnPtr<char> data = ""
+ MallocPtr<char> data = ""
form->currentStream = CFReadStreamCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(data.get()), size, kCFAllocatorNull);
- form->currentData = data.release();
+ form->currentData = std::move(data);
} else {
#if ENABLE(BLOB)
// Check if the file has been changed or not if required.