1. 24 Jun, 2016 1 commit
    • David Crawshaw's avatar
      reflect: avoid lock for some NumMethod()==0 cases · 3c6ed76d
      David Crawshaw authored
      The encoding/json package uses NumMethod()==0 as a fast check for
      interface satisfaction. In the case when a type has no methods at
      all, we don't need to grab the RWMutex.
      
      Improves JSON decoding benchmark on linux/amd64:
      
      	name           old time/op    new time/op    delta
      	CodeDecoder-8    44.2ms ± 2%    40.6ms ± 1%  -8.11%  (p=0.000 n=10+10)
      
      	name           old speed      new speed      delta
      	CodeDecoder-8  43.9MB/s ± 2%  47.8MB/s ± 1%  +8.82%  (p=0.000 n=10+10)
      
      For #16117
      
      Change-Id: Id717e7fcd2f41b7d51d50c26ac167af45bae3747
      Reviewed-on: https://go-review.googlesource.com/24433
      
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: David Crawshaw <crawshaw@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      3c6ed76d
  2. 23 Jun, 2016 2 commits
  3. 14 Jun, 2016 1 commit
  4. 03 Jun, 2016 1 commit
  5. 02 Jun, 2016 1 commit
  6. 25 May, 2016 1 commit
  7. 20 May, 2016 1 commit
  8. 17 May, 2016 1 commit
  9. 13 May, 2016 1 commit
  10. 12 May, 2016 1 commit
  11. 10 May, 2016 1 commit
  12. 27 Apr, 2016 2 commits
  13. 22 Apr, 2016 2 commits
  14. 18 Apr, 2016 1 commit
  15. 15 Apr, 2016 1 commit
  16. 13 Apr, 2016 2 commits
    • David Crawshaw's avatar
      cmd/compile, etc: use name for type pkgPath · f120936d
      David Crawshaw authored
      By replacing the *string used to represent pkgPath with a
      reflect.name everywhere, the embedded *string for package paths
      inside the reflect.name can be replaced by an offset, nameOff.
      This reduces the number of pointers in the type information.
      
      This also moves all reflect.name types into the same section, making
      it possible to use nameOff more widely in later CLs.
      
      No significant binary size change for normal binaries, but:
      
      linux/amd64 PIE:
      	cmd/go: -440KB (3.7%)
      	jujud:  -2.6MB (3.2%)
      
      For #6853.
      
      Change-Id: I3890b132a784a1090b1b72b32febfe0bea77eaee
      Reviewed-on: https://go-review.googlesource.com/21395
      
      
      Run-TryBot: David Crawshaw <crawshaw@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      f120936d
    • David Crawshaw's avatar
      cmd/compile, etc: store method tables as offsets · 7d469179
      David Crawshaw authored
      This CL introduces the typeOff type and a lookup method of the same
      name that can turn a typeOff offset into an *rtype.
      
      In a typical Go binary (built with buildmode=exe, pie, c-archive, or
      c-shared), there is one moduledata and all typeOff values are offsets
      relative to firstmoduledata.types. This makes computing the pointer
      cheap in typical programs.
      
      With buildmode=shared (and one day, buildmode=plugin) there are
      multiple modules whose relative offset is determined at runtime.
      We identify a type in the general case by the pair of the original
      *rtype that references it and its typeOff value. We determine
      the module from the original pointer, and then use the typeOff from
      there to compute the final *rtype.
      
      To ensure there is only one *rtype representing each type, the
      runtime initializes a typemap for each module, using any identical
      type from an earlier module when resolving that offset. This means
      that types computed from an offset match the type mapped by the
      pointer dynamic relocations.
      
      A series of followup CLs will replace other *rtype values with typeOff
      (and name/*string with nameOff).
      
      For types created at runtime by reflect, type offsets are treated as
      global IDs and reference into a reflect offset map kept by the runtime.
      
      darwin/amd64:
      	cmd/go:  -57KB (0.6%)
      	jujud:  -557KB (0.8%)
      
      linux/amd64 PIE:
      	cmd/go: -361KB (3.0%)
      	jujud:  -3.5MB (4.2%)
      
      For #6853.
      
      Change-Id: Icf096fd884a0a0cb9f280f46f7a26c70a9006c96
      Reviewed-on: https://go-review.googlesource.com/21285
      
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: David Crawshaw <crawshaw@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      7d469179
  17. 12 Apr, 2016 1 commit
    • David Crawshaw's avatar
      cmd/link, etc: store typelinks as offsets · f028b9f9
      David Crawshaw authored
      This is the first in a series of CLs to replace the use of pointers
      in binary read-only data with offsets.
      
      In standard Go binaries these CLs have a small effect, shrinking
      8-byte pointers to 4-bytes. In position-independent code, it also
      saves the dynamic relocation for the pointer. This has a significant
      effect on the binary size when building as PIE, c-archive, or
      c-shared.
      
      darwin/amd64:
      	cmd/go: -12KB (0.1%)
      	jujud:  -82KB (0.1%)
      
      linux/amd64 PIE:
      	cmd/go:  -86KB (0.7%)
      	jujud:  -569KB (0.7%)
      
      For #6853.
      
      Change-Id: Iad5625bbeba58dabfd4d334dbee3fcbfe04b2dcf
      Reviewed-on: https://go-review.googlesource.com/21284
      
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: David Crawshaw <crawshaw@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      f028b9f9
  18. 01 Apr, 2016 1 commit
    • Sebastien Binet's avatar
      reflect: implement StructOf · 633ab742
      Sebastien Binet authored
      This change exposes a facility to create new struct types from a slice of
      reflect.StructFields.
      
      - reflect: first stab at implementing StructOf
      - reflect: tests for StructOf
      
      StructOf creates new struct types in the form of structTypeWithMethods
      to accomodate the GC (especially the uncommonType.methods slice field.)
      
      Creating struct types with embedded interfaces with unexported methods
      is not supported yet and will panic.
      Creating struct types with non-ASCII field names or types is not yet
      supported (see #15064.)
      
      Binaries' sizes for linux_amd64:
      
      old=tip (0104a31b)
      
                  old bytes     new bytes     delta
      bin/go      9911336       9915456       +0.04%
      reflect     781704        830048        +6.18%
      
      Updates #5748.
      Updates #15064.
      
      Change-Id: I3b8fd4fadd6ce3b1b922e284f0ae72a3a8e3ce44
      Reviewed-on: https://go-review.googlesource.com/9251
      
      Reviewed-by: default avatarDavid Crawshaw <crawshaw@golang.org>
      Run-TryBot: David Crawshaw <crawshaw@golang.org>
      633ab742
  19. 25 Mar, 2016 2 commits
    • John Jeffery's avatar
      reflect: add method StructTag.Lookup · 5c8674a4
      John Jeffery authored
      The Lookup method provides a way to extract a tag value, while
      determining whether the tag key exists in the struct field's tag.
      
      Fixes #14883
      
      Change-Id: I7460cb68f0ca1aaa025935050b9e182efcb64db3
      Reviewed-on: https://go-review.googlesource.com/20864
      
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      5c8674a4
    • David Crawshaw's avatar
      cmd/compile, runtime: new static name encoding · 24ce64d1
      David Crawshaw authored
      Create a byte encoding designed for static Go names.
      
      It is intended to be a compact representation of a name
      and optional tag data that can be turned into a Go string
      without allocating, and describes whether or not it is
      exported without unicode table.
      
      The encoding is described in reflect/type.go:
      
      // The first byte is a bit field containing:
      //
      //	1<<0 the name is exported
      //	1<<1 tag data follows the name
      //	1<<2 pkgPath *string follow the name and tag
      //
      // The next two bytes are the data length:
      //
      //	 l := uint16(data[1])<<8 | uint16(data[2])
      //
      // Bytes [3:3+l] are the string data.
      //
      // If tag data follows then bytes 3+l and 3+l+1 are the tag length,
      // with the data following.
      //
      // If the import path follows, then ptrSize bytes at the end of
      // the data form a *string. The import path is only set for concrete
      // methods that are defined in a different package than their type.
      
      Shrinks binary sizes:
      
      	cmd/go: 164KB (1.6%)
      	jujud:  1.0MB (1.5%)
      
      For #6853.
      
      Change-Id: I46b6591015b17936a443c9efb5009de8dfe8b609
      Reviewed-on: https://go-review.googlesource.com/20968
      
      
      Run-TryBot: David Crawshaw <crawshaw@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      24ce64d1
  20. 23 Mar, 2016 1 commit
  21. 15 Mar, 2016 1 commit
    • David Crawshaw's avatar
      cmd/compile: compute second method type at runtime · f2772a49
      David Crawshaw authored
      The type information for a method includes two variants: a func
      without the receiver, and a func with the receiver as the first
      parameter. The former is used as part of the dynamic interface
      checks, but the latter is only returned as a type in the
      reflect.Method struct.
      
      Instead of computing it at compile time, construct it at run time
      with reflect.FuncOf.
      
      Using cl/20701 as a baseline,
      
      	cmd/go: -480KB, (4.4%)
      	jujud:  -5.6MB, (7.8%)
      
      For #6853.
      
      Change-Id: I1b8c73f3ab894735f53d00cb9c0b506d84d54e92
      Reviewed-on: https://go-review.googlesource.com/20709
      
      
      Run-TryBot: David Crawshaw <crawshaw@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      f2772a49
  22. 09 Mar, 2016 1 commit
    • David Crawshaw's avatar
      cmd/compile: remove slices from rtype.funcType · 8df733bd
      David Crawshaw authored
      Alternative to golang.org/cl/19852. This memory layout doesn't have
      an easy type representation, but it is noticeably smaller than the
      current funcType, and saves significant extra space.
      
      Some notes on the layout are in reflect/type.go:
      
      // A *rtype for each in and out parameter is stored in an array that
      // directly follows the funcType (and possibly its uncommonType). So
      // a function type with one method, one input, and one output is:
      //
      //	struct {
      //		funcType
      //		uncommonType
      //		[2]*rtype    // [0] is in, [1] is out
      //		uncommonTypeSliceContents
      //	}
      
      There are three arbitrary limits introduced by this CL:
      
      1. No more than 65535 function input parameters.
      2. No more than 32767 function output parameters.
      3. reflect.FuncOf is limited to 128 parameters.
      
      I don't think these are limits in practice, but are worth noting.
      
      Reduces godoc binary size by 2.4%, 330KB.
      
      For #6853.
      
      Change-Id: I225c0a0516ebdbe92d41dfdf43f716da42dfe347
      Reviewed-on: https://go-review.googlesource.com/19916
      
      Reviewed-by: default avatarRuss Cox <rsc@golang.org>
      Run-TryBot: David Crawshaw <crawshaw@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      8df733bd
  23. 08 Mar, 2016 1 commit
    • David Crawshaw's avatar
      cmd/compile: remove rtype *uncommonType field · a24b3ed7
      David Crawshaw authored
      Instead of a pointer on every rtype, use a bit flag to indicate that
      the contents of uncommonType directly follows the rtype value when it
      is needed.
      
      This requires a bit of juggling in the compiler's rtype encoder. The
      backing arrays for fields in the rtype are presently encoded directly
      after the slice header. This packing requires separating the encoding
      of the uncommonType slice headers from their backing arrays.
      
      Reduces binary size of godoc by ~180KB (1.5%).
      No measurable change in all.bash time.
      For #6853.
      
      Change-Id: I60205948ceb5c0abba76fdf619652da9c465a597
      Reviewed-on: https://go-review.googlesource.com/19790
      
      Reviewed-by: default avatarRuss Cox <rsc@golang.org>
      Run-TryBot: David Crawshaw <crawshaw@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      a24b3ed7
  24. 04 Mar, 2016 1 commit
  25. 02 Mar, 2016 1 commit
    • Brad Fitzpatrick's avatar
      all: single space after period. · 5fea2ccc
      Brad Fitzpatrick authored
      The tree's pretty inconsistent about single space vs double space
      after a period in documentation. Make it consistently a single space,
      per earlier decisions. This means contributors won't be confused by
      misleading precedence.
      
      This CL doesn't use go/doc to parse. It only addresses // comments.
      It was generated with:
      
      $ perl -i -npe 's,^(\s*// .+[a-z]\.)  +([A-Z]),$1 $2,' $(git grep -l -E '^\s*//(.+\.)  +([A-Z])')
      $ go test go/doc -update
      
      Change-Id: Iccdb99c37c797ef1f804a94b22ba5ee4b500c4f7
      Reviewed-on: https://go-review.googlesource.com/20022
      
      Reviewed-by: default avatarRob Pike <r@golang.org>
      Reviewed-by: default avatarDave Day <djd@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      5fea2ccc
  26. 26 Feb, 2016 1 commit
  27. 25 Feb, 2016 1 commit
    • David Crawshaw's avatar
      cmd/compile: remove rtype.ptrToThis · 30f93f09
      David Crawshaw authored
      Simplifies some code as ptrToThis was unreliable under dynamic
      linking. Now the same type lookup is used regardless of execution
      mode.
      
      A synthetic relocation, R_USETYPE, is introduced to make sure the
      linker includes *T on use of T, if *T is carrying methods.
      
      Changes the heap dump format. Anything reading the format needs to
      look at the last bool of a type of an interface value to determine
      if the type should be the pointer-to type.
      
      Reduces binary size of cmd/go by 0.2%.
      For #6853.
      
      Change-Id: I79fcb19a97402bdb0193f3c7f6d94ddf061ee7b2
      Reviewed-on: https://go-review.googlesource.com/19695
      
      Reviewed-by: default avatarKeith Randall <khr@golang.org>
      Run-TryBot: David Crawshaw <crawshaw@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      30f93f09
  28. 24 Feb, 2016 1 commit
  29. 23 Feb, 2016 1 commit
  30. 22 Feb, 2016 1 commit
  31. 27 Oct, 2015 1 commit
  32. 26 Oct, 2015 1 commit
  33. 09 Sep, 2015 1 commit
  34. 26 Aug, 2015 2 commits