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

41427 Commits

Author SHA1 Message Date
Cherry Zhang
bd229936cf [dev.link] cmd/link: restore export data hash
With the previous CL, the export data will not change whether it
is compiled with -dynlink flag or not. Restore the export data
hash, and reenable plugin version check.

TODO: it may be still better to just generate a fingerprint for
each package at compile time.

Change-Id: I1f298ac97c3ab9b8d05d1c95e8be74d10ca7cd0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/201720
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-17 20:28:28 +00:00
Cherry Zhang
286d744246 [dev.link] cmd/compile: pass index through when re-exporting
When we re-export an imported symbol that has an index, we should
pass the index through. Currently, if the symbol is not
referenced in the generated machine code, it does not get
assigned a package index, and the exporter will not export its
symbol index. Let the exporter handle this case -- if the symbol
has a symbol index but not a package index, still export its
symbol index. This is safe as referenced-by-name symbols always
have their package indices set to a special value.

This should reduce the number of referenced-by-name symbols, and
also make the export data more stable, less dependent on codegen
details.

Change-Id: Ic515a002ae84226e7fdbe68a53496c051b7badcc
Reviewed-on: https://go-review.googlesource.com/c/go/+/201719
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-17 20:28:15 +00:00
Than McIntosh
b661547d94 [dev.link] cmd/link: new loader method for reading relocations in batch
Add a new loader.Relocs method that reads all of the relocations for a
symbol into a slice. Handy in cases where the client knows in advance
that it wants to visit all the relocations on a symbol (as opposed to
just one or two).

Change-Id: I1a420513e160c8bb4b90c9824ae8d5b5de060c15
Reviewed-on: https://go-review.googlesource.com/c/go/+/201721
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-10-17 20:08:33 +00:00
Than McIntosh
6ecaae0325 [dev.link] cmd/link: remove unused slow paths from BytesAt/StringAt
This change removes the NewReader function (no longer used by objdump)
and prunes away the now unused code paths from Reader.BytesAt and
Reader.StringAt, which helps with performance. At the moment the
reader operates by always ingesting the entire object file (either via
direct read or by mmap), meaning that there will always be a slice
available for us to index into.

Change-Id: I3af7396effe19e50ed594fe8d82fd2d15465687c
Reviewed-on: https://go-review.googlesource.com/c/go/+/201437
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-10-17 14:20:15 +00:00
Than McIntosh
e5acb58c39 [dev.link] cmd/objdump: switch to using NewReaderFromBytes
Convert the object file dumper to use NewReaderFromBytes when
reading new object files, as opposed to NewReader.

Change-Id: I9f5e0356bd21c16f545cdd70262e983a2ed38bfc
Reviewed-on: https://go-review.googlesource.com/c/go/+/201441
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-10-17 14:20:08 +00:00
Than McIntosh
6cbf37b30b [dev.link] cmd/link: record go.itablink symbols during object file read
Change the new loader to keep a note of the set of "go.itablink.*"
symbols (using a small map), and add a method that clients can use to
query whether a given global index corresponds to a "go.itablink.*"
sym. This eliminates one instance of raw symbol name reading/matching
during new deadcode, which should produce a minor speedup.

Change-Id: I5915773a3f33c16099ccd68592dbba783d909bc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/201400
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-10-17 14:20:00 +00:00
Than McIntosh
8011051361 [dev.link] cmd: add flag to mark gotype symbols
Add a flag bit to mark symbols in the new object file as containing Go
type information. The use of a flag eliminates the need to do symbol
name matching as part of the new dead code elimination pass, which
should produce a minor speedup.

Change-Id: Iec8700e1139e2c4e310644c0766379865d2d6f82
Reviewed-on: https://go-review.googlesource.com/c/go/+/201399
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-10-17 14:18:37 +00:00
Than McIntosh
15634a0230 [dev.link] cmd: convert symbol "shared" flag to object file flag
For the new object file format, don't tag individual symbols with a
"shared" flag, since that characteristic is better off as an attribute
of the containing object file as opposed to the individual symbol. Add
a new flags field in the object file header and put a bit in the flags
if the shared flags is in effect during compilation.

Change-Id: I2cf6d33bf7bf2fd8a7614ae0cd6ef03914777498
Reviewed-on: https://go-review.googlesource.com/c/go/+/201398
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-10-17 14:18:28 +00:00
Cherry Zhang
2bbf2e0233 [dev.link] cmd/link: add basic shared library support in newobj mode
This CL adds basic shared library support in newobj mode. This is
not complete -- there are still tests in misc/cgo/testshared
failing. But at least a simple program works, and some tests
there pass.

Add the mechanism of loading external symbols with contents.
(Before, external symbols are always contentless.) This may
potentially be also used for other host objects.

Change-Id: I68dbf71e7949cc01ebf37ea159084e798ae16925
Reviewed-on: https://go-review.googlesource.com/c/go/+/201537
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-10-16 22:28:18 +00:00
Cherry Zhang
5caac2f73e [dev.link] cmd: default to new object files
Switch the default to new object files.

Internal linking cgo is disabled for now, as it does not work yet
in newobj mode.

Shared libraries are also broken.

Disable some tests that are known broken for now.

Change-Id: I8ca74793423861d607a2aa7b0d89a4f4d4ca7671
Reviewed-on: https://go-review.googlesource.com/c/go/+/200161
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-10-16 15:57:07 +00:00
Than McIntosh
c9470b0483 [dev.link] cmd/link/internal/objfile: relocate loader to new package
Third change of several to update the loader API to reflect the final
consensus version of the loader API as described in Cherry's doc.
This piece:

   - move objfile.Loader into its own separate package, and update
     clients accordingly.

This includes a few minor cleanups, including converting a couple
of loader-related functions to methods, and privatizing some of the
loader methods such as ToGlobal/ToLocal.

Change-Id: Iae20585751a45491d8b19dcffc096aadae6bbfc6
Reviewed-on: https://go-review.googlesource.com/c/go/+/200998
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-16 13:24:55 +00:00
Cherry Zhang
4a9b30cfc9 [dev.link] cmd/internal/goobj2: provide accessor methods for flags
Per Jeremy's comment in CL 199643. This makes the code read
better.

Change-Id: If270aecd712a27fb52e3faf5a4339200327d9ffe
Reviewed-on: https://go-review.googlesource.com/c/go/+/201023
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-10-15 19:00:07 +00:00
Cherry Zhang
7256f50065 [dev.link] cmd/link: let cgo import overwrite contentless data symbol
A contentless data symbol may be a declaration of a cgo-imported
variable, e.g.

	//go:cgo_import_dynamic xxx
	var xxx uintptr

In this case, we want to mark the symbol imported, instead of
defined with zero value.

We used to load cgo directives before loading the object file, so
we'll mark the symbol SDYNIMPORT first. But in newobj mode,
currently we load cgo directives later. Letting SDYNIMPORT
overwrite contentless data symbol makes it work in both ordering.

Change-Id: I878f52086d6cdb5a347669bf8f848a49bce87b52
Reviewed-on: https://go-review.googlesource.com/c/go/+/201020
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-10-15 19:00:00 +00:00
Cherry Zhang
5fec788239 [dev.link] cmd/link: add dupok symbols resolved to another package to textp
When a dupok symbol is resolved to another package, we still need
to record its presence in the current package, as the trampoline
pass expects packages are laid out in dependency order. At the
point after deadcode where we populate symbol contents for
reachable symbols (add relocations and read symbol data), make a
note of the dupok text symbols for each package. Later in
addToTextp we will visit packages in dependency order, process
the dup text symbol list for each package and select a final lib
for each dup text symbol.

Change-Id: Ib885e0a7e2343229d853aa629e3e337111df6011
Reviewed-on: https://go-review.googlesource.com/c/go/+/200797
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-15 18:59:52 +00:00
Cherry Zhang
6ba3ae9ca5 [dev.link] cmd/internal/obj, cmd/link: add InlTree in new object files
Add InlTree to the FuncInfo aux symbol in new object files.

In the linker, change InlinedCall.Func from a Symbol to a string,
as we only use its Name. (There was a use of Func.File, but that
use is not correct anyway.) So we don't need to create a Symbol
if not necessary.

Change-Id: I38ce568ae0934cd9cb6d0b30599f1c8d75444fc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/200098
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-15 18:56:08 +00:00
Cherry Zhang
dab05a0484 [dev.link] cmd/link: implement symbol overwrite logic
If two defined symbols have the same name, one contentless and
one with content, the one with content "wins". This is mainly for
go:linkname on data symbols. Support this logic in newobj mode.

Introduce an "overwrite" mechanism, letting one symbol overwrite
another. This machanism could later be used for the linker
overwriting symbol contents (e.g. -X flag).

Change-Id: I32ee7d4b82df275f11b38c3abefc99b878ff12d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/200097
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-15 18:55:59 +00:00
Cherry Zhang
27111e5fec [dev.link] cmd/internal/obj, cmd/link: use aux symbol for DWARF symbols
Use the auxiliary symbol mechanism to connect the text symbol and
its associated DWARF symbols. This way, the linker can track the
DWARF symbols from the text symbol, without looking up special
names.

Currently, in the linker this is only used in the deadcode pass
to track which DWARF symbols are used and need to load. Later
passes still use name lookup for now.

Change-Id: I2fe49f3b1f0ecc1472ae8aa93907cff740022d8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/199801
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-15 18:55:48 +00:00
Cherry Zhang
cab29ebd84 [dev.link] cmd/link: create sym.Symbols after deadcode in newobj mode
With the new object files, now we can run the deadcode pass on
indices instead of Symbol structs, so we can delay creating
Symbols after the deadcode pass. Then we only need to create
reachable symbols.

Not create Symbols in LoadNew and LoadRefs, and recombine
LoadReloc into LoadFull.

Split loadcgo into two parts: the first finds root symbols, the
second create Symbols and sets attributes. The first runs before
the deadcode pass, while the second runs after.

TODO: currently there are still symbols that are not marked
reachable but still used. This includes DWARF symbols, file
symbols, and type symbols that are referenced by DWARF symbols.
We still need to create them (conservatively).

Change-Id: I695779c9312be9d49ab1683957ac3e72e1f65a1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/199643
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-15 18:55:32 +00:00
Cherry Zhang
90fe9c7c5c [dev.link] cmd/internal/obj: convert "\" to "/" in file path
The old code does this. Do the same.

Change-Id: Ibf32ac347d6425e19ad0bc664c6b43ab5eba9c5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/201022
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-15 17:13:55 +00:00
Cherry Zhang
928623ca95 [dev.link] cmd/internal/goobj2: separate Autolib from Pkglist in new object file
In CL 196030 we decided to combine the imported package list
(Autolib) and referenced package list (PkgIdx, or Pkglist).
However, in some cases the Autolib list may contain file name,
instead of package path, e.g.
https://go.googlesource.com/go/+/refs/heads/dev.link/src/cmd/compile/internal/gc/main.go#1181
And the linker needs that to locate the file. This mostly happens
with direct invocation of the compiler and linker (i.e., not
through "go build").

Instead of letting the linker make guess of the file name based
on the package path, make Autolib a separate list.

Change-Id: If195a69462d04db515346ee67cdec925f5a69e2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/200157
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-10-14 22:28:25 +00:00
Cherry Zhang
cfa421c9a6 [dev.link] cmd/link: on AIX, use relocation to locate target symbol from TOC symbol
On AIX, a TOC symbol always has a relocation to its target symbol.
Instead of using name lookup to locate the target symbol, we can
just use the relocation.

Using name lookup, besides being less efficient, needs to provide
the right symbol version. In this particular case, we are looking
for a data symbol so it is almost always version 0. But in case
that it is a text symbol, we may get an ABIALIAS symbol, which
does not have its Sect set.

Change-Id: I1ecfd284b04a86bbbc450059ee89d99d40493e51
Reviewed-on: https://go-review.googlesource.com/c/go/+/201019
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-14 17:05:51 +00:00
Cherry Zhang
c9f633487b [dev.link] cmd/internal/obj: sort ctxt.Data on AIX
On AIX, TOC symbols may be created and added to ctxt.Data
concurrently. To ensure reproducible builds, sort ctxt.Data.
This implements the same logic as WriteObjFile does for old
object files.

Change-Id: I2e6e2d7755352848981544a4fb68b828a188c2ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/201021
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-14 16:47:02 +00:00
Cherry Zhang
d6535415fb [dev.link] cmd/link: support reflect.Type.Method tracking in deadcode2
When reflect.Type.Method is called, all exported methods from a
reachable type need to be conservatively live. When such a
function is called, the compiler sets an attribute to the
function, and the linker needs to check that attribute. Implement
this in the index-based deadcode pass.

Unify symbol flags and FuncInfo flags to make things simpler. In
particular, the deadcode pass can check the reflectMethod
attribute without reading in and decoding FuncInfo.

Change-Id: Ibb21e172f2996e899c6efa5551a29d0eca62df67
Reviewed-on: https://go-review.googlesource.com/c/go/+/200099
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-14 15:55:52 +00:00
Cherry Zhang
7d6f79e617 [dev.link] cmd/link: implement live method tracking in deadcode2
This essentially replicates the logic of live method tracking and
type symbol decoding, rewritten to operate on indices instead of
Symbols.

TODO: the special handling of reflect.Type.Method has not been
implemented.

TODO: the symbol name is used too much. It ought to be a better
way to do it.

Change-Id: I860ee7a506c00833902e4870d15aea698a705dd9
Reviewed-on: https://go-review.googlesource.com/c/go/+/199078
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-14 14:29:03 +00:00
Jeremy Faller
cc21e4d130 [dev.link] cmd/link: move macho host files to new loader format
Change-Id: I823b19c0742992dd760c6372428a1936bb7c7e70
Reviewed-on: https://go-review.googlesource.com/c/go/+/200768
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-14 14:03:56 +00:00
Cherry Zhang
24f9238b95 [dev.link] all: merge branch 'master' into dev.link
Clean merge.

Change-Id: If9bfb0f27f41563fd5d386de9c1081542c3ce498
2019-10-11 14:07:53 -04:00
Ian Lance Taylor
426bfbe9a3 runtime: move sighandler into signal_unix.go
We couldn't do this before because sighandler was compiled for nacl.

Updates #30439

Change-Id: Ieec9938b6a1796c48d251cd8b1db1a42c25f3943
Reviewed-on: https://go-review.googlesource.com/c/go/+/200739
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-11 17:28:42 +00:00
Alex Buchanan
df380693f3 mime/multipart: add Part.NextRawPart to avoid QP decoding
NextPart has automatic handling of quoted-printable encoding,
which is sometimes undesirable. NextRawPart adds a method
for reading a part while bypassing such automatic handling.

Fixes #29090

Change-Id: I6a042a4077c64091efa3f5dbecce0d9a34ac7065
Reviewed-on: https://go-review.googlesource.com/c/go/+/152877
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-10-11 17:03:37 +00:00
Constantin Konstantinidis
a08cb9f473 net/mail: added support to trailing CFWS in date
RFC 5322 date format allows CFWS after the timezone.
If CFWS is valid, it is discarded and parsing is done as before
using time.Parse().
Existing test is extended with limit cases and invalid strings.

Fixes #22661

Change-Id: I54b96d7bc384b751962a76690e7e4786217a7941
Reviewed-on: https://go-review.googlesource.com/c/go/+/117596
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-10-11 16:35:39 +00:00
Francesco Renzi
ba108c93b8 encoding/json: add Decoder.InputOffset for offset access
This makes Decoder.offset public while renaming it to
Decoder.InputOffset to match encoding/xml Decoder API

Code changes made by Adam Stankiewicz [sheerun@sher.pl]

Fixes #29688

Change-Id: I86dbfd2b2da80160846e92bfa580c53d8d45e2db
Reviewed-on: https://go-review.googlesource.com/c/go/+/200677
Run-TryBot: Johan Brandhorst <johan.brandhorst@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-10-11 16:34:01 +00:00
Michael Munday
ac8966aa58 cmd/compile/internal/ssa: fix block AuxIntType lookup
Avoid an out-of-range error when calling LongString on a generic
block.

Change-Id: I33ca88940d899bc71e3155bc63d2aa925cf83230
Reviewed-on: https://go-review.googlesource.com/c/go/+/200737
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2019-10-11 16:30:20 +00:00
Than McIntosh
9036351dd7 [dev.link] cmd/link/internal/objfile: update deadcode2 to use new reloc hooks
Update the new deadcode pass to use the revised loader interface
for querying relocations. Remove some of the previous loader relocation
methods, since they are no longer used.

Change-Id: I08cec4c05793a17698b2674068f64837a5bf4477
Reviewed-on: https://go-review.googlesource.com/c/go/+/200718
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-10-11 15:08:12 +00:00
Than McIntosh
0b25ab5d96 [dev.link] cmd/link/internal/objfile: new loader method for reloc queries
Second change of several to update the loader API to reflect the final
consensus version of the loader API as described in Cherry's doc.
This piece:

 - define new loader.Relocs() method that returns a struct
   encapsulating a set of relocations on a global symbol

Old way of examining relocations:

  nreloc := loader.NReloc(someGlobalSymbolIndex)
  for i := 0; i < nreloc; i++ {
    tgtIdx := loader.RelocSym(someGlobalSymbolIndex, i))
    ... <do something with tgtIdx>
  }

New way of examining relocations:

  relocs := d.loader.Relocs(someGlobalSymbolIndex)
  for i := 0; i < relocs.Count; i++ {
    r := relocs.At(i).Sym
    ... <do something with r.Sym>
  }

Change-Id: I5bead1d729655ea13b3396647e53aafcd3e60f97
Reviewed-on: https://go-review.googlesource.com/c/go/+/200717
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-10-11 15:06:34 +00:00
Emmanuel T Odeke
1627714cd5 test/fixedbugs: bump issue21576.go's timeout to 1min
Increases the exec timeout from 5sec to 1min, but
also print out the error value on any test failure.

Fixes #34836

Change-Id: Ida2b8bd460243491ef0f90dfe0f978dfe02a0703
Reviewed-on: https://go-review.googlesource.com/c/go/+/200519
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-10-11 15:05:18 +00:00
fenos
2ac8f799d8 crypto/tls: consistently use %v for error formatting
We should keep a consistent way of formatting errors
in this file.

Fixes #34848

Change-Id: Ibb75908504f381fccab0281a42e788ef8c716b6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/200679
Run-TryBot: Johan Brandhorst <johan.brandhorst@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2019-10-11 14:23:52 +00:00
davidsbond
b421b85841 errors: fix typo in TODO comment
Fixes #34846
Change-Id: I24b3e65fc96ec85b2821480e9396c9d1663611c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/200678
Run-TryBot: Johan Brandhorst <johan.brandhorst@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Johan Brandhorst <johan.brandhorst@gmail.com>
2019-10-11 13:33:01 +00:00
Bryan C. Mills
d189bdd684 internal/reflectlite: skip TestMirrorWithReflect reflect package source is unavailable
Fixes #34847

Change-Id: Ibb58c8820cdab8b9f3755fcfba754ad0c9ca982f
Reviewed-on: https://go-review.googlesource.com/c/go/+/200657
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Elias Naur <mail@eliasnaur.com>
2019-10-11 13:25:59 +00:00
Agniva De Sarker
d0f10a6e68 runtime,internal/bytealg: optimize wasmZero, wasmMove, Compare
Coalesce set/get pairs into a tee.

Change-Id: I88ccdcb148465615437bebf24145e941a037e0a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/200357
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Richard Musiol <neelance@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-10-11 04:00:35 +00:00
Brad Fitzpatrick
03ef105dae all: remove nacl (part 3, more amd64p32)
Part 1: CL 199499 (GOOS nacl)
Part 2: CL 200077 (amd64p32 files, toolchain)
Part 3: stuff that arguably should've been part of Part 2, but I forgot
        one of my grep patterns when splitting the original CL up into
        two parts.

This one might also have interesting stuff to resurrect for any future
x32 ABI support.

Updates #30439

Change-Id: I2b4143374a253a003666f3c69e776b7e456bdb9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/200318
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-10-10 22:38:38 +00:00
Cherry Zhang
e44dfa1f2b [dev.link] cmd/link: escape package path in objByPkg map
The package references recorded in the object file, which are
obtained from the compiler, are escaped. We should also use the
escaped package paths in the linker for resolving package
references.

Change-Id: I42eb12df6ff24330e6dc7bed1dc8224bb3b8a106
Reviewed-on: https://go-review.googlesource.com/c/go/+/200158
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-10 22:06:28 +00:00
Cherry Zhang
0108b54a3d [dev.link] cmd/internal/goobj: replace "". with package prefix in newobj mode
This is the behavior of the old code. Do the same.

Change-Id: I3d393d754dcbdb7e76a577252a94214d2e316651
Reviewed-on: https://go-review.googlesource.com/c/go/+/200159
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-10 22:05:44 +00:00
Cherry Zhang
ffca64dcf3 [dev.link] cmd/internal/obj: support -S flag in newobj mode
When the compiler's -S flag is specified, it dumps the
disassembly. Add this when writing the new style object file.

Change-Id: I4cf85e57d22d0ceea1fda6d3b59fe363573659e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/200100
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-10 22:05:21 +00:00
Cherry Zhang
8a9be4921a [dev.link] cmd/link: use index for deadcode
Switch the deadcode pass to use indices instead of Symbol
structures when using new object file format. Delay loading
symbol relocations and contents fully after the deadcode pass.
The next step is not to create Symbol structures until deadcode
is done.

Method tracking logic hasn't been implemented. Currently, all
methods of a reachable type are live.

Change-Id: Iffcd06ff84e6e52bd9eb24d1220d94234d18ab6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/198199
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-10 22:05:09 +00:00
Brad Fitzpatrick
6dc740f092 test: adjust a test to work with js/wasm's background goroutine
Fixes #34768

Change-Id: Ic73591f620cdee5bc7203483902e6ba98d2c442b
Reviewed-on: https://go-review.googlesource.com/c/go/+/200438
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-10-10 19:38:06 +00:00
alan
26ff21d44d runtime: remove no-op pointer writes in treap rotations
Change-Id: If5a272f331fe9da09467efedd0231a4ce34db0f8
GitHub-Last-Rev: 4b81a79a92
GitHub-Pull-Request: golang/go#28420
Reviewed-on: https://go-review.googlesource.com/c/go/+/144999
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2019-10-10 19:24:35 +00:00
Than McIntosh
f7659d49be [dev.link] cmd/link/internal/objfile: new 'Sym' type for global symbol index
First change of several to update the loader API to reflect the final
consensus version of the loader API as described in Cherry's doc.

This piece:

 - define new loader.Sym type to encapsulate a global symbol
   index (as opposed to just using 'int')

Change-Id: I6f6483e269f80abfc7d373b2856b2c0d61b9ac24
Reviewed-on: https://go-review.googlesource.com/c/go/+/200417
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2019-10-10 19:21:40 +00:00
Jay Conrod
68395a66f9 cmd/go: forbid module pattern 'all' when outside a module
Also, in cmd/doc, avoid calling 'go list -m all' when in module mode
outside a module since it's now an error.

Fixes #32027

Change-Id: I7224c7fdf7e950bce6c058ab2a5837c27ba3b899
Reviewed-on: https://go-review.googlesource.com/c/go/+/200297
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-10-10 19:07:50 +00:00
Jeremy Faller
46b7557836 cmd/compile: walk progs to generate debug_lines data
Walking the progs is simpler than using the is_stmt symbol shenanigans.
This is a reinstatement of CL 196661, which was rolled back due to tests
failing. Unlike that original CL, this change should output the same
debug_lines data the original approach wrote.

The stats for JUST this CLC, note teh small speedup in compilation, and
the lack of difference in binary size.

name                      old time/op       new time/op       delta
Template                        229ms ± 4%        218ms ± 1%  -4.95%  (p=0.000 n=10+8)
Unicode                        92.6ms ± 9%       88.6ms ±13%    ~     (p=0.089 n=10+10)
GoTypes                         850ms ± 2%        831ms ± 4%  -2.23%  (p=0.009 n=10+10)
Compiler                        3.99s ± 1%        3.93s ± 1%  -1.29%  (p=0.000 n=10+9)
SSA                             13.7s ± 1%        13.7s ± 1%    ~     (p=0.912 n=10+10)
Flate                           140ms ± 3%        138ms ± 3%  -1.90%  (p=0.009 n=10+10)
GoParser                        172ms ± 2%        169ms ± 4%    ~     (p=0.095 n=9+10)
Reflect                         530ms ± 3%        516ms ± 5%    ~     (p=0.052 n=10+10)
Tar                             202ms ± 1%        196ms ± 3%  -2.83%  (p=0.002 n=9+10)
XML                             280ms ± 3%        270ms ± 4%  -3.48%  (p=0.009 n=10+10)
LinkCompiler                    927ms ± 2%        907ms ± 4%    ~     (p=0.052 n=10+10)
ExternalLinkCompiler            1.97s ± 2%        1.97s ± 3%    ~     (p=0.853 n=10+10)
LinkWithoutDebugCompiler        549ms ± 3%        543ms ± 5%    ~     (p=0.481 n=10+10)
StdCmd                          12.0s ± 1%        12.0s ± 1%    ~     (p=0.905 n=9+10)

name                      old user-time/op  new user-time/op  delta
Template                        372ms ±18%        344ms ±11%    ~     (p=0.190 n=10+10)
Unicode                         264ms ±23%        241ms ±43%    ~     (p=0.315 n=8+10)
GoTypes                         1.56s ±22%        1.68s ± 5%    ~     (p=0.237 n=10+8)
Compiler                        7.41s ± 2%        7.31s ± 3%    ~     (p=0.123 n=10+10)
SSA                             24.5s ± 2%        24.7s ± 1%    ~     (p=0.133 n=10+9)
Flate                           199ms ± 6%        188ms ±28%    ~     (p=0.353 n=10+10)
GoParser                        243ms ±11%        240ms ± 6%    ~     (p=0.968 n=10+9)
Reflect                         929ms ±21%        862ms ±35%    ~     (p=0.190 n=10+10)
Tar                             284ms ± 9%        296ms ±17%    ~     (p=0.497 n=9+10)
XML                             386ms ±21%        398ms ±28%    ~     (p=1.000 n=9+10)
LinkCompiler                    1.13s ± 9%        1.12s ± 8%    ~     (p=0.546 n=9+9)
ExternalLinkCompiler            2.37s ±15%        2.30s ± 9%    ~     (p=0.549 n=10+9)
LinkWithoutDebugCompiler        646ms ±10%        642ms ±13%    ~     (p=0.853 n=10+10)

name                      old alloc/op      new alloc/op      delta
Template                       36.5MB ± 0%       36.5MB ± 0%  -0.11%  (p=0.000 n=10+9)
Unicode                        28.5MB ± 0%       28.5MB ± 0%    ~     (p=0.190 n=10+10)
GoTypes                         121MB ± 0%        121MB ± 0%  -0.10%  (p=0.000 n=9+10)
Compiler                        549MB ± 0%        549MB ± 0%  -0.10%  (p=0.000 n=9+10)
SSA                            1.92GB ± 0%       1.92GB ± 0%  -0.13%  (p=0.000 n=10+10)
Flate                          23.0MB ± 0%       23.0MB ± 0%  -0.07%  (p=0.000 n=10+10)
GoParser                       27.9MB ± 0%       27.9MB ± 0%  -0.09%  (p=0.000 n=10+10)
Reflect                        77.9MB ± 0%       77.8MB ± 0%  -0.13%  (p=0.000 n=9+10)
Tar                            34.5MB ± 0%       34.4MB ± 0%  -0.09%  (p=0.000 n=10+10)
XML                            44.3MB ± 0%       44.3MB ± 0%  -0.08%  (p=0.000 n=10+10)
LinkCompiler                    229MB ± 0%        225MB ± 0%  -1.74%  (p=0.000 n=10+10)
ExternalLinkCompiler            233MB ± 0%        242MB ± 0%  +3.81%  (p=0.000 n=10+10)
LinkWithoutDebugCompiler        156MB ± 0%        152MB ± 0%  -2.29%  (p=0.000 n=10+9)

name                      old allocs/op     new allocs/op     delta
Template                         373k ± 0%         373k ± 0%  -0.21%  (p=0.000 n=10+10)
Unicode                          340k ± 0%         340k ± 0%  -0.04%  (p=0.000 n=10+10)
GoTypes                         1.33M ± 0%        1.33M ± 0%  -0.20%  (p=0.000 n=10+9)
Compiler                        5.39M ± 0%        5.38M ± 0%  -0.16%  (p=0.000 n=10+10)
SSA                             18.3M ± 0%        18.2M ± 0%  -0.15%  (p=0.000 n=10+10)
Flate                            235k ± 0%         234k ± 0%  -0.23%  (p=0.000 n=10+7)
GoParser                         309k ± 0%         308k ± 0%  -0.20%  (p=0.000 n=10+10)
Reflect                          970k ± 0%         968k ± 0%  -0.30%  (p=0.000 n=10+10)
Tar                              347k ± 0%         347k ± 0%  -0.22%  (p=0.000 n=10+10)
XML                              425k ± 0%         424k ± 0%  -0.16%  (p=0.000 n=10+10)
LinkCompiler                     602k ± 0%         601k ± 0%  -0.03%  (p=0.000 n=9+10)
ExternalLinkCompiler            1.65M ± 0%        1.65M ± 0%  -0.02%  (p=0.000 n=10+10)
LinkWithoutDebugCompiler         220k ± 0%         220k ± 0%  -0.03%  (p=0.016 n=10+9)

