Commit Graph

46441 Commits

Author SHA1 Message Date
Rob Findley
168d6a49a5 [dev.regabi] go/types: use 512 bits as max. integer precision
This is a port of CL 288633 to go/types. It differs from that CL
in the implementation of opName, which now uses ast Exprs.

Additionally, a couple tests had to be updated:
 + TestEvalArith is updated to not overflow.
 + stmt0.src is updated to have an error positioned on the '<<'
   operator.

Change-Id: I628357c33a1e7b0bb5bb7de5736f1fb10ce404e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/290630
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-02-09 14:17:01 +00:00
Rob Findley
0a62067708 [dev.regabi] go/types: adjust importer to match compiler importer
This is an exact port of CL 288632 to go/types.

Change-Id: Ie46e13355bdd0713b392e042844bab8491a16504
Reviewed-on: https://go-review.googlesource.com/c/go/+/290629
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-02-09 14:15:43 +00:00
Rob Findley
1c58fcf7ed [dev.regabi] go/types: handle untyped constant arithmetic overflow
This is a port of CL 287832 for go/types. It differs from that CL in its
handling of position data. Unlike the syntax package, which has a
unified Operation node, go/types checks operations for ast.UnaryExpr,
IncDecStmt, and BinaryExpr. It was simpler to keep the existing position
logic. Notably, this correctly puts the errors on the operator.

Change-Id: Id1e3aefe863da225eb0a9b3628cfc8a5684c0c4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/290569
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Findley <rfindley@google.com>
2021-02-09 14:15:25 +00:00
Rob Findley
493363ccff [dev.regabi] go/types: must not import a package called "init"
This is a port of CL 287494 to go/types. The additional checks in
test/fixedbugs are included, though they won't be executed by go/types.
Support for errorcheckdir checks will be added to go/types in a later
CL.

Change-Id: I37e202ea5daf7d7b8fc6ae93a4c4dbd11762480f
Reviewed-on: https://go-review.googlesource.com/c/go/+/290570
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-02-09 14:00:14 +00:00
Rob Findley
c48d1503ba [dev.regabi] go/types: report unused packages in source order
This is a port of CL 287072 to go/types.

Change-Id: I08f56995f0323c1f238d1b44703a481d393471d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/289720
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-02-09 03:59:20 +00:00
Rob Findley
813958f13c [dev.regabi] go/types: factor out sorting of methods
This is a port of CL 285993 to go/types.

Change-Id: I7560cf1176fea5de2c54786a086e547c73294a60
Reviewed-on: https://go-review.googlesource.com/c/go/+/289717
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-02-09 03:57:38 +00:00
Rob Findley
11d15c171b [dev.regabi] go/types: convert untyped arguments to delete
This is a port of CL 285059 to go/types. The error assertion is updated
to match go/types error for assignment, which has been improved.

Change-Id: Icdd2751edea0abef7c84feadcbf9265d71239ade
Reviewed-on: https://go-review.googlesource.com/c/go/+/289716
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-02-09 03:28:12 +00:00
Rob Findley
618e3c15bd [dev.regabi] go/types: consistently report nil type as "untyped nil"
This is a port of CL 284052 to go/types. The port is not entirely
faithful, as untyped conversion has been refactored in go/types.
Additionally, a comment was added to reference issue #13061 in the
implicitType method.

For #13061

Change-Id: Iec17611f6432c988624023d1d74121ff34eb0c83
Reviewed-on: https://go-review.googlesource.com/c/go/+/289715
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-02-08 23:25:48 +00:00
Cherry Zhang
50449de66a [dev.regabi] all: merge master (1901853) into dev.regabi
Merge List:

+ 2021-02-08 1901853098 runtime/metrics: fix panic in readingAllMetric example
+ 2021-02-08 ed3e4afa12 syscall/plan9: remove spooky fd action at a distance
+ 2021-02-05 724d0720b3 doc/go1.16: add missed heading tag in vet section
+ 2021-02-05 b54cd94d47 embed, io/fs: clarify that leading and trailing slashes are disallowed
+ 2021-02-05 4516afebed testing/fstest: avoid symlink-induced failures in tester
+ 2021-02-04 8869086d8f runtime: fix typo in histogram.go
+ 2021-02-03 e491c6eea9 math/big: fix comment in divRecursiveStep

