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

35466 Commits

Author SHA1 Message Date
Hana Kim
6977a3b257 runtime/trace: implement annotation API
This implements the annotation API proposed in golang.org/cl/63274.

traceString is updated to protect the string map with trace.stringsLock
because the assumption that traceString is called by a single goroutine
(either at the beginning of tracing and at the end of tracing when
dumping all the symbols and function names) is no longer true.

traceString is used by the annotation apis (NewContext, StartSpan, Log)
to register frequently appearing strings (task and span names, and log
keys) after this change.

NewContext -> one or two records (EvString, EvUserTaskCreate)
end function -> one record (EvUserTaskEnd)
StartSpan -> one or two records (EvString, EvUserSpan)
span end function -> one or two records (EvString, EvUserSpan)
Log -> one or two records (EvString, EvUserLog)

EvUserLog record is of the typical record format written by traceEvent
except that it is followed by bytes that represents the value string.

In addition to runtime/trace change, this change includes
corresponding changes in internal/trace to parse the new record types.

Future work to improve efficiency:
  More efficient unique task id generation instead of atomic. (per-P
  counter).
  Instead of a centralized trace.stringsLock, consider using per-P
  string cache or something more efficient.

R=go1.11

Change-Id: Iec9276c6c51e5be441ccd52dec270f1e3b153970
Reviewed-on: https://go-review.googlesource.com/71690
Reviewed-by: Austin Clements <austin@google.com>
2018-02-15 18:54:14 +00:00
Hana Kim
32d1cd33c7 runtime/trace: user annotation API
This CL presents the proposed user annotation API skeleton.
This CL bumps up the trace version to 1.11.

Design doc https://goo.gl/iqJfJ3

Implementation CLs are followed.

The API introduces three basic building blocks. Log, Span, and Task.

Log is for basic logging. When called, the message will be recorded
to the trace along with timestamp, goroutine id, and stack info.

   trace.Log(ctx, messageType message)

Span can be thought as an extension of log to record interesting
time interval during a goroutine's execution. A span is local to a
goroutine by definition.

   trace.WithSpan(ctx, "doVeryExpensiveOp", func(ctx context) {
      /* do something very expensive */
   })

Task is higher-level concept that aids tracing of complex operations
that encompass multiple goroutines or are asynchronous.
For example, an RPC request, a HTTP request, a file write, or a
batch job can be traced with a Task.

Note we chose to design the API around context.Context so it allows
easier integration with other tracing tools, often designed around
context.Context as well. Log and WithSpan APIs recognize the task
information embedded in the context and record it in the trace as
well. That allows the Go execution tracer to associate and group
the spans and log messages based on the task information.

In order to create a Task,

   ctx, end := trace.NewContext(ctx, "myTask")
   defer end()

The Go execution tracer measures the time between the task created
and the task ended for the task latency.

More discussion history in golang.org/cl/59572.

Update #16619

R=go1.11

Change-Id: I59a937048294dafd23a75cf1723c6db461b193cd
Reviewed-on: https://go-review.googlesource.com/63274
Reviewed-by: Austin Clements <austin@google.com>
2018-02-15 18:52:43 +00:00
Michael Fraenkel
e057680542 cmd/compile: convert untyped bool for OIF and OFOR
Updates #23834.

Change-Id: I92aca9108590a0c7de774f4fad7ded97105e3cb8
Reviewed-on: https://go-review.googlesource.com/94475
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2018-02-15 18:36:17 +00:00
Carlos Eduardo Seo
9a9a8c0165 cmd/asm, cmd/internal/obj/ppc64: add Immediate Shifted opcodes for ppc64x
This change adds ADD/AND/OR/XOR Immediate Shifted instructions for
ppc64x so they are usable in Go asm code. These instructions were
originally present in asm9.go, but they were only usable in that
file (as -AADD, -AANDCC, -AOR, -AXOR). These old mnemonics are now
removed.

Updates #23845

Change-Id: Ifa2fac685e8bc628cb241dd446adfc3068181826
Reviewed-on: https://go-review.googlesource.com/94115
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2018-02-15 17:53:41 +00:00
Mikio Hara
d50bb8dbb9 all: drop support for Windows Vista or below (Windows XP)
Per the notice in the Go 1.10 release notes, this change drops the
support for Windows Vista or below (including Windows XP) and
simplifies the code for the sake of maintenance.

