diff --git a/src/cpu/core_dyn_x86.cpp b/src/cpu/core_dyn_x86.cpp index 50d78e8d..27aef301 100644 --- a/src/cpu/core_dyn_x86.cpp +++ b/src/cpu/core_dyn_x86.cpp @@ -27,6 +27,11 @@ #include #include +#if defined (_MSC_VER) +#include +#include +#endif + #if (C_HAVE_MPROTECT) #include @@ -45,7 +50,7 @@ #include "inout.h" #include "fpu.h" -#define CACHE_MAXSIZE (4096*2) +#define CACHE_MAXSIZE (4096*3) #define CACHE_TOTAL (1024*1024*8) #define CACHE_PAGES (512) #define CACHE_BLOCKS (64*1024) diff --git a/src/cpu/core_dyn_x86/cache.h b/src/cpu/core_dyn_x86/cache.h index a5f10b7b..8f51e880 100644 --- a/src/cpu/core_dyn_x86/cache.h +++ b/src/cpu/core_dyn_x86/cache.h @@ -457,8 +457,15 @@ static void cache_init(bool enable) { } } if (cache_code_start_ptr==NULL) { +#if defined (_MSC_VER) + cache_code_start_ptr=(Bit8u*)VirtualAlloc(0,CACHE_TOTAL+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP, + MEM_COMMIT,PAGE_EXECUTE_READWRITE); + if (!cache_code_start_ptr) + cache_code_start_ptr=(Bit8u*)malloc(CACHE_TOTAL+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP); +#else cache_code_start_ptr=(Bit8u*)malloc(CACHE_TOTAL+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP); - if(!cache_code_start_ptr) E_Exit("Allocating dynamic cache failed"); +#endif + if(!cache_code_start_ptr) E_Exit("Allocating dynamic core cache memory failed"); cache_code=(Bit8u*)(((int)cache_code_start_ptr + PAGESIZE_TEMP-1) & ~(PAGESIZE_TEMP-1)); //MEM LEAK. store old pointer if you want to free it. @@ -510,6 +517,8 @@ static void cache_close(void) { cache_blocks = NULL; } if (cache_code_start_ptr != NULL) { + ### care: under windows VirtualFree() has to be used if + ### VirtualAlloc was used for memory allocation free(cache_code_start_ptr); cache_code_start_ptr = NULL; } diff --git a/src/cpu/core_dynrec.cpp b/src/cpu/core_dynrec.cpp index e73b8b2b..0cc2cbf6 100644 --- a/src/cpu/core_dynrec.cpp +++ b/src/cpu/core_dynrec.cpp @@ -27,6 +27,11 @@ #include #include +#if defined (_MSC_VER) +#include +#include +#endif + #if (C_HAVE_MPROTECT) #include diff --git a/src/cpu/core_dynrec/cache.h b/src/cpu/core_dynrec/cache.h index f0517150..6fdc537b 100644 --- a/src/cpu/core_dynrec/cache.h +++ b/src/cpu/core_dynrec/cache.h @@ -562,7 +562,14 @@ static void cache_init(bool enable) { } if (cache_code_start_ptr==NULL) { // allocate the code cache memory +#if defined (_MSC_VER) + cache_code_start_ptr=(Bit8u*)VirtualAlloc(0,CACHE_TOTAL+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP, + MEM_COMMIT,PAGE_EXECUTE_READWRITE); + if (!cache_code_start_ptr) + cache_code_start_ptr=(Bit8u*)malloc(CACHE_TOTAL+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP); +#else cache_code_start_ptr=(Bit8u*)malloc(CACHE_TOTAL+CACHE_MAXSIZE+PAGESIZE_TEMP-1+PAGESIZE_TEMP); +#endif if(!cache_code_start_ptr) E_Exit("Allocating dynamic cache failed"); // align the cache at a page boundary @@ -624,6 +631,8 @@ static void cache_close(void) { cache_blocks = NULL; } if (cache_code_start_ptr != NULL) { + ### care: under windows VirtualFree() has to be used if + ### VirtualAlloc was used for memory allocation free(cache_code_start_ptr); cache_code_start_ptr = NULL; }