Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
2009-07-23 Norbert Leser <norbert.leser@nokia.com>
        Reviewed by Simon Hausmann.

        Fix for missing mmap features in Symbian
        https://bugs.webkit.org/show_bug.cgi?id=24540

        Fix, conditionally for PLATFORM(SYMBIAN), as an alternative
        to missing support for the MAP_ANON property flag in mmap.
        It utilizes Symbian specific memory allocation features.

        * runtime/Collector.cpp

Canonical link: https://commits.webkit.org/37879@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@46266 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
tronical committed Jul 23, 2009
1 parent 8c2b471 commit d90d1df
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
13 changes: 13 additions & 0 deletions JavaScriptCore/ChangeLog
@@ -1,3 +1,16 @@
2009-07-23 Norbert Leser <norbert.leser@nokia.com>

Reviewed by Simon Hausmann.

Fix for missing mmap features in Symbian
https://bugs.webkit.org/show_bug.cgi?id=24540

Fix, conditionally for PLATFORM(SYMBIAN), as an alternative
to missing support for the MAP_ANON property flag in mmap.
It utilizes Symbian specific memory allocation features.

* runtime/Collector.cpp

2009-07-22 Gavin Barraclough <barraclough@apple.com>

Reviewed by Sam Weinig.
Expand Down
40 changes: 37 additions & 3 deletions JavaScriptCore/runtime/Collector.cpp
Expand Up @@ -48,6 +48,11 @@
#include <mach/thread_act.h>
#include <mach/vm_map.h>

#elif PLATFORM(SYMBIAN)
#include <e32std.h>
#include <e32cmn.h>
#include <unistd.h>

#elif PLATFORM(WIN_OS)

#include <windows.h>
Expand Down Expand Up @@ -87,6 +92,11 @@ const size_t ALLOCATIONS_PER_COLLECTION = 4000;
// a PIC branch in Mach-O binaries, see <rdar://problem/5971391>.
#define MIN_ARRAY_SIZE (static_cast<size_t>(14))

#if PLATFORM(SYMBIAN)
const size_t MAX_NUM_BLOCKS = 256; // Max size of collector heap set to 16 MB
static RHeap* userChunk = 0;
#endif

static void freeHeap(CollectorHeap*);

#if ENABLE(JSC_MULTIPLE_THREADS)
Expand Down Expand Up @@ -128,6 +138,26 @@ Heap::Heap(JSGlobalData* globalData)
{
ASSERT(globalData);

#if PLATFORM(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 // PLATFORM(SYMBIAN)

memset(&primaryHeap, 0, sizeof(CollectorHeap));
memset(&numberHeap, 0, sizeof(CollectorHeap));
}
Expand Down Expand Up @@ -185,8 +215,12 @@ static NEVER_INLINE CollectorBlock* allocateBlock()
// FIXME: tag the region as a JavaScriptCore heap when we get a registered VM tag: <rdar://problem/6054788>.
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 PLATFORM(SYMBIAN)
// no memory map in symbian, need to hack with fastMalloc
void* address = fastMalloc(BLOCK_SIZE);
// Allocate a 64 kb aligned CollectorBlock
unsigned char* mask = reinterpret_cast<unsigned char*>(userChunk->Alloc(BLOCK_SIZE));
if (!mask)
CRASH();
uintptr_t address = reinterpret_cast<uintptr_t>(mask);

memset(reinterpret_cast<void*>(address), 0, BLOCK_SIZE);
#elif PLATFORM(WIN_OS)
// windows virtual address granularity is naturally 64k
Expand Down Expand Up @@ -231,7 +265,7 @@ static void freeBlock(CollectorBlock* block)
#if PLATFORM(DARWIN)
vm_deallocate(current_task(), reinterpret_cast<vm_address_t>(block), BLOCK_SIZE);
#elif PLATFORM(SYMBIAN)
fastFree(block);
userChunk->Free(reinterpret_cast<TAny*>(block));
#elif PLATFORM(WIN_OS)
VirtualFree(block, 0, MEM_RELEASE);
#elif HAVE(POSIX_MEMALIGN)
Expand Down

0 comments on commit d90d1df

Please sign in to comment.