There is one exception to the above. The code related to DLL and
system calls still remains in the runtime package. The remaining code
will be refined and used for supporting upcoming Windows versions in
future.

Updates #17245
Fixes #23072

Change-Id: I9e2821721f25ef9b83dfbf85be2b7ee5d9023aa5
Reviewed-on: https://go-review.googlesource.com/94255
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-15 17:24:42 +00:00
Tobias Klauser
9542ba674d net, internal/poll, net/internal/socktest: set SOCK_{CLOEXEC,NONBLOCK} atomically on NetBSD
NetBSD supports the SOCK_CLOEXEC and SOCK_NONBLOCK flags to the socket
syscall since version 6.0. The same version also introduced the paccept
syscall which can be used to implement syscall.Accept4.

Follows CL 40895

Change-Id: I9e4e1829b0382744c7799f4e58929a53b4e193f7
Reviewed-on: https://go-review.googlesource.com/94295
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-15 17:07:12 +00:00
Robert Griesemer
33eb0633e1 cmd/compile/internal/syntax: don't assume (operator) ~ means operator ^
The scanner assumed that ~ really meant ^, which may be helpful when
coming from C. But ~ is not a valid Go token, and pretending that it
should be ^ can lead to confusing error messages. Better to be upfront
about it and complain about the invalid character in the first place.

This was code "inherited" from the original yacc parser which was
derived from a C compiler. It's 10 years later and we can probably
assume that people are less confused about C and Go.

Fixes #23587.

Change-Id: I8d8f9b55b0dff009b75c1530d729bf9092c5aea6
Reviewed-on: https://go-review.googlesource.com/94160
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2018-02-15 16:41:24 +00:00
Daniel Martí
e7cbbbe9bb cmd/vendor/github.com/google/pprof: refresh from upstream
Updating to commit 0e0e5b7254e076a62326ab7305ba49e8515f0c91
from github.com/google/pprof

Recent modifications to the vendored pprof, such as skipping
TestWebInterface to avoid starting a web browser, have all been fixed
upstream.

Change-Id: I72e11108c438e1573bf2f9216e76d157378e8d45
Reviewed-on: https://go-review.googlesource.com/93375
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-15 16:25:43 +00:00
Tobias Klauser
afb9fc1de9 runtime: move ELF structure definitions into own files
Move the ELF32 and ELF64 structure definitions into their own files so
they can be reused when vDSO support is added for other architectures.

Change-Id: Id0171b4e5cea4add8635743c881e3bf3469597af
Reviewed-on: https://go-review.googlesource.com/93995
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-02-15 16:15:19 +00:00
Josh Bleecher Snyder
605c9feeb1 runtime: speed up stack copying a little
Remove a branch and a stack spill.

name                old time/op  new time/op  delta
StackCopy-8         79.2ms ± 1%  79.1ms ± 2%    ~     (p=0.063 n=96+95)
StackCopyNoCache-8   121ms ± 1%   120ms ± 2%  -0.46%  (p=0.000 n=97+88)

Change-Id: Ifcbbb05d773178fad84cb11a9a6768ace69fcf24
Reviewed-on: https://go-review.googlesource.com/94029
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-02-15 15:06:34 +00:00
Josh Bleecher Snyder
910d232a28 runtime: simplify amd64 memmove of 3/4 bytes
Change-Id: I132d3627ae301b68bf87eacb5bf41fd1ba2dcd91
Reviewed-on: https://go-review.googlesource.com/94025
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-15 15:05:53 +00:00
Josh Bleecher Snyder
8e0b814a3a runtime: fix minor doc typos in amd64 memmove
Change-Id: Ic1ce2f93d6a225699e9ce5307d62cdda8f97630d
Reviewed-on: https://go-review.googlesource.com/94024
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-15 15:05:34 +00:00
Josh Bleecher Snyder
3658299f44 runtime: short-circuit typedslicecopy when dstp == srcp
If copying from a slice to itself, skip the write barriers
and actual memory copies.

This happens in practice in code like this snippet from
the trim pass in the compiler, when k ends up being 0:

copy(s.Values[k:], s.Values[:m])

Change-Id: Ie6924acfd56151f874d87f1d7f1f74320b4c4f10
Reviewed-on: https://go-review.googlesource.com/94023
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-02-15 15:05:15 +00:00
Martin Möhrmann
bf9f1c1503 runtime: use new instead of newobject to create hmap in makemap
The runtime.hmap type is known at compile time.
Using new(hmap) avoids loading the hmap type from the maptype
supplied as an argument to makemap which is only known at runtime.

