Skip to content
Permalink
Browse files
2010-10-25 Sheriff Bot <webkit.review.bot@gmail.com>
        Unreviewed, rolling out r70450.
        http://trac.webkit.org/changeset/70450
        https://bugs.webkit.org/show_bug.cgi?id=48238

        Causes WTR to crash on tests which use SharedMemory.
        (Requested by bbandix on #webkit).

        * Platform/SharedMemory.h:
        * Platform/qt/MappedMemoryPool.cpp: Removed.
        * Platform/qt/SharedMemoryQt.cpp:
        (WebKit::SharedMemory::Handle::Handle):
        (WebKit::SharedMemory::Handle::~Handle):
        (WebKit::SharedMemory::Handle::encode):
        (WebKit::SharedMemory::Handle::decode):
        (WebKit::SharedMemory::create):
        (WebKit::SharedMemory::~SharedMemory):
        (WebKit::SharedMemory::createHandle):
        (WebKit::SharedMemory::systemPageSize):
        * Shared/qt/MappedMemory.h: Renamed from WebKit2/Platform/qt/MappedMemoryPool.h.
        (WebKit::MappedMemory::mapSize):
        (WebKit::MappedMemory::markUsed):
        (WebKit::MappedMemory::markFree):
        (WebKit::MappedMemory::isFree):
        (WebKit::MappedMemory::data):
        * Shared/qt/MappedMemoryPool.cpp: Added.
        (WebKit::MappedMemoryPool::MappedMemoryPool):
        (WebKit::MappedMemoryPool::instance):
        (WebKit::MappedMemoryPool::size):
        (WebKit::MappedMemoryPool::at):
        (WebKit::MappedMemoryPool::append):
        (WebKit::MappedMemoryPool::cleanUp):
        * Shared/qt/UpdateChunk.cpp:
        (WebKit::mapMemory):
        (WebKit::mapFile):
        (WebKit::UpdateChunk::UpdateChunk):
        (WebKit::UpdateChunk::decode):
        * Shared/qt/UpdateChunk.h:
        * WebKit2.pro:

Canonical link: https://commits.webkit.org/60989@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@70453 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
webkit-commit-queue committed Oct 25, 2010
1 parent 1d82c76 commit eb64aba862defe5219470b13b1de8cc2f13734e6
Showing 8 changed files with 181 additions and 200 deletions.
@@ -1,3 +1,44 @@
2010-10-25 Sheriff Bot <webkit.review.bot@gmail.com>

Unreviewed, rolling out r70450.
http://trac.webkit.org/changeset/70450
https://bugs.webkit.org/show_bug.cgi?id=48238

Causes WTR to crash on tests which use SharedMemory.
(Requested by bbandix on #webkit).

* Platform/SharedMemory.h:
* Platform/qt/MappedMemoryPool.cpp: Removed.
* Platform/qt/SharedMemoryQt.cpp:
(WebKit::SharedMemory::Handle::Handle):
(WebKit::SharedMemory::Handle::~Handle):
(WebKit::SharedMemory::Handle::encode):
(WebKit::SharedMemory::Handle::decode):
(WebKit::SharedMemory::create):
(WebKit::SharedMemory::~SharedMemory):
(WebKit::SharedMemory::createHandle):
(WebKit::SharedMemory::systemPageSize):
* Shared/qt/MappedMemory.h: Renamed from WebKit2/Platform/qt/MappedMemoryPool.h.
(WebKit::MappedMemory::mapSize):
(WebKit::MappedMemory::markUsed):
(WebKit::MappedMemory::markFree):
(WebKit::MappedMemory::isFree):
(WebKit::MappedMemory::data):
* Shared/qt/MappedMemoryPool.cpp: Added.
(WebKit::MappedMemoryPool::MappedMemoryPool):
(WebKit::MappedMemoryPool::instance):
(WebKit::MappedMemoryPool::size):
(WebKit::MappedMemoryPool::at):
(WebKit::MappedMemoryPool::append):
(WebKit::MappedMemoryPool::cleanUp):
* Shared/qt/UpdateChunk.cpp:
(WebKit::mapMemory):
(WebKit::mapFile):
(WebKit::UpdateChunk::UpdateChunk):
(WebKit::UpdateChunk::decode):
* Shared/qt/UpdateChunk.h:
* WebKit2.pro:

2010-10-25 Zoltan Horvath <zoltan@webkit.org>

Reviewed by Kenneth Rohde Christiansen.
@@ -30,10 +30,6 @@
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>

#if PLATFORM(QT)
#include <wtf/text/WTFString.h>
#endif

namespace CoreIPC {
class ArgumentDecoder;
class ArgumentEncoder;
@@ -64,8 +60,6 @@ class SharedMemory : public RefCounted<SharedMemory> {
mutable mach_port_t m_port;
#elif PLATFORM(WIN)
mutable HANDLE m_handle;
#elif PLATFORM(QT)
mutable String m_fileName;
#endif
size_t m_size;
};

This file was deleted.

@@ -1,7 +1,5 @@
/*
* Copyright (C) 2010 Apple Inc. All rights reserved.
* Copyright (c) 2010 University of Szeged
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,131 +25,58 @@

#include "SharedMemory.h"

#include "ArgumentDecoder.h"
#include "ArgumentEncoder.h"
#include "MappedMemoryPool.h"
#include "WebCoreArgumentCoders.h"
#include <QIODevice>
#include <unistd.h>
#include <wtf/text/WTFString.h>
#include "NotImplemented.h"

namespace WebKit {

static MappedMemoryPool* mappedMemoryPool = MappedMemoryPool::instance();

SharedMemory::Handle::Handle()
: m_fileName()
, m_size(0)
{
notImplemented();
}

SharedMemory::Handle::~Handle()
{
}

bool SharedMemory::Handle::isNull() const
{
return m_fileName.isNull();
notImplemented();
}

void SharedMemory::Handle::encode(CoreIPC::ArgumentEncoder* encoder) const
{
encoder->encodeUInt64(m_size);
encoder->encode(m_fileName);
m_fileName = String();
notImplemented();
}

bool SharedMemory::Handle::decode(CoreIPC::ArgumentDecoder* decoder, Handle& handle)
{
ASSERT(!handle.m_size);
ASSERT(handle.m_fileName.isEmpty());

uint64_t size;
if (!decoder->decodeUInt64(size))
return false;

String fileName;
if (!decoder->decode(fileName))
return false;

handle.m_size = size;
handle.m_fileName = fileName;

return true;
notImplemented();
return false;
}

PassRefPtr<SharedMemory> SharedMemory::create(size_t size)
{
MappedMemory* mm = mappedMemoryPool->mapMemory(size, QIODevice::ReadWrite);

RefPtr<SharedMemory> sharedMemory(adoptRef(new SharedMemory));
sharedMemory->m_size = size;
sharedMemory->m_data = reinterpret_cast<void*>(mm->data());

return sharedMemory.release();
}

static inline QIODevice::OpenMode mapProtection(SharedMemory::Protection protection)
{
switch (protection) {
case SharedMemory::ReadOnly:
return QIODevice::ReadOnly;
case SharedMemory::ReadWrite:
return QIODevice::ReadWrite;
}

ASSERT_NOT_REACHED();
return QIODevice::NotOpen;
notImplemented();
return 0;
}

PassRefPtr<SharedMemory> SharedMemory::create(const Handle& handle, Protection protection)
{
if (handle.isNull())
return 0;

QIODevice::OpenMode openMode = mapProtection(protection);

MappedMemory* mm = mappedMemoryPool->mapFile(QString(handle.m_fileName), handle.m_size, openMode);

RefPtr<SharedMemory> sharedMemory(adoptRef(new SharedMemory));
sharedMemory->m_size = handle.m_size;
sharedMemory->m_data = reinterpret_cast<void*>(mm->data());

return sharedMemory.release();
notImplemented();
return 0;
}

SharedMemory::~SharedMemory()
{
MappedMemory* mappedMemory = mappedMemoryPool->searchForMappedMemory(reinterpret_cast<uchar*>(m_data));
if (mappedMemory) {
mappedMemory->markFree();
delete mappedMemory;
}
notImplemented();
}

bool SharedMemory::createHandle(Handle& handle, Protection protection)
{
ASSERT(handle.m_fileName.isNull());
ASSERT(!handle.m_size);

MappedMemory* mm = mappedMemoryPool->searchForMappedMemory(reinterpret_cast<uchar*>(m_data));

if (!mm)
return false;

handle.m_fileName = mm->file->fileName();
handle.m_size = m_size;

return true;
notImplemented();
return false;
}

unsigned SharedMemory::systemPageSize()
{
static unsigned pageSize = 0;

if (!pageSize)
pageSize = getpagesize();

return pageSize;
}

@@ -0,0 +1,74 @@
/*
* Copyright (C) 2010 University of Szeged
* 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 UNIVERSITY OF SZEGED ``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 UNIVERSITY OF SZEGED 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.
*/

#include "MappedMemory.h"

#include "StdLibExtras.h"

namespace WebKit {

MappedMemoryPool::MappedMemoryPool()
{
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), SLOT(cleanUp()));
}

MappedMemoryPool* MappedMemoryPool::instance()
{
DEFINE_STATIC_LOCAL(MappedMemoryPool, singleton, ());
return &singleton;
}

size_t MappedMemoryPool::size() const
{
return m_pool.size();
}

MappedMemory& MappedMemoryPool::at(size_t i)
{
return m_pool.at(i);
}

MappedMemory& MappedMemoryPool::append(const MappedMemory& newMap)
{
m_pool.append(newMap);
return m_pool.last();
}

void MappedMemoryPool::cleanUp()
{
size_t size = m_pool.size();

for (size_t i = 0; i < size; ++i) {
MappedMemory& chunk = m_pool.at(i);
if (!chunk.isFree())
chunk.file->unmap(chunk.mappedBytes);
chunk.file->remove();
}

delete this;
}

} // namespace WebKit

0 comments on commit eb64aba

Please sign in to comment.