void JitCompareScreen::UpdateDisasm() { leftDisasm_->Clear(); rightDisasm_->Clear(); using namespace UI; I18NCategory *dev = GetI18NCategory("Developer"); JitBlockCache *blockCache = MIPSComp::jit->GetBlockCache(); char temp[256]; snprintf(temp, sizeof(temp), "%i/%i", currentBlock_, blockCache->GetNumBlocks()); blockName_->SetText(temp); if (currentBlock_ < 0 || currentBlock_ >= blockCache->GetNumBlocks()) { leftDisasm_->Add(new TextView(dev->T("No block"))); rightDisasm_->Add(new TextView(dev->T("No block"))); blockStats_->SetText(""); return; } JitBlock *block = blockCache->GetBlock(currentBlock_); snprintf(temp, sizeof(temp), "%08x", block->originalAddress); blockAddr_->SetText(temp); // Alright. First generate the MIPS disassembly. // TODO: Need a way to communicate branch continuing. for (u32 addr = block->originalAddress; addr <= block->originalAddress + block->originalSize * 4; addr += 4) { char temp[256]; MIPSDisAsm(Memory::Read_Instruction(addr), addr, temp, true); std::string mipsDis = temp; leftDisasm_->Add(new TextView(mipsDis))->SetFocusable(true); } #if defined(ARM) std::vector<std::string> targetDis = DisassembleArm2(block->normalEntry, block->codeSize); #elif defined(ARM64) std::vector<std::string> targetDis = DisassembleArm64(block->normalEntry, block->codeSize); #elif defined(_M_IX86) || defined(_M_X64) std::vector<std::string> targetDis = DisassembleX86(block->normalEntry, block->codeSize); #endif #if defined(ARM) || defined(ARM64) || defined(_M_IX86) || defined(_M_X64) for (size_t i = 0; i < targetDis.size(); i++) { rightDisasm_->Add(new TextView(targetDis[i]))->SetFocusable(true); } #endif int numMips = leftDisasm_->GetNumSubviews(); int numHost = rightDisasm_->GetNumSubviews(); snprintf(temp, sizeof(temp), "%d to %d : %d%%", numMips, numHost, 100 * numHost / numMips); blockStats_->SetText(temp); }
void JitCompareScreen::OnRandomBlock(int flag) { if (!MIPSComp::jit) { return; } JitBlockCache *blockCache = MIPSComp::jit->GetBlockCache(); int numBlocks = blockCache->GetNumBlocks(); if (numBlocks > 0) { bool anyWanted = false; int tries = 0; while (!anyWanted && tries < 10000) { currentBlock_ = rand() % numBlocks; const JitBlock *b = blockCache->GetBlock(currentBlock_); for (u32 addr = b->originalAddress; addr <= b->originalAddress + b->originalSize; addr += 4) { MIPSOpcode opcode = Memory::Read_Instruction(addr); if (MIPSGetInfo(opcode) & flag) { char temp[256]; MIPSDisAsm(opcode, addr, temp); // INFO_LOG(HLE, "Stopping VFPU instruction: %s", temp); anyWanted = true; break; } } tries++; } } UpdateDisasm(); }
UI::EventReturn JitCompareScreen::OnRandomBlock(UI::EventParams &e) { if (!MIPSComp::jit) { return UI::EVENT_DONE; } JitBlockCache *blockCache = MIPSComp::jit->GetBlockCache(); int numBlocks = blockCache->GetNumBlocks(); if (numBlocks > 0) { currentBlock_ = rand() % numBlocks; } UpdateDisasm(); return UI::EVENT_DONE; }