1. 12 Sep, 2019 5 commits
    • Daniel Martí's avatar
      cmd/compile: stop using go/types in rulegen · 1581bb98
      Daniel Martí authored
      Using go/types to get rid of all unused variables in CL 189798 was a
      neat idea, but it was pretty expensive. go/types is a full typechecker,
      which does a lot more work than we actually need. Moreover, we had to
      run it multiple times, to catch variables that became unused after
      removing existing unused variables.
      
      Instead, write our own little detector for unused imports and variables.
      It doesn't use ast.Walk, as we need to know what fields we're
      inspecting. For example, in "foo := bar", "foo" is declared, and "bar"
      is used, yet they both appear as simple *ast.Ident cases under ast.Walk.
      
      The code is documented to explain how unused variables are detected in a
      single syntax tree pass. Since this happens after we've generated a
      complete go/ast.File, we don't need to worry about our own simplified
      node types.
      
      The generated code is the same, but rulegen is much faster and uses less
      memory at its peak, so it should scale better with time.
      
      With 'benchcmd Rulegen go run *.go' on perflock, we get:
      
      	name     old time/op         new time/op         delta
      	Rulegen          4.00s ± 0%          3.41s ± 1%  -14.70%  (p=0.008 n=5+5)
      
      	name     old user-time/op    new user-time/op    delta
      	Rulegen          14.1s ± 1%          10.6s ± 1%  -24.62%  (p=0.008 n=5+5)
      
      	name     old sys-time/op     new sys-time/op     delta
      	Rulegen          318ms ±26%          263ms ± 9%     ~     (p=0.056 n=5+5)
      
      	name     old peak-RSS-bytes  new peak-RSS-bytes  delta
      	Rulegen          231MB ± 4%          181MB ± 3%  -21.69%  (p=0.008 n=5+5)
      
      Change-Id: I8387d52818f6131357868ad348dac8c96d926191
      Reviewed-on: https://go-review.googlesource.com/c/go/+/191782
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarKeith Randall <khr@golang.org>
      1581bb98
    • Nigel Tao's avatar
      compress/lzw: fix comment re high-code invariant · 396d6253
      Nigel Tao authored
      The listed invariant, while technically true, was misleading, and the
      invariant can be tightened. We never actually get to (d.hi ==
      d.overflow), due to the "d.hi--" line in the decoder.decode method.
      
      This is a comment-only commit, changing the comment to match the code.
      
      A follow-up commit could restore the comment, changing the code to match
      the original intented invariant. But the first step is to have the
      comment and the code say the same thing.
      
      Change-Id: Ifc9f78d5060454fc107af9be298026bf3043d400
      Reviewed-on: https://go-review.googlesource.com/c/go/+/191358Reviewed-by: default avatarDaniel Martí <mvdan@mvdan.cc>
      Reviewed-by: default avatarBryan C. Mills <bcmills@google.com>
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      396d6253
    • Cuong Manh Le's avatar
      cmd/compile: generalize isfat to handle 1-field structs and 1-element arrays · 3f0437e1
      Cuong Manh Le authored
      After CL 192979, it is safe now to optimize isfat slightly to handle
      1-field structs and 1-element arrays.
      
      Change-Id: Ie3bc30299abbcef36eee7a0681997cc2f88ed6a3
      Reviewed-on: https://go-review.googlesource.com/c/go/+/192980
      Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
      3f0437e1
    • Cuong Manh Le's avatar
      cmd/compile: allow iota inside function in a ConstSpec · 55c0ad4b
      Cuong Manh Le authored
      Fixes #22344
      
      Change-Id: I7c400d9d4ebcab279d08a8c190508d82cbd20899
      Reviewed-on: https://go-review.googlesource.com/c/go/+/194717
      Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
      55c0ad4b
    • Cuong Manh Le's avatar
      go/types: fix iota undefined after ConstDecl inside function in ConstSpec · 88076ebc
      Cuong Manh Le authored
      When reaching const declaration, Checker override context iota to use
      correct iota value, but does not restore the old value when exit, and
      always set context iota to nil. It ends up with undefined iota after
      const declaration.
      
      To fix it, preserve the original iota value and restore it after const
      declaration.
      
      Fixes #34228
      
      Change-Id: I42d5efb55a57e5ddc369bb72d31f1f039c92361c
      Reviewed-on: https://go-review.googlesource.com/c/go/+/194737
      Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
      88076ebc
  2. 11 Sep, 2019 22 commits
  3. 10 Sep, 2019 13 commits