1
0
mirror of https://github.com/golang/go synced 2024-11-08 03:36:12 -07:00
Commit Graph

291 Commits

Author SHA1 Message Date
Tobias Klauser
6155091042 internal/syscall/unix: omit unnecessary randomTrap check in GetRandom
The randomTrap const is initialized to a non-zero value for linux in
getrandom_linux_$GOARCH.go and for freebsd in getrandom_freebsd.go
directly since CL 16662. Thus, omit the unnecessary check.

Change-Id: Id20cd628dfe6fab9908fa5258c3132e3b422a6b4
Reviewed-on: https://go-review.googlesource.com/c/144108
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-10-24 13:43:00 +00:00
Martin Möhrmann
980340ade7 internal/cpu: add options and warnings for required cpu features
Updates #27218

Change-Id: I8603f3a639cdd9ee201c4f1566692e5b88877fc4
Reviewed-on: https://go-review.googlesource.com/c/144107
Run-TryBot: Martin Möhrmann <martisch@uos.de>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-24 06:27:53 +00:00
Lynn Boger
6994731ec2 internal/bytealg: improve asm for memequal on ppc64x
This includes two changes to the memequal function.

Previously the asm implementation on ppc64x for Equal called the internal
function memequal using a BL, whereas the other asm implementations for
bytes functions on ppc64x used BR. The BR is preferred because the BL
causes the calling function to stack a frame. This changes Equal so it
uses BR and is consistent with the others.

This also uses vsx instructions where possible to improve performance
of the compares for sizes over 32.

Here are results from the sizes affected:

Equal/32             8.40ns ± 0%     7.66ns ± 0%    -8.81%  (p=0.029 n=4+4)
Equal/4K              193ns ± 0%      144ns ± 0%   -25.39%  (p=0.029 n=4+4)
Equal/4M              346µs ± 0%      277µs ± 0%   -20.08%  (p=0.029 n=4+4)
Equal/64M            7.66ms ± 1%     7.27ms ± 0%    -5.10%  (p=0.029 n=4+4)

Change-Id: Ib6ee2cdc3e5d146e2705e3338858b8e965d25420
Reviewed-on: https://go-review.googlesource.com/c/143060
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
Reviewed-by: David Chase <drchase@google.com>
2018-10-23 19:22:44 +00:00
Peter Weinberger
daaf361f74 internal/traceparser: provide parser that uses less space and parses segments of runtime trace files
Traceparser generally takes 20-30% less space than internal/trace. The only
user of these pakcages is cmd/trace, and the new package lets it handle some
trace files that were too large. The new parser will also convert segments
of the raw trace file (e.g. the last 10 seconds) to Events. Trace files from
go 1.8 and before are not supported.

Change-Id: If83fa183246db8f75182ccd3ba8df07673c0ebd0
Reviewed-on: https://go-review.googlesource.com/c/137635
Run-TryBot: Peter Weinberger <pjw@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-10-23 14:00:14 +00:00
Clément Chigot
93eded0297 internal/syscall/unix, net: improve interface_aix.go
This commit improves the interface_aix.go file, based on feedbacks about
CL 138724.

To retrieve MTU, ioctl is needed. It's implemented inside
internal/syscall/unix.

Change-Id: Ic583d26b93935a32a5f1eb5a2170b86e80a4a85e
Reviewed-on: https://go-review.googlesource.com/c/142157
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-23 02:38:52 +00:00
Rob Pike
a440cc0d70 fmt: print maps in key-sorted order
For easier testing, change the way maps are printed so they
appear in a consistent order between runs. Do this by printing
them in key-sorted order.

To do this, we add a package at the root, internal/fmtsort,
that implements a general mechanism for sorting map keys
regardless of their type. This is a little messy and probably
slow, but formatted printing of maps has never been fast and
is already always reflection-driven.

The rules are:

The ordering rules are more general than with Go's < operator:

 - when applicable, nil compares low
 - ints, floats, and strings order by <
 - NaN compares less than non-NaN floats
 - bool compares false before true
 - complex compares real, then imag
 - pointers compare by machine address
 - channel values compare by machine address
 - structs compare each field in turn
 - arrays compare each element in turn.
 - interface values compare first by reflect.Type describing the concrete type
   and then by concrete value as described in the previous rules.

