diff --git a/Common/ArmEmitter.cpp b/Common/ArmEmitter.cpp index 17ef8e711f..2fcdafad51 100644 --- a/Common/ArmEmitter.cpp +++ b/Common/ArmEmitter.cpp @@ -22,6 +22,10 @@ #include #include +#ifdef __SYMBIAN32__ +#include +#endif + namespace ArmGen { @@ -61,7 +65,11 @@ const u8 *ARMXEmitter::AlignCodePage() void ARMXEmitter::Flush() { +#ifdef __SYMBIAN32__ + User::IMB_Range( startcode, code ); +#else __builtin___clear_cache (startcode, code); +#endif SLEEP(0); } void ARMXEmitter::SetCC(CCFlags cond) diff --git a/Common/MemoryUtil.cpp b/Common/MemoryUtil.cpp index 0fd1093316..d3be724610 100644 --- a/Common/MemoryUtil.cpp +++ b/Common/MemoryUtil.cpp @@ -45,6 +45,12 @@ #define round_page(x) ((((unsigned long)(x)) + PAGE_MASK) & ~(PAGE_MASK)) #endif +#ifdef __SYMBIAN32__ +#include +#define SYMBIAN_CODECHUNCK_SIZE 1024*1024*17; +static RChunk* g_code_chunk = NULL; +static RHeap* g_code_heap = NULL; +#endif // This is purposely not a full wrapper for virtualalloc/mmap, but it // provides exactly the primitive operations that Dolphin needs. @@ -54,9 +60,16 @@ void* AllocateExecutableMemory(size_t size, bool low) #if defined(_WIN32) void* ptr = VirtualAlloc(0, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); #elif defined(__SYMBIAN32__) - // On Symbian, we will need to create an RChunk and allocate with ->CreateLocalCode(size, size); - static char *map_hint = 0; - void* ptr = mmap(map_hint, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, -1, 0); + //This function may be called more than once, and we want to create only one big + //memory chunck for all the executable code for the JIT + if( g_code_chunk == NULL && g_code_heap == NULL) + { + TInt minsize = SYMBIAN_CODECHUNCK_SIZE; + TInt maxsize = SYMBIAN_CODECHUNCK_SIZE + 3*4096; //some offsets + g_code_chunk->CreateLocalCode(minsize, maxsize); + g_code_heap = UserHeap::ChunkHeap(*g_code_chunk, minsize, 1, maxsize); + } + void* ptr = (void*) g_code_heap->Alloc( size ); #else static char *map_hint = 0; #if defined(__x86_64__) && !defined(MAP_32BIT)