Diff
Modified: trunk/Source/WebCore/ChangeLog (176430 => 176431)
--- trunk/Source/WebCore/ChangeLog 2014-11-21 02:10:33 UTC (rev 176430)
+++ trunk/Source/WebCore/ChangeLog 2014-11-21 02:27:20 UTC (rev 176431)
@@ -1,3 +1,73 @@
+2014-11-20 Geoffrey Garen <[email protected]>
+
+ Removed the custom allocator for PODRedBlackTree
+ https://bugs.webkit.org/show_bug.cgi?id=138942
+
+ Reviewed by Sam Weinig.
+
+ bmalloc is fast enough.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/PODArena.h: Removed.
+ * platform/PODFreeListArena.h: Removed. This is the point of the patch.
+
+ * platform/PODIntervalTree.h:
+ (WebCore::PODIntervalTree::PODIntervalTree): Deleted. As a side effect
+ of removing our custom allocator, we can no longer have a special
+ "I'm not initialized yet" state. Instead, the tree either exists or not,
+ like an idiomatic C++ object.
+
+ * platform/PODRedBlackTree.h:
+ (WebCore::PODRedBlackTree::PODRedBlackTree): Ditto.
+
+ (WebCore::PODRedBlackTree::~PODRedBlackTree): We need to clear in our
+ destructor because we can no longer rely on the arena destructor
+ implicitly freeing our tree nodes.
+
+ Side note: This change basically removes the whole reason for having
+ a purpose-built tree for POD data. We should probably remove this whole
+ data structure in a follow-up patch, and just use a standard tree.
+
+ (WebCore::PODRedBlackTree::clear):
+ (WebCore::PODRedBlackTree::add):
+ (WebCore::PODRedBlackTree::remove):
+ (WebCore::PODRedBlackTree::contains):
+ (WebCore::PODRedBlackTree::visitInorder):
+ (WebCore::PODRedBlackTree::size):
+ (WebCore::PODRedBlackTree::checkInvariants):
+ (WebCore::PODRedBlackTree::dump):
+ (WebCore::PODRedBlackTree::deleteNode):
+ (WebCore::PODRedBlackTree::markFree): Use normal new/delete, and mark
+ ourselves as fast allocated so we get the bmalloc goodness.
+
+ (WebCore::PODRedBlackTree::isInitialized): Deleted.
+ (WebCore::PODRedBlackTree::initIfNeeded): Deleted.
+
+ * rendering/FloatingObjects.cpp:
+ (WebCore::FloatingObjects::findNextFloatLogicalBottomBelow):
+ (WebCore::FloatingObjects::findNextFloatLogicalBottomBelowForBlock):
+ (WebCore::FloatingObjects::FloatingObjects):
+ (WebCore::FloatingObjects::clear):
+ (WebCore::FloatingObjects::addPlacedObject):
+ (WebCore::FloatingObjects::removePlacedObject):
+ (WebCore::FloatingObjects::computePlacedFloatsTree):
+ (WebCore::FloatingObjects::placedFloatsTree):
+ (WebCore::FloatingObjects::logicalLeftOffsetForPositioningFloat):
+ (WebCore::FloatingObjects::logicalRightOffsetForPositioningFloat):
+ (WebCore::FloatingObjects::logicalLeftOffset):
+ (WebCore::FloatingObjects::logicalRightOffset): POD tree had a slightly
+ weird behavior in which it was valid to use some of its APIs without
+ first initializing it, but not others. It's not really possible to model
+ that behavior with normal C++ objects that use new/delete, so instead
+ I added some explicit NULL checks.
+
+ * rendering/FloatingObjects.h:
+ * rendering/RenderFlowThread.cpp:
+ (WebCore::RenderFlowThread::updateRegionsFlowThreadPortionRect):
+ * rendering/RenderView.cpp:
+ (WebCore::RenderView::intervalArena): Deleted.
+ * rendering/RenderView.h: Removed custom-allocator-related cruft.
+
2014-11-20 Dean Jackson <[email protected]>
Support unprefixed animation event types
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (176430 => 176431)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2014-11-21 02:10:33 UTC (rev 176430)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2014-11-21 02:27:20 UTC (rev 176431)
@@ -980,7 +980,6 @@
1CFAE3230A6D6A3F0032593D /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1CFAE3220A6D6A3F0032593D /* libobjc.dylib */; };
1F3C3BEA135CAF3C00B8C1AC /* MediaControls.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1F3C3BE8135CAF3C00B8C1AC /* MediaControls.cpp */; };
1F3C3BEB135CAF3C00B8C1AC /* MediaControls.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F3C3BE9135CAF3C00B8C1AC /* MediaControls.h */; };
- 1F3F19531499CA7600A5AEA7 /* PODFreeListArena.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F3F19521499CA7600A5AEA7 /* PODFreeListArena.h */; settings = {ATTRIBUTES = (Private, ); }; };
1F72BF0A187FD4490009BCB3 /* TileControllerMemoryHandlerIOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1F72BF08187FD4270009BCB3 /* TileControllerMemoryHandlerIOS.cpp */; };
1F72BF0B187FD45C0009BCB3 /* TileControllerMemoryHandlerIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F72BF09187FD4270009BCB3 /* TileControllerMemoryHandlerIOS.h */; settings = {ATTRIBUTES = (Private, ); }; };
1FAFBF1815A5FA6E00083A20 /* UTIUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1FAFBF1715A5FA5200083A20 /* UTIUtilities.mm */; };
@@ -5317,7 +5316,6 @@
BCB773620C17853D00132BA4 /* JSNodeFilterCondition.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB7735F0C17853D00132BA4 /* JSNodeFilterCondition.h */; };
BCB773630C17853D00132BA4 /* JSNodeFilterCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCB773600C17853D00132BA4 /* JSNodeFilterCustom.cpp */; };
BCB92D4F1293550B00C8387F /* FontBaseline.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB92D4E1293550B00C8387F /* FontBaseline.h */; settings = {ATTRIBUTES = (Private, ); }; };
- BCBB8AB813F1AFB000734DF0 /* PODArena.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBB8AB413F1AFB000734DF0 /* PODArena.h */; settings = {ATTRIBUTES = (Private, ); }; };
BCBB8AB913F1AFB000734DF0 /* PODInterval.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBB8AB513F1AFB000734DF0 /* PODInterval.h */; settings = {ATTRIBUTES = (Private, ); }; };
BCBB8ABA13F1AFB000734DF0 /* PODIntervalTree.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBB8AB613F1AFB000734DF0 /* PODIntervalTree.h */; settings = {ATTRIBUTES = (Private, ); }; };
BCBB8ABB13F1AFB000734DF0 /* PODRedBlackTree.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBB8AB713F1AFB000734DF0 /* PODRedBlackTree.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -7978,7 +7976,6 @@
1CFAE3220A6D6A3F0032593D /* libobjc.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libobjc.dylib; path = /usr/lib/libobjc.dylib; sourceTree = "<absolute>"; };
1F3C3BE8135CAF3C00B8C1AC /* MediaControls.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaControls.cpp; sourceTree = "<group>"; };
1F3C3BE9135CAF3C00B8C1AC /* MediaControls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaControls.h; sourceTree = "<group>"; };
- 1F3F19521499CA7600A5AEA7 /* PODFreeListArena.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PODFreeListArena.h; sourceTree = "<group>"; };
1F72BF08187FD4270009BCB3 /* TileControllerMemoryHandlerIOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TileControllerMemoryHandlerIOS.cpp; path = ios/TileControllerMemoryHandlerIOS.cpp; sourceTree = "<group>"; };
1F72BF09187FD4270009BCB3 /* TileControllerMemoryHandlerIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TileControllerMemoryHandlerIOS.h; path = ios/TileControllerMemoryHandlerIOS.h; sourceTree = "<group>"; };
1FAFBF1615A5FA5200083A20 /* UTIUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UTIUtilities.h; sourceTree = "<group>"; };
@@ -12748,7 +12745,6 @@
BCB7735F0C17853D00132BA4 /* JSNodeFilterCondition.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSNodeFilterCondition.h; sourceTree = "<group>"; };
BCB773600C17853D00132BA4 /* JSNodeFilterCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSNodeFilterCustom.cpp; sourceTree = "<group>"; };
BCB92D4E1293550B00C8387F /* FontBaseline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontBaseline.h; sourceTree = "<group>"; };
- BCBB8AB413F1AFB000734DF0 /* PODArena.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PODArena.h; sourceTree = "<group>"; };
BCBB8AB513F1AFB000734DF0 /* PODInterval.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PODInterval.h; sourceTree = "<group>"; };
BCBB8AB613F1AFB000734DF0 /* PODIntervalTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PODIntervalTree.h; sourceTree = "<group>"; };
BCBB8AB713F1AFB000734DF0 /* PODRedBlackTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PODRedBlackTree.h; sourceTree = "<group>"; };
@@ -21478,8 +21474,6 @@
1AD8F81A11CAB9E900E93E54 /* PlatformStrategies.cpp */,
1AD8F81911CAB9E900E93E54 /* PlatformStrategies.h */,
935C476A09AC4D4F00A6AAB4 /* PlatformWheelEvent.h */,
- BCBB8AB413F1AFB000734DF0 /* PODArena.h */,
- 1F3F19521499CA7600A5AEA7 /* PODFreeListArena.h */,
BCBB8AB513F1AFB000734DF0 /* PODInterval.h */,
BCBB8AB613F1AFB000734DF0 /* PODIntervalTree.h */,
BCBB8AB713F1AFB000734DF0 /* PODRedBlackTree.h */,
@@ -25667,8 +25661,6 @@
71E2183A17359FB8006E6E4D /* PlugInsResources.h in Headers */,
1AA8799011CBE846003C664F /* PluginStrategy.h in Headers */,
0AFDAC3D10F5448C00E1F3D2 /* PluginViewBase.h in Headers */,
- BCBB8AB813F1AFB000734DF0 /* PODArena.h in Headers */,
- 1F3F19531499CA7600A5AEA7 /* PODFreeListArena.h in Headers */,
BCBB8AB913F1AFB000734DF0 /* PODInterval.h in Headers */,
BCBB8ABA13F1AFB000734DF0 /* PODIntervalTree.h in Headers */,
BCBB8ABB13F1AFB000734DF0 /* PODRedBlackTree.h in Headers */,
Deleted: trunk/Source/WebCore/platform/PODArena.h (176430 => 176431)
--- trunk/Source/WebCore/platform/PODArena.h 2014-11-21 02:10:33 UTC (rev 176430)
+++ trunk/Source/WebCore/platform/PODArena.h 2014-11-21 02:27:20 UTC (rev 176431)
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2010 Google 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 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 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 PODArena_h
-#define PODArena_h
-
-#include <stdint.h>
-#include <wtf/Assertions.h>
-#include <wtf/FastMalloc.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-// An arena which allocates only Plain Old Data (POD), or classes and
-// structs bottoming out in Plain Old Data. NOTE: the constructors of
-// the objects allocated in this arena are called, but _not_ their
-// destructors.
-
-class PODArena : public RefCounted<PODArena> {
-protected:
- virtual ~PODArena() { }
- friend class WTF::RefCounted<PODArena>;
-
- // Returns the alignment requirement for classes and structs on the
- // current platform.
- template <class T> static size_t minAlignment()
- {
- return std::alignment_of<T>::value;
- }
-
- // Rounds up the given allocation size to the specified alignment.
- size_t roundUp(size_t size, size_t alignment)
- {
- ASSERT(!(alignment % 2));
- return (size + alignment - 1) & ~(alignment - 1);
- }
-};
-
-} // namespace WebCore
-
-#endif // PODArena_h
Deleted: trunk/Source/WebCore/platform/PODFreeListArena.h (176430 => 176431)
--- trunk/Source/WebCore/platform/PODFreeListArena.h 2014-11-21 02:10:33 UTC (rev 176430)
+++ trunk/Source/WebCore/platform/PODFreeListArena.h 2014-11-21 02:27:20 UTC (rev 176431)
@@ -1,192 +0,0 @@
-/*
- * Copyright (C) 2011 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. ``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
- * 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 PODFreeListArena_h
-#define PODFreeListArena_h
-
-#include "PODArena.h"
-
-namespace WebCore {
-
-template <class T>
-class PODFreeListArena : public PODArena {
-public:
- static PassRefPtr<PODFreeListArena> create()
- {
- return adoptRef(new PODFreeListArena);
- }
-
- template<class Argument1Type> T* allocateObject(const Argument1Type& argument1)
- {
-#if defined(ADDRESS_SANITIZER)
- return new T(argument1);
-#else
- size_t roundedSize = roundUp(sizeof(T), minAlignment<T>());
- void* ptr = allocate(roundedSize);
- if (ptr) {
- // Use placement operator new to allocate a T at this location.
- new(ptr) T(argument1);
- }
- return static_cast<T*>(ptr);
-#endif
- }
-
- void freeObject(T* ptr)
- {
-#if defined(ADDRESS_SANITIZER)
- delete ptr;
-#else
- for (typename Vector<OwnPtr<FreeListChunk>>::const_iterator it = m_chunks.begin(), end = m_chunks.end(); it != end; ++it) {
- FreeListChunk* chunk = static_cast<FreeListChunk*>(it->get());
- if (chunk->contains(ptr))
- chunk->free(ptr);
- }
-#endif
- }
-
-private:
- // The initial size of allocated chunks; increases as necessary to
- // satisfy large allocations. Mainly public for unit tests.
- enum {
- DefaultChunkSize = 16384
- };
-
- PODFreeListArena()
- : m_current(0)
- , m_currentChunkSize(DefaultChunkSize)
- {
- }
-
- void* allocate(size_t size)
- {
- void* ptr = 0;
- if (m_current) {
- // First allocate from the current chunk.
- ptr = m_current->allocate(size);
- if (!ptr) {
- // Check if we can allocate from other chunks' free list.
- for (typename Vector<OwnPtr<FreeListChunk>>::const_iterator it = m_chunks.begin(), end = m_chunks.end(); it != end; ++it) {
- FreeListChunk* chunk = static_cast<FreeListChunk*>(it->get());
- if (chunk->hasFreeList()) {
- ptr = chunk->allocate(size);
- if (ptr)
- break;
- }
- }
- }
- }
-
- if (!ptr) {
- if (size > m_currentChunkSize)
- m_currentChunkSize = size;
- m_chunks.append(adoptPtr(new FreeListChunk(m_currentChunkSize)));
- m_current = m_chunks.last().get();
- ptr = m_current->allocate(size);
- }
- return ptr;
- }
-
- // Manages a chunk of memory and individual allocations out of it.
- class FreeListChunk {
- WTF_MAKE_NONCOPYABLE(FreeListChunk);
-
- struct FreeCell {
- FreeCell *m_next;
- };
- public:
- explicit FreeListChunk(size_t size)
- : m_size(size)
- , m_currentOffset(0)
- , m_freeList(0)
- {
- m_base = static_cast<uint8_t*>(fastMalloc(size));
- }
-
- // Frees the memory allocated from the Allocator in the
- // constructor.
- ~FreeListChunk()
- {
- fastFree(m_base);
- }
-
- // Returns a pointer to "size" bytes of storage, or 0 if this
- // Chunk could not satisfy the allocation.
- void* allocate(size_t size)
- {
- if (m_freeList) {
- // Reuse a cell from the free list.
- void *cell = m_freeList;
- m_freeList = m_freeList->m_next;
- return cell;
- }
-
- // Check for overflow
- if (m_currentOffset + size < m_currentOffset)
- return 0;
-
- if (m_currentOffset + size > m_size)
- return 0;
-
- void* result = m_base + m_currentOffset;
- m_currentOffset += size;
- return result;
- }
-
- void free(void* ptr)
- {
- // Add the pointer to free list.
- ASSERT(contains(ptr));
-
- FreeCell* cell = reinterpret_cast<FreeCell*>(ptr);
- cell->m_next = m_freeList;
- m_freeList = cell;
- }
-
- bool contains(void* ptr) const
- {
- return ptr >= m_base && ptr < m_base + m_size;
- }
-
- bool hasFreeList() const
- {
- return m_freeList;
- }
-
- private:
- uint8_t* m_base;
- size_t m_size;
- size_t m_currentOffset;
-
- FreeCell *m_freeList;
- };
-
- FreeListChunk* m_current;
- size_t m_currentChunkSize;
- Vector<OwnPtr<FreeListChunk>> m_chunks;
-};
-
-} // namespace WebCore
-
-#endif
Modified: trunk/Source/WebCore/platform/PODIntervalTree.h (176430 => 176431)
--- trunk/Source/WebCore/platform/PODIntervalTree.h 2014-11-21 02:10:33 UTC (rev 176430)
+++ trunk/Source/WebCore/platform/PODIntervalTree.h 2014-11-21 02:27:20 UTC (rev 176431)
@@ -26,7 +26,6 @@
#ifndef PODIntervalTree_h
#define PODIntervalTree_h
-#include "PODArena.h"
#include "PODInterval.h"
#include "PODRedBlackTree.h"
#include "ValueToString.h"
@@ -67,6 +66,7 @@
// intervals in the tree.
template<class T, class UserData = void*>
class PODIntervalTree : public PODRedBlackTree<PODInterval<T, UserData>> {
+ WTF_MAKE_FAST_ALLOCATED;
WTF_MAKE_NONCOPYABLE(PODIntervalTree);
public:
// Typedef to reduce typing when declaring intervals to be stored in
@@ -74,24 +74,12 @@
typedef PODInterval<T, UserData> IntervalType;
typedef PODIntervalSearchAdapter<T, UserData> IntervalSearchAdapterType;
- PODIntervalTree(UninitializedTreeEnum unitializedTree)
- : PODRedBlackTree<IntervalType>(unitializedTree)
- {
- init();
- }
-
PODIntervalTree()
: PODRedBlackTree<IntervalType>()
{
init();
}
- explicit PODIntervalTree(PassRefPtr<PODArena> arena)
- : PODRedBlackTree<IntervalType>(arena)
- {
- init();
- }
-
// Returns all intervals in the tree which overlap the given query
// interval. The returned intervals are sorted by increasing low
// endpoint.
Modified: trunk/Source/WebCore/platform/PODRedBlackTree.h (176430 => 176431)
--- trunk/Source/WebCore/platform/PODRedBlackTree.h 2014-11-21 02:10:33 UTC (rev 176430)
+++ trunk/Source/WebCore/platform/PODRedBlackTree.h 2014-11-21 02:27:20 UTC (rev 176431)
@@ -72,7 +72,6 @@
#ifndef PODRedBlackTree_h
#define PODRedBlackTree_h
-#include "PODFreeListArena.h"
#include "ValueToString.h"
#include <wtf/Assertions.h>
#include <wtf/Noncopyable.h>
@@ -85,12 +84,9 @@
namespace WebCore {
-enum UninitializedTreeEnum {
- UninitializedTree
-};
-
template<class T>
class PODRedBlackTree {
+ WTF_MAKE_FAST_ALLOCATED;
public:
class Node;
@@ -102,11 +98,7 @@
virtual ~Visitor() { }
};
- // Constructs a new red-black tree without allocating an arena.
- // isInitialized will return false in this case. initIfNeeded can be used
- // to init the structure. This constructor is usefull for creating
- // lazy initialized tree.
- explicit PODRedBlackTree(UninitializedTreeEnum)
+ PODRedBlackTree()
: m_root(0)
, m_needsFullOrderingComparisons(false)
#ifndef NDEBUG
@@ -115,69 +107,28 @@
{
}
- // Constructs a new red-black tree, allocating temporary objects
- // from a newly constructed PODFreeListArena.
- PODRedBlackTree()
- : m_arena(PODFreeListArena<Node>::create())
- , m_root(0)
- , m_needsFullOrderingComparisons(false)
-#ifndef NDEBUG
- , m_verboseDebugging(false)
-#endif
+ virtual ~PODRedBlackTree()
{
+ clear();
}
- // Constructs a new red-black tree, allocating temporary objects
- // from the given PODArena.
- explicit PODRedBlackTree(PassRefPtr<PODFreeListArena<Node>> arena)
- : m_arena(arena)
- , m_root(0)
- , m_needsFullOrderingComparisons(false)
-#ifndef NDEBUG
- , m_verboseDebugging(false)
-#endif
- {
- }
-
- virtual ~PODRedBlackTree() { }
-
// Clearing will delete the contents of the tree. After this call
// isInitialized will return false.
void clear()
{
markFree(m_root);
- m_arena = 0;
m_root = 0;
}
- bool isInitialized() const
- {
- return m_arena;
- }
-
- void initIfNeeded()
- {
- if (!m_arena)
- m_arena = PODFreeListArena<Node>::create();
- }
-
- void initIfNeeded(PODFreeListArena<Node>* arena)
- {
- if (!m_arena)
- m_arena = arena;
- }
-
void add(const T& data)
{
- ASSERT(isInitialized());
- Node* node = m_arena->template allocateObject<T>(data);
+ Node* node = new Node(data);
insertNode(node);
}
// Returns true if the datum was found in the tree.
bool remove(const T& data)
{
- ASSERT(isInitialized());
Node* node = treeSearch(data);
if (node) {
deleteNode(node);
@@ -188,13 +139,11 @@
bool contains(const T& data) const
{
- ASSERT(isInitialized());
return treeSearch(data);
}
void visitInorder(Visitor* visitor) const
{
- ASSERT(isInitialized());
if (!m_root)
return;
visitInorderImpl(m_root, visitor);
@@ -202,7 +151,6 @@
int size() const
{
- ASSERT(isInitialized());
Counter counter;
visitInorder(&counter);
return counter.count();
@@ -216,7 +164,6 @@
virtual bool checkInvariants() const
{
- ASSERT(isInitialized());
int blackCount;
return checkInvariantsFromNode(m_root, &blackCount);
}
@@ -226,8 +173,7 @@
// debugging purposes.
void dump() const
{
- if (m_arena)
- dumpFromNode(m_root, 0);
+ dumpFromNode(m_root, 0);
}
// Turns on or off verbose debugging of the tree, causing many
@@ -248,6 +194,7 @@
// an internal concept; users of the tree deal only with the data
// they store in it.
class Node {
+ WTF_MAKE_FAST_ALLOCATED;
WTF_MAKE_NONCOPYABLE(Node);
public:
// Constructor. Newly-created nodes are colored red.
@@ -695,7 +642,7 @@
if (y->color() == Black)
deleteFixup(x, xParent);
- m_arena->freeObject(y);
+ delete y;
}
// Visits the subtree rooted at the given node in order.
@@ -717,7 +664,7 @@
markFree(node->left());
if (node->right())
markFree(node->right());
- m_arena->freeObject(node);
+ delete node;
}
//----------------------------------------------------------------------
@@ -810,7 +757,6 @@
//----------------------------------------------------------------------
// Data members
- RefPtr<PODFreeListArena<Node>> m_arena;
Node* m_root;
bool m_needsFullOrderingComparisons;
#ifndef NDEBUG
Modified: trunk/Source/WebCore/rendering/FloatingObjects.cpp (176430 => 176431)
--- trunk/Source/WebCore/rendering/FloatingObjects.cpp 2014-11-21 02:10:33 UTC (rev 176430)
+++ trunk/Source/WebCore/rendering/FloatingObjects.cpp 2014-11-21 02:27:20 UTC (rev 176431)
@@ -236,7 +236,8 @@
LayoutUnit FloatingObjects::findNextFloatLogicalBottomBelow(LayoutUnit logicalHeight)
{
FindNextFloatLogicalBottomAdapter adapter(m_renderer, logicalHeight);
- placedFloatsTree().allOverlapsWithAdapter(adapter);
+ if (const FloatingObjectTree* placedFloatsTree = this->placedFloatsTree())
+ placedFloatsTree->allOverlapsWithAdapter(adapter);
return adapter.nextShapeLogicalBottom();
}
@@ -244,14 +245,14 @@
LayoutUnit FloatingObjects::findNextFloatLogicalBottomBelowForBlock(LayoutUnit logicalHeight)
{
FindNextFloatLogicalBottomAdapter adapter(m_renderer, logicalHeight);
- placedFloatsTree().allOverlapsWithAdapter(adapter);
+ if (const FloatingObjectTree* placedFloatsTree = this->placedFloatsTree())
+ placedFloatsTree->allOverlapsWithAdapter(adapter);
return adapter.nextLogicalBottom();
}
FloatingObjects::FloatingObjects(const RenderBlockFlow& renderer)
- : m_placedFloatsTree(UninitializedTree)
- , m_leftObjectsCount(0)
+ : m_leftObjectsCount(0)
, m_rightObjectsCount(0)
, m_horizontalWritingMode(renderer.isHorizontalWritingMode())
, m_renderer(renderer)
@@ -274,7 +275,7 @@
void FloatingObjects::clear()
{
m_set.clear();
- m_placedFloatsTree.clear();
+ m_placedFloatsTree = nullptr;
m_leftObjectsCount = 0;
m_rightObjectsCount = 0;
}
@@ -321,8 +322,8 @@
ASSERT(!floatingObject->isInPlacedTree());
floatingObject->setIsPlaced(true);
- if (m_placedFloatsTree.isInitialized())
- m_placedFloatsTree.add(intervalForFloatingObject(floatingObject));
+ if (m_placedFloatsTree)
+ m_placedFloatsTree->add(intervalForFloatingObject(floatingObject));
#ifndef NDEBUG
floatingObject->setIsInPlacedTree(true);
@@ -333,8 +334,8 @@
{
ASSERT(floatingObject->isPlaced() && floatingObject->isInPlacedTree());
- if (m_placedFloatsTree.isInitialized()) {
- bool removed = m_placedFloatsTree.remove(intervalForFloatingObject(floatingObject));
+ if (m_placedFloatsTree) {
+ bool removed = m_placedFloatsTree->remove(intervalForFloatingObject(floatingObject));
ASSERT_UNUSED(removed, removed);
}
@@ -368,28 +369,30 @@
void FloatingObjects::computePlacedFloatsTree()
{
- ASSERT(!m_placedFloatsTree.isInitialized());
+ ASSERT(!m_placedFloatsTree);
if (m_set.isEmpty())
return;
- m_placedFloatsTree.initIfNeeded(m_renderer.view().intervalArena());
+
+ m_placedFloatsTree = std::make_unique<FloatingObjectTree>();
for (auto it = m_set.begin(), end = m_set.end(); it != end; ++it) {
FloatingObject* floatingObject = it->get();
if (floatingObject->isPlaced())
- m_placedFloatsTree.add(intervalForFloatingObject(floatingObject));
+ m_placedFloatsTree->add(intervalForFloatingObject(floatingObject));
}
}
-inline const FloatingObjectTree& FloatingObjects::placedFloatsTree()
+inline const FloatingObjectTree* FloatingObjects::placedFloatsTree()
{
- if (!m_placedFloatsTree.isInitialized())
+ if (!m_placedFloatsTree)
computePlacedFloatsTree();
- return m_placedFloatsTree;
+ return m_placedFloatsTree.get();
}
LayoutUnit FloatingObjects::logicalLeftOffsetForPositioningFloat(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit *heightRemaining)
{
ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatLeft> adapter(m_renderer, logicalTop, logicalTop, fixedOffset);
- placedFloatsTree().allOverlapsWithAdapter(adapter);
+ if (const FloatingObjectTree* placedFloatsTree = this->placedFloatsTree())
+ placedFloatsTree->allOverlapsWithAdapter(adapter);
if (heightRemaining)
*heightRemaining = adapter.heightRemaining();
@@ -400,7 +403,8 @@
LayoutUnit FloatingObjects::logicalRightOffsetForPositioningFloat(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit *heightRemaining)
{
ComputeFloatOffsetForFloatLayoutAdapter<FloatingObject::FloatRight> adapter(m_renderer, logicalTop, logicalTop, fixedOffset);
- placedFloatsTree().allOverlapsWithAdapter(adapter);
+ if (const FloatingObjectTree* placedFloatsTree = this->placedFloatsTree())
+ placedFloatsTree->allOverlapsWithAdapter(adapter);
if (heightRemaining)
*heightRemaining = adapter.heightRemaining();
@@ -411,7 +415,8 @@
LayoutUnit FloatingObjects::logicalLeftOffset(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit logicalHeight)
{
ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatLeft> adapter(m_renderer, logicalTop, logicalTop + logicalHeight, fixedOffset);
- placedFloatsTree().allOverlapsWithAdapter(adapter);
+ if (const FloatingObjectTree* placedFloatsTree = this->placedFloatsTree())
+ placedFloatsTree->allOverlapsWithAdapter(adapter);
return adapter.offset();
}
@@ -419,7 +424,8 @@
LayoutUnit FloatingObjects::logicalRightOffset(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit logicalHeight)
{
ComputeFloatOffsetForLineLayoutAdapter<FloatingObject::FloatRight> adapter(m_renderer, logicalTop, logicalTop + logicalHeight, fixedOffset);
- placedFloatsTree().allOverlapsWithAdapter(adapter);
+ if (const FloatingObjectTree* placedFloatsTree = this->placedFloatsTree())
+ placedFloatsTree->allOverlapsWithAdapter(adapter);
return std::min(fixedOffset, adapter.offset());
}
Modified: trunk/Source/WebCore/rendering/FloatingObjects.h (176430 => 176431)
--- trunk/Source/WebCore/rendering/FloatingObjects.h 2014-11-21 02:10:33 UTC (rev 176430)
+++ trunk/Source/WebCore/rendering/FloatingObjects.h 2014-11-21 02:27:20 UTC (rev 176431)
@@ -115,7 +115,6 @@
typedef PODInterval<LayoutUnit, FloatingObject*> FloatingObjectInterval;
typedef PODIntervalTree<LayoutUnit, FloatingObject*> FloatingObjectTree;
-typedef PODFreeListArena<PODRedBlackTree<FloatingObjectInterval>::Node> IntervalArena;
// FIXME: This is really the same thing as FloatingObjectSet.
// Change clients to use that set directly, and replace the moveAllToFloatInfoMap function with a takeSet function.
@@ -151,13 +150,13 @@
private:
void computePlacedFloatsTree();
- const FloatingObjectTree& placedFloatsTree();
+ const FloatingObjectTree* placedFloatsTree();
void increaseObjectsCount(FloatingObject::Type);
void decreaseObjectsCount(FloatingObject::Type);
FloatingObjectInterval intervalForFloatingObject(FloatingObject*);
FloatingObjectSet m_set;
- FloatingObjectTree m_placedFloatsTree;
+ std::unique_ptr<FloatingObjectTree> m_placedFloatsTree;
unsigned m_leftObjectsCount;
unsigned m_rightObjectsCount;
bool m_horizontalWritingMode;
Modified: trunk/Source/WebCore/rendering/RenderFlowThread.cpp (176430 => 176431)
--- trunk/Source/WebCore/rendering/RenderFlowThread.cpp 2014-11-21 02:10:33 UTC (rev 176430)
+++ trunk/Source/WebCore/rendering/RenderFlowThread.cpp 2014-11-21 02:27:20 UTC (rev 176431)
@@ -1017,7 +1017,6 @@
bool emptyRegionsSegment = false;
// FIXME: Optimize not to clear the interval all the time. This implies manually managing the tree nodes lifecycle.
m_regionIntervalTree.clear();
- m_regionIntervalTree.initIfNeeded();
for (auto& region : m_regionList) {
// If we find an empty auto-height region, clear the computedAutoHeight value.
if (emptyRegionsSegment && region->hasAutoLogicalHeight())
Modified: trunk/Source/WebCore/rendering/RenderView.cpp (176430 => 176431)
--- trunk/Source/WebCore/rendering/RenderView.cpp 2014-11-21 02:10:33 UTC (rev 176430)
+++ trunk/Source/WebCore/rendering/RenderView.cpp 2014-11-21 02:27:20 UTC (rev 176431)
@@ -1327,13 +1327,6 @@
currentFlowThread->popFlowThreadLayoutState();
}
-IntervalArena* RenderView::intervalArena()
-{
- if (!m_intervalArena)
- m_intervalArena = IntervalArena::create();
- return m_intervalArena.get();
-}
-
ImageQualityController& RenderView::imageQualityController()
{
if (!m_imageQualityController)
Modified: trunk/Source/WebCore/rendering/RenderView.h (176430 => 176431)
--- trunk/Source/WebCore/rendering/RenderView.h 2014-11-21 02:10:33 UTC (rev 176430)
+++ trunk/Source/WebCore/rendering/RenderView.h 2014-11-21 02:27:20 UTC (rev 176431)
@@ -24,7 +24,6 @@
#include "FrameView.h"
#include "LayoutState.h"
-#include "PODFreeListArena.h"
#include "Region.h"
#include "RenderBlockFlow.h"
#include "SelectionSubtreeRoot.h"
@@ -203,8 +202,6 @@
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
- IntervalArena* intervalArena();
-
IntSize viewportSizeForCSSViewportUnits() const;
void setRenderQuoteHead(RenderQuote* head) { m_renderQuoteHead = head; }
@@ -354,7 +351,6 @@
unsigned m_layoutStateDisableCount;
std::unique_ptr<RenderLayerCompositor> m_compositor;
std::unique_ptr<FlowThreadController> m_flowThreadController;
- RefPtr<IntervalArena> m_intervalArena;
RenderQuote* m_renderQuoteHead;
unsigned m_renderCounterCount;