Skip to content

Commit

Permalink
perf: avoid multiple calls to read same self.PC (#1527)
Browse files Browse the repository at this point in the history
* perf: avoid multiple calls to read same self.PC

* refresh PC value once
  • Loading branch information
catenacyber authored and disconnect3d committed Sep 29, 2019
1 parent 65795c0 commit 5bde1b5
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions manticore/native/cpu/abstractcpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,19 +950,21 @@ def execute(self):
"""
Decode, and execute one instruction pointed by register PC
"""
if issymbolic(self.PC):
curpc = self.PC
if issymbolic(curpc):
raise ConcretizeRegister(self, "PC", policy="ALL")
if not self.memory.access_ok(self.PC, "x"):
raise InvalidMemoryAccess(self.PC, "x")
if not self.memory.access_ok(curpc, "x"):
raise InvalidMemoryAccess(curpc, "x")

self._publish("will_decode_instruction", self.PC)
self._publish("will_decode_instruction", curpc)

insn = self.decode_instruction(self.PC)
insn = self.decode_instruction(curpc)
self._last_pc = self.PC

self._publish("will_execute_instruction", self.PC, insn)
self._publish("will_execute_instruction", self._last_pc, insn)

# FIXME (theo) why just return here?
# hook changed PC, so we trust that there is nothing more to do
if insn.address != self.PC:
return

Expand Down

0 comments on commit 5bde1b5

Please sign in to comment.