Change-Id: I5e2bd18f42251eeb4ad0bf5c93a08c6a9b873d7b
2021-02-08 14:01:08 -05:00
Cherry Zhang
7b0dfb177f [dev.regabi] runtime: use g register in some assembly functions on AMD64
Now that we have a g register, just use it.

Note: functions that can be called from ABI0 context (e.g.
morestack) is unchanged. Functions that switch g is also
unchanged, because we need to set the new g in both the register
and TLS.

TODO: other OSes.

Change-Id: I692a82a7caa8417ff620a59676a6275f56747b94
Reviewed-on: https://go-review.googlesource.com/c/go/+/289718
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-02-08 18:48:12 +00:00
Cherry Zhang
2e60c00f56 [dev.regabi] cmd/internal/obj/x86: use g register in stack bounds check
In ABIInternal context, we can directly use the g register for
stack bounds check.

Change-Id: I8b1073a3343984a6cd76cf5734ddc4a8cd5dc73f
Reviewed-on: https://go-review.googlesource.com/c/go/+/289711
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2021-02-08 17:49:38 +00:00
Cherry Zhang
22f9e1ccbc [dev.regabi] runtime: initialize special registers before sigpanic
In case that we are panicking in ABI0 context or external code,
special registers are not initialized. Initialized them in
injected code before calling sigpanic.

TODO: Windows, Plan 9.

Change-Id: I0919b80e7cc55463f3dd94f1f63cba305717270a
Reviewed-on: https://go-review.googlesource.com/c/go/+/289710
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-02-08 17:48:48 +00:00
Cherry Zhang
5d7dc53888 [dev.regabi] cmd/compile, runtime: reserve R14 as g registers on AMD64
This is a proof-of-concept change for using the g register on
AMD64. getg is now lowered to R14 in the new ABI. The g register
is not yet used in all places where it can be used (e.g. stack
bounds check, runtime assembly code).

Change-Id: I10123ddf38e31782cf58bafcdff170aee0ff0d1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/289196
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: David Chase <drchase@google.com>
2021-02-08 16:30:07 +00:00
Changkun Ou
1901853098 runtime/metrics: fix panic in readingAllMetric example
medianBucket can return if the total is greater than thresh.
However, if a histogram has no counts, total and thresh
will both be zero and cause panic.

Adding an equal sign to prevent the potential panic.

Fixes #44148

Change-Id: Ifb8a781990f490d142ae7c035b4e01d6a07ae04d
Reviewed-on: https://go-review.googlesource.com/c/go/+/290171
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-02-08 16:09:01 +00:00
Ori Bernstein
ed3e4afa12 syscall/plan9: remove spooky fd action at a distance
Change Plan 9 fork/exec to use the O_CLOEXEC file
descriptor, instead of relying on spooky at a
distance.

Historically, Plan 9 has set the O_CLOEXEC flag on
the underlying channels in the kernel, rather
than the file descriptors -- if two fds pointed
at a single channel, as with dup, changing the
flags on one of them would be observable on the
other.

The per-Chan semantics are ok, if unexpected,
when a chan is only handled within a single
process, but this isn't always the case.

Forked processes share Chans, but even more of
a problem is the interaction between /srv and
OCEXEC, which can lead to unexectedly closed
file descriptors in completely unrelated
proceses. For example:

	func exists() bool {
		// If some other thread execs here,
		// we don't want to leak the fd, so
		// open it O_CLOEXEC
		fd := Open("/srv/foo", O_CLOEXEC)
		if fd != -1 {
			Close(fd)
			return true
		}
		return false
	}

would close the connection to any file descriptor
(maybe even for the root fs) in ALL other processes
that have it open if an exec were to happen(!),
which is quite undesriable.

As a result, 9front will be changing this behavior
for the next release.

Go is the only code observed so far that relies on
this behavior on purpose, and  It's easy to make the
code work with both semantics: simply using the file
descriptor that was opened with O_CEXEC instead of
throwing it away.

So we do that here.

Fixes #43524

