1. 04 Apr, 2018 6 commits
    • Daniel Martí's avatar
      text/template: add variable assignments · 28c1ad9d
      Daniel Martí authored
      Variables can be declared and shadowing is supported, but modifying
      existing variables via assignments was not available.
      
      This meant that modifying a variable from a nested block was not
      possible:
      
      	{{ $v := "init" }}
      	{{ if true }}
      		{{ $v := "changed" }}
      	{{ end }}
      	v: {{ $v }} {{/* "init" */}}
      
      Introduce the "=" assignment token, such that one can now do:
      
      	{{ $v := "init" }}
      	{{ if true }}
      		{{ $v = "changed" }}
      	{{ end }}
      	v: {{ $v }} {{/* "changed" */}}
      
      To avoid confusion, rename PipeNode.Decl to PipeNode.Vars, as the
      variables may not always be declared after this change. Also change a
      few other names to better reflect the added ambiguity of variables in
      pipelines.
      
      Modifying the text/template/parse package in a backwards incompatible
      manner is acceptable, given that the package godoc clearly states that
      it isn't intended for general use. It's the equivalent of an internal
      package, back when internal packages didn't exist yet.
      
      To make the changes to the parse package sit well with the cmd/api test,
      update except.txt with the changes that we aren't worried about.
      
      Fixes #10608.
      
      Change-Id: I1f83a4297ee093fd45f9993cebb78fc9a9e81295
      Reviewed-on: https://go-review.googlesource.com/84480
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarRob Pike <r@golang.org>
      28c1ad9d
    • Nikhil Benesch's avatar
      cmd/go: rebuild as needed when vetting test packages · 804d0328
      Nikhil Benesch authored
      If A's external test package imports B, which imports A, and A's
      internal test code adds something to A that invalidates anything in A's
      export data, then we need to build B against the test-augmented version
      of A before using it to build A's external test package.
      
      https://golang.org/cl/92215 taught 'go test' to do this rebuilding
      properly, but 'go vet' was not taught the same trick when it learned to
      vet test packages in https://golang.org/cl/87636. This commit moves the
      necessary logic into the load.TestPackagesFor function so it can be
      shared by 'go test' and 'go vet'.
      
      Fixes #23701.
      
      Change-Id: I1086d447eca02933af53de693384eac99a08d9bd
      Reviewed-on: https://go-review.googlesource.com/104315
      Run-TryBot: Russ Cox <rsc@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      804d0328
    • Alberto Donizetti's avatar
      test/codegen: port arm64 byte slice zeroing tests · f2abca90
      Alberto Donizetti authored
      And delete them from asm_test.
      
      Change-Id: Id533130470da9176a401cb94972f626f43a62148
      Reviewed-on: https://go-review.googlesource.com/103656
      Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarGiovanni Bajo <rasky@develer.com>
      f2abca90
    • Alberto Donizetti's avatar
      cmd/compile: stack-allocate 2 worklists in order, dom passes · 4ed94ef1
      Alberto Donizetti authored
      Allocate two more ssa local worklists on the stack. The initial sizes
      are chosen to cover >99% of the calls.
      
      name      old time/op       new time/op       delta
      Template        281ms ± 2%        283ms ± 5%    ~     (p=0.443 n=18+19)
      Unicode         136ms ± 4%        135ms ± 7%    ~     (p=0.277 n=20+20)
      GoTypes         886ms ± 2%        885ms ± 2%    ~     (p=0.862 n=20+20)
      Compiler        4.03s ± 2%        4.02s ± 1%    ~     (p=0.270 n=19+20)
      SSA             9.66s ± 1%        9.64s ± 2%    ~     (p=0.253 n=20+20)
      Flate           186ms ± 5%        183ms ± 6%    ~     (p=0.174 n=20+20)
      GoParser        222ms ± 4%        219ms ± 4%    ~     (p=0.081 n=20+20)
      Reflect         569ms ± 2%        568ms ± 2%    ~     (p=0.686 n=19+19)
      Tar             258ms ± 4%        256ms ± 3%    ~     (p=0.211 n=20+20)
      XML             319ms ± 2%        317ms ± 3%    ~     (p=0.158 n=18+20)
      
      name      old user-time/op  new user-time/op  delta
      Template        396ms ± 6%        392ms ± 6%    ~     (p=0.211 n=20+20)
      Unicode         212ms ±10%        211ms ± 9%    ~     (p=0.904 n=20+20)
      GoTypes         1.21s ± 3%        1.21s ± 2%    ~     (p=0.183 n=20+20)
      Compiler        5.60s ± 2%        5.62s ± 2%    ~     (p=0.355 n=18+18)
      SSA             14.0s ± 6%        13.9s ± 5%    ~     (p=0.678 n=20+20)
      Flate           250ms ± 8%        245ms ± 6%    ~     (p=0.166 n=19+20)
      GoParser        305ms ± 6%        304ms ± 5%    ~     (p=0.659 n=20+20)
      Reflect         760ms ± 3%        758ms ± 4%    ~     (p=0.758 n=20+20)
      Tar             362ms ± 6%        357ms ± 5%    ~     (p=0.108 n=20+20)
      XML             429ms ± 4%        429ms ± 4%    ~     (p=0.799 n=20+20)
      
      name      old alloc/op      new alloc/op      delta
      Template       39.0MB ± 0%       38.8MB ± 0%  -0.55%  (p=0.000 n=20+20)
      Unicode        29.1MB ± 0%       29.1MB ± 0%  -0.06%  (p=0.000 n=20+20)
      GoTypes         116MB ± 0%        115MB ± 0%  -0.50%  (p=0.000 n=20+20)
      Compiler        493MB ± 0%        491MB ± 0%  -0.46%  (p=0.000 n=19+20)
      SSA            1.40GB ± 0%       1.40GB ± 0%  -0.31%  (p=0.000 n=19+20)
      Flate          25.0MB ± 0%       24.9MB ± 0%  -0.60%  (p=0.000 n=19+19)
      GoParser       30.9MB ± 0%       30.7MB ± 0%  -0.66%  (p=0.000 n=20+20)
      Reflect        77.5MB ± 0%       77.1MB ± 0%  -0.52%  (p=0.000 n=20+20)
      Tar            39.2MB ± 0%       39.0MB ± 0%  -0.47%  (p=0.000 n=20+20)
      XML            44.8MB ± 0%       44.6MB ± 0%  -0.45%  (p=0.000 n=20+19)
      
      name      old allocs/op     new allocs/op     delta
      Template         382k ± 0%         379k ± 0%  -0.69%  (p=0.000 n=20+19)
      Unicode          337k ± 0%         336k ± 0%  -0.09%  (p=0.000 n=20+20)
      GoTypes         1.19M ± 0%        1.18M ± 0%  -0.64%  (p=0.000 n=20+20)
      Compiler        4.60M ± 0%        4.58M ± 0%  -0.57%  (p=0.000 n=20+20)
      SSA             11.5M ± 0%        11.4M ± 0%  -0.42%  (p=0.000 n=19+20)
      Flate            235k ± 0%         233k ± 0%  -0.74%  (p=0.000 n=20+19)
      GoParser         316k ± 0%         313k ± 0%  -0.69%  (p=0.000 n=20+20)
      Reflect          953k ± 0%         946k ± 0%  -0.81%  (p=0.000 n=20+20)
      Tar              391k ± 0%         388k ± 0%  -0.61%  (p=0.000 n=20+19)
      XML              413k ± 0%         411k ± 0%  -0.56%  (p=0.000 n=20+20)
      
      Change-Id: I7378174e3550b47df4368b24cf24c8ce1b85c906
      Reviewed-on: https://go-review.googlesource.com/104656Reviewed-by: 's avatarDaniel Martí <mvdan@mvdan.cc>
      4ed94ef1
    • Lubomir I. Ivanov (VMware)'s avatar
      os/user: obtain a user GID on Windows · 2a16176a
      Lubomir I. Ivanov (VMware) authored
      Add the following helpers in lookup_windows.go:
      1) lookupGroupName() is used to obtain the SID of a group based
      on name.
      2) listGroupsForUsernameAndDomain() uses NetUserGetLocalGroups()
      as a WINAPI backend to obtain the list of local groups for this
      user.
      3) lookupUserPrimaryGroup() is now used to populate the User.Gid
      field when looking up a user by name.
      
      Implement listGroups(), lookupGroupId(), lookupGroup() and no longer
      return unimplemented errors.
      
      Do not skip Windows User.Gid tests in user_test.go.
      
      Change-Id: I81fd41b406da51f9a4cb24e50d392a333df81141
      GitHub-Last-Rev: d1448fd55d6eaa0f41bf347df18b40da06791df1
      GitHub-Pull-Request: golang/go#24222
      Reviewed-on: https://go-review.googlesource.com/98137Reviewed-by: 's avatarAlex Brainman <alex.brainman@gmail.com>
      Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      2a16176a
    • Josh Bleecher Snyder's avatar
      runtime: improve StackCopy benchmarks · 00fab205
      Josh Bleecher Snyder authored
      Make the StackCopyNoCache test easier to read.
      
      Add a StackCopyPtr test that actually has some pointers
      that need adjusting.
      
      Change-Id: I5b07c26f40cb485c9de97ed63fac89a9e6f36650
      Reviewed-on: https://go-review.googlesource.com/104195
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      00fab205
  2. 03 Apr, 2018 19 commits
    • Dhruvdutt Jadhav's avatar
      README: update number of contributors · f113a629
      Dhruvdutt Jadhav authored
      Change-Id: I5a1c7ed83a430a509d8f61f4aba8772d5d16ad48
      GitHub-Last-Rev: fed86d88691c8a62bafac18a4e5c0944a4e59050
      GitHub-Pull-Request: golang/go#24664
      Reviewed-on: https://go-review.googlesource.com/104515Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      f113a629
    • Robert Griesemer's avatar
      cmd/compile/internal/syntax: better error message for incorrect if/switch header · 4637699e
      Robert Griesemer authored
      Fixes #23664.
      
      Change-Id: Ic0637e9f896b2fc6502dfbab2d1c4de3c62c0bd2
      Reviewed-on: https://go-review.googlesource.com/104616Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
      Run-TryBot: Robert Griesemer <gri@golang.org>
      4637699e
    • Robert Griesemer's avatar
      cmd/compile/internal/syntax: update a couple of comments · a818ddd9
      Robert Griesemer authored
      Change-Id: Ie84d0e61697922c1e808d815fb7d9aec694ee8e9
      Reviewed-on: https://go-review.googlesource.com/104615Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
      a818ddd9
    • Giovanni Bajo's avatar
      cmd/compile: in prove, complete support for OpIsInBounds/OpIsSliceInBounds · ac43de3a
      Giovanni Bajo authored
      The logic in addBranchRestrictions didn't allow to correctly
      model OpIs(Slice)Bound for signed domain, and it was also partly
      implemented within addRestrictions.
      
      Thanks to the previous changes, it is now possible to handle
      the negative conditions correctly, so that we can learn
      both signed/LT + unsigned/LT on the positive side, and
      signed/GE + unsigned/GE on the negative side (but only if
      the index can be proved to be non-negative).
      
      This is able to prove ~50 more slice accesses in std+cmd.
      
      Change-Id: I9858080dc03b16f85993a55983dbc4b00f8491b0
      Reviewed-on: https://go-review.googlesource.com/104037
      Run-TryBot: Giovanni Bajo <rasky@develer.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarAustin Clements <austin@google.com>
      ac43de3a
    • Giovanni Bajo's avatar
      cmd/compile: in prove, make addRestrictions more generic · b846edfd
      Giovanni Bajo authored
      addRestrictions was taking a branch parameter, binding its logic
      to that of addBranchRestrictions. Since we will need to use it
      for updating the facts table for induction variables, refactor it
      to remove the branch parameter.
      
      Passes toolstash -cmp.
      
      Change-Id: Iaaec350a8becd1919d03d8574ffd1bbbd906d068
      Reviewed-on: https://go-review.googlesource.com/104036
      Run-TryBot: Giovanni Bajo <rasky@develer.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarAustin Clements <austin@google.com>
      b846edfd
    • isharipo's avatar
      math/big: remove "else" from if with block that ends with return · 02952ad7
      isharipo authored
      That "else" was needed due to gc DCE limitations.
      Now it's not the case and we can avoid go lint complaints.
      (See #23521 and https://golang.org/cl/91056.)
      
      There is inlining test for bigEndianWord, so if test
      is passing, no performance regression should occur.
      
      Change-Id: Id84d63f361e5e51a52293904ff042966c83c16e9
      Reviewed-on: https://go-review.googlesource.com/104555Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      02952ad7
    • Alberto Donizetti's avatar
      cmd/compile: stack-allocate values worklist in schedule · 00c8e149
      Alberto Donizetti authored
      Compiler instrumentation shows that the cap of the stores slice in the
      storeOrder function is almost always 64 or less. Since the slice does
      not escape, pre-allocating on the stack a 64-elements one greatly
      reduces the number of allocations performed by the function.
      
      name      old time/op       new time/op       delta
      Template        289ms ± 5%        283ms ± 3%  -1.99%  (p=0.000 n=19+20)
      Unicode         140ms ± 6%        136ms ± 6%  -2.61%  (p=0.021 n=19+20)
      GoTypes         915ms ± 2%        895ms ± 2%  -2.24%  (p=0.000 n=19+20)
      Compiler        4.15s ± 1%        4.04s ± 2%  -2.73%  (p=0.000 n=20+20)
      SSA             10.0s ± 1%         9.8s ± 2%  -2.13%  (p=0.000 n=20+20)
      Flate           189ms ± 6%        186ms ± 4%  -1.75%  (p=0.028 n=19+20)
      GoParser        229ms ± 5%        224ms ± 4%  -2.25%  (p=0.001 n=20+19)
      Reflect         584ms ± 2%        573ms ± 3%  -1.83%  (p=0.000 n=18+20)
      Tar             265ms ± 3%        261ms ± 3%  -1.33%  (p=0.021 n=20+20)
      XML             328ms ± 2%        321ms ± 2%  -2.11%  (p=0.000 n=20+20)
      
      name      old user-time/op  new user-time/op  delta
      Template        408ms ± 4%        400ms ± 4%  -1.98%  (p=0.006 n=19+20)
      Unicode         216ms ± 9%        216ms ± 7%    ~     (p=0.883 n=20+20)
      GoTypes         1.25s ± 1%        1.23s ± 3%  -1.32%  (p=0.002 n=19+20)
      Compiler        5.77s ± 1%        5.69s ± 2%  -1.47%  (p=0.000 n=18+19)
      SSA             14.6s ± 5%        14.1s ± 4%  -3.45%  (p=0.000 n=20+20)
      Flate           252ms ± 7%        251ms ± 7%    ~     (p=0.659 n=20+20)
      GoParser        314ms ± 5%        310ms ± 5%    ~     (p=0.165 n=20+20)
      Reflect         780ms ± 2%        769ms ± 3%  -1.34%  (p=0.004 n=19+18)
      Tar             365ms ± 7%        367ms ± 5%    ~     (p=0.841 n=20+20)
      XML             439ms ± 4%        432ms ± 4%  -1.45%  (p=0.043 n=20+20)
      
      name      old alloc/op      new alloc/op      delta
      Template       38.9MB ± 0%       38.8MB ± 0%  -0.26%  (p=0.000 n=19+20)
      Unicode        29.0MB ± 0%       29.0MB ± 0%  -0.02%  (p=0.001 n=20+19)
      GoTypes         115MB ± 0%        115MB ± 0%  -0.31%  (p=0.000 n=20+20)
      Compiler        492MB ± 0%        490MB ± 0%  -0.41%  (p=0.000 n=20+19)
      SSA            1.40GB ± 0%       1.39GB ± 0%  -0.48%  (p=0.000 n=20+20)
      Flate          24.9MB ± 0%       24.9MB ± 0%  -0.24%  (p=0.000 n=20+20)
      GoParser       30.9MB ± 0%       30.8MB ± 0%  -0.39%  (p=0.000 n=20+20)
      Reflect        77.1MB ± 0%       76.8MB ± 0%  -0.32%  (p=0.000 n=17+20)
      Tar            39.1MB ± 0%       39.0MB ± 0%  -0.23%  (p=0.000 n=20+20)
      XML            44.7MB ± 0%       44.6MB ± 0%  -0.30%  (p=0.000 n=20+18)
      
      name      old allocs/op     new allocs/op     delta
      Template         385k ± 0%         382k ± 0%  -0.99%  (p=0.000 n=20+19)
      Unicode          336k ± 0%         336k ± 0%  -0.08%  (p=0.000 n=19+17)
      GoTypes         1.20M ± 0%        1.18M ± 0%  -1.11%  (p=0.000 n=20+18)
      Compiler        4.66M ± 0%        4.59M ± 0%  -1.42%  (p=0.000 n=19+20)
      SSA             11.6M ± 0%        11.5M ± 0%  -1.49%  (p=0.000 n=20+20)
      Flate            237k ± 0%         235k ± 0%  -1.00%  (p=0.000 n=20+19)
      GoParser         319k ± 0%         315k ± 0%  -1.12%  (p=0.000 n=20+20)
      Reflect          960k ± 0%         952k ± 0%  -0.92%  (p=0.000 n=18+20)
      Tar              394k ± 0%         390k ± 0%  -0.87%  (p=0.000 n=20+20)
      XML              418k ± 0%         413k ± 0%  -1.18%  (p=0.000 n=20+20)
      
      Change-Id: I01b9f45b161379967d7a52e23f39ac30dd90edb0
      Reviewed-on: https://go-review.googlesource.com/104415Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
      00c8e149
    • Filippo Valsorda's avatar
      crypto/tls: simplify the Handshake locking strategy · ee7dd810
      Filippo Valsorda authored
      If in.Mutex is never locked by Handshake when c.handshakeComplete is
      true, and since c.handshakeComplete is unset and then set back by
      handleRenegotiation all under both in.Mutex and handshakeMutex, we can
      significantly simplify the locking strategy by removing the sync.Cond.
      
      See also https://groups.google.com/forum/#!topic/golang-dev/Xxiai-R_jH0
      and a more complete analysis at https://go-review.googlesource.com/c/go/+/33776#message-223a3ccc819f7015cc773d214c65bad70de5dfd7
      
      Change-Id: I6052695ece9aff9e3112c2fb176596fde8aa9cb2
      Reviewed-on: https://go-review.googlesource.com/33776Reviewed-by: 's avatarAdam Langley <agl@golang.org>
      ee7dd810
    • Michael Munday's avatar
      cmd/asm, math: add s390x floating point test instructions · 32e6461d
      Michael Munday authored
      Floating point test instructions allow special cases (NaN, ±∞ and
      a few other useful properties) to be checked directly.
      
      This CL adds the following instructions to the assembler:
       * LTEBR - load and test (float32)
       * LTDBR - load and test (float64)
       * TCEB  - test data class (float32)
       * TCDB  - test data class (float64)
      
      Note that I have only added immediate versions of the 'test data
      class' instructions for now as that's the only case I think the
      compiler will use.
      
      Change-Id: I3398aab2b3a758bf909bd158042234030c8af582
      Reviewed-on: https://go-review.googlesource.com/104457Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      Run-TryBot: Michael Munday <mike.munday@ibm.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      32e6461d
    • Javier Kohen's avatar
      regexp: use sync.Pool to cache regexp.machine objects · 7dbf9d43
      Javier Kohen authored
      Performance optimization for the internals of the Regexp type. This adds
      no features and has no user-visible impact beyond performance. Copy now
      shares the cache, so memory usage for programs that use Copy a lot
      should go down; Copy has effectively become a no-op.
      
      The before v. after benchmark results show a lot of noise from run to
      run, but there's a clear improvement to the Shared case and no detriment
      to the Copied case.
      
      BenchmarkMatchParallelShared-4                        361           77.9          -78.42%
      BenchmarkMatchParallelCopied-4                        70.3          72.2          +2.70%
      
      Macro benchmarks show that the lock contention in Regexp is gone, and my
      server is now able to scale linearly 2.5x times more than before (and I
      only stopped there because I ran out of CPU in my test machine).
      
      Fixes #24411
      
      Change-Id: Ib33abff2802f27599f5d09084775e95b54e3e1d7
      Reviewed-on: https://go-review.googlesource.com/101715Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      7dbf9d43
    • Pascal S. de Kloe's avatar
      crypto/rsa: add PublicKey.Size accessor · daa2d547
      Pascal S. de Kloe authored
      Provide the fixed size from the key pair.
      
      Change-Id: I365c8d0f7d915229ef089e46458d4c83273fc648
      Reviewed-on: https://go-review.googlesource.com/103876Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      daa2d547
    • Tobias Klauser's avatar
      runtime: parse auxv for page size and executable name on Solaris · 01237b13
      Tobias Klauser authored
      Decode AT_PAGESZ to determine physPageSize and AT_SUN_EXECNAME for
      os.Executable.
      
      Change-Id: I6ff774ad9d76c68fc61eb307df58217c17fd578d
      Reviewed-on: https://go-review.googlesource.com/104375
      Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      01237b13
    • Fangming.Fang's avatar
      cmd/asm: add essential instructions for AES-GCM on ARM64 · ef9bdd11
      Fangming.Fang authored
      This change adds VLD1, VST1, VPMULL{2}, VEXT, VRBIT, VUSHR and VSHL instructions
      for supporting AES-GCM implementation later.
      
      Fixes #24400
      
      Change-Id: I556feb88067f195cbe25629ec2b7a817acc58709
      Reviewed-on: https://go-review.googlesource.com/101095Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
      Run-TryBot: Cherry Zhang <cherryyz@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      ef9bdd11
    • isharipo's avatar
      cmd/compile: make DCE remove nodes after terminating if · dcaf3fb1
      isharipo authored
      This change makes compiler frontend dead code elimination of const expr if
      statements introduced in https://golang.org/cl/38773 treat both
      	if constCondTrue { ...; returnStmt } toBeRemoved...
      	if constCondFalse { ...; } else { returnStmt } toBeRemoved...
      identically to:
      	if constCondTrue { ...; returnStmt } else { toBeRemoved... }
      
      Where "constCondTrue" is a an expression that can be evaluated
      to "true" during compile time.
      
      The additional checks are only triggered for const expr
      if conditions that evaluate to true.
      
      name       old time/op       new time/op       delta
      Template         431ms ± 2%        429ms ± 1%    ~     (p=0.491 n=8+6)
      Unicode          198ms ± 4%        201ms ± 2%    ~     (p=0.234 n=7+6)
      GoTypes          1.40s ± 1%        1.41s ± 2%    ~     (p=0.053 n=7+7)
      Compiler         6.72s ± 2%        6.81s ± 1%  +1.35%  (p=0.011 n=7+7)
      SSA              17.3s ± 1%        17.3s ± 2%    ~     (p=0.731 n=6+7)
      Flate            275ms ± 2%        275ms ± 2%    ~     (p=0.902 n=7+7)
      GoParser         340ms ± 2%        339ms ± 2%    ~     (p=0.902 n=7+7)
      Reflect          910ms ± 2%        905ms ± 1%    ~     (p=0.310 n=6+6)
      Tar              403ms ± 1%        403ms ± 2%    ~     (p=0.366 n=7+6)
      XML              486ms ± 1%        490ms ± 1%    ~     (p=0.065 n=6+6)
      StdCmd           56.2s ± 1%        56.6s ± 2%    ~     (p=0.620 n=7+7)
      
      name       old user-time/op  new user-time/op  delta
      Template         559ms ± 8%        557ms ± 7%    ~     (p=0.713 n=8+7)
      Unicode          266ms ±13%        277ms ± 9%    ~     (p=0.157 n=8+7)
      GoTypes          1.83s ± 2%        1.84s ± 1%    ~     (p=0.522 n=8+7)
      Compiler         8.67s ± 4%        8.89s ± 4%    ~     (p=0.077 n=7+7)
      SSA              23.9s ± 1%        24.2s ± 1%  +1.31%  (p=0.005 n=7+7)
      Flate            351ms ± 4%        342ms ± 5%    ~     (p=0.105 n=7+7)
      GoParser         437ms ± 2%        423ms ± 5%  -3.14%  (p=0.016 n=7+7)
      Reflect          1.16s ± 3%        1.15s ± 2%    ~     (p=0.362 n=7+7)
      Tar              517ms ± 4%        511ms ± 3%    ~     (p=0.538 n=7+7)
      XML              619ms ± 3%        617ms ± 4%    ~     (p=0.483 n=7+7)
      
      Fixes #23521
      
      Change-Id: I165a7827d869aeb93ce6047d026ff873d039a4f3
      Reviewed-on: https://go-review.googlesource.com/91056
      Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
      dcaf3fb1
    • Daniel Martí's avatar
      cmd/compile: introduce gc.Node.copy method · 19ee2ef9
      Daniel Martí authored
      When making a shallow copy of a node, various methods were used,
      including calling nod(OXXX, nil, nil) and then overwriting it, or
      "n1 := *n" and then using &n1.
      
      Add a copy method instead, simplifying all of those and making them
      consistent.
      
      Passes toolstash -cmp on std cmd.
      
      Change-Id: I3f3fc88bad708edc712bf6d87214cda4ddc43b01
      Reviewed-on: https://go-review.googlesource.com/72710
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
      19ee2ef9
    • Giovanni Bajo's avatar
      cmd/compile: in prove, simplify logic of branch pushing · 321bd8c9
      Giovanni Bajo authored
      prove used a complex logic when trying to prove branch conditions:
      tryPushBranch() was sometimes leaving a checkpoint on the factsTable,
      sometimes not, and the caller was supposed to check the return value
      to know what to do.
      
      Since we're going to make the prove descend logic a little bit more
      complex by adding also induction variables, simplify the tryPushBranch
      logic, by removing any factsTable checkpoint handling from it.
      
      Passes toolstash -cmp.
      
      Change-Id: Idfb1703df8a455f612f93158328b36c461560781
      Reviewed-on: https://go-review.googlesource.com/104035
      Run-TryBot: Giovanni Bajo <rasky@develer.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarAustin Clements <austin@google.com>
      321bd8c9
    • Matthew Dempsky's avatar
      cmd/compile: improve declaration position precision · 26e0e8a8
      Matthew Dempsky authored
      Previously, n.Pos was reassigned to lineno when declare was called,
      which might not match where the identifier actually appeared in the
      source. This caused a loss of position precision for function
      parameters (which were all declared at the last parameter's position),
      and required some clumsy workarounds in bimport.go.
      
      This CL changes declare to leave n.Pos alone and also fixes a few
      places where n.Pos was not being set correctly.
      
      Change-Id: Ibe5b5fd30609c684367207df701f9a1bfa82867f
      Reviewed-on: https://go-review.googlesource.com/104275Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
      26e0e8a8
    • Robert Griesemer's avatar
      cmd/compile: better handling of incorrect type switches · c65a2781
      Robert Griesemer authored
      Don't report errors if we don't have a correct type switch
      guard; instead ignore it and leave it to the type-checker
      to report the error. This leads to better error messages
      concentrating on the type switch guard rather than errors
      around (confusing) syntactic details.
      
      Also clean up some code setting up AssertExpr (they never
      have a nil Type field) and remove some incorrect TODOs.
      
      Fixes #24470.
      
      Change-Id: I69512f36e0417e3b5ea9c8856768e04b19d654a8
      Reviewed-on: https://go-review.googlesource.com/103615
      Run-TryBot: Robert Griesemer <gri@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
      c65a2781
    • Brad Fitzpatrick's avatar
      strings: fix flaky TestBuilderGrow test · 071f0de4
      Brad Fitzpatrick authored
      Fixes #24647
      
      Change-Id: I79c2b45cf7fc9c0ed0c7a665472556bd248e7584
      Reviewed-on: https://go-review.googlesource.com/104235
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBryan Mills <bcmills@google.com>
      Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
      071f0de4
  3. 02 Apr, 2018 14 commits
    • quasilyte's avatar
      cmd/link/internal/ld: make Thearch unexported · da02dcda
      quasilyte authored
      s/Thearch/thearch/
      
      This reduces the amount of exported global variables,
      which in turn could make it easier to refactor them later.
      
      Also updated somewhat vague comment about ld.Thearch.
      There is no need for Thearch to be exported as Archinit is
      called by ld.Main.
      
      Updates #22095
      
      Change-Id: I266b291f6eac0165f70c51964738206e066cea08
      Reviewed-on: https://go-review.googlesource.com/103878
      Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      da02dcda
    • Matthew Dempsky's avatar
      cmd/compile: simplify exportsym debug message · fac7d5dd
      Matthew Dempsky authored
      No need to disambiguate if we're exporting or reexporting, because
      it's obvious from the output.
      
      Change-Id: I59053d34dc6f8b29e20749c7b03c3cb4f4d641ff
      Reviewed-on: https://go-review.googlesource.com/104236Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
      fac7d5dd
    • Matthew Dempsky's avatar
      cmd/compile: simplify exportsym flags and logic · ce1252a6
      Matthew Dempsky authored
      We used to have three Sym flags for dealing with export/reexport:
      Export, Package, and Exported.
      
      Export and Package were used to distinguish whether a symbol is
      exported or package-scope (i.e., mutually exclusive), except that for
      local declarations Export served double-duty as tracking whether the
      symbol had been added to exportlist.
      
      Meanwhile, imported declarations that needed reexporting could be
      added to exportlist multiple times, necessitating a flag to track
      whether they'd already been written out by exporter.
      
      Simplify all of these into a single OnExportList flag so that we can
      ensure symbols on exportlist are present exactly once. Merge
      reexportsym into exportsym so there's a single place where we append
      to exportlist.
      
      Code that used to set Exported to prevent a symbol from being exported
      can now just set OnExportList before calling declare to prevent it
      from even appearing on exportlist.
      
      Lastly, drop the IsAlias check in exportsym: we call exportsym too
      early for local symbols to detect if they're an alias, and we never
      reexport aliases.
      
      Passes toolstash-check.
      
      Change-Id: Icdea3719105dc169fcd7651606589cd08b0a80ff
      Reviewed-on: https://go-review.googlesource.com/103865
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      ce1252a6
    • Matthew Dempsky's avatar
      cmd/compile: cleanup Order.cleanTempNoPop slightly · 096d9677
      Matthew Dempsky authored
      Passes toolstash-check.
      
      Change-Id: Ia769e719e89e508201711775ea3e2cb3979387fa
      Reviewed-on: https://go-review.googlesource.com/102215
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarDaniel Martí <mvdan@mvdan.cc>
      096d9677
    • Matthew Dempsky's avatar
      cmd/compile: simplify reexport logic · bcc8edfd
      Matthew Dempsky authored
      Currently, we reexport any package-scope constant, function, type, or
      variable declarations needed by an inlineable function body. However,
      now that we have an early pass to walk inlineable function bodies
      (golang.org/cl/74110), we can simplify the logic for finding these
      declarations.
      
      The binary export format supports writing out type declarations
      in-place at their first use. Also, it always writes out constants by
      value, so their declarations never need to be reexported.
      
      Notably, we attempted this before (golang.org/cl/36170) and had to
      revert it (golang.org/cl/45911). However, this was because while
      writing out inline bodies, we could discover variable/function
      dependencies. By collecting variable/function dependencies during
      inlineable function discovery, we avoid this problem.
      
      While here, get rid of isInlineable. We already typecheck inlineable
      function bodies during inlFlood, so it's become a no-op. Just move the
      comment explaining parameter numbering to its caller.
      
      Change-Id: Ibbfaafce793733675d3a2ad98791758583055666
      Reviewed-on: https://go-review.googlesource.com/103864Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
      bcc8edfd
    • Ilya Tocar's avatar
      strings: speed-up replace for byteStringReplacer case · fd22542e
      Ilya Tocar authored
      Use Count instead of loop to determine a number of replacements.
      Also increment index instead of advancing slices, to avoid some extra stores.
      Shows very significant speed-up on html benchmarks:
      
      Escape-6          34.2µs ± 2%  20.8µs ± 2%  -39.06%  (p=0.000 n=10+10)
      EscapeNone-6      7.04µs ± 1%  1.05µs ± 0%  -85.03%  (p=0.000 n=10+10)
      
      On benchmarks in package strings results are still significant:
      
      ByteStringMatch-6    1.59µs ± 2%    1.17µs ± 2%  -26.35%  (p=0.000 n=10+10)
      HTMLEscapeNew-6       390ns ± 2%     337ns ± 2%  -13.62%  (p=0.000 n=10+10)
      HTMLEscapeOld-6       621ns ± 2%     603ns ± 2%   -2.95%  (p=0.000 n=10+9)
      
      Change-Id: Ibea3235b6e451ba72cd5db57716d17b917e72944
      Reviewed-on: https://go-review.googlesource.com/97255
      Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      fd22542e
    • Matthew Dempsky's avatar
      cmd/compile: disable instrumentation for no-race packages earlier · c0841ecd
      Matthew Dempsky authored
      Rather than checking for each function whether the package supports
      instrumentation, check once up front.
      
      Relatedly, tweak the logic for preventing inlining calls to runtime
      functions from instrumented packages. Previously, we simply disallowed
      inlining runtime functions altogether when instrumenting. With this
      CL, it's only disallowed from packages that are actually being
      instrumented. That is, now intra-runtime calls can be inlined.
      
      Updates #19054.
      
      Change-Id: I88c97b48bf70193a8a3ee18d952dcb26b0369d55
      Reviewed-on: https://go-review.googlesource.com/102815
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
      c0841ecd
    • Giovanni Bajo's avatar
      go/types: fix column reporting of invalid selector names · 69032440
      Giovanni Bajo authored
      Fixes #24645
      
      Change-Id: I914674451b6667c3ebaf012893503d9de58991ee
      Reviewed-on: https://go-review.googlesource.com/104155
      Run-TryBot: Giovanni Bajo <rasky@develer.com>
      Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
      69032440
    • Travis Bischel's avatar
      compress/gzip: do not count header bytes written in Write · f1deee0e
      Travis Bischel authored
      Before, if an underlying writer errored within 10 bytes (plus any gzip
      header metadata), a gzip.Write would erroneously report up to 10 bytes
      written that were not actually written of the input slice. This is
      especially problematic when the input slice is less than 10 bytes.
      
      The error came from counting the 10 header byte write. If writing the
      header is completely successful, the 10 bytes written is overridden by
      the flate write with the input slice.
      
      This removes counting the 10 required header bytes, and also changes the
      return to use zero until the slice is used.
      
      The old Write could return one byte written when it actually was not.
      This is difficult to verify because the smallest input slice is one
      byte; a test checking that the input slice was the byte written would be
      quite involved. Thankfully, gzip's minimum header write is 10 bytes. If
      we test that two bytes are not falsely written, we indirectly cover the
      one byte case.
      
      Fixes #24625
      
      Change-Id: I1c1f8cd791e0c4cffc22aa8acd95186582c832ba
      Reviewed-on: https://go-review.googlesource.com/103861Reviewed-by: 's avatarJoe Tsai <joetsai@google.com>
      Run-TryBot: Joe Tsai <joetsai@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      f1deee0e
    • isharipo's avatar
      test/fixedbugs: fix bug248 and bug345 · b44e73ea
      isharipo authored
      When test/run script was removed, these two tests
      were changed to be executed by test/run.go.
      Because errchk does not exit with non-zero status on
      errors, they were silently failing for a while.
      
      This change makes 2 things:
      
      1. Compile tested packages in GOROOT/test to match older runner script
         behavior (strictly required only in bug345, optional in bug248)
      
      2. Check command output with "(?m)^BUG" regexp.
         It approximates older `grep -q '^BUG' that was used before.
      
      See referenced issue for detailed explanation.
      
      Fixes #24629
      
      Change-Id: Ie888dcdb4e25cdbb19d434bbc5cb03eb633e9ee8
      Reviewed-on: https://go-review.googlesource.com/104095
      Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
      Reviewed-by: 's avatarEmmanuel Odeke <emm.odeke@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      b44e73ea
    • Matthew Dempsky's avatar
      cmd/compile: use newfuncname in dclfunc · 45ce10fa
      Matthew Dempsky authored
      Eliminates an inconsistency between user functions and generated
      functions.
      
      Passes toolstash-check.
      
      Change-Id: I946b511ca81d88a0024b5932cb50f3d8b9e808f4
      Reviewed-on: https://go-review.googlesource.com/103863
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
      45ce10fa
    • Meng Zhuo's avatar
      crypto/md5: add assembly implementation on arm64 · b834cd9a
      Meng Zhuo authored
      This change improves the performance of the block
      function used within crypto/md5 on arm64.  The following
      improvement was seen:
      
      name                 old time/op    new time/op     delta
      Hash8Bytes             1.62µs ± 0%     0.85µs ± 0%  -47.83%  (p=0.000 n=8+10)
      Hash1K                 8.82µs ± 0%     7.10µs ± 3%  -19.52%  (p=0.000 n=10+10)
      Hash8K                 59.5µs ± 2%     50.2µs ± 0%  -15.63%  (p=0.000 n=9+10)
      Hash8BytesUnaligned    1.63µs ± 0%     0.85µs ± 0%  -47.92%  (p=0.000 n=9+10)
      Hash1KUnaligned        14.1µs ± 0%      7.4µs ± 0%  -47.45%  (p=0.000 n=9+10)
      Hash8KUnaligned         101µs ± 0%       53µs ± 0%  -47.57%  (p=0.000 n=10+10)
      
      name                 old speed      new speed       delta
      Hash8Bytes           4.93MB/s ± 0%   9.44MB/s ± 0%  +91.61%  (p=0.000 n=9+10)
      Hash1K                116MB/s ± 0%    144MB/s ± 3%  +24.28%  (p=0.000 n=10+10)
      Hash8K                138MB/s ± 2%    163MB/s ± 0%  +18.52%  (p=0.000 n=9+10)
      Hash8BytesUnaligned  4.92MB/s ± 0%   9.44MB/s ± 0%  +92.04%  (p=0.000 n=9+10)
      Hash1KUnaligned      72.8MB/s ± 0%  138.6MB/s ± 0%  +90.29%  (p=0.000 n=9+8)
      Hash8KUnaligned      80.9MB/s ± 0%  154.2MB/s ± 0%  +90.71%  (p=0.000 n=10+10)
      
      Change-Id: I9e121a3132ff1b59e30f2de64e46106269065ecd
      Reviewed-on: https://go-review.googlesource.com/101875Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
      b834cd9a
    • Daniel Martí's avatar
      cmd: remove some unused parameters · 27226504
      Daniel Martí authored
      Change-Id: I9d2a4b8df324897e264d30801e95ddc0f0e75f3a
      Reviewed-on: https://go-review.googlesource.com/102337
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarIlya Tocar <ilya.tocar@intel.com>
      27226504
    • Matthew Dempsky's avatar
      cmd/compile: refactor constant rewriting · 0250ef91
      Matthew Dempsky authored
      Extract all rewrite-to-OLITERAL expressions to use a single setconst
      helper function.
      
      Does not pass toolstash-check for two reasons:
      
      1) We now consistently clear Left/Right/etc when rewriting Nodes into
      OLITERALs, which results in their inlining complexity being correctly
      computed. So more functions can now be inlined.
      
      2) We preserve Pos, so PC line tables change somewhat.
      
      Change-Id: I2b5c293bee7c69c2ccd704677f5aba4ec40e3155
      Reviewed-on: https://go-review.googlesource.com/103860
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarDaniel Martí <mvdan@mvdan.cc>
      0250ef91
  4. 01 Apr, 2018 1 commit
    • jimmyfrasche's avatar
      flag: correct zero values when printing defaults · 3c588b3f
      jimmyfrasche authored
      When the flag package first begin printing nonzero defaults, the test
      was against a fixed set of string representations of zero values.
      This worked until the string representation of a time.Duration
      changed from "0" to "0s", causing the zero Duration to register as
      nonzero. The flag package then added reflect-based code that fell back
      to the old test. This failed to work when a nonzero default for a flag
      happened to be the string representation of one the original fixed set
      of zero values in the original test. This change removes the original
      test, allowing the reflect-based code to be the only deciding factor.
      
      Fixes #23543
      
      Change-Id: I582ce554d6729e336fdd96fb27340674c15350d8
      Reviewed-on: https://go-review.googlesource.com/103867Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      3c588b3f