1. 29 Oct, 2017 1 commit
    • Austin Clements's avatar
      runtime: remove write barriers from newstack, gogo · 3beaf26e
      Austin Clements authored
      Currently, newstack and gogo have write barriers for maintaining the
      context register saved in g.sched.ctxt. This is troublesome, because
      newstack can be called from go:nowritebarrierrec places that can't
      allow write barriers. It happens to be benign because g.sched.ctxt
      will always be nil on entry to newstack *and* it so happens the
      incoming ctxt will also always be nil in these contexts (I
      think/hope), but this is playing with fire. It's also desirable to
      mark newstack go:nowritebarrierrec to prevent any other, non-benign
      write barriers from creeping in, but we can't do that right now
      because of this one write barrier.
      
      Fix all of this by observing that g.sched.ctxt is really just a saved
      live pointer register. Hence, we can shade it when we scan g's stack
      and otherwise move it back and forth between the actual context
      register and g.sched.ctxt without write barriers. This means we can
      save it in morestack along with all of the other g.sched, eliminate
      the save from newstack along with its troublesome write barrier, and
      eliminate the shenanigans in gogo to invoke the write barrier when
      restoring it.
      
      Once we've done all of this, we can mark newstack
      go:nowritebarrierrec.
      
      Fixes #22385.
      For #22460.
      
      Change-Id: I43c24958e3f6785b53c1350e1e83c2844e0d1522
      Reviewed-on: https://go-review.googlesource.com/72553
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
      Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
      3beaf26e
  2. 28 Oct, 2017 5 commits
  3. 27 Oct, 2017 10 commits
    • Russ Cox's avatar
      cmd/dist: translate /private/var to /var on darwin builders · 4f2ee499
      Russ Cox authored
      This is ugly but needed on the builders, because they do not set
      PWD/GOROOT consistently, and the new content-based staleness
      understands that the setting of GOROOT influences the content in
      the linker outputs.
      
      Change-Id: I0606f2c70b719619b188864ad3ae1b34432140cb
      Reviewed-on: https://go-review.googlesource.com/74070
      Run-TryBot: Russ Cox <rsc@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarDavid Crawshaw <crawshaw@golang.org>
      4f2ee499
    • Joshua Rubin's avatar
      net/http: fix minor leak in Header.WriteSubset · a4d03a9b
      Joshua Rubin authored
      Header.WriteSubset uses a sync.Pool but wouldn't Put the sorter back in
      the pool if there was an error writing to the io.Writer
      
      I'm not really sure why the sorter is returned to begin with. The
      comment says "for possible return to headerSorterCache".
      
      This also doesn't address potential panics that might occur, but the
      overhead of doing the Put in a defer would likely be too great.
      
      Change-Id: If3c45a4c3e11f6ec65d187e25b63455b0142d4e3
      Reviewed-on: https://go-review.googlesource.com/73910
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarTom Bergan <tombergan@google.com>
      a4d03a9b
    • Than McIntosh's avatar
      cmd/compile, cmd/link: support for DWARF file reference relocations · b52b77cb
      Than McIntosh authored
      New relocation flavor R_DWARFFILEREF, to be applied to DWARF attribute
      values that correspond to file references (ex: DW_AT_decl_file,
      DW_AT_call_file). The LSym for this relocation is the file itself; the
      linker replaces the relocation target with the index of the specified
      file in the line table's file section.
      
      Note: for testing purposes this patch changes the DWARF function
      subprogram DIE abbrev to include DW_AT_decl_file (allowed by DWARF
      but not especially useful) so as to have a way to test this
      functionality. This attribute will be removed once there are other
      file reference attributes (coming as part of inlining support).
      
      Change-Id: Icf676beb60fcc33f06d78e747ef717532daaa3ba
      Reviewed-on: https://go-review.googlesource.com/73330
      Run-TryBot: Than McIntosh <thanm@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarAustin Clements <austin@google.com>
      b52b77cb
    • Russ Cox's avatar
      cmd/dist: use latest heap, sort packages for compiler bootstrap · a93bc1d2
      Russ Cox authored
      The compiler depends on the way heap and sort break ties
      in some cases. Instead of trying to find them all, bundle
      those packages into the bootstrap compiler builds.
      
      The overall goal is that Go1.4 building cmd/compile during the
      bootstrap process produces a semantically equivalent compiler
      to cmd/compile compiling itself. After this CL, that property is true,
      at least for the compiler compiling itself and the other tools.
      
      A test for this property will be in CL 73212.
      
      Change-Id: Icc1ba7cbe828f5673e8198ebacb18c7c01f3a735
      Reviewed-on: https://go-review.googlesource.com/73952
      Run-TryBot: Russ Cox <rsc@golang.org>
      Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      a93bc1d2
    • Russ Cox's avatar
      sort: split post-Go1.4 code into its own file · 3caa02f6
      Russ Cox authored
      This will let us build the latest sort when bootstrapping the compiler.
      The compiler depends on the precise tie-breaks used by sort in
      some cases, and it's easier to bring sort along than require checking
      every sort call ever added to the compiler.
      
      Change-Id: Idc622f89aedbb40d848708c76650fc28779d0c3c
      Reviewed-on: https://go-review.googlesource.com/73951
      Run-TryBot: Russ Cox <rsc@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
      3caa02f6
    • Than McIntosh's avatar
      cmd/link: don't pass -gdwarf-2 to external linker · 3e1e66fa
      Than McIntosh authored
      Don't pass -gdwarf-2 to the external linker when external linkage is
      requested. The Go compiler is now emitting DWARF version 4, so this
      doesn't seem needed any more.
      
      Fixes #22455
      
      Change-Id: Ic4122c55e946619a266430f2d26f06d6803dd232
      Reviewed-on: https://go-review.googlesource.com/73672Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      3e1e66fa
    • Russ Cox's avatar
      cmd/go: delay gcc/clang flag support checks · 509140a5
      Russ Cox authored
      env.MkEnv was computing the full gcc command line to report as
      $GOGCCFLAGS in "go env" output, which meant running gcc (or clang)
      multiple times to discern which flags are available.
      We also set $GOGCCFLAGS in the environment, but nothing actually uses
      that as far as I can tell - it was always intended only for debugging.
      Move GOGCCFLAGS to env.ExtraEnvVars, which displayed in "go env"
      output but not set in child processes and not computed nearly as
      often.
      
      The effect is that trivial commands like "go help" or "go env GOARCH"
      or "go tool -n compile" now run in about 0.01s instead of 0.1s,
      because they no longer run gcc 4 times each.
      
      go test -short cmd/go drops from 81s to 44s (and needs more trimming).
      
      The $GOROOT/test suite drops from 92s to 33s, because the number of
      gcc invocation drops from 13,336 to 0.
      
      Overall, all.bash drops from 5m53s to 4m07s wall time.
      
      Change-Id: Ia85abc89e1e2bb126b933aff3bf7c5f6c0984cd5
      Reviewed-on: https://go-review.googlesource.com/73850
      Run-TryBot: Russ Cox <rsc@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      509140a5
    • Tobias Klauser's avatar
      syscall: document Time{spec,val} methods · 150a46c0
      Tobias Klauser authored
      Add godoc comments for Time{spec,val} methods Unix and Nano.
      
      Change-Id: I285bbd236af588b30140db7182b05f8b202b5b0b
      Reviewed-on: https://go-review.googlesource.com/73271
      Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      150a46c0
    • Tobias Klauser's avatar
      syscall: simplify return in Futimesat and Mount · dc97f410
      Tobias Klauser authored
      Directly return error instead of assigning to err and then returning.
      
      Change-Id: Ie5c466cac70cc6d52ee72ebba3e497e0da8a5797
      Reviewed-on: https://go-review.googlesource.com/73531
      Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      dc97f410
    • Artyom Pervukhin's avatar
      image/draw, image/color: optimize hot path sqDiff function · 7a8e8b2f
      Artyom Pervukhin authored
      Function sqDiff is called multiple times in the hot path (x, y loops) of
      drawPaletted from the image/draw package; number of sqDiff calls is
      between 4×width×height and 4×width×height×len(palette) for each
      drawPaletted call.
      
      Simplify this function by removing arguments comparison and relying
      instead on signed to unsigned integer conversion rules and properties of
      unsigned integer values operations guaranteed by the spec:
      
      > For unsigned integer values, the operations +, -, *, and << are
      > computed modulo 2n, where n is the bit width of the unsigned integer's
      > type. Loosely speaking, these unsigned integer operations discard high
      > bits upon overflow, and programs may rely on ``wrap around''.
      
      image/gif package benchmark that depends on the code updated shows
      throughput improvements:
      
      name               old time/op    new time/op    delta
      QuantizedEncode-4     788ms ± 2%     468ms ± 9%  -40.58%  (p=0.000 n=9+10)
      
      name               old speed      new speed      delta
      QuantizedEncode-4  1.56MB/s ± 2%  2.63MB/s ± 8%  +68.47%  (p=0.000 n=9+10)
      
      Closes #22375.
      
      Change-Id: Ic9a540e39ceb21e7741d308af1cfbe61b4ac347b
      Reviewed-on: https://go-review.googlesource.com/72373Reviewed-by: 's avatarNigel Tao <nigeltao@golang.org>
      7a8e8b2f
  4. 26 Oct, 2017 11 commits
    • Ian Lance Taylor's avatar
      test: add type alias test that caused gccgo to crash · 62229970
      Ian Lance Taylor authored
      Change-Id: I3b388e4ac05ace5b7768ade03df2bee5bcc26ba8
      Reviewed-on: https://go-review.googlesource.com/73790
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarThan McIntosh <thanm@google.com>
      62229970
    • isharipo's avatar
      obj/x86: re-organize code to make codegen easier · c35f239d
      isharipo authored
      1. Move AXXX constants (A-enumeration) from "a.out.go" to "aenum.go"
      2. Move VEX-encoded optabs from "asm6.go" to "vex_optabs.go"
      
      Also run "go generate" over aenum.go. This explains diff in "anames.go".
      
      Initialization of opindex is split into 2 loops:
      one for `vexOptab`, second for `optab`.
      
      Rationale:
      when VEX instructions are generated with current structure,
      asm6.go is modified, which can lead to merge conflicts and
      larger diffs than desired. Same for a.out.go.
      
      This change makes x86avxgen usage possible:
      https://go-review.googlesource.com/c/arch/+/66972
      
      Change-Id: Id9eefcf5ccf0a89440e5d01bcb80926a8163b41d
      Reviewed-on: https://go-review.googlesource.com/70630
      Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
      c35f239d
    • Christopher Koch's avatar
      syscall: remove unnecessary use of unsafe.Pointer. · 186872f3
      Christopher Koch authored
      Change-Id: I43b32fbca8761d33927e7d0541bba123df0e0122
      Reviewed-on: https://go-review.googlesource.com/73556Reviewed-by: 's avatarTobias Klauser <tobias.klauser@gmail.com>
      Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      186872f3
    • Austin Clements's avatar
      runtime: "fix" non-preemptible loop in TestParallelRWMutexReaders · da95254d
      Austin Clements authored
      TestParallelRWMutexReaders has a non-preemptible loop in it that can
      deadlock if GC triggers. "Fix" it like we've fixed similar tests.
      
      Updates #10958.
      
      Change-Id: I13618f522f5ef0c864e7171ad2f655edececacd7
      Reviewed-on: https://go-review.googlesource.com/73710
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      da95254d
    • Russ Cox's avatar
      vendor/golang_org/x/net/route: refresh from upstream · 4d8d1383
      Russ Cox authored
      This picks up a few changes and should stop the macOS crashes.
      
      Fixes #22456.
      
      Change-Id: I7e0aae119a5564fcfaa16eeab7422bdd5ff0497b
      Reviewed-on: https://go-review.googlesource.com/73691
      Run-TryBot: Russ Cox <rsc@golang.org>
      Reviewed-by: 's avatarAustin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      4d8d1383
    • Alberto Donizetti's avatar
      math/big: add (*Float).Sqrt · bd48d37e
      Alberto Donizetti authored
      This change adds a Square root method to the big.Float type, with
      signature
      
        (z *Float) Sqrt(x *Float) *Float
      
      Fixes #20460
      
      Change-Id: I050aaed0615fe0894e11c800744600648343c223
      Reviewed-on: https://go-review.googlesource.com/67830
      Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
      bd48d37e
    • Kevin Burke's avatar
      net/smtp: fix spelling mistake · 577538a2
      Kevin Burke authored
      Change-Id: I3141076c0db7b70ea408c941a857ed1f82dcb2df
      Reviewed-on: https://go-review.googlesource.com/73557Reviewed-by: 's avatarAlberto Donizetti <alb.donizetti@gmail.com>
      577538a2
    • David Crawshaw's avatar
      cmd/link, plugin: always encode path · 6355d6c7
      David Crawshaw authored
      Both the linker and the plugin package were inconsistent
      about when they applied the path encoding defined in
      objabi.PathToPrefix. As a result, only some symbols from
      a package path that required encoding were being found.
      
      So always encoding the path.
      
      Fixes #22295
      
      Change-Id: Ife86c79ca20b2e9307008ed83885e193d32b7dc4
      Reviewed-on: https://go-review.googlesource.com/72390
      Run-TryBot: David Crawshaw <crawshaw@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      6355d6c7
    • Ben Shi's avatar
      cmd/compile: optimize MOVBS/MOVBU/MOVHS/MOVHU on ARMv6 and ARMv7 · 78ea9a71
      Ben Shi authored
      MOVBS/MOVBU/MOVHS/MOVHU can be optimized with a single instruction
      on ARMv6 and ARMv7, instead of a pair of left/right shifts.
      
      The benchmark tests show big improvement in special cases and a little
      improvement in total.
      
      1. A special case gets about 29% improvement.
      name                     old time/op    new time/op    delta
      TypePro-4                  3.81ms ± 1%    2.71ms ± 1%  -28.97%  (p=0.000 n=26+25)
      The source code of this case can be found at
      https://github.com/benshi001/ugo1/blob/master/typepromotion_test.go
      
      2. There is a little improvement in the go1 benchmark, excluding the noise.
      name                     old time/op    new time/op    delta
      BinaryTree17-4              42.1s ± 3%     42.1s ± 2%    ~     (p=0.883 n=28+30)
      Fannkuch11-4                24.3s ± 4%     24.7s ± 7%  +1.64%  (p=0.026 n=30+30)
      FmtFprintfEmpty-4           833ns ± 2%     835ns ± 2%    ~     (p=0.371 n=26+28)
      FmtFprintfString-4         1.36µs ± 3%    1.35µs ± 1%    ~     (p=0.202 n=26+23)
      FmtFprintfInt-4            1.42µs ± 3%    1.43µs ± 1%  +0.66%  (p=0.000 n=26+27)
      FmtFprintfIntInt-4         2.10µs ± 1%    2.10µs ± 2%    ~     (p=0.104 n=25+26)
      FmtFprintfPrefixedInt-4    2.37µs ± 2%    2.33µs ± 1%  -1.75%  (p=0.000 n=25+28)
      FmtFprintfFloat-4          4.50µs ± 0%    4.37µs ± 1%  -2.81%  (p=0.000 n=23+25)
      FmtManyArgs-4              8.08µs ± 0%    8.13µs ± 3%    ~     (p=0.160 n=23+26)
      GobDecode-4                 102ms ± 4%     103ms ± 4%  +1.08%  (p=0.001 n=28+26)
      GobEncode-4                96.0ms ± 2%    95.2ms ± 3%  -0.81%  (p=0.000 n=24+25)
      Gzip-4                      4.17s ± 3%     4.11s ± 2%  -1.45%  (p=0.000 n=25+25)
      Gunzip-4                    597ms ± 2%     594ms ± 2%  -0.57%  (p=0.000 n=24+26)
      HTTPClientServer-4          708µs ± 4%     708µs ± 4%    ~     (p=0.852 n=28+28)
      JSONEncode-4                241ms ± 1%     245ms ± 3%  +1.62%  (p=0.000 n=27+28)
      JSONDecode-4                906ms ± 3%     889ms ± 3%  -1.85%  (p=0.000 n=23+24)
      Mandelbrot200-4            41.8ms ± 1%    41.8ms ± 1%    ~     (p=0.929 n=25+24)
      GoParse-4                  47.1ms ± 2%    45.3ms ± 4%  -3.80%  (p=0.000 n=28+24)
      RegexpMatchEasy0_32-4      1.27µs ± 2%    1.28µs ± 1%  +0.77%  (p=0.000 n=26+28)
      RegexpMatchEasy0_1K-4      8.08µs ± 9%    7.83µs ±10%  -3.10%  (p=0.012 n=26+26)
      RegexpMatchEasy1_32-4      1.29µs ± 5%    1.29µs ± 2%    ~     (p=0.301 n=26+29)
      RegexpMatchEasy1_1K-4      10.5µs ± 4%    10.3µs ± 5%  -1.95%  (p=0.003 n=26+26)
      RegexpMatchMedium_32-4     1.94µs ± 1%    1.95µs ± 1%    ~     (p=0.251 n=24+27)
      RegexpMatchMedium_1K-4      502µs ± 2%     502µs ± 2%    ~     (p=0.336 n=25+28)
      RegexpMatchHard_32-4       26.7µs ± 1%    26.6µs ± 3%    ~     (p=0.454 n=27+26)
      RegexpMatchHard_1K-4        801µs ± 3%     799µs ± 2%    ~     (p=0.097 n=24+26)
      Revcomp-4                  73.5ms ± 5%    73.2ms ± 3%    ~     (p=0.240 n=26+26)
      Template-4                  1.07s ± 2%     1.05s ± 1%  -2.39%  (p=0.000 n=26+24)
      TimeParse-4                6.87µs ± 1%    6.85µs ± 1%    ~     (p=0.094 n=28+23)
      TimeFormat-4               13.4µs ± 1%    13.4µs ± 1%    ~     (p=0.664 n=25+29)
      [Geo mean]                  717µs          713µs       -0.54%
      
      name                     old speed      new speed      delta
      GobDecode-4              7.52MB/s ± 4%  7.44MB/s ± 4%  -1.10%  (p=0.001 n=28+26)
      GobEncode-4              7.99MB/s ± 2%  8.06MB/s ± 3%  +0.81%  (p=0.000 n=24+25)
      Gzip-4                   4.66MB/s ± 3%  4.72MB/s ± 2%  +1.43%  (p=0.000 n=25+25)
      Gunzip-4                 32.5MB/s ± 2%  32.7MB/s ± 2%  +0.56%  (p=0.001 n=24+26)
      JSONEncode-4             8.04MB/s ± 1%  7.92MB/s ± 3%  -1.59%  (p=0.000 n=27+28)
      JSONDecode-4             2.14MB/s ± 3%  2.18MB/s ± 3%  +1.90%  (p=0.000 n=23+24)
      GoParse-4                1.23MB/s ± 3%  1.28MB/s ± 4%  +4.23%  (p=0.000 n=30+24)
      RegexpMatchEasy0_32-4    25.2MB/s ± 2%  25.0MB/s ± 1%  -0.76%  (p=0.000 n=26+28)
      RegexpMatchEasy0_1K-4     127MB/s ± 8%   131MB/s ± 9%  +3.29%  (p=0.012 n=26+26)
      RegexpMatchEasy1_32-4    24.8MB/s ± 5%  24.8MB/s ± 2%    ~     (p=0.339 n=26+29)
      RegexpMatchEasy1_1K-4    97.9MB/s ± 4%  99.8MB/s ± 5%  +1.98%  (p=0.004 n=26+26)
      RegexpMatchMedium_32-4    514kB/s ± 3%   515kB/s ± 3%    ~     (p=0.391 n=28+28)
      RegexpMatchMedium_1K-4   2.04MB/s ± 2%  2.04MB/s ± 2%    ~     (p=0.517 n=25+28)
      RegexpMatchHard_32-4     1.20MB/s ± 3%  1.20MB/s ± 3%    ~     (p=0.203 n=28+28)
      RegexpMatchHard_1K-4     1.28MB/s ± 3%  1.28MB/s ± 2%    ~     (p=0.499 n=24+26)
      Revcomp-4                34.6MB/s ± 4%  34.7MB/s ± 3%    ~     (p=0.245 n=26+26)
      Template-4               1.81MB/s ± 2%  1.85MB/s ± 3%  +2.30%  (p=0.000 n=26+25)
      [Geo mean]               6.82MB/s       6.88MB/s       +0.84%
      
      fixes #20653
      
      Change-Id: Ief0d6e726e517e51ae511325b21ee72598e759ff
      Reviewed-on: https://go-review.googlesource.com/71992Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
      Run-TryBot: Cherry Zhang <cherryyz@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      78ea9a71
    • griesemer's avatar
      test: add test cases for method expressions with literal receiver types · c74712b3
      griesemer authored
      For #9060.
      
      Change-Id: Ibd0f047083f3c98cec96c655a3e2024df8e1d2a0
      Reviewed-on: https://go-review.googlesource.com/73554Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      c74712b3
    • Keith Randall's avatar
      cmd/compile: make sure not to use SP as an index register · 40649e69
      Keith Randall authored
      ...because that's an illegal addressing mode.
      
      I double-checked handling of this code, and 387 is the only
      place where this check is missing.
      
      Fixes #22429
      
      Change-Id: I2284fe729ea86251c6af2f04076ddf7a5e66367c
      Reviewed-on: https://go-review.googlesource.com/73551
      Run-TryBot: Keith Randall <khr@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      40649e69
  5. 25 Oct, 2017 13 commits