Skip to content

Commit

Permalink
Update instructions implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Jun 25, 2021
1 parent 889a4c2 commit 4a4f083
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions lib/evmone/instructions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ inline evmc_status_code exp(ExecutionState& state) noexcept
auto& exponent = state.stack.top();

const auto exponent_significant_bytes =
static_cast<int>(intx::count_significant_words<uint8_t>(exponent));
static_cast<int>(intx::count_significant_bytes(exponent));
const auto exponent_cost = state.rev >= EVMC_SPURIOUS_DRAGON ? 50 : 10;
const auto additional_cost = exponent_significant_bytes * exponent_cost;
if ((state.gas_left -= additional_cost) < 0)
Expand Down Expand Up @@ -161,21 +161,14 @@ inline void gt(Stack& stack) noexcept

inline void slt(Stack& stack) noexcept
{
// TODO: Move this to intx.
const auto x = stack.pop();
auto& y = stack[0];
const auto x_neg = x.hi.hi >> 63;
const auto y_neg = y.hi.hi >> 63;
y = ((x_neg ^ y_neg) != 0) ? x_neg : x < y;
stack[0] = slt(x, stack[0]);
}

inline void sgt(Stack& stack) noexcept
{
const auto x = stack.pop();
auto& y = stack[0];
const auto x_neg = x.hi.hi >> 63;
const auto y_neg = y.hi.hi >> 63;
y = ((x_neg ^ y_neg) != 0) ? y_neg : y < x;
stack[0] = slt(stack[0], x);
}

inline void eq(Stack& stack) noexcept
Expand Down

0 comments on commit 4a4f083

Please sign in to comment.