diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2022-10-31 12:05:04 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-31 12:05:04 +0100 |
| commit | 8459ea0d31a851e847318273233c9a8b2b079eae (patch) | |
| tree | 2ab39af3c19d9720d906cd060211107c5dc549a2 /src/include | |
| parent | 494c245b591cef1a34cc4d4dc52163861d4e54af (diff) | |
| download | box64-8459ea0d31a851e847318273233c9a8b2b079eae.tar.gz box64-8459ea0d31a851e847318273233c9a8b2b079eae.zip | |
Remove dynablocklist (#438)
* [DYNAREC] Removed dynablock sons handling * [DYNAREC] Removed dynablocklist, and attached dynablocks to the jumptable * [DYNAREC] Changed handling of HotPage (part of Protection now) * [DYNAREC] Fixed some performance issues (especially with heavily threaded programs)
Diffstat (limited to 'src/include')
| -rwxr-xr-x | src/include/box64context.h | 2 | ||||
| -rw-r--r-- | src/include/custommem.h | 11 | ||||
| -rwxr-xr-x | src/include/dynablock.h | 19 | ||||
| -rwxr-xr-x | src/include/elfloader.h | 5 |
4 files changed, 14 insertions, 23 deletions
diff --git a/src/include/box64context.h b/src/include/box64context.h index 9eb130ec..1d7d8b58 100755 --- a/src/include/box64context.h +++ b/src/include/box64context.h @@ -26,7 +26,6 @@ typedef struct atfork_fnc_s { } atfork_fnc_t; #ifdef DYNAREC typedef struct dynablock_s dynablock_t; -typedef struct dynablocklist_s dynablocklist_t; typedef struct mmaplist_s mmaplist_t; typedef struct kh_dynablocks_s kh_dynablocks_t; #endif @@ -125,6 +124,7 @@ typedef struct box64context_s { pthread_mutex_t mutex_lock; // dynarec build will use their own mecanism #else pthread_mutex_t mutex_dyndump; + uintptr_t max_db_size; // the biggest (in x86_64 instructions bytes) built dynablock int trace_dynarec; #endif pthread_mutex_t mutex_tls; diff --git a/src/include/custommem.h b/src/include/custommem.h index c8a28fc5..0a8642f4 100644 --- a/src/include/custommem.h +++ b/src/include/custommem.h @@ -18,7 +18,6 @@ void customFree(void* p); #ifdef DYNAREC typedef struct dynablock_s dynablock_t; -typedef struct dynablocklist_s dynablocklist_t; // custom protection flag to mark Page that are Write protected for Dynarec purpose uintptr_t AllocDynarecMap(dynablock_t* db, size_t size); void FreeDynarecMap(dynablock_t* db, uintptr_t addr, size_t size); @@ -26,12 +25,15 @@ void FreeDynarecMap(dynablock_t* db, uintptr_t addr, size_t size); void addDBFromAddressRange(uintptr_t addr, size_t size); void cleanDBFromAddressRange(uintptr_t addr, size_t size, int destroy); -dynablocklist_t* getDB(uintptr_t idx); -void addJumpTableIfDefault64(void* addr, void* jmp); +dynablock_t* getDB(uintptr_t idx); +int addJumpTableIfDefault64(void* addr, void* jmp); // return 1 if write was succesfull +int setJumpTableIfRef64(void* addr, void* jmp, void* ref); // return 1 if write was succesfull void setJumpTableDefault64(void* addr); +void setJumpTableDefaultRef64(void* addr, void* jmp); int isJumpTableDefault64(void* addr); uintptr_t getJumpTable64(); uintptr_t getJumpTableAddress64(uintptr_t addr); +uintptr_t getJumpAddress64(uintptr_t addr); #endif #define PROT_DYNAREC 0x80 @@ -47,6 +49,9 @@ void loadProtectionFromMap(); void protectDB(uintptr_t addr, size_t size); void unprotectDB(uintptr_t addr, size_t size, int mark); // if mark==0, the blocks are not marked as potentially dirty int isprotectedDB(uintptr_t addr, size_t size); +int IsInHotPage(uintptr_t addr); +int AreaInHotPage(uintptr_t start, uintptr_t end); +void AddHotPage(uintptr_t addr); #endif void* find32bitBlock(size_t size); void* findBlockNearHint(void* hint, size_t size); diff --git a/src/include/dynablock.h b/src/include/dynablock.h index a2119643..7f28fbd7 100755 --- a/src/include/dynablock.h +++ b/src/include/dynablock.h @@ -3,35 +3,22 @@ typedef struct x64emu_s x64emu_t; typedef struct dynablock_s dynablock_t; -typedef struct dynablocklist_s dynablocklist_t; typedef struct kh_dynablocks_s kh_dynablocks_t; uint32_t X31_hash_code(void* addr, int len); -dynablocklist_t* NewDynablockList(uintptr_t text, int textsz, int direct); -void FreeDynablockList(dynablocklist_t** dynablocks); void FreeDynablock(dynablock_t* db, int need_lock); void MarkDynablock(dynablock_t* db); -//return 1 if Dynareblock is empty -int FreeRangeDynablock(dynablocklist_t* dynablocks, uintptr_t addr, uintptr_t size); -void MarkRangeDynablock(dynablocklist_t* dynablocks, uintptr_t addr, uintptr_t size); +void MarkRangeDynablock(dynablock_t* db, uintptr_t addr, uintptr_t size); +int FreeRangeDynablock(dynablock_t* db, uintptr_t addr, uintptr_t size); dynablock_t* FindDynablockFromNativeAddress(void* addr); // defined in box64context.h dynablock_t* FindDynablockDynablocklist(void* addr, kh_dynablocks_t* dynablocks); -uintptr_t StartDynablockList(dynablocklist_t* db); -uintptr_t EndDynablockList(dynablocklist_t* db); -void MarkDirectDynablock(dynablocklist_t* dynablocks, uintptr_t addr, uintptr_t size); - // Handling of Dynarec block (i.e. an exectable chunk of x64 translated code) -dynablock_t* DBGetBlock(x64emu_t* emu, uintptr_t addr, int create, dynablock_t** current); // return NULL if block is not found / cannot be created. Don't create if create==0 +dynablock_t* DBGetBlock(x64emu_t* emu, uintptr_t addr, int create); // return NULL if block is not found / cannot be created. Don't create if create==0 dynablock_t* DBAlternateBlock(x64emu_t* emu, uintptr_t addr, uintptr_t filladdr); -// Create and Add an new dynablock in the list, handling direct/map -dynablock_t *AddNewDynablock(dynablocklist_t* dynablocks, uintptr_t addr, int* created); - // for use in signal handler void cancelFillBlock(); -int IsInHotPage(uintptr_t addr); -void AddHotPage(uintptr_t addr); #endif //__DYNABLOCK_H_ \ No newline at end of file diff --git a/src/include/elfloader.h b/src/include/elfloader.h index a4f59719..579c98bd 100755 --- a/src/include/elfloader.h +++ b/src/include/elfloader.h @@ -10,7 +10,7 @@ typedef struct box64context_s box64context_t; typedef struct x64emu_s x64emu_t; typedef struct needed_libs_s needed_libs_t; #ifdef DYNAREC -typedef struct dynablocklist_s dynablocklist_t; +typedef struct dynablock_s dynablock_t; #endif elfheader_t* LoadAndCheckElfHeader(FILE* f, const char* name, int exec); // exec : 0 = lib, 1 = exec @@ -50,8 +50,7 @@ uint32_t GetTLSSize(elfheader_t* h); void* GetTLSPointer(box64context_t* context, elfheader_t* h); void* GetDTatOffset(box64context_t* context, unsigned long int index, unsigned long int offset); #ifdef DYNAREC -dynablocklist_t* GetDynablocksFromAddress(box64context_t *context, uintptr_t addr); -dynablocklist_t* GetDynablocksFromElf(elfheader_t* h); +dynablock_t* GetDynablocksFromAddress(box64context_t *context, uintptr_t addr); #endif void ResetSpecialCaseMainElf(elfheader_t* h); void CreateMemorymapFile(box64context_t* context, int fd); |