Commit e52b0254b5f620599639bf323bcfd21545be4c39
- Diff rendering mode:
- inline
- side by side
JavaScriptCore/ChangeLog
(36 / 0)
|   | |||
| 1 | 2010-06-18 Tucker Jay <jay.tucker@nokia.com> | ||
| 2 | |||
| 3 | Reviewed by NOBODY (OOPS!). | ||
| 4 | |||
| 5 | [Symbian] Lazy commit of memory required in JSC register file | ||
| 6 | https://bugs.webkit.org/show_bug.cgi?id=34349 | ||
| 7 | |||
| 8 | * JavaScriptCore.pro: Added 1 new Symbian source file | ||
| 9 | * interpreter/RegisterFile.cpp: | ||
| 10 | (JSC::RegisterFile::~RegisterFile): | ||
| 11 | * interpreter/RegisterFile.h: | ||
| 12 | (JSC::RegisterFile::): | ||
| 13 | (JSC::RegisterFile::start): | ||
| 14 | (JSC::RegisterFile::end): | ||
| 15 | (JSC::RegisterFile::size): | ||
| 16 | (JSC::RegisterFile::setNumGlobals): | ||
| 17 | (JSC::RegisterFile::numGlobals): | ||
| 18 | (JSC::RegisterFile::maxGlobals): | ||
| 19 | (JSC::RegisterFile::lastGlobal): | ||
| 20 | (JSC::RegisterFile::markGlobals): | ||
| 21 | (JSC::RegisterFile::markCallFrames): | ||
| 22 | (JSC::isPageAligned): | ||
| 23 | (JSC::RegisterFile::RegisterFile): | ||
| 24 | (JSC::RegisterFile::shrink): | ||
| 25 | (JSC::RegisterFile::grow): | ||
| 26 | * wtf/symbian/RegisterFileAllocatorSymbian.cpp: Added. | ||
| 27 | (WTF::RegisterFileAllocator::RegisterFileAllocator): | ||
| 28 | Helper class to allocate memory required by RegisterFile | ||
| 29 | more efficiently. | ||
| 30 | (WTF::RegisterFileAllocator::~RegisterFileAllocator): | ||
| 31 | (WTF::RegisterFileAllocator::buffer): | ||
| 32 | (WTF::RegisterFileAllocator::grow): | ||
| 33 | (WTF::RegisterFileAllocator::shrink): | ||
| 34 | * wtf/symbian/RegisterFileAllocatorSymbian.h: Added. | ||
| 35 | * wtf/symbian/SymbianDefines.h: Added. | ||
| 36 | |||
| 1 | 37 | 2010-06-19 Thiago Macieira <thiago.macieira@nokia.com> | |
| 2 | 38 | ||
| 3 | 39 | Reviewed by Kenneth Rohde Christiansen. |
|   | |||
| 212 | 212 | wtf/qt/ThreadingQt.cpp \ | |
| 213 | 213 | wtf/RandomNumber.cpp \ | |
| 214 | 214 | wtf/RefCountedLeakCounter.cpp \ | |
| 215 | wtf/symbian/RegisterFileAllocatorSymbian.cpp \ | ||
| 215 | 216 | wtf/ThreadingNone.cpp \ | |
| 216 | 217 | wtf/Threading.cpp \ | |
| 217 | 218 | wtf/TypeTraits.cpp \ |
|   | |||
| 40 | 40 | VirtualFree(m_buffer, DWORD(m_commitEnd) - DWORD(m_buffer), MEM_DECOMMIT); | |
| 41 | 41 | #endif | |
| 42 | 42 | VirtualFree(m_buffer, 0, MEM_RELEASE); | |
| 43 | #elif OS(SYMBIAN) | ||
| 44 | delete m_registerFileAllocator; | ||
| 43 | 45 | #else | |
| 44 | 46 | fastFree(m_buffer); | |
| 45 | 47 | #endif |
|   | |||
| 41 | 41 | #include <sys/mman.h> | |
| 42 | 42 | #endif | |
| 43 | 43 | ||
| 44 | #if OS(SYMBIAN) | ||
| 45 | #include <wtf/symbian/RegisterFileAllocatorSymbian.h> | ||
| 46 | #endif | ||
| 47 | |||
| 44 | 48 | namespace JSC { | |
| 45 | 49 | ||
| 46 | 50 | /* | |
| … | … | ||
| 156 | 156 | #if HAVE(VIRTUALALLOC) | |
| 157 | 157 | Register* m_commitEnd; | |
| 158 | 158 | #endif | |
| 159 | #if OS(SYMBIAN) | ||
| 160 | // Commits and frees a continguous chunk of memory as required | ||
| 161 | WTF::RegisterFileAllocator* m_registerFileAllocator; | ||
| 162 | #endif | ||
| 159 | 163 | ||
| 160 | 164 | JSGlobalObject* m_globalObject; // The global object whose vars are currently stored in the register file. | |
| 161 | 165 | }; | |
| 162 | 166 | ||
| 163 | 167 | // FIXME: Add a generic getpagesize() to WTF, then move this function to WTF as well. | |
| 164 | inline bool isPageAligned(size_t size) { return size != 0 && size % (8 * 1024) == 0; } | ||
| 168 | // This is still a hack that should be fixed later. We know that a Symbian page size is 4K. | ||
| 169 | #if OS(SYMBIAN) | ||
| 170 | inline bool isPageAligned(size_t size) { return size && !(size % (4 * 1024)); } | ||
| 171 | #else | ||
| 172 | inline bool isPageAligned(size_t size) { return size && !(size % (8 * 1024)); } | ||
| 173 | #endif | ||
| 165 | 174 | ||
| 166 | 175 | inline RegisterFile::RegisterFile(size_t capacity, size_t maxGlobals) | |
| 167 | 176 | : m_numGlobals(0) | |
| … | … | ||
| 217 | 217 | CRASH(); | |
| 218 | 218 | } | |
| 219 | 219 | m_commitEnd = reinterpret_cast<Register*>(reinterpret_cast<char*>(m_buffer) + committedSize); | |
| 220 | #else | ||
| 220 | #elif OS(SYMBIAN) | ||
| 221 | m_registerFileAllocator = new WTF::RegisterFileAllocator(bufferLength); | ||
| 222 | m_buffer = (Register*)(m_registerFileAllocator->buffer()); | ||
| 223 | // start by committing enough space to hold maxGlobals | ||
| 224 | void* newEnd = (void*)((int)m_buffer + (maxGlobals * sizeof(Register))); | ||
| 225 | m_registerFileAllocator->grow(newEnd); | ||
| 226 | #else | ||
| 221 | 227 | /* | |
| 222 | 228 | * If neither MMAP nor VIRTUALALLOC are available - use fastMalloc instead. | |
| 223 | 229 | * | |
| … | … | ||
| 245 | 245 | if (newEnd >= m_end) | |
| 246 | 246 | return; | |
| 247 | 247 | m_end = newEnd; | |
| 248 | if (m_end == m_start && (m_maxUsed - m_start) > maxExcessCapacity) | ||
| 248 | if (m_end == m_start && (m_maxUsed - m_start) > maxExcessCapacity) { | ||
| 249 | #if OS(SYMBIAN) | ||
| 250 | m_registerFileAllocator->shrink(newEnd); | ||
| 251 | #endif | ||
| 252 | |||
| 249 | 253 | releaseExcessCapacity(); | |
| 254 | } | ||
| 250 | 255 | } | |
| 251 | 256 | ||
| 252 | 257 | inline bool RegisterFile::grow(Register* newEnd) | |
| … | … | ||
| 275 | 275 | } | |
| 276 | 276 | m_commitEnd = reinterpret_cast<Register*>(reinterpret_cast<char*>(m_commitEnd) + size); | |
| 277 | 277 | } | |
| 278 | #endif | ||
| 279 | #if OS(SYMBIAN) | ||
| 280 | m_registerFileAllocator->grow((void*)newEnd); | ||
| 278 | 281 | #endif | |
| 279 | 282 | ||
| 280 | 283 | if (newEnd > m_maxUsed) |
|   | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | ||
| 3 | * | ||
| 4 | * Redistribution and use in source and binary forms, with or without | ||
| 5 | * modification, are permitted provided that the following conditions | ||
| 6 | * are met: | ||
| 7 | * | ||
| 8 | * 1. Redistributions of source code must retain the above copyright | ||
| 9 | * notice, this list of conditions and the following disclaimer. | ||
| 10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 11 | * notice, this list of conditions and the following disclaimer in the | ||
| 12 | * documentation and/or other materials provided with the distribution. | ||
| 13 | * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of | ||
| 14 | * its contributors may be used to endorse or promote products derived | ||
| 15 | * from this software without specific prior written permission. | ||
| 16 | * | ||
| 17 | * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | ||
| 18 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
| 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| 20 | * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | ||
| 21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
| 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
| 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 27 | */ | ||
| 28 | |||
| 29 | #include "config.h" | ||
| 30 | |||
| 31 | #if OS(SYMBIAN) | ||
| 32 | |||
| 33 | #include "RegisterFileAllocatorSymbian.h" | ||
| 34 | |||
| 35 | namespace WTF { | ||
| 36 | |||
| 37 | /** Efficiently allocates memory pools of size poolSize. | ||
| 38 | * Primarily designed for JSC RegisterFile's needs. | ||
| 39 | * Not thread-safe. | ||
| 40 | */ | ||
| 41 | RegisterFileAllocator::RegisterFileAllocator(TUint32 reservationSize, TUint32 poolSize) : | ||
| 42 | m_reserved(reservationSize), m_poolSize(poolSize) | ||
| 43 | { | ||
| 44 | // Get system's page size value. | ||
| 45 | SYMBIAN_PAGESIZE(m_pageSize); | ||
| 46 | |||
| 47 | // We only accept multiples of system page size for both initial reservation | ||
| 48 | // and the alignment/pool size | ||
| 49 | m_reserved = SYMBIAN_ROUNDUPTOMULTIPLE(m_reserved, m_pageSize); | ||
| 50 | __ASSERT_ALWAYS(SYMBIAN_ROUNDUPTOMULTIPLE(m_poolSize, m_pageSize), | ||
| 51 | User::Panic(_L("RegisterFileAllocator1"), KErrArgument)); | ||
| 52 | |||
| 53 | // Open a Symbian RChunk, and reserve requested virtual address range | ||
| 54 | // Any thread in this process can operate this RChunk due to EOwnerProcess access rights. | ||
| 55 | TInt ret = m_chunk.CreateDisconnectedLocal(0 , 0, (TInt)m_reserved , EOwnerProcess); | ||
| 56 | if (ret != KErrNone) | ||
| 57 | User::Panic(_L("RegisterFileAllocator2"), ret); | ||
| 58 | |||
| 59 | m_buffer = (void*)m_chunk.Base(); | ||
| 60 | m_resEnd = (void*)(m_chunk.Base() + m_chunk.MaxSize()); | ||
| 61 | m_comEnd = m_buffer; | ||
| 62 | } | ||
| 63 | |||
| 64 | RegisterFileAllocator::~RegisterFileAllocator() | ||
| 65 | { | ||
| 66 | // release everything! | ||
| 67 | m_chunk.Decommit(0, m_chunk.MaxSize()); | ||
| 68 | m_chunk.Close(); | ||
| 69 | } | ||
| 70 | |||
| 71 | void* RegisterFileAllocator::buffer() const | ||
| 72 | { | ||
| 73 | return m_buffer; | ||
| 74 | } | ||
| 75 | |||
| 76 | void RegisterFileAllocator::grow(void* newEnd) | ||
| 77 | { | ||
| 78 | // trying to commit more memory than reserved! | ||
| 79 | if (newEnd > m_resEnd) | ||
| 80 | return; | ||
| 81 | |||
| 82 | if (newEnd > m_comEnd) { | ||
| 83 | TInt nBytes = (TInt)(newEnd) - (TInt)(m_comEnd); | ||
| 84 | nBytes = SYMBIAN_ROUNDUPTOMULTIPLE(nBytes, m_poolSize); | ||
| 85 | TInt offset = (TInt)m_comEnd - (TInt)m_buffer; | ||
| 86 | |||
| 87 | TInt ret = m_chunk.Commit(offset, nBytes); | ||
| 88 | if (ret == KErrNone) | ||
| 89 | m_comEnd = (void*)(m_chunk.Base() + m_chunk.Size()); | ||
| 90 | } | ||
| 91 | } | ||
| 92 | |||
| 93 | void RegisterFileAllocator::shrink(void* newEnd) | ||
| 94 | { | ||
| 95 | if (newEnd < m_comEnd) { | ||
| 96 | TInt nBytes = (TInt)newEnd - (TInt)m_comEnd; | ||
| 97 | if (nBytes >= m_poolSize) { | ||
| 98 | TInt offset = SYMBIAN_ROUNDUPTOMULTIPLE((TUint)newEnd, m_poolSize) - (TInt)m_buffer; | ||
| 99 | nBytes = (TInt)m_comEnd - offset - (TInt)m_buffer; | ||
| 100 | if (nBytes > 0) { | ||
| 101 | TInt ret = m_chunk.Decommit(offset, nBytes); | ||
| 102 | if (ret == KErrNone) | ||
| 103 | m_comEnd = (void*)(m_chunk.Base() + m_chunk.Size()); | ||
| 104 | } | ||
| 105 | } | ||
| 106 | } | ||
| 107 | } | ||
| 108 | |||
| 109 | } // end of namespace | ||
| 110 | |||
| 111 | #endif // SYMBIAN |
|   | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | ||
| 3 | * | ||
| 4 | * Redistribution and use in source and binary forms, with or without | ||
| 5 | * modification, are permitted provided that the following conditions | ||
| 6 | * are met: | ||
| 7 | * | ||
| 8 | * 1. Redistributions of source code must retain the above copyright | ||
| 9 | * notice, this list of conditions and the following disclaimer. | ||
| 10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 11 | * notice, this list of conditions and the following disclaimer in the | ||
| 12 | * documentation and/or other materials provided with the distribution. | ||
| 13 | * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of | ||
| 14 | * its contributors may be used to endorse or promote products derived | ||
| 15 | * from this software without specific prior written permission. | ||
| 16 | * | ||
| 17 | * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | ||
| 18 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
| 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| 20 | * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | ||
| 21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
| 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
| 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 27 | */ | ||
| 28 | |||
| 29 | #ifndef RegisterFileAllocatorSymbian_h | ||
| 30 | #define RegisterFileAllocatorSymbian_h | ||
| 31 | |||
| 32 | #include "SymbianDefines.h" | ||
| 33 | |||
| 34 | namespace WTF { | ||
| 35 | |||
| 36 | /** | ||
| 37 | * Allocates contiguous regions of size poolSize. | ||
| 38 | * poolSize must be a multiple of system page size (typically 4K on Symbian/ARM) | ||
| 39 | * | ||
| 40 | * @param reservationSize Virtual address range to be reserved upon creation of chunk (bytes). | ||
| 41 | * @param poolSize Size of a single allocation. | ||
| 42 | */ | ||
| 43 | class RegisterFileAllocator { | ||
| 44 | |||
| 45 | public: | ||
| 46 | RegisterFileAllocator( | ||
| 47 | TUint32 reservationSize, TUint32 poolSize = SYMBIAN_REGFILEALLOC_DEFAULTPOOLSIZE); | ||
| 48 | ~RegisterFileAllocator(); | ||
| 49 | void* buffer() const; | ||
| 50 | void grow(void* newEnd); | ||
| 51 | void shrink(void* newEnd); | ||
| 52 | |||
| 53 | private: | ||
| 54 | RChunk m_chunk; // Symbian chunk that lets us reserve/commit/decommit | ||
| 55 | |||
| 56 | // all following values are in numbers of bytes | ||
| 57 | TInt m_pageSize; // cached value of system page size, typically 4K on Symbian | ||
| 58 | TUint32 m_reserved; // total number of reserved bytes in virtual memory | ||
| 59 | TUint32 m_poolSize; // size of one memory pool, set by default to 64K in wtf/symbian/SymbianDefines.h | ||
| 60 | |||
| 61 | void* m_buffer; // pointer to base of the chunk | ||
| 62 | void* m_comEnd; // pointer to end of currently committed memory | ||
| 63 | void* m_resEnd; // pointer to end of reserved memory | ||
| 64 | |||
| 65 | }; | ||
| 66 | |||
| 67 | } // end of namespace | ||
| 68 | |||
| 69 | #endif // RegisterFileAllocatorSymbian_h |
|   | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | ||
| 3 | * | ||
| 4 | * Redistribution and use in source and binary forms, with or without | ||
| 5 | * modification, are permitted provided that the following conditions | ||
| 6 | * are met: | ||
| 7 | * | ||
| 8 | * 1. Redistributions of source code must retain the above copyright | ||
| 9 | * notice, this list of conditions and the following disclaimer. | ||
| 10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 11 | * notice, this list of conditions and the following disclaimer in the | ||
| 12 | * documentation and/or other materials provided with the distribution. | ||
| 13 | * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of | ||
| 14 | * its contributors may be used to endorse or promote products derived | ||
| 15 | * from this software without specific prior written permission. | ||
| 16 | * | ||
| 17 | * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | ||
| 18 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
| 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| 20 | * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | ||
| 21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
| 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
| 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 27 | */ | ||
| 28 | |||
| 29 | #ifndef SymbianDefines_h | ||
| 30 | #define SymbianDefines_h | ||
| 31 | |||
| 32 | #include <e32cmn.h> | ||
| 33 | #include <e32std.h> | ||
| 34 | #include <hal.h> | ||
| 35 | |||
| 36 | #define SYMBIAN_PAGESIZE(x) (HAL::Get(HALData::EMemoryPageSize, x)); | ||
| 37 | #define SYMBIAN_FREERAM(x) (HAL::Get(HALData::EMemoryRAMFree, x)); | ||
| 38 | #define SYMBIAN_ROUNDUPTOMULTIPLE(x, multipleof) ( (x + multipleof - 1) & ~(multipleof - 1) ) | ||
| 39 | |||
| 40 | #define SYMBIAN_REGFILEALLOC_DEFAULTPOOLSIZE 65536 // 64K | ||
| 41 | |||
| 42 | #endif // SymbianDefines_h |