This change makes makemap consistent with makemap_small
by using new(hmap) instead of newobject in both functions.

Change-Id: Ia47acfda527e8a71d15a1a7a4c2b54fb923515eb
Reviewed-on: https://go-review.googlesource.com/91775
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-02-15 08:57:26 +00:00
Martin Möhrmann
530927e08a runtime: improve test file naming
The runtime builtin functions that are tested in append_test.go
are defined in slice.go. Renaming the test file to slice_test.go
makes this relation explicit with a common file name prefix.

Change-Id: I2f89ec23a6077fe6b80d2161efc760df828c8cd4
Reviewed-on: https://go-review.googlesource.com/90655
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-02-15 08:56:58 +00:00
Ian Lance Taylor
f7c2a71632 cmd/go: add options to security whitelist
Also permit passing flags to pkg-config, as we used to.

Also change the error message to refer to https://golang.org/s/invalidflag.

Fixes #23749

Change-Id: I3fbeb4c346610e6fd55e8720e720b0a40e352ab5
Reviewed-on: https://go-review.googlesource.com/93836
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-15 05:43:54 +00:00
Ian Lance Taylor
229a8ce639 doc: remove draft notice from Go 1.10 release notes
Change-Id: I063b556b59ecb8a8f4a3f121c32982b90eee2d74
Reviewed-on: https://go-review.googlesource.com/94159
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-15 05:25:05 +00:00
Ian Lance Taylor
0849dfd4a3 test: add new test that gccgo failed to compile
Updates #22305

Change-Id: I0e6bbd880599fc1b70d0378b746d162d4a846c65
Reviewed-on: https://go-review.googlesource.com/91556
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-15 03:37:20 +00:00
Robert Griesemer
eda39fe9b2 cmd/compile/internal/syntax: fix syntax.Parse doc string, improved tests
1) Fix the doc string for syntax.Parse: The returned AST is
always nil if there was an error and an error handler is missing.

2) Adjust the syntax Print and Dump tests such that they print and
dump the AST even in the presence of errors.

Change-Id: If658eabdcc83f578d815070bc65d1a5f6cfaddfc
Reviewed-on: https://go-review.googlesource.com/94157
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2018-02-15 01:48:21 +00:00
Robert Griesemer
1a22738749 cmd/compile/internal/syntax: more tolerant handling of missing function invocation in go/defer
Assume that an expression that is not a function call in a defer/go
statement is indeed a function that is just missing its invocation.
Report the error but continue with a sane syntax tree.

Fixes #23586.

Change-Id: Ib45ebac57c83b3e39ae4a1b137ffa291dec5b50d
Reviewed-on: https://go-review.googlesource.com/94156
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2018-02-15 01:48:16 +00:00
Matthew Dempsky
d3f6d11d84 cmd/compile: fix typechecking of untyped boolean expressions
Previously, if we typechecked a statement like

    var x bool = p1.f == p2.f && p1.g == p2.g

we would correctly update the '&&' node's type from 'untyped bool' to
'bool', but the '==' nodes would stay 'untyped bool'. This is
inconsistent, and caused consistency checks during walk to fail.

This CL doesn't pass toolstash because it seems to slightly affect the
register allocator's heuristics. (Presumably 'untyped bool's were
previously making it all the way through SSA?)

Fixes #23414.

Change-Id: Ia85f8cfc69b5ba35dfeb157f4edf57612ecc3285
Reviewed-on: https://go-review.googlesource.com/94022
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-02-15 01:00:06 +00:00
Kunpei Sakai
bcb563f4db cmd/compile: allow converting defined string types to []rune
Fixes #23298

Change-Id: I107c6f3a80db83f063c0daf262c6e7f7492e4d4c
Reviewed-on: https://go-review.googlesource.com/87695
Run-TryBot: Kunpei Sakai <namusyaka@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2018-02-15 00:25:21 +00:00
Robert Griesemer
f04eebfdf5 cmd/compile/internal/syntax: follow Go naming conventions for error methods
Also, remove parser.error method (in favor of parser.errorAt) as it's only
used twice.

This is a purely cosmetic change.

Change-Id: Idb3b8b50f1c2e4d10de2ffb1c1184ceba8f7de8a
Reviewed-on: https://go-review.googlesource.com/94030
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2018-02-14 23:31:06 +00:00
Keith Randall
1566bf9025 cmd/compile: fix constant folding of right shifts on s390x
Repeat previous fix on amd64 for s390x.
Sub-word right shifts should sign extend before shifting.

Update #23812

Change-Id: I2d770190c7d8a22310b0dbd9facb3fb05afa362a
Reviewed-on: https://go-review.googlesource.com/94028
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-14 23:07:39 +00:00
Matthew Dempsky
c3e8da67dd cmd/compile: fix printing of untyped types in -W output
It's always useful to distinguish "bool" and "string" from "untyped
bool" and "untyped string", so change typefmt to do this
unconditionally.

Also, while here, replace a bare 0 with its named constant FErr.

Fixes #23833.

Change-Id: I3fcb8d7204686937439caaaf8b3973fc236d0387
Reviewed-on: https://go-review.googlesource.com/94021
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-14 22:18:07 +00:00
Cherry Zhang
beeab6ac02 cmd/compile: fix go:uintptrescapes tag for unnamed parameters
The tag was overwritten by the code for special handling unnamed
parameters.

Fixes #23045.

Change-Id: Ie2e1db3e902a07a2bbbc2a3424cea300f0a42cc3
Reviewed-on: https://go-review.googlesource.com/82775
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2018-02-14 21:41:39 +00:00
Joe Tsai
91a6a2a30f encoding/json: make error capture logic in recover more type safe
Rather than only ignoring runtime.Error panics, which are a very
narrow set of possible panic values, switch it such that the json
package only captures panic values that have been properly wrapped
in a jsonError struct. This ensures that only intentional panics
originating from the json package are captured.

Fixes #23012

Change-Id: I5e85200259edd2abb1b0512ce6cc288849151a6d
Reviewed-on: https://go-review.googlesource.com/94019
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-14 21:34:26 +00:00
Robert Griesemer
70a04f6880 go/types: make gotype continue after syntax errors
This avoids odd behavior where sometimes a lot of useful
errors are not reported simply because of a small syntax
error.

Tested manually with non-existing files. (We cannot easily
add an automatic test because this is a stand-alone binary
in this directory that must be built manually.)

Fixes #23593.

Change-Id: Iff90f95413bed7d1023fa0a5c9eb0414144428a9
Reviewed-on: https://go-review.googlesource.com/93815
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-02-14 21:23:56 +00:00
Keith Randall
8f9cf5525e cmd/compile: constant fold !true and !false
Constant fold Not of boolean constants.

Noticed while working on #23504.

Change-Id: I965705154ee7348a1a159fad4e029b922d3171b3
Reviewed-on: https://go-review.googlesource.com/88956
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
2018-02-14 20:28:08 +00:00
Ian Lance Taylor
d1f679a6af test: add test case for incorrect gccgo compilation error
Updates #23489

Change-Id: Ie846ccfe4c4d9295857f5da6863ac8f2ac0f2f6a
Reviewed-on: https://go-review.googlesource.com/89935
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-14 20:13:22 +00:00
Ian Lance Taylor
034aca1cbb test: add a test that gccgo miscompiled
Updates #20923

Change-Id: Ia1210ea3dec39e5db2521aeafca24d6e731f0c93
Reviewed-on: https://go-review.googlesource.com/91657
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-14 20:13:07 +00:00
Ian Lance Taylor
d9fc1929e9 test: add test for rounding to positive zero
Per the language spec clarification in https://golang.org/cl/14727.

Updates #12576
Updates #12621

Change-Id: I1e459c3c11a571bd29582761faacaa9ca3178ba6
Reviewed-on: https://go-review.googlesource.com/91895
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-02-14 20:13:05 +00:00
Ilya Tocar
9916feeddf cmd/compile/internal/ssa: don't spill register offsets on amd64
Transform (ADDQconst SP) into (LEA SP), because lea is rematerializeable,
so this avoids register spill. We can't mark ADDQconst as rematerializeable,
because it clobbers flags. This makes go binary ~2kb smaller.

For reference here is generated code for function from bug report.
Before:
        CALL    "".g(SB)
        MOVBLZX (SP), AX
        LEAQ    8(SP), DI
        TESTB   AX, AX
        JEQ     15
        MOVQ    "".p(SP), SI
        DUFFCOPY        $196
        MOVQ    $0, (SP)
        PCDATA  $0, $1
        CALL    "".h(SB)
        RET
        MOVQ    DI, ""..autotmp_2-8(SP) // extra spill
        PCDATA  $0, $2
        CALL    "".g(SB)
        MOVQ    ""..autotmp_2-8(SP), DI // extra register fill
        MOVQ    "".p(SP), SI
        DUFFCOPY        $196
        MOVQ    $1, (SP)
        PCDATA  $0, $1
        CALL    "".h(SB)
        JMP     14
        END

After:
        CALL    "".g(SB)
        MOVBLZX (SP), AX
        TESTB   AX, AX
        JEQ     15
        LEAQ    8(SP), DI
        MOVQ    "".p(SP), SI
        DUFFCOPY        $196
        MOVQ    $0, (SP)
        PCDATA  $0, $1
        CALL    "".h(SB)
        RET
        PCDATA  $0, $0  // no spill
        CALL    "".g(SB)
        LEAQ    8(SP), DI // rematerialized instead
        MOVQ    "".p(SP), SI
        DUFFCOPY        $196
        MOVQ    $1, (SP)
        PCDATA  $0, $1
        CALL    "".h(SB)
        JMP     14
        END

Fixes #22947

Change-Id: I8f33b860dc6c8828373477171b172ca2ce30074f
Reviewed-on: https://go-review.googlesource.com/81815
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-02-14 20:08:43 +00:00
Ilya Tocar
de4edf3de7 cmd/compile/internal/amd64: update popcnt code generation
Popcnt has false dependency on output register and generates
MOVQ $0, reg to break it. But recently we switched MOVQ $0, reg
encoding from xor reg, reg  to actual mov $0, reg. This CL updates
code generation for popcnt to use actual XOR.

Change-Id: I4c1fc11e85758b53ba2679165fa55614ec54b27d
Reviewed-on: https://go-review.googlesource.com/82516
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-02-14 19:56:57 +00:00
Heschi Kreinick
9c4fd4626c cmd/compile/internal: pass LocalSlot values, not pointers
Because getStackOffset is a function pointer, the compiler assumes that
its arguments escape. Pass a value instead to avoid heap allocations.

Change-Id: Ib94e5941847f134cd00e873040a4d7fcf15ced26
Reviewed-on: https://go-review.googlesource.com/92397
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2018-02-14 18:29:24 +00:00
Heschi Kreinick
b8644e3243 cmd/compile/internal: reuse memory for valueToProgAfter
Not a big improvement, but does help edge cases like the SSA package.
Change-Id: I40e531110b97efd5f45955be477fd0f4faa8d545
Reviewed-on: https://go-review.googlesource.com/92396
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2018-02-14 18:29:23 +00:00
Heschi Kreinick
7ac756f74b cmd/compile/internal/ssa: use math/bits for register sets
Using bits.TrailingZeroes instead of iterating over each bit is a small
but easy win for the common case of only one or two registers being set.

I copied in the implementation for use with pre-1.9 bootstraps.

Change-Id: Ieaa768554d7d5239a5617fbf34f1ee0b32ce1de5
Reviewed-on: https://go-review.googlesource.com/92395
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2018-02-14 18:29:22 +00:00
Heschi Kreinick
39eea62340 cmd/compile/internal/ssa: reduce location list memory use
Put everything that showed up in the allocation profile into the cache,
and reuse it across functions.

After this CL, the overhead of enabling location lists is getting
pretty close to the desired 5%:

compilecmp -all -beforeflags -dwarflocationlists=0 -afterflags -dwarflocationlists=1 -n 30 4ebad42292b6a4090faf37753dd768d2965e38c4 4ebad42292b6a4090faf37753dd768d2965e38c4
compilecmp  -dwarflocationlists=0 4ebad42292b6a4090faf37753dd768d2965e38c4  -dwarflocationlists=1 4ebad42292b6a4090faf37753dd768d2965e38c4
benchstat -geomean  /tmp/869550129 /tmp/143495132
completed   30 of   30, estimated time remaining 0s (eta 3:24PM)
name        old time/op       new time/op       delta
Template          199ms ± 4%        209ms ± 6%   +5.17%  (p=0.000 n=29+30)
Unicode          99.2ms ± 8%      100.5ms ± 6%     ~     (p=0.112 n=30+30)
GoTypes           642ms ± 3%        684ms ± 3%   +6.54%  (p=0.000 n=29+30)
SSA               8.00s ± 1%        8.71s ± 1%   +8.78%  (p=0.000 n=29+29)
Flate             129ms ± 7%        134ms ± 5%   +3.77%  (p=0.000 n=30+30)
GoParser          157ms ± 4%        164ms ± 5%   +4.35%  (p=0.000 n=29+30)
Reflect           428ms ± 3%        450ms ± 4%   +5.09%  (p=0.000 n=30+30)
Tar               195ms ± 5%        204ms ± 8%   +4.78%  (p=0.000 n=30+30)
XML               228ms ± 4%        241ms ± 4%   +5.62%  (p=0.000 n=30+29)
StdCmd            15.4s ± 1%        16.7s ± 1%   +8.29%  (p=0.000 n=29+29)
[Geo mean]        476ms             502ms        +5.35%

