1. 22 Aug, 2018 19 commits
    • Shivansh Rai's avatar
      all: use consistent shebang line across all shell scripts · c92354f4
      Shivansh Rai authored
      Change-Id: I4aac882b1b618a388d0748a427dc998203d3a1b2
      Reviewed-on: https://go-review.googlesource.com/113856Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      c92354f4
    • go101's avatar
      strings: use Builder in Repeat to avoid an allocation · 7a178df0
      go101 authored
      name           old time/op    new time/op    delta
      Repeat/5x1-4     95.9ns ± 2%    70.1ns ± 2%  -26.93%  (p=0.000 n=9+10)
      Repeat/5x2-4      146ns ± 3%     100ns ± 2%  -31.99%  (p=0.000 n=10+10)
      Repeat/5x6-4      203ns ± 3%     140ns ± 4%  -30.77%  (p=0.000 n=10+10)
      Repeat/10x1-4     139ns ± 3%      92ns ± 4%  -34.08%  (p=0.000 n=10+10)
      Repeat/10x2-4     188ns ± 4%     122ns ± 2%  -35.34%  (p=0.000 n=10+10)
      Repeat/10x6-4     264ns ± 5%     179ns ± 4%  -32.15%  (p=0.000 n=10+10)
      
      name           old alloc/op   new alloc/op   delta
      Repeat/5x1-4      10.0B ± 0%      5.0B ± 0%  -50.00%  (p=0.000 n=10+10)
      Repeat/5x2-4      32.0B ± 0%     16.0B ± 0%  -50.00%  (p=0.000 n=10+10)
      Repeat/5x6-4      64.0B ± 0%     32.0B ± 0%  -50.00%  (p=0.000 n=10+10)
      Repeat/10x1-4     32.0B ± 0%     16.0B ± 0%  -50.00%  (p=0.000 n=10+10)
      Repeat/10x2-4     64.0B ± 0%     32.0B ± 0%  -50.00%  (p=0.000 n=10+10)
      Repeat/10x6-4      128B ± 0%       64B ± 0%  -50.00%  (p=0.000 n=10+10)
      
      Change-Id: I6619336da636df39c560f6cc481519f48c6e8176
      GitHub-Last-Rev: 4b2c73f3bfa0b3789268b9ea6e1ecdb984e8087c
      GitHub-Pull-Request: golang/go#25894
      Reviewed-on: https://go-review.googlesource.com/118855
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      7a178df0
    • Iskander Sharipov's avatar
      cmd/link/internal/amd64: remove /*fallthrough*/ comments · 6a11e1e8
      Iskander Sharipov authored
      These are artifacts originating from C->Go translation.
      
      Change-Id: Ib5cdcaf42f43f3968482892fb4945e19ef38bd6d
      Reviewed-on: https://go-review.googlesource.com/121795Reviewed-by: 's avatarDave Cheney <dave@cheney.net>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      6a11e1e8
    • Diego Siqueira's avatar
      plugin: remove unused func · bca00def
      Diego Siqueira authored
      Change-Id: Ife29464d581f00940af7ef9251bf99661c1350b6
      GitHub-Last-Rev: d7747706584b06b619fc78a85b6b9bfe619467c8
      GitHub-Pull-Request: golang/go#26740
      Reviewed-on: https://go-review.googlesource.com/127195Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      bca00def
    • Yury Smolsky's avatar
      test: remove errchk, the perl script · 02fecd33
      Yury Smolsky authored
      gc tests do not depend on errchk.
      
      Fixes #25669
      
      Change-Id: I99eb87bb9677897b9167d4fc9a6321fa66cd9116
      Reviewed-on: https://go-review.googlesource.com/115955Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      02fecd33
    • Iskander Sharipov's avatar
      cmd/internal/obj/arm64: simplify some bool expressions · ed2f84a9
      Iskander Sharipov authored
      Replace `!(o1 != 0)` with `o1 == 0` (for readability).
      
      Found using https://go-critic.github.io/overview.html#boolExprSimplify-ref
      
      Change-Id: I4fc035458f530973f9be15b38441ec7b5fb591ec
      Reviewed-on: https://go-review.googlesource.com/123377
      Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      ed2f84a9
    • Daniel Martí's avatar
      encoding/json: simplify some pieces of the encoder · 9d1540b7
      Daniel Martí authored
      Some WriteByte('\\') calls can be deduplicated.
      
      fillField is used in two occasions, but it is unnecessary when adding
      fields to the "next" stack, as those aren't used for the final encoding.
      Inline the func with its only remaining call.
      
      Finally, unindent a default-if block.
      
      The performance of the encoder is unaffected:
      
      name           old time/op    new time/op    delta
      CodeEncoder-4    6.65ms ± 1%    6.65ms ± 0%   ~     (p=0.662 n=6+5)
      
      Change-Id: Ie55baeab89abad9b9f13e9f6ca886a670c30dba9
      Reviewed-on: https://go-review.googlesource.com/122461
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      9d1540b7
    • Johan Brandhorst's avatar
      strings, bytes: avoid unnecessary function literals · 841a9136
      Johan Brandhorst authored
      A number of explicit function literals found through the
      unlambda linter are removed.
      
      Fixes #26802
      
      Change-Id: I0b122bdd95e9cb804c77efe20483fdf681c8154e
      Reviewed-on: https://go-review.googlesource.com/127756Reviewed-by: 's avatarJoe Tsai <thebrokentoaster@gmail.com>
      841a9136
    • Cholerae Hu's avatar
      net/mail: lazily initialize dateLayouts · 39eda0da
      Cholerae Hu authored
      Saves 6KB of memory in stdlib packages.
      
      Updates #26775
      
      Change-Id: I1a6184cefa78e9a3c034fa84506fdfe0fec27add
      Reviewed-on: https://go-review.googlesource.com/127736Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      39eda0da
    • Daniel Martí's avatar
      encoding/json: inline fieldByIndex · 75e7e05a
      Daniel Martí authored
      This function was only used in a single place - in the field encoding
      loop within the struct encoder.
      
      Inlining the function call manually lets us get rid of the call
      overhead. But most importantly, it lets us simplify the logic afterward.
      We no longer need to use reflect.Value{} and !fv.IsValid(), as we can
      skip the field immediately.
      
      The two factors combined (mostly just the latter) give a moderate speed
      improvement to this hot loop.
      
      name           old time/op    new time/op    delta
      CodeEncoder-4    6.01ms ± 1%    5.91ms ± 1%  -1.66%  (p=0.002 n=6+6)
      
      name           old speed      new speed      delta
      CodeEncoder-4   323MB/s ± 1%   328MB/s ± 1%  +1.69%  (p=0.002 n=6+6)
      
      Updates #5683.
      
      Change-Id: I12757c325a68abb2856026cf719c122612a1f38e
      Reviewed-on: https://go-review.googlesource.com/125417
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      75e7e05a
    • Daniel Martí's avatar
      encoding/json: simplify the structEncoder type · 81487266
      Daniel Martí authored
      structEncoder had two slices - the list of fields, and a list containing
      the encoder for each field. structEncoder.encode then looped over the
      fields, and indexed into the second slice to grab the field encoder.
      
      However, this makes it very hard for the compiler to be able to prove
      that the two slices always have the same length, and that the index
      expression doesn't need a bounds check.
      
      Merge the two slices into one to completely remove the need for bounds
      checks in the hot loop.
      
      While at it, don't copy the field elements when ranging, which greatly
      speeds up the hot loop in structEncoder.
      
      name           old time/op    new time/op    delta
      CodeEncoder-4    6.18ms ± 0%    5.56ms ± 0%  -10.08%  (p=0.002 n=6+6)
      
      name           old speed      new speed      delta
      CodeEncoder-4   314MB/s ± 0%   349MB/s ± 0%  +11.21%  (p=0.002 n=6+6)
      
      name           old alloc/op   new alloc/op   delta
      CodeEncoder-4    93.2kB ± 0%    62.1kB ± 0%  -33.33%  (p=0.002 n=6+6)
      
      Updates #5683.
      
      Change-Id: I0dd47783530f439b125e084aede09dda172eb1e8
      Reviewed-on: https://go-review.googlesource.com/125416
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      81487266
    • Tobias Klauser's avatar
      cmd/cover: fix off-by-one error in TestCoverHTML · f4e4ec2c
      Tobias Klauser authored
      Avoid index out of range if len(goldenLines) == len(outLines) + 1
      
      Change-Id: Ic23a85d2b8dd06a615e35a58331e78abe4ad6703
      Reviewed-on: https://go-review.googlesource.com/130396
      Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      f4e4ec2c
    • Ben Shi's avatar
      cmd/compile: implement "OPC $imm, (mem)" for 386 · a0a7e9fc
      Ben Shi authored
      New read-modify-write operations are introduced in this CL for 386.
      
      1. The total size of pkg/linux_386 decreases about 10KB (excluding
      cmd/compile).
      
      2. The go1 benchmark shows little regression.
      name                     old time/op    new time/op    delta
      BinaryTree17-4              3.32s ± 4%     3.29s ± 2%    ~     (p=0.059 n=30+30)
      Fannkuch11-4                3.49s ± 1%     3.46s ± 1%  -0.92%  (p=0.001 n=30+30)
      FmtFprintfEmpty-4          47.7ns ± 2%    46.8ns ± 5%  -1.93%  (p=0.011 n=25+30)
      FmtFprintfString-4         79.5ns ± 7%    80.2ns ± 3%  +0.89%  (p=0.001 n=28+29)
      FmtFprintfInt-4            90.5ns ± 2%    92.1ns ± 2%  +1.82%  (p=0.014 n=22+30)
      FmtFprintfIntInt-4          141ns ± 1%     144ns ± 3%  +2.23%  (p=0.013 n=22+30)
      FmtFprintfPrefixedInt-4     183ns ± 2%     184ns ± 3%    ~     (p=0.080 n=21+30)
      FmtFprintfFloat-4           409ns ± 3%     412ns ± 3%  +0.83%  (p=0.040 n=30+30)
      FmtManyArgs-4               597ns ± 6%     607ns ± 4%  +1.71%  (p=0.006 n=30+30)
      GobDecode-4                7.21ms ± 5%    7.18ms ± 6%    ~     (p=0.665 n=30+30)
      GobEncode-4                7.17ms ± 6%    7.09ms ± 7%    ~     (p=0.117 n=29+30)
      Gzip-4                      413ms ± 4%     399ms ± 4%  -3.48%  (p=0.000 n=30+30)
      Gunzip-4                   41.3ms ± 4%    41.7ms ± 3%  +1.05%  (p=0.011 n=30+30)
      HTTPClientServer-4         63.5µs ± 3%    62.9µs ± 2%  -0.97%  (p=0.017 n=30+27)
      JSONEncode-4               20.3ms ± 5%    20.1ms ± 5%  -1.16%  (p=0.004 n=30+30)
      JSONDecode-4               66.2ms ± 4%    67.7ms ± 4%  +2.21%  (p=0.000 n=30+30)
      Mandelbrot200-4            5.16ms ± 3%    5.18ms ± 3%    ~     (p=0.123 n=30+30)
      GoParse-4                  3.23ms ± 2%    3.27ms ± 2%  +1.08%  (p=0.006 n=30+30)
      RegexpMatchEasy0_32-4      98.9ns ± 5%    97.1ns ± 4%  -1.83%  (p=0.006 n=30+30)
      RegexpMatchEasy0_1K-4       842ns ± 3%     842ns ± 3%    ~     (p=0.550 n=30+30)
      RegexpMatchEasy1_32-4       107ns ± 4%     105ns ± 4%  -1.93%  (p=0.012 n=30+30)
      RegexpMatchEasy1_1K-4      1.03µs ± 4%    1.04µs ± 4%    ~     (p=0.304 n=30+30)
      RegexpMatchMedium_32-4      132ns ± 2%     129ns ± 4%  -2.02%  (p=0.000 n=21+30)
      RegexpMatchMedium_1K-4     44.1µs ± 4%    43.8µs ± 3%    ~     (p=0.641 n=30+30)
      RegexpMatchHard_32-4       2.26µs ± 4%    2.23µs ± 4%  -1.28%  (p=0.023 n=30+30)
      RegexpMatchHard_1K-4       68.1µs ± 3%    68.6µs ± 4%    ~     (p=0.089 n=30+30)
      Revcomp-4                   1.85s ± 2%     1.84s ± 2%    ~     (p=0.072 n=30+30)
      Template-4                 69.2ms ± 3%    68.5ms ± 3%  -1.04%  (p=0.012 n=30+30)
      TimeParse-4                 441ns ± 3%     446ns ± 4%  +1.21%  (p=0.001 n=30+30)
      TimeFormat-4                415ns ± 3%     415ns ± 3%    ~     (p=0.436 n=30+30)
      [Geo mean]                 67.0µs         66.9µs       -0.17%
      
      name                     old speed      new speed      delta
      GobDecode-4               107MB/s ± 5%   107MB/s ± 6%    ~     (p=0.663 n=30+30)
      GobEncode-4               107MB/s ± 6%   108MB/s ± 7%    ~     (p=0.117 n=29+30)
      Gzip-4                   47.0MB/s ± 4%  48.7MB/s ± 4%  +3.61%  (p=0.000 n=30+30)
      Gunzip-4                  470MB/s ± 4%   466MB/s ± 4%  -1.05%  (p=0.011 n=30+30)
      JSONEncode-4             95.6MB/s ± 5%  96.7MB/s ± 5%  +1.16%  (p=0.005 n=30+30)
      JSONDecode-4             29.3MB/s ± 4%  28.7MB/s ± 4%  -2.17%  (p=0.000 n=30+30)
      GoParse-4                17.9MB/s ± 2%  17.7MB/s ± 2%  -1.06%  (p=0.007 n=30+30)
      RegexpMatchEasy0_32-4     323MB/s ± 5%   329MB/s ± 4%  +1.93%  (p=0.006 n=30+30)
      RegexpMatchEasy0_1K-4    1.22GB/s ± 3%  1.22GB/s ± 3%    ~     (p=0.496 n=30+30)
      RegexpMatchEasy1_32-4     298MB/s ± 4%   303MB/s ± 4%  +1.84%  (p=0.017 n=30+30)
      RegexpMatchEasy1_1K-4     995MB/s ± 4%   989MB/s ± 4%    ~     (p=0.307 n=30+30)
      RegexpMatchMedium_32-4   7.56MB/s ± 4%  7.74MB/s ± 4%  +2.46%  (p=0.000 n=22+30)
      RegexpMatchMedium_1K-4   23.2MB/s ± 4%  23.4MB/s ± 3%    ~     (p=0.651 n=30+30)
      RegexpMatchHard_32-4     14.2MB/s ± 4%  14.3MB/s ± 4%  +1.29%  (p=0.021 n=30+30)
      RegexpMatchHard_1K-4     15.0MB/s ± 3%  14.9MB/s ± 4%    ~     (p=0.069 n=30+29)
      Revcomp-4                 138MB/s ± 2%   138MB/s ± 2%    ~     (p=0.072 n=30+30)
      Template-4               28.1MB/s ± 3%  28.4MB/s ± 3%  +1.05%  (p=0.012 n=30+30)
      [Geo mean]               79.7MB/s       80.2MB/s       +0.60%
      
      Change-Id: I44a1dfc942c9a385904553c4fe1fa8e509c8aa31
      Reviewed-on: https://go-review.googlesource.com/120916
      Run-TryBot: Ben Shi <powerman1st@163.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      a0a7e9fc
    • Filippo Valsorda's avatar
      crypto/tls: make ConnectionState.ExportKeyingMaterial a method · de16b322
      Filippo Valsorda authored
      The unexported field is hidden from reflect based marshalers, which
      would break otherwise. Also, make it return an error, as there are
      multiple reasons it might fail.
      
      Fixes #27125
      
      Change-Id: I92adade2fe456103d2d5c0315629ca0256953764
      Reviewed-on: https://go-review.googlesource.com/130535
      Run-TryBot: Filippo Valsorda <filippo@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      de16b322
    • Ben Shi's avatar
      cmd/compile: optimize 386 code with MULLload/DIVSSload/DIVSDload · 90f2fa00
      Ben Shi authored
      IMULL/DIVSS/DIVSD all can take the source operand from memory
      directly. And this CL implement that optimization.
      
      1. The total size of pkg/linux_386 decreases about 84KB (excluding
      cmd/compile).
      
      2. The go1 benchmark shows little regression in total (excluding noise).
      name                     old time/op    new time/op    delta
      BinaryTree17-4              3.29s ± 2%     3.27s ± 4%    ~     (p=0.192 n=30+30)
      Fannkuch11-4                3.49s ± 2%     3.54s ± 1%  +1.48%  (p=0.000 n=30+30)
      FmtFprintfEmpty-4          45.9ns ± 3%    46.3ns ± 4%  +0.89%  (p=0.037 n=30+30)
      FmtFprintfString-4         78.8ns ± 3%    78.7ns ± 4%    ~     (p=0.209 n=30+27)
      FmtFprintfInt-4            91.0ns ± 2%    90.3ns ± 2%  -0.82%  (p=0.031 n=30+27)
      FmtFprintfIntInt-4          142ns ± 4%     143ns ± 4%    ~     (p=0.136 n=30+30)
      FmtFprintfPrefixedInt-4     181ns ± 3%     183ns ± 4%  +1.40%  (p=0.005 n=30+30)
      FmtFprintfFloat-4           404ns ± 4%     408ns ± 3%    ~     (p=0.397 n=30+30)
      FmtManyArgs-4               601ns ± 3%     609ns ± 5%    ~     (p=0.059 n=30+30)
      GobDecode-4                7.21ms ± 5%    7.24ms ± 5%    ~     (p=0.612 n=30+30)
      GobEncode-4                6.91ms ± 6%    6.91ms ± 6%    ~     (p=0.797 n=30+30)
      Gzip-4                      398ms ± 6%     399ms ± 4%    ~     (p=0.173 n=30+30)
      Gunzip-4                   41.7ms ± 3%    41.8ms ± 3%    ~     (p=0.423 n=30+30)
      HTTPClientServer-4         62.3µs ± 2%    62.7µs ± 3%    ~     (p=0.085 n=29+30)
      JSONEncode-4               21.0ms ± 4%    20.7ms ± 5%  -1.39%  (p=0.014 n=30+30)
      JSONDecode-4               66.3ms ± 3%    67.4ms ± 1%  +1.71%  (p=0.003 n=30+24)
      Mandelbrot200-4            5.15ms ± 3%    5.16ms ± 3%    ~     (p=0.697 n=30+30)
      GoParse-4                  3.24ms ± 3%    3.27ms ± 4%  +0.91%  (p=0.032 n=30+30)
      RegexpMatchEasy0_32-4       101ns ± 5%      99ns ± 4%  -1.82%  (p=0.008 n=29+30)
      RegexpMatchEasy0_1K-4       848ns ± 4%     841ns ± 2%  -0.77%  (p=0.043 n=30+30)
      RegexpMatchEasy1_32-4       106ns ± 6%     106ns ± 3%    ~     (p=0.939 n=29+30)
      RegexpMatchEasy1_1K-4      1.02µs ± 3%    1.03µs ± 4%    ~     (p=0.297 n=28+30)
      RegexpMatchMedium_32-4      129ns ± 4%     127ns ± 4%    ~     (p=0.073 n=30+30)
      RegexpMatchMedium_1K-4     43.9µs ± 3%    43.8µs ± 3%    ~     (p=0.186 n=30+30)
      RegexpMatchHard_32-4       2.24µs ± 4%    2.22µs ± 4%    ~     (p=0.332 n=30+29)
      RegexpMatchHard_1K-4       68.0µs ± 4%    67.5µs ± 3%    ~     (p=0.290 n=30+30)
      Revcomp-4                   1.85s ± 3%     1.85s ± 3%    ~     (p=0.358 n=30+30)
      Template-4                 69.6ms ± 3%    70.0ms ± 4%    ~     (p=0.273 n=30+30)
      TimeParse-4                 445ns ± 3%     441ns ± 3%    ~     (p=0.494 n=30+30)
      TimeFormat-4                412ns ± 3%     412ns ± 6%    ~     (p=0.841 n=30+30)
      [Geo mean]                 66.7µs         66.8µs       +0.13%
      
      name                     old speed      new speed      delta
      GobDecode-4               107MB/s ± 5%   106MB/s ± 5%    ~     (p=0.615 n=30+30)
      GobEncode-4               111MB/s ± 6%   111MB/s ± 6%    ~     (p=0.790 n=30+30)
      Gzip-4                   48.8MB/s ± 6%  48.7MB/s ± 4%    ~     (p=0.167 n=30+30)
      Gunzip-4                  465MB/s ± 3%   465MB/s ± 3%    ~     (p=0.420 n=30+30)
      JSONEncode-4             92.4MB/s ± 4%  93.7MB/s ± 5%  +1.42%  (p=0.015 n=30+30)
      JSONDecode-4             29.3MB/s ± 3%  28.8MB/s ± 1%  -1.72%  (p=0.003 n=30+24)
      GoParse-4                17.9MB/s ± 3%  17.7MB/s ± 4%  -0.89%  (p=0.037 n=30+30)
      RegexpMatchEasy0_32-4     317MB/s ± 8%   324MB/s ± 4%  +2.14%  (p=0.006 n=30+30)
      RegexpMatchEasy0_1K-4    1.21GB/s ± 4%  1.22GB/s ± 2%  +0.77%  (p=0.036 n=30+30)
      RegexpMatchEasy1_32-4     298MB/s ± 7%   299MB/s ± 4%    ~     (p=0.511 n=30+30)
      RegexpMatchEasy1_1K-4    1.00GB/s ± 3%  1.00GB/s ± 4%    ~     (p=0.304 n=28+30)
      RegexpMatchMedium_32-4   7.75MB/s ± 4%  7.82MB/s ± 4%    ~     (p=0.089 n=30+30)
      RegexpMatchMedium_1K-4   23.3MB/s ± 3%  23.4MB/s ± 3%    ~     (p=0.181 n=30+30)
      RegexpMatchHard_32-4     14.3MB/s ± 4%  14.4MB/s ± 4%    ~     (p=0.320 n=30+29)
      RegexpMatchHard_1K-4     15.1MB/s ± 4%  15.2MB/s ± 3%    ~     (p=0.273 n=30+30)
      Revcomp-4                 137MB/s ± 3%   137MB/s ± 3%    ~     (p=0.352 n=30+30)
      Template-4               27.9MB/s ± 3%  27.7MB/s ± 4%    ~     (p=0.277 n=30+30)
      [Geo mean]               79.9MB/s       80.1MB/s       +0.15%
      
      Change-Id: I97333cd8ddabb3c7c88ca5aa9e14a005b74d306d
      Reviewed-on: https://go-review.googlesource.com/120695
      Run-TryBot: Ben Shi <powerman1st@163.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      90f2fa00
    • Ben Shi's avatar
      cmd/compile: optimize AMD64 with DIVSSload and DIVSDload · 705f3c74
      Ben Shi authored
      DIVSSload & DIVSDload directly operate on a memory operand. And
      binary size can be reduced by them, while the performance is
      not affected.
      
      The total size of pkg/linux_amd64 (excluding cmd/compile) decreases
      about 6KB.
      
      There is little regression in the go1 benchmark test (excluding noise).
      name                     old time/op    new time/op    delta
      BinaryTree17-4              2.63s ± 4%     2.62s ± 4%    ~     (p=0.809 n=30+30)
      Fannkuch11-4                2.40s ± 2%     2.40s ± 2%    ~     (p=0.109 n=30+30)
      FmtFprintfEmpty-4          43.1ns ± 4%    43.2ns ± 9%    ~     (p=0.168 n=30+30)
      FmtFprintfString-4         73.6ns ± 4%    74.1ns ± 4%    ~     (p=0.069 n=30+30)
      FmtFprintfInt-4            81.0ns ± 3%    81.4ns ± 5%    ~     (p=0.350 n=30+30)
      FmtFprintfIntInt-4          127ns ± 4%     129ns ± 4%  +0.99%  (p=0.021 n=30+30)
      FmtFprintfPrefixedInt-4     156ns ± 4%     155ns ± 4%    ~     (p=0.415 n=30+30)
      FmtFprintfFloat-4           219ns ± 4%     218ns ± 4%    ~     (p=0.071 n=30+30)
      FmtManyArgs-4               522ns ± 3%     518ns ± 3%  -0.68%  (p=0.034 n=30+30)
      GobDecode-4                6.49ms ± 6%    6.52ms ± 6%    ~     (p=0.832 n=30+30)
      GobEncode-4                6.10ms ± 9%    6.14ms ± 7%    ~     (p=0.485 n=30+30)
      Gzip-4                      227ms ± 1%     224ms ± 4%    ~     (p=0.484 n=24+30)
      Gunzip-4                   37.2ms ± 3%    36.8ms ± 4%    ~     (p=0.889 n=30+30)
      HTTPClientServer-4         58.9µs ± 1%    58.7µs ± 2%  -0.42%  (p=0.003 n=28+28)
      JSONEncode-4               12.0ms ± 3%    12.0ms ± 4%    ~     (p=0.523 n=30+30)
      JSONDecode-4               54.6ms ± 4%    54.5ms ± 4%    ~     (p=0.708 n=30+30)
      Mandelbrot200-4            3.78ms ± 4%    3.81ms ± 3%  +0.99%  (p=0.016 n=30+30)
      GoParse-4                  3.20ms ± 4%    3.20ms ± 5%    ~     (p=0.994 n=30+30)
      RegexpMatchEasy0_32-4      77.0ns ± 4%    75.9ns ± 3%  -1.39%  (p=0.006 n=29+30)
      RegexpMatchEasy0_1K-4       255ns ± 4%     253ns ± 4%    ~     (p=0.091 n=30+30)
      RegexpMatchEasy1_32-4      69.7ns ± 3%    70.3ns ± 4%    ~     (p=0.120 n=30+30)
      RegexpMatchEasy1_1K-4       373ns ± 2%     378ns ± 3%  +1.43%  (p=0.000 n=21+26)
      RegexpMatchMedium_32-4      107ns ± 2%     108ns ± 4%  +1.50%  (p=0.012 n=22+30)
      RegexpMatchMedium_1K-4     34.0µs ± 1%    34.3µs ± 3%  +1.08%  (p=0.008 n=24+30)
      RegexpMatchHard_32-4       1.53µs ± 3%    1.54µs ± 3%    ~     (p=0.234 n=30+30)
      RegexpMatchHard_1K-4       46.7µs ± 4%    47.0µs ± 4%    ~     (p=0.420 n=30+30)
      Revcomp-4                   411ms ± 7%     415ms ± 6%    ~     (p=0.059 n=30+30)
      Template-4                 65.5ms ± 5%    66.9ms ± 4%  +2.21%  (p=0.001 n=30+30)
      TimeParse-4                 317ns ± 3%     311ns ± 3%  -1.97%  (p=0.000 n=30+30)
      TimeFormat-4                293ns ± 3%     294ns ± 3%    ~     (p=0.243 n=30+30)
      [Geo mean]                 47.4µs         47.5µs       +0.17%
      
      name                     old speed      new speed      delta
      GobDecode-4               118MB/s ± 5%   118MB/s ± 6%    ~     (p=0.832 n=30+30)
      GobEncode-4               125MB/s ± 7%   125MB/s ± 7%    ~     (p=0.625 n=29+30)
      Gzip-4                   85.3MB/s ± 1%  86.6MB/s ± 4%    ~     (p=0.486 n=24+30)
      Gunzip-4                  522MB/s ± 3%   527MB/s ± 4%    ~     (p=0.889 n=30+30)
      JSONEncode-4              162MB/s ± 3%   162MB/s ± 4%    ~     (p=0.520 n=30+30)
      JSONDecode-4             35.5MB/s ± 4%  35.6MB/s ± 4%    ~     (p=0.701 n=30+30)
      GoParse-4                18.1MB/s ± 4%  18.1MB/s ± 4%    ~     (p=0.891 n=29+30)
      RegexpMatchEasy0_32-4     416MB/s ± 4%   422MB/s ± 3%  +1.43%  (p=0.005 n=29+30)
      RegexpMatchEasy0_1K-4    4.01GB/s ± 4%  4.04GB/s ± 4%    ~     (p=0.091 n=30+30)
      RegexpMatchEasy1_32-4     460MB/s ± 3%   456MB/s ± 5%    ~     (p=0.123 n=30+30)
      RegexpMatchEasy1_1K-4    2.74GB/s ± 2%  2.70GB/s ± 3%  -1.33%  (p=0.000 n=22+26)
      RegexpMatchMedium_32-4   9.39MB/s ± 3%  9.19MB/s ± 4%  -2.06%  (p=0.001 n=28+30)
      RegexpMatchMedium_1K-4   30.1MB/s ± 1%  29.8MB/s ± 3%  -1.04%  (p=0.008 n=24+30)
      RegexpMatchHard_32-4     20.9MB/s ± 3%  20.8MB/s ± 3%    ~     (p=0.234 n=30+30)
      RegexpMatchHard_1K-4     21.9MB/s ± 4%  21.8MB/s ± 4%    ~     (p=0.420 n=30+30)
      Revcomp-4                 619MB/s ± 7%   612MB/s ± 7%    ~     (p=0.059 n=30+30)
      Template-4               29.6MB/s ± 4%  29.0MB/s ± 4%  -2.16%  (p=0.002 n=30+30)
      [Geo mean]                123MB/s        123MB/s       -0.33%
      
      Change-Id: Ia59e077feae4f2824df79059daea4d0f678e3e4c
      Reviewed-on: https://go-review.googlesource.com/120275
      Run-TryBot: Ben Shi <powerman1st@163.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarIlya Tocar <ilya.tocar@intel.com>
      705f3c74
    • David Carlier's avatar
      crypto/rand: use the new getrandom syscall on FreeBSD · 64f3d75b
      David Carlier authored
      Since the 12.x branch, the getrandom syscall had been introduced
      with similar interface as Linux's and consistent syscall id
      across architectures.
      
      Change-Id: I63d6b45dbe9e29f07f1b5b6c2ec8be4fa624b9ee
      GitHub-Last-Rev: 6fb76e6522ef5ccb96d02445ffa39796dae89016
      GitHub-Pull-Request: golang/go#25976
      Reviewed-on: https://go-review.googlesource.com/120055
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      64f3d75b
    • Michael Fraenkel's avatar
      strings: use Builder in Map · 45c7d808
      Michael Fraenkel authored
      Use a builder to avoid the copy when converting the []byte to a string.
      
      name                  old time/op    new time/op    delta
      ByteByteMap-8            796ns ± 5%     700ns ± 1%  -12.00%  (p=0.000 n=9+8)
      Map/identity/ASCII-8     123ns ± 8%     126ns ± 7%     ~     (p=0.194 n=10+10)
      Map/identity/Greek-8     198ns ± 2%     204ns ± 5%   +2.99%  (p=0.008 n=9+10)
      Map/change/ASCII-8       266ns ±10%     202ns ± 3%  -24.19%  (p=0.000 n=10+10)
      Map/change/Greek-8       450ns ± 4%     406ns ± 1%   -9.73%  (p=0.000 n=9+10)
      MapNoChanges-8          85.4ns ± 3%    90.2ns ±11%   +5.67%  (p=0.000 n=9+10)
      
      name                  old alloc/op   new alloc/op   delta
      ByteByteMap-8             416B ± 0%      208B ± 0%  -50.00%  (p=0.000 n=10+10)
      Map/identity/ASCII-8     0.00B          0.00B          ~     (all equal)
      Map/identity/Greek-8     0.00B          0.00B          ~     (all equal)
      Map/change/ASCII-8        128B ± 0%       64B ± 0%  -50.00%  (p=0.000 n=10+10)
      Map/change/Greek-8        160B ± 0%       80B ± 0%  -50.00%  (p=0.000 n=10+10)
      MapNoChanges-8           0.00B          0.00B          ~     (all equal)
      
      name                  old allocs/op  new allocs/op  delta
      ByteByteMap-8             2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.000 n=10+10)
      Map/identity/ASCII-8      0.00           0.00          ~     (all equal)
      Map/identity/Greek-8      0.00           0.00          ~     (all equal)
      Map/change/ASCII-8        2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.000 n=10+10)
      Map/change/Greek-8        2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.000 n=10+10)
      MapNoChanges-8            0.00           0.00          ~     (all equal)
      
      Fixes #26304
      
      Change-Id: Ideec9dfc29b0b8107f34fc634247081d0031777d
      Reviewed-on: https://go-review.googlesource.com/122875Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      45c7d808
    • Daniël de Kok's avatar
      cmd/cgo: perform explicit conversion in _GoStringLen · d2ace0ce
      Daniël de Kok authored
      _GoStringLen performs an implicit conversion from intgo to size_t.
      Explicitly cast to size_t.
      
      This change avoids warnings when using cgo with CFLAGS:
      -Wconversion.
      
      Change-Id: I58f75a35e17f669a67f9805061c041b03eddbb5c
      GitHub-Last-Rev: b5df1ac0c3c90360fa1d22c069e0f126e9f894d8
      GitHub-Pull-Request: golang/go#27092
      Reviewed-on: https://go-review.googlesource.com/129820
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      d2ace0ce
  2. 21 Aug, 2018 21 commits
    • Alberto Donizetti's avatar
      time: accept anything between -23 and 23 as offset namezone name · 2ce84112
      Alberto Donizetti authored
      time.Parse currently rejects numeric timezones names with UTC offsets
      bigger than +12, but this is incorrect: there's a +13 timezone and a
      +14 timezone:
      
        $ zdump Pacific/Kiritimati
        Pacific/Kiritimati  Mon Jun 25 02:15:03 2018 +14
      
      For convenience, this cl changes the ranges of accepted offsets from
      -14..+12 to -23..+23 (zero still excluded), i.e. every possible offset
      that makes sense. We don't validate three-letter abbreviations for the
      timezones names, so there's no need to be too strict on numeric names.
      
      This change also fixes a bug in the parseTimeZone, that is currently
      unconditionally returning true (i.e. valid timezone), without checking
      the value returned by parseSignedOffset.
      
      This fixes 5 of 17 time.Parse() failures listed in Issue #26032.
      
      Updates #26032
      
      Change-Id: I2f08ca9aa41ea4c6149ed35ed2dd8f23eeb42bff
      Reviewed-on: https://go-review.googlesource.com/120558Reviewed-by: 's avatarRob Pike <r@golang.org>
      2ce84112
    • Ian Lance Taylor's avatar
      math: test for pos/neg zero return of Ceil/Floor/Trunc · 1ae2eed0
      Ian Lance Taylor authored
      Ceil and Trunc of -0.2 return -0, not +0, but we didn't test that.
      
      Updates #23647
      
      Change-Id: Idbd4699376abfb4ca93f16c73c114d610d86a9f2
      Reviewed-on: https://go-review.googlesource.com/91335
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      1ae2eed0
    • Jordan Rhee's avatar
      cmd/link: support windows/arm · aa311fec
      Jordan Rhee authored
      Enable the Go linker to generate executables for windows/arm.
      
      Generates PE relocation tables, which are used by Windows to
      dynamically relocate the Go binary in memory. Windows on ARM
      requires all modules to be relocatable, unlike x86/amd64 which are
      permitted to have fixed base addresses.
      
      Updates #26148
      
      Change-Id: Ie63964ff52c2377e121b2885e9d05ec3ed8dc1cd
      Reviewed-on: https://go-review.googlesource.com/125648
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      aa311fec
    • Ilya Tocar's avatar
      net: use internal/bytealg insetad of linkname tricks · 39e59da7
      Ilya Tocar authored
      We are currently using go:linkname for some algorithms from
      strings/bytes packages, to avoid importing strings/bytes.
      But strings/bytes are just wrappers around internal/bytealg, so
      we should use internal/bytealg directly.
      
      Change-Id: I2836f779b88bf8876d5fa725043a6042bdda0390
      Reviewed-on: https://go-review.googlesource.com/130515
      Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      39e59da7
    • Ilya Tocar's avatar
      time: optimize big4 · 08cc3dc5
      Ilya Tocar authored
      Use the same load order in big4 as in encoding/binary.BigEndian.
      This order is recognized by the compiler and converted into single load.
      This isn't in the hot path, but doesn't hurt readability, so lets do this.
      
      Change-Id: Ib1240d0b278e9d667ad419fe91fa52b23d28cfc0
      Reviewed-on: https://go-review.googlesource.com/130478
      Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      08cc3dc5
    • Andreas Auernhammer's avatar
      crypto/rc4: remove assembler implementations · 30eda671
      Andreas Auernhammer authored
      This CL removes the RC4 assembler implementations.
      RC4 is broken and should not be used for encryption
      anymore. Therefore it's not worth maintaining
      platform-specific assembler implementations.
      
      The native Go implementation may be slower
      or faster depending on the CPU:
      
      name       old time/op   new time/op   delta
      RC4_128-4    256ns ± 0%    196ns ± 0%  -23.78%  (p=0.029 n=4+4)
      RC4_1K-4    2.38µs ± 0%   1.54µs ± 0%  -35.22%  (p=0.029 n=4+4)
      RC4_8K-4    19.4µs ± 1%   12.0µs ± 0%  -38.35%  (p=0.029 n=4+4)
      
      name       old speed     new speed     delta
      RC4_128-4  498MB/s ± 0%  654MB/s ± 0%  +31.12%  (p=0.029 n=4+4)
      RC4_1K-4   431MB/s ± 0%  665MB/s ± 0%  +54.34%  (p=0.029 n=4+4)
      RC4_8K-4   418MB/s ± 1%  677MB/s ± 0%  +62.18%  (p=0.029 n=4+4)
      
      vendor_id	: GenuineIntel
      cpu family	: 6
      model		: 142
      model name	: Intel(R) Core(TM) i5-7Y54 CPU @ 1.20GHz
      stepping	: 9
      microcode	: 0x84
      cpu MHz		: 800.036
      cache size	: 4096 KB
      
      name       old time/op   new time/op   delta
      RC4_128-4    235ns ± 1%    431ns ± 0%  +83.00%  (p=0.000 n=10+10)
      RC4_1K-4    1.74µs ± 0%   3.41µs ± 0%  +96.74%  (p=0.000 n=10+10)
      RC4_8K-4    13.6µs ± 1%   26.8µs ± 0%  +97.58%   (p=0.000 n=10+9)
      
      name       old speed     new speed     delta
      RC4_128-4  543MB/s ± 0%  297MB/s ± 1%  -45.29%  (p=0.000 n=10+10)
      RC4_1K-4   590MB/s ± 0%  300MB/s ± 0%  -49.16%  (p=0.000 n=10+10)
      RC4_8K-4   596MB/s ± 1%  302MB/s ± 0%  -49.39%   (p=0.000 n=10+9)
      
      vendor_id       : GenuineIntel
      cpu family      : 6
      model           : 63
      model name      : Intel(R) Xeon(R) CPU @ 2.30GHz
      stepping        : 0
      microcode       : 0x1
      cpu MHz         : 2300.000
      cache size      : 46080 KB
      
      Fixes #25417
      
      Change-Id: I4124037154aaaa8e48d300c23974f125b6055a1c
      Reviewed-on: https://go-review.googlesource.com/130397
      Run-TryBot: Filippo Valsorda <filippo@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      Reviewed-by: 's avatarFilippo Valsorda <filippo@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      30eda671
    • Daniel Martí's avatar
      encoding/json: various minor decoder speed-ups · 6d4787af
      Daniel Martí authored
      Reuse v.Type() and cachedTypeFields(t) when decoding maps and structs.
      
      Always use the same data slices when in hot loops, to ensure that the
      compiler generates good code. "for i < len(data) { use(d.data[i]) }"
      makes it harder for the compiler.
      
      Finally, do other minor clean-ups, such as deduplicating switch cases,
      and using a switch instead of three chained ifs.
      
      The decoder sees a noticeable speed-up, in particular when decoding
      structs.
      
      name           old time/op    new time/op    delta
      CodeDecoder-4    29.8ms ± 1%    27.5ms ± 0%  -7.83%  (p=0.002 n=6+6)
      
      name           old speed      new speed      delta
      CodeDecoder-4  65.0MB/s ± 1%  70.6MB/s ± 0%  +8.49%  (p=0.002 n=6+6)
      
      Updates #5683.
      
      Change-Id: I9d751e22502221962da696e48996ffdeb777277d
      Reviewed-on: https://go-review.googlesource.com/122468
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      6d4787af
    • Daniel Martí's avatar
      encoding/json: defer error context work until necessary · 9a2a34e1
      Daniel Martí authored
      Calling Name on a reflect.Type is somewhat expensive, as it involves a
      number of nested calls and string handling.
      
      This cost was showing up when decoding structs, as we were calling it to
      set up an error context.
      
      We can avoid the extra work unless we do encounter an error, which makes
      decoding via struct types faster.
      
      name           old time/op    new time/op    delta
      CodeDecoder-4    31.0ms ± 1%    29.9ms ± 1%  -3.69%  (p=0.002 n=6+6)
      
      name           old speed      new speed      delta
      CodeDecoder-4  62.6MB/s ± 1%  65.0MB/s ± 1%  +3.83%  (p=0.002 n=6+6)
      
      Updates #5683.
      
      Change-Id: I48a3a85ef0ba96f524b7c3e9096cb2c4589e077a
      Reviewed-on: https://go-review.googlesource.com/122467
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      9a2a34e1
    • Michael Munday's avatar
      crypto/{aes,cipher,rand}: use binary.{Big,Little}Endian methods · 4a842f25
      Michael Munday authored
      Use the binary.{Big,Little}Endian integer encoding methods rather
      than unsafe or local implementations. These methods are tested to
      ensure they inline correctly and don't add unnecessary bounds checks,
      so it seems better to use them wherever possible.
      
      This introduces a dependency on encoding/binary to crypto/cipher. I
      think this is OK because other "L3" packages already import
      encoding/binary.
      
      Change-Id: I5cf01800d08554ca364e46cfc1d9445cf3c711a0
      Reviewed-on: https://go-review.googlesource.com/115555
      Run-TryBot: Michael Munday <mike.munday@ibm.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      4a842f25
    • Alberto Donizetti's avatar
      cmd/gofmt: skip gofmt idempotency check on known issue · 3649fe29
      Alberto Donizetti authored
      gofmt's TestAll runs gofmt on all the go files in the tree and checks,
      among other things, that gofmt is idempotent (i.e. that a second
      invocation does not change the input again).
      
      There's a known bug of gofmt not being idempotent (Issue #24472), and
      unfortunately the fixedbugs/issue22662.go file triggers it. We can't
      just gofmt the file, because it tests the effect of various line
      directives inside weirdly-placed comments, and gofmt moves those
      comments, making the test useless.
      
      Instead, just skip the idempotency check when gofmt-ing the
      problematic file.
      
      This fixes go test on the cmd/gofmt package, and a failure seen on the
      longtest builder.
      
      Updates #24472
      
      Change-Id: Ib06300977cd8fce6c609e688b222e9b2186f5aa7
      Reviewed-on: https://go-review.googlesource.com/130377Reviewed-by: 's avatarDaniel Martí <mvdan@mvdan.cc>
      Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      3649fe29
    • Ian Lance Taylor's avatar
      misc/cgo/testcarchive: make the tests work when using gccgo · 0829e1b7
      Ian Lance Taylor authored
      Change-Id: I62a7a8ebbbc1f1a266234b53680768da157b2df5
      Reviewed-on: https://go-review.googlesource.com/130416
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      0829e1b7
    • Ian Lance Taylor's avatar
      runtime: don't use linkname to refer to internal/cpu · cd7cb86d
      Ian Lance Taylor authored
      The runtime package already imports the internal/cpu package, so there
      is no reason for it to use go:linkname comments to refer to
      internal/cpu functions and variables. Since internal/cpu is internal,
      we can just export those names. Removing the obscurity of go:linkname
      outweighs the minor additional complexity added to the internal/cpu API.
      
      Change-Id: Id89951b7f3fc67cd9bce67ac6d01d44a647a10ad
      Reviewed-on: https://go-review.googlesource.com/128755
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      Reviewed-by: 's avatarMartin Möhrmann <moehrmann@google.com>
      cd7cb86d
    • Tobias Klauser's avatar
      syscall: add S_IRWXG and S_IRWXO on Solaris · 4e1b11e2
      Tobias Klauser authored
      As discussed in CL 126621, these constants are already defined on Linux,
      Darwin, FreeBSD and NetBSD. In order to ensure portability of existing
      code using the syscall package, provide them for Solaris as well.
      
      Change-Id: Id49f6991f36775b152b9c47b9923cd0a08053bcb
      Reviewed-on: https://go-review.googlesource.com/130356
      Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      4e1b11e2
    • Tobias Klauser's avatar
      syscall: add S_IRWXG and S_IRWXO on OpenBSD · d865e1fa
      Tobias Klauser authored
      As discussed in CL 126621, these constants are already defined on Linux,
      Darwin, FreeBSD and NetBSD. In order to ensure portability of existing
      code using the syscall package, provide them for OpenBSD (and
      DragonflyBSD, in a separate CL) as well.
      
      Change-Id: Ia9e07cb01f989d144a620d268daa8ec946788861
      Reviewed-on: https://go-review.googlesource.com/130336
      Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      d865e1fa
    • Tobias Klauser's avatar
      syscall: add S_IRWXG and S_IRWXO on DragonflyBSD · e8daca4c
      Tobias Klauser authored
      As discussed in CL 126621, these constants are already defined on Linux,
      Darwin, FreeBSD and NetBSD. In order to ensure portability of existing
      code using the syscall package, provide them for DragonflyBSD (and
      OpenBSD, in a separate CL) as well.
      
      Change-Id: I708c60f75f787a410bdfa4ceebd2825874e92511
      Reviewed-on: https://go-review.googlesource.com/130335
      Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      e8daca4c
    • Florian Forster's avatar
      net/url: escape URL.RawQuery on Parse if it contains invalid characters · 1040626c
      Florian Forster authored
      Fixes #22907
      
      Change-Id: I7abcf53ab92768514e13ce2554a6c25dcde8218e
      Reviewed-on: https://go-review.googlesource.com/99135
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      1040626c
    • Michael Munday's avatar
      go/build: format with latest gofmt · 1d1a0277
      Michael Munday authored
      Change-Id: I172af5c83a0d4d79ad627ba9dfe02dead23bf3a6
      Reviewed-on: https://go-review.googlesource.com/130376
      Run-TryBot: Michael Munday <mike.munday@ibm.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarDaniel Martí <mvdan@mvdan.cc>
      1d1a0277
    • Giovanni Bajo's avatar
      doc: remove mentions of cloning from GitHub · 94e4aca3
      Giovanni Bajo authored
      Complete CL117178 removing all references to GitHub, and leaving
      a small note to make sure we remember that it's not supported.
      
      Change-Id: Id4257515a864875808fa7a67f002ed52cfd635a3
      Reviewed-on: https://go-review.googlesource.com/130395Reviewed-by: 's avatarDaniel Martí <mvdan@mvdan.cc>
      94e4aca3
    • Daniel Martí's avatar
      cmd/compile: fix racy setting of gc's Config.Race · c1807989
      Daniel Martí authored
      ssaConfig.Race was being set by many goroutines concurrently, resulting
      in a data race seen below. This was very likely introduced by CL 121235.
      
      	WARNING: DATA RACE
      	Write at 0x00c000344408 by goroutine 12:
      	  cmd/compile/internal/gc.buildssa()
      	      /workdir/go/src/cmd/compile/internal/gc/ssa.go:134 +0x7a8
      	  cmd/compile/internal/gc.compileSSA()
      	      /workdir/go/src/cmd/compile/internal/gc/pgen.go:259 +0x5d
      	  cmd/compile/internal/gc.compileFunctions.func2()
      	      /workdir/go/src/cmd/compile/internal/gc/pgen.go:323 +0x5a
      
      	Previous write at 0x00c000344408 by goroutine 11:
      	  cmd/compile/internal/gc.buildssa()
      	      /workdir/go/src/cmd/compile/internal/gc/ssa.go:134 +0x7a8
      	  cmd/compile/internal/gc.compileSSA()
      	      /workdir/go/src/cmd/compile/internal/gc/pgen.go:259 +0x5d
      	  cmd/compile/internal/gc.compileFunctions.func2()
      	      /workdir/go/src/cmd/compile/internal/gc/pgen.go:323 +0x5a
      
      	Goroutine 12 (running) created at:
      	  cmd/compile/internal/gc.compileFunctions()
      	      /workdir/go/src/cmd/compile/internal/gc/pgen.go:321 +0x39b
      	  cmd/compile/internal/gc.Main()
      	      /workdir/go/src/cmd/compile/internal/gc/main.go:651 +0x437d
      	  main.main()
      	      /workdir/go/src/cmd/compile/main.go:51 +0x100
      
      	Goroutine 11 (running) created at:
      	  cmd/compile/internal/gc.compileFunctions()
      	      /workdir/go/src/cmd/compile/internal/gc/pgen.go:321 +0x39b
      	  cmd/compile/internal/gc.Main()
      	      /workdir/go/src/cmd/compile/internal/gc/main.go:651 +0x437d
      	  main.main()
      	      /workdir/go/src/cmd/compile/main.go:51 +0x100
      
      Instead, set up the field exactly once as part of initssaconfig.
      
      Change-Id: I2c30c6b1cf92b8fd98e7cb5c2e10c526467d0b0a
      Reviewed-on: https://go-review.googlesource.com/130375
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarDave Cheney <dave@cheney.net>
      c1807989
    • Daniel Martí's avatar
      encoding/json: remove alloc when encoding short byte slices · 30d3ebe3
      Daniel Martí authored
      If the encoded bytes fit in the bootstrap array encodeState.scratch, use
      that instead of allocating a new byte slice.
      
      Also tweaked the Encoding vs Encoder heuristic to use the length of the
      encoded bytes, not the length of the input bytes. Encoding is used for
      allocations of up to 1024 bytes, as we measured 2048 to be the point
      where it no longer provides a noticeable advantage.
      
      Also added some benchmarks. Only the first case changes in behavior.
      
      name                 old time/op    new time/op    delta
      MarshalBytes/32-4       420ns ± 1%     383ns ± 1%   -8.69%  (p=0.002 n=6+6)
      MarshalBytes/256-4      913ns ± 1%     915ns ± 0%     ~     (p=0.580 n=5+6)
      MarshalBytes/4096-4    7.72µs ± 0%    7.74µs ± 0%     ~     (p=0.340 n=5+6)
      
      name                 old alloc/op   new alloc/op   delta
      MarshalBytes/32-4        112B ± 0%       64B ± 0%  -42.86%  (p=0.002 n=6+6)
      MarshalBytes/256-4       736B ± 0%      736B ± 0%     ~     (all equal)
      MarshalBytes/4096-4    7.30kB ± 0%    7.30kB ± 0%     ~     (all equal)
      
      name                 old allocs/op  new allocs/op  delta
      MarshalBytes/32-4        2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.002 n=6+6)
      MarshalBytes/256-4       2.00 ± 0%      2.00 ± 0%     ~     (all equal)
      MarshalBytes/4096-4      2.00 ± 0%      2.00 ± 0%     ~     (all equal)
      
      Updates #5683.
      
      Change-Id: I5fa55c27bd7728338d770ae7c0756885ba9a5724
      Reviewed-on: https://go-review.googlesource.com/122462
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      30d3ebe3
    • Daniel Martí's avatar
      encoding/json: encode struct field names ahead of time · 2d3599e5
      Daniel Martí authored
      Struct field names are static, so we can run HTMLEscape on them when
      building each struct type encoder. Then, when running the struct
      encoder, we can select either the original or the escaped field name to
      write directly.
      
      When the encoder is not escaping HTML, using the original string works
      because neither Go struct field names nor JSON tags allow any characters
      that would need to be escaped, like '"', '\\', or '\n'.
      
      When the encoder is escaping HTML, the only difference is that '<', '>',
      and '&' are allowed via JSON struct field tags, hence why we use
      HTMLEscape to properly escape them.
      
      All of the above lets us encode field names with a simple if/else and
      WriteString calls, which are considerably simpler and faster than
      encoding an arbitrary string.
      
      While at it, also include the quotes and colon in these strings, to
      avoid three WriteByte calls in the loop hot path.
      
      Also added a few tests, to ensure that the behavior in these edge cases
      is not broken. The output of the tests is the same if this optimization
      is reverted.
      
      name           old time/op    new time/op    delta
      CodeEncoder-4    7.12ms ± 0%    6.14ms ± 0%  -13.85%  (p=0.004 n=6+5)
      
      name           old speed      new speed      delta
      CodeEncoder-4   272MB/s ± 0%   316MB/s ± 0%  +16.08%  (p=0.004 n=6+5)
      
      name           old alloc/op   new alloc/op   delta
      CodeEncoder-4    91.9kB ± 0%    93.2kB ± 0%   +1.43%  (p=0.002 n=6+6)
      
      name           old allocs/op  new allocs/op  delta
      CodeEncoder-4      0.00           0.00          ~     (all equal)
      
      Updates #5683.
      
      Change-Id: I6f6a340d0de4670799ce38cf95b2092822d2e3ef
      Reviewed-on: https://go-review.googlesource.com/122460
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      2d3599e5