Debugger: Exp evaluator - removed cache for expressions that contain labels (too complex to cache) and fixed a few bugs with work/save/internal ram
This commit is contained in:
parent
24d1ae096f
commit
75899fe8d3
4 changed files with 15 additions and 21 deletions
|
@ -6,7 +6,6 @@
|
|||
#include "LabelManager.h"
|
||||
|
||||
std::unordered_map<string, std::vector<int>, StringHasher> ExpressionEvaluator::_outputCache;
|
||||
std::unordered_map<string, std::vector<int>, StringHasher> ExpressionEvaluator::_customOutputCache;
|
||||
SimpleLock ExpressionEvaluator::_cacheLock;
|
||||
|
||||
bool ExpressionEvaluator::IsOperator(string token, int &precedence, bool unaryOperator)
|
||||
|
@ -333,11 +332,6 @@ int32_t ExpressionEvaluator::PrivateEvaluate(string expression, DebugState &stat
|
|||
auto cacheOutputQueue = _outputCache.find(expression);
|
||||
if(cacheOutputQueue != _outputCache.end()) {
|
||||
outputQueue = &(cacheOutputQueue->second);
|
||||
} else {
|
||||
auto customCacheResult = _customOutputCache.find(expression);
|
||||
if(customCacheResult != _customOutputCache.end()) {
|
||||
output = _customOutputCache[expression];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -346,11 +340,10 @@ int32_t ExpressionEvaluator::PrivateEvaluate(string expression, DebugState &stat
|
|||
fixedExp.erase(std::remove(fixedExp.begin(), fixedExp.end(), ' '), fixedExp.end());
|
||||
ToRpn(fixedExp, output);
|
||||
|
||||
LockHandler lock = _cacheLock.AcquireSafe();
|
||||
if(_containsCustomLabels) {
|
||||
_customOutputCache[expression] = output;
|
||||
outputQueue = &output;
|
||||
} else {
|
||||
LockHandler lock = _cacheLock.AcquireSafe();
|
||||
_outputCache[expression] = output;
|
||||
outputQueue = &_outputCache[expression];
|
||||
}
|
||||
|
@ -389,10 +382,4 @@ bool ExpressionEvaluator::Validate(string expression)
|
|||
} catch(std::exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void ExpressionEvaluator::ResetCustomCache()
|
||||
{
|
||||
LockHandler lock = _cacheLock.AcquireSafe();
|
||||
_customOutputCache.clear();
|
||||
}
|
|
@ -86,7 +86,6 @@ private:
|
|||
const vector<int> _unaryPrecedence = { { 11, 11, 11, 11 } };
|
||||
|
||||
static std::unordered_map<string, std::vector<int>, StringHasher> _outputCache;
|
||||
static std::unordered_map<string, std::vector<int>, StringHasher> _customOutputCache;
|
||||
static SimpleLock _cacheLock;
|
||||
|
||||
Debugger* _debugger;
|
||||
|
@ -107,6 +106,4 @@ public:
|
|||
int32_t Evaluate(string expression, DebugState &state, int16_t memoryValue = 0, uint32_t memoryAddr = 0);
|
||||
int32_t Evaluate(string expression, DebugState &state, EvalResultType &resultType, int16_t memoryValue = 0, uint32_t memoryAddr = 0);
|
||||
bool Validate(string expression);
|
||||
|
||||
static void ResetCustomCache();
|
||||
};
|
|
@ -9,8 +9,6 @@ LabelManager::LabelManager(shared_ptr<BaseMapper> mapper)
|
|||
|
||||
void LabelManager::SetLabel(uint32_t address, AddressType addressType, string label, string comment)
|
||||
{
|
||||
ExpressionEvaluator::ResetCustomCache();
|
||||
|
||||
switch(addressType) {
|
||||
case AddressType::InternalRam: address |= 0x40000000; break;
|
||||
case AddressType::PrgRom: address |= 0x20000000; break;
|
||||
|
@ -94,7 +92,20 @@ int32_t LabelManager::GetLabelRelativeAddress(string label)
|
|||
{
|
||||
auto result = _codeLabelReverseLookup.find(label);
|
||||
if(result != _codeLabelReverseLookup.end()) {
|
||||
return _mapper->FromAbsoluteAddress(result->second);
|
||||
uint32_t address = result->second;
|
||||
AddressType type = AddressType::InternalRam;
|
||||
if(address & 0x40000000) {
|
||||
type = AddressType::InternalRam;
|
||||
} else if(address & 0x20000000) {
|
||||
type = AddressType::PrgRom;
|
||||
} else if(address & 0x10000000) {
|
||||
type = AddressType::WorkRam;
|
||||
} else if(address & 0x08000000) {
|
||||
type = AddressType::SaveRam;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
return _mapper->FromAbsoluteAddress(address & 0x07FFFFFF, type);
|
||||
}
|
||||
return -1;
|
||||
}
|
|
@ -4,7 +4,6 @@
|
|||
using std::unordered_map;
|
||||
|
||||
class BaseMapper;
|
||||
class ExpressionEvaluator;
|
||||
enum class AddressType;
|
||||
|
||||
class LabelManager
|
||||
|
|
Loading…
Add table
Reference in a new issue