The new package is internal because we really do not want
everyone using this to sort things. It is slow, not general, and
only suitable for the subset of types that can be map keys.

Also use the package in text/template, which already had a
weaker version of this mechanism.

This change requires adding a dependency on sort to the fmt
package, but that isn't disruptive to the dependency tree.

Fixes #21095

Change-Id: Ia602115c7de5d95993dbd609611d8bd96e054157
Reviewed-on: https://go-review.googlesource.com/c/142737
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2018-10-18 21:12:24 +00:00
Martin Möhrmann
3e0227f6a0 internal/cpu: add invalid option warnings and support to enable cpu features
This CL adds the ability to enable the cpu feature FEATURE by specifying
FEATURE=on in GODEBUGCPU. Syntax support to enable cpu features is useful
in combination with a preceeding all=off to disable all but some specific
cpu features. Example:

GODEBUGCPU=all=off,sse3=on

This CL implements printing of warnings for invalid GODEBUGCPU settings:
- requests enabling features that are not supported with the current CPU
- specifying values different than 'on' or 'off' for a feature
- settings for unkown cpu feature names

Updates #27218

Change-Id: Ic13e5c4c35426a390c50eaa4bd2a408ef2ee21be
Reviewed-on: https://go-review.googlesource.com/c/141800
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-10-15 21:46:44 +00:00
Akhil Indurti
bb3bf5bb53 internal/cpu: expose ARM feature flags for FMA
This change exposes feature flags needed to implement an FMA intrinsic
on ARM CPUs via auxv's HWCAP bits. Specifically, it exposes HasVFPv4 to
detect if an ARM processor has the fourth version of the vector floating
point unit. The relevant instruction for this CL is VFMA, emitted in Go
as FMULAD.

Updates #26630.

Change-Id: Ibbc04fb24c2b4d994f93762360f1a37bc6d83ff7
Reviewed-on: https://go-review.googlesource.com/c/126315
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
2018-10-15 10:57:04 +00:00
Martin Möhrmann
4fb8b1de3c internal/cpu: use 'off' for disabling cpu capabilities instead of '0'
Updates #27218

Change-Id: I4ce20376fd601b5f958d79014af7eaf89e9de613
Reviewed-on: https://go-review.googlesource.com/c/141818
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-12 16:44:26 +00:00
Tobias Klauser
d82e51a119 internal/poll: add FD.Fsync on aix
Follow-up for CL 138717. This fixes the build of the os package on
aix.

Change-Id: I879b9360e71837ab622ae3a7b6144782cf5a9ce7
Reviewed-on: https://go-review.googlesource.com/c/141797
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-12 16:10:54 +00:00
Martin Möhrmann
a5248acd91 internal/cpu: enable support for GODEBUGCPU in non-experimental builds
Enabling GODEBUGCPU without the need to set GOEXPERIMENT=debugcpu  enables
trybots and builders to run tests for GODEBUGCPU features in upcoming CLs
that will implement the new syntax and features for non-experimental
GODEBUGCPU support from proposal golang.org/issue/27218.

Updates #27218

Change-Id: Icc69e51e736711a86b02b46bd441ffc28423beba
Reviewed-on: https://go-review.googlesource.com/c/141817
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-12 15:40:45 +00:00
Clément Chigot
86e251c938 internal/syscall: add AIX operating system
This commit adds AIX operating system to internal/syscall package for ppc64
architecture.

Updates: #25893

Change-Id: I5c3a9d4403ca170a7e894e06e68b83387d09b816
Reviewed-on: https://go-review.googlesource.com/c/138718
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-03 21:28:26 +00:00
Clément Chigot
816e493495 internal/poll: add AIX operating system
This commit adds AIX operating system to internal/poll package for ppc64
architecture.

Updates: #25893

Change-Id: I9b1da9255012de58f16547c1b18f8840485da170
Reviewed-on: https://go-review.googlesource.com/c/138717
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-10-03 21:15:18 +00:00
Zhou Peng
b8ac64a581 all: this big patch remove whitespace from assembly files
Don't worry, this patch just remove trailing whitespace from
assembly files, and does not touch any logical changes.

Change-Id: Ia724ac0b1abf8bc1e41454bdc79289ef317c165d
Reviewed-on: https://go-review.googlesource.com/c/113595
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-10-03 15:28:51 +00:00
Ian Lance Taylor
b83ef36d6a go/build: move isStandardPackage to new internal/goroot package
The module code in cmd/go sometimes needs to know whether it is
looking at a standard package, and currently uses gc-specific code for
that. This CL moves the existing isStandardPackage code in the
go/build package, which works for both gc and gccgo, into a new
internal/goroot package so that cmd/go can call it. The changes to
cmd/go will be in a subsequent CL.

Change-Id: Ic1ce4c022a932c6b3e99fa062631577085cc6ecb
Reviewed-on: https://go-review.googlesource.com/137435
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-09-25 22:07:43 +00:00
Carlos Eduardo Seo
23f7554194 internal/bytealg: improve performance of IndexByte for ppc64x
Use addi+lvx instruction fusion and remove register dependencies in
the main loop to improve performance.

benchmark                      old ns/op     new ns/op     delta
BenchmarkIndexByte/10-192      9.86          9.75          -1.12%
BenchmarkIndexByte/32-192      15.6          11.2          -28.21%
BenchmarkIndexByte/4K-192      155           97.6          -37.03%
BenchmarkIndexByte/4M-192      171790        129650        -24.53%
BenchmarkIndexByte/64M-192     6530982       5018424       -23.16%

benchmark                      old MB/s     new MB/s     speedup
BenchmarkIndexByte/10-192      1013.72      1025.76      1.01x
BenchmarkIndexByte/32-192      2049.47      2868.01      1.40x
BenchmarkIndexByte/4K-192      26422.69     41975.67     1.59x
BenchmarkIndexByte/4M-192      24415.17     32350.74     1.33x
BenchmarkIndexByte/64M-192     10275.46     13372.50     1.30x

Change-Id: Iedf17f01f374d58e85dcd6a972209bfcb7eb6063
Reviewed-on: https://go-review.googlesource.com/137415
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2018-09-25 20:25:25 +00:00
Andrei Tudor Călin
83c605fb96 internal/poll: improve Splice comments
Clarify the behavior of splice on older kernels, merge comments so
control flow becomes more obvious, as discussed in CL 133575.

Change-Id: I95855991bd0b1fa1c78a900b39c4382f65d83468
Reviewed-on: https://go-review.googlesource.com/135436
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-09-16 03:22:13 +00:00
Ben Burkert
1bf5796cae internal/poll: fall back on unsupported splice from unix socket
Gracefully fallback to a userspace copy when the kernel does not support
splice(2) on a unix domain socket. EINVAL is returned by the splice
syscall if it does not support unix domain sockets. Keeping the handled
return value as false when the first splice call fails with EINVAL will
cause the caller to fall back to a userspace copy.

Fixes #27513

Change-Id: I4b10c1900ba3c096cb32edb7c8a6044f468efb52
Reviewed-on: https://go-review.googlesource.com/133575
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2018-09-15 09:25:07 +00:00
erifan01
de28555c0b internal/bytealg: optimize Equal on arm64
Currently the 16-byte loop chunk16_loop is implemented with NEON instructions LD1, VMOV and VCMEQ.
Using scalar instructions LDP and CMP to achieve this loop can reduce the number of clock cycles.
For cases where the length of strings are between 4 to 15 bytes, loading the last 8 or 4 bytes at
a time to reduce the number of comparisons.

Benchmarks:
name                 old time/op    new time/op    delta
Equal/0-8              5.51ns ± 0%    5.84ns ±14%     ~     (p=0.246 n=7+8)
Equal/1-8              10.5ns ± 0%    10.5ns ± 0%     ~     (all equal)
Equal/6-8              14.0ns ± 0%    12.5ns ± 0%  -10.71%  (p=0.000 n=8+8)
Equal/9-8              13.5ns ± 0%    12.5ns ± 0%   -7.41%  (p=0.000 n=8+8)
Equal/15-8             15.5ns ± 0%    12.5ns ± 0%  -19.35%  (p=0.000 n=8+8)
Equal/16-8             14.0ns ± 0%    13.0ns ± 0%   -7.14%  (p=0.000 n=8+8)
Equal/20-8             16.5ns ± 0%    16.0ns ± 0%   -3.03%  (p=0.000 n=8+8)
Equal/32-8             16.5ns ± 0%    15.3ns ± 0%   -7.27%  (p=0.000 n=8+8)
Equal/4K-8              552ns ± 0%     553ns ± 0%     ~     (p=0.315 n=8+8)
Equal/4M-8             1.13ms ±23%    1.20ms ±27%     ~     (p=0.442 n=8+8)
Equal/64M-8            32.9ms ± 0%    32.6ms ± 0%   -1.15%  (p=0.000 n=8+8)
CompareBytesEqual-8    12.0ns ± 0%    12.0ns ± 0%     ~     (all equal)

Change-Id: If317ecdcc98e31883d37fd7d42b113b548c5bd2a
Reviewed-on: https://go-review.googlesource.com/112496
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
2018-09-12 19:56:55 +00:00
Lynn Boger
a0fad982b1 internal/bytealg: implement bytes.Count in asm for ppc64x
This adds an asm implementation for the Count function in ppc64x.
The Go code that manipulates a byte at a time is especially
inefficient on ppc64x, so an asm implementation is a significant
improvement.

bytes:
name               old time/op   new time/op    delta
CountSingle/10-8    23.1ns ± 0%    18.6ns ± 0%    -19.48%  (p=1.000 n=1+1)
CountSingle/32-8    60.4ns ± 0%    19.0ns ± 0%    -68.54%  (p=1.000 n=1+1)
CountSingle/4K-8    7.29µs ± 0%    0.45µs ± 0%    -93.80%  (p=1.000 n=1+1)
CountSingle/4M-8    7.49ms ± 0%    0.45ms ± 0%    -93.97%  (p=1.000 n=1+1)
CountSingle/64M-8    127ms ± 0%       9ms ± 0%    -92.53%  (p=1.000 n=1+1)

html:
name              old time/op  new time/op  delta
Escape-8          57.5µs ± 0%  36.1µs ± 0%  -37.13%  (p=1.000 n=1+1)
EscapeNone-8      20.0µs ± 0%   2.0µs ± 0%  -90.14%  (p=1.000 n=1+1)

Change-Id: Iadbf422c0e9a37b47d2d95fb8c778420f3aabb58
Reviewed-on: https://go-review.googlesource.com/131695
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
2018-09-12 15:47:43 +00:00
Alex Brainman
1705962cf9 internal/poll: handle zero-byte write in FD.WriteTo
Zero-byte write was fixed by CL 132781, that was submitted 3 days ago.
But I just submitted CL 129137, and the CL broken zero-byte write
functionality without me noticing. CL 129137 was based on old commit
(older than 3 days ago), and try-bots did not discover the breakage.

Fix zero-byte write again.

Fixes windows build.

Change-Id: Ib403b25fd25cb881963f25706eecca92b924aaa1
Reviewed-on: https://go-review.googlesource.com/134275
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2018-09-09 04:42:15 +00:00
Alex Brainman
bbf9e6db0a internal/poll: cap reads and writes to 1GB on windows
Fixes #26923

Change-Id: I62fec814220ccdf7acd8d79a133d1add3f24cf98
Reviewed-on: https://go-review.googlesource.com/129137
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-09-09 03:57:19 +00:00
Jake B
3e5b5d69dc net: ensure WriteTo on Windows sends even zero-byte payloads
This builds on:
https://github.com/golang/go/pull/27445

"...And then send change to fix windows internal/poll.FD.WriteTo - together with making TestUDPZeroBytePayload run again."
- alexbrainman - https://github.com/golang/go/issues/26668#issuecomment-408657503

Fixes #26668

Change-Id: Icd9ecb07458f13e580b3e7163a5946ccec342509
GitHub-Last-Rev: 3bf2b8b46b
GitHub-Pull-Request: golang/go#27446
Reviewed-on: https://go-review.googlesource.com/132781
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2018-09-06 09:54:01 +00:00
Alex Brainman
8359b5e134 internal/poll: advance file position in windows sendfile
Some versions of Windows (Windows 10 1803) do not set file
position after TransmitFile completes. So just use Seek
to set file position before returning from sendfile.

Fixes #25722

