1. 19 Sep, 2019 1 commit
  2. 18 Sep, 2019 24 commits
  3. 17 Sep, 2019 12 commits
  4. 16 Sep, 2019 3 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