name                      old object-bytes  new object-bytes  delta
Template                        553kB ± 0%        553kB ± 0%  -0.01%  (p=0.000 n=10+10)
Unicode                         215kB ± 0%        215kB ± 0%    ~     (all equal)
GoTypes                        2.02MB ± 0%       2.02MB ± 0%  -0.00%  (p=0.000 n=10+10)
Compiler                       7.98MB ± 0%       7.98MB ± 0%  -0.01%  (p=0.000 n=10+10)
SSA                            27.1MB ± 0%       27.1MB ± 0%  -0.00%  (p=0.000 n=10+10)
Flate                           340kB ± 0%        340kB ± 0%  -0.01%  (p=0.000 n=10+10)
GoParser                        434kB ± 0%        434kB ± 0%  -0.00%  (p=0.000 n=10+10)
Reflect                        1.34MB ± 0%       1.34MB ± 0%  -0.01%  (p=0.000 n=10+10)
Tar                             479kB ± 0%        479kB ± 0%  -0.00%  (p=0.000 n=10+10)
XML                             618kB ± 0%        618kB ± 0%  -0.01%  (p=0.000 n=10+10)

name                      old export-bytes  new export-bytes  delta
Template                       20.4kB ± 0%       20.4kB ± 0%    ~     (all equal)
Unicode                        8.21kB ± 0%       8.21kB ± 0%    ~     (all equal)
GoTypes                        36.6kB ± 0%       36.6kB ± 0%    ~     (all equal)
Compiler                        116kB ± 0%        116kB ± 0%  +0.00%  (p=0.000 n=10+10)
SSA                             141kB ± 0%        141kB ± 0%  +0.00%  (p=0.000 n=10+10)
Flate                          5.10kB ± 0%       5.10kB ± 0%    ~     (all equal)
GoParser                       8.92kB ± 0%       8.92kB ± 0%    ~     (all equal)
Reflect                        11.8kB ± 0%       11.8kB ± 0%    ~     (all equal)
Tar                            10.9kB ± 0%       10.9kB ± 0%    ~     (all equal)
XML                            17.4kB ± 0%       17.4kB ± 0%    ~     (all equal)

name                      old text-bytes    new text-bytes    delta
HelloSize                       742kB ± 0%        742kB ± 0%    ~     (all equal)
CmdGoSize                      10.6MB ± 0%       10.6MB ± 0%    ~     (all equal)

name                      old data-bytes    new data-bytes    delta
HelloSize                      10.7kB ± 0%       10.7kB ± 0%    ~     (all equal)
CmdGoSize                       312kB ± 0%        312kB ± 0%    ~     (all equal)

name                      old bss-bytes     new bss-bytes     delta
HelloSize                       122kB ± 0%        122kB ± 0%    ~     (all equal)
CmdGoSize                       146kB ± 0%        146kB ± 0%    ~     (all equal)

name                      old exe-bytes     new exe-bytes     delta
HelloSize                      1.10MB ± 0%       1.10MB ± 0%    ~     (all equal)
CmdGoSize                      14.9MB ± 0%       14.9MB ± 0%  -0.03%  (p=0.000 n=10+10)

Change-Id: Ie078a42b29353b96654fa1f0f47d600b5a53762d
Reviewed-on: https://go-review.googlesource.com/c/go/+/200017
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-10 13:56:58 +00:00
Cuong Manh Le
fb9af8411e encoding/json: support TextUnmarshaler for map keys with string underlying types
When unmarshaling to a map, the map's key type must either be a string,
an integer, or implement encoding.TextUnmarshaler. But for a user
defined type, reflect.Kind will not distinguish between the static type
and the underlying type. In:

	var x MyString = "x"
	t := reflect.TypeOf(x)
	println(t.Kind() == reflect.String)

the Kind of x is still reflect.String, even though the static type of x
is MyString.

Moreover, checking for the map's key type is a string occurs first, so
even if the map key type MyString implements encoding.TextUnmarshaler,
it will be ignored.

To fix the bug, check for encoding.TextUnmarshaler first.

Fixes #34437

Change-Id: I780e0b084575e1dddfbb433fe03857adf71d05fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/200237
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2019-10-10 12:59:11 +00:00
Tom Thorogood
900ebcfe4d encoding/json: stop escaping U+2028 and U+2029 in Compact
Compact has been inconsistently escaping only some problematic characters
(U+2028 and U+2029), but not others (<, > and &). This change addresses
this inconsistency by removing the escaping of U+2028 and U+2029.

Callers who need to escape the output of Compact should use HTMLEscape
which escapes <, >, &, U+2028 and U+2029.

Fixes #34070
Fixes #30357
Updates #5836

Change-Id: Icfce7691d2b8b1d9b05ba7b64d2d1e4f3b67871b
GitHub-Last-Rev: 38859fe3e2
GitHub-Pull-Request: golang/go#34804
Reviewed-on: https://go-review.googlesource.com/c/go/+/200217
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-10 11:31:54 +00:00