]> Cypherpunks repositories - gostls13.git/commit
[dev.typeparams] cmd/compile: simplify variable capturing in unified IR
authorMatthew Dempsky <mdempsky@google.com>
Fri, 25 Jun 2021 08:54:50 +0000 (01:54 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Fri, 25 Jun 2021 14:32:28 +0000 (14:32 +0000)
commit1b60284c0a375de2349540771a3bc1a719ddf52e
tree3d39d8307c0471def2f2b63b66c73bb4e752a413
parent9fe7c38d3d7cd8a90e33515981dd00e1233563c9
[dev.typeparams] cmd/compile: simplify variable capturing in unified IR

While initially building out unified IR, I didn't have any indexing
scheme. Everything was written out in order. Consequently, if I wanted
to write A before B, I had to compute A before B.

One particular example of this is handling closure variables: the
reader needs the list of closure variables before it can start reading
the function body, so I had to write them out first, and so I had to
compute them first in a separate, dedicated pass.

However, that constraint went away a while ago. For example, it's now
possible to replace the two-pass closure variable capture with a
single pass. We just write out the function body earlier, but then
wait to write out its index.

I anticipate this approach will make it easier to implement
dictionaries: rather than needing a separate pass to correctly
recognize and handle all of the generics cases, we can just hook into
the existing logic.

Change-Id: Iab1e07f9202cd5d2b6864eef10116960456214df
Reviewed-on: https://go-review.googlesource.com/c/go/+/330851
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
src/cmd/compile/internal/noder/linker.go
src/cmd/compile/internal/noder/reader.go
src/cmd/compile/internal/noder/writer.go