Commit 09711e0 1 parent 48964fc commit 09711e0 Copy full SHA for 09711e0
File tree 1 file changed +6
-7
lines changed
1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -12,17 +12,16 @@ 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 ;
19
-
20
15
JumpdestMap map (code_size); // Allocate and init bitmap with zeros.
21
16
for (size_t i = 0 ; i < code_size; ++i)
22
17
{
23
18
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.
19
+
20
+ // To find if op is any PUSH opcode (OP_PUSH1 <= op <= OP_PUSH32)
21
+ // it can be noticed that OP_PUSH32 is INT8_MAX (0x7f) therefore
22
+ // static_cast<int8_t>(op) <= OP_PUSH32 is always true and can be skipped.
23
+ if (static_cast <int8_t >(op) >= OP_PUSH1) // If any PUSH opcode .
24
+ i += op - size_t {OP_PUSH1 - 1 }; // Skip PUSH data.
26
25
else if (INTX_UNLIKELY (op == OP_JUMPDEST))
27
26
map[i] = true ;
28
27
}
You can’t perform that action at this time.
0 commit comments