Change-Id: I4887f5c934a5e63e5e6c1bb59878a325abc928d3
GitHub-Last-Rev: 96bb21bd1e
GitHub-Pull-Request: golang/go#43533
Reviewed-on: https://go-review.googlesource.com/c/go/+/281833
Reviewed-by: David du Colombier <0intro@gmail.com>
Reviewed-by: Richard Miller <millerresearch@gmail.com>
Reviewed-by: Jacob Moody <j4kem00dy@gmail.com>
Run-TryBot: David du Colombier <0intro@gmail.com>
Trust: Ian Lance Taylor <iant@golang.org>
2021-02-08 15:56:59 +00:00
Cherry Zhang
a21de9ec73 [dev.regabi] cmd/link: resolve symbol ABI in shared linkage
In shared build mode and linkage, currently we assume all
function symbols are ABI0 (except for generated type algorithm
functions), and alias them to ABIInternal. When the two ABIs
actually differ (as it is now), this is not actually correct.
This CL resolves symbol ABI based on their mangled names.
If the symbol's name has a ".abi0" or ".abiinternal" suffix, it
is of the corresponding ABI. The symbol without the suffix is
the other ABI. For functions without ABI wrapper generated,
only one ABI exists but we don't know what it is, so we still
use alias (for now).

Change-Id: I2165f149bc83d513e81eb1eb4ee95464335b0e75
Reviewed-on: https://go-review.googlesource.com/c/go/+/289289
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-02-08 15:50:35 +00:00
KimMachineGun
724d0720b3 doc/go1.16: add missed heading tag in vet section
Add missed heading tag in CL 276373.

For #40700

Change-Id: Ida9e8861589bbc296a5a1cecbf9fe33fa09ed0ca
GitHub-Last-Rev: d218f8d4b7
GitHub-Pull-Request: golang/go#44111
Reviewed-on: https://go-review.googlesource.com/c/go/+/289869
Reviewed-by: Tim King <taking@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Tim King <taking@google.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2021-02-05 23:13:11 +00:00
Jay Conrod
b54cd94d47 embed, io/fs: clarify that leading and trailing slashes are disallowed
Fixes #44012

Change-Id: I5782cea301a65ae12ba870ff1e6b2e0a2651dc09
Reviewed-on: https://go-review.googlesource.com/c/go/+/290071
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
2021-02-05 22:35:11 +00:00
Russ Cox
4516afebed testing/fstest: avoid symlink-induced failures in tester
Do not require directory entry and Stat result to match for symlinks,
because they won't (Stat dereferences the symlink).

Fixes #44113.

Change-Id: Ifc6dbce5719906e2f42254a7172f1ef787464a9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/290009
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-02-05 21:03:18 +00:00
Cherry Zhang
8fa84772ba [dev.regabi] runtime: delete gosave function
The runtime.gosave function is not used anywhere. Delete.

Note: there is also a gosave<> function, which is actually used
and not deleted.

Change-Id: I64149a7afdd217de26d1e6396233f2becfad7153
Reviewed-on: https://go-review.googlesource.com/c/go/+/289719
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-02-05 20:05:30 +00:00
Cherry Zhang
946351d5a2 [dev.regabi] runtime: zero X15 in racecall
racecall can be called in ABIInternal context (e.g. raceread
calling racecalladdr calling racecall) without wrapper. racecall
calls C code, which doesn't preserve our special registers. Set
them explicitly in racecall upon returning from C.

Change-Id: Ic990479c1fca6bb8a3b151325c7a89be8331a530
Reviewed-on: https://go-review.googlesource.com/c/go/+/289709
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2021-02-05 17:34:54 +00:00
Cherry Zhang
397a46a10a [dev.regabi] cmd/asm: define g register on AMD64
Define g register as R14 on AMD64. It is not used now, but will
be in later CLs.

The name "R14" is still recognized.

Change-Id: I9a066b15bf1051113db8c6640605e350cea397b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/289195
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-02-05 17:34:26 +00:00
Cherry Zhang
e79c2fd428 [dev.regabi] runtime: mark racecallbackthunk as ABIInternal
racecallbackthunk is called from C, and it needs to follow C ABI.
The assembly code preserves C callee-save registers. It must not
be called via wrappers, which may not preserve those registers.

Change-Id: Icd72c399f4424d73c4882860d85057fe2671f6aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/289194
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-02-05 16:52:30 +00:00
Cherry Zhang
7cc6de59f2 [dev.regabi] runtime: don't mark rt0_go ABIInternal
rt0_go is not actually ABIInternal, and it actually has callers
(e.g. _rt0_amd64).

Change-Id: Id730176e620ad9f443e6bfca6ded81a1367531ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/289193
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-02-05 16:52:18 +00:00
Cherry Zhang
63de211014 [dev.regabi] runtime/cgo: call setg_gcc in crosscall_amd64
Currently, when using cgo, the g pointer is set via a separate
call to setg_gcc or with inline assembly in threadentry. This CL
changes it to call setg_gcc in crosscall_amd64, like other g-
register platforms. When we have an actual g register on AMD64,
we'll need to set the register immediately before calling into
Go.

Change-Id: Ib1171e05cd0dabba3b7d12e072084d141051cf3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/289192
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-02-05 16:09:50 +00:00
Rob Findley
120b819f45 [dev.regabi] go/types: report error for invalid main function signature
This is a port of CL 279424, which didn't make it into master in time
for go1.16. Move it to dev.regabi so that it may be merged.

Notably, this port no longer removes the _InvalidInitSig error code,
instead opting to deprecate it. Now that error codes are 'locked in' for
go1.16, even if their API may not yet be exposed, we should follow the
practice of not changing their values. In the future, code generation
can make it easier to keep error code values constant.

For #43308

Change-Id: I5260b93fd063393d38d6458e45a67e7f9b7426ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/289714
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-02-04 20:43:49 +00:00
Cherry Zhang
52d5cb2822 [dev.regabi] cmd/internal/obj: access Attribute atomically
Symbol's Attributes and ABI are in the same word. In the
concurrent backend, we may read one symbol's ABI (the callee)
while setting its attributes in another goroutine.

Fix racecompile build.

Change-Id: I500e869bafdd72080119ab243db94eee3afcf926
Reviewed-on: https://go-review.googlesource.com/c/go/+/289290
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-02-04 20:25:59 +00:00
Rob Findley
bc451b5770 [dev.regabi] go/types: port check_test.go ergonomics from dev.typeparams
On the dev.typeparams and dev.go2go branches, check_test.go has been
updated to automatically discover test data. This is convenient, so port
it to dev.regabi.

Change-Id: I5da9a9a5139c35a2693e64364eb9928ece1cd7c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/289713
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-02-04 17:13:55 +00:00
Rob Findley
afd67f3334 [dev.regabi] go/types: no "declared but not used" errors for invalid var decls
This is a port of CL 274615, adapted to go/types. The only change was in
the positioning of expected errors in vardecl.src: in go/types they are
positioned on the identifier.

Change-Id: Iab03265a7c4287749373e4380c6db6a95f262f30
Reviewed-on: https://go-review.googlesource.com/c/go/+/289712
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-02-04 17:13:14 +00:00
Ikko Ashimine
8869086d8f runtime: fix typo in histogram.go
indicies -> indices

Change-Id: Ia50ae5918fc7a53c23590a94a18087a99bfd9bb7
GitHub-Last-Rev: 98eb724275
GitHub-Pull-Request: golang/go#44095
Reviewed-on: https://go-review.googlesource.com/c/go/+/289529
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Keith Randall <khr@golang.org>
2021-02-04 04:46:49 +00:00
Cherry Zhang
401d7e5a24 [dev.regabi] cmd/compile: reserve X15 as zero register on AMD64
In ABIInternal, reserve X15 as constant zero, and use it to zero
memory. (Maybe there can be more use of it?)

The register is zeroed when transition to ABIInternal from ABI0.

Caveat: using X15 generates longer instructions than using X0.
Maybe we want to use X0?

Change-Id: I12d5ee92a01fc0b59dad4e5ab023ac71bc2a8b7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/288093
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2021-02-03 22:44:53 +00:00
Cherry Zhang
bfc7418e6d [dev.regabi] runtime, syscall, etc.: mark Darwin syscall wrappers as ABIInternal
Mark the syscall wrappers as ABIInternal, as they have addresses
taken from Go code, and it is important to call to them without
wrappers.

Previously, the wrapper is just a single JMP instruction, which
makes it not matter. In the next CL we'll make the wrapper
actually have a frame. The real wrappers will mess up things
such as stack alignment for C ABI.

