Skip to content

Commit

Permalink
core/vm: improve jumpdest analysis >PUSH15
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman committed Aug 14, 2021
1 parent 66ce675 commit 3b8abe1
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions core/vm/analysis.go
Expand Up @@ -83,11 +83,20 @@ func (bits *bitvec) set7(pos uint64) {
func (bits *bitvec) set8(pos uint64) {
a := byte(0xFF >> (pos % 8))
(*bits)[pos/8] |= a
if ^a != 0{
if ^a != 0 {
(*bits)[pos/8+1] = ^a
}
}

func (bits *bitvec) set16(pos uint64) {
a := byte(0xFF >> (pos % 8))
(*bits)[pos/8] |= a
(*bits)[pos/8+1] = 0xFF
if ^a != 0 {
(*bits)[pos/8+2] = ^a
}
}

// codeSegment checks if the position is in a code segment.
func (bits *bitvec) codeSegment(pos uint64) bool {
return ((*bits)[pos/8] & (0x80 >> (pos % 8))) == 0
Expand All @@ -106,9 +115,15 @@ func codeBitmap(code []byte) bitvec {
continue
}
numbits := op - PUSH1 + 1
for ; numbits >= 8; numbits -= 8 {
bits.set8(pc)
pc += 8
if numbits >= 8 {
for ; numbits >= 16; numbits -= 16 {
bits.set16(pc)
pc += 16
}
for ; numbits >= 8; numbits -= 8 {
bits.set8(pc)
pc += 8
}
}
switch numbits {
case 1:
Expand Down

0 comments on commit 3b8abe1

Please sign in to comment.