Commit 96ddad5 1 parent 48964fc commit 96ddad5 Copy full SHA for 96ddad5
File tree 1 file changed +6
-6
lines changed
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -12,17 +12,17 @@ namespace evmone
12
12
{
13
13
JumpdestMap build_jumpdest_map (const uint8_t * code, size_t code_size)
14
14
{
15
- // Bitmask for PUSH opcode identification.
16
- // It clears the lower 5 bits of a byte.
17
- // The opcode is PUSH iff remaining byte value is 0x60 (OP_PUSH1) .
18
- constexpr auto push_op_mask = 0xE0 ;
15
+ // To find if op is any PUSH opcode (OP_PUSH1 <= op <= OP_PUSH32)
16
+ // it can be noticed that OP_PUSH32 is INT8_MAX (0x7f) therefore
17
+ // static_cast<int8_t>(op) <= OP_PUSH32 is always true and can be skipped .
18
+ static_assert (OP_PUSH32 == std::numeric_limits< int8_t >:: max ()) ;
19
19
20
20
JumpdestMap map (code_size); // Allocate and init bitmap with zeros.
21
21
for (size_t i = 0 ; i < code_size; ++i)
22
22
{
23
23
const auto op = code[i];
24
- if ((op & push_op_mask) == OP_PUSH1) // If any PUSH opcode.
25
- i += op - size_t {OP_PUSH1 - 1 }; // Skip PUSH data.
24
+ if (static_cast < int8_t > (op) >= OP_PUSH1) // If any PUSH opcode (see explanation above) .
25
+ i += op - size_t {OP_PUSH1 - 1 }; // Skip PUSH data.
26
26
else if (INTX_UNLIKELY (op == OP_JUMPDEST))
27
27
map[i] = true ;
28
28
}
You can’t perform that action at this time.
0 commit comments