aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/vm.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-05-29 20:40:45 +0800
committerFelix Lange <fjl@twurst.com>2015-06-03 22:25:05 +0800
commitea2718c9462ae351baab5eaa05a7e1ef9dc916fa (patch)
treedd91f4e77fc779ffd3170272ea9025bcdfc002ef /core/vm/vm.go
parentb4818a003aabb1722f8413ba98fa5b6262ef9673 (diff)
downloadgo-tangerine-ea2718c9462ae351baab5eaa05a7e1ef9dc916fa.tar.gz
go-tangerine-ea2718c9462ae351baab5eaa05a7e1ef9dc916fa.tar.zst
go-tangerine-ea2718c9462ae351baab5eaa05a7e1ef9dc916fa.zip
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
Diffstat (limited to 'core/vm/vm.go')
-rw-r--r--core/vm/vm.go17
1 files changed, 8 insertions, 9 deletions
diff --git a/core/vm/vm.go b/core/vm/vm.go
index 6db99bdcc..0d8facbb6 100644
--- a/core/vm/vm.go
+++ b/core/vm/vm.go
@@ -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)
}