This doesn't look really nice, but I don't know how we can do
better...

TODO: other OSes.

Change-Id: Ifb3920494990a7775e3e6902fbcaf137df3cc653
Reviewed-on: https://go-review.googlesource.com/c/go/+/288092
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-02-03 22:43:42 +00:00
Katie Hockman
e491c6eea9 math/big: fix comment in divRecursiveStep
There appears to be a typo in the description of
the recursive division algorithm.

Two things seem suspicious with the original comment:
  1. It is talking about choosing s, but s doesn't
     appear anywhere in the equation.
  2. The math in the equation is incorrect.

Where
  B = len(v)/2
  s = B - 1

Proof that it is incorrect:
    len(v) - B >= B + 1
    len(v) - len(v)/2 >= len(v)/2 + 1

    This doesn't hold if len(v) is even, e.g. 10:
    10 - 10/2 >= 10/2 + 1
    10 - 5 >= 5 + 1
    5 >= 6  // this is false

The new equation will be the following,
which will be mathematically correct:
    len(v) - s >= B + 1
    len(v) - (len(v)/2 - 1) >= len(v)/2 + 1
    len(v) - len(v)/2 + 1 >= len(v)/2 + 1
    len(v) - len(v)/2 >= len(v)/2

    This holds if len(v) is even or odd.

    e.g. 10
    10 - 10/2 >= 10/2
    10 - 5 >= 5
    5 >= 5

    e.g. 11
    11 - 11/2 >= 11/2
    11 - 5 >= 5
    6 >= 5

Change-Id: If77ce09286cf7038637b5dfd0fb7d4f828023f56
Reviewed-on: https://go-review.googlesource.com/c/go/+/287372
Run-TryBot: Katie Hockman <katie@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Trust: Katie Hockman <katie@golang.org>
2021-02-03 15:04:02 +00:00
Robert Griesemer
23b0c1f76e [dev.regabi] all: merge master (fca94ab) into dev.regabi
Conflicts:

- src/syscall/mksyscall.pl

Merge List:

+ 2021-02-02 fca94ab3ab spec: improve the example in Type assertions section
+ 2021-02-02 98f8454a73 cmd/link: don't decode type symbol in shared library in deadcode
+ 2021-02-02 1426a571b7 cmd/link: fix off-by-1 error in findShlibSection
+ 2021-02-01 32e789f4fb test: fix incorrectly laid out instructions in issue11656.go
+ 2021-02-01 0b6cfea634 doc/go1.16: document that on OpenBSD syscalls are now made through libc
+ 2021-02-01 26e29aa15a cmd/link: disable TestPIESize if CGO isn't enabled
+ 2021-02-01 6ac91e460c doc/go1.16: minor markup fixes
+ 2021-01-29 44361140c0 embed: update docs for proposal tweaks
+ 2021-01-29 68058edc39 runtime: document pointer write atomicity for memclrNoHeapPointers
+ 2021-01-28 c8bd8010ff syscall: generate readlen/writelen for openbsd libc
+ 2021-01-28 41bb49b878 cmd/go: revert TestScript/build_trimpath to use ioutil.ReadFile
+ 2021-01-28 725a642c2d runtime: correct syscall10/syscall10X on openbsd/amd64
+ 2021-01-28 4b068cafb5 doc/go1.16: document go/build/constraint package
+ 2021-01-28 376518d77f runtime,syscall: convert syscall on openbsd/arm64 to libc
+ 2021-01-27 00f2ff5c94 api/go1.16: add go/build/constraint APIs
+ 2021-01-27 35334caf18 crypto/x509: remove leftover CertificateRequest field
+ 2021-01-27 a5a5e2c968 runtime: make sure to remove open-coded defer entries in all cases after a recover
+ 2021-01-27 8cfa01943a runtime: block console ctrlhandler when the signal is handled
+ 2021-01-27 ff9e8364c6 cmd/go: skip issue33139 when the 'cc' script command is unavailable
+ 2021-01-27 cd176b3615 runtime: switch runtime to libc for openbsd/arm64
+ 2021-01-27 6c8fbfbdcf runtime: convert openbsd/arm64 locking to libc
+ 2021-01-27 5cdf0da1bf syscall: clean up mkasm related changes
+ 2021-01-27 210f70e298 doc/go1.16: fix closing brace in .Export format
+ 2021-01-27 0f797f168d math: fix typo in sqrt.go code comment
+ 2021-01-26 8634a234df runtime,syscall: convert syscall on openbsd/amd64 to libc
+ 2021-01-26 1d5e14632e os: further document limitations around naked file descriptors
+ 2021-01-26 cf263e9f77 os: correct names in CreateTemp and MkdirTemp doc comments
+ 2021-01-26 ce8b318624 net/http/fcgi: remove locking added to prevent a test-only race

Change-Id: I9e89df040dfbbeb50f4ce653a8da437cb72b3ef9
2021-02-02 10:27:02 -08:00
task4233
fca94ab3ab spec: improve the example in Type assertions section
The example, var v, ok T1 = x.(T), can be interpreted as type T1 interface{} or type T = bool; type T1 = T.
Separating the example would help understanding for readers.

Change-Id: I179f4564e67f4d503815d29307df2cebb50c82f9
GitHub-Last-Rev: b34fffb6bb
GitHub-Pull-Request: golang/go#44040
Reviewed-on: https://go-review.googlesource.com/c/go/+/288472
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Robert Griesemer <gri@golang.org>
2021-02-02 16:35:53 +00:00
Cherry Zhang
98f8454a73 cmd/link: don't decode type symbol in shared library in deadcode
In the linker's deadcode pass we decode type symbols for
interface satisfaction analysis. When linking against Go shared
libraries, the type symbol may come from a shared library, so it
doesn't have data in the current module being linked, so we cannot
decode it. We already have code to skip DYNIMPORT symbols. However,
this doesn't actually work, because at that point the type symbols'
names haven't been mangled, whereas they may be mangled in the
shared library. So the symbol definition (in shared library) and
reference (in current module) haven't been connected.

Skip decoding type symbols of type Sxxx (along with DYNIMPORT)
when linkShared.

Note: we cannot skip all type symbols, as we still need to mark
unexported methods defined in the current module.

Fixes #44031.

Change-Id: I833d19a060c94edbd6fc448172358f9a7d760657
Reviewed-on: https://go-review.googlesource.com/c/go/+/288496
Trust: Cherry Zhang <cherryyz@google.com>
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-02-02 16:00:58 +00:00
Cherry Zhang
1426a571b7 cmd/link: fix off-by-1 error in findShlibSection
We want to find a section that contains addr. sect.Addr+sect.Size
is the exclusive upper bound.

Change-Id: If2cd6bdd6e03174680e066189b0f4bf9e2ba6630
Reviewed-on: https://go-review.googlesource.com/c/go/+/288592
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-02-02 15:59:11 +00:00
Tom Thorogood
32e789f4fb test: fix incorrectly laid out instructions in issue11656.go
CL 279423 introduced a regression in this test as it incorrectly laid
out various instructions. In the case of arm, the second instruction
was overwriting the first. In the case of 386, amd64 and s390x, the
instructions were being appended to the end of the slice after 64
zero bytes.

This was causing test failures on "linux/s390x on z13".

Fixes #44028

Change-Id: Id136212dabdae27db7e91904b0df6a3a9d2f4af4
Reviewed-on: https://go-review.googlesource.com/c/go/+/288278
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-02-01 21:38:01 +00:00
Dan Scales
ca6999e27c [dev.regabi] test: add a test for inlining closures
Add a test case for issue 43818. We don't want to mark as inlinable a
function with a closure that has an operation (such as OSELRECV2) that
we don't currently support for exporting. This test case fails to
compile without the fix for #43818.

Updates #43818

Change-Id: Ief322a14aefaefc6913c40a6b8505214bd622fda
Reviewed-on: https://go-review.googlesource.com/c/go/+/288392
Run-TryBot: Dan Scales <danscales@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
2021-02-01 18:28:05 +00:00
Cherry Zhang
0b6cfea634 doc/go1.16: document that on OpenBSD syscalls are now made through libc
Updates #36435, #40700.

Change-Id: I1e2ded111ad58066cc9f2c9d00e719497b0f34d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/287634
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
2021-02-01 16:54:54 +00:00
Nehal J Wani
26e29aa15a cmd/link: disable TestPIESize if CGO isn't enabled
With CGO disabled, the test throws the following error:

