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();
|
ProgramCounter currentPC = curr - bytecode.begin();
|
||||||
validJumpTargets[currentPC] = true;
|
validJumpTargets[currentPC] = true;
|
||||||
|
|
||||||
auto inst = static_cast<Instruction>(*curr);
|
auto inst = Instruction(*curr);
|
||||||
switch (inst)
|
switch (inst)
|
||||||
{
|
{
|
||||||
|
|
||||||
case Instruction::ANY_PUSH:
|
case Instruction::ANY_PUSH:
|
||||||
{
|
{
|
||||||
auto numBytes = static_cast<size_t>(inst) - static_cast<size_t>(Instruction::PUSH1) + 1;
|
auto val = readPushData(curr, bytecode.end());
|
||||||
auto next = curr + numBytes + 1;
|
auto next = curr + 1;
|
||||||
if (next >= bytecode.end())
|
if (next == bytecode.end())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
auto nextInst = static_cast<Instruction>(*next);
|
auto nextInst = Instruction(*next);
|
||||||
|
|
||||||
if (nextInst == Instruction::JUMP || nextInst == Instruction::JUMPI)
|
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.
|
// Create a block for the JUMP target.
|
||||||
ProgramCounter targetPC = val < bytecode.size() ? val.convert_to<ProgramCounter>() : bytecode.size();
|
ProgramCounter targetPC = val < bytecode.size() ? val.convert_to<ProgramCounter>() : bytecode.size();
|
||||||
splitPoints.insert(targetPC);
|
splitPoints.insert(targetPC);
|
||||||
|
|
@ -86,8 +77,6 @@ void Compiler::createBasicBlocks(bytesConstRef bytecode)
|
||||||
ProgramCounter jumpPC = (next - bytecode.begin());
|
ProgramCounter jumpPC = (next - bytecode.begin());
|
||||||
directJumpTargets[jumpPC] = targetPC;
|
directJumpTargets[jumpPC] = targetPC;
|
||||||
}
|
}
|
||||||
|
|
||||||
curr += numBytes;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue