aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/vm.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-05-06 23:43:27 +0800
committerobscuren <geffobscura@gmail.com>2014-05-06 23:43:27 +0800
commita0af7de58eeba598c8e967ae9deefb4ee287a1df (patch)
tree5ebf941f106b4827949dc1849ca12039473e4819 /ethchain/vm.go
parentaf6875f4b25145402b20e37ab037d912f54ec968 (diff)
downloaddexon-a0af7de58eeba598c8e967ae9deefb4ee287a1df.tar.gz
dexon-a0af7de58eeba598c8e967ae9deefb4ee287a1df.tar.zst
dexon-a0af7de58eeba598c8e967ae9deefb4ee287a1df.zip
Optimizations
Diffstat (limited to 'ethchain/vm.go')
-rw-r--r--ethchain/vm.go30
1 files changed, 10 insertions, 20 deletions
diff --git a/ethchain/vm.go b/ethchain/vm.go
index 3a3b3447a..bac313006 100644
--- a/ethchain/vm.go
+++ b/ethchain/vm.go
@@ -95,6 +95,8 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
ethutil.Config.Log.Debugf("# op\n")
}
+ fmt.Println(closure.Script)
+
for {
// The base for all big integer arithmetic
base := new(big.Int)
@@ -104,11 +106,9 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
val := closure.Get(pc)
// Get the opcode (it must be an opcode!)
op := OpCode(val.Uint())
- /*
- if ethutil.Config.Debug {
- ethutil.Config.Log.Debugf("%-3d %-4s", pc, op.String())
- }
- */
+ if ethutil.Config.Debug {
+ ethutil.Config.Log.Debugf("%-3d %-4s", pc, op.String())
+ }
gas := new(big.Int)
useGas := func(amount *big.Int) {
@@ -352,27 +352,17 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
// TODO
stack.Push(big.NewInt(0))
- // 0x50 range
- case oPUSH: // Push PC+1 on to the stack
+ // 0x50 range
+ case oPUSH1, oPUSH2, oPUSH3, oPUSH4, oPUSH5, oPUSH6, oPUSH7, oPUSH8, oPUSH9, oPUSH10, oPUSH11, oPUSH12, oPUSH13, oPUSH14, oPUSH15, oPUSH16, oPUSH17, oPUSH18, oPUSH19, oPUSH20, oPUSH21, oPUSH22, oPUSH23, oPUSH24, oPUSH25, oPUSH26, oPUSH27, oPUSH28, oPUSH29, oPUSH30, oPUSH31, oPUSH32:
+ a := big.NewInt(int64(op) - int64(oPUSH1) + 1)
pc.Add(pc, ethutil.Big1)
- data := closure.Gets(pc, big.NewInt(32))
+ data := closure.Gets(pc, a)
val := ethutil.BigD(data.Bytes())
-
// Push value to stack
stack.Push(val)
-
- pc.Add(pc, big.NewInt(31))
+ pc.Add(pc, a.Sub(a, big.NewInt(1)))
step++
- case oPUSH20:
- pc.Add(pc, ethutil.Big1)
- data := closure.Gets(pc, big.NewInt(20))
- val := ethutil.BigD(data.Bytes())
- // Push value to stack
- stack.Push(val)
-
- pc.Add(pc, big.NewInt(19))
- step++
case oPOP:
require(1)
stack.Pop()