diff --git a/gnovm/pkg/gnolang/machine.go b/gnovm/pkg/gnolang/machine.go index c6859d0466a..521f97d9e6a 100644 --- a/gnovm/pkg/gnolang/machine.go +++ b/gnovm/pkg/gnolang/machine.go @@ -1088,15 +1088,16 @@ const ( OpCPUTypeAssert2 = 25 // TODO: OpCPUStaticTypeOf is an arbitrary number. // A good way to benchmark this is yet to be determined. - OpCPUStaticTypeOf = 100 - OpCPUCompositeLit = 50 - OpCPUArrayLit = 137 - OpCPUSliceLit = 183 - OpCPUSliceLit2 = 467 - OpCPUMapLit = 475 - OpCPUStructLit = 179 - OpCPUFuncLit = 61 - OpCPUConvert = 16 + OpCPUStaticTypeOf = 100 + OpCPUCompositeLit = 50 + OpCPUArrayLit = 137 + OpCPUSliceLit = 183 + OpCPUSliceLit2 = 467 + OpCPUCompositeLitEl = 40 + OpCPUMapLit = 475 + OpCPUStructLit = 179 + OpCPUFuncLit = 61 + OpCPUConvert = 16 /* Type operators */ OpCPUFieldType = 59 diff --git a/gnovm/pkg/gnolang/op_expressions.go b/gnovm/pkg/gnolang/op_expressions.go index 766b20995a0..6ded5b55bca 100644 --- a/gnovm/pkg/gnolang/op_expressions.go +++ b/gnovm/pkg/gnolang/op_expressions.go @@ -408,6 +408,11 @@ func (m *Machine) doOpArrayLit() { // assess performance TODO x := m.PopExpr().(*CompositeLitExpr) ne := len(x.Elts) + + defer func() { + m.incrCPU(int64(OpCPUCompositeLitEl * ne)) + }() + // peek array type. at := m.PeekValue(1 + ne).V.(TypeValue).Type bt := baseOf(at).(*ArrayType) @@ -493,6 +498,11 @@ func (m *Machine) doOpSliceLit2() { // assess performance TODO x := m.PopExpr().(*CompositeLitExpr) el := len(x.Elts) + + defer func() { + m.incrCPU(int64(OpCPUCompositeLitEl * el)) + }() + tvs := m.PopValues(el * 2) // peek slice type. st := m.PeekValue(1).V.(TypeValue).Type @@ -542,6 +552,11 @@ func (m *Machine) doOpSliceLit2() { func (m *Machine) doOpMapLit() { x := m.PopExpr().(*CompositeLitExpr) ne := len(x.Elts) + + defer func() { + m.incrCPU(int64(OpCPUCompositeLitEl * ne)) + }() + // peek map type. mt := m.PeekValue(1 + ne*2).V.(TypeValue).Type // bt := baseOf(at).(*MapType) @@ -581,6 +596,11 @@ func (m *Machine) doOpStructLit() { // assess performance TODO x := m.PopExpr().(*CompositeLitExpr) el := len(x.Elts) // may be incomplete + + defer func() { + m.incrCPU(int64(OpCPUCompositeLitEl * el)) + }() + // peek struct type. xt := m.PeekValue(1 + el).V.(TypeValue).Type st := baseOf(xt).(*StructType)