1. 16 Nov, 2015 14 commits
    • Austin Clements's avatar
      runtime: clear tiny alloc cache in mark term, not sweep term · 835c83b4
      Austin Clements authored
      The tiny alloc cache is maintained in a pointer from non-GC'd memory
      (mcache) to heap memory and hence must be handled carefully.
      
      Currently we clear the tiny alloc cache during sweep termination and,
      if it is assigned to a non-nil value during concurrent marking, we
      depend on a write barrier to keep the new value alive. However, while
      the compiler currently always generates this write barrier, we're
      treading on thin ice because write barriers may not happen for writes
      to non-heap memory (e.g., typedmemmove). Without this lucky write
      barrier, the GC may free a current tiny block while it's still
      reachable by the tiny allocator, leading to later memory corruption.
      
      Change this code so that, rather than depending on the write barrier,
      we simply clear the tiny cache during mark termination when we're
      clearing all of the other mcaches. If the current tiny block is
      reachable from regular pointers, it will be retained; if it isn't
      reachable from regular pointers, it may be freed, but that's okay
      because there won't be any pointers in non-GC'd memory to it.
      
      Change-Id: I8230980d8612c35c2997b9705641a1f9f865f879
      Reviewed-on: https://go-review.googlesource.com/16962
      Run-TryBot: Austin Clements <austin@google.com>
      Reviewed-by: default avatarRuss Cox <rsc@golang.org>
      Reviewed-by: default avatarKeith Randall <khr@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      835c83b4
    • Caleb Spare's avatar
      crypto/tls: return a typed error on invalid record headers · 45d1c8ab
      Caleb Spare authored
      The user can inspect the record data to detect that the other side is
      not using the TLS protocol.
      
      This will be used by the net/http client (in a follow-on CL) to detect
      when an HTTPS client is speaking to an HTTP server.
      
      Updates #11111.
      
      Change-Id: I872f78717aa8e8e98cebd8075436209a52039a73
      Reviewed-on: https://go-review.googlesource.com/16078Reviewed-by: default avatarAdam Langley <agl@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      45d1c8ab
    • Marcel van Lohuizen's avatar
      unicode/utf8: table-based algorithm for decoding · bf5b4e71
      Marcel van Lohuizen authored
      This simplifies covering all cases, reducing the number of branches
      and making unrolling for simpler functions manageable.
      This significantly improves performance of non-ASCII input.
      
      This change will also allow addressing Issue #11733 in an efficient
      manner.
      
      RuneCountTenASCIIChars-8             13.7ns ± 4%  13.5ns ± 2%     ~     (p=0.116 n=7+8)
      RuneCountTenJapaneseChars-8           153ns ± 3%    74ns ± 2%  -51.42%  (p=0.000 n=8+8)
      RuneCountInStringTenASCIIChars-8     13.5ns ± 2%  12.5ns ± 3%   -7.13%  (p=0.000 n=8+7)
      RuneCountInStringTenJapaneseChars-8   145ns ± 2%    68ns ± 2%  -53.21%  (p=0.000 n=8+8)
      ValidTenASCIIChars-8                 14.1ns ± 3%  12.5ns ± 5%  -11.38%  (p=0.000 n=8+8)
      ValidTenJapaneseChars-8               147ns ± 3%    71ns ± 4%  -51.72%  (p=0.000 n=8+8)
      ValidStringTenASCIIChars-8           12.5ns ± 3%  12.3ns ± 3%     ~     (p=0.095 n=8+8)
      ValidStringTenJapaneseChars-8         146ns ± 4%    70ns ± 2%  -51.62%  (p=0.000 n=8+7)
      DecodeASCIIRune-8                    5.91ns ± 2%  4.83ns ± 3%  -18.28%  (p=0.001 n=7+7)
      DecodeJapaneseRune-8                 12.2ns ± 7%   8.5ns ± 3%  -29.79%  (p=0.000 n=8+7)
      FullASCIIRune-8                      5.95ns ± 3%  4.27ns ± 1%  -28.23%  (p=0.000 n=8+7)
      FullJapaneseRune-8                   12.0ns ± 6%   4.3ns ± 3%  -64.39%  (p=0.000 n=8+8)
      
      Change-Id: Iea1d6b0180cbbee1739659a0a38038126beecaca
      Reviewed-on: https://go-review.googlesource.com/16940Reviewed-by: default avatarRuss Cox <rsc@golang.org>
      bf5b4e71
    • Russ Cox's avatar
      cmd/compile: fix value range check for complex constants · 2c11164d
      Russ Cox authored
      Fixes #11590.
      
      Change-Id: I4144107334604a2cc98c7984df3b5d4cde3d30af
      Reviewed-on: https://go-review.googlesource.com/16920Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      2c11164d
    • Russ Cox's avatar
      cmd/compile: do not emit args_stackmap for func _ · 292ad592
      Russ Cox authored
      Fixes #11699.
      
      Change-Id: I01bf506d76260bcdf828bbde52791e328aa441a5
      Reviewed-on: https://go-review.googlesource.com/16921Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      292ad592
    • Russ Cox's avatar
      cmd/compile: reject identifiers beginning with non-ASCII digit · 247959d9
      Russ Cox authored
      Fixes #11359.
      
      Change-Id: I0fdfa410939f7e42020cbb19d74a67e1cc3cd610
      Reviewed-on: https://go-review.googlesource.com/16919Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      247959d9
    • Russ Cox's avatar
      cmd/compile: document -trimpath · f2eb3de6
      Russ Cox authored
      Fixes #8999.
      
      Change-Id: I1390605bdf908f59b596975ea51eb04bd03bbae0
      Reviewed-on: https://go-review.googlesource.com/16918Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      f2eb3de6
    • Ian Lance Taylor's avatar
      cmd/compile: add special case for testing first field of struct variable · 9aed0b7e
      Ian Lance Taylor authored
      The change to the write barrier in https://golang.org/cl/16899 means
      that the compiler now emits tests of the first field of a struct.  That
      was using a register that was not used before.  This change fixes that
      for amd64 by adding a special case for the first field of a struct.
      
      Update #12416.
      
      Change-Id: Ia57baa62cd741592fbeb9be82f1e846be73d6edd
      Reviewed-on: https://go-review.googlesource.com/16933
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarRuss Cox <rsc@golang.org>
      9aed0b7e
    • Ian Lance Taylor's avatar
      runtime: add optional expensive check for invalid cgo pointer passing · be1ef467
      Ian Lance Taylor authored
      If you set GODEBUG=cgocheck=2 the runtime package will use the write
      barrier to detect cases where a Go program writes a Go pointer into
      non-Go memory.  In conjunction with the existing cgo checks, and the
      not-yet-implemented cgo check for exported functions, this should
      reliably detect all cases (that do not import the unsafe package) in
      which a Go pointer is incorrectly shared with C code.  This check is
      optional because it turns on the write barrier at all times, which is
      known to be expensive.
      
      Update #12416.
      
      Change-Id: I549d8b2956daa76eac853928e9280e615d6365f4
      Reviewed-on: https://go-review.googlesource.com/16899Reviewed-by: default avatarRuss Cox <rsc@golang.org>
      be1ef467
    • Ian Lance Taylor's avatar
      cmd/dist: check more GOOS/GOARCH combinations in mkdeps.bash · 1860a0fa
      Ian Lance Taylor authored
      The current mkdeps.bash just checks for dependencies for GOOS=windows
      with the current GOARCH.  This is not always accurate as some package
      imports only happen on specific GOOS/GOARCH combinations.  Check a
      selected, easily changed, combination of GOOS/GOARCH values.
      
      This generates a deps.go identical to the one in the repository today.
      
      Fixes #13221.
      
      Change-Id: I96d67d49c8c63641d578acedbb28be807607db65
      Reviewed-on: https://go-review.googlesource.com/16882Reviewed-by: default avatarMichael Matloob <matloob@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      1860a0fa
    • Rahul Chaudhry's avatar
      cmd/go: set buildmode=pie default for android/arm64. · f7c7ed7c
      Rahul Chaudhry authored
      Just like android/arm, android/arm64 refuses to execute non-PIE
      binaries. In addition, starting from the M release (Marshmallow),
      Android refuses to execute binaries with any text relocations
      (this was just a warning in the L release). This makes "-shared"
      necessary as well when building executables for Android.
      
      Change-Id: Id8802de5be98ff472fc370f8d22ffbde316aaf1e
      Reviewed-on: https://go-review.googlesource.com/16744Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      f7c7ed7c
    • Austin Clements's avatar
      runtime: handle sysReserve returning a pointer below the arena · 0de59c27
      Austin Clements authored
      In mheap.sysAlloc, if an allocation at arena_used would exceed
      arena_end (but wouldn't yet push us past arena_start+_MaxArean32), it
      trie to extend the arena reservation by another 256 MB. It extends the
      arena by calling sysReserve, which, on 32-bit, calls mmap without
      MAP_FIXED, which means the address is just a hint and the kernel can
      put the mapping wherever it wants. In particular, mmap may choose an
      address below arena_start (the kernel also chose arena_start, so there
      could be lots of space below it). Currently, we don't detect this case
      and, if it happens, mheap.sysAlloc will corrupt arena_end and
      arena_used then return the low pointer to mheap.grow, which will crash
      when it attempts to index in to h_spans with an underflowed index.
      
      Fix this by checking not only that that p+p_size isn't too high, but
      that p isn't too low.
      
      Fixes #13143.
      
      Change-Id: I8d0f42bd1484460282a83c6f1a6f8f0df7fb2048
      Reviewed-on: https://go-review.googlesource.com/16927
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      0de59c27
    • Austin Clements's avatar
      runtime: avoid stat underflow crash · 97dc5915
      Austin Clements authored
      If the area returned by sysReserve in mheap.sysAlloc is outside the
      usable arena, we sysFree it. We pass a fake stat pointer to sysFree
      because we haven't added the allocation to any stat at that point.
      However, we pass a 0 stat, so sysFree panics when it decrements the
      stat because the fake stat underflows.
      
      Fix this by setting the fake stat to the allocation size.
      
      Updates #13143 (this is a prerequisite to fixing that bug).
      
      Change-Id: I61a6c9be19ac1c95863cf6a8435e19790c8bfc9a
      Reviewed-on: https://go-review.googlesource.com/16926Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      97dc5915
    • Marcel van Lohuizen's avatar
      unicode/utf8: removed uses of ranging over string · 9b299c1e
      Marcel van Lohuizen authored
      Ranging over string is much slower than using DecodeRuneInString.
      See golang.org/issue/13162.
      
      Replacing ranging over a string with the implementation of the Bytes
      counterpart results in the following performance improvements:
      
      RuneCountInStringTenASCIIChars-8     43.0ns ± 1%  16.4ns ± 2%  -61.80%  (p=0.000 n=7+8)
      RuneCountInStringTenJapaneseChars-8   161ns ± 2%   154ns ± 2%   -4.58%  (p=0.000 n=8+8)
      ValidStringTenASCIIChars-8           52.2ns ± 1%  13.2ns ± 1%  -74.62%  (p=0.001 n=7+7)
      ValidStringTenJapaneseChars-8         173ns ± 2%   153ns ± 2%  -11.78%  (p=0.000 n=7+8)
      
      Update golang/go#13162
      
      Change-Id: Ifc40a6a94bb3317f1f2d929d310bd2694645e9f6
      Reviewed-on: https://go-review.googlesource.com/16695Reviewed-by: default avatarRuss Cox <rsc@golang.org>
      9b299c1e
  2. 15 Nov, 2015 7 commits
  3. 14 Nov, 2015 12 commits
  4. 13 Nov, 2015 7 commits
    • Matthew Dempsky's avatar
      runtime: remove zgoarch_*.go files · 06eb504c
      Matthew Dempsky authored
      These now live in runtime/internal/sys.
      
      Change-Id: I270597142516512bfc1395419e51d8083ba1663f
      Reviewed-on: https://go-review.googlesource.com/16891
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      06eb504c
    • Marcel van Lohuizen's avatar
      net/rpc: verify that embedding works with changed semantics · b4c9ec8b
      Marcel van Lohuizen authored
      Exported methods of unexported embedded structs get added
      correctly to the pool. Behavior is unchanged before and after
      https://golang.org/cl/14085.
      
      Change-Id: I2b4053bab02ff045f0a4577b8114808a60aae27e
      Reviewed-on: https://go-review.googlesource.com/16305Reviewed-by: default avatarRuss Cox <rsc@golang.org>
      b4c9ec8b
    • Brad Fitzpatrick's avatar
      A+C: add Steve Newman (Google CLA) · f762d0d2
      Brad Fitzpatrick authored
      Steve Newman (Google CLA) was missing from the CONTRIBUTORS file,
      presumably because his old commits (made prior to Go being open
      source) in SVN/perforce were imported into hg/git later as
      "devnull@localhost", which probably didn't match anything, and we
      didn't start tracking CLA contributions prior to the Go
      open source release.
      
      As a fun historical note, the initial HTTP client from Steve:
      https://github.com/golang/go/commit/f315fb3
      
      Change-Id: I2b8da4564d99820504788ecc41495a62391078d5
      Reviewed-on: https://go-review.googlesource.com/16864Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      f762d0d2
    • Robert Griesemer's avatar
      cmd/compile/internal/gc: recursive-descent parser · b569b87c
      Robert Griesemer authored
      This is a translation of the yacc-based parser with adjustements
      to make the grammar work for a recursive-descent parser followed
      by cleanups and simplifications.
      
      The yacc actions were mostly literally copied for correctness
      with better temporary names.
      
      A few of the syntax tests were adjusted for slightly different
      error messages (it is very difficult to match the yacc-based
      error messages in all cases, and sometimes the new parser could
      produce better errors).
      
      The new parser is enabled by default.
      To switch back to the yacc-based parser, set -oldparser.
      To hardwire the switch back, uncomment "oldparser = 1" in lex.go.
      
      - passes all.bash
      - ~18% reduced parse time per file on average for make.bash
      - ~3% reduced compile time for building cmd/compile
      
      Change-Id: Icb5651bb9d8b9f66261762d2c94a03793050d4ce
      Reviewed-on: https://go-review.googlesource.com/16665
      Run-TryBot: Robert Griesemer <gri@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarRuss Cox <rsc@golang.org>
      b569b87c
    • Ian Lance Taylor's avatar
      cmd/go: fix build -n when adding to archive with gc toolchain · b5c1b5d7
      Ian Lance Taylor authored
      Fix the output of build -n when adding to an existing archive with the
      gc toolchain by observing that we are, now, always doing that.  When
      using the gc toolchain the archive is now always created by the Go
      compiler, and never by the pack command.
      
      No test because we have not historically tested build -n output.
      
      Fixes #13118.
      
      Change-Id: I3a5c43cf45169fa6c9581e4741309c77d2b6e58b
      Reviewed-on: https://go-review.googlesource.com/16761Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
      Reviewed-by: default avatarDavid Crawshaw <crawshaw@golang.org>
      b5c1b5d7
    • Brad Fitzpatrick's avatar
      A+C: automated updates · 51fed716
      Brad Fitzpatrick authored
      Add Alberto Bertogli (individual CLA)
      Add Alexander Demakin (individual CLA)
      Add Angelo Bulfone (individual CLA)
      Add Anthony Canino (individual CLA)
      Add Arnout Engelen (individual CLA)
      Add Cedric Staub (corporate CLA for Square, Inc.)
      Add Dan Caddigan (individual CLA)
      Add Dan Jacques (corporate CLA for Google Inc.)
      Add Daniel Skinner (individual CLA)
      Add David Howden (individual CLA)
      Add Dmitry Yakunin (individual CLA)
      Add Emmanuel Odeke (individual CLA)
      Add Eric Koleda (corporate CLA for Google Inc.)
      Add Erik Dubbelboer (individual CLA)
      Add Evan Broder (corporate CLA for Stripe, Inc.)
      Add Ford Hurley (individual CLA)
      Add Francisco Claude (individual CLA)
      Add Gaurish Sharma (individual CLA)
      Add Hsin-Ho Yeh (individual CLA)
      Add Ian Gudger (individual CLA)
      Add Ilya Tocar (corporate CLA for Intel Corporation)
      Add John Jenkins (individual CLA)
      Add Kenny Grant (individual CLA)
      Add Kevin Malachowski (corporate CLA for Google Inc.)
      Add Kim Shrier (corporate CLA for RackTop Systems Inc.)
      Add Klaus Post (individual CLA)
      Add Lewin Bormann (individual CLA)
      Add Manu S Ajith (individual CLA)
      Add Matt Drollette (individual CLA)
      Add Meng Zhuo (individual CLA)
      Add Mhd Sulhan (individual CLA)
      Add Mohit Agarwal (individual CLA)
      Add Nathan Otterness (individual CLA)
      Add Nathan VanBenschoten (individual CLA)
      Add Paul Hankin (corporate CLA for Google Inc.)
      Add Paul Meyer (individual CLA)
      Add Pavel Paulau (individual CLA)
      Add Ralph Corderoy (individual CLA)
      Add Rob Norman (individual CLA)
      Add Seth Hoenig (individual CLA)
      Add Spencer Nelson (individual CLA)
      Add Steve Phillips (individual CLA)
      Add Thorben Krueger (individual CLA)
      Add Tormod Erevik Lea (individual CLA)
      Add Will Chan (corporate CLA for Google Inc.)
      Add Yao Zhang (individual CLA)
      Add Yasuharu Goto (individual CLA)
      Add Yuki Yugui Sonoda (corporate CLA for Google Inc.)
      
      Updates #12042
      
      Change-Id: Ia5f8e184fdbe8b135b2c29bb75f20bf72042abae
      Reviewed-on: https://go-review.googlesource.com/16825Reviewed-by: default avatarRuss Cox <rsc@golang.org>
      51fed716
    • David Crawshaw's avatar
      Revert "cmd/internal/obj/arm64, cmd/link: use two instructions rather than... · 9958a7b5
      David Crawshaw authored
      Revert "cmd/internal/obj/arm64, cmd/link: use two instructions rather than three for loads from memory"
      
      This reverts commit 3a9bc571.
      
      Breaks darwin/arm64.
      
      Change-Id: Ib958beacabca48020a6a47332fbdec99d994060b
      Reviewed-on: https://go-review.googlesource.com/16906Reviewed-by: default avatarMichael Hudson-Doyle <michael.hudson@canonical.com>
      9958a7b5