aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/vm.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/vm/vm.go')
-rw-r--r--core/vm/vm.go27
1 files changed, 13 insertions, 14 deletions
diff --git a/core/vm/vm.go b/core/vm/vm.go
index 6db99bdcc..2bd950385 100644
--- a/core/vm/vm.go
+++ b/core/vm/vm.go
@@ -71,18 +71,22 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
}
}
- var (
- op OpCode
+ // Don't bother with the execution if there's no code.
+ if len(code) == 0 {
+ return context.Return(nil), nil
+ }
- destinations = analyseJumpDests(context.Code)
- mem = NewMemory()
- stack = newStack()
- pc = new(big.Int)
- statedb = self.env.State()
+ var (
+ 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)
}
@@ -95,11 +99,6 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
}
)
- // Don't bother with the execution if there's no code.
- if len(code) == 0 {
- return context.Return(nil), nil
- }
-
for {
// The base for all big integer arithmetic
base := new(big.Int)