1. 22 Mar, 2017 23 commits
    • Kenny Grant's avatar
      net/http: improve speed of default mux · 1295b745
      Kenny Grant authored
      The DefaultServeMux included in net/http uses a map to store routes,
      but iterates all keys for every request to allow longer paths.
      
      This change checks the map for an exact match first.
      
      To check performance was better, BenchmarkServeMux has been added -
      this adds >100 routes and checks the matches.
      
      Exact matches are faster and more predictable on this benchmark
      and on most existing package benchmarks.
      
      https://perf.golang.org/search?q=upload:20170312.1
      
      ServeMux-4  2.02ms ± 2%	0.04ms ± 2%  −98.08%  (p=0.004 n=5+6)
      
      https://perf.golang.org/search?q=upload:20170312.2
      
      ReadRequestChrome-4	184MB/s  ± 8%	186MB/s  ± 1%	~
      ReadRequestCurl-4	45.0MB/s ± 1%	46.2MB/s ± 1%	+2.71%
      Read...Apachebench-4	45.8MB/s ±13%	48.7MB/s ± 1%	~
      ReadRequestSiege-4	63.6MB/s ± 5%	69.2MB/s ± 1%	+8.75%
      ReadRequestWrk-4	30.9MB/s ± 9%	34.4MB/s ± 2%	+11.25%
      
      Change-Id: I8afafcb956f07197419d545a9f1c03ecaa307384
      Reviewed-on: https://go-review.googlesource.com/38057Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      1295b745
    • Robert Griesemer's avatar
      cmd/compile/internal/syntax: replace inlined statement lists with syntax.BlockStmt · b5f81eae
      Robert Griesemer authored
      This simplifies the code and removes a premature optimization.
      It increases the amount of allocated syntax.Node space by ~0.4%
      for parsing all of std lib, which is negligible.
      
      Before the change (best of 5 runs):
      
        $ go test -run StdLib -fast
        parsed 1517022 lines (3394 files) in 793.487886ms (1911840 lines/s)
        allocated 387.086Mb (267B/line, 487.828Mb/s)
      
      After the change (best of 5 runs):
      
        $ go test -run StdLib -fast
        parsed 1516911 lines (3392 files) in 805.028655ms (1884294 lines/s)
        allocated 388.466Mb (268B/line, 482.549Mb/s)
      
      Change-Id: Id19d6210fdc62393862ba3b04913352d95c599be
      Reviewed-on: https://go-review.googlesource.com/38439
      Run-TryBot: Robert Griesemer <gri@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
      b5f81eae
    • Robert Griesemer's avatar
      cmd/compile/internal/syntax: add position info for { and } braces · e0329248
      Robert Griesemer authored
      This change adds position information for { and } braces in the
      source. There's a 1.9% increase in memory use for syntax.Nodes,
      which is negligible relative to overall compiler memory consumption.
      
      Parsing the std library (using syntax package only) and memory
      consumption before this change (fastest of 5 runs):
      
        $ go test -run StdLib -fast
        parsed 1516827 lines (3392 files) in 780.612335ms (1943124 lines/s)
        allocated 379.903Mb (486.673Mb/s)
      
      After this change (fastest of 5 runs):
      
        $ go test -run StdLib -fast
        parsed 1517022 lines (3394 files) in 793.487886ms (1911840 lines/s)
        allocated 387.086Mb (267B/line, 487.828Mb/s)
      
      While not an exact apples-to-apples comparison (the syntax package
      has changed and is also parsed), the overall impact is small.
      
      Also: Small improvements to nodes_test.go.
      
      Change-Id: Ib8a7f90bbe79de33d83684e33b1bf8dbc32e644a
      Reviewed-on: https://go-review.googlesource.com/38435Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
      e0329248
    • Sam Whited's avatar
      encoding/xml: format test output using subtests · ec512340
      Sam Whited authored
      Change-Id: I2d155c838935cd8427abd142a462ff4c56829715
      Reviewed-on: https://go-review.googlesource.com/37948Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      ec512340
    • Josselin Costanzi's avatar
      bytes: fix typo in comment · 0d3cd51c
      Josselin Costanzi authored
      Change-Id: Ia739337dc9961422982912cc6a669022559fb991
      Reviewed-on: https://go-review.googlesource.com/38365Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      0d3cd51c
    • Josh Bleecher Snyder's avatar
      cmd/compile: eliminate Gins and Naddr · 352e19c9
      Josh Bleecher Snyder authored
      Preparation for eliminating Prog-related globals.
      
      Passes toolstash-check -all.
      
      Updates #15756
      
      Change-Id: Ia199fcb282cc3a84903a6e92a3ce342c5faba79c
      Reviewed-on: https://go-review.googlesource.com/38409
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
      352e19c9
    • Carlos Eduardo Seo's avatar
      cmd/compile/internal/ppc64, cmd/compile/internal/ssa: Remove OldArch checks · c644a76e
      Carlos Eduardo Seo authored
      Starting in go1.9, the minimum processor requirement for ppc64 is POWER8.
      Therefore, the checks for OldArch and the code enabled by it are not necessary
      anymore.
      
      Updates #19074
      
      Change-Id: I33d6a78b2462c80d57c5dbcba2e13424630afab4
      Reviewed-on: https://go-review.googlesource.com/38404
      Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      c644a76e
    • Carlos Eduardo Seo's avatar
      runtime/internal/atomic: Remove unnecessary checks for GOARCH_ppc64 · 189053ae
      Carlos Eduardo Seo authored
      Starting in go1.9, the minimum processor requirement for ppc64 is POWER8. This
      means the checks for GOARCH_ppc64 in asm_ppc64x.s can be removed, since we can
      assume LBAR and STBCCC instructions (both from ISA 2.06) will always be
      available.
      
      Updates #19074
      
      Change-Id: Ib4418169cd9fc6f871a5ab126b28ee58a2f349e2
      Reviewed-on: https://go-review.googlesource.com/38406Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      Reviewed-by: default avatarLynn Boger <laboger@linux.vnet.ibm.com>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      189053ae
    • Matthew Dempsky's avatar
      cmd/compile/internal/gc: make SSAGenFPJump a method of SSAGenState · 22ea7fc1
      Matthew Dempsky authored
      Change-Id: Ie22a08c93dfcfd4b336e7b158415448dd55b2c11
      Reviewed-on: https://go-review.googlesource.com/38407
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      22ea7fc1
    • Josh Bleecher Snyder's avatar
      cmd/internal/obj: eliminate Link.Asmode · cfb3c8df
      Josh Bleecher Snyder authored
      Asmode is always set to p.Mode,
      which is always set based on the arch family.
      Instead, use the arch family directly.
      
      Passes toolstash-check -all.
      
      Change-Id: Id982472dcc8eeb6dd22cac5ad2f116b54a44caee
      Reviewed-on: https://go-review.googlesource.com/38451
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
      cfb3c8df
    • Josh Bleecher Snyder's avatar
      cmd/internal/obj: eliminate Ctxt.Mode · a470e5d4
      Josh Bleecher Snyder authored
      Replace Ctxt.Mode with a method, Ctxt.RegWidth,
      which is calculated directly off the arch info.
      
      I believe that Prog.Mode can also be removed; future CL.
      
      This is a step towards obj.Link immutability.
      
      Passes toolstash-check -all.
      
      Updates #15756
      
      Change-Id: Ifd7f8f6ed0a2fdc032d1dd306fcd695a14aa5bc5
      Reviewed-on: https://go-review.googlesource.com/38446
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
      a470e5d4
    • Josh Bleecher Snyder's avatar
      cmd/compile: funnel SSA Prog creation through SSAGenState · 0a94daa3
      Josh Bleecher Snyder authored
      Step one in eliminating Prog-related globals.
      
      Passes toolstash-check -all.
      
      Updates #15756
      
      Change-Id: I3b777fb5a7716f2d9da3067fbd94c28ca894a465
      Reviewed-on: https://go-review.googlesource.com/38450
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
      0a94daa3
    • Alan Donovan's avatar
      cmd/vet: -lostcancel: fix crash in ill-typed code · 3b39f523
      Alan Donovan authored
      Fixes golang/go#19656
      
      Change-Id: Ied20d3f25b6e147cc693a1dd1aeb9480adc6687e
      Reviewed-on: https://go-review.googlesource.com/38405Reviewed-by: default avatarJosh Bleecher Snyder <josharian@gmail.com>
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      3b39f523
    • Mikio Hara's avatar
      net/http: fix possible nil pointer dereference in TestOnlyWriteTimeout · b029e943
      Mikio Hara authored
      TestOnlyWriteTimeout assumes wrongly that:
      - the Accept method of trackLastConnListener is called only once
      - the shared variable conn never becomes nil
      and crashes on some circumstances.
      
      Updates #19032.
      
      Change-Id: I61de22618cd90b84a2b6401afdb6e5d9b3336b12
      Reviewed-on: https://go-review.googlesource.com/36735
      Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      b029e943
    • Josh Bleecher Snyder's avatar
      cmd/compile: pass an explicit position to namedAuto · 0b4e8d00
      Josh Bleecher Snyder authored
      To enable this, inline the call to nod and simplify.
      Eliminates a reference to lineno from the backend.
      
      Passes toolstash-check -all.
      
      Updates #15756
      
      Change-Id: I9c4bd77d10d727aa8f5e6c6bb16b0e05de165631
      Reviewed-on: https://go-review.googlesource.com/38441
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
      0b4e8d00
    • Josh Bleecher Snyder's avatar
      cmd/internal/obj: clean up brloop · 2f2cd557
      Josh Bleecher Snyder authored
      Add docs.
      Reduce indentation.
      
      Passes toolstash-check -all.
      
      Change-Id: I968d1af25989886ae9945052e05e211a107dde9c
      Reviewed-on: https://go-review.googlesource.com/38443
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
      2f2cd557
    • Aliaksandr Valialkin's avatar
      strconv: optimize decimal ints formatting with smallsString · 4c8023bf
      Aliaksandr Valialkin authored
      Benchmark results for GOARCH=amd64:
      
      name                                     old time/op  new time/op  delta
      FormatInt-4                              2.51µs ± 2%  2.40µs ± 2%   -4.51%  (p=0.000 n=9+10)
      AppendInt-4                              1.67µs ± 2%  1.61µs ± 3%   -3.74%  (p=0.000 n=9+9)
      FormatUint-4                              698ns ± 2%   643ns ± 3%   -7.95%  (p=0.000 n=10+8)
      AppendUint-4                              478ns ± 1%   418ns ± 2%  -12.61%  (p=0.000 n=8+10)
      AppendUintVarlen/1-4                     9.30ns ± 6%  9.15ns ± 1%     ~     (p=0.199 n=9+10)
      AppendUintVarlen/12-4                    9.12ns ± 0%  9.16ns ± 2%     ~     (p=0.307 n=9+9)
      AppendUintVarlen/123-4                   18.6ns ± 2%  18.7ns ± 0%     ~     (p=0.091 n=10+6)
      AppendUintVarlen/1234-4                  19.1ns ± 4%  17.7ns ± 1%   -7.35%  (p=0.000 n=10+9)
      AppendUintVarlen/12345-4                 21.5ns ± 3%  20.7ns ± 3%   -3.78%  (p=0.002 n=9+10)
      AppendUintVarlen/123456-4                23.5ns ± 3%  20.9ns ± 1%  -11.14%  (p=0.000 n=10+9)
      AppendUintVarlen/1234567-4               25.0ns ± 2%  23.6ns ± 7%   -5.48%  (p=0.004 n=9+10)
      AppendUintVarlen/12345678-4              26.8ns ± 2%  23.4ns ± 2%  -12.79%  (p=0.000 n=9+10)
      AppendUintVarlen/123456789-4             29.8ns ± 3%  26.5ns ± 5%  -11.03%  (p=0.000 n=10+10)
      AppendUintVarlen/1234567890-4            31.6ns ± 3%  26.9ns ± 3%  -14.95%  (p=0.000 n=10+9)
      AppendUintVarlen/12345678901-4           33.8ns ± 3%  29.3ns ± 5%  -13.21%  (p=0.000 n=10+10)
      AppendUintVarlen/123456789012-4          35.5ns ± 4%  29.2ns ± 4%  -17.82%  (p=0.000 n=10+10)
      AppendUintVarlen/1234567890123-4         37.6ns ± 4%  31.4ns ± 3%  -16.48%  (p=0.000 n=10+10)
      AppendUintVarlen/12345678901234-4        39.8ns ± 6%  32.0ns ± 7%  -19.60%  (p=0.000 n=10+10)
      AppendUintVarlen/123456789012345-4       40.7ns ± 0%  34.4ns ± 4%  -15.55%  (p=0.000 n=6+10)
      AppendUintVarlen/1234567890123456-4      45.4ns ± 6%  35.1ns ± 4%  -22.66%  (p=0.000 n=10+10)
      AppendUintVarlen/12345678901234567-4     45.1ns ± 1%  36.7ns ± 4%  -18.77%  (p=0.000 n=9+10)
      AppendUintVarlen/123456789012345678-4    46.9ns ± 0%  36.4ns ± 3%  -22.49%  (p=0.000 n=9+10)
      AppendUintVarlen/1234567890123456789-4   50.6ns ± 6%  38.8ns ± 3%  -23.28%  (p=0.000 n=10+10)
      AppendUintVarlen/12345678901234567890-4  51.3ns ± 2%  38.4ns ± 0%  -25.00%  (p=0.000 n=9+8)
      
      Benchmark results for GOARCH=386:
      
      name                                     old time/op  new time/op  delta
      FormatInt-4                              6.21µs ± 0%  6.14µs ± 0%  -1.11%  (p=0.008 n=5+5)
      AppendInt-4                              4.95µs ± 0%  4.85µs ± 0%  -1.99%  (p=0.016 n=5+4)
      FormatUint-4                             1.89µs ± 1%  1.83µs ± 1%  -2.94%  (p=0.008 n=5+5)
      AppendUint-4                             1.59µs ± 0%  1.57µs ± 2%  -1.72%  (p=0.040 n=5+5)
      FormatIntSmall-4                         8.48ns ± 0%  8.48ns ± 0%    ~     (p=0.905 n=5+5)
      AppendIntSmall-4                         12.2ns ± 0%  12.2ns ± 0%    ~     (all equal)
      AppendUintVarlen/1-4                     10.6ns ± 1%  10.7ns ± 0%    ~     (p=0.238 n=5+4)
      AppendUintVarlen/12-4                    10.7ns ± 0%  10.7ns ± 1%    ~     (p=0.333 n=4+5)
      AppendUintVarlen/123-4                   29.9ns ± 1%  30.2ns ± 0%  +1.07%  (p=0.016 n=5+4)
      AppendUintVarlen/1234-4                  32.4ns ± 1%  30.4ns ± 0%  -6.30%  (p=0.008 n=5+5)
      AppendUintVarlen/12345-4                 35.1ns ± 2%  34.9ns ± 0%    ~     (p=0.238 n=5+5)
      AppendUintVarlen/123456-4                36.6ns ± 0%  35.3ns ± 0%  -3.55%  (p=0.029 n=4+4)
      AppendUintVarlen/1234567-4               38.9ns ± 0%  39.6ns ± 0%  +1.80%  (p=0.029 n=4+4)
      AppendUintVarlen/12345678-4              41.3ns ± 0%  40.1ns ± 0%  -2.91%  (p=0.000 n=5+4)
      AppendUintVarlen/123456789-4             44.9ns ± 1%  44.8ns ± 0%    ~     (p=0.667 n=5+5)
      AppendUintVarlen/1234567890-4            65.6ns ± 0%  66.2ns ± 1%  +0.88%  (p=0.016 n=4+5)
      AppendUintVarlen/12345678901-4           77.9ns ± 0%  76.3ns ± 0%  -2.00%  (p=0.000 n=4+5)
      AppendUintVarlen/123456789012-4          80.7ns ± 0%  79.1ns ± 1%  -2.01%  (p=0.008 n=5+5)
      AppendUintVarlen/1234567890123-4         83.6ns ± 0%  80.2ns ± 1%  -4.07%  (p=0.008 n=5+5)
      AppendUintVarlen/12345678901234-4        86.2ns ± 1%  83.3ns ± 0%  -3.39%  (p=0.008 n=5+5)
      AppendUintVarlen/123456789012345-4       88.5ns ± 0%  83.7ns ± 0%  -5.42%  (p=0.008 n=5+5)
      AppendUintVarlen/1234567890123456-4      90.6ns ± 0%  88.3ns ± 0%  -2.54%  (p=0.008 n=5+5)
      AppendUintVarlen/12345678901234567-4     92.7ns ± 0%  89.0ns ± 1%  -4.01%  (p=0.008 n=5+5)
      AppendUintVarlen/123456789012345678-4    95.6ns ± 1%  92.6ns ± 0%  -3.18%  (p=0.016 n=5+4)
      AppendUintVarlen/1234567890123456789-4    118ns ± 0%   114ns ± 0%    ~     (p=0.079 n=4+5)
      AppendUintVarlen/12345678901234567890-4   138ns ± 0%   136ns ± 0%  -1.45%  (p=0.008 n=5+5)
      
      Updates #19445
      
      Change-Id: Iafbe5c074898187c150dc3854e5b9fc19c10be05
      Reviewed-on: https://go-review.googlesource.com/38255
      Run-TryBot: Robert Griesemer <gri@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
      4c8023bf
    • Josh Bleecher Snyder's avatar
      cmd/internal/obj: clean up checkaddr · 33266df8
      Josh Bleecher Snyder authored
      Coalesce identical cases.
      Give it a proper doc comment.
      Fix comment locations.
      Update/delete old comments.
      
      Passes toolstash-check -all.
      
      Change-Id: I88d9cf20e6e04b0c1c6583e92cd96335831f183f
      Reviewed-on: https://go-review.googlesource.com/38442
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarDave Cheney <dave@cheney.net>
      Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
      33266df8
    • Josh Bleecher Snyder's avatar
      cmd/internal/obj: eliminate AMODE · 3394633d
      Josh Bleecher Snyder authored
      AMODE appears to have been intended to allow
      a Prog to switch between 16 (!), 32, or 64 bit x86.
      It is unused anywhere in the tree.
      
      Passes toolstash-check -all.
      
      Updates #15756
      
      Change-Id: Ic57b257cfe580f29dad81d97e4193bf3c330c598
      Reviewed-on: https://go-review.googlesource.com/38445
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarDave Cheney <dave@cheney.net>
      Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
      3394633d
    • Josh Bleecher Snyder's avatar
      cmd/internal/obj: eliminate unnecessary ctxt.Cursym assignment · 88d4ab82
      Josh Bleecher Snyder authored
      None of the following code uses it.
      
      Passes toolstash-check -all.
      
      Updates #15756
      
      Change-Id: Ieeaaca8ba31e5c345c0c8a758d520b24be88e173
      Reviewed-on: https://go-review.googlesource.com/38444
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarDave Cheney <dave@cheney.net>
      88d4ab82
    • Rob Pike's avatar
      cmd/doc: implement "go doc struct.field" · 2c47c3e2
      Rob Pike authored
      By analogy with the handling of methods on types, show the documentation
      for a single field of a struct.
      
      	% go doc ast.structtype.fields
      	struct StructType {
      	    Fields *FieldList  // list of field declarations
      	}
      	%
      
      Fixes #19169.
      
      Change-Id: I002f992e4aa64bee667e2e4bccc7082486149842
      Reviewed-on: https://go-review.googlesource.com/38438Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      2c47c3e2
    • Jason Travis's avatar
      test/bench/go1: fix typo in parserdata_test.go comment · 19040ac8
      Jason Travis authored
      Change-Id: Iaca02660bdc8262db2b003a94aca661b5cec5576
      Reviewed-on: https://go-review.googlesource.com/38437Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      19040ac8
    • Josh Bleecher Snyder's avatar
      cmd/compile: disable typPtr caching in the backend · f9fb4579
      Josh Bleecher Snyder authored
      The only new Types that the backend introduces
      are pointers to Types generated by the frontend.
      Usually, when we generate a *T,
      we cache the resulting Type in T,
      to avoid recreating it later.
      However, that caching is not concurrency safe.
      Rather than add mutexes, this CL disables that
      caching before starting the backend.
      The backend generates few enough new *Ts that the
      performance impact of this is small, particularly
      if we pre-create some commonly used *Ts.
      
      Updates #15756
      
      name       old alloc/op    new alloc/op    delta
      Template      40.3MB ± 0%     40.4MB ± 0%  +0.18%  (p=0.001 n=10+10)
      Unicode       29.8MB ± 0%     29.8MB ± 0%  +0.11%  (p=0.043 n=10+9)
      GoTypes        114MB ± 0%      115MB ± 0%  +0.33%  (p=0.000 n=9+10)
      SSA            855MB ± 0%      859MB ± 0%  +0.40%  (p=0.000 n=10+10)
      Flate         25.7MB ± 0%     25.8MB ± 0%  +0.35%  (p=0.000 n=10+10)
      GoParser      31.9MB ± 0%     32.1MB ± 0%  +0.58%  (p=0.000 n=10+10)
      Reflect       79.6MB ± 0%     79.9MB ± 0%  +0.31%  (p=0.000 n=10+10)
      Tar           26.9MB ± 0%     26.9MB ± 0%  +0.21%  (p=0.000 n=10+10)
      XML           42.5MB ± 0%     42.7MB ± 0%  +0.52%  (p=0.000 n=10+9)
      
      name       old allocs/op   new allocs/op   delta
      Template        394k ± 1%       393k ± 0%    ~     (p=0.529 n=10+10)
      Unicode         319k ± 1%       319k ± 0%    ~     (p=0.720 n=10+9)
      GoTypes        1.15M ± 0%      1.15M ± 0%  +0.14%  (p=0.035 n=10+10)
      SSA            7.53M ± 0%      7.56M ± 0%  +0.45%  (p=0.000 n=9+10)
      Flate           238k ± 0%       238k ± 1%    ~     (p=0.579 n=10+10)
      GoParser        318k ± 1%       320k ± 1%  +0.64%  (p=0.001 n=10+10)
      Reflect        1.00M ± 0%      1.00M ± 0%    ~     (p=0.393 n=10+10)
      Tar             254k ± 0%       254k ± 1%    ~     (p=0.075 n=10+10)
      XML             395k ± 0%       397k ± 0%  +0.44%  (p=0.001 n=10+9)
      
      Change-Id: I6c031ed4f39108f26969c5712b73aa2fc08cd10a
      Reviewed-on: https://go-review.googlesource.com/38417
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
      f9fb4579
  2. 21 Mar, 2017 17 commits
    • Brad Fitzpatrick's avatar
      syscall, os: fix FreeBSD 9 build · 2730c17a
      Brad Fitzpatrick authored
      I broke FreeBSD 9 in https://golang.org/cl/38426 by using Pipe2.
      
      We still want to support FreeBSD 9 for one last release (Go 1.9 will
      be the last), and FreeBSD 9 doesn't have Pipe2.
      
      So this still uses Pipe2, but falls back to Pipe on error.
      
      Updates #18854
      Updates #19072
      
      Change-Id: I1de90fb83606c93fb84b4b86fba31e207a702835
      Reviewed-on: https://go-review.googlesource.com/38430Reviewed-by: default avatarRob Pike <r@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      2730c17a
    • Matthew Dempsky's avatar
      cmd/compile/internal/gc: remove unneeded effects cache fields · ee80afe3
      Matthew Dempsky authored
      Must have been lost when rebasing the SSA liveness CLs.
      
      Change-Id: Iaac33158cc7c92ea44a023c242eb914a7d6979c6
      Reviewed-on: https://go-review.googlesource.com/38427
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      ee80afe3
    • Josselin Costanzi's avatar
      bytes: add optimized countByte for amd64 · 01cd22c6
      Josselin Costanzi authored
      Use SSE/AVX2 when counting a single byte.
      Inspired from runtime indexbyte implementation.
      
      Benchmark against previous implementation, where
      1 byte in every 8 is the one we are looking for:
      
      * On a machine without AVX2
      name               old time/op   new time/op     delta
      CountSingle/10-4    61.8ns ±10%     15.6ns ±11%    -74.83%  (p=0.000 n=10+10)
      CountSingle/32-4     100ns ± 4%       17ns ±10%    -82.54%  (p=0.000 n=10+9)
      CountSingle/4K-4    9.66µs ± 3%     0.37µs ± 6%    -96.21%  (p=0.000 n=10+10)
      CountSingle/4M-4    11.0ms ± 6%      0.4ms ± 4%    -96.04%  (p=0.000 n=10+10)
      CountSingle/64M-4    194ms ± 8%        8ms ± 2%    -95.64%  (p=0.000 n=10+10)
      
      name               old speed     new speed       delta
      CountSingle/10-4   162MB/s ±10%    645MB/s ±10%   +297.00%  (p=0.000 n=10+10)
      CountSingle/32-4   321MB/s ± 5%   1844MB/s ± 9%   +474.79%  (p=0.000 n=10+9)
      CountSingle/4K-4   424MB/s ± 3%  11169MB/s ± 6%  +2533.10%  (p=0.000 n=10+10)
      CountSingle/4M-4   381MB/s ± 7%   9609MB/s ± 4%  +2421.88%  (p=0.000 n=10+10)
      CountSingle/64M-4  346MB/s ± 7%   7924MB/s ± 2%  +2188.78%  (p=0.000 n=10+10)
      
      * On a machine with AVX2
      name               old time/op   new time/op     delta
      CountSingle/10-8    37.1ns ± 3%      8.2ns ± 1%    -77.80%  (p=0.000 n=10+10)
      CountSingle/32-8    66.1ns ± 3%      9.8ns ± 2%    -85.23%  (p=0.000 n=10+10)
      CountSingle/4K-8    7.36µs ± 3%     0.11µs ± 1%    -98.54%  (p=0.000 n=10+10)
      CountSingle/4M-8    7.46ms ± 2%     0.15ms ± 2%    -97.95%  (p=0.000 n=10+9)
      CountSingle/64M-8    124ms ± 2%        6ms ± 4%    -95.09%  (p=0.000 n=10+10)
      
      name               old speed     new speed       delta
      CountSingle/10-8   269MB/s ± 3%   1213MB/s ± 1%   +350.32%  (p=0.000 n=10+10)
      CountSingle/32-8   484MB/s ± 4%   3277MB/s ± 2%   +576.66%  (p=0.000 n=10+10)
      CountSingle/4K-8   556MB/s ± 3%  37933MB/s ± 1%  +6718.36%  (p=0.000 n=10+10)
      CountSingle/4M-8   562MB/s ± 2%  27444MB/s ± 3%  +4783.43%  (p=0.000 n=10+9)
      CountSingle/64M-8  543MB/s ± 2%  11054MB/s ± 3%  +1935.81%  (p=0.000 n=10+10)
      
      Fixes #19411
      
      Change-Id: Ieaf20b1fabccabe767c55c66e242e86f3617f883
      Reviewed-on: https://go-review.googlesource.com/38258
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarKeith Randall <khr@golang.org>
      01cd22c6
    • Brad Fitzpatrick's avatar
      syscall, os: use pipe2 syscall on FreeBSD instead of pipe · 0ebaca6b
      Brad Fitzpatrick authored
      The pipe2 syscall exists in all officially supported FreeBSD
      versions: 10, 11 and future 12.
      The pipe syscall no longer exists in 11 and 12. To build and
      run Go on these versions, kernel needs COMPAT_FREEBSD10 option.
      
      Based on Gleb Smirnoff's https://golang.org/cl/38422
      
      Fixes #18854
      
      Change-Id: I8e201ee1b15dca10427c3093b966025d160aaf61
      Reviewed-on: https://go-review.googlesource.com/38426
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      Reviewed-by: default avatarRob Pike <r@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      0ebaca6b
    • Matthew Dempsky's avatar
      cmd/compile: add regress test for issue 19632 · 051cbf3f
      Matthew Dempsky authored
      Updates #19632.
      
      Change-Id: I1411dd997c8c6a789d17d0dcc0bfbd2281447b16
      Reviewed-on: https://go-review.googlesource.com/38401
      Run-TryBot: Matthew Dempsky <mdempsky@google.com>
      Reviewed-by: default avatarJosh Bleecher Snyder <josharian@gmail.com>
      Reviewed-by: default avatarDaniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      051cbf3f
    • Josh Bleecher Snyder's avatar
      cmd/compile: remove function-name-based debuglive tweaks · 10fdf769
      Josh Bleecher Snyder authored
      It's easier to grep output than recompile the compiler anyway.
      
      For concurrent compilation.
      
      Updates #15756
      
      Change-Id: I151cb5dc77056469cd9019d516f86454e931a197
      Reviewed-on: https://go-review.googlesource.com/38424
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
      10fdf769
    • Josh Bleecher Snyder's avatar
      cmd/compile: eliminate a Curfn reference in plive · 89840e4a
      Josh Bleecher Snyder authored
      I think this got lost in a rebase somewhere.
      
      Updates #15756
      
      Change-Id: Ia3e7c60d1b9254f2877217073732b46c91059ade
      Reviewed-on: https://go-review.googlesource.com/38425
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      89840e4a
    • Matthew Dempsky's avatar
      cmd/compile/internal/gc: fix liveness regression · baa0fdd0
      Matthew Dempsky authored
      During AllocFrame, we drop unused variables from Curfn.Func.Dcl, but
      there might still be OpVarFoo instructions that reference those
      variables. This wasn't a problem though because gvardefx used to emit
      ANOP for unused variables instead of AVARFOO.
      
      As an easy fix, if we see OpVarFoo (or OpKeepAlive) referencing an
      unused variable, we can ignore it.
      
      Fixes #19632.
      
      Change-Id: I4e9ffabdb4058f7cdcc4663b540f5a5a692daf8b
      Reviewed-on: https://go-review.googlesource.com/38400Reviewed-by: default avatarJosh Bleecher Snyder <josharian@gmail.com>
      baa0fdd0
    • Daniel Martí's avatar
      runtime: remove unused *chantype parameters · 2e29eb57
      Daniel Martí authored
      The chanrecv funcs don't use it at all. The chansend ones do, but the
      element type is now part of the hchan struct, which is already a
      parameter.
      
      hchan can be nil in chansend when sending to a nil channel, so when
      instrumenting we must copy to the stack to be able to read the channel
      type.
      
      name             old time/op  new time/op  delta
      ChanUncontended  6.42µs ± 1%  6.22µs ± 0%  -3.06%  (p=0.000 n=19+18)
      
      Initially found by github.com/mvdan/unparam.
      
      Fixes #19591.
      
      Change-Id: I3a5e8a0082e8445cc3f0074695e3593fd9c88412
      Reviewed-on: https://go-review.googlesource.com/38351
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
      2e29eb57
    • Brad Fitzpatrick's avatar
      flag: validate Int and Uint values to be in range · c65ceff1
      Brad Fitzpatrick authored
      Fixes #19230
      
      Change-Id: I38df9732b88f0328506e74f1a46f52adf47db1e5
      Reviewed-on: https://go-review.googlesource.com/38419Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      c65ceff1
    • Vladimir Stefanovic's avatar
      cmd/compile,runtime: fix atomic And8 for mipsle · 24dc8c6c
      Vladimir Stefanovic authored
      Removing stray xori that came from big endian copy/paste.
      Adding atomicand8 check to runtime.check() that would have revealed
      this error.
      Might fix #19396.
      
      Change-Id: If8d6f25d3e205496163541eb112548aa66df9c2a
      Reviewed-on: https://go-review.googlesource.com/38257
      Run-TryBot: Cherry Zhang <cherryyz@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
      24dc8c6c
    • Lynn Boger's avatar
      cmd/compile: improve LoweredZero performance for ppc64x · 23bd9191
      Lynn Boger authored
      This change improves the performance of the LoweredZero rule
      on ppc64x.
      
      The improvement can be seen in the runtime ClearFat
      benchmarks:
      
      BenchmarkClearFat12-16       2.40          0.69          -71.25%
      BenchmarkClearFat16-16       9.98          0.93          -90.68%
      BenchmarkClearFat24-16       4.75          0.93          -80.42%
      BenchmarkClearFat32-16       6.02          0.93          -84.55%
      BenchmarkClearFat40-16       7.19          1.16          -83.87%
      BenchmarkClearFat48-16       15.0          1.39          -90.73%
      BenchmarkClearFat56-16       9.95          1.62          -83.72%
      BenchmarkClearFat64-16       18.0          1.86          -89.67%
      BenchmarkClearFat128-16      30.0          8.08          -73.07%
      BenchmarkClearFat256-16      52.5          11.3          -78.48%
      BenchmarkClearFat512-16      97.0          19.0          -80.41%
      BenchmarkClearFat1024-16     244           34.2          -85.98%
      
      Fixes: #19532
      
      Change-Id: If493e28bc1d8e61bc79978498be9f5336a36cd3f
      Reviewed-on: https://go-review.googlesource.com/38096
      Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarMichael Munday <munday@ca.ibm.com>
      23bd9191
    • Volker Dobler's avatar
      net/http/cookiejar: fix out-of-bounds errors on malformed domains · d972dc2d
      Volker Dobler authored
      The old implementation of Jar made the assumption that the host names
      in the URLs given to SetCookies() and Cookies() methods are well-formed.
      This is not an unreasonable assumption as malformed host names do not
      trigger calls to SetCookies or Cookies (at least not from net/http)
      as the HTTP request themselves are not executed. But there can be other
      invocations of these methods and at least on Linux it was possible to
      make DNS lookup to domain names with two trailing dots (see issue #7122).
      
      This is an old bug and this CL revives an old change (see
      https://codereview.appspot.com/52100043) to fix the issue. The discussion
      around 52100043 focused on the interplay between the jar and the
      public suffix list and who is responsible for which type if domain name
      canonicalization. The new bug report in issue #19384 used a nil public
      suffix list which demonstrates that the package cookiejar alone exhibits
      this problem and any solution cannot be fully delegated to the
      implementation of the used PublicSuffixList: Package cookiejar itself
      needs to protect against host names of the form ".." which triggered an
      out-of-bounds error.
      
      This CL does not address the issue of host name canonicalization and
      the question who is responsible for it. This CL just prevents the
      out-of-bounds error: It is a very conservative change, i.e. one might
      still set and retrieve cookies for host names like "weird.stuf...".
      Several more test cases document how the current code works.
      
      Fixes #19384.
      
      Change-Id: I14be080e8a2a0b266ced779f2aeb18841b730610
      Reviewed-on: https://go-review.googlesource.com/37843
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarRuss Cox <rsc@golang.org>
      d972dc2d
    • Hugues Bruant's avatar
      runtime: add mapdelete_fast* · 5d6b7fca
      Hugues Bruant authored
      Add benchmarks for map delete with int32/int64/string key
      
      Benchmark results on darwin/amd64
      
      name                 old time/op  new time/op  delta
      MapDelete/Int32/1-8   151ns ± 8%    99ns ± 3%  -34.39%  (p=0.008 n=5+5)
      MapDelete/Int32/2-8   128ns ± 2%   111ns ±15%  -13.40%  (p=0.040 n=5+5)
      MapDelete/Int32/4-8   128ns ± 5%   114ns ± 2%  -10.82%  (p=0.008 n=5+5)
      MapDelete/Int64/1-8   144ns ± 0%   104ns ± 3%  -27.53%  (p=0.016 n=4+5)
      MapDelete/Int64/2-8   153ns ± 1%   126ns ± 3%  -17.17%  (p=0.008 n=5+5)
      MapDelete/Int64/4-8   178ns ± 3%   136ns ± 2%  -23.60%  (p=0.008 n=5+5)
      MapDelete/Str/1-8     187ns ± 3%   171ns ± 3%   -8.54%  (p=0.008 n=5+5)
      MapDelete/Str/2-8     221ns ± 3%   206ns ± 4%   -7.18%  (p=0.016 n=5+4)
      MapDelete/Str/4-8     256ns ± 5%   232ns ± 2%   -9.36%  (p=0.016 n=4+5)
      
      name                     old time/op    new time/op    delta
      BinaryTree17-8              2.78s ± 7%     2.70s ± 1%    ~     (p=0.151 n=5+5)
      Fannkuch11-8                3.21s ± 2%     3.19s ± 1%    ~     (p=0.310 n=5+5)
      FmtFprintfEmpty-8          49.1ns ± 3%    50.2ns ± 2%    ~     (p=0.095 n=5+5)
      FmtFprintfString-8         78.6ns ± 4%    80.2ns ± 5%    ~     (p=0.460 n=5+5)
      FmtFprintfInt-8            79.7ns ± 1%    81.0ns ± 3%    ~     (p=0.103 n=5+5)
      FmtFprintfIntInt-8          117ns ± 2%     119ns ± 0%    ~     (p=0.079 n=5+4)
      FmtFprintfPrefixedInt-8     153ns ± 1%     146ns ± 3%  -4.19%  (p=0.024 n=5+5)
      FmtFprintfFloat-8           239ns ± 1%     237ns ± 1%    ~     (p=0.246 n=5+5)
      FmtManyArgs-8               506ns ± 2%     509ns ± 2%    ~     (p=0.238 n=5+5)
      GobDecode-8                7.06ms ± 4%    6.86ms ± 1%    ~     (p=0.222 n=5+5)
      GobEncode-8                6.01ms ± 5%    5.87ms ± 2%    ~     (p=0.222 n=5+5)
      Gzip-8                      246ms ± 4%     236ms ± 1%  -4.12%  (p=0.008 n=5+5)
      Gunzip-8                   37.7ms ± 4%    37.3ms ± 1%    ~     (p=0.841 n=5+5)
      HTTPClientServer-8         64.9µs ± 1%    64.4µs ± 0%  -0.80%  (p=0.032 n=5+4)
      JSONEncode-8               16.0ms ± 2%    16.2ms ±11%    ~     (p=0.548 n=5+5)
      JSONDecode-8               53.2ms ± 2%    53.1ms ± 4%    ~     (p=1.000 n=5+5)
      Mandelbrot200-8            4.33ms ± 2%    4.32ms ± 2%    ~     (p=0.841 n=5+5)
      GoParse-8                  3.24ms ± 2%    3.27ms ± 4%    ~     (p=0.690 n=5+5)
      RegexpMatchEasy0_32-8      86.2ns ± 1%    85.2ns ± 3%    ~     (p=0.286 n=5+5)
      RegexpMatchEasy0_1K-8       198ns ± 2%     199ns ± 1%    ~     (p=0.310 n=5+5)
      RegexpMatchEasy1_32-8      82.6ns ± 2%    81.8ns ± 1%    ~     (p=0.294 n=5+5)
      RegexpMatchEasy1_1K-8       359ns ± 2%     354ns ± 1%  -1.39%  (p=0.048 n=5+5)
      RegexpMatchMedium_32-8      123ns ± 2%     123ns ± 1%    ~     (p=0.905 n=5+5)
      RegexpMatchMedium_1K-8     38.2µs ± 2%    38.6µs ± 8%    ~     (p=0.690 n=5+5)
      RegexpMatchHard_32-8       1.92µs ± 2%    1.91µs ± 5%    ~     (p=0.460 n=5+5)
      RegexpMatchHard_1K-8       57.6µs ± 1%    57.0µs ± 2%    ~     (p=0.310 n=5+5)
      Revcomp-8                   483ms ± 7%     441ms ± 1%  -8.79%  (p=0.016 n=5+4)
      Template-8                 58.0ms ± 1%    58.2ms ± 7%    ~     (p=0.310 n=5+5)
      TimeParse-8                 324ns ± 6%     312ns ± 2%    ~     (p=0.087 n=5+5)
      TimeFormat-8                330ns ± 1%     329ns ± 1%    ~     (p=0.968 n=5+5)
      
      name                     old speed      new speed      delta
      GobDecode-8               109MB/s ± 4%   112MB/s ± 1%    ~     (p=0.222 n=5+5)
      GobEncode-8               128MB/s ± 5%   131MB/s ± 2%    ~     (p=0.222 n=5+5)
      Gzip-8                   78.9MB/s ± 4%  82.3MB/s ± 1%  +4.25%  (p=0.008 n=5+5)
      Gunzip-8                  514MB/s ± 4%   521MB/s ± 1%    ~     (p=0.841 n=5+5)
      JSONEncode-8              121MB/s ± 2%   120MB/s ±10%    ~     (p=0.548 n=5+5)
      JSONDecode-8             36.5MB/s ± 2%  36.6MB/s ± 4%    ~     (p=1.000 n=5+5)
      GoParse-8                17.9MB/s ± 2%  17.7MB/s ± 4%    ~     (p=0.730 n=5+5)
      RegexpMatchEasy0_32-8     371MB/s ± 1%   375MB/s ± 3%    ~     (p=0.310 n=5+5)
      RegexpMatchEasy0_1K-8    5.15GB/s ± 1%  5.13GB/s ± 1%    ~     (p=0.548 n=5+5)
      RegexpMatchEasy1_32-8     387MB/s ± 2%   391MB/s ± 1%    ~     (p=0.310 n=5+5)
      RegexpMatchEasy1_1K-8    2.85GB/s ± 2%  2.89GB/s ± 1%    ~     (p=0.056 n=5+5)
      RegexpMatchMedium_32-8   8.07MB/s ± 2%  8.06MB/s ± 1%    ~     (p=0.730 n=5+5)
      RegexpMatchMedium_1K-8   26.8MB/s ± 2%  26.6MB/s ± 7%    ~     (p=0.690 n=5+5)
      RegexpMatchHard_32-8     16.7MB/s ± 2%  16.7MB/s ± 5%    ~     (p=0.421 n=5+5)
      RegexpMatchHard_1K-8     17.8MB/s ± 1%  18.0MB/s ± 2%    ~     (p=0.310 n=5+5)
      Revcomp-8                 527MB/s ± 6%   577MB/s ± 1%  +9.44%  (p=0.016 n=5+4)
      Template-8               33.5MB/s ± 1%  33.4MB/s ± 7%    ~     (p=0.310 n=5+5)
      
      Updates #19495
      
      Change-Id: Ib9ece1690813d9b4788455db43d30891e2138df5
      Reviewed-on: https://go-review.googlesource.com/38172Reviewed-by: default avatarHugues Bruant <hugues.bruant@gmail.com>
      Reviewed-by: default avatarKeith Randall <khr@golang.org>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      5d6b7fca
    • Alex Brainman's avatar
      runtime: import os package in BenchmarkRunningGoProgram · f2b79cad
      Alex Brainman authored
      I would like to use BenchmarkRunningGoProgram to measure
      changes for issue #15588. So the program in the benchmark
      should import "os" package.
      
      It is also reasonable that basic Go program includes
      "os" package.
      
      For #15588.
      
      Change-Id: Ida6712eab22c2e79fbe91b6fdd492eaf31756852
      Reviewed-on: https://go-review.googlesource.com/37914
      Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      f2b79cad
    • Josh Bleecher Snyder's avatar
      cmd/compile: fix pos of typenames created during SSA construction · 165a96e2
      Josh Bleecher Snyder authored
      Prior to this CL, the function's position was used.
      The dottype Node's position is clearly better.
      
      I'm not thrilled about introducing a reference to
      lineno in the middle of SSA construction;
      I will have to remove it later.
      My immediate goal is stability and correctness of positions,
      though, since that aids refactoring, so this is an improvement.
      
      An example from package io:
      
      func (t *multiWriter) WriteString(s string) (n int, err error) {
      	var p []byte // lazily initialized if/when needed
      	for _, w := range t.writers {
      		if sw, ok := w.(stringWriter); ok {
      			n, err = sw.WriteString(s)
      
      The w.(stringWriter) type assertion includes loading
      the address of static type data for stringWriter:
      
      LEAQ	type."".stringWriter(SB), R10
      
      Prior to this CL, this instruction was given the line number
      of the function declaration.
      After this CL, this instruction is given the line number
      of the type assertion itself.
      
      Change-Id: Ifcca274b581a5a57d7e3102c4d7b7786bf307210
      Reviewed-on: https://go-review.googlesource.com/38389
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
      165a96e2
    • Rob Pike's avatar
      encoding/gob: document the extra byte after a singleton · 67a46cc1
      Rob Pike authored
      This paragraph has been added, as the notion was missing from the
      documentation.
      
      If a value is passed to Encode and the type is not a struct (or pointer to struct,
      etc.), for simplicity of processing it is represented as a struct of one field.
      The only visible effect of this is to encode a zero byte after the value, just as
      after the last field of an encoded struct, so that the decode algorithm knows when
      the top-level value is complete.
      
      Fixes #16978
      
      Change-Id: I5f008e792d1b6fe80d2e026a7ff716608889db32
      Reviewed-on: https://go-review.googlesource.com/38414Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      67a46cc1