Change-Id: I7a49be10304b5db19dda707b13ac93d338aeb190
Reviewed-on: https://go-review.googlesource.com/131976
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Yasuhiro MATSUMOTO <mattn.jp@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-31 09:16:02 +00:00
Tobias Klauser
975f1afd85 internal/syscall/unix: remove unnecessary empty.s
After CL 130736 there are no empty function declarations this package
anymore, so empty.s is no longer needed.

Change-Id: Ic4306f10ad8a31777a3337870ce19e14c1510f3b
Reviewed-on: https://go-review.googlesource.com/131835
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-28 14:05:21 +00:00
Martin Möhrmann
eae5fc88c1 internal/bytealg: replace use of runtime.support_sse2 with cpu.X86.HasSSE2
This makes the runtime.support_sse2 variable unused
so it is removed in this CL too.

Change-Id: Ia8b9ffee7ac97128179f74ef244b10315e44c234
Reviewed-on: https://go-review.googlesource.com/131455
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-26 15:27:20 +00:00
Martin Möhrmann
05c02444eb all: align cpu feature variable offset naming
Add an "offset_" prefix to all cpu feature variable offset constants to
signify that they are not boolean cpu feature variables.

Remove _ from offset constant names.

Change-Id: I6e22a79ebcbe6e2ae54c4ac8764f9260bb3223ff
Reviewed-on: https://go-review.googlesource.com/131215
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-24 18:40:16 +00:00
Martin Möhrmann
961eb13b67 runtime: replace sys.CacheLineSize by corresponding internal/cpu const and vars
sys here is runtime/internal/sys.

Replace uses of sys.CacheLineSize for padding by
cpu.CacheLinePad or cpu.CacheLinePadSize.
Replace other uses of sys.CacheLineSize by cpu.CacheLineSize.
Remove now unused sys.CacheLineSize.

Updates #25203

Change-Id: I1daf410fe8f6c0493471c2ceccb9ca0a5a75ed8f
Reviewed-on: https://go-review.googlesource.com/126601
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-24 18:28:25 +00:00
Martin Möhrmann
60f83621fc internal/cpu: add a CacheLinePadSize constant
The new constant CacheLinePadSize can be used to compute best effort
alignment of structs to cache lines.

e.g. the runtime can use this in the locktab definition:
var locktab [57]struct {
        l   spinlock
        pad [cpu.CacheLinePadSize - unsafe.Sizeof(spinlock{})]byte
}

Change-Id: I86f6fbfc5ee7436f742776a7d4a99a1d54ffccc8
Reviewed-on: https://go-review.googlesource.com/131237
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-24 17:45:28 +00:00
Martin Möhrmann
2e8c31b3d2 runtime: move arm hardware division support detection to internal/cpu
Assumes mandatory VFP and VFPv3 support to be present by default
but not IDIVA if AT_HWCAP is not available.

Adds GODEBUGCPU options to disable the use of code paths in the runtime
that use hardware support for division.

Change-Id: Ida02311bd9b9701de3fc120697e69445bf6c0853
Reviewed-on: https://go-review.googlesource.com/114826
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-08-24 14:27:07 +00:00
Tobias Klauser
d8cf1514ca internal/syscall/unix: don't use linkname to refer to syscall.fcntl
Just open-code the fcntl syscall instead of relying on the obscurity of
go:linkname.

Change-Id: I3e4ec9db6539e016f56667d7b8b87aa37671d0e7
Reviewed-on: https://go-review.googlesource.com/130736
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-24 07:28:54 +00:00
Kazuhiro Sera
ad644d2e86 all: fix typos detected by github.com/client9/misspell
Change-Id: Iadb3c5de8ae9ea45855013997ed70f7929a88661
GitHub-Last-Rev: ae85bcf82b
GitHub-Pull-Request: golang/go#26920
Reviewed-on: https://go-review.googlesource.com/128955
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-23 15:54:07 +00:00
Emmanuel T Odeke
be10ad7622 internal/poll: use F_FULLFSYNC fcntl for FD.Fsync on OS X
As reported in #26650 and also cautioned on the man page
for fsync on OS X, fsync doesn't properly flush content
to permanent storage, and might cause corruption of data if
the OS crashes or if the drive loses power. Thus it is recommended
to use the F_FULLFSYNC fcntl, which flushes all buffered data to
permanent storage and is important for applications such as
databases that require a strict ordering of writes.

