aboutsummaryrefslogtreecommitdiffstats
path: root/prog/encodingexec.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-02-18 13:49:48 +0100
committerDmitry Vyukov <dvyukov@google.com>2018-02-19 21:48:20 +0100
commit85d1218f4108e0fe793f63e57e2edadd5da5764f (patch)
tree2b8cbd8c476cd0f21d1add6bc74d0ca5bb9dec46 /prog/encodingexec.go
parent2be2288ee256f3b84a7de15b82894097a08fd939 (diff)
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.
Diffstat (limited to 'prog/encodingexec.go')
-rw-r--r--prog/encodingexec.go7
1 files changed, 2 insertions, 5 deletions
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++