Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/evmone/analysis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ struct instr_info;

struct execution_state
{
const instr_info* next_instr{nullptr};
evmc_status_code status = EVMC_SUCCESS;
int64_t gas_left = 0;

Expand All @@ -113,10 +112,10 @@ struct execution_state
evmc_revision rev = {};

/// Terminates the execution with the given status code.
void exit(evmc_status_code status_code) noexcept
const instr_info* exit(evmc_status_code status_code) noexcept
{
status = status_code;
next_instr = nullptr;
return nullptr;
}
};

Expand All @@ -134,7 +133,7 @@ union instr_argument

static_assert(sizeof(instr_argument) == sizeof(void*), "Incorrect size of instr_argument");

using exec_fn = void (*)(execution_state&, instr_argument arg);
using exec_fn = const instr_info* (*)(const instr_info*, execution_state&);

/// The evmone intrinsic opcodes.
///
Expand Down
12 changes: 3 additions & 9 deletions lib/evmone/execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,16 @@ evmc_result execute(evmc_instance*, evmc_context* ctx, evmc_revision rev, const

auto state = std::make_unique<execution_state>();
state->analysis = &analysis;
state->next_instr = &state->analysis->instrs[0];
state->msg = msg;
state->code = code;
state->code_size = code_size;
state->host = evmc::HostContext{ctx};
state->gas_left = msg->gas;
state->rev = rev;
while (state->next_instr)
{
const auto& instr = *state->next_instr;

// Advance next_instr to allow jump opcodes to overwrite it.
++state->next_instr;

instr.fn(*state, instr.arg);
}
const instr_info* instr = &state->analysis->instrs[0];
while (instr)
instr = instr->fn(instr, *state);

evmc_result result{};

Expand Down
Loading