Ignore:
Timestamp:
Mar 22, 2010, 5:28:28 PM (15 years ago)
Author:
[email protected]
Message:

2010-03-22 Siddharth Mathur <[email protected]>

Reviewed by Laszlo Gombos.

[Symbian] More efficient aligned memory allocation for JSC Collector
https://bugs.webkit.org/show_bug.cgi?id=34350

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

Legend:

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

    r55453 r56370  
    5454#include <mach/vm_map.h>
    5555
    56 #elif OS(SYMBIAN)
    57 #include <e32std.h>
    58 #include <e32cmn.h>
    59 #include <unistd.h>
    60 
    6156#elif OS(WINDOWS)
    6257
     
    109104// a PIC branch in Mach-O binaries, see <rdar://problem/5971391>.
    110105#define MIN_ARRAY_SIZE (static_cast<size_t>(14))
    111 
    112 #if OS(SYMBIAN)
    113 const size_t MAX_NUM_BLOCKS = 256; // Max size of collector heap set to 16 MB
    114 static RHeap* userChunk = 0;
    115 #endif
    116106
    117107#if ENABLE(JSC_MULTIPLE_THREADS)
     
    147137#endif
    148138    , m_globalData(globalData)
     139#if OS(SYMBIAN)
     140    , m_blockallocator(JSCCOLLECTOR_VIRTUALMEM_RESERVATION, BLOCK_SIZE)
     141#endif
    149142{
    150143    ASSERT(globalData);
    151    
    152 #if OS(SYMBIAN)
    153     // Symbian OpenC supports mmap but currently not the MAP_ANON flag.
    154     // Using fastMalloc() does not properly align blocks on 64k boundaries
    155     // and previous implementation was flawed/incomplete.
    156     // UserHeap::ChunkHeap allows allocation of continuous memory and specification
    157     // of alignment value for (symbian) cells within that heap.
    158     //
    159     // Clarification and mapping of terminology:
    160     // RHeap (created by UserHeap::ChunkHeap below) is continuos memory chunk,
    161     // which can dynamically grow up to 8 MB,
    162     // that holds all CollectorBlocks of this session (static).
    163     // Each symbian cell within RHeap maps to a 64kb aligned CollectorBlock.
    164     // JSCell objects are maintained as usual within CollectorBlocks.
    165     if (!userChunk) {
    166         userChunk = UserHeap::ChunkHeap(0, 0, MAX_NUM_BLOCKS * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE);
    167         if (!userChunk)
    168             CRASH();
    169     }
    170 #endif // OS(SYMBIAN)
    171    
    172144    memset(&m_heap, 0, sizeof(CollectorHeap));
    173145    allocateBlock();
     
    212184    }
    213185#endif
    214 
     186#if OS(SYMBIAN)
     187    m_blockallocator.destroy();
     188#endif
    215189    m_globalData = 0;
    216190}
     
    222196    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);
    223197#elif OS(SYMBIAN)
    224     // Allocate a 64 kb aligned CollectorBlock
    225     unsigned char* mask = reinterpret_cast<unsigned char*>(userChunk->Alloc(BLOCK_SIZE));
    226     if (!mask)
     198    void* address = m_blockallocator.alloc(); 
     199    if (!address)
    227200        CRASH();
    228     uintptr_t address = reinterpret_cast<uintptr_t>(mask);
    229201#elif OS(WINCE)
    230202    void* address = VirtualAlloc(NULL, BLOCK_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
     
    317289    vm_deallocate(current_task(), reinterpret_cast<vm_address_t>(block), BLOCK_SIZE);
    318290#elif OS(SYMBIAN)
    319     userChunk->Free(reinterpret_cast<TAny*>(block));
     291    m_blockallocator.free(reinterpret_cast<void*>(block));
    320292#elif OS(WINCE)
    321293    VirtualFree(block, 0, MEM_RELEASE);
Note: See TracChangeset for help on using the changeset viewer.