1. 09 May, 2018 12 commits
  2. 08 May, 2018 28 commits
    • Matt Juran's avatar
      test: fast GC+concurrency+types verification · e0adc35c
      Matt Juran authored
      This test runs independent goroutines modifying a comprehensive variety
      of local vars to look for garbage collector regressions. This test has
      been verified to trigger issue 22781 on the go1.9.2 tag. This test
      expands on test/fixedbugs/issue22781.go.
      
      Tests #22781
      
      Change-Id: Id32f8dde7ef650aea1b1b4cf518e6d045537bfdc
      Reviewed-on: https://go-review.googlesource.com/93715
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      e0adc35c
    • Martin Möhrmann's avatar
      cmd/compile: optimize map-clearing range idiom · aee71dd7
      Martin Möhrmann authored
      replace map clears of the form:
      
              for k := range m {
                      delete(m, k)
              }
      
      (where m is map with key type that is reflexive for ==)
      with a new runtime function that clears the maps backing
      array with a memclr and reinitializes the hmap struct.
      
      Map key types that for example contain floats are not
      replaced by this optimization since NaN keys cannot
      be deleted from maps using delete.
      
      name                           old time/op  new time/op  delta
      GoMapClear/Reflexive/1         92.2ns ± 1%  47.1ns ± 2%  -48.89%  (p=0.000 n=9+9)
      GoMapClear/Reflexive/10         108ns ± 1%    48ns ± 2%  -55.68%  (p=0.000 n=10+10)
      GoMapClear/Reflexive/100        303ns ± 2%   110ns ± 3%  -63.56%  (p=0.000 n=10+10)
      GoMapClear/Reflexive/1000      3.58µs ± 3%  1.23µs ± 2%  -65.49%  (p=0.000 n=9+10)
      GoMapClear/Reflexive/10000     28.2µs ± 3%  10.3µs ± 2%  -63.55%  (p=0.000 n=9+10)
      GoMapClear/NonReflexive/1       121ns ± 2%   124ns ± 7%     ~     (p=0.097 n=10+10)
      GoMapClear/NonReflexive/10      137ns ± 2%   139ns ± 3%   +1.53%  (p=0.033 n=10+10)
      GoMapClear/NonReflexive/100     331ns ± 3%   334ns ± 2%     ~     (p=0.342 n=10+10)
      GoMapClear/NonReflexive/1000   3.64µs ± 3%  3.64µs ± 2%     ~     (p=0.887 n=9+10)
      GoMapClear/NonReflexive/10000  28.1µs ± 2%  28.4µs ± 3%     ~     (p=0.247 n=10+10)
      
      Fixes #20138
      
      Change-Id: I181332a8ef434a4f0d89659f492d8711db3f3213
      Reviewed-on: https://go-review.googlesource.com/110055Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      aee71dd7
    • Rob Pike's avatar
      doc/faq: tidy up a couple of nits · cd1976db
      Rob Pike authored
      The phrase "couple X" is considered colloquial, so make that "a couple of X".
      Also move the start of a sentence to a new line in a couple of places
      for easier editing, in one place thereby removing two spaces after a period.
      
      Change-Id: If5ef05eb496afc235f8f0134c4e7346375a65181
      Reviewed-on: https://go-review.googlesource.com/112176Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      cd1976db
    • Hana (Hyang-Ah) Kim's avatar
      cmd/trace: handle invalid goid para in /trace · 43b18f42
      Hana (Hyang-Ah) Kim authored
      Change-Id: I1cb7c8b70a5ae16386f6abb577c23d821f7ff7f0
      Reviewed-on: https://go-review.googlesource.com/112197Reviewed-by: 's avatarPeter Weinberger <pjw@google.com>
      Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
      43b18f42
    • Hana (Hyang-Ah) Kim's avatar
      cmd/trace: skip links for buckets with 0 count · 9eface70
      Hana (Hyang-Ah) Kim authored
      Change-Id: Ib1c2f7cc8e8f631ed9e74161699332f492d4cb0d
      Reviewed-on: https://go-review.googlesource.com/112196Reviewed-by: 's avatarPeter Weinberger <pjw@google.com>
      9eface70
    • jimmyfrasche's avatar
      doc: make front page video respond to layout changes (1/2) · d96221f2
      jimmyfrasche authored
      The videos on the front page are always the same width, regardless of
      the viewport width. These changes let the video fill the space given
      to its container regardless of layout. It uses the standard hack for
      making iframes responsive, but the videos are loaded at random and do
      not have uniform aspect ratios so that information is injected into the
      DOM using custom properties. If these are not supported, it falls back
      to the same layout present before this change.
      
      Note: this change also requires CL 108678 to complete the fix,
      though either CL without the other is harmless.
      
      Updates #24997.
      
      Change-Id: I2f93dc21ffe01d99ce0e175e9dd0e3d486fddc9f
      Reviewed-on: https://go-review.googlesource.com/108677
      Run-TryBot: Andrew Bonventre <andybons@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarAndrew Bonventre <andybons@golang.org>
      d96221f2
    • Keith Randall's avatar
      cmd/compile: rename memory-using operations · f3234866
      Keith Randall authored
      Some *mem ops are loads, some are stores, some are modifications.
      Replace mem->load for the loads.
      Replace mem->store for the stores.
      Replace mem->modify for the load-modify-stores.
      
      The only semantic change in this CL is to mark
      ADD(Q|L)constmodify (which used to be ADD(Q|L)constmem) as
      both a read and a write, instead of just a write. This is arguably
      a bug fix, but the bug isn't triggerable at the moment, see CL 112157.
      
      Change-Id: Iccb45aea817b606adb2d712ff99b10ee28e4616a
      Reviewed-on: https://go-review.googlesource.com/112159
      Run-TryBot: Keith Randall <khr@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      f3234866
    • Keith Randall's avatar
      cmd/compile: remove unnecessary convert ops on 32-bit archs · 6b0941a1
      Keith Randall authored
      Missing rule to fold out Convert ops on 32-bit architectures.
      
      This comes up with expressions like
      unsafe.Pointer(uintptr(p) + x)
      
      Change-Id: I429e968e5d1a3e13a386ddd29a08ebb6d7dd938a
      Reviewed-on: https://go-review.googlesource.com/112158Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      Reviewed-by: 's avatarDavid Chase <drchase@google.com>
      6b0941a1
    • Keith Randall's avatar
      cmd/compile: mark modify ops as both read and write · dffc915b
      Keith Randall authored
      If the modify ops operate on a variable, we should tell the liveness
      pass that the variable is still live before the instruction.
      
      This looks like a bug, but I don't think there's any way to trigger
      it at the moment. It only matters for pointer-containing values, and
      the modify ops don't normally work on pointers. Even when I reach for
      unsafe.Pointer tricks, I can't get ADDLmodify to work on pointers, as
      there's always a Convert or VarDef preventing the coalescing.
      
      TL;DR I can't figure out a test for this. But we should probably
      fix it anyway.
      
      Change-Id: I971c62616dec51a33788b7634e6478e1bfcd6260
      Reviewed-on: https://go-review.googlesource.com/112157Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      dffc915b
    • Paul Jolly's avatar
      cmd/go: fix go list -test where C is a dependency. · 941b3b77
      Paul Jolly authored
      Currently go list -test runtime/cgo fails with an index out of range
      error. This appears to be because the updating of import paths that
      happens as part of -test doesn't take into account the fact that the
      Internal.Imports of a package do not contain "C", whereas the public
      Imports do.
      
      Therefore we skip the public Import of "C" if it exists and continue.
      
      Change-Id: I5cdc8968890fa7e5da3e375718606037d3282754
      Reviewed-on: https://go-review.googlesource.com/111175
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      941b3b77
    • Chotepud Teo's avatar
      cmd/go: added missing space to pkg-config errors · cf4e5597
      Chotepud Teo authored
      pkg-config errors were missing a space between pkg-config flags and packages
      e.g.  pkg-config --cflags --staticsdl2
      
      Fixes #25260
      
      Change-Id: Iacecb697c5782c4822db9eefa1a2e4c4daf91a69
      GitHub-Last-Rev: 2adf8576be66e31160c109a79f3853feac293f1b
      GitHub-Pull-Request: golang/go#25261
      Reviewed-on: https://go-review.googlesource.com/111638
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      cf4e5597
    • Brian Kessler's avatar
      math/big: implement Lehmer's extended GCD algorithm · 50649a96
      Brian Kessler authored
      Updates #15833
      
      The extended GCD algorithm can be implemented using
      Lehmer's algorithm with additional updates for the
      cosequences following Algorithm 10.45 from Cohen et al.
      "Handbook of Elliptic and Hyperelliptic Curve Cryptography" pp 192.
      This brings the speed of the extended GCD calculation within
      ~2x of the base GCD calculation.  There is a slight degradation in
      the non-extended GCD speed for small inputs (1-2 words) due to the
      additional code to handle the extended updates.
      
      name                          old time/op    new time/op    delta
      GCD10x10/WithoutXY-4             262ns ± 1%     266ns ± 2%     ~     (p=0.333 n=5+5)
      GCD10x10/WithXY-4               1.42µs ± 2%    0.74µs ± 3%  -47.90%  (p=0.008 n=5+5)
      GCD10x100/WithoutXY-4            520ns ± 2%     539ns ± 1%   +3.81%  (p=0.008 n=5+5)
      GCD10x100/WithXY-4              2.32µs ± 1%    1.67µs ± 0%  -27.80%  (p=0.008 n=5+5)
      GCD10x1000/WithoutXY-4          1.40µs ± 1%    1.45µs ± 2%   +3.26%  (p=0.016 n=4+5)
      GCD10x1000/WithXY-4             4.78µs ± 1%    3.43µs ± 1%  -28.37%  (p=0.008 n=5+5)
      GCD10x10000/WithoutXY-4         10.0µs ± 0%    10.2µs ± 3%   +1.80%  (p=0.008 n=5+5)
      GCD10x10000/WithXY-4            20.9µs ± 3%    17.9µs ± 1%  -14.20%  (p=0.008 n=5+5)
      GCD10x100000/WithoutXY-4        96.8µs ± 0%    96.3µs ± 1%     ~     (p=0.310 n=5+5)
      GCD10x100000/WithXY-4            196µs ± 3%     159µs ± 2%  -18.61%  (p=0.008 n=5+5)
      GCD100x100/WithoutXY-4          2.53µs ±15%    2.34µs ± 0%   -7.35%  (p=0.008 n=5+5)
      GCD100x100/WithXY-4             19.3µs ± 0%     3.9µs ± 1%  -79.58%  (p=0.008 n=5+5)
      GCD100x1000/WithoutXY-4         4.23µs ± 0%    4.17µs ± 3%     ~     (p=0.127 n=5+5)
      GCD100x1000/WithXY-4            22.8µs ± 1%     7.5µs ±10%  -67.00%  (p=0.008 n=5+5)
      GCD100x10000/WithoutXY-4        19.1µs ± 0%    19.0µs ± 0%     ~     (p=0.095 n=5+5)
      GCD100x10000/WithXY-4           75.1µs ± 2%    30.5µs ± 2%  -59.38%  (p=0.008 n=5+5)
      GCD100x100000/WithoutXY-4        170µs ± 5%     167µs ± 1%     ~     (p=1.000 n=5+5)
      GCD100x100000/WithXY-4           542µs ± 2%     267µs ± 2%  -50.79%  (p=0.008 n=5+5)
      GCD1000x1000/WithoutXY-4        28.0µs ± 0%    27.1µs ± 0%   -3.29%  (p=0.008 n=5+5)
      GCD1000x1000/WithXY-4            329µs ± 0%      42µs ± 1%  -87.12%  (p=0.008 n=5+5)
      GCD1000x10000/WithoutXY-4       47.2µs ± 0%    46.4µs ± 0%   -1.65%  (p=0.016 n=5+4)
      GCD1000x10000/WithXY-4           607µs ± 9%     123µs ± 1%  -79.70%  (p=0.008 n=5+5)
      GCD1000x100000/WithoutXY-4       260µs ±17%     245µs ± 0%     ~     (p=0.056 n=5+5)
      GCD1000x100000/WithXY-4         3.64ms ± 1%    0.93ms ± 1%  -74.41%  (p=0.016 n=4+5)
      GCD10000x10000/WithoutXY-4       513µs ± 0%     507µs ± 0%   -1.22%  (p=0.008 n=5+5)
      GCD10000x10000/WithXY-4         7.44ms ± 1%    1.00ms ± 0%  -86.58%  (p=0.008 n=5+5)
      GCD10000x100000/WithoutXY-4     1.23ms ± 0%    1.23ms ± 1%     ~     (p=0.056 n=5+5)
      GCD10000x100000/WithXY-4        37.3ms ± 0%     7.3ms ± 1%  -80.45%  (p=0.008 n=5+5)
      GCD100000x100000/WithoutXY-4    24.2ms ± 0%    24.2ms ± 0%     ~     (p=0.841 n=5+5)
      GCD100000x100000/WithXY-4        505ms ± 1%      56ms ± 1%  -88.92%  (p=0.008 n=5+5)
      
      Change-Id: I25f42ab8c55033acb83cc32bb03c12c1963925e8
      Reviewed-on: https://go-review.googlesource.com/78755Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
      Run-TryBot: Robert Griesemer <gri@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      50649a96
    • Ian Lance Taylor's avatar
      cmd/go: add -test to go list usage line · 25858cce
      Ian Lance Taylor authored
      Change-Id: Ia57f0ef1a3bdeb06346e175d67979e2a4512622d
      Reviewed-on: https://go-review.googlesource.com/112160
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      25858cce
    • Zhou Peng's avatar
      plugin: make stub lookup signature match dlopen version · 5b976d37
      Zhou Peng authored
      Change-Id: I64958f8f1a935adc07868362975447d0c0033084
      Reviewed-on: https://go-review.googlesource.com/111716Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      5b976d37
    • Michael Munday's avatar
      cmd/compile: fix Zero-to-Load forwarding rules · fbfbf03b
      Michael Munday authored
      Avoid using values that do not dominate the block the Zero op is in.
      Should fix the SSA check builder.
      
      The additional OffPtr ops inserted by these rules should always be
      optimized away when the Load is replaced with a const zero.
      
      Fixes #25288.
      
      Change-Id: I4163b58e60364f77c8a206ba084073a58ca6320a
      Reviewed-on: https://go-review.googlesource.com/112136
      Run-TryBot: Michael Munday <mike.munday@ibm.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      fbfbf03b
    • Michael Munday's avatar
      cmd/compile: simplify shift lowering on s390x · 8af0c77d
      Michael Munday authored
      Use conditional moves instead of subtractions with borrow to handle
      saturation cases. This allows us to delete the SUBE/SUBEW ops and
      associated rules from the SSA backend. Using conditional moves also
      means we can detect when shift values are masked so I've added some
      new rules to constant fold the relevant comparisons and masking ops.
      
      Also use the new shiftIsBounded() function to avoid generating code
      to handle saturation cases where possible.
      
      Updates #25167 for s390x.
      
      Change-Id: Ief9991c91267c9151ce4c5ec07642abb4dcc1c0d
      Reviewed-on: https://go-review.googlesource.com/110070
      Run-TryBot: Michael Munday <mike.munday@ibm.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      8af0c77d
    • Elias Naur's avatar
      misc/ios: retry iOS launch even if no device app path was found · 704893b1
      Elias Naur authored
      Now that the iOS exec wrapper uninstalls any existing test app before
      installing a new, looking up the device app path might fail. Before,
      the lookup always succeeded (even though the path reported might be
      stale).
      
      For the iOS builder.
      
      Change-Id: I5667b6fae15f88745bdee796db219a429a26e203
      Reviewed-on: https://go-review.googlesource.com/112075
      Run-TryBot: Elias Naur <elias.naur@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarHyang-Ah Hana Kim <hyangah@gmail.com>
      704893b1
    • Richard Miller's avatar
      syscall: eliminate aliasing of syscall error strings in Plan 9 · 1b494876
      Richard Miller authored
      To avoid allocation between entersyscall and exitsyscall in Plan 9,
      syscall error strings retrieved from the OS were being stored in
      a shared buffer for each M, leading to overwriting of error strings
      by subsequent syscalls, and potential confusion if exitsyscall
      switched to a different M.  Instead, the error string is now
      retrieved to the G stack and then copied to a new allocated array
      after exitsyscall.
      
      A new test TestPlan9Syserr is provided to confirm the correction.
      
      Fixes #13770
      Fixes #24921
      
      Change-Id: I013c4a42baae80d03a5b61d828396527189f5551
      Reviewed-on: https://go-review.googlesource.com/111195Reviewed-by: 's avatarDavid du Colombier <0intro@gmail.com>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      Run-TryBot: David du Colombier <0intro@gmail.com>
      1b494876
    • Tobias Klauser's avatar
      debug/elf: add machine and OSABI constants · d148cbe1
      Tobias Klauser authored
      Provide a complete list of EM_* and ELFOSABI_* constants.
      
      Compiled from the tables at
      http://www.sco.com/developers/gabi/latest/ch4.eheader.html
      and llvm/BinaryFormat/ELF.h from LLVM.
      
      Change-Id: Ice1e1476076fafdb8bb8af848caec6d80a82c452
      Reviewed-on: https://go-review.googlesource.com/112115
      Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      d148cbe1
    • Joe Kyo's avatar
      encoding/binary: returns length of bool slice in intDataSize · 5188b4de
      Joe Kyo authored
      intDataSize should return length of bool slice, so functions
      Read and Write can use the fast path to process bool slice.
      
      Change-Id: I8cd275e3ffea82024850662d86caca64bd91bf70
      Reviewed-on: https://go-review.googlesource.com/112135Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      5188b4de
    • Tobias Klauser's avatar
      cmd/compile: use nodl in zeroResults · 6428c892
      Tobias Klauser authored
      Use nodl instead of nod to avoid setting and resetting lineo.
      
      Passes toolstash-check.
      
      Updates #19683
      
      Change-Id: I6a47a7ba43a11352767029eced29f08dff8501a2
      Reviewed-on: https://go-review.googlesource.com/100335
      Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
      6428c892
    • Richard Musiol's avatar
      math, math/big: add wasm architecture · b00f72e0
      Richard Musiol authored
      This commit adds the wasm architecture to the math package.
      
      Updates #18892
      
      Change-Id: I5cc38552a31b193d35fb81ae87600a76b8b9e9b5
      Reviewed-on: https://go-review.googlesource.com/106996Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
      b00f72e0
    • Richard Musiol's avatar
      internal/bytealg: add wasm architecture · b382fe28
      Richard Musiol authored
      This commit adds the wasm architecture to the internal/bytealg package.
      
      Some parts of the assembly code have been extracted from WebAssembly
      bytecode generated with Emscripten (which uses musl libc).
      
      Updates #18892
      
      Change-Id: Iba7f7158356b816c9ad03ca9223903a41a024da6
      Reviewed-on: https://go-review.googlesource.com/103915Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      b382fe28
    • Lynn Boger's avatar
      cmd/compile,test: combine byte loads and stores on ppc64le · 28edaf45
      Lynn Boger authored
      CL 74410 added rules to combine consecutive byte loads and
      stores when the byte order was little endian for ppc64le. This
      is the corresponding change for bytes that are in big endian order.
      These rules are all intended for a little endian target arch.
      
      This adds new testcases in test/codegen/memcombine.go
      
      Fixes #22496
      Updates #24242
      
      Benchmark improvement for encoding/binary:
      name                      old time/op    new time/op    delta
      ReadSlice1000Int32s-16      11.0µs ± 0%     9.0µs ± 0%  -17.47%  (p=0.029 n=4+4)
      ReadStruct-16               2.47µs ± 1%    2.48µs ± 0%   +0.67%  (p=0.114 n=4+4)
      ReadInts-16                  642ns ± 1%     630ns ± 1%   -2.02%  (p=0.029 n=4+4)
      WriteInts-16                 654ns ± 0%     653ns ± 1%   -0.08%  (p=0.629 n=4+4)
      WriteSlice1000Int32s-16     8.75µs ± 0%    8.20µs ± 0%   -6.19%  (p=0.029 n=4+4)
      PutUint16-16                1.16ns ± 0%    0.93ns ± 0%  -19.83%  (p=0.029 n=4+4)
      PutUint32-16                1.16ns ± 0%    0.93ns ± 0%  -19.83%  (p=0.029 n=4+4)
      PutUint64-16                1.85ns ± 0%    0.93ns ± 0%  -49.73%  (p=0.029 n=4+4)
      LittleEndianPutUint16-16    1.03ns ± 0%    0.93ns ± 0%   -9.71%  (p=0.029 n=4+4)
      LittleEndianPutUint32-16    0.93ns ± 0%    0.93ns ± 0%     ~     (all equal)
      LittleEndianPutUint64-16    0.93ns ± 0%    0.93ns ± 0%     ~     (all equal)
      PutUvarint32-16             43.0ns ± 0%    43.1ns ± 0%   +0.12%  (p=0.429 n=4+4)
      PutUvarint64-16              174ns ± 0%     175ns ± 0%   +0.29%  (p=0.429 n=4+4)
      
      Updates made to functions in gcm.go to enable their matching. An existing
      testcase prevents these functions from being replaced by those in encoding/binary
      due to import dependencies.
      
      Change-Id: Idb3bd1e6e7b12d86cd828fb29cb095848a3e485a
      Reviewed-on: https://go-review.googlesource.com/98136
      Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      28edaf45
    • Michael Munday's avatar
      cmd/compile: add some generic composite type optimizations · f31a18de
      Michael Munday authored
      Propagate values through some wide Zero/Move operations. Among
      other things this allows us to optimize some kinds of array
      initialization. For example, the following code no longer
      requires a temporary be allocated on the stack. Instead it
      writes the values directly into the return value.
      
      func f(i uint32) [4]uint32 {
          return [4]uint32{i, i+1, i+2, i+3}
      }
      
      The return value is unnecessarily cleared but removing that is
      probably a task for dead store analysis (I think it needs to
      be able to match multiple Store ops to wide Zero ops).
      
      In order to reliably remove stack variables that are rendered
      unnecessary by these new rules I've added a new generic version
      of the unread autos elimination pass.
      
      These rules are triggered more than 5000 times when building and
      testing the standard library.
      
      Updates #15925 (fixes for arrays of up to 4 elements).
      Updates #24386 (fixes for up to 4 kept elements).
      Updates #24416.
      
      compilebench results:
      
      name       old time/op       new time/op       delta
      Template         353ms ± 5%        359ms ± 3%    ~     (p=0.143 n=10+10)
      Unicode          219ms ± 1%        217ms ± 4%    ~     (p=0.740 n=7+10)
      GoTypes          1.26s ± 1%        1.26s ± 2%    ~     (p=0.549 n=9+10)
      Compiler         6.00s ± 1%        6.08s ± 1%  +1.42%  (p=0.000 n=9+8)
      SSA              15.3s ± 2%        15.6s ± 1%  +2.43%  (p=0.000 n=10+10)
      Flate            237ms ± 2%        240ms ± 2%  +1.31%  (p=0.015 n=10+10)
      GoParser         285ms ± 1%        285ms ± 1%    ~     (p=0.878 n=8+8)
      Reflect          797ms ± 3%        807ms ± 2%    ~     (p=0.065 n=9+10)
      Tar              334ms ± 0%        335ms ± 4%    ~     (p=0.460 n=8+10)
      XML              419ms ± 0%        423ms ± 1%  +0.91%  (p=0.001 n=7+9)
      StdCmd           46.0s ± 0%        46.4s ± 0%  +0.85%  (p=0.000 n=9+9)
      
      name       old user-time/op  new user-time/op  delta
      Template         337ms ± 3%        346ms ± 5%    ~     (p=0.053 n=9+10)
      Unicode          205ms ±10%        205ms ± 8%    ~     (p=1.000 n=10+10)
      GoTypes          1.22s ± 2%        1.21s ± 3%    ~     (p=0.436 n=10+10)
      Compiler         5.85s ± 1%        5.93s ± 0%  +1.46%  (p=0.000 n=10+8)
      SSA              14.9s ± 1%        15.3s ± 1%  +2.62%  (p=0.000 n=10+10)
      Flate            229ms ± 4%        228ms ± 6%    ~     (p=0.796 n=10+10)
      GoParser         271ms ± 3%        275ms ± 4%    ~     (p=0.165 n=10+10)
      Reflect          779ms ± 5%        775ms ± 2%    ~     (p=0.971 n=10+10)
      Tar              317ms ± 4%        319ms ± 5%    ~     (p=0.853 n=10+10)
      XML              404ms ± 4%        409ms ± 5%    ~     (p=0.436 n=10+10)
      
      name       old alloc/op      new alloc/op      delta
      Template        34.9MB ± 0%       35.0MB ± 0%  +0.26%  (p=0.000 n=10+10)
      Unicode         29.3MB ± 0%       29.3MB ± 0%  +0.02%  (p=0.000 n=10+10)
      GoTypes          115MB ± 0%        115MB ± 0%  +0.30%  (p=0.000 n=10+10)
      Compiler         519MB ± 0%        521MB ± 0%  +0.30%  (p=0.000 n=10+10)
      SSA             1.55GB ± 0%       1.57GB ± 0%  +1.34%  (p=0.000 n=10+9)
      Flate           24.1MB ± 0%       24.2MB ± 0%  +0.10%  (p=0.000 n=10+10)
      GoParser        28.1MB ± 0%       28.1MB ± 0%  +0.07%  (p=0.000 n=10+10)
      Reflect         78.7MB ± 0%       78.7MB ± 0%  +0.03%  (p=0.000 n=8+10)
      Tar             34.4MB ± 0%       34.5MB ± 0%  +0.12%  (p=0.000 n=10+10)
      XML             43.2MB ± 0%       43.2MB ± 0%  +0.13%  (p=0.000 n=10+10)
      
      name       old allocs/op     new allocs/op     delta
      Template          330k ± 0%         330k ± 0%  -0.01%  (p=0.017 n=10+10)
      Unicode           337k ± 0%         337k ± 0%  +0.01%  (p=0.000 n=9+10)
      GoTypes          1.15M ± 0%        1.15M ± 0%  +0.03%  (p=0.000 n=10+10)
      Compiler         4.77M ± 0%        4.77M ± 0%  +0.03%  (p=0.000 n=9+10)
      SSA              12.5M ± 0%        12.6M ± 0%  +1.16%  (p=0.000 n=10+10)
      Flate             221k ± 0%         221k ± 0%  +0.05%  (p=0.000 n=9+10)
      GoParser          275k ± 0%         275k ± 0%  +0.01%  (p=0.014 n=10+9)
      Reflect           944k ± 0%         944k ± 0%  -0.02%  (p=0.000 n=10+10)
      Tar               324k ± 0%         323k ± 0%  -0.12%  (p=0.000 n=10+10)
      XML               384k ± 0%         384k ± 0%  -0.01%  (p=0.001 n=10+10)
      
      name       old object-bytes  new object-bytes  delta
      Template         476kB ± 0%        476kB ± 0%  -0.04%  (p=0.000 n=10+10)
      Unicode          218kB ± 0%        218kB ± 0%    ~     (all equal)
      GoTypes         1.58MB ± 0%       1.58MB ± 0%  -0.04%  (p=0.000 n=10+10)
      Compiler        6.25MB ± 0%       6.24MB ± 0%  -0.09%  (p=0.000 n=10+10)
      SSA             15.9MB ± 0%       16.1MB ± 0%  +1.22%  (p=0.000 n=10+10)
      Flate            304kB ± 0%        304kB ± 0%  -0.13%  (p=0.000 n=10+10)
      GoParser         370kB ± 0%        370kB ± 0%  -0.00%  (p=0.000 n=10+10)
      Reflect         1.27MB ± 0%       1.27MB ± 0%  -0.12%  (p=0.000 n=10+10)
      Tar              421kB ± 0%        419kB ± 0%  -0.64%  (p=0.000 n=10+10)
      XML              518kB ± 0%        517kB ± 0%  -0.12%  (p=0.000 n=10+10)
      
      name       old export-bytes  new export-bytes  delta
      Template        16.7kB ± 0%       16.7kB ± 0%    ~     (all equal)
      Unicode         6.52kB ± 0%       6.52kB ± 0%    ~     (all equal)
      GoTypes         29.2kB ± 0%       29.2kB ± 0%    ~     (all equal)
      Compiler        88.0kB ± 0%       88.0kB ± 0%    ~     (all equal)
      SSA              109kB ± 0%        109kB ± 0%    ~     (all equal)
      Flate           4.49kB ± 0%       4.49kB ± 0%    ~     (all equal)
      GoParser        8.10kB ± 0%       8.10kB ± 0%    ~     (all equal)
      Reflect         7.71kB ± 0%       7.71kB ± 0%    ~     (all equal)
      Tar             9.15kB ± 0%       9.15kB ± 0%    ~     (all equal)
      XML             12.3kB ± 0%       12.3kB ± 0%    ~     (all equal)
      
      name       old text-bytes    new text-bytes    delta
      HelloSize        676kB ± 0%        672kB ± 0%  -0.59%  (p=0.000 n=10+10)
      CmdGoSize       7.26MB ± 0%       7.24MB ± 0%  -0.18%  (p=0.000 n=10+10)
      
      name       old data-bytes    new data-bytes    delta
      HelloSize       10.2kB ± 0%       10.2kB ± 0%    ~     (all equal)
      CmdGoSize        248kB ± 0%        248kB ± 0%    ~     (all equal)
      
      name       old bss-bytes     new bss-bytes     delta
      HelloSize        125kB ± 0%        125kB ± 0%    ~     (all equal)
      CmdGoSize        145kB ± 0%        145kB ± 0%    ~     (all equal)
      
      name       old exe-bytes     new exe-bytes     delta
      HelloSize       1.46MB ± 0%       1.45MB ± 0%  -0.31%  (p=0.000 n=10+10)
      CmdGoSize       14.7MB ± 0%       14.7MB ± 0%  -0.17%  (p=0.000 n=10+10)
      
      Change-Id: Ic72b0c189dd542f391e1c9ab88a76e9148dc4285
      Reviewed-on: https://go-review.googlesource.com/106495
      Run-TryBot: Michael Munday <mike.munday@ibm.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      f31a18de
    • Ben Shi's avatar
      cmd/compile: emit more compact 386 instructions · 098ca846
      Ben Shi authored
      ADDL/SUBL/ANDL/ORL/XORL can have a memory operand as destination,
      and this CL optimize the compiler to emit such instructions on
      386 for more compact binary.
      
      Here is test report:
      1. The total size of pkg/linux_386/ and pkg/tool/linux_386/ decreases
      about 14KB.
      (pkg/linux_386/cmd/compile/ and pkg/tool/linux_386/compile are excluded)
      
      2. The go1 benchmark shows little change, excluding ±2% noise.
      name                     old time/op    new time/op    delta
      BinaryTree17-4              3.34s ± 2%     3.38s ± 2%  +1.27%  (p=0.000 n=40+39)
      Fannkuch11-4                3.55s ± 1%     3.51s ± 1%  -1.33%  (p=0.000 n=40+40)
      FmtFprintfEmpty-4          46.3ns ± 3%    46.9ns ± 4%  +1.41%  (p=0.002 n=40+40)
      FmtFprintfString-4         80.8ns ± 3%    80.4ns ± 6%  -0.54%  (p=0.044 n=40+40)
      FmtFprintfInt-4            93.0ns ± 3%    92.2ns ± 4%  -0.88%  (p=0.007 n=39+40)
      FmtFprintfIntInt-4          144ns ± 5%     145ns ± 2%  +0.78%  (p=0.015 n=40+40)
      FmtFprintfPrefixedInt-4     184ns ± 2%     182ns ± 2%  -1.06%  (p=0.004 n=40+40)
      FmtFprintfFloat-4           415ns ± 4%     419ns ± 4%    ~     (p=0.434 n=40+40)
      FmtManyArgs-4               615ns ± 3%     619ns ± 3%    ~     (p=0.100 n=40+40)
      GobDecode-4                7.30ms ± 6%    7.36ms ± 6%    ~     (p=0.074 n=40+40)
      GobEncode-4                7.10ms ± 6%    7.21ms ± 5%    ~     (p=0.082 n=40+39)
      Gzip-4                      364ms ± 3%     362ms ± 6%  -0.71%  (p=0.020 n=40+40)
      Gunzip-4                   42.4ms ± 3%    42.2ms ± 3%    ~     (p=0.303 n=40+40)
      HTTPClientServer-4         62.9µs ± 1%    62.9µs ± 1%    ~     (p=0.768 n=38+39)
      JSONEncode-4               21.4ms ± 4%    21.5ms ± 5%    ~     (p=0.210 n=40+40)
      JSONDecode-4               67.7ms ± 3%    67.9ms ± 4%    ~     (p=0.713 n=40+40)
      Mandelbrot200-4            5.18ms ± 3%    5.21ms ± 3%  +0.59%  (p=0.021 n=40+40)
      GoParse-4                  3.35ms ± 3%    3.34ms ± 2%    ~     (p=0.996 n=40+40)
      RegexpMatchEasy0_32-4      98.5ns ± 5%    96.3ns ± 4%  -2.15%  (p=0.001 n=40+40)
      RegexpMatchEasy0_1K-4       851ns ± 4%     850ns ± 5%    ~     (p=0.700 n=40+40)
      RegexpMatchEasy1_32-4       105ns ± 7%     107ns ± 4%  +1.50%  (p=0.017 n=40+40)
      RegexpMatchEasy1_1K-4      1.03µs ± 5%    1.03µs ± 4%    ~     (p=0.992 n=40+40)
      RegexpMatchMedium_32-4      130ns ± 6%     128ns ± 4%  -1.66%  (p=0.012 n=40+40)
      RegexpMatchMedium_1K-4     44.0µs ± 5%    43.6µs ± 3%    ~     (p=0.704 n=40+40)
      RegexpMatchHard_32-4       2.29µs ± 3%    2.23µs ± 4%  -2.38%  (p=0.000 n=40+40)
      RegexpMatchHard_1K-4       69.0µs ± 3%    68.1µs ± 3%  -1.28%  (p=0.003 n=40+40)
      Revcomp-4                   1.85s ± 2%     1.87s ± 3%  +1.11%  (p=0.000 n=40+40)
      Template-4                 69.8ms ± 3%    69.6ms ± 3%    ~     (p=0.125 n=40+40)
      TimeParse-4                 442ns ± 5%     440ns ± 3%    ~     (p=0.585 n=40+40)
      TimeFormat-4                419ns ± 3%     420ns ± 3%    ~     (p=0.824 n=40+40)
      [Geo mean]                 67.3µs         67.2µs       -0.11%
      
      name                     old speed      new speed      delta
      GobDecode-4               105MB/s ± 6%   104MB/s ± 6%    ~     (p=0.074 n=40+40)
      GobEncode-4               108MB/s ± 7%   107MB/s ± 5%    ~     (p=0.080 n=40+39)
      Gzip-4                   53.3MB/s ± 3%  53.7MB/s ± 6%  +0.73%  (p=0.021 n=40+40)
      Gunzip-4                  458MB/s ± 3%   460MB/s ± 3%    ~     (p=0.301 n=40+40)
      JSONEncode-4             90.8MB/s ± 4%  90.3MB/s ± 4%    ~     (p=0.213 n=40+40)
      JSONDecode-4             28.7MB/s ± 3%  28.6MB/s ± 4%    ~     (p=0.679 n=40+40)
      GoParse-4                17.3MB/s ± 3%  17.3MB/s ± 2%    ~     (p=1.000 n=40+40)
      RegexpMatchEasy0_32-4     325MB/s ± 5%   333MB/s ± 4%  +2.44%  (p=0.000 n=40+38)
      RegexpMatchEasy0_1K-4    1.20GB/s ± 4%  1.21GB/s ± 5%    ~     (p=0.684 n=40+40)
      RegexpMatchEasy1_32-4     303MB/s ± 7%   298MB/s ± 4%  -1.52%  (p=0.022 n=40+40)
      RegexpMatchEasy1_1K-4     995MB/s ± 5%   996MB/s ± 4%    ~     (p=0.996 n=40+40)
      RegexpMatchMedium_32-4   7.67MB/s ± 6%  7.80MB/s ± 4%  +1.68%  (p=0.011 n=40+40)
      RegexpMatchMedium_1K-4   23.3MB/s ± 5%  23.5MB/s ± 3%    ~     (p=0.697 n=40+40)
      RegexpMatchHard_32-4     14.0MB/s ± 3%  14.3MB/s ± 4%  +2.43%  (p=0.000 n=40+40)
      RegexpMatchHard_1K-4     14.8MB/s ± 3%  15.0MB/s ± 3%  +1.30%  (p=0.003 n=40+40)
      Revcomp-4                 137MB/s ± 2%   136MB/s ± 3%  -1.10%  (p=0.000 n=40+40)
      Template-4               27.8MB/s ± 3%  27.9MB/s ± 3%    ~     (p=0.128 n=40+40)
      [Geo mean]               79.6MB/s       79.9MB/s       +0.28%
      
      Change-Id: I02a3efc125dc81e18fc8495eb2bf1bba59ab8733
      Reviewed-on: https://go-review.googlesource.com/110157
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      Reviewed-by: 's avatarIlya Tocar <ilya.tocar@intel.com>
      098ca846
    • Shengyu Zhang's avatar
      text/scanner: return RawString token rather than String for raw string literals · c8915a06
      Shengyu Zhang authored
      Fixes #23675
      
      Change-Id: I78e13d1ca90400e4dd48674b93bb6e2e30718d97
      GitHub-Last-Rev: f2b3a59d2bd92f28fc06360e7920c37b9da0af01
      GitHub-Pull-Request: golang/go#25287
      Reviewed-on: https://go-review.googlesource.com/112037Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
      Run-TryBot: Robert Griesemer <gri@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      c8915a06
    • Richard Musiol's avatar
      runtime: add js/wasm architecture · 35ea6246
      Richard Musiol authored
      This commit adds the js/wasm architecture to the runtime package.
      Currently WebAssembly has no support for threads yet, see
      https://github.com/WebAssembly/design/issues/1073. Because of that,
      there is no preemption of goroutines and no sysmon goroutine.
      
      Design doc: https://docs.google.com/document/d/131vjr4DH6JFnb-blm_uRdaC0_Nv3OUwjEY5qVCxCup4
      About WebAssembly assembly files: https://docs.google.com/document/d/1GRmy3rA4DiYtBlX-I1Jr_iHykbX8EixC3Mq0TCYqbKc
      
      Updates #18892
      
      Change-Id: I7f12d21b5180500d55ae9fd2f7e926a1731db391
      Reviewed-on: https://go-review.googlesource.com/103877
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarAustin Clements <austin@google.com>
      35ea6246