1. 18 Sep, 2019 22 commits
  2. 17 Sep, 2019 12 commits
  3. 16 Sep, 2019 6 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