aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/vm.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2016-01-21 22:29:58 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2016-03-23 07:04:00 +0800
commit342ae7ce7dfd7a0eab2dd06bfa65199825279f05 (patch)
tree4d90314e50e137bcd8ee837cbb396fee40e2bb4b /core/vm/vm.go
parent2855a93ede6e9437d05a82c2397d48744621db9b (diff)
downloadgo-tangerine-342ae7ce7dfd7a0eab2dd06bfa65199825279f05.tar.gz
go-tangerine-342ae7ce7dfd7a0eab2dd06bfa65199825279f05.tar.zst
go-tangerine-342ae7ce7dfd7a0eab2dd06bfa65199825279f05.zip
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.
Diffstat (limited to 'core/vm/vm.go')
-rw-r--r--core/vm/vm.go13
1 files changed, 5 insertions, 8 deletions
diff --git a/core/vm/vm.go b/core/vm/vm.go
index 95d27c64c..26df8aef4 100644
--- a/core/vm/vm.go
+++ b/core/vm/vm.go
@@ -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 {