From 7332dd762a406bb94d37e53a0bdd16045760d956 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 25 Jan 2011 10:45:41 +0100 Subject: Moved the implementation of mapFromGlobal/mapToGlobal to QWidgetPrivate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: João Abecasis --- src/gui/kernel/qwidget_p.h | 2 ++ src/gui/kernel/qwidget_x11.cpp | 50 +++++++++++++++++++++++++----------------- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 693984a..3759dd1 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -767,6 +767,8 @@ public: void x11UpdateIsOpaque(); bool isBackgroundInherited() const; void updateX11AcceptFocus(); + QPoint mapToGlobal(const QPoint &pos) const; + QPoint mapFromGlobal(const QPoint &pos) const; #elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN uint noPaintOnScreen : 1; // see qwidget_win.cpp ::paintEngine() #ifndef QT_NO_GESTURES diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index a93c545..4b59bfc 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -1280,39 +1280,49 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) #endif } - -QPoint QWidget::mapToGlobal(const QPoint &pos) const +QPoint QWidgetPrivate::mapToGlobal(const QPoint &pos) const { - Q_D(const QWidget); - if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) { - QPoint p = pos + data->crect.topLeft(); + Q_Q(const QWidget); + if (!q->testAttribute(Qt::WA_WState_Created) || !q->internalWinId()) { + QPoint p = pos + q->data->crect.topLeft(); //cannot trust that !isWindow() implies parentWidget() before create - return (isWindow() || !parentWidget()) ? p : parentWidget()->mapToGlobal(p); + return (q->isWindow() || !q->parentWidget()) ? p : q->parentWidget()->d_func()->mapToGlobal(p); } - int x, y; + int x, y; Window child; - QPoint p = d->mapToWS(pos); - XTranslateCoordinates(X11->display, internalWinId(), - QApplication::desktop()->screen(d->xinfo.screen())->internalWinId(), + QPoint p = mapToWS(pos); + XTranslateCoordinates(X11->display, q->internalWinId(), + QApplication::desktop()->screen(xinfo.screen())->internalWinId(), p.x(), p.y(), &x, &y, &child); return QPoint(x, y); } - -QPoint QWidget::mapFromGlobal(const QPoint &pos) const +QPoint QWidgetPrivate::mapFromGlobal(const QPoint &pos) const { - Q_D(const QWidget); - if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) { + Q_Q(const QWidget); + if (!q->testAttribute(Qt::WA_WState_Created) || !q->internalWinId()) { //cannot trust that !isWindow() implies parentWidget() before create - QPoint p = (isWindow() || !parentWidget()) ? pos : parentWidget()->mapFromGlobal(pos); - return p - data->crect.topLeft(); + QPoint p = (q->isWindow() || !q->parentWidget()) ? pos : q->parentWidget()->d_func()->mapFromGlobal(pos); + return p - q->data->crect.topLeft(); } - int x, y; + int x, y; Window child; XTranslateCoordinates(X11->display, - QApplication::desktop()->screen(d->xinfo.screen())->internalWinId(), - internalWinId(), pos.x(), pos.y(), &x, &y, &child); - return d->mapFromWS(QPoint(x, y)); + QApplication::desktop()->screen(xinfo.screen())->internalWinId(), + q->internalWinId(), pos.x(), pos.y(), &x, &y, &child); + return mapFromWS(QPoint(x, y)); +} + +QPoint QWidget::mapToGlobal(const QPoint &pos) const +{ + Q_D(const QWidget); + return d->mapToGlobal(pos); +} + +QPoint QWidget::mapFromGlobal(const QPoint &pos) const +{ + Q_D(const QWidget); + return d->mapFromGlobal(pos); } void QWidgetPrivate::updateSystemBackground() -- cgit v0.12 From cdd776a91e65bf5c30cea1bab9823134a3f797d0 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 25 Jan 2011 10:01:56 +0100 Subject: Improved performance of mapFromGlobal/mapToGlobal on X11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't call XTranslateCoordinates anymore, but use the toplevel window offset that we already store to convert between screen coordinates and widget coordinates. Reviewed-by: João Abecasis --- src/gui/kernel/qwidget_x11.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index 4b59bfc..9893478 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -1316,12 +1316,40 @@ QPoint QWidgetPrivate::mapFromGlobal(const QPoint &pos) const QPoint QWidget::mapToGlobal(const QPoint &pos) const { Q_D(const QWidget); + QPoint offset = data->crect.topLeft(); + const QWidget *w = this; + const QWidget *p = w->parentWidget(); + while (!w->isWindow() && p) { + w = p; + p = p->parentWidget(); + offset += w->data->crect.topLeft(); + } + + const QWidgetPrivate *wd = w->d_func(); + QTLWExtra *tlw = wd->topData(); + if (!tlw->embedded) + return pos + offset; + return d->mapToGlobal(pos); } QPoint QWidget::mapFromGlobal(const QPoint &pos) const { Q_D(const QWidget); + QPoint offset = data->crect.topLeft(); + const QWidget *w = this; + const QWidget *p = w->parentWidget(); + while (!w->isWindow() && p) { + w = p; + p = p->parentWidget(); + offset += w->data->crect.topLeft(); + } + + const QWidgetPrivate *wd = w->d_func(); + QTLWExtra *tlw = wd->topData(); + if (!tlw->embedded) + return pos - offset; + return d->mapFromGlobal(pos); } -- cgit v0.12 From 7db489a0de073a2a56fe32d16f1cbe1bebdfd06d Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 25 Jan 2011 11:39:37 +0100 Subject: QtScript/JSC on Symbian: Enhanced memory allocator for Collector heap Cherry-picked from http://trac.webkit.org/changeset/56370 The old allocator caused QML to crash in MCL (TB10.1, week 1). Task-number: QTBUG-14293 Reviewed-by: Simon Hausmann --- .../javascriptcore/JavaScriptCore/ChangeLog | 28 +++++ .../JavaScriptCore/JavaScriptCore.pri | 3 + .../JavaScriptCore/runtime/Collector.cpp | 46 ++----- .../JavaScriptCore/runtime/Collector.h | 9 ++ .../JavaScriptCore/runtime/CollectorHeapIterator.h | 10 +- .../wtf/symbian/BlockAllocatorSymbian.cpp | 132 +++++++++++++++++++++ .../wtf/symbian/BlockAllocatorSymbian.h | 120 +++++++++++++++++++ src/3rdparty/javascriptcore/VERSION | 4 +- src/script/script.pro | 1 - 9 files changed, 309 insertions(+), 44 deletions(-) create mode 100644 src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp create mode 100644 src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog b/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog index fd6c3f7..c2b1155 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog +++ b/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog @@ -232,6 +232,34 @@ without using doubles, but the code would be much more complicated, and there is no important reason to stick to integers here. +2010-03-22 Siddharth Mathur + + Reviewed by Laszlo Gombos. + + [Symbian] More efficient aligned memory allocation for JSC Collector + https://bugs.webkit.org/show_bug.cgi?id=34350 + + * JavaScriptCore.pri: Added 2 new Symbian source files and HAL linkage + + * runtime/Collector.cpp: Reduced port-specific code and added private data member + (JSC::Heap::Heap): + (JSC::Heap::~Heap): + (JSC::Heap::destroy): + (JSC::Heap::allocateBlock): + (JSC::Heap::freeBlockPtr): + + * runtime/Collector.h: Added private data member + + * wtf/symbian: Added. + * wtf/symbian/BlockAllocatorSymbian.cpp: Added. + (WTF::AlignedBlockAllocator::AlignedBlockAllocator): Helper class to allocate + aligned blocks more efficiently as required by Collector + (WTF::AlignedBlockAllocator::alloc): + (WTF::AlignedBlockAllocator::free): + (WTF::AlignedBlockAllocator::destroy): + (WTF::AlignedBlockAllocator::~AlignedBlockAllocator): + * wtf/symbian/BlockAllocatorSymbian.h: Added. + 2010-03-22 Geoffrey Garen Reviewed by Sam Weinig. diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri b/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri index d75bd31..b061321 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri +++ b/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri @@ -16,6 +16,7 @@ CONFIG(debug, debug|release) { symbian: { # Need to guarantee this comes before system includes of /epoc32/include MMP_RULES += "USERINCLUDE ../JavaScriptCore/profiler" + LIBS += -lhal } INCLUDEPATH = \ @@ -33,6 +34,7 @@ INCLUDEPATH = \ $$PWD/runtime \ $$PWD/wrec \ $$PWD/wtf \ + $$PWD/wtf/symbian \ $$PWD/wtf/unicode \ $$PWD/yarr \ $$PWD/API \ @@ -211,6 +213,7 @@ SOURCES += \ wtf/qt/ThreadingQt.cpp \ wtf/RandomNumber.cpp \ wtf/RefCountedLeakCounter.cpp \ + wtf/symbian/BlockAllocatorSymbian.cpp \ wtf/symbian/RegisterFileAllocatorSymbian.cpp \ wtf/ThreadingNone.cpp \ wtf/Threading.cpp \ diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp index 24873c8..42e2a35 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp +++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp @@ -53,11 +53,6 @@ #include #include -#elif OS(SYMBIAN) -#include -#include -#include - #elif OS(WINDOWS) #include @@ -109,11 +104,6 @@ const size_t ALLOCATIONS_PER_COLLECTION = 3600; // a PIC branch in Mach-O binaries, see . #define MIN_ARRAY_SIZE (static_cast(14)) -#if OS(SYMBIAN) -const size_t MAX_NUM_BLOCKS = 256; // Max size of collector heap set to 16 MB -static RHeap* userChunk = 0; -#endif - #if ENABLE(JSC_MULTIPLE_THREADS) #if OS(DARWIN) @@ -146,29 +136,11 @@ Heap::Heap(JSGlobalData* globalData) , m_currentThreadRegistrar(0) #endif , m_globalData(globalData) +#if OS(SYMBIAN) + , m_blockallocator(JSCCOLLECTOR_VIRTUALMEM_RESERVATION, BLOCK_SIZE) +#endif { ASSERT(globalData); - -#if OS(SYMBIAN) - // Symbian OpenC supports mmap but currently not the MAP_ANON flag. - // Using fastMalloc() does not properly align blocks on 64k boundaries - // and previous implementation was flawed/incomplete. - // UserHeap::ChunkHeap allows allocation of continuous memory and specification - // of alignment value for (symbian) cells within that heap. - // - // Clarification and mapping of terminology: - // RHeap (created by UserHeap::ChunkHeap below) is continuos memory chunk, - // which can dynamically grow up to 8 MB, - // that holds all CollectorBlocks of this session (static). - // Each symbian cell within RHeap maps to a 64kb aligned CollectorBlock. - // JSCell objects are maintained as usual within CollectorBlocks. - if (!userChunk) { - userChunk = UserHeap::ChunkHeap(0, 0, MAX_NUM_BLOCKS * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE); - if (!userChunk) - CRASH(); - } -#endif // OS(SYMBIAN) - memset(&m_heap, 0, sizeof(CollectorHeap)); allocateBlock(); } @@ -211,7 +183,9 @@ void Heap::destroy() t = next; } #endif - +#if OS(SYMBIAN) + m_blockallocator.destroy(); +#endif m_globalData = 0; } @@ -221,11 +195,9 @@ NEVER_INLINE CollectorBlock* Heap::allocateBlock() vm_address_t address = 0; vm_map(current_task(), &address, BLOCK_SIZE, BLOCK_OFFSET_MASK, VM_FLAGS_ANYWHERE | VM_TAG_FOR_COLLECTOR_MEMORY, MEMORY_OBJECT_NULL, 0, FALSE, VM_PROT_DEFAULT, VM_PROT_DEFAULT, VM_INHERIT_DEFAULT); #elif OS(SYMBIAN) - // Allocate a 64 kb aligned CollectorBlock - unsigned char* mask = reinterpret_cast(userChunk->Alloc(BLOCK_SIZE)); - if (!mask) + void* address = m_blockallocator.alloc(); + if (!address) CRASH(); - uintptr_t address = reinterpret_cast(mask); #elif OS(WINCE) void* address = VirtualAlloc(NULL, BLOCK_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); #elif OS(WINDOWS) @@ -316,7 +288,7 @@ NEVER_INLINE void Heap::freeBlockPtr(CollectorBlock* block) #if OS(DARWIN) vm_deallocate(current_task(), reinterpret_cast(block), BLOCK_SIZE); #elif OS(SYMBIAN) - userChunk->Free(reinterpret_cast(block)); + m_blockallocator.free(reinterpret_cast(block)); #elif OS(WINCE) VirtualFree(block, 0, MEM_RELEASE); #elif OS(WINDOWS) diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h index 7f7a679..d3616dc 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h +++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h @@ -35,6 +35,10 @@ #include #endif +#if OS(SYMBIAN) +#include +#endif + #define ASSERT_CLASS_FITS_IN_CELL(class) COMPILE_ASSERT(sizeof(class) <= CELL_SIZE, class_fits_in_cell) namespace JSC { @@ -167,6 +171,11 @@ namespace JSC { pthread_key_t m_currentThreadRegistrar; #endif +#if OS(SYMBIAN) + // Allocates collector blocks with correct alignment + WTF::AlignedBlockAllocator m_blockallocator; +#endif + JSGlobalData* m_globalData; }; diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/CollectorHeapIterator.h b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/CollectorHeapIterator.h index 4a38df9..e4f2f91 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/CollectorHeapIterator.h +++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/CollectorHeapIterator.h @@ -97,12 +97,14 @@ namespace JSC { inline LiveObjectIterator& LiveObjectIterator::operator++() { - advance(HeapConstants::cellsPerBlock - 1); - if (m_block < m_heap.nextBlock || (m_block == m_heap.nextBlock && m_cell < m_heap.nextCell)) + if (m_block < m_heap.nextBlock || m_cell < m_heap.nextCell) { + advance(HeapConstants::cellsPerBlock); return *this; + } - while (m_block < m_heap.usedBlocks && !m_heap.blocks[m_block]->marked.get(m_cell)) - advance(HeapConstants::cellsPerBlock - 1); + do { + advance(HeapConstants::cellsPerBlock); + } while (m_block < m_heap.usedBlocks && !m_heap.blocks[m_block]->marked.get(m_cell)); return *this; } diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp new file mode 100644 index 0000000..6a28e9e --- /dev/null +++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp @@ -0,0 +1,132 @@ +/* + * 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 + * 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. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * 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. + */ + +#include "config.h" + +#if OS(SYMBIAN) + +#include "BlockAllocatorSymbian.h" + + +namespace WTF { + +/** Efficiently allocates blocks of size blockSize with blockSize alignment. + * Primarly designed for JSC Collector's needs. + * Not thread-safe. + */ +AlignedBlockAllocator::AlignedBlockAllocator(TUint32 reservationSize, TUint32 blockSize ) + : m_reservation(reservationSize), + m_blockSize(blockSize) +{ + + // Get system's page size value. + SYMBIAN_PAGESIZE(m_pageSize); + + // We only accept multiples of system page size for both initial reservation and the alignment/block size + m_reservation = SYMBIAN_ROUNDUPTOMULTIPLE(m_reservation, m_pageSize); + __ASSERT_ALWAYS(SYMBIAN_ROUNDUPTOMULTIPLE(m_blockSize, m_pageSize), User::Panic(_L("AlignedBlockAllocator1"), KErrArgument)); + + // Calculate max. bit flags we need to carve a reservationSize range into blockSize-sized blocks + m_map.numBits = m_reservation / m_blockSize; + const TUint32 bitsPerWord = 8*sizeof(TUint32); + const TUint32 numWords = (m_map.numBits + bitsPerWord -1) / bitsPerWord; + + m_map.bits = new TUint32[numWords]; + __ASSERT_ALWAYS(m_map.bits, User::Panic(_L("AlignedBlockAllocator2"), KErrNoMemory)); + m_map.clearAll(); + + // Open a Symbian RChunk, and reserve requested virtual address range + // Any thread in this process can operate this rchunk due to EOwnerProcess access rights. + TInt ret = m_chunk.CreateDisconnectedLocal(0 , 0, (TInt)m_reservation , EOwnerProcess); + if (ret != KErrNone) + User::Panic(_L("AlignedBlockAllocator3"), ret); + + // This is the offset to m_chunk.Base() required to make it m_blockSize-aligned + m_offset = SYMBIAN_ROUNDUPTOMULTIPLE(TUint32(m_chunk.Base()), m_blockSize) - TUint(m_chunk.Base()); + +} + +void* AlignedBlockAllocator::alloc() +{ + + TInt freeRam = 0; + void* address = 0; + + // Look up first free slot in bit map + const TInt freeIdx = m_map.findFree(); + + // Pseudo OOM: We ate up the address space we reserved.. + // ..even though the device may have free RAM left + if (freeIdx < 0) + return 0; + + TInt ret = m_chunk.Commit(m_offset + (m_blockSize * freeIdx), m_blockSize); + if (ret != KErrNone) + return 0; // True OOM: Device didn't have physical RAM to spare + + // Updated bit to mark region as in use. + m_map.set(freeIdx); + + // Calculate address of committed region (block) + address = (void*)( (m_chunk.Base() + m_offset) + (TUint)(m_blockSize * freeIdx) ); + + return address; +} + +void AlignedBlockAllocator::free(void* block) +{ + // Calculate index of block to be freed + TInt idx = TUint(static_cast(block) - m_chunk.Base() - m_offset) / m_blockSize; + + __ASSERT_DEBUG(idx >= 0 && idx < m_map.numBits, User::Panic(_L("AlignedBlockAllocator4"), KErrCorrupt)); // valid index check + __ASSERT_DEBUG(m_map.get(idx), User::Panic(_L("AlignedBlockAllocator5"), KErrCorrupt)); // in-use flag check + + // Return committed region to system RAM pool (the physical RAM becomes usable by others) + TInt ret = m_chunk.Decommit(m_offset + m_blockSize * idx, m_blockSize); + + // mark this available again + m_map.clear(idx); +} + +void AlignedBlockAllocator::destroy() +{ + // release everything! + m_chunk.Decommit(0, m_chunk.MaxSize()); + m_map.clearAll(); +} + +AlignedBlockAllocator::~AlignedBlockAllocator() +{ + destroy(); + m_chunk.Close(); + delete [] m_map.bits; +} + +} // end of namespace + +#endif // SYMBIAN diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h new file mode 100644 index 0000000..21422f6 --- /dev/null +++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h @@ -0,0 +1,120 @@ +/* + * 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 + * 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. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * 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 BlockAllocatorSymbian_h +#define BlockAllocatorSymbian_h + +#include +#include +#include + + +#define SYMBIAN_PAGESIZE(x) (HAL::Get(HALData::EMemoryPageSize, x)); +#define SYMBIAN_FREERAM(x) (HAL::Get(HALData::EMemoryRAMFree, x)); +#define SYMBIAN_ROUNDUPTOMULTIPLE(x, multipleof) ( (x + multipleof - 1) & ~(multipleof - 1) ) + +// Set sane defaults if -D wasn't provided via compiler args +#ifndef JSCCOLLECTOR_VIRTUALMEM_RESERVATION +#if defined(__WINS__) + // Emulator has limited virtual address space + #define JSCCOLLECTOR_VIRTUALMEM_RESERVATION (4*1024*1024) +#else + // HW has plenty of virtual addresses + #define JSCCOLLECTOR_VIRTUALMEM_RESERVATION (128*1024*1024) +#endif +#endif + +namespace WTF { + +/** + * Allocates contiguous region of size blockSize with blockSize-aligned address. + * blockSize must be a multiple of system page size (typically 4K on Symbian/ARM) + * + * @param reservationSize Virtual address range to be reserved upon creation of chunk (bytes). + * @param blockSize Size of a single allocation. Returned address will also be blockSize-aligned. + */ +class AlignedBlockAllocator { + public: + AlignedBlockAllocator(TUint32 reservationSize, TUint32 blockSize); + ~AlignedBlockAllocator(); + void destroy(); + void* alloc(); + void free(void* data); + + private: + RChunk m_chunk; // Symbian chunk that lets us reserve/commit/decommit + TUint m_offset; // offset of first committed region from base + TInt m_pageSize; // cached value of system page size, typically 4K on Symbian + TUint32 m_reservation; + TUint32 m_blockSize; + + // Tracks comitted/decommitted state of a blockSize region + struct { + + TUint32 *bits; // array of bit flags + TUint32 numBits; // number of regions to keep track of + + bool get(TUint32 n) const + { + return !!(bits[n >> 5] & (1 << (n & 0x1F))); + } + + void set(TUint32 n) + { + bits[n >> 5] |= (1 << (n & 0x1F)); + } + + void clear(TUint32 n) + { + bits[n >> 5] &= ~(1 << (n & 0x1F)); + } + + void clearAll() + { + for (TUint32 i = 0; i < numBits; i++) + clear(i); + } + + TInt findFree() const + { + for (TUint32 i = 0; i < numBits; i++) { + if (!get(i)) + return i; + } + return -1; + } + + } m_map; + +}; + +} + +#endif // end of BlockAllocatorSymbian_h + + diff --git a/src/3rdparty/javascriptcore/VERSION b/src/3rdparty/javascriptcore/VERSION index 9991ac0..b4744b7 100644 --- a/src/3rdparty/javascriptcore/VERSION +++ b/src/3rdparty/javascriptcore/VERSION @@ -4,8 +4,8 @@ This is a snapshot of JavaScriptCore from The commit imported was from the - javascriptcore-snapshot-05102010 branch/tag + javascriptcore-snapshot-24012011 branch/tag and has the sha1 checksum - 82ead85cfea5859044eeb25b33314dcc0fa5eea1 + d143bde5ae8cff229aebd43487a2fce5e713e990 diff --git a/src/script/script.pro b/src/script/script.pro index d1633d8..63917b1 100644 --- a/src/script/script.pro +++ b/src/script/script.pro @@ -81,7 +81,6 @@ include(script.pri) symbian { TARGET.UID3=0x2001B2E1 - LIBS += -lhal } symbian { -- cgit v0.12 From 41297f2d592ef21327b5c7523c52c1ecd3c727f4 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 25 Jan 2011 13:49:46 +0200 Subject: Fix QMAKE_POST_LINK in Symbian for targets with special characters. Proper fixed targets was not used to generate the dependency for QMAKE_POST_LINK in symbian-sbsv2, causing post linking to happen before actual linking. Task-number: QTBUG-16881 Reviewed-by: axis --- qmake/generators/symbian/symmake_sbsv2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qmake/generators/symbian/symmake_sbsv2.cpp b/qmake/generators/symbian/symmake_sbsv2.cpp index 6d01523..9eccd46 100644 --- a/qmake/generators/symbian/symmake_sbsv2.cpp +++ b/qmake/generators/symbian/symmake_sbsv2.cpp @@ -686,7 +686,7 @@ void SymbianSbsv2MakefileGenerator::writeBldInfExtensionRulesPart(QTextStream& t fixFlmCmd(&postLinkCmd, commandsToReplace); t << "START EXTENSION qt/qmake_post_link" << endl; t << "OPTION POST_LINK_CMD " << postLinkCmd << endl; - t << "OPTION LINK_TARGET " << removePathSeparators(escapeFilePath(fileFixify(project->first("TARGET"))).append(".").append(getTargetExtension())) << endl; + t << "OPTION LINK_TARGET " << fixedTarget << QLatin1String(".") << getTargetExtension() << endl; t << "END" << endl; t << endl; } -- cgit v0.12 From 34c297faca93e1286573b2a01127e4e7af00aff2 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Mon, 24 Jan 2011 19:09:38 +0100 Subject: Fix cursor position adjustment when removing strings Commit 0ba1b4d0 introduced a regression to QTextDocument: it postponed cursor position adjustment until the move operation is done, but contentsChanged will be triggered by finishEdit() in this move operation, thus cursor positions in this signal handler will be in inconsistent states (normally we should first update cursor position then trigger contentsChanged). In this case we should also postpone finishEdit() handling after cursor positions have been adjusted, then the states expose to applications will be consistent. Task-number: QTBUG-15857 Reviewed-by: Eskil --- src/gui/text/qtextdocument_p.cpp | 4 +++- tests/auto/qtextcursor/tst_qtextcursor.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index 498a432..2172f74 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -663,7 +663,8 @@ void QTextDocumentPrivate::move(int pos, int to, int length, QTextUndoCommand::O Q_ASSERT(blocks.length() == fragments.length()); - finishEdit(); + if (!blockCursorAdjustment) + finishEdit(); } void QTextDocumentPrivate::remove(int pos, int length, QTextUndoCommand::Operation op) @@ -678,6 +679,7 @@ void QTextDocumentPrivate::remove(int pos, int length, QTextUndoCommand::Operati curs->changed = true; } } + finishEdit(); } void QTextDocumentPrivate::setCharFormat(int pos, int length, const QTextCharFormat &newFormat, FormatChangeMode mode) diff --git a/tests/auto/qtextcursor/tst_qtextcursor.cpp b/tests/auto/qtextcursor/tst_qtextcursor.cpp index ee2baef..4d52dd7 100644 --- a/tests/auto/qtextcursor/tst_qtextcursor.cpp +++ b/tests/auto/qtextcursor/tst_qtextcursor.cpp @@ -134,6 +134,7 @@ private slots: void endOfLine(); void editBlocksDuringRemove(); + void selectAllDuringRemove(); void update_data(); void update(); @@ -1388,6 +1389,17 @@ public slots: ++recordingCount; } + void selectAllContents() + { + // Only test the first time + if (!recordingCount) { + recordingCount++; + cursor->select(QTextCursor::Document); + lastRecordedPosition = cursor->position(); + lastRecordedAnchor = cursor->anchor(); + } + } + private: QTextCursor *cursor; }; @@ -1411,6 +1423,22 @@ void tst_QTextCursor::editBlocksDuringRemove() QVERIFY(doc->toPlainText().isEmpty()); } +void tst_QTextCursor::selectAllDuringRemove() +{ + CursorListener listener(&cursor); + + cursor.insertText("Hello World"); + cursor.movePosition(QTextCursor::End); + + connect(doc, SIGNAL(contentsChanged()), &listener, SLOT(selectAllContents())); + listener.recordingCount = 0; + QTextCursor localCursor = cursor; + localCursor.deletePreviousChar(); + + QCOMPARE(listener.lastRecordedPosition, 10); + QCOMPARE(listener.lastRecordedAnchor, 0); +} + void tst_QTextCursor::update_data() { QTest::addColumn("text"); -- cgit v0.12 From c6a6448272168f0105c973bef5e531114533fc90 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Mon, 24 Jan 2011 14:22:57 +0100 Subject: add autotest for digest authentication Reviewed-by: Markus Goetz Task-number: QTBUG-15070 --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 30 +++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index bd22837..8274140 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -212,6 +212,7 @@ private Q_SLOTS: void ioGetFromBuiltinHttp(); void ioGetFromHttpWithReuseParallel(); void ioGetFromHttpWithReuseSequential(); + void ioGetFromHttpWithAuth_data(); void ioGetFromHttpWithAuth(); void ioGetFromHttpWithAuthSynchronous(); void ioGetFromHttpWithProxyAuth(); @@ -2163,15 +2164,27 @@ void tst_QNetworkReply::ioGetFromHttpWithReuseSequential() } } +void tst_QNetworkReply::ioGetFromHttpWithAuth_data() +{ + QTest::addColumn("url"); + QTest::addColumn("expectedData"); + + QFile reference(SRCDIR "/rfc3252.txt"); + reference.open(QIODevice::ReadOnly); + QByteArray referenceData = reference.readAll(); + QTest::newRow("basic") << QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/rfcs-auth/rfc3252.txt") << referenceData; + QTest::newRow("digest") << QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/auth-digest/") << QByteArray("digest authentication successful\n"); +} + void tst_QNetworkReply::ioGetFromHttpWithAuth() { // This test sends three requests // The first two in parallel // The third after the first two finished - QFile reference(SRCDIR "/rfc3252.txt"); - QVERIFY(reference.open(QIODevice::ReadOnly)); - QNetworkRequest request(QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/rfcs-auth/rfc3252.txt")); + QFETCH(QUrl, url); + QFETCH(QByteArray, expectedData); + QNetworkRequest request(url); { QNetworkReplyPtr reply1 = manager.get(request); QNetworkReplyPtr reply2 = manager.get(request); @@ -2196,14 +2209,12 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth() QCOMPARE(reply1->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); QCOMPARE(reply2->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); - QByteArray referenceData = reference.readAll(); - QCOMPARE(reader1.data, referenceData); - QCOMPARE(reader2.data, referenceData); + QCOMPARE(reader1.data, expectedData); + QCOMPARE(reader2.data, expectedData); QCOMPARE(authspy.count(), 1); } - reference.seek(0); // rinse and repeat: { QNetworkReplyPtr reply = manager.get(request); @@ -2219,13 +2230,12 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth() this, SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*))); QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); - QCOMPARE(reader.data, reference.readAll()); + QCOMPARE(reader.data, expectedData); QCOMPARE(authspy.count(), 0); } // now check with synchronous calls: - reference.seek(0); { request.setAttribute( static_cast(SynchronousRequestAttribute), @@ -2241,7 +2251,7 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth() // the only thing we check here is that the auth cache was used when using synchronous requests QCOMPARE(replySync->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); - QCOMPARE(replySync->readAll(), reference.readAll()); + QCOMPARE(replySync->readAll(), expectedData); } } -- cgit v0.12 From cb38007cd3b253fb2e3a8587ae9e64080e707a31 Mon Sep 17 00:00:00 2001 From: Eckhart Koppen Date: Tue, 25 Jan 2011 15:11:33 +0200 Subject: Temporary fix for ambiguous cast from four letter char constant --- src/gui/text/qfontdatabase_s60.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index ad67189..97426a8 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -721,7 +721,7 @@ static inline bool ttfMarkAppFont(QByteArray &ttf, const QString &marker) memoryRanges.append(Range(offset, lengthAligned)); quint32 checkSum = qFromBigEndian(tableRecord->checkSum); - if (tableRecord->tag == qToBigEndian('head')) { + if (tableRecord->tag == qToBigEndian(static_cast('head'))) { if (length < ttfCheckSumAdjustmentOffset + sizeof(quint32)) return false; // Invalid 'head' table const quint32 *checkSumAdjustmentTag = @@ -735,7 +735,7 @@ static inline bool ttfMarkAppFont(QByteArray &ttf, const QString &marker) bool updateTableChecksum = false; QByteArray table; - if (tableRecord->tag == qToBigEndian('name')) { + if (tableRecord->tag == qToBigEndian(static_cast('name'))) { table = QByteArray(ttf.constData() + offset, length); if (!ttfMarkNameTable(table, marker)) return false; // Name table was not markable. -- cgit v0.12 From f0667b4b439f87f8bd613add148e94d520e77be1 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 25 Jan 2011 16:50:22 +0100 Subject: Revert "QtScript/JSC on Symbian: Enhanced memory allocator for Collector heap" This reverts commit 7db489a0de073a2a56fe32d16f1cbe1bebdfd06d. The change to CollectorHeapIterator.h is not Symbian-specific and it introduced test failures on all platforms (tst_QScriptEngineAgent::positionChange_3()). --- .../javascriptcore/JavaScriptCore/ChangeLog | 28 ----- .../JavaScriptCore/JavaScriptCore.pri | 3 - .../JavaScriptCore/runtime/Collector.cpp | 46 +++++-- .../JavaScriptCore/runtime/Collector.h | 9 -- .../JavaScriptCore/runtime/CollectorHeapIterator.h | 10 +- .../wtf/symbian/BlockAllocatorSymbian.cpp | 132 --------------------- .../wtf/symbian/BlockAllocatorSymbian.h | 120 ------------------- src/3rdparty/javascriptcore/VERSION | 4 +- src/script/script.pro | 1 + 9 files changed, 44 insertions(+), 309 deletions(-) delete mode 100644 src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp delete mode 100644 src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog b/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog index c2b1155..fd6c3f7 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog +++ b/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog @@ -232,34 +232,6 @@ without using doubles, but the code would be much more complicated, and there is no important reason to stick to integers here. -2010-03-22 Siddharth Mathur - - Reviewed by Laszlo Gombos. - - [Symbian] More efficient aligned memory allocation for JSC Collector - https://bugs.webkit.org/show_bug.cgi?id=34350 - - * JavaScriptCore.pri: Added 2 new Symbian source files and HAL linkage - - * runtime/Collector.cpp: Reduced port-specific code and added private data member - (JSC::Heap::Heap): - (JSC::Heap::~Heap): - (JSC::Heap::destroy): - (JSC::Heap::allocateBlock): - (JSC::Heap::freeBlockPtr): - - * runtime/Collector.h: Added private data member - - * wtf/symbian: Added. - * wtf/symbian/BlockAllocatorSymbian.cpp: Added. - (WTF::AlignedBlockAllocator::AlignedBlockAllocator): Helper class to allocate - aligned blocks more efficiently as required by Collector - (WTF::AlignedBlockAllocator::alloc): - (WTF::AlignedBlockAllocator::free): - (WTF::AlignedBlockAllocator::destroy): - (WTF::AlignedBlockAllocator::~AlignedBlockAllocator): - * wtf/symbian/BlockAllocatorSymbian.h: Added. - 2010-03-22 Geoffrey Garen Reviewed by Sam Weinig. diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri b/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri index b061321..d75bd31 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri +++ b/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri @@ -16,7 +16,6 @@ CONFIG(debug, debug|release) { symbian: { # Need to guarantee this comes before system includes of /epoc32/include MMP_RULES += "USERINCLUDE ../JavaScriptCore/profiler" - LIBS += -lhal } INCLUDEPATH = \ @@ -34,7 +33,6 @@ INCLUDEPATH = \ $$PWD/runtime \ $$PWD/wrec \ $$PWD/wtf \ - $$PWD/wtf/symbian \ $$PWD/wtf/unicode \ $$PWD/yarr \ $$PWD/API \ @@ -213,7 +211,6 @@ SOURCES += \ wtf/qt/ThreadingQt.cpp \ wtf/RandomNumber.cpp \ wtf/RefCountedLeakCounter.cpp \ - wtf/symbian/BlockAllocatorSymbian.cpp \ wtf/symbian/RegisterFileAllocatorSymbian.cpp \ wtf/ThreadingNone.cpp \ wtf/Threading.cpp \ diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp index 42e2a35..24873c8 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp +++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp @@ -53,6 +53,11 @@ #include #include +#elif OS(SYMBIAN) +#include +#include +#include + #elif OS(WINDOWS) #include @@ -104,6 +109,11 @@ const size_t ALLOCATIONS_PER_COLLECTION = 3600; // a PIC branch in Mach-O binaries, see . #define MIN_ARRAY_SIZE (static_cast(14)) +#if OS(SYMBIAN) +const size_t MAX_NUM_BLOCKS = 256; // Max size of collector heap set to 16 MB +static RHeap* userChunk = 0; +#endif + #if ENABLE(JSC_MULTIPLE_THREADS) #if OS(DARWIN) @@ -136,11 +146,29 @@ Heap::Heap(JSGlobalData* globalData) , m_currentThreadRegistrar(0) #endif , m_globalData(globalData) -#if OS(SYMBIAN) - , m_blockallocator(JSCCOLLECTOR_VIRTUALMEM_RESERVATION, BLOCK_SIZE) -#endif { ASSERT(globalData); + +#if OS(SYMBIAN) + // Symbian OpenC supports mmap but currently not the MAP_ANON flag. + // Using fastMalloc() does not properly align blocks on 64k boundaries + // and previous implementation was flawed/incomplete. + // UserHeap::ChunkHeap allows allocation of continuous memory and specification + // of alignment value for (symbian) cells within that heap. + // + // Clarification and mapping of terminology: + // RHeap (created by UserHeap::ChunkHeap below) is continuos memory chunk, + // which can dynamically grow up to 8 MB, + // that holds all CollectorBlocks of this session (static). + // Each symbian cell within RHeap maps to a 64kb aligned CollectorBlock. + // JSCell objects are maintained as usual within CollectorBlocks. + if (!userChunk) { + userChunk = UserHeap::ChunkHeap(0, 0, MAX_NUM_BLOCKS * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE); + if (!userChunk) + CRASH(); + } +#endif // OS(SYMBIAN) + memset(&m_heap, 0, sizeof(CollectorHeap)); allocateBlock(); } @@ -183,9 +211,7 @@ void Heap::destroy() t = next; } #endif -#if OS(SYMBIAN) - m_blockallocator.destroy(); -#endif + m_globalData = 0; } @@ -195,9 +221,11 @@ NEVER_INLINE CollectorBlock* Heap::allocateBlock() vm_address_t address = 0; vm_map(current_task(), &address, BLOCK_SIZE, BLOCK_OFFSET_MASK, VM_FLAGS_ANYWHERE | VM_TAG_FOR_COLLECTOR_MEMORY, MEMORY_OBJECT_NULL, 0, FALSE, VM_PROT_DEFAULT, VM_PROT_DEFAULT, VM_INHERIT_DEFAULT); #elif OS(SYMBIAN) - void* address = m_blockallocator.alloc(); - if (!address) + // Allocate a 64 kb aligned CollectorBlock + unsigned char* mask = reinterpret_cast(userChunk->Alloc(BLOCK_SIZE)); + if (!mask) CRASH(); + uintptr_t address = reinterpret_cast(mask); #elif OS(WINCE) void* address = VirtualAlloc(NULL, BLOCK_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); #elif OS(WINDOWS) @@ -288,7 +316,7 @@ NEVER_INLINE void Heap::freeBlockPtr(CollectorBlock* block) #if OS(DARWIN) vm_deallocate(current_task(), reinterpret_cast(block), BLOCK_SIZE); #elif OS(SYMBIAN) - m_blockallocator.free(reinterpret_cast(block)); + userChunk->Free(reinterpret_cast(block)); #elif OS(WINCE) VirtualFree(block, 0, MEM_RELEASE); #elif OS(WINDOWS) diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h index d3616dc..7f7a679 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h +++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h @@ -35,10 +35,6 @@ #include #endif -#if OS(SYMBIAN) -#include -#endif - #define ASSERT_CLASS_FITS_IN_CELL(class) COMPILE_ASSERT(sizeof(class) <= CELL_SIZE, class_fits_in_cell) namespace JSC { @@ -171,11 +167,6 @@ namespace JSC { pthread_key_t m_currentThreadRegistrar; #endif -#if OS(SYMBIAN) - // Allocates collector blocks with correct alignment - WTF::AlignedBlockAllocator m_blockallocator; -#endif - JSGlobalData* m_globalData; }; diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/CollectorHeapIterator.h b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/CollectorHeapIterator.h index e4f2f91..4a38df9 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/CollectorHeapIterator.h +++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/CollectorHeapIterator.h @@ -97,14 +97,12 @@ namespace JSC { inline LiveObjectIterator& LiveObjectIterator::operator++() { - if (m_block < m_heap.nextBlock || m_cell < m_heap.nextCell) { - advance(HeapConstants::cellsPerBlock); + advance(HeapConstants::cellsPerBlock - 1); + if (m_block < m_heap.nextBlock || (m_block == m_heap.nextBlock && m_cell < m_heap.nextCell)) return *this; - } - do { - advance(HeapConstants::cellsPerBlock); - } while (m_block < m_heap.usedBlocks && !m_heap.blocks[m_block]->marked.get(m_cell)); + while (m_block < m_heap.usedBlocks && !m_heap.blocks[m_block]->marked.get(m_cell)) + advance(HeapConstants::cellsPerBlock - 1); return *this; } diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp deleted file mode 100644 index 6a28e9e..0000000 --- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * 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 - * 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. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 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. - */ - -#include "config.h" - -#if OS(SYMBIAN) - -#include "BlockAllocatorSymbian.h" - - -namespace WTF { - -/** Efficiently allocates blocks of size blockSize with blockSize alignment. - * Primarly designed for JSC Collector's needs. - * Not thread-safe. - */ -AlignedBlockAllocator::AlignedBlockAllocator(TUint32 reservationSize, TUint32 blockSize ) - : m_reservation(reservationSize), - m_blockSize(blockSize) -{ - - // Get system's page size value. - SYMBIAN_PAGESIZE(m_pageSize); - - // We only accept multiples of system page size for both initial reservation and the alignment/block size - m_reservation = SYMBIAN_ROUNDUPTOMULTIPLE(m_reservation, m_pageSize); - __ASSERT_ALWAYS(SYMBIAN_ROUNDUPTOMULTIPLE(m_blockSize, m_pageSize), User::Panic(_L("AlignedBlockAllocator1"), KErrArgument)); - - // Calculate max. bit flags we need to carve a reservationSize range into blockSize-sized blocks - m_map.numBits = m_reservation / m_blockSize; - const TUint32 bitsPerWord = 8*sizeof(TUint32); - const TUint32 numWords = (m_map.numBits + bitsPerWord -1) / bitsPerWord; - - m_map.bits = new TUint32[numWords]; - __ASSERT_ALWAYS(m_map.bits, User::Panic(_L("AlignedBlockAllocator2"), KErrNoMemory)); - m_map.clearAll(); - - // Open a Symbian RChunk, and reserve requested virtual address range - // Any thread in this process can operate this rchunk due to EOwnerProcess access rights. - TInt ret = m_chunk.CreateDisconnectedLocal(0 , 0, (TInt)m_reservation , EOwnerProcess); - if (ret != KErrNone) - User::Panic(_L("AlignedBlockAllocator3"), ret); - - // This is the offset to m_chunk.Base() required to make it m_blockSize-aligned - m_offset = SYMBIAN_ROUNDUPTOMULTIPLE(TUint32(m_chunk.Base()), m_blockSize) - TUint(m_chunk.Base()); - -} - -void* AlignedBlockAllocator::alloc() -{ - - TInt freeRam = 0; - void* address = 0; - - // Look up first free slot in bit map - const TInt freeIdx = m_map.findFree(); - - // Pseudo OOM: We ate up the address space we reserved.. - // ..even though the device may have free RAM left - if (freeIdx < 0) - return 0; - - TInt ret = m_chunk.Commit(m_offset + (m_blockSize * freeIdx), m_blockSize); - if (ret != KErrNone) - return 0; // True OOM: Device didn't have physical RAM to spare - - // Updated bit to mark region as in use. - m_map.set(freeIdx); - - // Calculate address of committed region (block) - address = (void*)( (m_chunk.Base() + m_offset) + (TUint)(m_blockSize * freeIdx) ); - - return address; -} - -void AlignedBlockAllocator::free(void* block) -{ - // Calculate index of block to be freed - TInt idx = TUint(static_cast(block) - m_chunk.Base() - m_offset) / m_blockSize; - - __ASSERT_DEBUG(idx >= 0 && idx < m_map.numBits, User::Panic(_L("AlignedBlockAllocator4"), KErrCorrupt)); // valid index check - __ASSERT_DEBUG(m_map.get(idx), User::Panic(_L("AlignedBlockAllocator5"), KErrCorrupt)); // in-use flag check - - // Return committed region to system RAM pool (the physical RAM becomes usable by others) - TInt ret = m_chunk.Decommit(m_offset + m_blockSize * idx, m_blockSize); - - // mark this available again - m_map.clear(idx); -} - -void AlignedBlockAllocator::destroy() -{ - // release everything! - m_chunk.Decommit(0, m_chunk.MaxSize()); - m_map.clearAll(); -} - -AlignedBlockAllocator::~AlignedBlockAllocator() -{ - destroy(); - m_chunk.Close(); - delete [] m_map.bits; -} - -} // end of namespace - -#endif // SYMBIAN diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h deleted file mode 100644 index 21422f6..0000000 --- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * 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 - * 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. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 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 BlockAllocatorSymbian_h -#define BlockAllocatorSymbian_h - -#include -#include -#include - - -#define SYMBIAN_PAGESIZE(x) (HAL::Get(HALData::EMemoryPageSize, x)); -#define SYMBIAN_FREERAM(x) (HAL::Get(HALData::EMemoryRAMFree, x)); -#define SYMBIAN_ROUNDUPTOMULTIPLE(x, multipleof) ( (x + multipleof - 1) & ~(multipleof - 1) ) - -// Set sane defaults if -D wasn't provided via compiler args -#ifndef JSCCOLLECTOR_VIRTUALMEM_RESERVATION -#if defined(__WINS__) - // Emulator has limited virtual address space - #define JSCCOLLECTOR_VIRTUALMEM_RESERVATION (4*1024*1024) -#else - // HW has plenty of virtual addresses - #define JSCCOLLECTOR_VIRTUALMEM_RESERVATION (128*1024*1024) -#endif -#endif - -namespace WTF { - -/** - * Allocates contiguous region of size blockSize with blockSize-aligned address. - * blockSize must be a multiple of system page size (typically 4K on Symbian/ARM) - * - * @param reservationSize Virtual address range to be reserved upon creation of chunk (bytes). - * @param blockSize Size of a single allocation. Returned address will also be blockSize-aligned. - */ -class AlignedBlockAllocator { - public: - AlignedBlockAllocator(TUint32 reservationSize, TUint32 blockSize); - ~AlignedBlockAllocator(); - void destroy(); - void* alloc(); - void free(void* data); - - private: - RChunk m_chunk; // Symbian chunk that lets us reserve/commit/decommit - TUint m_offset; // offset of first committed region from base - TInt m_pageSize; // cached value of system page size, typically 4K on Symbian - TUint32 m_reservation; - TUint32 m_blockSize; - - // Tracks comitted/decommitted state of a blockSize region - struct { - - TUint32 *bits; // array of bit flags - TUint32 numBits; // number of regions to keep track of - - bool get(TUint32 n) const - { - return !!(bits[n >> 5] & (1 << (n & 0x1F))); - } - - void set(TUint32 n) - { - bits[n >> 5] |= (1 << (n & 0x1F)); - } - - void clear(TUint32 n) - { - bits[n >> 5] &= ~(1 << (n & 0x1F)); - } - - void clearAll() - { - for (TUint32 i = 0; i < numBits; i++) - clear(i); - } - - TInt findFree() const - { - for (TUint32 i = 0; i < numBits; i++) { - if (!get(i)) - return i; - } - return -1; - } - - } m_map; - -}; - -} - -#endif // end of BlockAllocatorSymbian_h - - diff --git a/src/3rdparty/javascriptcore/VERSION b/src/3rdparty/javascriptcore/VERSION index b4744b7..9991ac0 100644 --- a/src/3rdparty/javascriptcore/VERSION +++ b/src/3rdparty/javascriptcore/VERSION @@ -4,8 +4,8 @@ This is a snapshot of JavaScriptCore from The commit imported was from the - javascriptcore-snapshot-24012011 branch/tag + javascriptcore-snapshot-05102010 branch/tag and has the sha1 checksum - d143bde5ae8cff229aebd43487a2fce5e713e990 + 82ead85cfea5859044eeb25b33314dcc0fa5eea1 diff --git a/src/script/script.pro b/src/script/script.pro index 63917b1..d1633d8 100644 --- a/src/script/script.pro +++ b/src/script/script.pro @@ -81,6 +81,7 @@ include(script.pri) symbian { TARGET.UID3=0x2001B2E1 + LIBS += -lhal } symbian { -- cgit v0.12 From 86a864f906d7dcda1b1ab04d1e25e7020a53be64 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 25 Jan 2011 17:06:16 +0100 Subject: QtScript/JSC on Symbian: Enhanced memory allocator for Collector heap Cherry-picked from http://trac.webkit.org/changeset/56370 The old allocator caused QML to crash in MCL (TB10.1, week 1). Task-number: QTBUG-14293 Reviewed-by: Simon Hausmann --- .../javascriptcore/JavaScriptCore/ChangeLog | 28 +++++ .../JavaScriptCore/JavaScriptCore.pri | 3 + .../JavaScriptCore/runtime/Collector.cpp | 46 ++----- .../JavaScriptCore/runtime/Collector.h | 9 ++ .../wtf/symbian/BlockAllocatorSymbian.cpp | 132 +++++++++++++++++++++ .../wtf/symbian/BlockAllocatorSymbian.h | 120 +++++++++++++++++++ src/3rdparty/javascriptcore/VERSION | 4 +- src/script/script.pro | 1 - 8 files changed, 303 insertions(+), 40 deletions(-) create mode 100644 src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp create mode 100644 src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog b/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog index fd6c3f7..c2b1155 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog +++ b/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog @@ -232,6 +232,34 @@ without using doubles, but the code would be much more complicated, and there is no important reason to stick to integers here. +2010-03-22 Siddharth Mathur + + Reviewed by Laszlo Gombos. + + [Symbian] More efficient aligned memory allocation for JSC Collector + https://bugs.webkit.org/show_bug.cgi?id=34350 + + * JavaScriptCore.pri: Added 2 new Symbian source files and HAL linkage + + * runtime/Collector.cpp: Reduced port-specific code and added private data member + (JSC::Heap::Heap): + (JSC::Heap::~Heap): + (JSC::Heap::destroy): + (JSC::Heap::allocateBlock): + (JSC::Heap::freeBlockPtr): + + * runtime/Collector.h: Added private data member + + * wtf/symbian: Added. + * wtf/symbian/BlockAllocatorSymbian.cpp: Added. + (WTF::AlignedBlockAllocator::AlignedBlockAllocator): Helper class to allocate + aligned blocks more efficiently as required by Collector + (WTF::AlignedBlockAllocator::alloc): + (WTF::AlignedBlockAllocator::free): + (WTF::AlignedBlockAllocator::destroy): + (WTF::AlignedBlockAllocator::~AlignedBlockAllocator): + * wtf/symbian/BlockAllocatorSymbian.h: Added. + 2010-03-22 Geoffrey Garen Reviewed by Sam Weinig. diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri b/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri index d75bd31..b061321 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri +++ b/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri @@ -16,6 +16,7 @@ CONFIG(debug, debug|release) { symbian: { # Need to guarantee this comes before system includes of /epoc32/include MMP_RULES += "USERINCLUDE ../JavaScriptCore/profiler" + LIBS += -lhal } INCLUDEPATH = \ @@ -33,6 +34,7 @@ INCLUDEPATH = \ $$PWD/runtime \ $$PWD/wrec \ $$PWD/wtf \ + $$PWD/wtf/symbian \ $$PWD/wtf/unicode \ $$PWD/yarr \ $$PWD/API \ @@ -211,6 +213,7 @@ SOURCES += \ wtf/qt/ThreadingQt.cpp \ wtf/RandomNumber.cpp \ wtf/RefCountedLeakCounter.cpp \ + wtf/symbian/BlockAllocatorSymbian.cpp \ wtf/symbian/RegisterFileAllocatorSymbian.cpp \ wtf/ThreadingNone.cpp \ wtf/Threading.cpp \ diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp index 24873c8..42e2a35 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp +++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp @@ -53,11 +53,6 @@ #include #include -#elif OS(SYMBIAN) -#include -#include -#include - #elif OS(WINDOWS) #include @@ -109,11 +104,6 @@ const size_t ALLOCATIONS_PER_COLLECTION = 3600; // a PIC branch in Mach-O binaries, see . #define MIN_ARRAY_SIZE (static_cast(14)) -#if OS(SYMBIAN) -const size_t MAX_NUM_BLOCKS = 256; // Max size of collector heap set to 16 MB -static RHeap* userChunk = 0; -#endif - #if ENABLE(JSC_MULTIPLE_THREADS) #if OS(DARWIN) @@ -146,29 +136,11 @@ Heap::Heap(JSGlobalData* globalData) , m_currentThreadRegistrar(0) #endif , m_globalData(globalData) +#if OS(SYMBIAN) + , m_blockallocator(JSCCOLLECTOR_VIRTUALMEM_RESERVATION, BLOCK_SIZE) +#endif { ASSERT(globalData); - -#if OS(SYMBIAN) - // Symbian OpenC supports mmap but currently not the MAP_ANON flag. - // Using fastMalloc() does not properly align blocks on 64k boundaries - // and previous implementation was flawed/incomplete. - // UserHeap::ChunkHeap allows allocation of continuous memory and specification - // of alignment value for (symbian) cells within that heap. - // - // Clarification and mapping of terminology: - // RHeap (created by UserHeap::ChunkHeap below) is continuos memory chunk, - // which can dynamically grow up to 8 MB, - // that holds all CollectorBlocks of this session (static). - // Each symbian cell within RHeap maps to a 64kb aligned CollectorBlock. - // JSCell objects are maintained as usual within CollectorBlocks. - if (!userChunk) { - userChunk = UserHeap::ChunkHeap(0, 0, MAX_NUM_BLOCKS * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE); - if (!userChunk) - CRASH(); - } -#endif // OS(SYMBIAN) - memset(&m_heap, 0, sizeof(CollectorHeap)); allocateBlock(); } @@ -211,7 +183,9 @@ void Heap::destroy() t = next; } #endif - +#if OS(SYMBIAN) + m_blockallocator.destroy(); +#endif m_globalData = 0; } @@ -221,11 +195,9 @@ NEVER_INLINE CollectorBlock* Heap::allocateBlock() vm_address_t address = 0; vm_map(current_task(), &address, BLOCK_SIZE, BLOCK_OFFSET_MASK, VM_FLAGS_ANYWHERE | VM_TAG_FOR_COLLECTOR_MEMORY, MEMORY_OBJECT_NULL, 0, FALSE, VM_PROT_DEFAULT, VM_PROT_DEFAULT, VM_INHERIT_DEFAULT); #elif OS(SYMBIAN) - // Allocate a 64 kb aligned CollectorBlock - unsigned char* mask = reinterpret_cast(userChunk->Alloc(BLOCK_SIZE)); - if (!mask) + void* address = m_blockallocator.alloc(); + if (!address) CRASH(); - uintptr_t address = reinterpret_cast(mask); #elif OS(WINCE) void* address = VirtualAlloc(NULL, BLOCK_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); #elif OS(WINDOWS) @@ -316,7 +288,7 @@ NEVER_INLINE void Heap::freeBlockPtr(CollectorBlock* block) #if OS(DARWIN) vm_deallocate(current_task(), reinterpret_cast(block), BLOCK_SIZE); #elif OS(SYMBIAN) - userChunk->Free(reinterpret_cast(block)); + m_blockallocator.free(reinterpret_cast(block)); #elif OS(WINCE) VirtualFree(block, 0, MEM_RELEASE); #elif OS(WINDOWS) diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h index 7f7a679..d3616dc 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h +++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h @@ -35,6 +35,10 @@ #include #endif +#if OS(SYMBIAN) +#include +#endif + #define ASSERT_CLASS_FITS_IN_CELL(class) COMPILE_ASSERT(sizeof(class) <= CELL_SIZE, class_fits_in_cell) namespace JSC { @@ -167,6 +171,11 @@ namespace JSC { pthread_key_t m_currentThreadRegistrar; #endif +#if OS(SYMBIAN) + // Allocates collector blocks with correct alignment + WTF::AlignedBlockAllocator m_blockallocator; +#endif + JSGlobalData* m_globalData; }; diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp new file mode 100644 index 0000000..6a28e9e --- /dev/null +++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp @@ -0,0 +1,132 @@ +/* + * 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 + * 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. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * 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. + */ + +#include "config.h" + +#if OS(SYMBIAN) + +#include "BlockAllocatorSymbian.h" + + +namespace WTF { + +/** Efficiently allocates blocks of size blockSize with blockSize alignment. + * Primarly designed for JSC Collector's needs. + * Not thread-safe. + */ +AlignedBlockAllocator::AlignedBlockAllocator(TUint32 reservationSize, TUint32 blockSize ) + : m_reservation(reservationSize), + m_blockSize(blockSize) +{ + + // Get system's page size value. + SYMBIAN_PAGESIZE(m_pageSize); + + // We only accept multiples of system page size for both initial reservation and the alignment/block size + m_reservation = SYMBIAN_ROUNDUPTOMULTIPLE(m_reservation, m_pageSize); + __ASSERT_ALWAYS(SYMBIAN_ROUNDUPTOMULTIPLE(m_blockSize, m_pageSize), User::Panic(_L("AlignedBlockAllocator1"), KErrArgument)); + + // Calculate max. bit flags we need to carve a reservationSize range into blockSize-sized blocks + m_map.numBits = m_reservation / m_blockSize; + const TUint32 bitsPerWord = 8*sizeof(TUint32); + const TUint32 numWords = (m_map.numBits + bitsPerWord -1) / bitsPerWord; + + m_map.bits = new TUint32[numWords]; + __ASSERT_ALWAYS(m_map.bits, User::Panic(_L("AlignedBlockAllocator2"), KErrNoMemory)); + m_map.clearAll(); + + // Open a Symbian RChunk, and reserve requested virtual address range + // Any thread in this process can operate this rchunk due to EOwnerProcess access rights. + TInt ret = m_chunk.CreateDisconnectedLocal(0 , 0, (TInt)m_reservation , EOwnerProcess); + if (ret != KErrNone) + User::Panic(_L("AlignedBlockAllocator3"), ret); + + // This is the offset to m_chunk.Base() required to make it m_blockSize-aligned + m_offset = SYMBIAN_ROUNDUPTOMULTIPLE(TUint32(m_chunk.Base()), m_blockSize) - TUint(m_chunk.Base()); + +} + +void* AlignedBlockAllocator::alloc() +{ + + TInt freeRam = 0; + void* address = 0; + + // Look up first free slot in bit map + const TInt freeIdx = m_map.findFree(); + + // Pseudo OOM: We ate up the address space we reserved.. + // ..even though the device may have free RAM left + if (freeIdx < 0) + return 0; + + TInt ret = m_chunk.Commit(m_offset + (m_blockSize * freeIdx), m_blockSize); + if (ret != KErrNone) + return 0; // True OOM: Device didn't have physical RAM to spare + + // Updated bit to mark region as in use. + m_map.set(freeIdx); + + // Calculate address of committed region (block) + address = (void*)( (m_chunk.Base() + m_offset) + (TUint)(m_blockSize * freeIdx) ); + + return address; +} + +void AlignedBlockAllocator::free(void* block) +{ + // Calculate index of block to be freed + TInt idx = TUint(static_cast(block) - m_chunk.Base() - m_offset) / m_blockSize; + + __ASSERT_DEBUG(idx >= 0 && idx < m_map.numBits, User::Panic(_L("AlignedBlockAllocator4"), KErrCorrupt)); // valid index check + __ASSERT_DEBUG(m_map.get(idx), User::Panic(_L("AlignedBlockAllocator5"), KErrCorrupt)); // in-use flag check + + // Return committed region to system RAM pool (the physical RAM becomes usable by others) + TInt ret = m_chunk.Decommit(m_offset + m_blockSize * idx, m_blockSize); + + // mark this available again + m_map.clear(idx); +} + +void AlignedBlockAllocator::destroy() +{ + // release everything! + m_chunk.Decommit(0, m_chunk.MaxSize()); + m_map.clearAll(); +} + +AlignedBlockAllocator::~AlignedBlockAllocator() +{ + destroy(); + m_chunk.Close(); + delete [] m_map.bits; +} + +} // end of namespace + +#endif // SYMBIAN diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h new file mode 100644 index 0000000..21422f6 --- /dev/null +++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h @@ -0,0 +1,120 @@ +/* + * 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 + * 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. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * 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 BlockAllocatorSymbian_h +#define BlockAllocatorSymbian_h + +#include +#include +#include + + +#define SYMBIAN_PAGESIZE(x) (HAL::Get(HALData::EMemoryPageSize, x)); +#define SYMBIAN_FREERAM(x) (HAL::Get(HALData::EMemoryRAMFree, x)); +#define SYMBIAN_ROUNDUPTOMULTIPLE(x, multipleof) ( (x + multipleof - 1) & ~(multipleof - 1) ) + +// Set sane defaults if -D wasn't provided via compiler args +#ifndef JSCCOLLECTOR_VIRTUALMEM_RESERVATION +#if defined(__WINS__) + // Emulator has limited virtual address space + #define JSCCOLLECTOR_VIRTUALMEM_RESERVATION (4*1024*1024) +#else + // HW has plenty of virtual addresses + #define JSCCOLLECTOR_VIRTUALMEM_RESERVATION (128*1024*1024) +#endif +#endif + +namespace WTF { + +/** + * Allocates contiguous region of size blockSize with blockSize-aligned address. + * blockSize must be a multiple of system page size (typically 4K on Symbian/ARM) + * + * @param reservationSize Virtual address range to be reserved upon creation of chunk (bytes). + * @param blockSize Size of a single allocation. Returned address will also be blockSize-aligned. + */ +class AlignedBlockAllocator { + public: + AlignedBlockAllocator(TUint32 reservationSize, TUint32 blockSize); + ~AlignedBlockAllocator(); + void destroy(); + void* alloc(); + void free(void* data); + + private: + RChunk m_chunk; // Symbian chunk that lets us reserve/commit/decommit + TUint m_offset; // offset of first committed region from base + TInt m_pageSize; // cached value of system page size, typically 4K on Symbian + TUint32 m_reservation; + TUint32 m_blockSize; + + // Tracks comitted/decommitted state of a blockSize region + struct { + + TUint32 *bits; // array of bit flags + TUint32 numBits; // number of regions to keep track of + + bool get(TUint32 n) const + { + return !!(bits[n >> 5] & (1 << (n & 0x1F))); + } + + void set(TUint32 n) + { + bits[n >> 5] |= (1 << (n & 0x1F)); + } + + void clear(TUint32 n) + { + bits[n >> 5] &= ~(1 << (n & 0x1F)); + } + + void clearAll() + { + for (TUint32 i = 0; i < numBits; i++) + clear(i); + } + + TInt findFree() const + { + for (TUint32 i = 0; i < numBits; i++) { + if (!get(i)) + return i; + } + return -1; + } + + } m_map; + +}; + +} + +#endif // end of BlockAllocatorSymbian_h + + diff --git a/src/3rdparty/javascriptcore/VERSION b/src/3rdparty/javascriptcore/VERSION index 9991ac0..b4744b7 100644 --- a/src/3rdparty/javascriptcore/VERSION +++ b/src/3rdparty/javascriptcore/VERSION @@ -4,8 +4,8 @@ This is a snapshot of JavaScriptCore from The commit imported was from the - javascriptcore-snapshot-05102010 branch/tag + javascriptcore-snapshot-24012011 branch/tag and has the sha1 checksum - 82ead85cfea5859044eeb25b33314dcc0fa5eea1 + d143bde5ae8cff229aebd43487a2fce5e713e990 diff --git a/src/script/script.pro b/src/script/script.pro index d1633d8..63917b1 100644 --- a/src/script/script.pro +++ b/src/script/script.pro @@ -81,7 +81,6 @@ include(script.pri) symbian { TARGET.UID3=0x2001B2E1 - LIBS += -lhal } symbian { -- cgit v0.12 From 54313b3ba81c276cf06c40c2420b1ff1f30e64c3 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Wed, 26 Jan 2011 09:05:19 +0200 Subject: Application background is incorrect if app locked to landscape. If application orientation has been locked to landscape and application is started out while device orientation is portrait, QS60Style draws the QPalette::background like device would be in landscape. Style is incorrectly following device orientation, when it should follow application orientation. As a fix, style follows now application orientation. As a bonus, unnecessary fullscreen QPixmap creation is avoided when rotating the device. Task-number: QTBUG-16816 Reviewed-by: Jani Hautakangas --- src/gui/styles/qs60style_s60.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 04c40aa..605872e 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -1378,12 +1378,13 @@ QPixmap QS60StylePrivate::frame(SkinFrameElements frame, const QSize &size, Skin QPixmap QS60StylePrivate::backgroundTexture() { bool createNewBackground = false; + TRect applicationRect = (static_cast(S60->appUi())->ApplicationRect()); if (!m_background) { createNewBackground = true; } else { //if background brush does not match screensize, re-create it - if (m_background->width() != S60->screenWidthInPixels || - m_background->height() != S60->screenHeightInPixels) { + if (m_background->width() != applicationRect.Width() || + m_background->height() != applicationRect.Height()) { delete m_background; createNewBackground = true; } @@ -1391,7 +1392,7 @@ QPixmap QS60StylePrivate::backgroundTexture() if (createNewBackground) { QPixmap background = part(QS60StyleEnums::SP_QsnBgScreen, - QSize(S60->screenWidthInPixels, S60->screenHeightInPixels), 0, SkinElementFlags()); + QSize(applicationRect.Width(), applicationRect.Height()), 0, SkinElementFlags()); m_background = new QPixmap(background); } return *m_background; @@ -1411,7 +1412,6 @@ QS60Style::QS60Style() void QS60StylePrivate::handleDynamicLayoutVariantSwitch() { clearCaches(QS60StylePrivate::CC_LayoutChange); - setBackgroundTexture(qApp); setActiveLayout(); refreshUI(); foreach (QWidget *widget, QApplication::allWidgets()) -- cgit v0.12 From 977ed996677e6156df1a89011d2aefb1c475af4c Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 25 Jan 2011 18:24:58 +0100 Subject: Add util/xkbdatagen/README Reviewed-by: Joao --- src/gui/kernel/qkeymapper_x11_p.cpp | 1 + util/xkbdatagen/README | 1 + util/xkbdatagen/main.cpp | 1 + 3 files changed, 3 insertions(+) create mode 100644 util/xkbdatagen/README diff --git a/src/gui/kernel/qkeymapper_x11_p.cpp b/src/gui/kernel/qkeymapper_x11_p.cpp index 1fad4b0..2dbe1e7 100644 --- a/src/gui/kernel/qkeymapper_x11_p.cpp +++ b/src/gui/kernel/qkeymapper_x11_p.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ // This file is auto-generated, do not edit! +// (Generated using util/xkbdatagen) static struct { const char *layout; diff --git a/util/xkbdatagen/README b/util/xkbdatagen/README new file mode 100644 index 0000000..bae68b8 --- /dev/null +++ b/util/xkbdatagen/README @@ -0,0 +1 @@ +program used to generate qkeymapper_x11_p.cpp diff --git a/util/xkbdatagen/main.cpp b/util/xkbdatagen/main.cpp index 3ec2f57..b8ececc 100644 --- a/util/xkbdatagen/main.cpp +++ b/util/xkbdatagen/main.cpp @@ -456,6 +456,7 @@ int main(int argc, char **argv) "****************************************************************************/\n" "\n" "// This file is auto-generated, do not edit!\n" + "// (Generated using util/xkbdatagen)\n" "\n"); // data structure -- cgit v0.12