mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-07 05:07:36 +00:00
vm: simplify slot and make it private
Hiding refcounter inside a slot is actually a good idea, but it makes the structure somewhat bigger, especially given that the refcounter is the same and belongs more to VM or Context. New structure is a bit more efficient: name old time/op new time/op delta ScriptFibonacci-8 672µs ± 2% 644µs ± 0% -4.15% (p=0.008 n=5+5) ScriptNestedRefCount-8 1.08ms ± 1% 1.05ms ± 2% -2.56% (p=0.008 n=5+5) ScriptPushPop/4-8 1.52µs ± 1% 1.47µs ± 1% -3.14% (p=0.008 n=5+5) ScriptPushPop/16-8 3.66µs ± 1% 3.54µs ± 1% -3.24% (p=0.008 n=5+5) ScriptPushPop/128-8 24.7µs ± 1% 23.2µs ± 1% -6.14% (p=0.008 n=5+5) ScriptPushPop/1024-8 183µs ± 1% 173µs ± 1% -5.01% (p=0.008 n=5+5) name old alloc/op new alloc/op delta ScriptFibonacci-8 114kB ± 0% 114kB ± 0% ~ (p=0.079 n=4+5) ScriptNestedRefCount-8 241kB ± 0% 241kB ± 0% ~ (p=0.333 n=5+4) ScriptPushPop/4-8 160B ± 0% 160B ± 0% ~ (all equal) ScriptPushPop/16-8 640B ± 0% 640B ± 0% ~ (all equal) ScriptPushPop/128-8 8.70kB ± 0% 8.70kB ± 0% ~ (all equal) ScriptPushPop/1024-8 73.2kB ± 0% 73.2kB ± 0% ~ (all equal) name old allocs/op new allocs/op delta ScriptFibonacci-8 3.17k ± 0% 3.17k ± 0% -0.03% (p=0.008 n=5+5) ScriptNestedRefCount-8 10.7k ± 0% 10.7k ± 0% ~ (all equal) ScriptPushPop/4-8 8.00 ± 0% 8.00 ± 0% ~ (all equal) ScriptPushPop/16-8 32.0 ± 0% 32.0 ± 0% ~ (all equal) ScriptPushPop/128-8 259 ± 0% 259 ± 0% ~ (all equal) ScriptPushPop/1024-8 2.05k ± 0% 2.05k ± 0% ~ (all equal) It'd be especially nice to internalize static slot, but as we can't compare slices it's not possible.
This commit is contained in:
parent
a0473aca92
commit
ee05f73b6f
6 changed files with 54 additions and 66 deletions
|
@ -32,9 +32,9 @@ type Context struct {
|
|||
// Evaluation stack pointer.
|
||||
estack *Stack
|
||||
|
||||
static *Slot
|
||||
local *Slot
|
||||
arguments *Slot
|
||||
static *slot
|
||||
local slot
|
||||
arguments slot
|
||||
|
||||
// Exception context stack.
|
||||
tryStack Stack
|
||||
|
@ -277,16 +277,19 @@ func (c *Context) DumpStaticSlot() string {
|
|||
|
||||
// DumpLocalSlot returns json formatted representation of the given slot.
|
||||
func (c *Context) DumpLocalSlot() string {
|
||||
return dumpSlot(c.local)
|
||||
return dumpSlot(&c.local)
|
||||
}
|
||||
|
||||
// DumpArgumentsSlot returns json formatted representation of the given slot.
|
||||
func (c *Context) DumpArgumentsSlot() string {
|
||||
return dumpSlot(c.arguments)
|
||||
return dumpSlot(&c.arguments)
|
||||
}
|
||||
|
||||
// dumpSlot returns json formatted representation of the given slot.
|
||||
func dumpSlot(s *Slot) string {
|
||||
func dumpSlot(s *slot) string {
|
||||
if s == nil || *s == nil {
|
||||
return "[]"
|
||||
}
|
||||
b, _ := json.MarshalIndent(s, "", " ")
|
||||
return string(b)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue