mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
Use readPushData() in basic block analysis
This commit is contained in:
parent
bfb96606a2
commit
439561a5fa
1 changed files with 5 additions and 16 deletions
|
|
@ -56,29 +56,20 @@ void Compiler::createBasicBlocks(bytesConstRef bytecode)
|
|||
ProgramCounter currentPC = curr - bytecode.begin();
|
||||
validJumpTargets[currentPC] = true;
|
||||
|
||||
auto inst = static_cast<Instruction>(*curr);
|
||||
auto inst = Instruction(*curr);
|
||||
switch (inst)
|
||||
{
|
||||
|
||||
case Instruction::ANY_PUSH:
|
||||
{
|
||||
auto numBytes = static_cast<size_t>(inst) - static_cast<size_t>(Instruction::PUSH1) + 1;
|
||||
auto next = curr + numBytes + 1;
|
||||
if (next >= bytecode.end())
|
||||
auto val = readPushData(curr, bytecode.end());
|
||||
auto next = curr + 1;
|
||||
if (next == bytecode.end())
|
||||
break;
|
||||
|
||||
auto nextInst = static_cast<Instruction>(*next);
|
||||
|
||||
auto nextInst = Instruction(*next);
|
||||
if (nextInst == Instruction::JUMP || nextInst == Instruction::JUMPI)
|
||||
{
|
||||
// Compute target PC of the jump.
|
||||
u256 val = 0;
|
||||
for (auto iter = curr + 1; iter < next; ++iter)
|
||||
{
|
||||
val <<= 8;
|
||||
val |= *iter;
|
||||
}
|
||||
|
||||
// Create a block for the JUMP target.
|
||||
ProgramCounter targetPC = val < bytecode.size() ? val.convert_to<ProgramCounter>() : bytecode.size();
|
||||
splitPoints.insert(targetPC);
|
||||
|
|
@ -86,8 +77,6 @@ void Compiler::createBasicBlocks(bytesConstRef bytecode)
|
|||
ProgramCounter jumpPC = (next - bytecode.begin());
|
||||
directJumpTargets[jumpPC] = targetPC;
|
||||
}
|
||||
|
||||
curr += numBytes;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue