Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize yield search #131

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions compiler/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,9 @@ func Compile(path string, options ...Option) error {

type compiler struct {
onlyListFiles bool

prog *ssa.Program
generics map[*ssa.Function][]*ssa.Function
coroutinePkg *packages.Package

fset *token.FileSet
prog *ssa.Program
coroutinePkg *packages.Package
fset *token.FileSet
}

func (c *compiler) compile(path string) error {
Expand Down Expand Up @@ -120,19 +117,6 @@ func (c *compiler) compile(path string) error {
functions := ssautil.AllFunctions(c.prog)
cg := vta.CallGraph(functions, cha.CallGraph(c.prog))

log.Printf("collecting generic instances")
c.generics = map[*ssa.Function][]*ssa.Function{}
for fn := range functions {
if fn.Signature.TypeParams() != nil {
if _, ok := c.generics[fn]; !ok {
c.generics[fn] = nil
}
}
if origin := fn.Origin(); origin != nil {
c.generics[origin] = append(c.generics[origin], fn)
}
}

log.Printf("finding yield points")
packages.Visit(pkgs, func(p *packages.Package) bool {
if p.PkgPath == coroutinePackage {
Expand All @@ -146,8 +130,8 @@ func (c *compiler) compile(path string) error {
}
yieldFunc := c.prog.FuncValue(c.coroutinePkg.Types.Scope().Lookup("Yield").(*types.Func))
yieldInstances := functionColors{}
if fns, ok := c.generics[yieldFunc]; ok {
for _, fn := range fns {
for fn := range functions {
if fn.Origin() == yieldFunc {
yieldInstances[fn] = fn.Signature
}
}
Expand Down
Loading