Also added a note in syscall_darwin.go that syscall.Fsync is
not invoked for os.File.Sync.

Fixes #26650.

Change-Id: Idecd9adbbdd640b9c5b02e73b60ed254c98b48b6
Reviewed-on: https://go-review.googlesource.com/130676
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-22 22:26:40 +00:00
Brad Fitzpatrick
d35135b9da internal/poll, net: fix sendfile on Windows, add test
Fixes #27085

Change-Id: I4eb3ff7c76e0b8e4d8fe0298f739b0284d74a031
Reviewed-on: https://go-review.googlesource.com/130855
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-22 21:12:00 +00:00
David Carlier
64f3d75bc2 crypto/rand: use the new getrandom syscall on FreeBSD
Since the 12.x branch, the getrandom syscall had been introduced
with similar interface as Linux's and consistent syscall id
across architectures.

Change-Id: I63d6b45dbe9e29f07f1b5b6c2ec8be4fa624b9ee
GitHub-Last-Rev: 6fb76e6522
GitHub-Pull-Request: golang/go#25976
Reviewed-on: https://go-review.googlesource.com/120055
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-22 01:49:02 +00:00
Ian Lance Taylor
cd7cb86d8e runtime: don't use linkname to refer to internal/cpu
The runtime package already imports the internal/cpu package, so there
is no reason for it to use go:linkname comments to refer to
internal/cpu functions and variables. Since internal/cpu is internal,
we can just export those names. Removing the obscurity of go:linkname
outweighs the minor additional complexity added to the internal/cpu API.

Change-Id: Id89951b7f3fc67cd9bce67ac6d01d44a647a10ad
Reviewed-on: https://go-review.googlesource.com/128755
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
2018-08-21 14:36:09 +00:00
Shivansh Rai
d05f31a3c5 internal/poll: Avoid evaluating condition for an unreachable branch
Change-Id: I868dcaf84767d631bc8f1b6ef6bcb3ec18047259
Reviewed-on: https://go-review.googlesource.com/116135
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-20 21:50:00 +00:00
Martin Möhrmann
7b9c2c1950 internal/cpu: add and use cpu.CacheLinePad for padding structs
Add a CacheLinePad struct type to internal/cpu that has a size of CacheLineSize.
This can be used for padding structs in order to avoid false sharing.

Updates #25203

Change-Id: Icb95ae68d3c711f5f8217140811cad1a1d5be79a
Reviewed-on: https://go-review.googlesource.com/116276
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-20 15:41:37 +00:00
Martin Möhrmann
21ac811924 internal/cpu: make all constants for s390x feature detection typed
Only the first constant in the function and facility
constant declaration blocks were typed constants.
Make all other constants used for function codes and
named facilities also typed.

Change-Id: I1814121de3733094da699c78b7311f99ba4772e1
Reviewed-on: https://go-review.googlesource.com/126776
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-20 15:13:39 +00:00
Martin Möhrmann
2556df0ac0 internal/cpu: remove parentheses from arm64 feature constants
The parentheses are not required for the definitions and it brings
the declaration style in line with other architectures feature bits
defined in internal/cpu.

Change-Id: I86cc3812c1488216779e0d1f0e7481687502e592
Reviewed-on: https://go-review.googlesource.com/126775
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-08-20 14:33:26 +00:00
Brad Fitzpatrick
4b74506da1 doc: update the minimum support Windows version
Also, remove some test code that was trying to work on XP and fix up
some comments referencing XP.

Fixes #26191
Updates #23380

Change-Id: I0b7319fe1954afddb22d396e5ec91d8c960268d8
Reviewed-on: https://go-review.googlesource.com/123415
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-07-11 22:05:38 +00:00
Ian Lance Taylor
8d6fc84986 internal/poll: don't take read lock in SetBlocking
Taking a read lock in SetBlocking could cause SetBlocking to block
waiting for a Read in another goroutine to complete. Since SetBlocking
is called by os.(*File).Fd, that could lead to deadlock if the
goroutine calling Fd is going to use it to unblock the Read.
Use an atomic store instead.

Updates #24481

