Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed May 31, 2021
1 parent 104bb39 commit 1085606
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/evmone/baseline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,28 @@ inline evmc_status_code check_requirements(const char* const* instruction_names,
template <bool TracingEnabled>
evmc_result execute(const VM& vm, ExecutionState& state, const CodeAnalysis& analysis) noexcept
{
// state.code = {analysis.padded_code.get(), analysis.code_size};

const auto* const code = analysis.padded_code.get();

auto* tracer = vm.get_tracer();
if constexpr (TracingEnabled)
tracer->notify_execution_start(state.rev, *state.msg, state.code);
tracer->notify_execution_start(state.rev, *state.msg, code);

const auto rev = state.rev;

const auto instruction_names = evmc_get_instruction_names_table(rev);
const auto instruction_metrics = evmc_get_instruction_metrics_table(rev);

const auto* pc = analysis.padded_code.get();
const auto* pc = code;
while (true) // Guaranteed to terminate because code must end with STOP.
{
if constexpr (TracingEnabled)
tracer->notify_instruction_start(static_cast<uint32_t>(pc - code));
{
const auto offset = static_cast<uint32_t>(pc - code);
if (offset < analysis.code_size) // Skip STOP from code padding.
tracer->notify_instruction_start(offset);
}

const auto op = *pc;
const auto status = check_requirements(instruction_names, instruction_metrics, state, op);
Expand Down Expand Up @@ -402,7 +410,7 @@ evmc_result execute(const VM& vm, ExecutionState& state, const CodeAnalysis& ana
continue;

case OP_PC:
state.stack.push(pc - analysis.padded_code.get());
state.stack.push(pc - code);
break;
case OP_MSIZE:
msize(state);
Expand Down

0 comments on commit 1085606

Please sign in to comment.