Stopping dyncom translation where there is a binary translation available.

This commit is contained in:
Dani Messerman 2015-05-05 22:41:52 +03:00
parent 70463da199
commit f8ca04f93f
3 changed files with 27 additions and 8 deletions

View File

@ -35,7 +35,8 @@ enum {
CALL = (1 << 4), CALL = (1 << 4),
RET = (1 << 5), RET = (1 << 5),
END_OF_PAGE = (1 << 6), END_OF_PAGE = (1 << 6),
THUMB = (1 << 7) THUMB = (1 << 7),
BINARY_TRANSLATED = (1 << 8)
}; };
#define RM BITS(sht_oper, 0, 3) #define RM BITS(sht_oper, 0, 3)
@ -3653,6 +3654,10 @@ static int InterpreterTranslate(ARMul_State* cpu, int& bb_start, u32 addr) {
translated: translated:
phys_addr += inst_size; phys_addr += inst_size;
if (BinaryTranslationLoader::CanRun(phys_addr, cpu->TFlag))
{
inst_base->br = BINARY_TRANSLATED;
}
if ((phys_addr & 0xfff) == 0) { if ((phys_addr & 0xfff) == 0) {
inst_base->br = END_OF_PAGE; inst_base->br = END_OF_PAGE;
} }

View File

@ -130,6 +130,8 @@ void BinaryTranslationLoader::Load(FileUtil::IOFile& file)
g_verify = *verify_ptr; g_verify = *verify_ptr;
g_enabled = true; g_enabled = true;
LOG_INFO(Loader, "Binary translation enabled");
} }
void BinaryTranslationLoader::SetCpuState(ARMul_State* state) void BinaryTranslationLoader::SetCpuState(ARMul_State* state)
@ -155,6 +157,16 @@ bool BinaryTranslationLoader::CanRun(bool specific_address)
return true; return true;
} }
bool BinaryTranslationLoader::CanRun(u32 pc, bool tflag)
{
if (!g_enabled) return false;
if (tflag) return false;
std::swap(g_state->Reg[15], pc);
auto result = g_can_run_function();
std::swap(g_state->Reg[15], pc);
return result;
}
uint32_t BinaryTranslationLoader::Run(uint32_t instruction_count) uint32_t BinaryTranslationLoader::Run(uint32_t instruction_count)
{ {
// No need to check the PC, Run does it anyway // No need to check the PC, Run does it anyway

View File

@ -12,6 +12,8 @@ public:
// Checks whether the cpu state can be run // Checks whether the cpu state can be run
// If specific_address, checks the specific PC too // If specific_address, checks the specific PC too
static bool CanRun(bool specific_address); static bool CanRun(bool specific_address);
// Checks whether the cpu state can run the specific address at the specific mode
static bool CanRun(u32 pc, bool tflag);
// Runs the state provided at SetCpuState. // Runs the state provided at SetCpuState.
// Returns instruction_count + number of instructions executed // Returns instruction_count + number of instructions executed
static uint32_t Run(uint32_t instruction_count); static uint32_t Run(uint32_t instruction_count);