core/vm: grow arena

pull/30362/head
Martin Holst Swende 2 months ago
parent d36447e554
commit a2dbaeebbc
No known key found for this signature in database
GPG Key ID: 683B438C05A5DDF0
  1. 10
      core/vm/stack.go

@ -17,6 +17,8 @@
package vm package vm
import ( import (
"slices"
"github.com/holiman/uint256" "github.com/holiman/uint256"
) )
@ -27,7 +29,11 @@ type stackArena struct {
} }
func (sa *stackArena) push(value *uint256.Int) { func (sa *stackArena) push(value *uint256.Int) {
// TODO check length of bs.data and possibly grow() it as needed if len(sa.data) <= sa.top {
// we need to grow the arena
sa.data = slices.Grow(sa.data, 512)
sa.data = sa.data[:cap(sa.data)]
}
sa.data[sa.top] = *value sa.data[sa.top] = *value
sa.top++ sa.top++
} }
@ -38,7 +44,7 @@ func (sa *stackArena) pop() {
func newArena() *stackArena { func newArena() *stackArena {
return &stackArena{ return &stackArena{
data: make([]uint256.Int, 256), data: make([]uint256.Int, 1024),
} }
} }

Loading…
Cancel
Save