In general, if a break or continue label is not found, we don't
know if a correspondingly named label was not declared, was declared
but is not visible, or will be declared (and won't be visible).
Complain about "invalid" rather than "not declared" label.
Added more tests.
R=adonovan
CC=golang-dev
https://golang.org/cl/14149043
Details:
- Warnings are reported as values in Result, not a callback in Config.
- remove TODO to eliminate Print callback. It's better than the alternative.
- remove unused Config.root field.
- hang Result off analysis object (impl. detail)
- reword TODO.
R=crawshaw
CC=golang-dev
https://golang.org/cl/14128043
This CL temporarily removes some preliminary label checks.
They will be implemented completely in a subsequent CL.
R=adonovan
CC=golang-dev
https://golang.org/cl/14055043
Motivation: simple constraints---copy and addr---are more
amenable to pre-solver optimizations (forthcoming) than
complex constraints: load, store, and all others.
In code such as the following:
t0 = new struct { x, y int }
t1 = &t0.y
t2 = *t1
there's no need for the full generality of a (complex)
load constraint for t2=*t1 since t1 can only point to t0.y.
All we need is a (simple) copy constraint t2 = (t0.y)
where (t0.y) is the object node label for that field.
For all "addressable" SSA instructions, we tabulate
whether their points-to set is necessarily a singleton. For
some (e.g. Alloc, MakeSlice, etc) this is always true by
design. For others (e.g. FieldAddr) it depends on their
operands.
We exploit this information when generating constraints:
all load-form and store-form constraints are reduced to copy
constraints if the pointer's PTS is a singleton.
Similarly all FieldAddr (y=&x.f) and IndexAddr (y=&x[0])
constraints are reduced to offset addition, for singleton
operands.
Here's the constraint mix when running on the oracle itself.
The total number of constraints is unchanged but the fraction
that are complex has gone down to 21% from 53%.
before after
--simple--
addr 20682 46949
copy 61454 91211
--complex--
offsetAddr 41621 15325
load 18769 12925
store 30758 6908
invoke 758 760
typeAssert 1688 1689
total 175832 175869
Also:
- Add Pointer.Context() for local variables,
since we now plumb cgnodes throughout. Nice.
- Refactor all load-form (load, receive, lookup) and
store-form (Store, send, MapUpdate) constraints to use
genLoad and genStore.
- Log counts of constraints by type.
- valNodes split into localval and globalval maps;
localval is purged after each function.
- analogous maps localobj[v] and globalobj[v] hold sole label
for pts(v), if singleton.
- fnObj map subsumed by globalobj.
- make{Function/Global/Constant} inlined into objectValue.
Much cleaner.
R=crawshaw
CC=golang-dev
https://golang.org/cl/13979043
Also update style.css to hide outline of editable text areas and apply
correct styles to line numbers in non-playground snippets.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13946043
The previous CL made the assumption that Root is the first
node, which is false for programs that import "reflect".
Reverted to the previous way: an explicit root field.
Added regression test (callgraph2) via oracle.
R=crawshaw
TBR=crawshaw
CC=golang-dev
https://golang.org/cl/13967043
Also: pointer.Analyze now returns a pointer.Result object,
containing the callgraph and the results of ssa.Value queries.
The oracle has been updated to use the new call and pointer APIs.
R=crawshaw, gri
CC=golang-dev
https://golang.org/cl/13915043
e.g. "oracle callgraph <package>"
Also: simplified error handling.
Eliminated oracle.errorf because it prepends "file:line:col: "
to the error message so the main function can't safely prepend "Error: ".
The position wasn't interesting though: it was just -pos, more or less.
R=crawshaw, dominik.honnef, r
CC=golang-dev
https://golang.org/cl/13864044
This package provides a simple abstraction of a call graph,
capable of representing context sensitive and insensitive
graphs. It also provides some basic utilities and algorithms.
This simplifies clients such as the oracle, and makes similar
clients (e.g. an offline version of the oracle) easier to write.
R=crawshaw, gri
CC=golang-dev
https://golang.org/cl/13901044
Downloading the GCC repo takes a lot of time and everything works fine if we just store it in the buildRoot and reuse it.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13583045
This CL is mostly a renaming s/json/serial/, abstracting the
oracle package away from any particular data syntax. (The
encoding/* machinery is very clean; clearly I should have
structured it this way from the outset.)
Supporting XML then becomes a one-liner in cmd/oracle/main.go.
Also: call MarshalIndent(), not Marshall() then Indent().
R=crawshaw
CC=golang-dev
https://golang.org/cl/13858046
This change adds a new build dashboard url to the existing appengine app: $dashurl/gccgo/ which will show the build status of gccgo.
* Added Dashboard struct with exported Name, Rel(ative)Path, and Packages fields.
* Added Dashboard Context method that returns an appengine context with a namespace corresponding to the dashboard's name.
* Modified HandlerFuncs to use Dashboard's Context method for all appengine requests.
* Modified ui template to show different title/header for separate dashboard and added dashboard tab.
R=adg
CC=golang-dev
https://golang.org/cl/13753043
This change affects the API: Func objects now always have a *Signature
as type (never a *Builtin). Instead, built-ins now appear as *Builtin
objects. Only the built-in name is exposed, other fields are now private
to go/types.
Several bugs are fixed:
- correctly checking for built-ins permitted in statement context
- expression statements that are calls are not type-checked twice anymore
- go/defer statements report call types and provide good error messages now
This CL will briefly break the build until CL 13848043 is submitted.
R=adonovan
CC=golang-dev
https://golang.org/cl/13813043
(reflect.Value).Send
(reflect.Value).TrySend
(reflect.Value).Recv
(reflect.Value).TryRecv
(reflect.Type).ChanOf
(reflect.Type).In
(reflect.Type).Out
reflect.Indirect
reflect.MakeChan
Also:
- specialize genInvoke when the receiver is a reflect.Type under the
assumption that there's only one possible concrete type. This
makes all reflect.Type operations context-sensitive since the calls
are no longer dynamic.
- Rename all variables to match the actual parameter names used in
the reflect API.
- Add pointer.Config.Reflection flag
(exposed in oracle as --reflect, default false) to enable reflection.
It currently adds about 20% running time. I'll make it true after
the presolver is implemented.
- Simplified worklist datatype and solver main loop slightly
(~10% speed improvement).
- Use addLabel() utility to add a label to a PTS.
(Working on my 3 yr old 2x2GHz+4GB Mac vs 8x4GHz+24GB workstation,
one really notices the cost of pointer analysis.
Note to self: time to implement presolver.)
R=crawshaw
CC=golang-dev
https://golang.org/cl/13242062
The existing standalone Query function builds an importer, ssa.Program, oracle,
and query position, executes the query and returns the result.
For clients (such as Frederik Zipp's web-based github.com/fzipp/pythia tool)
that wish to load the program once and make several queries, we now expose
these as separate operations too. Here's a client, in pseudocode:
o := oracle.New(...)
for ... {
qpos := o.ParseQueryPos(...)
res := o.Query(mode, qpos)
print result
}
NB: this is a slight deoptimisation in the one-shot case since we have to
build the entire SSA program with debug info, not just the query package,
since we now don't know the query package at that time.
The 'exact' param to ParseQueryPos needs more thought since its
ideal value is a function of the query mode. This will do for now.
Details:
- expose Oracle type, New() func and Query() method.
- expose QueryPos type and ParseQueryPos func.
- improved package doc comment.
- un-exposed the "needs" bits.
- added test.
R=crawshaw
CC=frederik.zipp, golang-dev
https://golang.org/cl/13810043
Full help is only displayed when -help is requested;
CLI usage errors just remind the the user of this flag.
R=r, crawshaw
CC=golang-dev
https://golang.org/cl/13523048
line2byte doesn't handle non utf-8 fileencoding. So added s:getpos().
And also, changing errorformat is not right way on go filetype.
Added range operations.
R=golang-dev, kamil.kisiel, dsymonds, dominik.honnef
CC=golang-dev
https://golang.org/cl/13656045
also:
- initial code for unused label errors
- some cleanups, better names
- additional tests
TODO: Dot-imported packages are not handled yet; i.e., they
are always considered used for now.
R=adonovan
CC=golang-dev
https://golang.org/cl/13768043
Godoc depends on go.talks/pkg/present by way of go.tools/pkg/blog.
Better to keep all godoc dependencies in one place.
R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/13656047
Also:
- added more tests
- removed Var.Used accessor: it's not meaningful for clients since
it does not reflect actual use/def information
- fixed position for short variable declaration errors
R=adonovan
CC=golang-dev
https://golang.org/cl/13240051