1
0
mirror of https://github.com/golang/go synced 2024-11-07 05:46:17 -07:00
Commit Graph

3980 Commits

Author SHA1 Message Date
Robert Griesemer
9d6717b260 go.tools/go/importer: handle predeclared types consistently
- pre-poluate typIndex and typList using a predefined list of types
- no need to handle basic types explicitly anymore
- removed basicTag
- go/types: exported UniverseByte and UniverseRune for now

LGTM=adonovan
R=adonovan
CC=cmang, golang-codereviews
https://golang.org/cl/65920044
2014-02-19 13:27:11 -08:00
Alan Donovan
aaa5866ea1 go.tools/go/loader: rename backdoor so only tests can use it.
Also: add copyright message.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/64040044
2014-02-19 13:52:19 -05:00
Alan Donovan
03ca00ddd4 go.tools/go/types/typeutil: new package for type utilities.
Contains the members formerly known as:
- ssa.IntuitiveMethodSet
- typemap.M (now: Map)

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/65670043
2014-02-19 13:32:36 -05:00
Alan Donovan
42022f89d4 go.tools/go/loader: add file missing from rev ebef51b726fc
(CL https://golang.org/cl/62540043)

TBR=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/65530046
2014-02-19 13:28:12 -05:00
Alan Donovan
0c9517ddba go.tools/go/pointer: assert that input program is complete.
Fixes golang/go#7257

LGTM=crawshaw
R=daniel.morsing, crawshaw
CC=golang-codereviews
https://golang.org/cl/65730045
2014-02-19 13:08:06 -05:00
Josh Bleecher Snyder
e8c291b808 go.tools/cmd/benchcmp: sort by original benchmark order by default
benchcmp now preserves benchmark order. This restores the original
misc/benchcmp behavior. This also makes the output of benchcmp stable,
and groups together multiple -cpu results.

Magnitude-based sorting is still available via the -mag flag.
It is useful for surfacing items of note (particularly changes
in allocs) when making compiler changes and running broad
benchmarks.

Fixes golang/go#7259.

LGTM=dave
R=dave, mtj
CC=bradfitz, dvyukov, golang-codereviews
https://golang.org/cl/60840045
2014-02-19 07:44:49 -08:00
Alan Donovan
ed45af74ff go.tools/go/loader: add AllowTypeErrors flag.
If this flag is set, (*Config).Load will not return an
error even if some packages had type errors.  Each individual
PackageInfo can be queried for its error state, now exposed as
TypeError.

In addition, each PackageInfo exposes whether it is
"transitively error-free".  ssa.Create skips packages without
this flag since it is required for SSA construction.

+ Test.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/62000045
2014-02-18 19:43:14 -05:00
Alan Donovan
5f96644dbf go.tools/pointer: opt: type-based label tracking reduces solver time by up to 75%.
Observation: not all alias facts are interesting.
- A channel-peers query also cares about pointers of kind chan.
- An oracle "points-to" query on an expression of kind map
  only cares about maps.
- We always care about func, interface and reflect.Value,
  since they're needed for sound analysis of dynamic dispatch.

We needn't bother collecting alias information for
uninteresting pointers, and this massively reduces the number
of labels flowing in to the constraint system.
The only constraints that create new labels are addressOf
and offsetAddr; both are now selectively emitted by type.

We compute the set of type kinds to track, based on the
{Indirect,}Query types.  (We could enable tracking at an
even finer grain if we want.)

This requires that we can see all the {Indirect,}Query
value types a priori, which is not the case for the PrintCalls
mechanism used in the tests, so I have rewritten the latter
to use {Indirect,}Query instead.

This reduces the solver-phase time for the entire standard
library and tests from >8m to <2m.  Similar speedups are
obtained on small and medium-sized programs.

Details:
- shouldTrack inspects the flattened form of a type to see if
  it contains fields we must track.  It memoizes the result.
- added precondition checks to (*Config).Add{,Indirect}Query.
- added (*ssa.Program).LookupMethod convenience method.
- added Example of how to use the Query mechanism.
- removed code made dead by a recent invariant:
  the only pointerlike Const value is nil.
- don't generate constraints for any functions in "reflect".
  (we had forgotten to skip synthetic wrappers too).
- write PTA warnings to the log.
- add annotations for more intrinsics.

LGTM=gri, crawshaw
R=crawshaw, gri
CC=golang-codereviews
https://golang.org/cl/62540043
2014-02-18 12:40:44 -08:00
Alan Donovan
675033b4f3 go.tools/go/ssa: fix nondeterministic computation of necessary method sets.
Method Signatures (types.Signatures with a non-nil receiver) behave
like ordinary func Signatures in the hash function/equivalence relation
used by typemap.M, which leads to surprising incomplete traversal
over the type graph if an M is used to remember types already
visited.

This change avoids ever putting method Signatures in a typemap.

% go test -v code.google.com/p/go.tools/go/ssa
now repeatedly shows the exact same number of functions and
instructions.

(We should discuss how to avoid this problem more generally.)

Also:
- recur over the params/results of all the methods of
  each type when computing necessary method sets.
- there's no longer any need to treat declarations of unexported
  methods as a root for traversal.  Added test case.
- enable SourceImports flag in stdlib_test, which was dropped
  during a recent refactoring (d'oh).
- doc tweaks

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/65450043
2014-02-18 12:39:29 -08:00
Alan Donovan
a75195d091 go.tools/go/ssa/interp: fix tests broken by recent runtime changes.
This CL adds no-op stubs for intrinsics now required by tests:
 	 runtime.Goexit
	 sync.runtime_Sem{acquire,release}
        sync/atomic.AddUint{32,64}
 	Goexit needs more thought; for now I've disabled the interpreted
       tests of the "testing" package to make the build green again.

TBR=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/65480044
2014-02-18 15:37:24 -05:00
Francesc Campoy
ca8198c132 go.tools/playground: parse shebang correctly
Fixes golang/go#7321.

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/63560043
2014-02-18 09:44:12 -08:00
David du Colombier
0b0cd8b22c go.tools/dashboard/builder: use $home on Plan 9
LGTM=alex.brainman
R=golang-codereviews, lucio.dere, alex.brainman
CC=golang-codereviews
https://golang.org/cl/64520043
2014-02-16 17:40:50 +01:00
Dave Cheney
a565a4ff67 go.tools/dashboard/builder: respect CGO_ENABLED value from the environment
Allow builder owners to set CGO_ENABLED to override the logic in cmd/go

LGTM=minux.ma, adg
R=golang-codereviews, minux.ma, adg
CC=golang-codereviews
https://golang.org/cl/63570046
2014-02-16 20:43:00 +11:00
Shenghou Ma
ddb496edf3 go.tools/dashboard/builder: use "hg archive -t files -r REV dest" instead of "hg clone" for the work directory.
It will save a lot of time for slow builders running on slow SD cards.

LGTM=dave, adg
R=golang-codereviews, dave, adg
CC=golang-codereviews
https://golang.org/cl/63550043
2014-02-13 20:50:29 -05:00
Andrew Gerrand
b277773706 go.tools/dashboard/app: tweak build column order
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/63590043
2014-02-14 11:35:50 +11:00
Andrew Gerrand
47596b4b81 go.tools/cmd/vet: add stable checks to doc.go
These are the simplest possible descriptions of each command.
They may be fleshed out later.

Fixes golang/go#7298.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/61480044
2014-02-13 11:05:01 +11:00
Alan Donovan
8c7a4539cd go.tools/pointer: implement (*reflect.rtype).MethodByName for abstract methods.
+ test.

LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/25810043
2014-02-12 12:45:55 -05:00
Brad Fitzpatrick
05bc285da4 cmd/goimports: update doc, remove old gofmt flags
Don't say the word "fork" (not accurate), and remove the
tab/comment flags that were removed from gofmt.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/61410052
2014-02-12 08:35:02 -08:00
Alan Donovan
d10dca34ca go.tools/ssa/interp: add several standard library packages to test suite.
- Add math.{Log,Ldexp} to externals
- Test now uses FromArgs
- Scan all initial packages for tests, don't assume Created[0] exists.
  (It doesn't if we import a package that has only in-package tests.)

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/62010044
2014-02-11 20:35:18 -05:00
Alan Donovan
b2557286bb go.tools/go/ssa/interp: improve "no such method" error.
LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/59740043
2014-02-11 18:15:10 -05:00
Alan Donovan
08fadac071 go.tools/go/loader: simplify command-line syntax.
Previously, each word could be a package import path or a
comma-separated list of *.go file names.  Now, if the
first word ends with ".go", all words are assumed to be
Go source files.  This makes it impossible to specify
two ad-hoc packages from source files, but no-one needs that.

FromArgs also takes a boolean indicating whether tests
are wanted or not.

Also: ssadump: add -test flag to set that boolean.
For the oracle it's always true.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/61470047
2014-02-11 16:52:16 -05:00
Alan Donovan
1f29e74bfa go.tools/go/types: remove Type.MethodSet() method.
Method-set caching is now performed externally using a MethodSetCache (if desired), not by the Types themselves.

This a minor deoptimization due to the extra maps, but avoids a situation in which method-sets are computed and frozen prematurely. (See b/7114)

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/61430045
2014-02-11 16:49:27 -05:00
Robert Griesemer
fc1d9c5505 go.tools/go/types: adjust 3-index slice tests
The parser is now checking the presence of the 2nd and 3rd
index of 3-index slice expressions. See also:

https://golang.org/cl/58950045/
http://golang.org/issue/7305

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/58500045
2014-02-11 13:40:59 -08:00
Alan Donovan
ee92efc193 go.tools/ssa: tweaks to CreateTestMainPackage.
Move mutation of program to the final step.
+ 2 assertions;
+ switches.go: comment fix.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/61510044
2014-02-11 15:59:20 -05:00
Alan Donovan
ddfef020d1 go.tools/go/ssa/interp: add missing case to fake reflect function.
LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/61410049
2014-02-11 15:36:41 -05:00
Andrew Gerrand
1a5e5b083b go.tools/godoc/redirect: remove race detector blog post redirect
Update golang/go#7275

LGTM=minux.ma, dvyukov
R=dvyukov, minux.ma
CC=golang-codereviews
https://golang.org/cl/60900044
2014-02-11 09:26:17 +11:00
Brad Fitzpatrick
a0c2140b91 imports: fix a case where we weren't gofmt-compatible
Because goimports also sorts stdlib-vs-external differently
(whereas gofmt just sorts string-wise), we need to put a blank
line between imports of different classes. This happened in
some cases, but not all.

Fixes golang/go#7132

LGTM=kamil.kisiel
R=golang-codereviews, kamil.kisiel
CC=golang-codereviews
https://golang.org/cl/60870047
2014-02-07 17:03:34 -08:00
Alan Donovan
b3dbe56610 go.tools/go/ssa: support 3-operand x[lo:hi:max] slices.
+ very basic test ($GOROOT/test/slice3.go needs unsafe.Pointer)

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/60030043
2014-02-05 17:54:51 -05:00
Robert Griesemer
c37c5f6f46 go.tools/go/types: internal cleanup (resolve a TODO)
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/59560046
2014-02-04 11:06:00 -08:00
Robert Griesemer
5351a1ccd2 go.tools/godoc: don't associate builtin nil with a type
Special case for (fake) package builtin: don't associate
any constant, variable, or factory function with a type.

Fixes golang/go#6645.

LGTM=bgarcia
R=bgarcia, r, bradfitz
CC=golang-codereviews
https://golang.org/cl/54820044
2014-02-04 10:26:38 -08:00
Robert Griesemer
20efc5ba73 go.tools/go/types: use init cycle tracking for all const and var cycles
Also rename types.Assertable -> types.AssertableTo per adonovan.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/59680044
2014-02-03 16:02:56 -08:00
Robert Griesemer
4dcaee97b2 go.tools/cmd/vet: use new Assertable predicate (fix build)
LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/59210045
2014-02-03 11:39:10 -08:00
Gordon Klaus
3e68d08251 go.tools/go/types: export Comparable and Assertable, simplify Implements
The "static bool" parameter to Implements was confusing; typically we think about interface implementation and type assertion as separate but related concepts, but here they were merged.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/58540044
2014-02-03 11:21:01 -08:00
Robert Griesemer
ed1b894ade go.tools/go/types: print cyles of recursive type declarations
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/59140043
2014-02-03 10:34:06 -08:00
Josh Bleecher Snyder
285f6fe2f6 go.tools/cmd/benchcmp: add benchcmp
This is intended to replace the awk-based misc/benchcmp.
It mostly matches the existing misc/benchcmp.
Notable changes:

* Written in Go.
* Minor whitespace changes in the output; the tabular nature of the
  output is preserved, as is most number formatting and verbiage.
* Comparisons within each section are sorted from highest change to lowest.
* Proper handling of multiple benchmarks with the same name (issue 7016).
* Does not omit benchmark comparisons for which the new value is zero.
* Adds -changed flag to only show benchmarks whose value have changed.
  Useful for memory-oriented, large-scale benchmark comparisons.
* Has tests.
* Formats small ns measurements with extra precision.

Updates golang/go#7016.

LGTM=r
R=golang-codereviews, dave, dvyukov, oleku.konko, bradfitz, gobot, r
CC=golang-codereviews
https://golang.org/cl/47980043
2014-01-31 15:39:59 -08:00
Robert Griesemer
caced9f304 go.tools/go/ssa: remove windows test exclusion
Issue 7189 was likely fixed with revision ed6ecfe1bc4e .

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/59230044
2014-01-31 15:31:10 -08:00
Robert Griesemer
91159eb214 go.tools/go/types: don't type-check methods twice
- Centralize "visited" check in check.objDecl.
- Assert that object-specific declX functions
are only called with objects that have no
type associated with them, yet.
- Added test case.

Thanks to Richard Musiol (neelance@gmail.com) for
finding the bug and providing an easy test case.

For a discussion of the bug see the issue.

Fixes golang/go#7245.

TBR=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/59210043
2014-01-31 15:12:05 -08:00
Alex Brainman
269daf307c go.tools/go/ssa: skip broken TestStdlib on windows
Update golang/go#7189

LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/49640049
2014-01-31 17:46:15 +11:00
Alex Brainman
69f7b061bd go.tools/go/ssa: stop if error in TestStdlib
Update golang/go#7189

LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/58910043
2014-01-31 17:30:37 +11:00
Brad Garcia
d682175c6e godoc: test fixes for recent cmdline changes.
Tests broken by:
https://code.google.com/p/go/source/detail?r=1666da2583f4&repo=tools

R=gri, adonovan
CC=golang-codereviews
https://golang.org/cl/58780043
2014-01-30 15:32:23 -05:00
Robert Griesemer
9cd9226d63 go.tools/go/types: fix type cycle tracking
Fixes golang/go#7236.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/58430043
2014-01-30 09:46:03 -08:00
Brad Garcia
f97ec06d2c godoc: forward /pkg/C links to /cmd/cgo.
Fixes golang/go#5651.

R=bradfitz
CC=golang-codereviews
https://golang.org/cl/58660043
2014-01-30 07:07:12 -05:00
Brad Garcia
2ca2bfc172 godoc: Fix commandline mode output.
Fix output of packages with multiple files.
Remove extra output when filter is requested.
Fixes golang/go#7115.

R=bradfitz, adg
CC=golang-codereviews
https://golang.org/cl/52750044
2014-01-30 06:28:19 -05:00
Robert Griesemer
bf4d636dc9 go.tools/go/types: cleanup handling of forward chains of underlying types
- consistently set underlying types of incoming named types in typInternal
- use underlying() helper function to resolve forward chains
- related consistency cleanups

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/53870044
2014-01-29 14:24:54 -08:00
Robert Griesemer
c4535ece1b go.tools/go/types: various cleanups - no semantic changes
- split resolver.go into resolver.go and decl.go
- renamed types.go -> type.go
- renamed objects.go -> object.go

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/58010043
2014-01-29 10:53:49 -08:00
Brad Garcia
efd232e270 godoc: set expvar for http.ResponseWriter errors.
R=bradfitz
CC=adg, golang-codereviews
https://golang.org/cl/56680044
2014-01-29 10:53:45 -05:00
Alan Donovan
744d7e68b1 go.tools/go/ssa: use bytes.Buffer instead of io.Writer.
This is (a) more efficient and (b) avoids the need for
constant error handling, since buffer writes can't fail.

Also:
- added WriteFunction and WritePackage functions,
  similar to types.WriteFoo.
- *Function and *Package now implement io.WriterTo.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/57930044
2014-01-28 17:48:10 -05:00
Robert Griesemer
83cdd9ba10 go.tools/go/types: export ConvertibleTo
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/57950043
2014-01-28 14:28:10 -08:00
Alan Donovan
d0efad3082 go.tools/go/ssa: use types.WriteSignature
LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/57930043
2014-01-28 17:04:41 -05:00
Alan Donovan
64ec206bfd go.tools/go/types: combine Info.{Types,Values} maps.
This results in significant improvement to type-checking time:
it reduces by 4% the entire running time of ssa/stdlib_test
(GOMAXPROCS=8, n=7).

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/57770043
2014-01-28 16:46:24 -05:00