name        old user-time/op  new user-time/op  delta
Template          294ms ±18%        304ms ±15%     ~     (p=0.242 n=29+29)
Unicode           182ms ±27%        172ms ±28%     ~     (p=0.104 n=30+30)
GoTypes           957ms ±15%       1016ms ±12%   +6.16%  (p=0.000 n=30+30)
SSA               13.3s ± 5%        14.3s ± 3%   +7.32%  (p=0.000 n=30+28)
Flate             188ms ±17%        193ms ±17%     ~     (p=0.288 n=28+29)
GoParser          232ms ±16%        238ms ±13%     ~     (p=0.065 n=30+29)
Reflect           585ms ±13%        620ms ±10%   +5.88%  (p=0.000 n=30+30)
Tar               298ms ±21%        332ms ±23%  +11.32%  (p=0.000 n=30+30)
XML               329ms ±17%        343ms ±12%   +4.18%  (p=0.032 n=30+30)
[Geo mean]        492ms             513ms        +4.13%

name        old alloc/op      new alloc/op      delta
Template         38.3MB ± 0%       40.3MB ± 0%   +5.29%  (p=0.000 n=30+30)
Unicode          29.3MB ± 0%       29.6MB ± 0%   +1.28%  (p=0.000 n=30+29)
GoTypes           110MB ± 0%        118MB ± 0%   +6.97%  (p=0.000 n=29+30)
SSA              1.48GB ± 0%       1.61GB ± 0%   +9.06%  (p=0.000 n=30+30)
Flate            24.8MB ± 0%       26.0MB ± 0%   +4.99%  (p=0.000 n=29+30)
GoParser         30.9MB ± 0%       32.2MB ± 0%   +4.20%  (p=0.000 n=30+30)
Reflect          76.8MB ± 0%       80.6MB ± 0%   +4.97%  (p=0.000 n=30+30)
Tar              39.6MB ± 0%       41.7MB ± 0%   +5.22%  (p=0.000 n=29+30)
XML              42.0MB ± 0%       45.4MB ± 0%   +8.22%  (p=0.000 n=29+30)
[Geo mean]       63.9MB            67.5MB        +5.56%

name        old allocs/op     new allocs/op     delta
Template           383k ± 0%         405k ± 0%   +5.69%  (p=0.000 n=30+30)
Unicode            343k ± 0%         346k ± 0%   +0.98%  (p=0.000 n=30+27)
GoTypes           1.15M ± 0%        1.22M ± 0%   +6.17%  (p=0.000 n=29+29)
SSA               12.2M ± 0%        13.2M ± 0%   +8.15%  (p=0.000 n=30+30)
Flate              234k ± 0%         249k ± 0%   +6.44%  (p=0.000 n=30+30)
GoParser           315k ± 0%         332k ± 0%   +5.31%  (p=0.000 n=30+28)
Reflect            972k ± 0%        1010k ± 0%   +3.89%  (p=0.000 n=30+30)
Tar                394k ± 0%         415k ± 0%   +5.35%  (p=0.000 n=28+30)
XML                404k ± 0%         429k ± 0%   +6.31%  (p=0.000 n=29+29)
[Geo mean]         651k              686k        +5.35%

Change-Id: Ia005a8d6b33ce9f8091322f004376a3d6e5c1a94
Reviewed-on: https://go-review.googlesource.com/89357
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2018-02-14 18:29:21 +00:00
Heschi Kreinick
2075a9323d cmd/compile: reimplement location list generation
Completely redesign and reimplement location list generation to be more
efficient, and hopefully not too hard to understand.