Change-Id: I79413328e06ddf28b6d5b8af7a0e29d5b4e1e6ff
Reviewed-on: https://go-review.googlesource.com/123176
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-07-11 00:34:18 +00:00
Keith Randall
be9c994609 internal/bytealg: specify argmaps for exported functions
Functions exported on behalf of other packages need to have their
argument stack maps specified explicitly.  They don't get an implicit
map because they are not in the local package, and if they get defer'd
they need argument maps.

Fixes #24419

Change-Id: I35b7d8b4a03d4770ba88699e1007cb3fcb5397a9
Reviewed-on: https://go-review.googlesource.com/122676
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-07-10 17:13:53 +00:00
bill_ofarrell
a5f8128e39 bytes, strings: fix comparison of long byte slices on s390x
The existing implementation of bytes.Compare on s390x doesn't work properly for slices longer
than 256 elements. This change fixes that. Added tests for long strings and slices of bytes.

Fixes #26114

Change-Id: If6d8b68ee6dbcf99a24f867a1d3438b1f208954f
Reviewed-on: https://go-review.googlesource.com/121495
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-29 20:48:07 +00:00
Dmitri Shuralyov
257d6c48e0 internal/syscall/unix: add build constraint to nonblocking_js.go
The intention was for this file to be constrained to both js and wasm,
but the build constraint was missing, causing it to be constrained only
to js because of the _js suffix in the filename.

Add a js,wasm build constraint. The js part is redundant, but specified
anyway to make it more visible and consistent with other similar files.

This issue was spotted while working on GopherJS, because it was causing
a conflict there (both nonblocking.go and nonblocking_js.go files were
being matched).

Change-Id: Ifc6843269e1108fe61b1723be25a12254e806fd4
Reviewed-on: https://go-review.googlesource.com/121275
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-28 03:12:01 +00:00
Brad Fitzpatrick
3dced519cb syscall, internal/poll: fix build on js/wasm
Fixes #26014

Change-Id: I9d92414a9181c5d189e3e266666950656bf00406
Reviewed-on: https://go-review.googlesource.com/120576
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-22 17:58:16 +00:00
Ian Lance Taylor
00eac8921e os, net: avoid races between dup, set-blocking-mode, and closing
Fixes #24481
Fixes #24483

Change-Id: Id7da498425a440c91582aa5480c253ae7a9c932c
Reviewed-on: https://go-review.googlesource.com/119955
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-22 14:27:22 +00:00
Andrei Tudor Călin
24fb2e015a internal/poll: use more fine-grained locking in Splice
The previous code acquired a read lock on src and a write lock on
dst for the entire duration of Splice. This resulted in deadlock,
in a situation akin to the following:

Splice is blocking, waiting to read from src.

The caller tries to close dst from another goroutine, but Close on
dst blocks in runtime.semacquire, because Splice is still holding a
write lock on it, and the Close didn't unblock any I/O.

The caller cannot unblock the read side of Splice through other means,
because they are stuck waiting in dst.Close().

Use more fine-grained locking instead: acquire the read lock on src
just before trying to splice from the source socket to the pipe,
and acquire the write lock on dst just before trying to splice from
the pipe to the destination socket.

Fixes #25985

Change-Id: I264c91c7a69bb6c5e28610e2bd801244804cf86d
Reviewed-on: https://go-review.googlesource.com/120317
Run-TryBot: Aram Hăvărneanu <aram@mgk.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-21 22:13:34 +00:00
Ian Lance Taylor
3ca5b7c5b2 internal/poll: better panic message for lock overflow
Instead of "inconsistent poll.fdMutex", panic with
"too many concurrent operations on a single file or socket (max 1048575)".

Fixes #25558

Change-Id: I5cad3633aa539fb6f48cca236c6656c86acfb663
Reviewed-on: https://go-review.googlesource.com/119956
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2018-06-20 16:55:30 +00:00
Richard Musiol
c12399fffb all: enable vet/all for js/wasm and fix vet issues
This commit enables vet/all for the js/wasm architecture. It got
skipped initially because the codebase did not fully compile yet
for js/wasm, which made vet/all fail.

startTimer and stopTimer are not needed in the syscall package.
Removed their assembly code since their Go stubs were already gone.

Change-Id: Icaeb6d903876e51ceb1edff7631f715a98c28696
Reviewed-on: https://go-review.googlesource.com/118657
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-15 00:05:22 +00:00