HighFunction: store entryPoint/entryAddrSpace

Unfortunately fetching entrypoint hits the database lock. As this is invariant for the HighFunction, cache these results instead.
This commit is contained in:
sad-dev 2024-06-18 16:39:45 +08:00 committed by GitHub
parent 789cbd9241
commit f5b8236976
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -50,6 +50,8 @@ public class HighFunction extends PcodeSyntaxTree {
private GlobalSymbolMap globalSymbols; private GlobalSymbolMap globalSymbols;
private List<JumpTable> jumpTables; private List<JumpTable> jumpTables;
private List<DataTypeSymbol> protoOverrides; private List<DataTypeSymbol> protoOverrides;
private Address entryPoint;
private AddressSpace entryAddrSpace;
/** /**
* @param function function associated with the higher level function abstraction. * @param function function associated with the higher level function abstraction.
@ -64,6 +66,8 @@ public class HighFunction extends PcodeSyntaxTree {
this.language = language; this.language = language;
this.compilerSpec = compilerSpec; this.compilerSpec = compilerSpec;
AddressSpace stackSpace = function.getProgram().getAddressFactory().getStackSpace(); AddressSpace stackSpace = function.getProgram().getAddressFactory().getStackSpace();
entryPoint = function.getEntryPoint();
entryAddrSpace = entryPoint.getAddressSpace();
localSymbols = new LocalSymbolMap(this, stackSpace); localSymbols = new LocalSymbolMap(this, stackSpace);
globalSymbols = new GlobalSymbolMap(this); globalSymbols = new GlobalSymbolMap(this);
proto = new FunctionPrototype(localSymbols, function); proto = new FunctionPrototype(localSymbols, function);
@ -87,7 +91,7 @@ public class HighFunction extends PcodeSyntaxTree {
if (func instanceof FunctionDB) { if (func instanceof FunctionDB) {
return func.getSymbol().getID(); return func.getSymbol().getID();
} }
return func.getProgram().getSymbolTable().getDynamicSymbolID(func.getEntryPoint()); return func.getProgram().getSymbolTable().getDynamicSymbolID(entryPoint);
} }
/** /**
@ -255,7 +259,7 @@ public class HighFunction extends PcodeSyntaxTree {
} }
if (subel == ELEM_ADDR.id()) { if (subel == ELEM_ADDR.id()) {
Address addr = AddressXML.decode(decoder); Address addr = AddressXML.decode(decoder);
if (!func.getEntryPoint().equals(addr)) { if (!entryPoint.equals(addr)) {
throw new DecoderException("Mismatched address in function tag"); throw new DecoderException("Mismatched address in function tag");
} }
} }
@ -300,7 +304,7 @@ public class HighFunction extends PcodeSyntaxTree {
private void decodeJumpTableList(Decoder decoder) throws DecoderException { private void decodeJumpTableList(Decoder decoder) throws DecoderException {
int el = decoder.openElement(ELEM_JUMPTABLELIST); int el = decoder.openElement(ELEM_JUMPTABLELIST);
while (decoder.peekElement() != 0) { while (decoder.peekElement() != 0) {
JumpTable table = new JumpTable(func.getEntryPoint().getAddressSpace()); JumpTable table = new JumpTable(entryAddrSpace);
table.decode(decoder); table.decode(decoder);
if (!table.isEmpty()) { if (!table.isEmpty()) {
if (jumpTables == null) { if (jumpTables == null) {
@ -318,10 +322,10 @@ public class HighFunction extends PcodeSyntaxTree {
pcaddr = rep.getPCAddress(); pcaddr = rep.getPCAddress();
if (pcaddr == Address.NO_ADDRESS) { if (pcaddr == Address.NO_ADDRESS) {
try { try {
pcaddr = func.getEntryPoint().add(-1); pcaddr = entryPoint.add(-1);
} }
catch (AddressOutOfBoundsException e) { catch (AddressOutOfBoundsException e) {
pcaddr = func.getEntryPoint(); pcaddr = entryPoint;
} }
} }
} }
@ -446,7 +450,7 @@ public class HighFunction extends PcodeSyntaxTree {
encoder.writeBool(ATTRIB_NORETURN, true); encoder.writeBool(ATTRIB_NORETURN, true);
} }
if (entryPoint == null) { if (entryPoint == null) {
AddressXML.encode(encoder, func.getEntryPoint()); AddressXML.encode(encoder, this.entryPoint);
} }
else { else {
AddressXML.encode(encoder, entryPoint); // Address is forced on XML AddressXML.encode(encoder, entryPoint); // Address is forced on XML