From e54e9781a4e043b3140b0c908ba4f4e469fd317e Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sun, 26 Apr 2020 14:14:14 +0200 Subject: prog: remove Dir from Type Having Dir is Type is handy, but forces us to duplicate lots of types. E.g. if a struct is referenced as both in and out, then we need to have 2 copies and 2 copies of structs/types it includes. If also prevents us from having the struct type as struct identity (because we can have up to 3 of them). Revert to the old way we used to do it: propagate Dir as we walk syscall arguments. This moves lots of dir passing from pkg/compiler to prog package. Now Arg contains the dir, so once we build the tree, we can use dirs as before. Reduces size of sys/linux/gen/amd64.go from 6058336 to 5661150 (-6.6%). Update #1580 --- prog/analysis.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'prog/analysis.go') diff --git a/prog/analysis.go b/prog/analysis.go index fe022b670..e1fbaa557 100644 --- a/prog/analysis.go +++ b/prog/analysis.go @@ -69,13 +69,13 @@ func (s *state) analyzeImpl(c *Call, resources bool) { switch typ := arg.Type().(type) { case *ResourceType: a := arg.(*ResultArg) - if resources && typ.Dir() != DirIn { + if resources && a.Dir() != DirIn { s.resources[typ.Desc.Name] = append(s.resources[typ.Desc.Name], a) // TODO: negative PIDs and add them as well (that's process groups). } case *BufferType: a := arg.(*DataArg) - if typ.Dir() != DirOut && len(a.Data()) != 0 { + if a.Dir() != DirOut && len(a.Data()) != 0 { val := string(a.Data()) // Remove trailing zero padding. for len(val) >= 2 && val[len(val)-1] == 0 && val[len(val)-2] == 0 { -- cgit mrf-deployment