Ghidra is a software reverse engineering (SRE) framework
GP-4712 refactoring, adding back in cache with no locking
emteere19cf2fba3c4c
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/plugin/processors/sleigh/ContextCache.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/plugin/processors/sleigh/ContextCache.javaindex 5b1e562b72..639898eccb 100644--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/plugin/processors/sleigh/ContextCache.java+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/plugin/processors/sleigh/ContextCache.java@@ -15,16 +15,19 @@*/package ghidra.app.plugin.processors.sleigh;-import ghidra.program.model.address.Address;-import ghidra.program.model.lang.*;-import java.math.BigInteger;import java.util.Arrays;+import generic.stl.Pair;+import ghidra.program.model.address.Address;+import ghidra.program.model.lang.*;+public class ContextCache {private int context_size = 0;private Register contextBaseRegister = null;+ Pair <BigInteger, int []> lastValue = null;+public ContextCache() {}@@ -55,7 +58,13 @@ public class ContextCache {private int[] getWords(BigInteger value) {+ Pair <BigInteger, int []> lastValueTmp = lastValue;+ if (lastValueTmp != null && value.equals(lastValueTmp.first)) {+ return lastValueTmp.second;+ }+int[] words = new int[context_size];+byte[] bytes = value.toByteArray();int byteIndexDiff = context_size * 4 - bytes.length;for (int i = 0; i < context_size; i++) {@@ -66,6 +75,10 @@ public class ContextCache {}words[i] = word;}++ lastValueTmp = new Pair<BigInteger, int[]>(value, words);+ lastValue = lastValueTmp;+return words;}diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/plugin/processors/sleigh/SleighLanguage.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/plugin/processors/sleigh/SleighLanguage.javaindex 0e810c2b1f..1688ba427b 100644--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/plugin/processors/sleigh/SleighLanguage.java+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/plugin/processors/sleigh/SleighLanguage.java@@ -378,13 +378,12 @@ public class SleighLanguage implements Language {if (!instructProtoMap.containsKey(hashcode)) {newProto.cacheInfo(buf, context, true);}-- res = instructProtoMap.get(hashcode);- if (res == null) { // We have a prototype we have never seen- // before, build it fully- instructProtoMap.put(hashcode, newProto);+ res = instructProtoMap.putIfAbsent(hashcode, newProto);+ // if there was no previous value, assume newProto inserted+ if (res == null) {res = newProto;}+if (inDelaySlot && res.hasDelaySlots()) {throw new NestedDelaySlotException();}diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighFunction.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighFunction.javaindex 1f0068159d..ce492b49ad 100644--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighFunction.java+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighFunction.java@@ -51,7 +51,6 @@ public class HighFunction extends PcodeSyntaxTree {private List<JumpTable> jumpTables;private List<DataTypeSymbol> protoOverrides;private Address entryPoint;- private AddressSpace entryAddrSpace;/*** @param function function associated with the higher level function abstraction.@@ -67,7 +66,6 @@ public class HighFunction extends PcodeSyntaxTree {this.compilerSpec = compilerSpec;AddressSpace stackSpace = function.getProgram().getAddressFactory().getStackSpace();entryPoint = function.getEntryPoint();- entryAddrSpace = entryPoint.getAddressSpace();localSymbols = new LocalSymbolMap(this, stackSpace);globalSymbols = new GlobalSymbolMap(this);proto = new FunctionPrototype(localSymbols, function);@@ -304,7 +302,7 @@ public class HighFunction extends PcodeSyntaxTree {private void decodeJumpTableList(Decoder decoder) throws DecoderException {int el = decoder.openElement(ELEM_JUMPTABLELIST);while (decoder.peekElement() != 0) {- JumpTable table = new JumpTable(entryAddrSpace);+ JumpTable table = new JumpTable(entryPoint.getAddressSpace());table.decode(decoder);if (!table.isEmpty()) {if (jumpTables == null) {