This is an experiment in static analysis of Go programs
to understand which struct fields a program might use.
It is not part of the Go language specification, it must
be enabled explicitly when building the toolchain,
and it may be removed at any time.
After building the toolchain with GOEXPERIMENT=fieldtrack,
a specific field can be marked for tracking by including
`go:"track"` in the field tag:
package pkg
type T struct {
F int `go:"track"`
G int // untracked
}
To simplify usage, only named struct types can have
tracked fields, and only exported fields can be tracked.
The implementation works by making each function begin
with a sequence of no-op USEFIELD instructions declaring
which tracked fields are accessed by a specific function.
After the linker's dead code elimination removes unused
functions, the fields referred to by the remaining
USEFIELD instructions are the ones reported as used by
the binary.
The -k option to the linker specifies the fully qualified
symbol name (such as my/pkg.list) of a string variable that
should be initialized with the field tracking information
for the program. The field tracking string is a sequence
of lines, each terminated by a \n and describing a single
tracked field referred to by the program. Each line is made
up of one or more tab-separated fields. The first field is
the name of the tracked field, fully qualified, as in
"my/pkg.T.F". Subsequent fields give a shortest path of
reverse references from that field to a global variable or
function, corresponding to one way in which the program
might reach that field.
A common source of false positives in field tracking is
types with large method sets, because a reference to the
type descriptor carries with it references to all methods.
To address this problem, the CL also introduces a comment
annotation
//go:nointerface
that marks an upcoming method declaration as unavailable
for use in satisfying interfaces, both statically and
dynamically. Such a method is also invisible to package
reflect.
Again, all of this is disabled by default. It only turns on
if you have GOEXPERIMENT=fieldtrack set during make.bash.
R=iant, ken
CC=golang-dev
https://golang.org/cl/6749064
The only code change is in exp/gotype/gotype.go.
The latest reviewed version of exp/types is now
exp/types/staging.
First step toward replacing exp/types with
exp/types/staging.
R=iant
CC=golang-dev
https://golang.org/cl/6819071
1. Prepend racefuncenter() to fn->enter -- fn->enter can contain new() calls,
and we want them to be in the scope of the function.
2. Dump fn->enter and fn->exit.
3. Add TODO that OTYPESW expression can contain interesting memory accesses.
4. Ignore only _ names instead of all names starting with _.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6822048
- simplified assignment checking by removing duplicate code
- implemented field lookup (methods, structs, embedded fields)
- importing methods (not just parsing them)
- type-checking functions and methods
- typechecking more statements (inc/dec, select, return)
- tracing support for easier debugging
- handling nil more correctly (comparisons)
- initial support for [...]T{} arrays
- initial support for method expressions
- lots of bug fixes
All packages under pkg/go as well as pkg/exp/types typecheck
now with pkg/exp/gotype applied to them; i.e., a significant
amount of typechecking works now (several statements are not
implemented yet, but handling statements is almost trivial in
comparison with typechecking expressions).
R=rsc
CC=golang-dev
https://golang.org/cl/6768063
Use wrapper functions to tell scheduler what we are doing.
With this patch, and a separate patch to the go tool, all the
cgo tests pass with gccgo.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6812058
* Use -fgo-pkgpath and -gccgopkgpath rather than -fgo-prefix
and -gccgoprefix.
* Define GOPKGPATH when compiling .c or .s files for gccgo.
* Use -fgo-relative-import-path.
* Produce .o files for gccgo, not .[568] files.
* Pass -E when linking if using cgo.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6820064
The idea is to (1) process ninit of all nodes,
and (2) put instrumentation of ninit into the nodes themselves (not the top-level statement ninit).
Fixes#4304.
R=golang-dev, rsc
CC=golang-dev, lvd
https://golang.org/cl/6818049
When local declarations needed unexported types, these could
be missing in the export data.
Fixes build with -gcflags -lll, except for exp/gotype.
R=golang-dev, rsc, lvd
CC=golang-dev
https://golang.org/cl/6813067
This should make the compiler emit errors specific to the bounds checking instead of overflow errors on the underlying types.
Updates #4232.
R=rsc
CC=golang-dev
https://golang.org/cl/6783054
This is an attempt at making the interaction between
these three constructs clearer. Specifically:
- return statements terminate a function, execute deferred
functions, return to the caller, and then execution
continues after the call
- panic calls terminate a function, execute deferred
functions, return to the caller, and then re-panic
- deferred functions are executed before a function _returns_
to its caller
The hope is that with this change it becomes clear when a
deferred function is executed (when a function returns),
and when it is not (when a program exits).
R=r, rsc, iant, ken, iant
CC=golang-dev
https://golang.org/cl/6736071
Incorrect cast was causing panics when
calling String() on dnsMsg with dnsRR_A
answers.
R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6818043
Plan 9 and Go's lib9/fmt disagree on whether %#x includes the 0x prefix
when printing 0, because ANSI C gave bad advice long ago.
Avoiding that case makes binaries compiled on different systems compatible.
R=ken2
CC=akumar, golang-dev
https://golang.org/cl/6814066
defined by the PLTE chunk. Such pixels decode to opaque black,
which matches what libpng does.
Fixes#4319.
On my reading, the PNG spec isn't clear whether palette index values
outside of those defined by the PLTE chunk is an error, and if not,
what to do.
Libpng 1.5.3 falls back to opaque black. png_set_PLTE says:
/* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead
* of num_palette entries, in case of an invalid PNG file that has
* too-large sample values.
*/
png_ptr->palette = (png_colorp)png_calloc(png_ptr,
PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color));
ImageMagick 6.5.7 returns an error:
$ convert -version
Version: ImageMagick 6.5.7-8 2012-08-17 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC
Features: OpenMP
$ convert packetloss.png x.bmp
convert: Invalid colormap index `packetloss.png' @ image.c/SyncImage/3849.
R=r
CC=golang-dev
https://golang.org/cl/6822065
Tailorings are represented by removing and reinserting entries from a linked list.
After all tailorings are done, missing weights are computed and verified.
This implementation assumes that entries that are used in expansions are not
reinserted at a later point. This considerably simplifies the implementation.
R=r
CC=golang-dev
https://golang.org/cl/6739052
incremental comparisons. Instead, processing is now done directly on colElems.
As a result, the size of the weights array is now reduced by 75%.
Details:
- Primary value of type 1 colElem is shifted by 1 bit so that primaries
of all types can be compared without shifting.
- Quaternary values are now stored in the colElem itself. This is possible
as quaternary values other than 0 or maxQuaternary are only needed when other
values are ignored.
- Simplified processWeights by removing cases that are needed for ICU but not
for us (our CJK primary values fit in a single value).
R=r
CC=golang-dev
https://golang.org/cl/6817054
I fixed a bug in gccgo that was causing it to only give an
error for the first package that was imported and not used.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6813058