elf_test.go:291: # command-line-arguments
    loadinternal: cannot find runtime/cgo

Change-Id: Iaeb183562ab637c714240b49e73078bdb791b35b
GitHub-Last-Rev: f8fe9afad5
GitHub-Pull-Request: golang/go#43911
Reviewed-on: https://go-review.googlesource.com/c/go/+/286632
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
2021-02-01 15:52:59 +00:00
Toshihiro Shiino
6ac91e460c doc/go1.16: minor markup fixes
Add missing <code> tags.
Remove unnecessary <br> tag.

For #40700

Change-Id: I03d3ce1c89a9ae3d3195dcd2bb8b1a61f011e1ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/288275
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
2021-02-01 05:14:58 +00:00
Ian Lance Taylor
44361140c0 embed: update docs for proposal tweaks
//go:embed variables can be type aliases.

//go:embed variables can't be local to a function.

For #43216
For #43602
Fixes #43978

Change-Id: Ib1d104dfa32b97c91d8bfc5ed5d461ca14da188f
Reviewed-on: https://go-review.googlesource.com/c/go/+/288072
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2021-01-29 19:48:48 +00:00
Cherry Zhang
68058edc39 runtime: document pointer write atomicity for memclrNoHeapPointers
memclrNoHeapPointers is the underlying implementation of
typedmemclr and memclrHasPointers, so it still needs to write
pointer-aligned words atomically. Document this requirement.

Updates #41428.

Change-Id: Ice00dee5de7a96a50e51ff019fcef069e8a8406a
Reviewed-on: https://go-review.googlesource.com/c/go/+/287692
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2021-01-29 19:11:07 +00:00
Joel Sing
c8bd8010ff syscall: generate readlen/writelen for openbsd libc
Rather than hand rolling readlen and writelen, move it to being generated
via mksyscall.pl, as is done for most other functions.

Updates #36435

Change-Id: I649aed7b182b41c8639686feae25ce19dab812c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/287532
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-01-28 16:45:43 +00:00
Bryan C. Mills
41bb49b878 cmd/go: revert TestScript/build_trimpath to use ioutil.ReadFile
This call was changed to os.ReadFile in CL 266365, but the test also
builds that source file using gccgo if present, and released versions
of gccgo do not yet support ioutil.ReadFile.

Manually tested with gccgo gccgo 10.2.1 (see #35786).

Fixes #43974.
Updates #42026.

Change-Id: Ic4ca0848d3ca324e2ab10fd14ad867f21e0898e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/287613
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-01-28 16:35:06 +00:00
Joel Sing
725a642c2d runtime: correct syscall10/syscall10X on openbsd/amd64
The syscall10/syscall10X implementation uses an incorrect stack offset for
arguments a7 to a10. Correct this so that the syscall arguments work as
intended.

Updates #36435
Fixes #43927

Change-Id: Ia7ae6cc8c89f50acfd951c0f271f3b3309934499
Reviewed-on: https://go-review.googlesource.com/c/go/+/287252
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-01-28 16:02:12 +00:00
Ian Lance Taylor
4b068cafb5 doc/go1.16: document go/build/constraint package
For #40700
For #41184
Fixes #43957

Change-Id: Ia346f4cf160431b721efeba7dc5f1fb8814efd95
Reviewed-on: https://go-review.googlesource.com/c/go/+/287472
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-01-28 05:46:54 +00:00
Joel Sing
376518d77f runtime,syscall: convert syscall on openbsd/arm64 to libc
Convert the syscall package on openbsd/arm64 to use libc rather than performing
direct system calls.

Updates #36435

Change-Id: I7e1da8537cea9ed9bf2676f181e56ae99383333f
Reviewed-on: https://go-review.googlesource.com/c/go/+/286815
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-01-28 02:19:23 +00:00
David Chase
aca22bddf2 [dev.regabi] cmd/compile: remove nested functions from expands_calls.go
Replace nested function spaghetti with state object and methods.
Still somewhat complex, but a bit more explicit.

Change-Id: I21987c8e4be75821faa5a248af05d2095cdfb0d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/287132
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-01-27 21:57:05 +00:00