aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/exp
AgeCommit message (Collapse)Author
2013-03-06exp/norm: delete, part of moving to go.textRob Pike
See also https://golang.org/cl/7520044 R=golang-dev, rsc CC=golang-dev https://golang.org/cl/7533044
2013-03-02exp: delete all packages except normRob Pike
They are moving to code.google.com/p/go.exp. See also https://golang.org/cl/7463043 R=golang-dev, minux.ma CC=golang-dev https://golang.org/cl/7456047
2013-03-01exp/ssa/interp: disable interp_test on non-POSIX.Alan Donovan
R=gri, rsc CC=golang-dev https://golang.org/cl/7422051
2013-03-01exp/ssa/interp: uncomment tests now passing thanks to recent typechecker fixes.Alan Donovan
Also: add support for pointer conversions, covered by one new test. R=gri, bradfitz, dave CC=golang-dev https://golang.org/cl/7435047
2013-03-01exp/ssa: fix bug in bridge methodAlan Donovan
Bridge methods for embedded interfaces were passing the interface twice: once as receiver, once as first param. Covered by $GOROOT/test/ddd.go. Also: - invent names ("arg%d") for parameters if missing. - refactoring: move common code for bridge methods into createParams and emitTailCall. R=gri CC=golang-dev https://golang.org/cl/7437047
2013-03-01net/http/cookiejar: move cookiejar from exp/cookiejar toNigel Tao
net/http/cookiejar. This is a straight rename. There are no code changes. Fixes #1960. R=rsc, adg CC=dr.volker.dobler, golang-dev https://golang.org/cl/7436043
2013-02-28go/types: fix type-checking of shift expressionsRobert Griesemer
Completely rethought shift expression type checking. Instead of attempting to type-check them eagerly, now delay the checking of untyped constant lhs in non- constant shifts until the final expression type becomes clear. Once it is clear, update the respective expression tree with the final (not untyped) type and check respective shift lhs' where necessary. This also cleans up another conundrum: How to report the type of untyped constants as it changes from untyped to typed. Now, Context.Expr is only called for an expresion x once x has received its final (not untyped) type (for constant initializers, the final type may still be untyped). With this CL all remaining std lib packages that did not typecheck due to shift errors pass now. TODO: There's a lot of residual stuff that needs to be cleaned up but with this CL all tests pass now. R=adonovan, axwalk CC=golang-dev https://golang.org/cl/7381052
2013-02-28exp/cookiejar: eliminate some "."+str garbage.Nigel Tao
It's not a big deal, but it's easy to fix. R=dsymonds CC=dr.volker.dobler, golang-dev https://golang.org/cl/7425043
2013-02-28exp/cookiejar: add some more testsVolker Dobler
New tests added for port handling and IDNA domains. A new test case contains several redundant tests but provides a nice documentation of the implemented rules for domain handling. R=nigeltao CC=golang-dev https://golang.org/cl/7393070
2013-02-27exp/ssa: fix *bsd breakage.Alan Donovan
Use portable ReadDirent, not linux Getdents. R=gri TBR=gri CC=golang-dev https://golang.org/cl/7405051
2013-02-27exp/ssa: a number of bug fixes.Alan Donovan
ssadump: - permit naming a package (not just *.go files) on command line. - set BuildSerially flag when setting Log* flags (Q. should instead the logging functions take a lock?) Builder: - fixed bug when calling variadic function with zero '...'-params. Added regression test. interp: - more external functions: the 'error' interface bytes.{Equal,IndexByte} reflect.(Value).{Bool,NumOut,Out} syscall.{Close,Fstat,Read,Open,Stat,Lstat,Fstat, Getdents,ParseDirents,Getwd} - permit comparisons between *Function and *closure. With this CL, ssadump can now interpret ssadump itself (!), loading, parsing, typing, SSA-building, and running println("Hello, World!"). While a fmt-based equivalent still lacks some external routines, e.g. math/big, I think there are diminishing returns in expanding the interpreter (and debugging it is starting to feel like "Inception"). I'm pretty confident this package is now good enough for wider use. R=gri CC=golang-dev https://golang.org/cl/7392053
2013-02-27exp/ssa: resolve botched merge.Alan Donovan
While submitting CL 7371051 I accidentally reverted much of CL 7395052. This change restores it. R=gri TBR=gri CC=golang-dev https://golang.org/cl/7364051
2013-02-27exp/ssa: make invokation of deferred procedure calls explicit.Alan Donovan
The correct semantics of named result parameters and deferred procedures cannot be implemented with the existing Ret instruction alone, since the required sequence is: (1) evaluate return operands and parallel-assign them to named result parameters (2) invoke deferred procedures (3) load named result parameters to form result tuple. We introduce a new 'rundefers' instruction that explicitly invokes the deferred procedure calls, and we generate code that follows the sequence above. Most functions do not use deferred procedures but this cannot be known in a single pass. So, we add an optimisation to eliminate redundant 'rundefers'; it is piggybacked on the existing pass done for "lifting". Added tests. R=gri CC=golang-dev https://golang.org/cl/7411043
2013-02-27exp/ssa: perform all packages' BUILD phases in parallel.Alan Donovan
Details: - move Builder.nTo1Vars into package => thread-safe. - add BuildSerially builder mode flag to disable concurrency. - add Builder.BuildAllPackages method. Benchmark: BuildAllPackages for $GOROOT/test/append.go drops to 83ms from 190ms (GOMAXPROCS=8). R=gri CC=golang-dev https://golang.org/cl/7371051
2013-02-27exp/locale/collate: fixed go vet error.Marcel van Lohuizen
R=r, dave CC=golang-dev https://golang.org/cl/7403055
2013-02-27exp/locale/collate: several changes based on comments on CL 7060051Marcel van Lohuizen
which was submitted earlier. R=r CC=golang-dev https://golang.org/cl/7402048
2013-02-27exp/cookiejar: add a test for canonicalHost errors.Nigel Tao
R=dr.volker.dobler CC=golang-dev https://golang.org/cl/7389048
2013-02-26go/types: be more robust in presence of multiple errorsRobert Griesemer
- better documentation of Check - better handling of (explicit) internal panics - gotype: don't stop after 1st error R=adonovan, r CC=golang-dev https://golang.org/cl/7406052
2013-02-26exp/ssa: support multiple labels on same statement.Alan Donovan
Actually it already worked since the spec only requires that the one immediately preceding a for/switch/... be usable as the target of a break or continue statement. Added a test. Also: allocate Function.lblocks on first use. R=gri CC=golang-dev https://golang.org/cl/7365058
2013-02-26exp/ssa: reimplement logic for field selection.Alan Donovan
The previous approach desugared the ast.SelectorExpr to make implicit field selections explicit. But: 1) it was clunky since it required allocating temporary syntax trees. 2) it was not thread-safe since it required poking types into the shared type map for the new ASTs. 3) the desugared syntax had no place to represent the package lexically enclosing each implicit field selection, so it was as if they all occurred in the same package as the explicit field selection. This meant unexported field names changed meaning. This CL does what I should have done all along: just generate the SSA instructions directly from the original AST and the promoted field information. Also: - add logStack util for paired start/end log messages. Useful for debugging crashes. R=gri CC=golang-dev https://golang.org/cl/7395052
2013-02-25go/types: fix sizeof computationsRobert Griesemer
Context.Alignof/Offsetsof/Sizeof now provide means to customize the type checker for a given platform. - provide Context.Offsetsof to specify the offsets of struct fields - use the correct sizes for ints, uint, uintptrs in constant computations - moved all size computations into separate file (sizes.go) - fixed a bug with string constant slicing R=adonovan, axwalk CC=golang-dev https://golang.org/cl/7363054
2013-02-26exp/cookiejar: implement IDNA/Punycode's toASCII.Nigel Tao
R=dr.volker.dobler CC=golang-dev https://golang.org/cl/7398049
2013-02-22exp/ssa: silence go vetRob Pike
R=adonovan CC=golang-dev https://golang.org/cl/7386052
2013-02-22exp/ssa: support variadic synthetic methods.Alan Donovan
We wrap the final '...' argument's type in types.Slice. Added tests. Also: - Function.writeSignature: suppress slice '[]' when printing variadic arg '...'. - Eliminate Package.ImportPath field; redundant w.r.t. Package.Types.Path. - Use "TODO: (opt|fix)" notation more widely. - Eliminate many redundant/stale TODOs. R=gri CC=golang-dev https://golang.org/cl/7378057
2013-02-22exp/ssa: fixed bug (typo) in findPromotedField.Alan Donovan
By appending to the wrong (always empty) list, only the last anonymous field was being considered for promotion. Also: - eliminated "function-local NamedTypes" TODO; nothing to do. - fixed Function.DumpTo: printing of anon receivers was "( T)", now "(T)"; extracted writeSignature into own function. - eliminated blockNames function; thanks to BasicBlock.String, "%s" of []*BasicBlock is fine. - extracted buildReferrers into own function. exp/ssa can now build its own transitive closure. R=gri CC=golang-dev https://golang.org/cl/7384054
2013-02-22exp/ssa: cross off a few remaining TODO issues.Alan Donovan
- append: nothing to do (nonsemantic change). - delete: now performs correct conversion (+ test). - emitCompare: nothing to do. - emitArith (shifts): nothing to do (+ test). - "banish untyped types": give up on that. - real, imag: now do correct conversions. - added comment to interp.go re zero-size values. R=gri CC=golang-dev https://golang.org/cl/7391046
2013-02-21exp/ssa/interp: fix build for Plan 9Anthony Martin
R=adonovan, minux.ma, alex.brainman, akumar, rminnich CC=golang-dev, lucio.dere https://golang.org/cl/7300078
2013-02-21unicode: use new Scanner interface in table creationRob Pike
Update norm and local/collate as well. R=mpvl CC=golang-dev https://golang.org/cl/7395045
2013-02-21exp/ssa/interp: (#6 of 5): test interpretation of SSA form of $GOROOT/test/*.go.Alan Donovan
The interpreter's os.Exit now triggers a special panic rather than kill the test process. (It's semantically dubious, since it will run deferred routines.) Interpret now returns its exit code rather than calling os.Exit. Also: - disabled parts of a few $GOROOT/tests via os.Getenv("GOSSAINTERP"). - remove unnecessary 'slots' param to external functions; they are never closures. Most of the tests are disabled until go/types supports shifts. They can be reenabled if you patch this workaround: https://golang.org/cl/7312068 R=iant, bradfitz CC=golang-dev, gri https://golang.org/cl/7313062
2013-02-21exp/ssa: add dedicated Panic instruction.Alan Donovan
By avoiding the need for self-loops following calls to panic, we reduce the number of basic blocks considerably. R=gri CC=golang-dev, iant https://golang.org/cl/7403043
2013-02-21exp/ssa: build fully pruned SSA form.Alan Donovan
Overview: Function.finish() now invokes the "lifting" pass which replaces local allocs and loads and stores to such cells by SSA registers. We use very standard machinery: (1) we build the dominator tree for the function's control flow graph (CFG) using the "Simple" Lengauer-Tarjan algorithm. (Very "simple" in fact: even simple path compression is not yet implemented.) In sanity-checking mode, we cross check the dominator tree against an alternative implementation using a simple iterative dataflow algorithm. This all lives in dom.go, along with some diagnostic printing routines. (2) we build the dominance frontier for the entire CFG using the Cytron et al algorithm. The DF is represented as a slice of slices, keyed by block index. See buildDomFrontier() in lift.go. (3) we determine for each Alloc whether it can be lifted: is it only subject to loads and stores? If so, we traverse the iterated dominance frontier (IDF) creating φ-nodes; they are not prepended to the blocks yet. See liftAlloc() in lift.go. (4) we perform the SSA renaming algorithm from Cytron et al, replacing all loads to lifted Alloc cells by the value stored by the dominating store operation, and deleting the stores and allocs. See rename() in lift.go. (5) we eliminate unneeded φ-nodes, then concatenate the remaining ones with the non-deleted instructions of the block into a new slice. We eliminate any lifted allocs from Function.Locals. To ease reviewing, I have avoided almost all optimisations at this point, though there are many opportunities to explore. These will be easier to understand as follow-up changes. All the existing tests (pending CL 7313062) pass. (Faster!) Details: "NaiveForm" BuilderMode flag suppresses all the new logic. Exposed as 'ssadump -build=N'. BasicBlock: - add .Index field (b.Func[b.Index]==b), simplifying algorithms such as Kildall-style dataflow with bitvectors. - rename the Name field to Comment to better reflect its reduced purpose. It now has a String() method. - 'dom' field holds dominator tree node; private for now. - new predIndex method. - hasPhi is now a method dom.go: - domTree: a new struct for a node in a dominator tree. - buildDomTree builds the dominator tree using the simple variant Lengauer/Tarjan algorithm with Georgiadis' bucket optimizations. - sanityCheckDomTree builds dominance relation using Kildall-style dataflow and ensures the same result is obtained. - printDomTreeDot prints the CFG/DomTree in GraphViz format. blockopt.go: - perform a mark/sweep pass to eliminate unreachable cycles; the previous prune() opt would only eliminate trivially dead blocks. (Needed for LT algo.) - using .Index, fuseblocks can now delete fused blocks directly. - delete prune(). sanity.go: more consistency checks: - Phi with missing edge value - local Alloc instructions must appear in Function.Locals. - BasicBlock.Index, Func consistency - CFG edges are all intraprocedural. - detect nils in BasicBlock.Instrs. - detect Function.Locals with Heap flag set. - check fn.Blocks is nil if empty. Also: - Phi now has Comment field for debugging. - Fixed bug in Select.Operands() (took address of temporary copy of field) - new Literal constructor zeroLiteral(). - algorithms steal private fields Alloc.index, BasicBlock.gaps to avoid allocating maps. - We print Function.Locals in DumpTo. - added profiling support to ssadump. R=iant, gri CC=golang-dev https://golang.org/cl/7229074
2013-02-20go/types: support for customizable Alignof, SizeofRobert Griesemer
(Offsetof is a function of Alignof and Sizeof.) - removed IntSize, PtrSize from Context (set Sizeof instead) - GcImporter needs a Context now (it needs to have access to Sizeof/Alignof) - removed exported Size field from Basic (use Sizeof) - added Offset to Field - added Alignment, Size to Struct R=adonovan CC=golang-dev https://golang.org/cl/7357046
2013-02-19go/types: include package import path in NamedType.String().Alan Donovan
This avoids ambiguity and makes the diagnostics closer to those issued by gc, but it is more verbose since it qualifies intra-package references. Without extra context---e.g. a 'from *Package' parameter to Type.String()---we are forced to err on one side or the other. Also, cosmetic changes to exp/ssa: - Remove package-qualification workaround in Function.FullName. - Always set go/types.Package.Path field to the import path, since we know the correct path at this point. - In Function.DumpTo, show variadic '...' and result type info, and delete now-redundant "# Type: " line. R=gri CC=golang-dev https://golang.org/cl/7325051
2013-02-19exp/README: update READMERobert Griesemer
R=golang-dev, dsymonds, bradfitz CC=golang-dev https://golang.org/cl/7323073
2013-02-19cmd/godoc: use go/build to determine package and example filesRobert Griesemer
Also: - faster code for example extraction - simplify handling of command documentation: all "main" packages are treated as commands - various minor cleanups along the way For commands written in Go, any doc.go file containing documentation must now be part of package main (rather then package documentation), otherwise the documentation won't show up in godoc (it will still build, though). For commands written in C, documentation may still be in doc.go files defining package documentation, but the recommended way is to explicitly ignore those files with a +build ignore constraint to define package main. Fixes #4806. R=adg, rsc, dave, bradfitz CC=golang-dev https://golang.org/cl/7333046
2013-02-19go/types: Use left-hand side's type as hint for right-handAndrew Wilkins
side expression evaluation in assignment operations. R=golang-dev, gri CC=golang-dev https://golang.org/cl/7349046
2013-02-19exp/cookiejar: store cookies under TLD+1 on nil public suffix listVolker Dobler
The current implementation would store all cookies received from any .com domain under "com" in the entries map if a nil public suffix list is used in constructing the Jar. This is inefficient. This CL uses the TLD+1 of the domain if the public suffix list is nil which has two advantages: - It uses the entries map efficiently. - It prevents a host foo.com to set cookies for bar.com. (It may set the cookie, but it won't be returned to bar.com.) A domain like www.british-library.uk may still set a domain cookie for .british-library.uk in this case. The behavior for a non-nil public suffix list is unchanged, cookies are stored under eTLD+1 in this case. R=nigeltao CC=golang-dev https://golang.org/cl/7312105
2013-02-18exp/cookiejar: make cookie sorting deterministic.Volker Dobler
Re-enable TestUpdateAndDelete, TestExpiration, TestChromiumDomain and TestChromiumDeletion on Windows. Sorting of cookies with same path length and same creation time is done by an additional seqNum field. This makes the order in which cookies are returned in Cookies deterministic, even if the system clock is manipulated or on systems with a low-resolution clock. The tests now use a synthetic time: This makes cookie testing reliable in case of bogus system clocks and speeds up the expiration tests. R=nigeltao, alex.brainman, dave CC=golang-dev https://golang.org/cl/7323063
2013-02-15exp/cookiejar: fix windows/386 buildRuss Cox
More mysteriously broken tests. TBR=nigeltao CC=golang-dev https://golang.org/cl/7342048
2013-02-15exp/cookiejar: fix windows builderRuss Cox
TBR=nigeltao CC=golang-dev https://golang.org/cl/7322084
2013-02-14go/parser: cleanups following CL 7307085Robert Griesemer
- use the new AllErrors flag where appropriate - unless AllErrors is set, eliminate spurious errors before they are added to the errors list (it turns out that reporting spurious errors always leads to too many uninformative errors after all) R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/7323065
2013-02-14exp/cookiejar: implement Cookies and provided testsVolker Dobler
This CL provides the implementation of Cookies and the complete test suite. Several tests have been ported from the Chromium project as a cross check. R=nigeltao, rsc, bradfitz CC=golang-dev https://golang.org/cl/7311073
2013-02-13go/types: adjust gcimporter to actual gc export dataRobert Griesemer
Unexported field and method names that appear in the export data (as part of some exported type) are fully qualified with a package id (path). In some cases, a package with that id was never exported for any other use (i.e. only the path is of interest). We must not create a "real" package in those cases because we don't have a package name. Entering an unnamed package into the map of imported packages makes that package accessible for other imports. Such a subsequent import may find the unnamed package in the map, and reuse it. That reused and imported package is then entered into the importing file scope, still w/o a name. References to that package cannot resolved after that. Was bug. R=adonovan CC=golang-dev https://golang.org/cl/7307112
2013-02-13exp/ssa: add Instruction.Operands and Value.Referrers methods.Alan Donovan
Operands returns the SSA values used by an instruction. Referrers returns the SSA instructions that use a value, for some values. These will be used for SSA renaming, to follow. R=iant, gri CC=golang-dev https://golang.org/cl/7312090
2013-02-12exp/ssa: omit Function's package name when printing intra-package references.Alan Donovan
R=iant CC=golang-dev https://golang.org/cl/7307105
2013-02-12exp/locale/collate: moved low-level collation functionalityMarcel van Lohuizen
into separate package. This allows this code to be shared with the search package without the need for these two to use the same tables. Adjusted various files accordingly. R=rsc CC=golang-dev https://golang.org/cl/7213044
2013-02-11go/types: len(((*T)(nil)).X) is const if X is an arrayRobert Griesemer
Fixes #4744. R=adonovan CC=golang-dev https://golang.org/cl/7305080
2013-02-11exp/ssa: special-case 'range' loops based on type of range expression.Alan Donovan
The lowering of ast.RangeStmt now has three distinct cases: 1) rangeIter for maps and strings; approximately: it = range x for { k, v, ok = next it if !ok { break } ... } The Range instruction and the interpreter's "iter" datatype are now restricted to these types. 2) rangeChan for channels; approximately: for { k, ok = <-x if !ok { break } ... } 3) rangeIndexed for slices, arrays, and *array; approximately: for k, l = 0, len(x); k < l; k++ { v = x[k] ... } In all cases we now evaluate the side effects of the range expression exactly once, per comments on http://code.google.com/p/go/issues/detail?id=4644. However the exact spec wording is still being discussed in https://golang.org/cl/7307083/. Further (small) changes may be required once the dust settles. R=iant CC=golang-dev https://golang.org/cl/7303074
2013-02-11exp/html, exp/html/atom: delete, as they're moving to the go.netNigel Tao
sub-repo. The matching change is at https://golang.org/cl/7310063 The rationale was discussed at https://groups.google.com/d/topic/golang-nuts/Qq5hTQyPuLg/discussion R=adg, dave CC=golang-dev https://golang.org/cl/7317043
2013-02-11exp/cookiejar: implementation of SetCookiesVolker Dobler
This CL provides the rest of the SetCookies code as well as some test infrastructure which will be used to test also the Cookies method. This test infrastructure is optimized for readability and tries to make it easy to review table driven test cases. Tests for all the different corner cases of SetCookies will be provided in a separate CL. R=nigeltao, rsc, bradfitz CC=golang-dev https://golang.org/cl/7306054