1. 18 Sep, 2019 18 commits
  2. 17 Sep, 2019 12 commits
  3. 16 Sep, 2019 10 commits
    • Matthew Dempsky's avatar
      cmd/compile: major refactoring of switch walking · 8f3d9855
      Matthew Dempsky authored
      There are a lot of complexities to handling switches efficiently:
      
      1. Order matters for expression switches with non-constant cases and
      for type expressions with interface types. We have to respect
      side-effects, and we also can't allow later cases to accidentally take
      precedence over earlier cases.
      
      2. For runs of integers, floats, and string constants in expression
      switches or runs of concrete types in type switches, we want to emit
      efficient binary searches.
      
      3. For runs of consecutive integers in expression switches, we want to
      collapse them into range comparisons.
      
      4. For binary searches of strings, we want to compare by length first,
      because that's more efficient and we don't need to respect any
      particular ordering.
      
      5. For "switch true { ... }" and "switch false { ... }", we want to
      optimize "case x:" as simply "if x" or "if !x", respectively, unless x
      is interface-typed.
      
      The current swt.go code reflects how these constraints have been
      incrementally added over time, with each of them being handled ad
      hocly in different parts of the code. Also, the existing code tries
      very hard to reuse logic between expression and type switches, even
      though the similarities are very superficial.
      
      This CL rewrites switch handling to better abstract away the logic
      involved in constructing the binary searches. In particular, it's
      intended to make further optimizations to switch dispatch much easier.
      
      It also eliminates the need for both OXCASE and OCASE ops, and a
      subsequent CL can collapse the two.
      
      Passes toolstash-check.
      
      Change-Id: Ifcd1e56f81f858117a412971d82e98abe7c4481f
      Reviewed-on: https://go-review.googlesource.com/c/go/+/194660
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarKeith Randall <khr@golang.org>
      8f3d9855
    • Matthew Dempsky's avatar
      test: add test coverage for type-switch hash collisions · 115e4c9c
      Matthew Dempsky authored
      This CL expands the test for #29612 to check that type switches also
      work correctly when type hashes collide.
      
      Change-Id: Ia153743e6ea0736c1a33191acfe4d8ba890be527
      Reviewed-on: https://go-review.googlesource.com/c/go/+/195782
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      Reviewed-by: default avatarKeith Randall <khr@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      115e4c9c
    • Lucas Bremgartner's avatar
      encoding/json: validate strings when decoding into Number · c1000c50
      Lucas Bremgartner authored
      Unmarshaling a string into a json.Number should first check that the string is a valid Number.
      If not, we should fail without decoding it.
      
      Fixes #14702
      
      Change-Id: I286178e93df74ad63c0a852c3f3489577072cf47
      GitHub-Last-Rev: fe69bb68eed06d056639f440d2daf4bb7c99013b
      GitHub-Pull-Request: golang/go#34272
      Reviewed-on: https://go-review.googlesource.com/c/go/+/195045Reviewed-by: default avatarDaniel Martí <mvdan@mvdan.cc>
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      c1000c50
    • Daniel Martí's avatar
      cmd/compiler: skip some go/printer work in rulegen · 0e0bff84
      Daniel Martí authored
      We use go/format on the final output, so don't bother with the added
      tabwriter work to align comments when using go/printer.
      
      	name     old time/op         new time/op         delta
      	Rulegen          2.53s ± 2%          2.48s ± 1%  -2.20%  (p=0.032 n=5+5)
      
      	name     old user-time/op    new user-time/op    delta
      	Rulegen          11.2s ± 1%          10.8s ± 0%  -3.72%  (p=0.008 n=5+5)
      
      	name     old sys-time/op     new sys-time/op     delta
      	Rulegen          218ms ±17%          207ms ±19%    ~     (p=0.548 n=5+5)
      
      	name     old peak-RSS-bytes  new peak-RSS-bytes  delta
      	Rulegen          184MB ± 3%          175MB ± 4%    ~     (p=0.056 n=5+5)
      
      Change-Id: I53bad2ab15cace67415f2171fffcd13ed596e62b
      Reviewed-on: https://go-review.googlesource.com/c/go/+/195219
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      0e0bff84
    • Daniel Martí's avatar
      cmd/compile: parallelize another big chunk of rulegen · 357e8f83
      Daniel Martí authored
      rulegen has a sanity check that ensures all the arch-specific opcodes
      are handled by each of the gen files.
      
      This is an expensive chunk of work, particularly since there are a lot
      of opcodes in total, and each one of them compiles and runs a regular
      expression.
      
      Parallelize that for each architecture, which greatly speeds up 'go run
      *.go' on my laptop with four real CPU cores.
      
      	name     old time/op         new time/op         delta
      	Rulegen          3.39s ± 1%          2.53s ± 2%  -25.34%  (p=0.008 n=5+5)
      
      	name     old user-time/op    new user-time/op    delta
      	Rulegen          10.6s ± 1%          11.2s ± 1%   +6.09%  (p=0.008 n=5+5)
      
      	name     old sys-time/op     new sys-time/op     delta
      	Rulegen          201ms ± 7%          218ms ±17%     ~     (p=0.548 n=5+5)
      
      	name     old peak-RSS-bytes  new peak-RSS-bytes  delta
      	Rulegen          182MB ± 3%          184MB ± 3%     ~     (p=0.690 n=5+5)
      
      Change-Id: Iec538ed0fa7eb867eeeeaab3da1e2615ce32cbb9
      Reviewed-on: https://go-review.googlesource.com/c/go/+/195218
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarKeith Randall <khr@golang.org>
      357e8f83
    • Jay Conrod's avatar
      cmd/go: don't split internal test main packages twice · 4d18a7ce
      Jay Conrod authored
      Fixes #34321
      
      Change-Id: Ia6253038c525089e20a1da64a2c5c9dcc57edd74
      Reviewed-on: https://go-review.googlesource.com/c/go/+/195677
      Run-TryBot: Jay Conrod <jayconrod@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBryan C. Mills <bcmills@google.com>
      4d18a7ce
    • Matthew Dempsky's avatar
      cmd/compile: require -lang=go1.14 for overlapping interfaces · 7f907b9c
      Matthew Dempsky authored
      Support for overlapping interfaces is a new (proposed) Go language
      feature to be supported in Go 1.14, so it shouldn't be supported under
      -lang=go1.13 or earlier.
      
      Fixes #34329.
      
      Change-Id: I5fea5716b7d135476980bc40b4f6e8c611b67735
      Reviewed-on: https://go-review.googlesource.com/c/go/+/195678
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
      7f907b9c
    • Alberto Donizetti's avatar
      Revert "test/codegen: document -all_codegen option in README" · c2facbe9
      Alberto Donizetti authored
      This reverts CL 192101.
      
      Reason for revert: The same paragraph was added 2 weeks ago
      (look a few lines above)
      
      Change-Id: I05efb2631d7b4966f66493f178f2a649c715a3cc
      Reviewed-on: https://go-review.googlesource.com/c/go/+/195637Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
      c2facbe9
    • Jay Conrod's avatar
      cmd/go: don't include package dir in cache key when -trimpath is set · aa680c0c
      Jay Conrod authored
      The '-trimpath' flag tells 'go build' to trim any paths from the
      output files that are tied to the current workspace or toolchain. When
      this flag is set, we do not need to include the package directory in
      the text hashed to construct the action ID for each package.
      
      Fixes #33772
      
      Change-Id: I20b902d2f58019709b15864ca79aa0d9255ae707
      Reviewed-on: https://go-review.googlesource.com/c/go/+/195318
      Run-TryBot: Jay Conrod <jayconrod@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBryan C. Mills <bcmills@google.com>
      aa680c0c
    • Matthew Dempsky's avatar
      cmd/compile: trim function name prefix from escape diagnostics · 606019cb
      Matthew Dempsky authored
      This information is redundant with the position information already
      provided. Also, no other -m diagnostics print out function name.
      
      While here, report parameter leak diagnostics against the parameter
      declaration position rather than the function, and use Warnl for
      "moved to heap" messages.
      
      Test cases updated programmatically by removing the first word from
      every "no match for" error emitted by run.go:
      
      go run run.go |& \
        sed -E -n 's/^(.*):(.*): no match for `([^ ]* (.*))` in:$/\1!\2!\3!\4/p' | \
        while IFS='!' read -r fn line before after; do
          before=$(echo "$before" | sed 's/[.[\*^$()+?{|]/\\&/g')
          after=$(echo "$after" | sed -E 's/(\&|\\)/\\&/g')
          fn=$(find . -name "${fn}" | head -1)
          sed -i -E -e "${line}s/\"${before}\"/\"${after}\"/" "${fn}"
        done
      
      Passes toolstash-check.
      
      Change-Id: I6e02486b1409e4a8dbb2b9b816d22095835426b5
      Reviewed-on: https://go-review.googlesource.com/c/go/+/195040
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
      606019cb