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/prio.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'prog/prio.go') diff --git a/prog/prio.go b/prog/prio.go index b67bbaea0..2a9486570 100644 --- a/prog/prio.go +++ b/prog/prio.go @@ -65,11 +65,11 @@ func (target *Target) calcStaticPriorities() [][]float32 { func (target *Target) calcResourceUsage() map[string]map[int]weights { uses := make(map[string]map[int]weights) for _, c := range target.Syscalls { - ForeachType(c, func(t Type) { + foreachType(c, func(t Type, ctx typeCtx) { switch a := t.(type) { case *ResourceType: if target.AuxResources[a.Desc.Name] { - noteUsage(uses, c, 0.1, a.Dir(), "res%v", a.Desc.Name) + noteUsage(uses, c, 0.1, ctx.Dir, "res%v", a.Desc.Name) } else { str := "res" for i, k := range a.Desc.Kind { @@ -78,25 +78,25 @@ func (target *Target) calcResourceUsage() map[string]map[int]weights { if i < len(a.Desc.Kind)-1 { w = 0.2 } - noteUsage(uses, c, float32(w), a.Dir(), str) + noteUsage(uses, c, float32(w), ctx.Dir, str) } } case *PtrType: if _, ok := a.Type.(*StructType); ok { - noteUsage(uses, c, 1.0, a.Dir(), "ptrto-%v", a.Type.Name()) + noteUsage(uses, c, 1.0, ctx.Dir, "ptrto-%v", a.Type.Name()) } if _, ok := a.Type.(*UnionType); ok { - noteUsage(uses, c, 1.0, a.Dir(), "ptrto-%v", a.Type.Name()) + noteUsage(uses, c, 1.0, ctx.Dir, "ptrto-%v", a.Type.Name()) } if arr, ok := a.Type.(*ArrayType); ok { - noteUsage(uses, c, 1.0, a.Dir(), "ptrto-%v", arr.Type.Name()) + noteUsage(uses, c, 1.0, ctx.Dir, "ptrto-%v", arr.Type.Name()) } case *BufferType: switch a.Kind { case BufferBlobRand, BufferBlobRange, BufferText: case BufferString: if a.SubKind != "" { - noteUsage(uses, c, 0.2, a.Dir(), fmt.Sprintf("str-%v", a.SubKind)) + noteUsage(uses, c, 0.2, ctx.Dir, fmt.Sprintf("str-%v", a.SubKind)) } case BufferFilename: noteUsage(uses, c, 1.0, DirIn, "filename") @@ -104,7 +104,7 @@ func (target *Target) calcResourceUsage() map[string]map[int]weights { panic("unknown buffer kind") } case *VmaType: - noteUsage(uses, c, 0.5, a.Dir(), "vma") + noteUsage(uses, c, 0.5, ctx.Dir, "vma") case *IntType: switch a.Kind { case IntPlain, IntRange: -- cgit mrf-deployment