Changeset 46266 in webkit for trunk/JavaScriptCore/runtime


Ignore:
Timestamp:
Jul 23, 2009, 7:28:47 AM (16 years ago)
Author:
Simon Hausmann
Message:

2009-07-23 Norbert Leser <[email protected]>

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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/Collector.cpp

    r44993 r46266  
    4949#include <mach/vm_map.h>
    5050
     51#elif PLATFORM(SYMBIAN)
     52#include <e32std.h>
     53#include <e32cmn.h>
     54#include <unistd.h>
     55
    5156#elif PLATFORM(WIN_OS)
    5257
     
    8792// a PIC branch in Mach-O binaries, see <rdar://problem/5971391>.
    8893#define MIN_ARRAY_SIZE (static_cast<size_t>(14))
     94
     95#if PLATFORM(SYMBIAN)
     96const size_t MAX_NUM_BLOCKS = 256; // Max size of collector heap set to 16 MB
     97static RHeap* userChunk = 0;
     98#endif
    8999
    90100static void freeHeap(CollectorHeap*);
     
    129139    ASSERT(globalData);
    130140
     141#if PLATFORM(SYMBIAN)
     142    // Symbian OpenC supports mmap but currently not the MAP_ANON flag.
     143    // Using fastMalloc() does not properly align blocks on 64k boundaries
     144    // and previous implementation was flawed/incomplete.
     145    // UserHeap::ChunkHeap allows allocation of continuous memory and specification
     146    // of alignment value for (symbian) cells within that heap.
     147    //
     148    // Clarification and mapping of terminology:
     149    // RHeap (created by UserHeap::ChunkHeap below) is continuos memory chunk,
     150    // which can dynamically grow up to 8 MB,
     151    // that holds all CollectorBlocks of this session (static).
     152    // Each symbian cell within RHeap maps to a 64kb aligned CollectorBlock.
     153    // JSCell objects are maintained as usual within CollectorBlocks.
     154    if (!userChunk) {
     155        userChunk = UserHeap::ChunkHeap(0, 0, MAX_NUM_BLOCKS * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE);
     156        if (!userChunk)
     157            CRASH();
     158    }
     159#endif // PLATFORM(SYMBIAN)
     160   
    131161    memset(&primaryHeap, 0, sizeof(CollectorHeap));
    132162    memset(&numberHeap, 0, sizeof(CollectorHeap));
     
    186216    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);
    187217#elif PLATFORM(SYMBIAN)
    188     // no memory map in symbian, need to hack with fastMalloc
    189     void* address = fastMalloc(BLOCK_SIZE);
     218    // Allocate a 64 kb aligned CollectorBlock
     219    unsigned char* mask = reinterpret_cast<unsigned char*>(userChunk->Alloc(BLOCK_SIZE));
     220    if (!mask)
     221        CRASH();
     222    uintptr_t address = reinterpret_cast<uintptr_t>(mask);
     223
    190224    memset(reinterpret_cast<void*>(address), 0, BLOCK_SIZE);
    191225#elif PLATFORM(WIN_OS)
     
    232266    vm_deallocate(current_task(), reinterpret_cast<vm_address_t>(block), BLOCK_SIZE);
    233267#elif PLATFORM(SYMBIAN)
    234     fastFree(block);
     268    userChunk->Free(reinterpret_cast<TAny*>(block));
    235269#elif PLATFORM(WIN_OS)
    236270    VirtualFree(block, 0, MEM_RELEASE);
Note: See TracChangeset for help on using the changeset viewer.