mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
dropped masks
This commit is contained in:
parent
ae0edbf0d0
commit
36a4609150
1 changed files with 6 additions and 41 deletions
|
|
@ -133,11 +133,11 @@ func (bv bitVec) codeBitVec(code []byte) bitVec {
|
|||
var pc uint64
|
||||
for pc < uint64(len(code)) {
|
||||
op := code[pc]
|
||||
if int8(op) < 0x60 {
|
||||
if int8(op) < int8(PUSH1) {
|
||||
pc++
|
||||
continue // continue if the OpCode is not PUSH1..32
|
||||
}
|
||||
numBytes := op - 0x5f // number of data bytes pushed
|
||||
numBytes := op - uint8(PUSH0) // number of data bytes pushed
|
||||
shift := uint8((pc + 1) % 32)
|
||||
i := (pc + 1) / 32
|
||||
|
||||
|
|
@ -146,12 +146,12 @@ func (bv bitVec) codeBitVec(code []byte) bitVec {
|
|||
bv[i] |= 1 << shift
|
||||
pc += 2
|
||||
case 32:
|
||||
a := masks[numBytes] << shift
|
||||
bv[i] |= uint32(a)
|
||||
bv[i+1] = uint32(^a)
|
||||
a := uint32(0xffffffff) << shift
|
||||
bv[i] |= a
|
||||
bv[i+1] = ^a
|
||||
pc += 33
|
||||
default:
|
||||
a := masks[numBytes] << shift
|
||||
a := (uint64(1<<numBytes) - 1) << shift
|
||||
bv[i] |= uint32(a)
|
||||
bv[i+1] = uint32(a >> 32)
|
||||
pc += uint64(numBytes + 1)
|
||||
|
|
@ -159,38 +159,3 @@ func (bv bitVec) codeBitVec(code []byte) bitVec {
|
|||
}
|
||||
return bv
|
||||
}
|
||||
|
||||
var masks = [256]uint64{
|
||||
1: 0b00000000_00000000_00000000_00000001,
|
||||
2: 0b00000000_00000000_00000000_00000011,
|
||||
3: 0b00000000_00000000_00000000_00000111,
|
||||
4: 0b00000000_00000000_00000000_00001111,
|
||||
5: 0b00000000_00000000_00000000_00011111,
|
||||
6: 0b00000000_00000000_00000000_00111111,
|
||||
7: 0b00000000_00000000_00000000_01111111,
|
||||
8: 0b00000000_00000000_00000000_11111111,
|
||||
9: 0b00000000_00000000_00000001_11111111,
|
||||
10: 0b00000000_00000000_00000011_11111111,
|
||||
11: 0b00000000_00000000_00000111_11111111,
|
||||
12: 0b00000000_00000000_00001111_11111111,
|
||||
13: 0b00000000_00000000_00011111_11111111,
|
||||
14: 0b00000000_00000000_00111111_11111111,
|
||||
15: 0b00000000_00000000_01111111_11111111,
|
||||
16: 0b00000000_00000000_11111111_11111111,
|
||||
17: 0b00000000_00000001_11111111_11111111,
|
||||
18: 0b00000000_00000011_11111111_11111111,
|
||||
19: 0b00000000_00000111_11111111_11111111,
|
||||
20: 0b00000000_00001111_11111111_11111111,
|
||||
21: 0b00000000_00011111_11111111_11111111,
|
||||
22: 0b00000000_00111111_11111111_11111111,
|
||||
23: 0b00000000_01111111_11111111_11111111,
|
||||
24: 0b00000000_11111111_11111111_11111111,
|
||||
25: 0b00000001_11111111_11111111_11111111,
|
||||
26: 0b00000011_11111111_11111111_11111111,
|
||||
27: 0b00000111_11111111_11111111_11111111,
|
||||
28: 0b00001111_11111111_11111111_11111111,
|
||||
29: 0b00011111_11111111_11111111_11111111,
|
||||
30: 0b00111111_11111111_11111111_11111111,
|
||||
31: 0b01111111_11111111_11111111_11111111,
|
||||
32: 0b11111111_11111111_11111111_11111111,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue