Skip to content

Commit

Permalink
baseline: Use padded code for execution
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Jun 2, 2021
1 parent 31c8312 commit 6d98168
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/evmone/baseline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ 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
{
// Use padded code.
state.code = {analysis.padded_code.get(), state.code.size()};

auto* tracer = vm.get_tracer();
if constexpr (TracingEnabled)
tracer->notify_execution_start(state.rev, *state.msg, state.code);
Expand All @@ -120,7 +123,11 @@ evmc_result execute(const VM& vm, ExecutionState& state, const CodeAnalysis& ana
while (pc != code_end)
{
if constexpr (TracingEnabled)
tracer->notify_instruction_start(static_cast<uint32_t>(pc - code), state);
{
const auto offset = static_cast<uint32_t>(pc - code);
if (offset < state.code.size()) // Skip STOP from code padding.
tracer->notify_instruction_start(offset, state);
}

const auto op = *pc;
const auto status = check_requirements(instruction_names, instruction_metrics, state, op);
Expand Down

0 comments on commit 6d98168

Please sign in to comment.