core/vm: improve JUMPDEST analysis
* JUMPDEST analysis is faster because less type conversions are performed. * The map of JUMPDEST locations is now created lazily at the first JUMP. * The result of the analysis is kept around for recursive invocations through CALL/CALLCODE. Fixes #1147
This commit is contained in:
@ -72,17 +72,16 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
|
||||
}
|
||||
|
||||
var (
|
||||
op OpCode
|
||||
|
||||
destinations = analyseJumpDests(context.Code)
|
||||
mem = NewMemory()
|
||||
stack = newStack()
|
||||
pc = new(big.Int)
|
||||
statedb = self.env.State()
|
||||
op OpCode
|
||||
codehash = crypto.Sha3Hash(code)
|
||||
mem = NewMemory()
|
||||
stack = newStack()
|
||||
pc = new(big.Int)
|
||||
statedb = self.env.State()
|
||||
|
||||
jump = func(from *big.Int, to *big.Int) error {
|
||||
nop := context.GetOp(to)
|
||||
if !destinations.Has(to) {
|
||||
if !context.jumpdests.has(codehash, code, to) {
|
||||
nop := context.GetOp(to)
|
||||
return fmt.Errorf("invalid jump destination (%v) %v", nop, to)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user