Skip to content

Commit

Permalink
core/vm: unroll loops in analysis bitmap population
Browse files Browse the repository at this point in the history
Unroll loops in bitvec.setN(): first one can at most run 2 times,
second one at most once.
  • Loading branch information
chfast authored and holiman committed May 31, 2022
1 parent 97f595c commit 6a0dda3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions core/vm/analysis.go
Expand Up @@ -81,13 +81,20 @@ func codeBitmapInternal(code, bits bitvec) bitvec {
}
numbits := op - PUSH1 + 1
if numbits >= 8 {
for ; numbits >= 16; numbits -= 16 {
if numbits >= 16 {
bits.set16(pc)
pc += 16
numbits -= 16
}
for ; numbits >= 8; numbits -= 8 {
if numbits >= 16 {
bits.set16(pc)
pc += 16
numbits -= 16
}
if numbits >= 8 {
bits.set8(pc)
pc += 8
numbits -= 8
}
}
switch numbits {
Expand Down

0 comments on commit 6a0dda3

Please sign in to comment.