1. 24 Oct, 2019 9 commits
    • Bryan C. Mills's avatar
      cmd/go: populate available module information for packages in vendor mode · b36f22bf
      Bryan C. Mills authored
      Updates #33848
      
      Change-Id: I10b4c79faef8bc3dee2ceba14d496fa049e84fb2
      Reviewed-on: https://go-review.googlesource.com/c/go/+/202977
      Run-TryBot: Bryan C. Mills <bcmills@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarJay Conrod <jayconrod@google.com>
      b36f22bf
    • Cuong Manh Le's avatar
      syscall: correct comment in testGetdirentries · 05ee5065
      Cuong Manh Le authored
      Correct comment about allocating big enough slice to copy result of
      Getdirentries.
      
      While at it, also convert from Dirent directly to slice of byte.
      
      Updates #35092
      
      Change-Id: I892de7953120622882e1561728e1e56b009a2351
      Reviewed-on: https://go-review.googlesource.com/c/go/+/202880
      Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      05ee5065
    • Dan Scales's avatar
      cmd/compile, cmd/link, runtime: make defers low-cost through inline code and extra funcdata · be64a19d
      Dan Scales authored
      Generate inline code at defer time to save the args of defer calls to unique
      (autotmp) stack slots, and generate inline code at exit time to check which defer
      calls were made and make the associated function/method/interface calls. We
      remember that a particular defer statement was reached by storing in the deferBits
      variable (always stored on the stack). At exit time, we check the bits of the
      deferBits variable to determine which defer function calls to make (in reverse
      order). These low-cost defers are only used for functions where no defers
      appear in loops. In addition, we don't do these low-cost defers if there are too
      many defer statements or too many exits in a function (to limit code increase).
      
      When a function uses open-coded defers, we produce extra
      FUNCDATA_OpenCodedDeferInfo information that specifies the number of defers, and
      for each defer, the stack slots where the closure and associated args have been
      stored. The funcdata also includes the location of the deferBits variable.
      Therefore, for panics, we can use this funcdata to determine exactly which defers
      are active, and call the appropriate functions/methods/closures with the correct
      arguments for each active defer.
      
      In order to unwind the stack correctly after a recover(), we need to add an extra
      code segment to functions with open-coded defers that simply calls deferreturn()
      and returns. This segment is not reachable by the normal function, but is returned
      to by the runtime during recovery. We set the liveness information of this
      deferreturn() to be the same as the liveness at the first function call during the
      last defer exit code (so all return values and all stack slots needed by the defer
      calls will be live).
      
      I needed to increase the stackguard constant from 880 to 896, because of a small
      amount of new code in deferreturn().
      
      The -N flag disables open-coded defers. '-d defer' prints out the kind of defer
      being used at each defer statement (heap-allocated, stack-allocated, or
      open-coded).
      
      Cost of defer statement  [ go test -run NONE -bench BenchmarkDefer$ runtime ]
        With normal (stack-allocated) defers only:         35.4  ns/op
        With open-coded defers:                             5.6  ns/op
        Cost of function call alone (remove defer keyword): 4.4  ns/op
      
      Text size increase (including funcdata) for go binary without/with open-coded defers:  0.09%
      
      The average size increase (including funcdata) for only the functions that use
      open-coded defers is 1.1%.
      
      The cost of a panic followed by a recover got noticeably slower, since panic
      processing now requires a scan of the stack for open-coded defer frames. This scan
      is required, even if no frames are using open-coded defers:
      
      Cost of panic and recover [ go test -run NONE -bench BenchmarkPanicRecover runtime ]
        Without open-coded defers:        62.0 ns/op
        With open-coded defers:           255  ns/op
      
      A CGO Go-to-C-to-Go benchmark got noticeably faster because of open-coded defers:
      
      CGO Go-to-C-to-Go benchmark [cd misc/cgo/test; go test -run NONE -bench BenchmarkCGoCallback ]
        Without open-coded defers:        443 ns/op
        With open-coded defers:           347 ns/op
      
      Updates #14939 (defer performance)
      Updates #34481 (design doc)
      
      Change-Id: I63b1a60d1ebf28126f55ee9fd7ecffe9cb23d1ff
      Reviewed-on: https://go-review.googlesource.com/c/go/+/202340Reviewed-by: default avatarAustin Clements <austin@google.com>
      be64a19d
    • Bryan C. Mills's avatar
      cmd/go/internal/list: ensure that cfg.BuildMod is initialized before reading it in 'go list -m' · dc77dc2b
      Bryan C. Mills authored
      The default value of cfg.BuildMod depends on the 'go' version in the
      go.mod file. The go.mod file is read and parsed, and its settings are
      applied, in modload.InitMod.
      
      As it turns out, modload.Enabled does not invoke InitMod, so
      cfg.BuildMod is not necessarily set even if modload.Enabled returns
      true.
      
      Updates #33848
      
      Change-Id: I13a4dd80730528e6f1a5acc492fcfe07cb59d94e
      Reviewed-on: https://go-review.googlesource.com/c/go/+/202917
      Run-TryBot: Bryan C. Mills <bcmills@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarJay Conrod <jayconrod@google.com>
      dc77dc2b
    • Cuong Manh Le's avatar
      syscall: remove un-used const ptrSize · a42a3968
      Cuong Manh Le authored
      Change-Id: Ic809a533f9c4042373bdad3ba1cd237d203bacff
      Reviewed-on: https://go-review.googlesource.com/c/go/+/202881Reviewed-by: default avatarTobias Klauser <tobias.klauser@gmail.com>
      Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
      Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      a42a3968
    • Cuong Manh Le's avatar
      syscall: make convertFromDirents11 checkptr safe · 722b0e32
      Cuong Manh Le authored
      Fixes #35092
      
      Change-Id: I8f1ee2b79d42b2291548fd5645940a61f6d67582
      Reviewed-on: https://go-review.googlesource.com/c/go/+/202878
      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>
      722b0e32
    • Brad Fitzpatrick's avatar
      syscall: make TestGetdirentries checkptr safe · 68981bf3
      Brad Fitzpatrick authored
      Fixes Darwin.
      
      Updates #35092
      
      Change-Id: I045f070c8549d00610b459e3a82cac870d9ddb54
      Reviewed-on: https://go-review.googlesource.com/c/go/+/203077
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      Reviewed-by: default avatarCuong Manh Le <cuong.manhle.vn@gmail.com>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      68981bf3
    • Robert Griesemer's avatar
      math/big: make Rat.Denom side-effect free · a52c0a19
      Robert Griesemer authored
      A Rat is represented via a quotient a/b where a and b are Int values.
      To make it possible to use an uninitialized Rat value (with a and b
      uninitialized and thus == 0), the implementation treats a 0 denominator
      as 1.
      
      Rat.Num and Rat.Denom return pointers to these values a and b. Because
      b may be 0, Rat.Denom used to first initialize it to 1 and thus produce
      an undesirable side-effect (by changing the Rat's denominator).
      
      This CL changes Denom to return a new (not shared) *Int with value 1
      in the rare case where the Rat was not initialized. This eliminates
      the side effect and returns the correct denominator value.
      
      While this is changing behavior of the API, the impact should now be
      minor because together with (prior) CL https://golang.org/cl/202997,
      which initializes Rats ASAP, Denom is unlikely used to access the
      denominator of an uninitialized (and thus 0) Rat. Any operation that
      will somehow set a Rat value will ensure that the denominator is not 0.
      
      Fixes #33792.
      Updates #3521.
      
      Change-Id: I0bf15ac60513cf52162bfb62440817ba36f0c3fc
      Reviewed-on: https://go-review.googlesource.com/c/go/+/203059
      Run-TryBot: Robert Griesemer <gri@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      a52c0a19
    • Robert Griesemer's avatar
      math/big: normalize unitialized denominators ASAP · 4412181e
      Robert Griesemer authored
      A Rat is represented via a quotient a/b where a and b are Int values.
      To make it possible to use an uninitialized Rat value (with a and b
      uninitialized and thus == 0), the implementation treats a 0 denominator
      as 1.
      
      For each operation we check if the denominator is 0, and then treat
      it as 1 (if necessary). Operations that create a new Rat result,
      normalize that value such that a result denominator 1 is represened
      as 0 again.
      
      This CL changes this behavior slightly: 0 denominators are still
      interpreted as 1, but whenever we (safely) can, we set an uninitialized
      0 denominator to 1. This simplifies the code overall.
      
      Also: Improved some doc strings.
      
      Preparation for addressing issue #33792.
      
      Updates #33792.
      
      Change-Id: I3040587c8d0dad2e840022f96ca027d8470878a0
      Reviewed-on: https://go-review.googlesource.com/c/go/+/202997
      Run-TryBot: Robert Griesemer <gri@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      4412181e
  2. 23 Oct, 2019 14 commits
  3. 22 Oct, 2019 17 commits