From 85d1218f4108e0fe793f63e57e2edadd5da5764f Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sun, 18 Feb 2018 13:49:48 +0100 Subject: prog: rework foreachArg Make Foreach* callback accept the arg and a context struct that can contain lots of aux info. This (1) removes lots of unuser base/parent args, (2) provides foundation for stopping recursion, (3) allows to merge foreachSubargOffset. --- prog/encodingexec.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'prog/encodingexec.go') diff --git a/prog/encodingexec.go b/prog/encodingexec.go index 1d5b5e870..d0c8f6c80 100644 --- a/prog/encodingexec.go +++ b/prog/encodingexec.go @@ -86,7 +86,7 @@ func (p *Prog) SerializeForExec(buffer []byte) (int, error) { } // Calculate arg offsets within structs. // Generate copyin instructions that fill in data into pointer arguments. - foreachArg(c, func(arg, _ Arg, _ *[]Arg) { + ForeachArg(c, func(arg Arg, _ *ArgCtx) { if a, ok := arg.(*PointerArg); ok && a.Res != nil { foreachSubargOffset(a.Res, func(arg1 Arg, offset uint64) { addr := p.Target.PhysicalAddr(arg) + offset @@ -167,7 +167,7 @@ func (p *Prog) SerializeForExec(buffer []byte) (int, error) { w.writeArg(arg) } // Generate copyout instructions that persist interesting return values. - foreachArg(c, func(arg, base Arg, _ *[]Arg) { + ForeachArg(c, func(arg Arg, _ *ArgCtx) { if !isUsed(arg) { return } @@ -176,9 +176,6 @@ func (p *Prog) SerializeForExec(buffer []byte) (int, error) { // Idx is already assigned above. case *ConstArg, *ResultArg: // Create a separate copyout instruction that has own Idx. - if _, ok := base.(*PointerArg); !ok { - panic("arg base is not a pointer") - } info := w.args[arg] info.Idx = copyoutSeq copyoutSeq++ -- cgit mrf-deployment