From 33da416a820fe617b9c15a32faff537d4356d80a Mon Sep 17 00:00:00 2001 From: Kingcom Date: Tue, 26 Nov 2013 22:20:12 +0100 Subject: [PATCH] Reduce disassembler memory usage --- Core/Debugger/DisassemblyManager.cpp | 26 ++++++++++++++++++-------- Core/Debugger/DisassemblyManager.h | 1 + 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Core/Debugger/DisassemblyManager.cpp b/Core/Debugger/DisassemblyManager.cpp index 66586d611..a293db71c 100644 --- a/Core/Debugger/DisassemblyManager.cpp +++ b/Core/Debugger/DisassemblyManager.cpp @@ -416,6 +416,15 @@ void DisassemblyFunction::generateBranchLines() } } +void DisassemblyFunction::addOpcodeSequence(u32 start, u32 end) +{ + DisassemblyOpcode* opcode = new DisassemblyOpcode(start,(end-start)/4); + entries[start] = opcode; + for (u32 pos = start; pos < end; pos += 4) + { + lineAddresses.push_back(pos); + } +} void DisassemblyFunction::load() { @@ -440,6 +449,7 @@ void DisassemblyFunction::load() u32 funcPos = address; u32 funcEnd = address+size; + u32 opcodeSequenceStart = funcPos; while (funcPos < funcEnd) { MIPSAnalyst::MipsOpcodeInfo opInfo = MIPSAnalyst::GetOpcodeInfo(cpu,funcPos); @@ -449,11 +459,6 @@ void DisassemblyFunction::load() // skip branches and their delay slots if (opInfo.isBranch) { - DisassemblyOpcode* opcode = new DisassemblyOpcode(opAddress,2); - entries[opAddress] = opcode; - lineAddresses.push_back(opAddress); - lineAddresses.push_back(opAddress+4); - funcPos += 4; continue; } @@ -517,21 +522,26 @@ void DisassemblyFunction::load() if (macro != NULL) { + if (opcodeSequenceStart != opAddress) + addOpcodeSequence(opcodeSequenceStart,opAddress); + entries[opAddress] = macro; for (int i = 0; i < macro->getNumLines(); i++) { lineAddresses.push_back(macro->getLineAddress(i)); } + + opcodeSequenceStart = funcPos; continue; } } } // just a normal opcode - DisassemblyOpcode* opcode = new DisassemblyOpcode(opAddress,1); - entries[opAddress] = opcode; - lineAddresses.push_back(opAddress); } + + if (opcodeSequenceStart != funcPos) + addOpcodeSequence(opcodeSequenceStart,funcPos); } void DisassemblyFunction::clear() diff --git a/Core/Debugger/DisassemblyManager.h b/Core/Debugger/DisassemblyManager.h index 94b5f97ef..52126ccb1 100644 --- a/Core/Debugger/DisassemblyManager.h +++ b/Core/Debugger/DisassemblyManager.h @@ -74,6 +74,7 @@ private: void generateBranchLines(); void load(); void clear(); + void addOpcodeSequence(u32 start, u32 end); u32 address; u32 size;