RegKills are gone. Instead of using the regalloc's liveness
calculations, redo them using the Ops' clobber information. Besides
saving a lot of Values, this avoids adding RegKills to blocks that would
be empty otherwise, which was messing up optimizations. This does mean
that it's much harder to tell whether the generation process is buggy
(there's nothing to cross-check it with), and there may be disagreements
with GC liveness. But the performance gain is significant, and it's nice
not to be messing with earlier compiler phases.

The intermediate representations are gone. Instead of producing
ssa.BlockDebugs, then dwarf.LocationLists, and then finally real
location lists, go directly from the SSA to a (mostly) real location
list. Because the SSA analysis happens before assembly, it stores
encoded block/value IDs where PCs would normally go. It would be easier
to do the SSA analysis after assembly, but I didn't want to retain the
SSA just for that.

Generation proceeds in two phases: first, it traverses the function in
CFG order, storing the state of the block at the beginning and end. End
states are used to produce the start states of the successor blocks. In
the second phase, it traverses in program text order and produces the
location lists. The processing in the second phase is redundant, but
much cheaper than storing the intermediate representation. It might be
possible to combine the two phases somewhat to take advantage of cases
where the CFG matches the block layout, but I haven't tried.

Location lists are finalized by adding a base address selection entry,
translating each encoded block/value ID to a real PC, and adding the
terminating zero entry. This probably won't work on OSX, where dsymutil
will choke on the base address selection. I tried emitting CU-relative
relocations for each address, and it was *very* bad for performance --
it uses more memory storing all the relocations than it does for the
actual location list bytes. I think I'm going to end up synthesizing the
relocations in the linker only on OSX, but TBD.

TestNexting needs updating: with more optimizations working, the
debugger doesn't stop on the continue (line 88) any more, and the test's
duplicate suppression kicks in. Also, dx and dy live a little longer
now, but they have the correct values.

Change-Id: Ie772dfe23a4e389ca573624fac4d05401ae32307
Reviewed-on: https://go-review.googlesource.com/89356
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2018-02-14 18:29:19 +00:00
Heschi Kreinick
7d7af6106f cmd/compile/internal: decouple scope tracking from location lists
We're trying to enable location lists by default, and it's easier to do
that if we don't have to worry about scope tracking at the same time.
We can evaluate their performance impact separately.

However, that does mean that "err" is ambiguous in the test case, so
rename it to err2 for now.

Change-Id: I24f119016185c52b7d9affc74207f6a5b450fb6f
Reviewed-on: https://go-review.googlesource.com/89355
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2018-02-14 18:29:18 +00:00
Ian Lance Taylor
07751f4b58 runtime: use private futexes on Linux
By default futexes are permitted in shared memory regions, which
requires the kernel to translate the memory address. Since our futexes
are never in shared memory, set FUTEX_PRIVATE_FLAG, which makes futex
operations slightly more efficient.

Change-Id: I2a82365ed27d5cd8d53c5382ebaca1a720a80952
Reviewed-on: https://go-review.googlesource.com/80144
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2018-02-14 17:37:26 +00:00
fanzha02
ebd4950e3b cmd/asm: add PRFM instruction on ARM64
The current assembler cannot handle PRFM(immediate) instruciton.
The fix creates a prfopfield struct that contains the eight
prefetch operations and the value to use in instruction. And add
the test cases.

Fixes #22932

Change-Id: I621d611bd930ef3c42306a4372447c46d53b2ccf
Reviewed-on: https://go-review.googlesource.com/81675
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-02-14 17:09:52 +00:00
Cherry Zhang
0938e4cf90 cmd/internal/obj/mips: support NEG, avoid crash with illegal instruction
Add support of NEG{V,W} pseudo-instructions, which are translated
to a SUB instruction from R0 with proper width.

Also turn illegal instruction to UNDEF, to avoid crashing in
asmout when it tries to read the operands.

Fixes #23548.

Change-Id: I047b27559ccd9594c3dcf62ab039b636098f30a3
Reviewed-on: https://go-review.googlesource.com/89896
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2018-02-14 17:09:37 +00:00
Cherry Zhang
1fccbfe90e nacl*.bash: pass flags to make.bash
Just like all.bash passes flags to make.bash, I think it makes
sense that naclmake.bash and nacltest.bash do so as well. For
example, on a slow machine I can do "./nacltest.bash -v" to see
the build progress.

Change-Id: Id766dd590e6b83e8b5345822580dc1b05eac8ea3
Reviewed-on: https://go-review.googlesource.com/93117
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-02-14 17:09:31 +00:00
Cherry Zhang
5a43a271e8 cmd/compile: CALLudiv on nacl/arm doesn't clobber R12
On nacl/arm, R12 is clobbered by the RET instruction in function
that has a frame. runtime.udiv doesn't have a frame, so it does
not clobber R12.

Change-Id: I0de448749f615908f6659e92d201ba3eb2f8266d
Reviewed-on: https://go-review.googlesource.com/93116
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-02-14 17:09:15 +00:00
Cherry Zhang
633b38c5d2 runtime/internal/atomic: add early nil check on ARM
If nil, fault before taking the lock or calling into the kernel.

Change-Id: I013d78a5f9233c2a9197660025f679940655d384
Reviewed-on: https://go-review.googlesource.com/93636
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-02-14 17:09:05 +00:00
Cherry Zhang
97124af99a runtime/internal/atomic: unify sys_*_arm.s on non-linux
Updates #23778.

Change-Id: I80e57a15b6e3bbc2e25ea186399ff0e360fc5c21
Reviewed-on: https://go-review.googlesource.com/93635
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-02-14 17:08:58 +00:00
Martin Möhrmann
a90fc6d2d4 cmd/compile: replace range loop over list of nodes with orderexprlistinplace
Replace explicit range loop that applies orderexprinplace on a
list of nodes with existing helper function orderexprlistinplace.

Passes toolstash -cmp.

Change-Id: Ic8098ed08cf67f319de3faa83b00a5b73bbde95d
Reviewed-on: https://go-review.googlesource.com/88815
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-02-14 16:27:55 +00:00
Andrew Bonventre
d009679d42 github: add a Pull Request template
Change-Id: I02938b2435e3a98efea7ee5545a6f8f5f6f794b4
Reviewed-on: https://go-review.googlesource.com/93915
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-14 16:13:49 +00:00
Chad Rosier
cdd961630c cmd/compile: generate tbz/tbnz when comparing against zero on arm64
The tbz/tbnz checks the sign bit to determine if the value is >= 0 or < 0.

go1 benchmark results:
name                   old speed      new speed      delta
JSONEncode             94.4MB/s ± 1%  95.7MB/s ± 0%  +1.36%  (p=0.000 n=10+9)
JSONDecode             19.7MB/s ± 1%  19.9MB/s ± 1%  +1.08%  (p=0.000 n=9+10)
Gzip                   45.5MB/s ± 0%  46.0MB/s ± 0%  +1.06%  (p=0.000 n=10+10)
Revcomp                 376MB/s ± 0%   379MB/s ± 0%  +0.69%  (p=0.000 n=10+10)
RegexpMatchHard_1K     12.6MB/s ± 0%  12.7MB/s ± 0%  +0.57%  (p=0.000 n=10+8)
RegexpMatchMedium_32   3.21MB/s ± 0%  3.22MB/s ± 0%  +0.31%  (p=0.000 n=9+10)
RegexpMatchEasy1_1K    1.27GB/s ± 0%  1.27GB/s ± 0%  +0.23%  (p=0.000 n=9+9)
RegexpMatchHard_32     11.4MB/s ± 0%  11.4MB/s ± 1%  +0.19%  (p=0.036 n=10+8)
RegexpMatchEasy0_1K    1.77GB/s ± 0%  1.77GB/s ± 0%  +0.13%  (p=0.000 n=9+10)
RegexpMatchMedium_1K   19.3MB/s ± 0%  19.3MB/s ± 0%  +0.04%  (p=0.008 n=10+8)
RegexpMatchEasy0_32     131MB/s ± 0%   131MB/s ± 0%    ~     (p=0.211 n=10+10)
GobDecode              57.5MB/s ± 1%  57.6MB/s ± 2%    ~     (p=0.469 n=10+10)
GobEncode              58.6MB/s ± 1%  58.5MB/s ± 2%    ~     (p=0.781 n=10+10)
GoParse                9.40MB/s ± 0%  9.39MB/s ± 0%  -0.19%  (p=0.005 n=10+9)
RegexpMatchEasy1_32     133MB/s ± 0%   133MB/s ± 0%  -0.48%  (p=0.000 n=10+10)
Template               20.9MB/s ± 0%  20.6MB/s ± 0%  -1.54%  (p=0.000 n=8+10)

Change-Id: I411efe44db35c3962445618d5a47c12e31b3925b
Reviewed-on: https://go-review.googlesource.com/92715
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-02-14 15:52:41 +00:00