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 --- pkg/compiler/check.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'pkg/compiler/check.go') diff --git a/pkg/compiler/check.go b/pkg/compiler/check.go index e22f217fd..2c0438086 100644 --- a/pkg/compiler/check.go +++ b/pkg/compiler/check.go @@ -323,7 +323,7 @@ func (comp *compiler) checkLenType(t0, t *ast.Type, parents []parentDesc, warned[parentName] = true return } - _, args, _ := comp.getArgsBase(t, "", prog.DirIn, isArg) + _, args, _ := comp.getArgsBase(t, "", isArg) for i, arg := range args { argDesc := desc.Args[i] if argDesc.Type == typeArgLenTarget { @@ -522,7 +522,7 @@ func (comp *compiler) collectUsedType(structs, flags, strflags map[string]bool, } return } - _, args, _ := comp.getArgsBase(t, "", prog.DirIn, isArg) + _, args, _ := comp.getArgsBase(t, "", isArg) for i, arg := range args { if desc.Args[i].Type == typeArgType { comp.collectUsedType(structs, flags, strflags, arg, desc.Args[i].IsArg) @@ -603,7 +603,7 @@ func (comp *compiler) checkTypeCtors(t *ast.Type, dir prog.Dir, isArg bool, if desc == typePtr { dir = genDir(t.Args[0]) } - _, args, _ := comp.getArgsBase(t, "", dir, isArg) + _, args, _ := comp.getArgsBase(t, "", isArg) for i, arg := range args { if desc.Args[i].Type == typeArgType { comp.checkTypeCtors(arg, dir, desc.Args[i].IsArg, ctors, checked) @@ -684,7 +684,7 @@ func (comp *compiler) recurseField(checked map[string]bool, t *ast.Type, path [] comp.checkStructRecursion(checked, comp.structs[t.Ident], path) return } - _, args, base := comp.getArgsBase(t, "", prog.DirIn, false) + _, args, base := comp.getArgsBase(t, "", false) if desc == typePtr && base.IsOptional { return // optional pointers prune recursion } @@ -774,7 +774,7 @@ func (comp *compiler) checkType(ctx checkCtx, t *ast.Type, flags checkFlags) { return } if desc.Check != nil { - _, args, base := comp.getArgsBase(t, "", prog.DirIn, flags&checkIsArg != 0) + _, args, base := comp.getArgsBase(t, "", flags&checkIsArg != 0) desc.Check(comp, t, args, base) } } @@ -1098,12 +1098,12 @@ func (comp *compiler) checkVarlens() { } func (comp *compiler) isVarlen(t *ast.Type) bool { - desc, args, _ := comp.getArgsBase(t, "", prog.DirIn, false) + desc, args, _ := comp.getArgsBase(t, "", false) return desc.Varlen != nil && desc.Varlen(comp, t, args) } func (comp *compiler) isZeroSize(t *ast.Type) bool { - desc, args, _ := comp.getArgsBase(t, "", prog.DirIn, false) + desc, args, _ := comp.getArgsBase(t, "", false) return desc.ZeroSize != nil && desc.ZeroSize(comp, t, args) } -- cgit mrf-deployment