Diff
Modified: releases/WebKitGTK/webkit-2.12/Source/bmalloc/ChangeLog (197067 => 197068)
--- releases/WebKitGTK/webkit-2.12/Source/bmalloc/ChangeLog 2016-02-25 09:15:08 UTC (rev 197067)
+++ releases/WebKitGTK/webkit-2.12/Source/bmalloc/ChangeLog 2016-02-25 09:15:29 UTC (rev 197068)
@@ -1,3 +1,68 @@
+2016-02-19 Joonghun Park <jh718.p...@samsung.com>
+
+ Unreviewed. Fix debug build error since r196847
+
+ Fix gcc build warning appeared as below
+ by removing BASSERT(refCount <= maxRefCount).
+ error: comparison is always true due to limited range of data type
+ [-Werror=type-limits]
+
+ * bmalloc/SmallLine.h:
+ (bmalloc::SmallLine::ref): Deleted.
+
+2016-02-19 Geoffrey Garen <gga...@apple.com>
+
+ bmalloc: Chunk, Page, and Line don't need to be class templates
+ https://bugs.webkit.org/show_bug.cgi?id=154480
+
+ Reviewed by Gavin Barraclough.
+
+ We needed class templates to distinguish between small and medium,
+ but medium is gone now.
+
+ * bmalloc.xcodeproj/project.pbxproj:
+ * bmalloc/Chunk.h: Removed.
+ * bmalloc/Heap.cpp:
+ (bmalloc::Heap::initializeLineMetadata):
+ (bmalloc::Heap::allocateSmallBumpRanges):
+ * bmalloc/Heap.h:
+ * bmalloc/Line.h: Removed.
+ * bmalloc/Page.h: Removed.
+ * bmalloc/Sizes.h:
+ * bmalloc/SmallChunk.h: Replaced with Source/bmalloc/bmalloc/Chunk.h.
+ (bmalloc::SmallChunk::begin):
+ (bmalloc::SmallChunk::end):
+ (bmalloc::SmallChunk::lines):
+ (bmalloc::SmallChunk::pages):
+ (bmalloc::SmallChunk::get):
+ (bmalloc::SmallLine::get):
+ (bmalloc::SmallLine::begin):
+ (bmalloc::SmallLine::end):
+ (bmalloc::SmallPage::get):
+ (bmalloc::SmallPage::begin):
+ (bmalloc::SmallPage::end):
+ (bmalloc::Chunk::begin): Deleted.
+ (bmalloc::Chunk::end): Deleted.
+ (bmalloc::Chunk::lines): Deleted.
+ (bmalloc::Chunk::pages): Deleted.
+ * bmalloc/SmallLine.h: Replaced with Source/bmalloc/bmalloc/Line.h.
+ (bmalloc::SmallLine::ref):
+ (bmalloc::SmallLine::deref):
+ (bmalloc::Line<Traits>::begin): Deleted.
+ (bmalloc::Line<Traits>::end): Deleted.
+ (bmalloc::Line<Traits>::ref): Deleted.
+ (bmalloc::Line<Traits>::deref): Deleted.
+ * bmalloc/SmallPage.h: Replaced with Source/bmalloc/bmalloc/Page.h.
+ (bmalloc::SmallPage::hasFreeLines):
+ (bmalloc::SmallPage::setHasFreeLines):
+ (bmalloc::SmallPage::ref):
+ (bmalloc::SmallPage::deref):
+ (bmalloc::Page::hasFreeLines): Deleted.
+ (bmalloc::Page::setHasFreeLines): Deleted.
+ (bmalloc::Page<Traits>::ref): Deleted.
+ (bmalloc::Page<Traits>::deref): Deleted.
+ * bmalloc/SmallTraits.h: Removed.
+
2016-02-18 Geoffrey Garen <gga...@apple.com>
bmalloc: Remove the concept of medium objects
Deleted: releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Chunk.h (197067 => 197068)
--- releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Chunk.h 2016-02-25 09:15:08 UTC (rev 197067)
+++ releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Chunk.h 2016-02-25 09:15:29 UTC (rev 197068)
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2014 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 Chunk_h
-#define Chunk_h
-
-#include "ObjectType.h"
-#include "Sizes.h"
-#include "VMAllocate.h"
-
-namespace bmalloc {
-
-template<class Traits>
-class Chunk {
-public:
- typedef typename Traits::PageType Page;
- typedef typename Traits::LineType Line;
-
- static const size_t lineSize = Traits::lineSize;
- static const size_t chunkSize = Traits::chunkSize;
- static const size_t chunkOffset = Traits::chunkOffset;
- static const uintptr_t chunkMask = Traits::chunkMask;
-
- static Chunk* get(void*);
-
- Page* begin() { return Page::get(Line::get(m_memory)); }
- Page* end() { return &m_pages[pageCount]; }
-
- Line* lines() { return m_lines; }
- Page* pages() { return m_pages; }
-
-private:
- static_assert(!(vmPageSize % lineSize), "vmPageSize must be an even multiple of line size");
- static_assert(!(chunkSize % lineSize), "chunk size must be an even multiple of line size");
-
- static const size_t lineCount = chunkSize / lineSize;
- static const size_t pageCount = chunkSize / vmPageSize;
-
- Line m_lines[lineCount];
- Page m_pages[pageCount];
-
- // Align to vmPageSize to avoid sharing physical pages with metadata.
- // Otherwise, we'll confuse the scavenger into trying to scavenge metadata.
- // FIXME: Below #ifdef workaround fix should be removed after all linux based ports bump
- // own gcc version. See https://bugs.webkit.org/show_bug.cgi?id=140162#c87
-#if BPLATFORM(IOS)
- char m_memory[] __attribute__((aligned(16384)));
- static_assert(vmPageSize == 16384, "vmPageSize and alignment must be same");
-#else
- char m_memory[] __attribute__((aligned(4096)));
- static_assert(vmPageSize == 4096, "vmPageSize and alignment must be same");
-#endif
-};
-
-template<class Traits>
-inline auto Chunk<Traits>::get(void* object) -> Chunk*
-{
- BASSERT(isSmall(object));
- return static_cast<Chunk*>(mask(object, chunkMask));
-}
-
-}; // namespace bmalloc
-
-#endif // Chunk
Modified: releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Heap.cpp (197067 => 197068)
--- releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Heap.cpp 2016-02-25 09:15:08 UTC (rev 197067)
+++ releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Heap.cpp 2016-02-25 09:15:29 UTC (rev 197068)
@@ -27,10 +27,10 @@
#include "BumpAllocator.h"
#include "LargeChunk.h"
#include "LargeObject.h"
-#include "Line.h"
-#include "Page.h"
#include "PerProcess.h"
#include "SmallChunk.h"
+#include "SmallLine.h"
+#include "SmallPage.h"
#include <thread>
namespace bmalloc {
@@ -54,12 +54,12 @@
size_t object = 0;
size_t line = 0;
while (object < vmPageSize) {
- line = object / SmallPage::lineSize;
- size_t leftover = object % SmallPage::lineSize;
+ line = object / smallLineSize;
+ size_t leftover = object % smallLineSize;
size_t objectCount;
size_t remainder;
- divideRoundingUp(SmallPage::lineSize - leftover, size, objectCount, remainder);
+ divideRoundingUp(smallLineSize - leftover, size, objectCount, remainder);
metadata[line] = { static_cast<unsigned short>(leftover), static_cast<unsigned short>(objectCount) };
@@ -114,7 +114,7 @@
BASSERT(page->hasFreeLines(lock));
// Find a free line.
- for (size_t lineNumber = 0; lineNumber < SmallPage::lineCount; ++lineNumber) {
+ for (size_t lineNumber = 0; lineNumber < smallLineCount; ++lineNumber) {
if (lines[lineNumber].refCount(lock))
continue;
@@ -134,7 +134,7 @@
page->ref(lock);
// Merge with subsequent free lines.
- while (++lineNumber < SmallPage::lineCount) {
+ while (++lineNumber < smallLineCount) {
if (lines[lineNumber].refCount(lock))
break;
Modified: releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Heap.h (197067 => 197068)
--- releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Heap.h 2016-02-25 09:15:08 UTC (rev 197067)
+++ releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Heap.h 2016-02-25 09:15:29 UTC (rev 197068)
@@ -86,7 +86,7 @@
void scavengeSmallPages(std::unique_lock<StaticMutex>&, std::chrono::milliseconds);
void scavengeLargeObjects(std::unique_lock<StaticMutex>&, std::chrono::milliseconds);
- std::array<std::array<LineMetadata, SmallPage::lineCount>, smallMax / alignment> m_smallLineMetadata;
+ std::array<std::array<LineMetadata, smallLineCount>, smallMax / alignment> m_smallLineMetadata;
std::array<Vector<SmallPage*>, smallMax / alignment> m_smallPagesWithFreeLines;
Deleted: releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Line.h (197067 => 197068)
--- releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Line.h 2016-02-25 09:15:08 UTC (rev 197067)
+++ releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Line.h 2016-02-25 09:15:29 UTC (rev 197068)
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2014 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 Line_h
-#define Line_h
-
-#include "BAssert.h"
-#include "Mutex.h"
-#include "ObjectType.h"
-#include <mutex>
-
-namespace bmalloc {
-
-template<class Traits>
-class Line {
-public:
- typedef typename Traits::ChunkType Chunk;
-
- static const size_t minimumObjectSize = Traits::minimumObjectSize;
- static const size_t lineSize = Traits::lineSize;
-
- static const unsigned char maxRefCount = std::numeric_limits<unsigned char>::max();
- static_assert(lineSize / minimumObjectSize < maxRefCount, "maximum object count must fit in Line");
-
- static Line* get(void*);
-
- void ref(std::lock_guard<StaticMutex>&, unsigned char);
- bool deref(std::lock_guard<StaticMutex>&);
- unsigned refCount(std::lock_guard<StaticMutex>&) { return m_refCount; }
-
- char* begin();
- char* end();
-
-private:
- unsigned char m_refCount;
-};
-
-template<class Traits>
-inline auto Line<Traits>::get(void* object) -> Line*
-{
- BASSERT(isSmall(object));
- Chunk* chunk = Chunk::get(object);
- size_t lineNumber = (reinterpret_cast<char*>(object) - reinterpret_cast<char*>(chunk)) / lineSize;
- return &chunk->lines()[lineNumber];
-}
-
-template<class Traits>
-inline char* Line<Traits>::begin()
-{
- Chunk* chunk = Chunk::get(this);
- size_t lineNumber = this - chunk->lines();
- size_t offset = lineNumber * lineSize;
- return &reinterpret_cast<char*>(chunk)[offset];
-}
-
-template<class Traits>
-inline char* Line<Traits>::end()
-{
- return begin() + lineSize;
-}
-
-template<class Traits>
-inline void Line<Traits>::ref(std::lock_guard<StaticMutex>&, unsigned char refCount)
-{
- BASSERT(!m_refCount);
- BASSERT(refCount <= maxRefCount);
- m_refCount = refCount;
-}
-
-template<class Traits>
-inline bool Line<Traits>::deref(std::lock_guard<StaticMutex>&)
-{
- BASSERT(m_refCount);
- --m_refCount;
- return !m_refCount;
-}
-
-} // namespace bmalloc
-
-#endif // Line_h
Deleted: releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Page.h (197067 => 197068)
--- releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Page.h 2016-02-25 09:15:08 UTC (rev 197067)
+++ releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Page.h 2016-02-25 09:15:29 UTC (rev 197068)
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2014 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 Page_h
-#define Page_h
-
-#include "BAssert.h"
-#include "Mutex.h"
-#include "VMAllocate.h"
-#include <mutex>
-
-namespace bmalloc {
-
-template<typename Traits>
-class Page {
-public:
- typedef typename Traits::ChunkType Chunk;
- typedef typename Traits::LineType Line;
-
- static const size_t lineSize = Traits::lineSize;
- static const size_t lineCount = vmPageSize / lineSize;
-
- static const unsigned char maxRefCount = std::numeric_limits<unsigned char>::max();
- static_assert(lineCount < maxRefCount, "maximum line count must fit in Page");
-
- static Page* get(Line*);
-
- void ref(std::lock_guard<StaticMutex>&);
- bool deref(std::lock_guard<StaticMutex>&);
- unsigned refCount(std::lock_guard<StaticMutex>&) { return m_refCount; }
-
- size_t sizeClass() { return m_sizeClass; }
- void setSizeClass(size_t sizeClass) { m_sizeClass = sizeClass; }
-
- bool hasFreeLines(std::lock_guard<StaticMutex>&) const { return m_hasFreeLines; }
- void setHasFreeLines(std::lock_guard<StaticMutex>&, bool hasFreeLines) { m_hasFreeLines = hasFreeLines; }
-
- Line* begin();
- Line* end();
-
-private:
- unsigned char m_hasFreeLines: 1;
- unsigned char m_refCount: 7;
- unsigned char m_sizeClass;
-};
-
-template<typename Traits>
-inline void Page<Traits>::ref(std::lock_guard<StaticMutex>&)
-{
- BASSERT(m_refCount < maxRefCount);
- ++m_refCount;
-}
-
-template<typename Traits>
-inline bool Page<Traits>::deref(std::lock_guard<StaticMutex>&)
-{
- BASSERT(m_refCount);
- --m_refCount;
- return !m_refCount;
-}
-
-template<typename Traits>
-inline auto Page<Traits>::get(Line* line) -> Page*
-{
- Chunk* chunk = Chunk::get(line);
- size_t lineNumber = line - chunk->lines();
- size_t pageNumber = lineNumber * lineSize / vmPageSize;
- return &chunk->pages()[pageNumber];
-}
-
-template<typename Traits>
-inline auto Page<Traits>::begin() -> Line*
-{
- Chunk* chunk = Chunk::get(this);
- size_t pageNumber = this - chunk->pages();
- size_t lineNumber = pageNumber * lineCount;
- return &chunk->lines()[lineNumber];
-}
-
-template<typename Traits>
-inline auto Page<Traits>::end() -> Line*
-{
- return begin() + lineCount;
-}
-
-} // namespace bmalloc
-
-#endif // Page_h
Modified: releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Sizes.h (197067 => 197068)
--- releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Sizes.h 2016-02-25 09:15:08 UTC (rev 197067)
+++ releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/Sizes.h 2016-02-25 09:15:29 UTC (rev 197068)
@@ -58,6 +58,7 @@
static const size_t smallMax = 1024;
static const size_t smallLineSize = 256;
+ static const size_t smallLineCount = vmPageSize / smallLineSize;
static const size_t smallLineMask = ~(smallLineSize - 1ul);
static const size_t smallChunkSize = superChunkSize / 2;
Modified: releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallChunk.h (197067 => 197068)
--- releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallChunk.h 2016-02-25 09:15:08 UTC (rev 197067)
+++ releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallChunk.h 2016-02-25 09:15:29 UTC (rev 197068)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,15 +26,94 @@
#ifndef SmallChunk_h
#define SmallChunk_h
-#include "Chunk.h"
+#include "Sizes.h"
#include "SmallLine.h"
#include "SmallPage.h"
-#include "SmallTraits.h"
+#include "VMAllocate.h"
namespace bmalloc {
-typedef Chunk<SmallTraits> SmallChunk;
+class SmallChunk {
+public:
+ static SmallChunk* get(void*);
+ SmallPage* begin() { return SmallPage::get(SmallLine::get(m_memory)); }
+ SmallPage* end() { return &m_pages[pageCount]; }
+
+ SmallLine* lines() { return m_lines; }
+ SmallPage* pages() { return m_pages; }
+
+private:
+ static_assert(!(vmPageSize % smallLineSize), "vmPageSize must be an even multiple of line size");
+ static_assert(!(smallChunkSize % smallLineSize), "chunk size must be an even multiple of line size");
+
+ static const size_t lineCount = smallChunkSize / smallLineSize;
+ static const size_t pageCount = smallChunkSize / vmPageSize;
+
+ SmallLine m_lines[lineCount];
+ SmallPage m_pages[pageCount];
+
+ // Align to vmPageSize to avoid sharing physical pages with metadata.
+ // Otherwise, we'll confuse the scavenger into trying to scavenge metadata.
+ // FIXME: Below #ifdef workaround fix should be removed after all linux based ports bump
+ // own gcc version. See https://bugs.webkit.org/show_bug.cgi?id=140162#c87
+#if BPLATFORM(IOS)
+ char m_memory[] __attribute__((aligned(16384)));
+ static_assert(vmPageSize == 16384, "vmPageSize and alignment must be same");
+#else
+ char m_memory[] __attribute__((aligned(4096)));
+ static_assert(vmPageSize == 4096, "vmPageSize and alignment must be same");
+#endif
+};
+
+inline SmallChunk* SmallChunk::get(void* object)
+{
+ BASSERT(isSmall(object));
+ return static_cast<SmallChunk*>(mask(object, smallChunkMask));
+}
+
+inline SmallLine* SmallLine::get(void* object)
+{
+ BASSERT(isSmall(object));
+ SmallChunk* chunk = SmallChunk::get(object);
+ size_t lineNumber = (reinterpret_cast<char*>(object) - reinterpret_cast<char*>(chunk)) / smallLineSize;
+ return &chunk->lines()[lineNumber];
+}
+
+inline char* SmallLine::begin()
+{
+ SmallChunk* chunk = SmallChunk::get(this);
+ size_t lineNumber = this - chunk->lines();
+ size_t offset = lineNumber * smallLineSize;
+ return &reinterpret_cast<char*>(chunk)[offset];
+}
+
+inline char* SmallLine::end()
+{
+ return begin() + smallLineSize;
+}
+
+inline SmallPage* SmallPage::get(SmallLine* line)
+{
+ SmallChunk* chunk = SmallChunk::get(line);
+ size_t lineNumber = line - chunk->lines();
+ size_t pageNumber = lineNumber * smallLineSize / vmPageSize;
+ return &chunk->pages()[pageNumber];
+}
+
+inline SmallLine* SmallPage::begin()
+{
+ SmallChunk* chunk = SmallChunk::get(this);
+ size_t pageNumber = this - chunk->pages();
+ size_t lineNumber = pageNumber * smallLineCount;
+ return &chunk->lines()[lineNumber];
+}
+
+inline SmallLine* SmallPage::end()
+{
+ return begin() + smallLineCount;
+}
+
}; // namespace bmalloc
-#endif // SmallChunk
+#endif // Chunk
Modified: releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallLine.h (197067 => 197068)
--- releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallLine.h 2016-02-25 09:15:08 UTC (rev 197067)
+++ releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallLine.h 2016-02-25 09:15:29 UTC (rev 197068)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,13 +26,44 @@
#ifndef SmallLine_h
#define SmallLine_h
-#include "Line.h"
-#include "SmallTraits.h"
+#include "BAssert.h"
+#include "Mutex.h"
+#include "ObjectType.h"
+#include <mutex>
namespace bmalloc {
-typedef Line<SmallTraits> SmallLine;
+class SmallLine {
+public:
+ static const unsigned char maxRefCount = std::numeric_limits<unsigned char>::max();
+ static_assert(smallLineSize / alignment < maxRefCount, "maximum object count must fit in Line");
+ static SmallLine* get(void*);
+
+ void ref(std::lock_guard<StaticMutex>&, unsigned char);
+ bool deref(std::lock_guard<StaticMutex>&);
+ unsigned refCount(std::lock_guard<StaticMutex>&) { return m_refCount; }
+
+ char* begin();
+ char* end();
+
+private:
+ unsigned char m_refCount;
+};
+
+inline void SmallLine::ref(std::lock_guard<StaticMutex>&, unsigned char refCount)
+{
+ BASSERT(!m_refCount);
+ m_refCount = refCount;
+}
+
+inline bool SmallLine::deref(std::lock_guard<StaticMutex>&)
+{
+ BASSERT(m_refCount);
+ --m_refCount;
+ return !m_refCount;
+}
+
} // namespace bmalloc
#endif // SmallLine_h
Modified: releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallPage.h (197067 => 197068)
--- releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallPage.h 2016-02-25 09:15:08 UTC (rev 197067)
+++ releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallPage.h 2016-02-25 09:15:29 UTC (rev 197068)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,13 +26,52 @@
#ifndef SmallPage_h
#define SmallPage_h
-#include "SmallTraits.h"
-#include "Page.h"
+#include "BAssert.h"
+#include "Mutex.h"
+#include "VMAllocate.h"
+#include <mutex>
namespace bmalloc {
-typedef Page<SmallTraits> SmallPage;
+class SmallPage {
+public:
+ static const unsigned char maxRefCount = std::numeric_limits<unsigned char>::max();
+ static_assert(smallLineCount < maxRefCount, "maximum line count must fit in SmallPage");
+
+ static SmallPage* get(SmallLine*);
+ void ref(std::lock_guard<StaticMutex>&);
+ bool deref(std::lock_guard<StaticMutex>&);
+ unsigned refCount(std::lock_guard<StaticMutex>&) { return m_refCount; }
+
+ size_t sizeClass() { return m_sizeClass; }
+ void setSizeClass(size_t sizeClass) { m_sizeClass = sizeClass; }
+
+ bool hasFreeLines(std::lock_guard<StaticMutex>&) const { return m_hasFreeLines; }
+ void setHasFreeLines(std::lock_guard<StaticMutex>&, bool hasFreeLines) { m_hasFreeLines = hasFreeLines; }
+
+ SmallLine* begin();
+ SmallLine* end();
+
+private:
+ unsigned char m_hasFreeLines: 1;
+ unsigned char m_refCount: 7;
+ unsigned char m_sizeClass;
+};
+
+inline void SmallPage::ref(std::lock_guard<StaticMutex>&)
+{
+ BASSERT(m_refCount < maxRefCount);
+ ++m_refCount;
+}
+
+inline bool SmallPage::deref(std::lock_guard<StaticMutex>&)
+{
+ BASSERT(m_refCount);
+ --m_refCount;
+ return !m_refCount;
+}
+
} // namespace bmalloc
#endif // SmallPage_h
Deleted: releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallTraits.h (197067 => 197068)
--- releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallTraits.h 2016-02-25 09:15:08 UTC (rev 197067)
+++ releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc/SmallTraits.h 2016-02-25 09:15:29 UTC (rev 197068)
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2014 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 SmallTraits_h
-#define SmallTraits_h
-
-#include "Sizes.h"
-
-namespace bmalloc {
-
-template<class Traits> class Chunk;
-template<class Traits> class Line;
-template<class Traits> class Page;
-
-struct SmallTraits {
- typedef Chunk<SmallTraits> ChunkType;
- typedef Line<SmallTraits> LineType;
- typedef Page<SmallTraits> PageType;
-
- static const size_t lineSize = smallLineSize;
- static const size_t minimumObjectSize = alignment;
- static const size_t chunkSize = smallChunkSize;
- static const size_t chunkOffset = smallChunkOffset;
- static const uintptr_t chunkMask = smallChunkMask;
-};
-
-} // namespace bmalloc
-
-#endif // SmallTraits_h
Modified: releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj (197067 => 197068)
--- releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj 2016-02-25 09:15:08 UTC (rev 197067)
+++ releases/WebKitGTK/webkit-2.12/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj 2016-02-25 09:15:29 UTC (rev 197068)
@@ -37,13 +37,9 @@
14DD789918F48D4A00950702 /* Cache.h in Headers */ = {isa = PBXBuildFile; fileRef = 144469E517A46BFE00F9EA1D /* Cache.h */; settings = {ATTRIBUTES = (Private, ); }; };
14DD789A18F48D4A00950702 /* Deallocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 145F685A179DC90200D65598 /* Deallocator.h */; settings = {ATTRIBUTES = (Private, ); }; };
14DD789C18F48D4A00950702 /* BumpAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 1413E462189DE1CD00546D68 /* BumpAllocator.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 14DD78B418F48D6B00950702 /* Chunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 147AAA9418CE5CA6002201E4 /* Chunk.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 14DD78B518F48D6B00950702 /* Line.h in Headers */ = {isa = PBXBuildFile; fileRef = 14DA32071885F9E6007269E0 /* Line.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 14DD78BA18F48D6B00950702 /* Page.h in Headers */ = {isa = PBXBuildFile; fileRef = 146BEE2318C980D60002D5A2 /* Page.h */; settings = {ATTRIBUTES = (Private, ); }; };
14DD78BB18F48D6B00950702 /* SmallChunk.h in Headers */ = {isa = PBXBuildFile; fileRef = 147AAA8C18CD36A7002201E4 /* SmallChunk.h */; settings = {ATTRIBUTES = (Private, ); }; };
14DD78BC18F48D6B00950702 /* SmallLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 1452478618BC757C00F80098 /* SmallLine.h */; settings = {ATTRIBUTES = (Private, ); }; };
14DD78BD18F48D6B00950702 /* SmallPage.h in Headers */ = {isa = PBXBuildFile; fileRef = 143E29ED18CAE90500FE8A0F /* SmallPage.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 14DD78BE18F48D6B00950702 /* SmallTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 147AAA9718CE5FB6002201E4 /* SmallTraits.h */; settings = {ATTRIBUTES = (Private, ); }; };
14DD78C518F48D7500950702 /* Algorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 1421A87718EE462A00B4DD68 /* Algorithm.h */; settings = {ATTRIBUTES = (Private, ); }; };
14DD78C618F48D7500950702 /* AsyncTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 1417F65218BA88A00076FA3F /* AsyncTask.h */; settings = {ATTRIBUTES = (Private, ); }; };
14DD78C718F48D7500950702 /* BAssert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1413E468189EEDE400546D68 /* BAssert.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -113,13 +109,10 @@
145F6878179E3A4400D65598 /* Range.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = Range.h; path = bmalloc/Range.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
146BEE1E18C841C50002D5A2 /* SegregatedFreeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SegregatedFreeList.h; path = bmalloc/SegregatedFreeList.h; sourceTree = "<group>"; };
146BEE2118C845AE0002D5A2 /* SegregatedFreeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SegregatedFreeList.cpp; path = bmalloc/SegregatedFreeList.cpp; sourceTree = "<group>"; };
- 146BEE2318C980D60002D5A2 /* Page.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Page.h; path = bmalloc/Page.h; sourceTree = "<group>"; };
1479E21217A1A255006D4E9D /* Vector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = Vector.h; path = bmalloc/Vector.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
1479E21417A1A63E006D4E9D /* VMAllocate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = VMAllocate.h; path = bmalloc/VMAllocate.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
147AAA8818CD17CE002201E4 /* LargeChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LargeChunk.h; path = bmalloc/LargeChunk.h; sourceTree = "<group>"; };
147AAA8C18CD36A7002201E4 /* SmallChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SmallChunk.h; path = bmalloc/SmallChunk.h; sourceTree = "<group>"; };
- 147AAA9418CE5CA6002201E4 /* Chunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Chunk.h; path = bmalloc/Chunk.h; sourceTree = "<group>"; };
- 147AAA9718CE5FB6002201E4 /* SmallTraits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SmallTraits.h; path = bmalloc/SmallTraits.h; sourceTree = "<group>"; };
1485655E18A43AF900ED6942 /* BoundaryTag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BoundaryTag.h; path = bmalloc/BoundaryTag.h; sourceTree = "<group>"; };
1485656018A43DBA00ED6942 /* ObjectType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjectType.h; path = bmalloc/ObjectType.h; sourceTree = "<group>"; };
14895D8F1A3A319C0006235D /* Environment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Environment.cpp; path = bmalloc/Environment.cpp; sourceTree = "<group>"; };
@@ -133,7 +126,6 @@
14CC394418EA8743004AFE34 /* libmbmalloc.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libmbmalloc.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
14D2CD9A1AA12CFB00770440 /* VMState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VMState.h; path = bmalloc/VMState.h; sourceTree = "<group>"; };
14D9DB4517F2447100EAAB79 /* FixedVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = FixedVector.h; path = bmalloc/FixedVector.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
- 14DA32071885F9E6007269E0 /* Line.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = Line.h; path = bmalloc/Line.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
14DA320C18875B09007269E0 /* Heap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Heap.h; path = bmalloc/Heap.h; sourceTree = "<group>"; };
14DA320E18875D9F007269E0 /* Heap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Heap.cpp; path = bmalloc/Heap.cpp; sourceTree = "<group>"; };
14F271BE18EA3963008C152F /* libbmalloc.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libbmalloc.a; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -193,13 +185,9 @@
147AAA9A18CE5FD3002201E4 /* heap: small | medium */ = {
isa = PBXGroup;
children = (
- 147AAA9418CE5CA6002201E4 /* Chunk.h */,
- 14DA32071885F9E6007269E0 /* Line.h */,
- 146BEE2318C980D60002D5A2 /* Page.h */,
147AAA8C18CD36A7002201E4 /* SmallChunk.h */,
1452478618BC757C00F80098 /* SmallLine.h */,
143E29ED18CAE90500FE8A0F /* SmallPage.h */,
- 147AAA9718CE5FB6002201E4 /* SmallTraits.h */,
);
name = "heap: small | medium";
sourceTree = "<group>";
@@ -303,7 +291,6 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
- 14DD78B518F48D6B00950702 /* Line.h in Headers */,
14DD78CF18F48D7500950702 /* Vector.h in Headers */,
14C919C918FCC59F0028DB43 /* BPlatform.h in Headers */,
14DD788C18F48CAE00950702 /* LargeChunk.h in Headers */,
@@ -311,7 +298,6 @@
1440AFCB1A95261100837FAA /* Zone.h in Headers */,
140FA00519CE4B6800FFD3C8 /* LineMetadata.h in Headers */,
14DD78CC18F48D7500950702 /* PerThread.h in Headers */,
- 14DD78B418F48D6B00950702 /* Chunk.h in Headers */,
14DD78CA18F48D7500950702 /* Mutex.h in Headers */,
143CB81D19022BC900B16A45 /* StaticMutex.h in Headers */,
1448C30118F3754C00502839 /* bmalloc.h in Headers */,
@@ -322,7 +308,6 @@
14DD78CD18F48D7500950702 /* Range.h in Headers */,
14DD789C18F48D4A00950702 /* BumpAllocator.h in Headers */,
14DD789918F48D4A00950702 /* Cache.h in Headers */,
- 14DD78BE18F48D6B00950702 /* SmallTraits.h in Headers */,
14DD789018F48CEB00950702 /* Sizes.h in Headers */,
14DD78C718F48D7500950702 /* BAssert.h in Headers */,
14DD78D018F48D7500950702 /* VMAllocate.h in Headers */,
@@ -330,7 +315,6 @@
143EF9B01A9FABF6004F5C77 /* FreeList.h in Headers */,
14DD78CE18F48D7500950702 /* Syscall.h in Headers */,
14DD78C618F48D7500950702 /* AsyncTask.h in Headers */,
- 14DD78BA18F48D6B00950702 /* Page.h in Headers */,
14DD78BB18F48D6B00950702 /* SmallChunk.h in Headers */,
14DD78C918F48D7500950702 /* Inline.h in Headers */,
14895D921A3A319C0006235D /* Environment.h in Headers */,