forked from TrueCloudLab/neoneo-go
vm: store refcounter directly in VM
VM always has it, so allocating yet another object makes no sense.
This commit is contained in:
parent
0a2bbf3c04
commit
ff7d594bef
2 changed files with 6 additions and 6 deletions
|
@ -26,7 +26,7 @@ func (s *Slot) init(n int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *VM) newSlot(n int) *Slot {
|
func (v *VM) newSlot(n int) *Slot {
|
||||||
s := newSlot(v.refs)
|
s := newSlot(&v.refs)
|
||||||
s.init(n)
|
s.init(n)
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
10
pkg/vm/vm.go
10
pkg/vm/vm.go
|
@ -73,7 +73,7 @@ type VM struct {
|
||||||
|
|
||||||
uncaughtException stackitem.Item // exception being handled
|
uncaughtException stackitem.Item // exception being handled
|
||||||
|
|
||||||
refs *refCounter
|
refs refCounter
|
||||||
|
|
||||||
gasConsumed int64
|
gasConsumed int64
|
||||||
GasLimit int64
|
GasLimit int64
|
||||||
|
@ -100,14 +100,14 @@ func NewWithTrigger(t trigger.Type) *VM {
|
||||||
vm := &VM{
|
vm := &VM{
|
||||||
state: NoneState,
|
state: NoneState,
|
||||||
istack: newStack("invocation", nil),
|
istack: newStack("invocation", nil),
|
||||||
refs: newRefCounter(),
|
|
||||||
trigger: t,
|
trigger: t,
|
||||||
|
|
||||||
SyscallHandler: defaultSyscallHandler,
|
SyscallHandler: defaultSyscallHandler,
|
||||||
Invocations: make(map[util.Uint160]int),
|
Invocations: make(map[util.Uint160]int),
|
||||||
}
|
}
|
||||||
|
|
||||||
vm.estack = newStack("evaluation", vm.refs)
|
vm.refs.items = make(map[stackitem.Item]int)
|
||||||
|
vm.estack = newStack("evaluation", &vm.refs)
|
||||||
return vm
|
return vm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,11 +281,11 @@ func (v *VM) LoadScript(b []byte) {
|
||||||
func (v *VM) LoadScriptWithFlags(b []byte, f callflag.CallFlag) {
|
func (v *VM) LoadScriptWithFlags(b []byte, f callflag.CallFlag) {
|
||||||
v.checkInvocationStackSize()
|
v.checkInvocationStackSize()
|
||||||
ctx := NewContextWithParams(b, 0, -1, 0)
|
ctx := NewContextWithParams(b, 0, -1, 0)
|
||||||
v.estack = newStack("evaluation", v.refs)
|
v.estack = newStack("evaluation", &v.refs)
|
||||||
ctx.estack = v.estack
|
ctx.estack = v.estack
|
||||||
ctx.tryStack = newStack("exception", nil)
|
ctx.tryStack = newStack("exception", nil)
|
||||||
ctx.callFlag = f
|
ctx.callFlag = f
|
||||||
ctx.static = newSlot(v.refs)
|
ctx.static = newSlot(&v.refs)
|
||||||
ctx.callingScriptHash = v.GetCurrentScriptHash()
|
ctx.callingScriptHash = v.GetCurrentScriptHash()
|
||||||
v.istack.PushVal(ctx)
|
v.istack.PushVal(ctx)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue