[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
andreas.kling at nokia.com
andreas.kling at nokia.com
Wed Dec 22 14:33:55 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 969e25e098f51b6258b79d1c14ad6555d3f4d1d5
Author: andreas.kling at nokia.com <andreas.kling at nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Oct 13 12:05:01 2010 +0000
2010-10-13 Andreas Kling <kling at webkit.org>
Reviewed by Kenneth Rohde Christiansen.
[Qt] Use flag instead of magic word to mark memory map free/used
Original patch by Antti Koivisto.
* Shared/qt/MappedMemory.h:
(WebKit::MappedMemory::mapSize):
(WebKit::MappedMemory::markUsed):
(WebKit::MappedMemory::markFree):
(WebKit::MappedMemory::isFree):
(WebKit::MappedMemory::data):
* Shared/qt/MappedMemoryPool.cpp:
(WebKit::MappedMemoryPool::cleanUp):
* Shared/qt/UpdateChunk.cpp:
(WebKit::mapMemory):
(WebKit::mapFile):
(WebKit::UpdateChunk::data):
(WebKit::UpdateChunk::decode):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69649 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 0b6f55b..ccdec75 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,25 @@
+2010-10-13 Andreas Kling <kling at webkit.org>
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ [Qt] Use flag instead of magic word to mark memory map free/used
+
+ Original patch by Antti Koivisto.
+
+ * Shared/qt/MappedMemory.h:
+ (WebKit::MappedMemory::mapSize):
+ (WebKit::MappedMemory::markUsed):
+ (WebKit::MappedMemory::markFree):
+ (WebKit::MappedMemory::isFree):
+ (WebKit::MappedMemory::data):
+ * Shared/qt/MappedMemoryPool.cpp:
+ (WebKit::MappedMemoryPool::cleanUp):
+ * Shared/qt/UpdateChunk.cpp:
+ (WebKit::mapMemory):
+ (WebKit::mapFile):
+ (WebKit::UpdateChunk::data):
+ (WebKit::UpdateChunk::decode):
+
2010-10-12 Jon Honeycutt <jhoneycutt at apple.com>
Build fix. Unreviewed.
diff --git a/WebKit2/Shared/qt/MappedMemory.h b/WebKit2/Shared/qt/MappedMemory.h
index 79a5167..412c210 100644
--- a/WebKit2/Shared/qt/MappedMemory.h
+++ b/WebKit2/Shared/qt/MappedMemory.h
@@ -35,11 +35,21 @@
namespace WebKit {
struct MappedMemory {
QFile* file;
- uchar* data;
- size_t size;
- void markUsed() { *reinterpret_cast<uint64_t*>(data) = 0; }
- void markFree() { *reinterpret_cast<uint64_t*>(data) = 0xdeadbeef; }
- bool isFree() { return *reinterpret_cast<uint64_t*>(data) == 0xdeadbeef; }
+ struct Data {
+ uint32_t isFree; // keep bytes aligned
+ uchar bytes;
+ };
+ union {
+ uchar* mappedBytes;
+ Data* dataPtr;
+ };
+ size_t dataSize;
+
+ size_t mapSize() const { return dataSize + sizeof(Data); }
+ void markUsed() { dataPtr->isFree = false; }
+ void markFree() { dataPtr->isFree = true; }
+ bool isFree() const { return dataPtr->isFree; }
+ uchar* data() const { return &dataPtr->bytes; }
};
class MappedMemoryPool : public QObject {
diff --git a/WebKit2/Shared/qt/MappedMemoryPool.cpp b/WebKit2/Shared/qt/MappedMemoryPool.cpp
index ed47d3b..f9f2f83 100644
--- a/WebKit2/Shared/qt/MappedMemoryPool.cpp
+++ b/WebKit2/Shared/qt/MappedMemoryPool.cpp
@@ -64,7 +64,7 @@ void MappedMemoryPool::cleanUp()
for (size_t i = 0; i < size; ++i) {
MappedMemory& chunk = m_pool.at(i);
if (!chunk.isFree())
- chunk.file->unmap(chunk.data);
+ chunk.file->unmap(chunk.mappedBytes);
chunk.file->remove();
}
diff --git a/WebKit2/Shared/qt/UpdateChunk.cpp b/WebKit2/Shared/qt/UpdateChunk.cpp
index 15d0c2c..8dd0f61 100644
--- a/WebKit2/Shared/qt/UpdateChunk.cpp
+++ b/WebKit2/Shared/qt/UpdateChunk.cpp
@@ -48,17 +48,17 @@ static MappedMemory* mapMemory(size_t size)
MappedMemoryPool* pool = MappedMemoryPool::instance();
for (unsigned n = 0; n < pool->size(); ++n) {
MappedMemory& current = pool->at(n);
- if (current.size >= size && current.isFree()) {
+ if (current.dataSize >= size && current.isFree()) {
current.markUsed();
return ¤t;
}
}
MappedMemory newMap;
- newMap.size = size;
+ newMap.dataSize = size;
newMap.file = new QTemporaryFile(QDir::tempPath() + "/WebKit2UpdateChunk");
newMap.file->open(QIODevice::ReadWrite);
- newMap.file->resize(newMap.size);
- newMap.data = newMap.file->map(0, newMap.size);
+ newMap.file->resize(newMap.mapSize());
+ newMap.mappedBytes = newMap.file->map(0, newMap.mapSize());
newMap.file->close();
newMap.markUsed();
return &pool->append(newMap);
@@ -78,7 +78,8 @@ static MappedMemory* mapFile(QString fileName, size_t size)
newMap.file = new QFile(fileName);
if (!newMap.file->open(QIODevice::ReadWrite))
return 0;
- newMap.data = newMap.file->map(0, size);
+ newMap.dataSize = size;
+ newMap.mappedBytes = newMap.file->map(0, newMap.mapSize());
ASSERT(!newMap.isFree());
newMap.file->close();
newMap.file->remove(); // The map stays alive even when the file is unlinked.
@@ -105,8 +106,8 @@ UpdateChunk::~UpdateChunk()
uint8_t* UpdateChunk::data()
{
ASSERT(m_mappedMemory);
- ASSERT(m_mappedMemory->data);
- return reinterpret_cast<uint8_t*>(m_mappedMemory->data);
+ ASSERT(m_mappedMemory->mappedBytes);
+ return reinterpret_cast<uint8_t*>(m_mappedMemory->data());
}
void UpdateChunk::encode(CoreIPC::ArgumentEncoder* encoder) const
@@ -130,7 +131,7 @@ bool UpdateChunk::decode(CoreIPC::ArgumentDecoder* decoder, UpdateChunk& chunk)
chunk.m_mappedMemory = mapFile(fileName, chunk.size());
- return chunk.m_mappedMemory->data;
+ return chunk.m_mappedMemory->mappedBytes;
}
QImage UpdateChunk::createImage()
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list