vm: store exception stack in the context
Avoid allocating it.
This commit is contained in:
parent
d3198c3082
commit
ed35cf8f12
3 changed files with 5 additions and 4 deletions
|
@ -35,8 +35,8 @@ type Context struct {
|
||||||
local *Slot
|
local *Slot
|
||||||
arguments *Slot
|
arguments *Slot
|
||||||
|
|
||||||
// Exception context stack pointer.
|
// Exception context stack.
|
||||||
tryStack *Stack
|
tryStack Stack
|
||||||
|
|
||||||
// Script hash of the prog.
|
// Script hash of the prog.
|
||||||
scriptHash util.Uint160
|
scriptHash util.Uint160
|
||||||
|
|
|
@ -171,6 +171,7 @@ func initStack(s *Stack, n string, refc *refCounter) {
|
||||||
s.refs = refc
|
s.refs = refc
|
||||||
s.top.next = &s.top
|
s.top.next = &s.top
|
||||||
s.top.prev = &s.top
|
s.top.prev = &s.top
|
||||||
|
s.len = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear clears all elements on the stack and set its length to 0.
|
// Clear clears all elements on the stack and set its length to 0.
|
||||||
|
|
|
@ -282,7 +282,7 @@ func (v *VM) LoadScriptWithFlags(b []byte, f callflag.CallFlag) {
|
||||||
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)
|
initStack(&ctx.tryStack, "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()
|
||||||
|
@ -1519,7 +1519,7 @@ func (v *VM) call(ctx *Context, offset int) {
|
||||||
newCtx.RetCount = -1
|
newCtx.RetCount = -1
|
||||||
newCtx.local = nil
|
newCtx.local = nil
|
||||||
newCtx.arguments = nil
|
newCtx.arguments = nil
|
||||||
newCtx.tryStack = newStack("exception", nil)
|
initStack(&newCtx.tryStack, "exception", nil)
|
||||||
newCtx.NEF = ctx.NEF
|
newCtx.NEF = ctx.NEF
|
||||||
v.istack.PushVal(newCtx)
|
v.istack.PushVal(newCtx)
|
||||||
v.Jump(newCtx, offset)
|
v.Jump(newCtx, offset)
|
||||||
|
|
Loading…
Reference in a new issue