1. 24 Apr, 2019 9 commits
    • Joel Sing's avatar
      cmd/dist: handle arm64 as a machine hardware name · a21a6e44
      Joel Sing authored
      OpenBSD/arm64 reports itself as arm64 from `uname -m` - this currently
      matches as gohostarch=arm, rather than gohostarch=arm64. Correct this
      by matching on both aarch64 and arm64 (the alternative would be to use
      `uname -p`, however that's likely to cause upset elsewhere).
      
      Updates #31656
      
      Change-Id: I7b2da93495d808e704caf032b3fadc984077769e
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173598Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      a21a6e44
    • Marcel van Lohuizen's avatar
      unicode: update table using new generator in x/text · e308d41f
      Marcel van Lohuizen authored
      The changes in Unicode 11 exposes a bug in maketables.go.
      We update the Unicode 10 tables using a new generator
      to minimize the changes upgrading to Unicode 11.
      
      This change switches over the generation from core to that in
      x/text. To properly update the tables one needs to run the generate
      in x/text anyway, so this makes that official.
      
      The RangeTable generator in x/text also generates slightly compacter
      tables.
      
      Updates golang/go#27945
      
      See CL 154443
      
      Change-Id: I6c59e082d5b8cd9e9332a32d8971061228581d66
      Reviewed-on: https://go-review.googlesource.com/c/go/+/169617
      Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      e308d41f
    • Russ Cox's avatar
      cmd/go: change -tags to a comma-separated list · 80e78327
      Russ Cox authored
      Using commas makes it possible to put multiple tags into GOFLAGS.
      The space-separated form is still recognized and will be maintained.
      
      Alleviates #26849 somewhat.
      Fixes #18800 (again).
      
      Change-Id: I6f4cf28ea31e53e21ccbdad6ef1a0aee63b007d7
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173438
      Run-TryBot: Russ Cox <rsc@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      Reviewed-by: default avatarIan Cottrell <iancottrell@google.com>
      80e78327
    • Russ Cox's avatar
      cmd/go: add -trimpath build flag · 74695644
      Russ Cox authored
      "go build -trimpath" trims the recorded file paths in the
      resulting packages and executables to avoid recording
      the names of any local directories. Instead, the files appear
      to be stored in directories named either "go/src/..." (for the
      standard library) or named after the module or package
      in which the files appear.
      
      Fixes #16860.
      
      Change-Id: I433afeeb1fdeea641286b21693fee5e0a66d607e
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173345
      Run-TryBot: Russ Cox <rsc@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarJay Conrod <jayconrod@google.com>
      74695644
    • Marcel van Lohuizen's avatar
      unicode: remove script test · 8a20fde6
      Marcel van Lohuizen authored
      The script test requires a manual update on each new
      Unicode release, which interupts the automated flow.
      The test is removed in favor of one that fits within the
      automated scripts.
      See https://go-review.googlesource.com/c/text/+/169638.
      
      Updates golang/go#27945
      
      Change-Id: I9c9f1e2a77f7baef17040ea09eec28d7cf55b5e4
      Reviewed-on: https://go-review.googlesource.com/c/go/+/169619Reviewed-by: default avatarRuss Cox <rsc@golang.org>
      8a20fde6
    • Russ Cox's avatar
      cmd/internal/objabi: expand -trimpath syntax · 4891a3b6
      Russ Cox authored
      This CL affects the low-level -trimpath flag provided
      by both cmd/asm and cmd/compile. Previously, the flag
      took the name of a single directory that would be trimmed
      from recorded paths in the resulting object file.
      This CL makes the flag take a semicolon-separated list of paths.
      Further, each path can now end in an optional "=>replacement"
      to specify what to replace that leading path prefix with,
      instead of only dropping it.
      
      A followup CL will add a mode to cmd/go that uses this
      richer -trimpath to build binaries that do not contain any
      local path names.
      
      For #16860.
      
      Change-Id: I246811750f37607c7f7a8fbecd56c5475ebe1ea5
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173344
      Run-TryBot: Russ Cox <rsc@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarJay Conrod <jayconrod@google.com>
      4891a3b6
    • Josh Bleecher Snyder's avatar
      unicode/utf8: make acceptRanges bigger · 97dfbc54
      Josh Bleecher Snyder authored
      This avoids bounds checks in the calling code.
      The nominal increased size of the array in the binary
      is compensated for by the decreased size of the functions that call it.
      
      The benchmark changes are a bit scattered, but overall positive.
      
      name                                 old time/op  new time/op  delta
      RuneCountTenASCIIChars-8             8.86ns ± 4%  7.93ns ± 5%  -10.45%  (p=0.000 n=45+49)
      RuneCountTenJapaneseChars-8          38.2ns ± 2%  37.2ns ± 1%   -2.63%  (p=0.000 n=44+41)
      RuneCountInStringTenASCIIChars-8     7.82ns ± 2%  8.70ns ± 2%  +11.19%  (p=0.000 n=43+43)
      RuneCountInStringTenJapaneseChars-8  39.3ns ± 9%  40.0ns ± 5%   +1.59%  (p=0.043 n=50+50)
      ValidTenASCIIChars-8                 8.68ns ± 5%  8.74ns ± 5%     ~     (p=0.070 n=50+48)
      ValidTenJapaneseChars-8              34.1ns ± 5%  36.8ns ± 4%   +8.09%  (p=0.000 n=45+50)
      ValidStringTenASCIIChars-8           9.76ns ± 7%  8.33ns ± 3%  -14.59%  (p=0.000 n=48+47)
      ValidStringTenJapaneseChars-8        37.7ns ± 8%  36.5ns ± 5%   -3.12%  (p=0.011 n=50+47)
      EncodeASCIIRune-8                    2.60ns ± 1%  2.59ns ± 2%   -0.24%  (p=0.018 n=43+36)
      EncodeJapaneseRune-8                 3.75ns ± 2%  4.56ns ± 6%  +21.71%  (p=0.000 n=41+50)
      DecodeASCIIRune-8                    2.59ns ± 2%  2.59ns ± 2%     ~     (p=0.350 n=44+41)
      DecodeJapaneseRune-8                 4.29ns ± 2%  4.31ns ± 2%   +0.61%  (p=0.001 n=48+39)
      FullASCIIRune-8                      0.87ns ± 6%  0.29ns ± 5%  -67.31%  (p=0.000 n=49+43)
      FullJapaneseRune-8                   0.65ns ± 6%  0.65ns ± 4%     ~     (p=0.375 n=50+49)
      [Geo mean]                           7.02ns       6.51ns        -7.19%
      
      
      Change-Id: I8d5d69c8d33ce2bff94785fba39a2203f9315cb0
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173537
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      97dfbc54
    • Josh Bleecher Snyder's avatar
      bytes, internal/bytealg: simplify Equal · ca0c449a
      Josh Bleecher Snyder authored
      The compiler has advanced enough that it is cheaper
      to convert to strings than to go through the assembly
      trampolines to call runtime.memequal.
      
      Simplify Equal accordingly, and cull dead code from bytealg.
      
      While we're here, simplify Equal's documentation.
      
      Fixes #31587
      
      Change-Id: Ie721d33f9a6cbd86b1d873398b20e7882c2c63e9
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173323
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarDave Cheney <dave@cheney.net>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      ca0c449a
    • Udalov Max's avatar
      cmd/go/internal/modcmd: assign module's path and version to fileJSON when... · de050717
      Udalov Max authored
      cmd/go/internal/modcmd: assign module's path and version to fileJSON when modFile's module statement exists
      
      Fixes panic on nil pointer dereference error when assigning module's path and version pair to fileJSON.
      
      Fixes #31623
      
      Change-Id: I3f61122ba0676a1270d3ad98900af8c8e9c90935
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173397
      Run-TryBot: Jay Conrod <jayconrod@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarJay Conrod <jayconrod@google.com>
      de050717
  2. 23 Apr, 2019 20 commits
    • sergey's avatar
      net/url: Reduce allocation on parsing URL func · 601eee39
      sergey authored
      Build result string via string.Builder to avoid allocation.
      As side effect some performance boots.
      
      name                 old time/op    new time/op    delta
      QueryUnescape/#00-4     114ns ± 0%      98ns ± 1%  -13.89%  (p=0.000 n=4+5)
      QueryUnescape/#01-4     401ns ± 2%     383ns ± 1%   -4.54%  (p=0.008 n=5+5)
      QueryUnescape/#02-4     300ns ± 2%     274ns ± 2%   -8.66%  (p=0.008 n=5+5)
      QueryUnescape/#03-4     564ns ± 2%     542ns ± 2%   -4.04%  (p=0.008 n=5+5)
      QueryUnescape/#04-4    3.27µs ± 2%    3.34µs ± 8%     ~     (p=0.690 n=5+5)
      PathUnescape/#00-4      112ns ± 2%      99ns ± 3%  -11.25%  (p=0.008 n=5+5)
      PathUnescape/#01-4      392ns ± 2%     374ns ± 6%     ~     (p=0.063 n=5+5)
      PathUnescape/#02-4      296ns ± 2%     274ns ± 2%   -7.43%  (p=0.008 n=5+5)
      PathUnescape/#03-4      556ns ± 2%     537ns ± 1%   -3.45%  (p=0.008 n=5+5)
      PathUnescape/#04-4     2.99µs ± 1%    3.00µs ± 1%     ~     (p=0.690 n=5+5)
      
      name                 old allocs/op  new allocs/op  delta
      QueryUnescape/#00-4      2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
      QueryUnescape/#01-4      2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
      QueryUnescape/#02-4      2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
      QueryUnescape/#03-4      2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
      QueryUnescape/#04-4      2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
      PathUnescape/#00-4       2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
      PathUnescape/#01-4       2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
      PathUnescape/#02-4       2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
      PathUnescape/#03-4       2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
      PathUnescape/#04-4       2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)
      
      Change-Id: I7cba5eb53bebef7b1fdd44598eed47241ce83167
      Reviewed-on: https://go-review.googlesource.com/c/go/+/166463Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      601eee39
    • Matthew Dempsky's avatar
      cmd/compile: don't call hcrash in Warn · 24513d33
      Matthew Dempsky authored
      Fixes #31638.
      
      Change-Id: I748f64b48b75241a9db31c9f37555379a841677a
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173443
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      Reviewed-by: default avatarKeith Randall <khr@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      24513d33
    • Brad Fitzpatrick's avatar
      net: don't crash on Windows when Lookup name has null byte in string · 2e118812
      Brad Fitzpatrick authored
      Fixes #31597
      
      Change-Id: I0db1f6f457632c49f9ecfa9d85b99b4cf7d91325
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173362
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      Reviewed-by: default avatarAlex Brainman <alex.brainman@gmail.com>
      2e118812
    • Keith Randall's avatar
      Revert "cmd/compile: add signed divisibility by power of 2 rules" · 17615969
      Keith Randall authored
      This reverts CL 168038 (git 68819fb6)
      
      Reason for revert: Doesn't work on 32 bit archs.
      
      Change-Id: Idec9098060dc65bc2f774c5383f0477f8eb63a3d
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173442Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      17615969
    • Bryan C. Mills's avatar
      cmd/go/internal/web: merge internal/web2 into web · 58de7c6d
      Bryan C. Mills authored
      The cmd/go/internal/web package was forked in order to support direct
      HTTPS fetches from widely-used hosting providers,¹ but direct fetches
      were subsequently dropped in CL 107657. The forked web2 package, with
      its GitHub-specific diagnostics and .netrc support, remained in use
      for module proxy support, but was not used for the initial '?go-get=1'
      path resolution, so the .netrc file was only used to fetch from
      already-resolved module protocol servers.
      
      This CL moves the .netrc support into its own (new) package,
      cmd/go/internal/auth, and consolidates the web and web2 packages back
      into just web. As a result, fetches via the web package now support
      .netrc, and fetches that previously used web2 now enforce the same
      security policies as web (such as prohibiting HTTPS-to-HTTP
      redirects).
      
      ¹https://github.com/golang/vgo/commit/63138cb6ceed7d6d4e51a8cbd568c64bd3e2b132
      
      Fixes #29591
      Fixes #29888
      Fixes #30610
      Updates #26232
      
      Change-Id: Ia3a13526e443679cf14a72a1f3db96f336ce5e73
      Reviewed-on: https://go-review.googlesource.com/c/go/+/170879
      Run-TryBot: Russ Cox <rsc@golang.org>
      Reviewed-by: default avatarRuss Cox <rsc@golang.org>
      Reviewed-by: default avatarJay Conrod <jayconrod@google.com>
      58de7c6d
    • David Chase's avatar
      cmd/link: revert/revise CL 98075 because LLDB is very picky now · 807761f3
      David Chase authored
      This was originally
      
      Revert "cmd/link: fix up debug_range for dsymutil (revert CL 72371)"
      
      which has the effect of no longer using Base Address Selection
      Entries in DWARF.  However, the build-time costs of that are
      about 2%, so instead the hacky fixup that generated technically
      incorrect DWARF was removed from the linker, and the choice
      is instead made in the compiler, dependent on platform, but
      also under control of a flag so that we can report this bug
      against LLDB/dsymutil/dwarfdump (really, the LLVM dwarf
      libraries).
      
      This however does not solve #31188; debugging still fails,
      but dwarfdump no longer complains.  There are at least two
      LLDB bugs involved, and this change will at allow us
      to report them without them being rejected because our
      now-obsolete workaround for the first bug creates
      not-quite-DWARF.
      
      Updates #31188.
      
      Change-Id: I5300c51ad202147bab7333329ebe961623d2b47d
      Reviewed-on: https://go-review.googlesource.com/c/go/+/170638
      Run-TryBot: David Chase <drchase@google.com>
      Reviewed-by: default avatarHeschi Kreinick <heschi@google.com>
      807761f3
    • Brian Kessler's avatar
      cmd/compile: add signed divisibility by power of 2 rules · 68819fb6
      Brian Kessler authored
      For powers of two (c=1<<k), the divisibility check x%c == 0 can be made
      just by checking the trailing zeroes via a mask x&(c-1)==0 even for signed
      integers.  This avoids division fixups when just divisibility check is needed.
      
      To apply this rule the generic divisibility rule for  A%B = A-(A/B*B) is disabled
      on the "opt" pass, but this does not affect generated code as this rule is applied
      later.
      
      The speed up on amd64 due to elimination of unneccessary fixup code is ~55%:
      
      name                     old time/op  new time/op  delta
      DivconstI64-4            2.08ns ± 0%  2.07ns ± 0%     ~     (p=0.079 n=5+5)
      DivisiblePow2constI64-4  1.78ns ± 1%  0.81ns ± 1%  -54.55%  (p=0.008 n=5+5)
      DivconstU64-4            2.08ns ± 0%  2.08ns ± 0%     ~     (p=1.000 n=5+5)
      DivconstI32-4            1.53ns ± 0%  1.53ns ± 0%     ~     (all equal)
      DivisiblePow2constI32-4  1.79ns ± 1%  0.81ns ± 4%  -54.75%  (p=0.008 n=5+5)
      DivconstU32-4            1.78ns ± 1%  1.78ns ± 1%     ~     (p=1.000 n=5+5)
      DivconstI16-4            1.54ns ± 2%  1.53ns ± 0%     ~     (p=0.333 n=5+4)
      DivisiblePow2constI16-4  1.78ns ± 0%  0.79ns ± 1%  -55.39%  (p=0.000 n=4+5)
      DivconstU16-4            1.00ns ± 5%  0.99ns ± 1%     ~     (p=0.730 n=5+5)
      DivconstI8-4             1.54ns ± 0%  1.53ns ± 0%     ~     (p=0.714 n=4+5)
      DivisiblePow2constI8-4   1.78ns ± 0%  0.80ns ± 0%  -55.06%  (p=0.000 n=5+4)
      DivconstU8-4             0.93ns ± 1%  0.95ns ± 1%   +1.72%  (p=0.024 n=5+5)
      
      A follow-up CL will address the general case of x%c == 0 for signed integers.
      
      Updates #15806
      
      Change-Id: I0d284863774b1bc8c4ce87443bbaec6103e14ef4
      Reviewed-on: https://go-review.googlesource.com/c/go/+/168038Reviewed-by: default avatarKeith Randall <khr@golang.org>
      68819fb6
    • Keith Randall's avatar
      runtime: randomize package initialization order in race mode · 8515d9cf
      Keith Randall authored
      This is one small step to force people to not depend on the order of
      initialization of packages which are not explicitly ordered by import
      directives. Similar to randomizing map iteration order, this makes
      sure people aren't depending on the behavior of the current release,
      so that we can change the order in future releases without breaking
      everyone.
      
      Maybe one day we can randomize always, but for now we do it just in
      race mode. (We would need to measure the impact on startup time before
      we enabled it always.)
      
      RELNOTE=yes
      
      Change-Id: I99026394796125974c5f2c3660a88becb92c9df3
      Reviewed-on: https://go-review.googlesource.com/c/go/+/170318
      Run-TryBot: Keith Randall <khr@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarJosh Bleecher Snyder <josharian@gmail.com>
      8515d9cf
    • Keith Randall's avatar
      cmd/compile: always mark atColumn1 results as statements · fd788a86
      Keith Randall authored
      In 31618, we end up comparing the is-stmt-ness of positions
      to repurpose real instructions as inline marks. If the is-stmt-ness
      doesn't match, we end up not being able to remove the inline mark.
      
      Always use statement-full positions to do the matching, so we
      always find a match if there is one.
      
      Also always use positions that are statements for inline marks.
      
      Fixes #31618
      
      Change-Id: Idaf39bdb32fa45238d5cd52973cadf4504f947d5
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173324
      Run-TryBot: Keith Randall <khr@golang.org>
      Reviewed-by: default avatarDavid Chase <drchase@google.com>
      fd788a86
    • Matthew Dempsky's avatar
      cmd/compile: respect -newescape in genwrapper · a152dd04
      Matthew Dempsky authored
      Noticed while preparing a CL for Go 1.14 to remove esc.go.
      
      Change-Id: Ic12be33f5b16c8424d85f373fa450247be086078
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173298
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
      a152dd04
    • Michael Munday's avatar
      math: consolidate assembly stub implementations · f0fdbb1e
      Michael Munday authored
      Where assembly functions are just jumps to the Go implementation
      put them into a stubs_<arch>.s file. This reduces the number of
      files considerably and makes it easier to see what is really
      implemented in assembly.
      
      I've also run the stubs files through asmfmt to format them in
      a more consistent way.
      
      Eventually we should replace these 'stub' assembly files with
      a pure Go implementation now that we have mid-stack inlining
      (see #31362).
      
      Change-Id: If5b2022dcc23e1299f1b7ba79884f1b1263d0f7f
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173398
      Run-TryBot: Michael Munday <mike.munday@ibm.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      f0fdbb1e
    • Benny Siegert's avatar
      A: Add Maya Rashish (individual CLA) · 3d631662
      Benny Siegert authored
      Change-Id: I1380229c250a6100dc7e0bcf59be8df425a3efac
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173399Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      3d631662
    • Benny Siegert's avatar
      doc: update wording in contribution guide · d0fadb93
      Benny Siegert authored
      The top right menu in Gerrit is now a gear icon, and the link
      has a slightly different title.
      
      Change-Id: I3f5d194f31ad09a99416a45db392aa4b5c7d98ff
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173400Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      d0fadb93
    • Nikhil Benesch's avatar
      cmd/go: include AR env var in gccgo build IDs · 213d1cf3
      Nikhil Benesch authored
      The gccgo toolchain uses the archiver specified by the AR environment
      variable, or `ar` by default. Teach the build ID to take the value of
      this environment variable into account, since different archivers can
      produce different results.
      
      Fix #30046.
      
      Change-Id: Ia6821258d54eecedb9026afc38a515cd564c45cb
      Reviewed-on: https://go-review.googlesource.com/c/go/+/160897
      Run-TryBot: Russ Cox <rsc@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarRuss Cox <rsc@golang.org>
      213d1cf3
    • Russ Cox's avatar
      encoding/json: document HTML escaping in Compact · d92bc7a5
      Russ Cox authored
      Make explicit that Compact does HTML escaping.
      
      Fixes #30357.
      
      Change-Id: I4648f8f3e907d659db977d07253f716df6e07d7b
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173417
      Run-TryBot: Russ Cox <rsc@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      d92bc7a5
    • Russ Cox's avatar
      cmd/go: move runtime/debug.modinfo to runtime.modinfo · b51c1570
      Russ Cox authored
      It is easier to ensure that the symbol is always present
      if we move it to package runtime. Avoids init-time work.
      Also moves it next to buildVersion, the other similar symbol.
      
      Setting up for "go version <binary>".
      
      For #31624.
      
      Change-Id: I943724469ce6992153e701257eb6f12da88c8e4e
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173341
      Run-TryBot: Russ Cox <rsc@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      b51c1570
    • Shubham Sharma's avatar
      net: add IsNotFound field to DNSError · fac3b5d0
      Shubham Sharma authored
      This adds the ability to determine if a lookup error was
      due to a non-existent hostname. Previously users needed
      to do string matching on the DNSError.Err value.
      
      Fixes #28635
      
      Change-Id: If4bd3ad32cbc2db5614f2c6b72e0a9161d813efa
      Reviewed-on: https://go-review.googlesource.com/c/go/+/168597
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      fac3b5d0
    • Daniel Martí's avatar
      encoding/json: index names for the struct decoder · 7e08c7f4
      Daniel Martí authored
      In the common case, structs have a handful of fields and most inputs
      match struct field names exactly.
      
      The previous code would do a linear search over the fields, stopping at
      the first exact match, and otherwise using the first case insensitive
      match.
      
      This is unfortunate, because it means that for the common case, we'd do
      a linear search with bytes.Equal. Even for structs with only two or
      three fields, that is pretty wasteful.
      
      Worse even, up until the exact match was found via the linear search,
      all previous fields would run their equalFold functions, which aren't
      cheap even in the simple case.
      
      Instead, cache a map along with the field list that indexes the fields
      by their name. This way, a case sensitive field search doesn't involve a
      linear search, nor does it involve any equalFold func calls.
      
      This patch should also slightly speed up cases where there's a case
      insensitive match but not a case sensitive one, as then we'd avoid
      calling bytes.Equal on all the fields. Though that's not a common case,
      and there are no benchmarks for it.
      
      name           old time/op    new time/op    delta
      CodeDecoder-8    11.0ms ± 0%    10.6ms ± 1%  -4.42%  (p=0.000 n=9+10)
      
      name           old speed      new speed      delta
      CodeDecoder-8   176MB/s ± 0%   184MB/s ± 1%  +4.62%  (p=0.000 n=9+10)
      
      name           old alloc/op   new alloc/op   delta
      CodeDecoder-8    2.28MB ± 0%    2.28MB ± 0%    ~     (p=0.725 n=10+10)
      
      name           old allocs/op  new allocs/op  delta
      CodeDecoder-8     76.9k ± 0%     76.9k ± 0%    ~     (all equal)
      
      Updates #28923.
      
      Change-Id: I9929c1f06c76505e5b96914199315dbdaae5dc76
      Reviewed-on: https://go-review.googlesource.com/c/go/+/172918
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      7e08c7f4
    • Josh Bleecher Snyder's avatar
      cmd/compile: clean up string/bytes/runes conversion code · 980a57a8
      Josh Bleecher Snyder authored
      Combine the OBYTES2STR and ORUNES2STR cases, as they are identical.
      
      Clean up the construction, commenting, and spacing of the other cases,
      and make them all match.
      
      Passes toolstash-check.
      
      Change-Id: I1be8a528927caeb15e49cb12ca0f11c0827dadd9
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173322
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      980a57a8
    • Russ Cox's avatar
      cmd/go: add env -w and env -u to set and unset default env vars · f0e97546
      Russ Cox authored
      Setting environment variables for go command configuration
      is too difficult and system-specific. This CL adds go env -w,
      to change the default settings more easily, in a portable way.
      It also adds go env -u, to unset those changes.
      
      See https://golang.org/design/30411-env for details.
      
      Fixes #30411.
      
      Change-Id: I36e83f55b666459f8f7f482432a4a6ee015da71d
      Reviewed-on: https://go-review.googlesource.com/c/go/+/171137
      Run-TryBot: Russ Cox <rsc@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBryan C. Mills <bcmills@google.com>
      f0e97546
  3. 22 Apr, 2019 11 commits
    • Matthew Dempsky's avatar
      cmd/compile: refactor visitBottomUp to use inspectList · e40dffe5
      Matthew Dempsky authored
      Passes toolstash-check.
      
      Change-Id: I02efba7bab3ea49d87c8472bbb99116565bf8423
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173321Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      e40dffe5
    • Matthew Dempsky's avatar
      cmd/compile: change visitBottomUp from post-order traversal to pre-order · ef2806e4
      Matthew Dempsky authored
      No meaningful change, but allows the followup CL to pass
      toolstash-check.
      
      Change-Id: I1d852c97838be3f84cf795bc9daec9b15c705956
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173320
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      ef2806e4
    • Benoit Sigoure's avatar
      net/http: document that Basic Auth may require URL encoding · 415da714
      Benoit Sigoure authored
      Explicitly warn callers that no URL encoding is performed and
      that they might need to do it.
      
      Fixes #31577
      
      Change-Id: I52dc3fd2798ba8c3652d4a967b1c5c48eb69f43b
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173319Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      415da714
    • Tyler Bui-Palsulich's avatar
      cmd/go: expand cannot determine module path error · 1f0c102a
      Tyler Bui-Palsulich authored
      See suggestion 2 of #31543 by thepudds.
      
      We may want to expand 'go help mod init' in the future to document what
      the module path should look like.
      
      Change-Id: Ia559fa96fda871e011d53f42a803175abc512202
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173318
      Run-TryBot: Jay Conrod <jayconrod@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarJay Conrod <jayconrod@google.com>
      1f0c102a
    • Shawn Elliott's avatar
      cmd/go/internal/generate: stop premature variable substitution in commands · e6ae4e86
      Shawn Elliott authored
      go:generate commands passed no arguments are currently subject
      to premature variable substitution due to mistakenly assuming append
      guarantees a copy.  The change fixes this by forcing a slice copy at
      each invocation of a command.
      
      The previous code assumed that append would always generate a
      copy of its inputs. However, append wouldn't create a copy if there was
      no need to increase capacity and it would just return the original
      input slice. This resulted in premature variable substitutions in
      the "master word list" of generate commands, thus yielding incorrect
      results across multiple invocations of the same command when the
      body contained substitutions e.g. environment variables, moreover
      these can change during the lifetime of go:generate processing a
      file.
      
      Note that this behavior would not manifest itself if any arguments were
      passed to the command, because append would make a copy of the slice
      as it needed to increase its capacity.   The "hacky" work-around was to
      always pass at least one argument to any command, even if the
      command ignores it.  e.g.,
             //go:generate MyNoArgsCmd ' '
      
      This CL fixes that issue and removes the need for the hack mentioned
      above.
      
      Fixes #31608
      
      Change-Id: I782ac2234bd7035a37f61c101ee4aee38ed8d29f
      GitHub-Last-Rev: 796d3430191f183c123c450a60b4a7987cc85e20
      GitHub-Pull-Request: golang/go#31527
      Reviewed-on: https://go-review.googlesource.com/c/go/+/172580
      Run-TryBot: Jay Conrod <jayconrod@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarJay Conrod <jayconrod@google.com>
      e6ae4e86
    • Keith Randall's avatar
      cmd/compile: use correct package name for stack object symbol · 43001a0d
      Keith Randall authored
      Stack object generation code was always using the local package name
      for its symbol. Normally that doesn't matter, as we usually only
      compile functions in the local package. But for wrappers, the compiler
      generates functions which live in other packages. When there are two
      other packages with identical functions to wrap, the same name appears
      twice, and the compiler goes boom.
      
      Fixes #31252
      
      Change-Id: I7026eebabe562cb159b8b6046cf656afd336ba25
      Reviewed-on: https://go-review.googlesource.com/c/go/+/171464
      Run-TryBot: Keith Randall <khr@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
      43001a0d
    • Maya Rashish's avatar
      runtime: use named macros on NetBSD · d1f43cce
      Maya Rashish authored
      It will use the full names that appear in netbsd's /usr/include/sys/syscall.h names.
      This adds some compat-goo (sys_sigprocmask->SYS_sigprocmask14), which might not be pretty, but the information about whether the compat version is used is probably important, as Go will keep using interfaces even after they are considered compatibility, which has caused problems in the past.
      also, the same names appear in ktrace (with the numbers).
      
      Change-Id: Idc1bb254ee33757a39ba224d91e8fbb0331e2149
      GitHub-Last-Rev: b915e8f8a323cdc2d03119c3cf18e35d08c63d18
      GitHub-Pull-Request: golang/go#31594
      Reviewed-on: https://go-review.googlesource.com/c/go/+/173158Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      d1f43cce
    • Austin Clements's avatar
      runtime: improve mstart comments · 744fcfec
      Austin Clements authored
      Some of the comments were unclear or outdated.
      
      Change-Id: I02e01bf60def0074c1fa760e94aa992e9e4969b9
      Reviewed-on: https://go-review.googlesource.com/c/go/+/172987
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarMichael Knyszek <mknyszek@google.com>
      744fcfec
    • Daniel Martí's avatar
      encoding/json: avoid work when unquoting strings · fe1afe8d
      Daniel Martí authored
      We can work out how many bytes can be unquoted trivially in
      rescanLiteral, which already iterates over a string's bytes.
      
      Removing the extra loop in unquoteBytes simplifies the function and
      speeds it up, especially when decoding simple strings, which are common.
      
      While at it, we can remove unnecessary checks like len(s)<2 and
      s[0]=='"'. Add a comment explaining why.
      
      name           old time/op    new time/op    delta
      CodeDecoder-8    11.2ms ± 0%    11.1ms ± 1%  -1.63%  (p=0.000 n=9+10)
      
      name           old speed      new speed      delta
      CodeDecoder-8   173MB/s ± 0%   175MB/s ± 1%  +1.66%  (p=0.000 n=9+10)
      
      Updates #28923.
      
      Change-Id: I2436a3a7f8148a2f7a6a4cdbd7dec6b32ef5e20c
      Reviewed-on: https://go-review.googlesource.com/c/go/+/151157
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      fe1afe8d
    • erifan01's avatar
      math/big: optimize mulAddVWW on arm64 for better performance · d17d41e5
      erifan01 authored
      Unroll the cycle 4 times to reduce load overhead.
      
      Benchmarks:
      name                old time/op    new time/op    delta
      MulAddVWW/1-8         15.9ns ± 0%    11.9ns ± 0%  -24.92%  (p=0.000 n=8+8)
      MulAddVWW/2-8         16.1ns ± 0%    13.9ns ± 1%  -13.82%  (p=0.000 n=8+8)
      MulAddVWW/3-8         18.9ns ± 0%    17.3ns ± 0%   -8.47%  (p=0.000 n=8+8)
      MulAddVWW/4-8         21.7ns ± 0%    19.5ns ± 0%  -10.14%  (p=0.000 n=8+8)
      MulAddVWW/5-8         25.1ns ± 0%    22.5ns ± 0%  -10.27%  (p=0.000 n=8+8)
      MulAddVWW/10-8        41.6ns ± 0%    40.0ns ± 0%   -3.79%  (p=0.000 n=8+8)
      MulAddVWW/100-8        368ns ± 0%     363ns ± 0%   -1.36%  (p=0.000 n=8+8)
      MulAddVWW/1000-8      3.52µs ± 0%    3.52µs ± 0%   -0.14%  (p=0.000 n=8+8)
      MulAddVWW/10000-8     35.1µs ± 0%    35.1µs ± 0%   -0.01%  (p=0.000 n=7+6)
      MulAddVWW/100000-8     351µs ± 0%     351µs ± 0%   +0.15%  (p=0.038 n=8+8)
      
      Change-Id: I052a4db286ac6e4f3293289c7e9a82027da0405e
      Reviewed-on: https://go-review.googlesource.com/c/go/+/155780
      Run-TryBot: Cherry Zhang <cherryyz@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
      d17d41e5
    • erifan01's avatar
      cmd/compile: intrinsify math/bits.Sub64 for arm64 · f8f265b9
      erifan01 authored
      This CL instrinsifies Sub64 with arm64 instruction sequence NEGS, SBCS,
      NGC and NEG, and optimzes the case of borrowing chains.
      
      Benchmarks:
      name              old time/op       new time/op       delta
      Sub-64            2.500000ns +- 0%  2.048000ns +- 1%  -18.08%  (p=0.000 n=10+10)
      Sub32-64          2.500000ns +- 0%  2.500000ns +- 0%     ~     (all equal)
      Sub64-64          2.500000ns +- 0%  2.080000ns +- 0%  -16.80%  (p=0.000 n=10+7)
      Sub64multiple-64  7.090000ns +- 0%  2.090000ns +- 0%  -70.52%  (p=0.000 n=10+10)
      
      Change-Id: I3d2664e009a9635e13b55d2c4567c7b34c2c0655
      Reviewed-on: https://go-review.googlesource.com/c/go/+/159018Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
      Run-TryBot: Cherry Zhang <cherryyz@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      f8f265b9