core, core/vm, tests: changed the initialisation behaviour of the EVM
The EVM was previously initialised and created for every CALL, CALLCODE, DELEGATECALL and CREATE. This PR changes this behaviour so that the same EVM can be used through the session and beyond as long as the Environment sticks around.
This commit is contained in:
committed by
Jeffrey Wilcke
parent
2855a93ede
commit
342ae7ce7d
@ -30,15 +30,12 @@ import (
|
||||
|
||||
// Vm is an EVM and implements VirtualMachine
|
||||
type Vm struct {
|
||||
env Environment
|
||||
env Environment
|
||||
jumpTable vmJumpTable
|
||||
}
|
||||
|
||||
// New returns a new Vm
|
||||
func New(env Environment) *Vm {
|
||||
// init the jump table. Also prepares the homestead changes
|
||||
jumpTable.init(env.BlockNumber())
|
||||
|
||||
return &Vm{env: env}
|
||||
func EVM(env Environment) *Vm {
|
||||
return &Vm{env: env, jumpTable: newJumpTable(env.BlockNumber())}
|
||||
}
|
||||
|
||||
// Run loops and evaluates the contract's code with the given input data
|
||||
@ -169,7 +166,7 @@ func (self *Vm) Run(contract *Contract, input []byte) (ret []byte, err error) {
|
||||
mem.Resize(newMemSize.Uint64())
|
||||
// Add a log message
|
||||
self.log(pc, op, contract.Gas, cost, mem, stack, contract, nil)
|
||||
if opPtr := jumpTable[op]; opPtr.valid {
|
||||
if opPtr := self.jumpTable[op]; opPtr.valid {
|
||||
if opPtr.fn != nil {
|
||||
opPtr.fn(instruction{}, &pc, self.env, contract, mem, stack)
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user