1. 15 Aug, 2017 24 commits
    • Martin Möhrmann's avatar
      cmd/compile: generate makechan calls with int arguments · 8a6e51ae
      Martin Möhrmann authored
      Where possible generate calls to runtime makechan with int arguments
      during compile time instead of makechan with int64 arguments.
      
      This eliminates converting arguments for calls to makechan with
      int64 arguments for platforms where int64 values do not fit into
      arguments of type int.
      
      A similar optimization for makeslice was introduced in CL
      golang.org/cl/27851.
      
      386:
      name                old time/op  new time/op  delta
      MakeChan/Byte       52.4ns ± 6%  45.0ns ± 1%  -14.14%  (p=0.000 n=10+10)
      MakeChan/Int        54.5ns ± 1%  49.1ns ± 1%   -9.87%  (p=0.000 n=10+10)
      MakeChan/Ptr         150ns ± 1%   143ns ± 0%   -4.38%  (p=0.000 n=9+7)
      MakeChan/Struct/0   49.2ns ± 2%  43.2ns ± 2%  -12.27%  (p=0.000 n=10+10)
      MakeChan/Struct/32  81.7ns ± 2%  76.2ns ± 1%   -6.71%  (p=0.000 n=10+10)
      MakeChan/Struct/40  88.4ns ± 2%  82.5ns ± 2%   -6.60%  (p=0.000 n=10+10)
      
      AMD64:
      name                old time/op  new time/op  delta
      MakeChan/Byte       83.4ns ± 8%  80.8ns ± 3%    ~     (p=0.171 n=10+10)
      MakeChan/Int         101ns ± 3%   101ns ± 2%    ~     (p=0.412 n=10+10)
      MakeChan/Ptr         128ns ± 1%   128ns ± 1%    ~     (p=0.191 n=10+10)
      MakeChan/Struct/0   67.6ns ± 3%  68.7ns ± 4%    ~     (p=0.224 n=10+10)
      MakeChan/Struct/32   138ns ± 1%   139ns ± 1%    ~     (p=0.185 n=10+9)
      MakeChan/Struct/40   154ns ± 1%   154ns ± 1%  -0.55%  (p=0.027 n=10+9)
      
      Change-Id: Ie854cb066007232c5e9f71ea7d6fe27e81a9c050
      Reviewed-on: https://go-review.googlesource.com/55140
      Run-TryBot: Martin Möhrmann <moehrmann@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      8a6e51ae
    • Joe Tsai's avatar
      archive/tar: re-implement USTAR path splitting · 4c557743
      Joe Tsai authored
      The logic for USTAR was disabled because a previous implementation of
      Writer had a wrong understanding of the differences between USTAR and GNU,
      causing the prefix field is incorrectly be populated in GNU files.
      
      Now that this issue has been fixed, we can re-enable the logic for USTAR
      path splitting, which allows Writer to use the USTAR for a wider range
      of possible inputs.
      
      Updates #9683
      Updates #12594
      Updates #17630
      
      Change-Id: I9fe34e5df63f99c6dd56fee3a7e7e4d6ec3995c9
      Reviewed-on: https://go-review.googlesource.com/55574
      Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      4c557743
    • Joe Tsai's avatar
      archive/tar: centralize errors in common.go · a0237c52
      Joe Tsai authored
      Move all sentinel errors to common.go since some of them are
      returned by both the reader and writer and remove errInvalidHeader
      since it not used.
      
      Also, consistently use the "tar: " prefix for errors.
      
      Change-Id: I0afb185bbf3db80dfd9595321603924454a4c2f9
      Reviewed-on: https://go-review.googlesource.com/55650Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      a0237c52
    • Martin Möhrmann's avatar
      strconv: cleanup variable declarations in ParseUint · de7e5d45
      Martin Möhrmann authored
      Move variable declarations closer to their first uses.
      
      Use an additional string variable s0 for error reporting that references
      the original input string. This allows the variable s to be modified.
      
      Change-Id: I4725152490ca1dc10c1161ad8ad2f4ae8933493f
      Reviewed-on: https://go-review.googlesource.com/55138Reviewed-by: 's avatarJoe Tsai <thebrokentoaster@gmail.com>
      Reviewed-by: 's avatarMarvin Stenger <marvin.stenger94@gmail.com>
      Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      de7e5d45
    • Martin Möhrmann's avatar
      runtime: simplify memory capacity check in growslice · 365594ad
      Martin Möhrmann authored
      Instead of comparing if the number of elements will
      not fit into memory check if the memory size of the
      slices backing memory is higher then the memory limit.
      
      This avoids a division or maxElems lookup.
      
      With et.size > 0:
         uintptr(newcap)                > maxSliceCap(et.size)
      -> uintptr(int(capmem / et.size)) > _MaxMem  /  et.size
      ->             capmem / et.size   > _MaxMem  /  et.size
      ->             capmem             > _MaxMem
      
      Note that due to integer division from capmem > _MaxMem
      it does not follow that uintptr(newcap) > maxSliceCap(et.size).
      
      Consolidated runtime GrowSlice benchmarks by using sub-benchmarks and
      added more struct sizes to show performance improvement when division
      is avoided for element sizes larger than 32 bytes.
      
      AMD64:
      GrowSlice/Byte       38.9ns ± 2%  38.9ns ± 1%    ~     (p=0.974 n=20+20)
      GrowSlice/Int        58.3ns ± 3%  58.0ns ± 2%    ~     (p=0.154 n=20+19)
      GrowSlice/Ptr        95.7ns ± 2%  95.1ns ± 2%  -0.60%  (p=0.034 n=20+20)
      GrowSlice/Struct/24  95.4ns ± 1%  93.9ns ± 1%  -1.54%  (p=0.000 n=19+19)
      GrowSlice/Struct/32   110ns ± 1%   108ns ± 1%  -1.76%  (p=0.000 n=19+20)
      GrowSlice/Struct/40   138ns ± 1%   128ns ± 1%  -7.09%  (p=0.000 n=20+20)
      
      Change-Id: I1c37857c74ea809da373e668791caffb6a5cbbd3
      Reviewed-on: https://go-review.googlesource.com/53471
      Run-TryBot: Martin Möhrmann <moehrmann@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      365594ad
    • Russ Cox's avatar
      cmd/link: implement R_X86_64_PC64 relocations · ef6978b2
      Russ Cox authored
      Change-Id: I1d7bd5cff7350a4e0f78b8efc8406e79c74732d1
      Reviewed-on: https://go-review.googlesource.com/55370Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      ef6978b2
    • Joe Tsai's avatar
      archive/tar: add support for atime and ctime to Writer · 9223adcc
      Joe Tsai authored
      Both the GNU and PAX formats support atime and ctime fields.
      The implementation is trivial now that we have:
      * support for formatting PAX records for timestamps
      * dedicated methods that only handle one format (e.g., GNU)
      
      Fixes #17876
      
      Change-Id: I0c604fce14a47d722098afc966399cca2037395d
      Reviewed-on: https://go-review.googlesource.com/55570
      Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      9223adcc
    • Joe Tsai's avatar
      archive/tar: reject bad key-value pairs for PAX records · 1da0e7e2
      Joe Tsai authored
      We forbid empty keys or keys with '=' because it leads to ambiguous parsing.
      Relevent PAX specification:
      <<<
      A keyword shall not include an <equals-sign>.
      >
      > Also, we forbid the writer from encoding records with an empty value.
      > While, this is a valid record syntactically, the semantics of an empty
      > value is that previous records with that key should be deleted.
      > Since we have no support (and probably never will) for global PAX records,
      > deletion is a non-sensible operation.
      > <<<
      > If the <value> field is zero length,
      > it shall delete any header block field,
      > previously entered extended header value,
      > or global extended header value of the same name.
      
      Fixes #20698
      Fixes #15567
      
      Change-Id: Ia29c5c6ef2e36cd9e6d7f6cff10e92b96a62f0d1
      Reviewed-on: https://go-review.googlesource.com/55571Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      1da0e7e2
    • Joe Tsai's avatar
      archive/tar: support PAX subsecond resolution times · 2bcc24e9
      Joe Tsai authored
      Add support for PAX subsecond resolution times. Since the parser
      supports negative timestamps, the formatter also handles negative
      timestamps.
      
      The relevant PAX specification is:
      <<<
      Portable file timestamps cannot be negative. If pax encounters a
      file with a negative timestamp in copy or write mode, it can reject
      the file, substitute a non-negative timestamp, or generate a
      non-portable timestamp with a leading '-'.
      >
      > <<<
      > All of these time records shall be formatted as a decimal
      > representation of the time in seconds since the Epoch.
      > If a <period> ( '.' ) decimal point character is present,
      > the digits to the right of the point shall represent the units of
      > a subsecond timing granularity, where the first digit is tenths of
      > a second and each subsequent digit is a tenth of the previous digit.
      
      Fixes #11171
      
      Change-Id: Ied108f3d2654390bc1b0ddd66a4081c2b83e490b
      Reviewed-on: https://go-review.googlesource.com/55552
      Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      2bcc24e9
    • Keith Randall's avatar
      runtime: initialize itab.hash always · fcf445dc
      Keith Randall authored
      We weren't initializing this field for dynamically-generated itabs.
      Turns out it doesn't matter, as any time we use this field we also
      generate a static itab for the interface type / concrete type pair.
      But we should initialize it anyway, just to be safe.
      
      Performance on the benchmarks in CL 44339:
      benchmark               old ns/op     new ns/op     delta
      BenchmarkItabFew-12     1040585       26466         -97.46%
      BenchmarkItabAll-12     228873499     4287696       -98.13%
      
      Change-Id: I58ed2b31e6c98b584122bdaf844fee7268b58295
      Reviewed-on: https://go-review.googlesource.com/44475Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
      fcf445dc
    • Keith Randall's avatar
      runtime: remove link field from itab · 04d6f982
      Keith Randall authored
      We don't use it any more, remove it.
      
      Change-Id: I76ce1a4c2e7048fdd13a37d3718b5abf39ed9d26
      Reviewed-on: https://go-review.googlesource.com/44474Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
      04d6f982
    • Keith Randall's avatar
      runtime: remove bad field from itab · 98d0634b
      Keith Randall authored
      Just use fun[0]==0 to indicate a bad itab.
      
      Change-Id: I28ecb2d2d857090c1ecc40b1d1866ac24a844848
      Reviewed-on: https://go-review.googlesource.com/44473Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
      98d0634b
    • Keith Randall's avatar
      runtime: new itab lookup table · 3d1699ea
      Keith Randall authored
      Keep itabs in a growable hash table.
      Use a simple open-addressable hash table, quadratic probing, power
      of two sized.
      Synchronization gets a bit more tricky. The common read path now
      has two atomic reads, one to get the table pointer and one to read
      the entry out of the table.
      
      I set the max load factor to 75%, kind of arbitrarily. There's a
      space-speed tradeoff here, and I'm not sure where we should land.
      
      Because we use open addressing the itab.link field is no longer needed.
      I'll remove it in a separate CL.
      
      Fixes #20505
      
      Change-Id: Ifb3d9a337512d6cf968c1fceb1eeaf89559afebf
      Reviewed-on: https://go-review.googlesource.com/44472
      Run-TryBot: Keith Randall <khr@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
      3d1699ea
    • Joe Tsai's avatar
      archive/tar: properly handle header-only "files" in Writer · e098e514
      Joe Tsai authored
      Certain special type-flags, specifically 1, 2, 3, 4, 5, 6,
      do not have a data section. Thus, regardless of what the size field
      says, we should not attempt to write any data for these special types.
      
      The relevant PAX and USTAR specification says:
      <<<
      If the typeflag field is set to specify a file to be of type 1 (a link)
      or 2 (a symbolic link), the size field shall be specified as zero.
      If the typeflag field is set to specify a file of type 5 (directory),
      the size field shall be interpreted as described under the definition
      of that record type. No data logical records are stored for types 1, 2, or 5.
      If the typeflag field is set to 3 (character special file),
      4 (block special file), or 6 (FIFO), the meaning of the size field is
      unspecified by this volume of POSIX.1-2008, and no data logical records shall
      be stored on the medium.
      Additionally, for type 6, the size field shall be ignored when reading.
      If the typeflag field is set to any other value, the number of logical
      records written following the header shall be (size+511)/512, ignoring
      any fraction in the result of the division.
      >>>
      
      Fixes #15565
      
      Change-Id: Id11886b723b3b13deb15221dca51c25cd778a6b5
      Reviewed-on: https://go-review.googlesource.com/55553Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      e098e514
    • Joe Tsai's avatar
      archive/tar: roundtrip reading device numbers · 17fa5a7c
      Joe Tsai authored
      Both GNU and BSD tar do not care if the devmajor and devminor values are
      set on entries (like regular files) that aren't character or block devices.
      
      While this is non-sensible, it is more consistent with the Writer to actually
      read these fields always. In a vast majority of the cases these will still
      be zero. In the rare situation where someone actually cares about these,
      at least information was not silently lost.
      
      Change-Id: I6e4ba01cd897a1b13c28b1837e102a4fdeb420ba
      Reviewed-on: https://go-review.googlesource.com/55572Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      17fa5a7c
    • Yuval Pavel Zholkover's avatar
      syscall: add missing int flag argument to utimensat · 0b06929b
      Yuval Pavel Zholkover authored
      Fixes #21437
      
      Change-Id: I55fbf5114ae1bb7f4aa1a20450e8d5309756cd5b
      Reviewed-on: https://go-review.googlesource.com/55430
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      Reviewed-by: 's avatarTobias Klauser <tobias.klauser@gmail.com>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      0b06929b
    • Ian Lance Taylor's avatar
      runtime: remove unused global variable emptystring · 67b39859
      Ian Lance Taylor authored
      Last runtime use was removed in https://golang.org/cl/133700043,
      September 2014.
      
      Replace plan9 syscall uses with plan9-specific variable.
      
      Change-Id: Ifb910c021c1419a7c782959f90b054ed600d9e19
      Reviewed-on: https://go-review.googlesource.com/55450Reviewed-by: 's avatarMartin Möhrmann <moehrmann@google.com>
      Run-TryBot: Martin Möhrmann <moehrmann@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      67b39859
    • Hiroshi Ioka's avatar
      cmd/link: improve error message · 1ee701e8
      Hiroshi Ioka authored
      ld.SymKind and objabi.RelocType have string representations,
      which is human friendly. Prefer to use it.
      
      Change-Id: I458ee0ca5866be0db8462c36cd053561a8206c95
      Reviewed-on: https://go-review.googlesource.com/55253Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      1ee701e8
    • Josh Bleecher Snyder's avatar
      runtime: refactor out tophash calculation · 44571753
      Josh Bleecher Snyder authored
      No functional changes; tophash is inlined.
      
      Change-Id: Ic8ce95b3622eafbddcfbc97f8c630ab8c5bfe7ad
      Reviewed-on: https://go-review.googlesource.com/55233
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      44571753
    • Josh Bleecher Snyder's avatar
      runtime: unify cases in mapiternext · 02ad116b
      Josh Bleecher Snyder authored
      The preceding cleanup made it clear that two cases
      (have golden data, unreachable key) are handled identically.
      Simplify the control flow to reflect that.
      
      Simplifies the code and generates shorter machine code.
      
      Change-Id: Id612e0da6679813e855506f47222c58ea6497d70
      Reviewed-on: https://go-review.googlesource.com/55093
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      02ad116b
    • Josh Bleecher Snyder's avatar
      runtime: mask a bounded slice access in hashmap evacuate · c50a9718
      Josh Bleecher Snyder authored
      Shaves a few instructions off.
      
      Change-Id: I39f1b01ae7e770d632d5e77a6aa4b5a1f123b41a
      Reviewed-on: https://go-review.googlesource.com/55090
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      c50a9718
    • Hiroshi Ioka's avatar
      cmd/go: correctly quote environment variables in -x output · 4b38200b
      Hiroshi Ioka authored
      This fixes the -x output so that when it reports environment variables they
      are correctly quoted for later execution by the shell.
      Also fix -x output to use the right path to the pack tool, and note when
      we are touching a file.
      
      Fixes #21427
      
      Change-Id: I323ef4edf9905b08bc26944b94183d8da2fa9675
      Reviewed-on: https://go-review.googlesource.com/55350Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      4b38200b
    • Hiroshi Ioka's avatar
      debug/macho: make Type implements fmt.(Go)Stringer interfaces · c3fa6f4d
      Hiroshi Ioka authored
      Fixes #21436
      
      Change-Id: I56f43e2852696c28edbcc772a54125a9a9c32497
      Reviewed-on: https://go-review.googlesource.com/55262Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      c3fa6f4d
    • Hiroshi Ioka's avatar
      cmd/link: correct Mach-O file flag · 90ffc40e
      Hiroshi Ioka authored
      Only set MH_NOUNDEFS if there are no undefined symbols.
      Doesn't seem to matter, but may as well do it right.
      
      Change-Id: I6c472e000578346c28cf0e10f24f870e3a0de628
      Reviewed-on: https://go-review.googlesource.com/55310Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      90ffc40e
  2. 14 Aug, 2017 16 commits
    • Keith Randall's avatar
      cmd/link,compile: Provide size for func types · f4abbc0e
      Keith Randall authored
      They are currently not given a size, which makes the DWARF reader
      very confused. Particularly things like [4]func() get a size of -4, not 32.
      
      Fixes #21097
      
      Change-Id: I01e754134d82fbbe6567e3c7847a4843792a3776
      Reviewed-on: https://go-review.googlesource.com/55551Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      f4abbc0e
    • Josh Bleecher Snyder's avatar
      runtime: refactor evacuate x/y handling · 77a9cb9b
      Josh Bleecher Snyder authored
      This change unifies the x and y cases.
      
      It shrinks evacuate's machine code by ~25% and its stack size by ~15%.
      
      It also eliminates a critical branch.
      Whether an entry should go to x or y is designed to be unpredictable.
      As a result, half of the branch predictions for useX were wrong.
      Mispredicting that branch can easily incur an expensive cache miss.
      Switching to an xy array allows elimination of that branch,
      which in turn reduces cache misses.
      
      Change-Id: Ie9cef53744b96c724c377ac0985b487fc50b49b1
      Reviewed-on: https://go-review.googlesource.com/54653
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      77a9cb9b
    • Josh Bleecher Snyder's avatar
      runtime: calculate k only once in mapiternext · 589fc314
      Josh Bleecher Snyder authored
      Make the calculation of k and v a bit lazier.
      None of the following code cares about indirect-vs-direct k,
      and it happens on all code paths, so check t.indirectkey earlier.
      
      Simplifies the code and reduces both machine code and stack size.
      
      Change-Id: I5ea4c0772848d7a4b15383baedb9a1f7feb47201
      Reviewed-on: https://go-review.googlesource.com/55092
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      589fc314
    • Josh Bleecher Snyder's avatar
      runtime: special case allocation of arrays of size 1 · 29e9b89b
      Josh Bleecher Snyder authored
      This avoids division and multiplication.
      Instrumentation suggests that this is a very common case.
      
      Change-Id: I2d5d5012d4f4df4c4af1f9f85ca9c323c9889c0e
      Reviewed-on: https://go-review.googlesource.com/54657
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      29e9b89b
    • Josh Bleecher Snyder's avatar
      runtime: use integer math for hashmap overLoadFactor · 733567a1
      Josh Bleecher Snyder authored
      Change-Id: I92cf39a05e738a03d956779d7a1ab1ef8074b2ab
      Reviewed-on: https://go-review.googlesource.com/54655
      Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      733567a1
    • Joe Tsai's avatar
      archive/tar: remove writeHeader and writePAXHeaderLegacy · 694875cb
      Joe Tsai authored
      Previous CLs (CL/54970, CL55231, and CL/55237) re-implemented tar.Writer
      entirely using specialized methods (writeUSTARHeader, writePAXHeader,
      and writeGNUHeader) allowing tar.Writer to entirely side-step the broken
      and buggy logic in writeHeader.
      
      Since writeHeader and writePAXHeaderLegacy is now dead-code,
      we can delete them.
      
      One minor change is that we call Writer.Flush at the start of WriteHeader.
      This used to be performed by writeHeader, but doing so in WriteHeader
      ensures each of the specialized methods can benefit from its effect.
      
      Fixes #17665
      Fixes #12594
      
      Change-Id: Iff2ef8e7310d40ac5484d2f8852fc5df25201426
      Reviewed-on: https://go-review.googlesource.com/55550Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      694875cb
    • Joe Tsai's avatar
      archive/tar: implement specialized logic for GNU format · ffd9810e
      Joe Tsai authored
      Rather than going through writeHeader, which attempts to handle all formats,
      implement writeGNUHeader, which only has an understanding of the GNU format.
      
      Currently, the implementation is nearly identical to writeUSTARHeader, except:
      * formatNumeric is used instead of formatOctal
      * the GNU magic value is used
      
      This is kept as a separate method since it makes more logical sense
      when we add support for sparse files, long filenames, and atime/ctime fields,
      which do not affect USTAR.
      
      Updates #12594
      
      Change-Id: I76efc0b39dc649efc22646dfc9867a7c165f34a8
      Reviewed-on: https://go-review.googlesource.com/55237
      Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarMartin Möhrmann <moehrmann@google.com>
      ffd9810e
    • Martin Möhrmann's avatar
      strings: use slice instead of list and array in Fields comment · d180d186
      Martin Möhrmann authored
      Change-Id: I70b839ff0ae5f015587390a82616ebb1d657d71a
      Reviewed-on: https://go-review.googlesource.com/55490Reviewed-by: 's avatarJoe Tsai <thebrokentoaster@gmail.com>
      Run-TryBot: Martin Möhrmann <moehrmann@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      d180d186
    • Martin Möhrmann's avatar
      runtime: replace some uses of newarray with newobject for maps · 248a7c7c
      Martin Möhrmann authored
      This avoids the never triggered capacity checks in newarray.
      
      Change-Id: Ib72b204adcb9e3fd3ab963defe0cd40e22d5d492
      Reviewed-on: https://go-review.googlesource.com/54731
      Run-TryBot: Martin Möhrmann <moehrmann@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      248a7c7c
    • Martin Möhrmann's avatar
      bytes: speed up Fields and FieldsFunc · 7df29b50
      Martin Möhrmann authored
      Applies the optimizations from golang.org/cl/42810 and golang.org/cl/37959
      done to the strings package to the bytes package.
      
      name                      old time/op    new time/op     delta
      Fields/ASCII/16              417ns ± 4%      118ns ± 3%    -71.65%  (p=0.000 n=10+10)
      Fields/ASCII/256            5.95µs ± 3%     0.88µs ± 0%    -85.23%  (p=0.000 n=10+7)
      Fields/ASCII/4096           92.3µs ± 1%     12.8µs ± 2%    -86.13%  (p=0.000 n=10+10)
      Fields/ASCII/65536          1.49ms ± 1%     0.25ms ± 1%    -83.14%  (p=0.000 n=10+10)
      Fields/ASCII/1048576        25.0ms ± 1%      6.5ms ± 2%    -74.04%  (p=0.000 n=10+10)
      Fields/Mixed/16              406ns ± 1%      222ns ± 1%    -45.24%  (p=0.000 n=10+9)
      Fields/Mixed/256            5.78µs ± 1%     2.27µs ± 1%    -60.73%  (p=0.000 n=9+10)
      Fields/Mixed/4096           97.9µs ± 1%     40.5µs ± 3%    -58.66%  (p=0.000 n=10+10)
      Fields/Mixed/65536          1.58ms ± 1%     0.69ms ± 1%    -56.58%  (p=0.000 n=10+10)
      Fields/Mixed/1048576        26.6ms ± 1%     12.6ms ± 2%    -52.44%  (p=0.000 n=9+10)
      FieldsFunc/ASCII/16          395ns ± 1%      188ns ± 1%    -52.34%  (p=0.000 n=10+10)
      FieldsFunc/ASCII/256        5.90µs ± 1%     2.00µs ± 1%    -66.06%  (p=0.000 n=10+10)
      FieldsFunc/ASCII/4096       92.5µs ± 1%     33.0µs ± 1%    -64.34%  (p=0.000 n=10+9)
      FieldsFunc/ASCII/65536      1.48ms ± 1%     0.54ms ± 1%    -63.38%  (p=0.000 n=10+9)
      FieldsFunc/ASCII/1048576    25.1ms ± 1%     10.5ms ± 3%    -58.24%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/16          401ns ± 1%      205ns ± 2%    -48.87%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/256        5.70µs ± 1%     1.98µs ± 1%    -65.28%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/4096       97.5µs ± 1%     35.4µs ± 1%    -63.65%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/65536      1.57ms ± 1%     0.61ms ± 1%    -61.20%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/1048576    26.5ms ± 1%     11.4ms ± 2%    -56.84%  (p=0.000 n=10+10)
      
      name                      old speed      new speed       delta
      Fields/ASCII/16           38.4MB/s ± 4%  134.9MB/s ± 3%   +251.55%  (p=0.000 n=10+10)
      Fields/ASCII/256          43.0MB/s ± 3%  290.6MB/s ± 1%   +575.97%  (p=0.000 n=10+8)
      Fields/ASCII/4096         44.4MB/s ± 1%  320.0MB/s ± 2%   +620.90%  (p=0.000 n=10+10)
      Fields/ASCII/65536        44.0MB/s ± 1%  260.7MB/s ± 1%   +493.15%  (p=0.000 n=10+10)
      Fields/ASCII/1048576      42.0MB/s ± 1%  161.6MB/s ± 2%   +285.21%  (p=0.000 n=10+10)
      Fields/Mixed/16           39.4MB/s ± 1%   71.7MB/s ± 1%    +82.20%  (p=0.000 n=10+10)
      Fields/Mixed/256          44.3MB/s ± 1%  112.8MB/s ± 1%   +154.64%  (p=0.000 n=9+10)
      Fields/Mixed/4096         41.9MB/s ± 1%  101.2MB/s ± 3%   +141.92%  (p=0.000 n=10+10)
      Fields/Mixed/65536        41.5MB/s ± 1%   95.5MB/s ± 1%   +130.29%  (p=0.000 n=10+10)
      Fields/Mixed/1048576      39.4MB/s ± 1%   82.9MB/s ± 2%   +110.28%  (p=0.000 n=9+10)
      FieldsFunc/ASCII/16       40.5MB/s ± 1%   84.9MB/s ± 2%   +109.80%  (p=0.000 n=10+10)
      FieldsFunc/ASCII/256      43.4MB/s ± 1%  127.9MB/s ± 1%   +194.58%  (p=0.000 n=10+10)
      FieldsFunc/ASCII/4096     44.3MB/s ± 1%  124.2MB/s ± 1%   +180.44%  (p=0.000 n=10+9)
      FieldsFunc/ASCII/65536    44.2MB/s ± 1%  120.6MB/s ± 1%   +173.06%  (p=0.000 n=10+9)
      FieldsFunc/ASCII/1048576  41.8MB/s ± 1%  100.2MB/s ± 3%   +139.53%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/16       39.8MB/s ± 1%   77.8MB/s ± 2%    +95.46%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/256      44.9MB/s ± 1%  129.4MB/s ± 1%   +187.97%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/4096     42.0MB/s ± 1%  115.6MB/s ± 1%   +175.08%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/65536    41.6MB/s ± 1%  107.3MB/s ± 1%   +157.75%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/1048576  39.6MB/s ± 1%   91.8MB/s ± 2%   +131.72%  (p=0.000 n=10+10)
      
      name                      old alloc/op   new alloc/op    delta
      Fields/ASCII/16              80.0B ± 0%      80.0B ± 0%       ~     (all equal)
      Fields/ASCII/256              768B ± 0%       768B ± 0%       ~     (all equal)
      Fields/ASCII/4096           9.47kB ± 0%     9.47kB ± 0%       ~     (all equal)
      Fields/ASCII/65536           147kB ± 0%      147kB ± 0%       ~     (all equal)
      Fields/ASCII/1048576        2.27MB ± 0%     2.27MB ± 0%       ~     (all equal)
      Fields/Mixed/16              96.0B ± 0%      96.0B ± 0%       ~     (all equal)
      Fields/Mixed/256              768B ± 0%       768B ± 0%       ~     (all equal)
      Fields/Mixed/4096           9.47kB ± 0%    24.83kB ± 0%   +162.16%  (p=0.000 n=10+10)
      Fields/Mixed/65536           147kB ± 0%      497kB ± 0%   +237.24%  (p=0.000 n=10+10)
      Fields/Mixed/1048576        2.26MB ± 0%     9.61MB ± 0%   +324.89%  (p=0.000 n=10+10)
      FieldsFunc/ASCII/16          80.0B ± 0%      80.0B ± 0%       ~     (all equal)
      FieldsFunc/ASCII/256          768B ± 0%       768B ± 0%       ~     (all equal)
      FieldsFunc/ASCII/4096       9.47kB ± 0%    24.83kB ± 0%   +162.16%  (p=0.000 n=10+10)
      FieldsFunc/ASCII/65536       147kB ± 0%      497kB ± 0%   +237.24%  (p=0.000 n=10+10)
      FieldsFunc/ASCII/1048576    2.27MB ± 0%     9.61MB ± 0%   +323.72%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/16          96.0B ± 0%      96.0B ± 0%       ~     (all equal)
      FieldsFunc/Mixed/256          768B ± 0%       768B ± 0%       ~     (all equal)
      FieldsFunc/Mixed/4096       9.47kB ± 0%    24.83kB ± 0%   +162.16%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/65536       147kB ± 0%      497kB ± 0%   +237.24%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/1048576    2.26MB ± 0%     9.61MB ± 0%   +324.89%  (p=0.000 n=10+10)
      
      name                      old allocs/op  new allocs/op   delta
      Fields/ASCII/16               1.00 ± 0%       1.00 ± 0%       ~     (all equal)
      Fields/ASCII/256              1.00 ± 0%       1.00 ± 0%       ~     (all equal)
      Fields/ASCII/4096             1.00 ± 0%       1.00 ± 0%       ~     (all equal)
      Fields/ASCII/65536            1.00 ± 0%       1.00 ± 0%       ~     (all equal)
      Fields/ASCII/1048576          1.00 ± 0%       1.00 ± 0%       ~     (all equal)
      Fields/Mixed/16               1.00 ± 0%       1.00 ± 0%       ~     (all equal)
      Fields/Mixed/256              1.00 ± 0%       1.00 ± 0%       ~     (all equal)
      Fields/Mixed/4096             1.00 ± 0%       5.00 ± 0%   +400.00%  (p=0.000 n=10+10)
      Fields/Mixed/65536            1.00 ± 0%      12.00 ± 0%  +1100.00%  (p=0.000 n=10+10)
      Fields/Mixed/1048576          1.00 ± 0%      24.00 ± 0%  +2300.00%  (p=0.000 n=10+10)
      FieldsFunc/ASCII/16           1.00 ± 0%       1.00 ± 0%       ~     (all equal)
      FieldsFunc/ASCII/256          1.00 ± 0%       1.00 ± 0%       ~     (all equal)
      FieldsFunc/ASCII/4096         1.00 ± 0%       5.00 ± 0%   +400.00%  (p=0.000 n=10+10)
      FieldsFunc/ASCII/65536        1.00 ± 0%      12.00 ± 0%  +1100.00%  (p=0.000 n=10+10)
      FieldsFunc/ASCII/1048576      1.00 ± 0%      24.00 ± 0%  +2300.00%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/16           1.00 ± 0%       1.00 ± 0%       ~     (all equal)
      FieldsFunc/Mixed/256          1.00 ± 0%       1.00 ± 0%       ~     (all equal)
      FieldsFunc/Mixed/4096         1.00 ± 0%       5.00 ± 0%   +400.00%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/65536        1.00 ± 0%      12.00 ± 0%  +1100.00%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/1048576      1.00 ± 0%      24.00 ± 0%  +2300.00%  (p=0.000 n=10+10)
      
      Change-Id: If1926782decc2f60d3b4b8c41c2ce7d8bdedfd8f
      Reviewed-on: https://go-review.googlesource.com/55131
      Run-TryBot: Martin Möhrmann <moehrmann@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarJoe Tsai <thebrokentoaster@gmail.com>
      7df29b50
    • Martin Möhrmann's avatar
      strconv: unify error creation in ParseUint with ParseInt · dd6880d6
      Martin Möhrmann authored
      Remove goto and use helper functions in ParseUint to create errors.
      
      Change-Id: I1c4677ae1b9980db79065a9f8ca1f2c470249505
      Reviewed-on: https://go-review.googlesource.com/55135
      Run-TryBot: Martin Möhrmann <moehrmann@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarJoe Tsai <thebrokentoaster@gmail.com>
      dd6880d6
    • Martin Möhrmann's avatar
      strconv: adjust test output and names for parseUint and parseInt · 566f390c
      Martin Möhrmann authored
      Instead of printing Atoi as function name for test failures
      print the actual function name and arguments tested.
      
      Add a base field to the parseUint64BaseTests for consistency with
      the parseInt64BaseTests tests.
      
      Change-Id: Ib9891bdb87b62672b4216625212acfe6474c70fc
      Reviewed-on: https://go-review.googlesource.com/55136
      Run-TryBot: Martin Möhrmann <moehrmann@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      Reviewed-by: 's avatarJoe Tsai <thebrokentoaster@gmail.com>
      566f390c
    • Keith Randall's avatar
      runtime: add a use of runtime.KeepAlive's argument · 2c990f45
      Keith Randall authored
      This makes sure that its argument is marked live on entry.
      We need its arg to be live so defers of KeepAlive get
      scanned correctly by the GC.
      
      Fixes #21402
      
      Change-Id: I906813e433d0e9726ca46483723303338da5b4d7
      Reviewed-on: https://go-review.googlesource.com/55150
      Run-TryBot: Keith Randall <khr@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      2c990f45
    • Dmitry Vyukov's avatar
      cmd/go: parallelize fmt · 1f631a2f
      Dmitry Vyukov authored
      Currently go fmt formats all files sequentially.
      That's a shame. Parallelize it over files.
      
      Reduces time of go fmt ./... in std lib
      from ~6.1s to ~0.9s.
      
      Reduces time of go fmt github.com/google/syzkaller/...
      from ~5.2s to ~1.8s.
      
      Change-Id: I3d27fc25326106b2a4781e13506a25c12d5bcdc5
      Reviewed-on: https://go-review.googlesource.com/45491
      Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      1f631a2f
    • Ilya Tocar's avatar
      encoding/base32: improve performance in common case · 8b2f8439
      Ilya Tocar authored
      Unroll loop to improve perfromance back to 1.8 level.
      name              old time/op    new time/op    delta
      EncodeToString-6    63.0µs ± 3%    51.7µs ± 2%  -17.94%  (p=0.000 n=10+10)
      
      name              old speed      new speed      delta
      EncodeToString-6   130MB/s ± 3%   159MB/s ± 2%  +21.83%  (p=0.000 n=10+10)
      
      Vs 1.8:
      EncodeToString-6    54.9µs ± 2%    51.7µs ± 2%   -5.95%  (p=0.000 n=10+10)
      
      name              old speed      new speed      delta
      EncodeToString-6   149MB/s ± 2%   159MB/s ± 2%   +6.32%  (p=0.000 n=10+10)
      
      Fixes #21262
      
      Change-Id: I41bf7e1f61041781386d16d573bffe1a7173c0c3
      Reviewed-on: https://go-review.googlesource.com/52510
      Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarKeith Randall <khr@golang.org>
      8b2f8439
    • Hiroshi Ioka's avatar
      cmd/link: don't link the same dylib multiple times · 1f8433c6
      Hiroshi Ioka authored
      Also, unexport Machoadddynlib
      
      n=`go test -c crypto/x509 && otool -l x509.test | grep libSystem | wc -l`
      
      Before this CL, n = 3.
      After this CL, n = 1.
      
      on my environment.
      
      Change-Id: Ic7b8157435cc85086404860dc6c84eb0aecc5d19
      Reviewed-on: https://go-review.googlesource.com/44771Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      Reviewed-by: 's avatarAvelino <t@avelino.xxx>
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      1f8433c6