Go Pointer Analysis and Type Parameters #46
scott-cotton
started this conversation in
General
Replies: 1 comment
-
see golang/go#48525 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Type parameters in Go are enabled in tip. This will have a profound impact in many ways, and one of those ways is pointer analysis.
The current architecture of pal and its memory model are not yet ready for type parameters. For one things, we have decided to work on the golang/x/tools/go/ssa format, and this format does not yet support type parameters even though go@tip the language does.
For another thing, the memory model used by pal is fundamentally based on identifying contiguous memory for structured data. In Go 1.17, pre-type-parameters, contiguous memory for structured data is fairly easy to identify based on types. A struct's fields are (logically) contiguous in pal. An array's elements are contiguous, and this property is recursive: arrays of structs of arrays of .... are contiguous. (Pal does not handle alignment)
In whole program analysis, we could assume all type parameters are instantiated and use non-parametric types to determine such contiguous memory. But what of library code with type parameters? What if those parameters are instantiated with pointers or structures containing pointers?
These questions are the topic of this discussion. How might you think of pointer analysis in the presence of type parameters?
Beta Was this translation helpful? Give feedback.
All reactions