In the cases where we do an early call to typecheckaste() in noder to
expose CONVIFACE nodes, we need a preceding call to transformArgs().
This is needed to allow typecheckaste() to run correctly, in the case of
f(g()), where g has multiple return values.
I also cleaned up the code a bit and commented the code in Call(), and
we do the call to typecheckaste() in several more cases.
In stencil.go:stencil(), I moved the transformCall earlier for the
OCALLMETH/ODOTMETH case, just as I did in my previous CL for
OCALL/OFUNCINST. By doing this, transformArgs no longer needs to deal
with the extra dictionary args. Therefore, I was able to simply
transformArgs() to look like typecheckargs() again, and make use of
RewriteMultiValue directly.
Updates #47514
Change-Id: I49eb82ac05707e50c2e2fb03e39458a70491d406
Reviewed-on: https://go-review.googlesource.com/c/go/+/340531
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Add a new dynamicType node, which is used as a case entry when
the type being switched to is generic.
Change-Id: Ice77c6f224b8fdd3ff574fdf4a8ea5f6c7ddbe75
Reviewed-on: https://go-review.googlesource.com/c/go/+/339429
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Simplify the implementation of interface conversions in the compiler.
Don't pass fields that aren't needed (the data word, usually) to the runtime.
For generics, we need to put a dynamic type in an interface. The new
dataWord function is exactly what we need (the type word will come
from a dictionary).
Change-Id: Iade5de5c174854b65ad248f35c7893c603f7be3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/340029
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
This avoids an incorrect msan uninitialized memory report when using
runtime.SetCgoTraceback when a signal occurs while the fifth argument
register is undefined. See the issue for more details.
Fixes#47543
Change-Id: I3d1b673e2c93471ccdae0171a99b88b5a6062840
Reviewed-on: https://go-review.googlesource.com/c/go/+/339902
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
types2 now determines type parameter indices lazily, so we don't need
them just as we are importing. We set them in types1 as we are importing
the type param list itself.
type param indices are not strongly needed in types1 - we only use them
in one place which could be rewritten. But I kept them in analogy to
types2 (TypeParam.Index).
Fixes#47451
Change-Id: I30631f95c45a259354eaf7ec5194f71e799eb358
Reviewed-on: https://go-review.googlesource.com/c/go/+/340532
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Change-Id: I704bdb411bda3d8a40906c12f182e268dca4718f
Reviewed-on: https://go-review.googlesource.com/c/go/+/340450
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Writing CL 333629 clarified my thinking about the behavioral changes
associated with lazy loading. There are really two interrelated
changes — graph pruning, and lazy loading proper — that are both made
possible by the added redundancy in the go.mod file.
(I had initially approached the whole cluster of features as “lazy
loading” because that was the starting point for the design. Graph
pruning came into the picture when we looked at how to bound the
worst-case behavior of lazy loading, but it is really the more
important of the two aspects of the design.)
Note that this change adds links to doc anchors added in CL 333629.
Fixes#36460Fixes#47397
Change-Id: I0ef4af57f647bf5ee210ea7099191fb4befa2cc1
Reviewed-on: https://go-review.googlesource.com/c/go/+/335135
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Interface.Complete is not needed anymore. We can remove it in
types2 (and eventually make it an empty function in go/types,
where we must maintain the existing API).
Change-Id: I689f0d6f3a83997d8ca5bae773b9af0083d0bf4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/340255
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
At the moment, operations on termlists are O(n^2).
This is fine for normal-sized unions, but overlong
termlist lenghts will lead to excessive type checking
times.
Limit the length of termlists to avoid "compilations
that don't finish".
Change-Id: I39a7fc61b01c9db06faeb49a0e014b1ede532710
Reviewed-on: https://go-review.googlesource.com/c/go/+/340254
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Export a term as a pair (tilde, type) rather than (type, tilde)
to match the new Union/Term API.
Change-Id: I221c09c2c746ae19fbae0c970ffb26fa7a8ac736
Reviewed-on: https://go-review.googlesource.com/c/go/+/340251
Trust: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Instead of providing a list of tildes and types, use a list of
Terms to create a Union, with suitable accessors.
Define the (exported) notion of a Term representing a union term.
This simplified various uses and also will be easier to extend
should we want to add more information to a Term in the future.
Change-Id: I52fd73938bfa11bac60adbf10580b6d0680df4f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/340250
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Follow-up on https://golang.org/cl/339596 .
Change-Id: Ifa249379df083f80176b9f99900be0bf12483f41
Reviewed-on: https://go-review.googlesource.com/c/go/+/339905
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
End-users are not expected to deal with the details of panics,
so providing extra information such as an "internal error" prefix
is not helpful.
Matches the types2 changes made in https://golang.org/cl/339969 .
Change-Id: Icb34a9daab981a84f41f8ae7ae5dc1b85b2d2c81
Reviewed-on: https://go-review.googlesource.com/c/go/+/339904
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Change-Id: Iaa58b17ad65e93548bb3da8231e0cb6da0c48105
Reviewed-on: https://go-review.googlesource.com/c/go/+/339903
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
For make with a type parameter argument, the structural type of
the type parameter's constraint determines what make is making.
Change-Id: I3b48f8ce3236b7624e0638b5f5be208c5915c987
Reviewed-on: https://go-review.googlesource.com/c/go/+/339899
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
For range expressions of type parameter type, the structural type
of the type parameter's constraint determines the range operation.
While at it, rename implicitArrayDeref to arrayPtrDeref.
Change-Id: Ib631a8a14e717498e5264944f659309df1f68cc2
Reviewed-on: https://go-review.googlesource.com/c/go/+/339897
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
- use the symbol 𝓤 (as in 𝓤niverse) instead of ⊤ to denote the set
of all types (for better readabilty, ⊤ is hard to distinguish from
T in some fonts)
- use isAll instead of isTop to test for the set of all types
- use allTermlist instead of topTermlist to denote the termlist
representing all types
Change-Id: Idcb0b3398782b38653338e65173c0dbb935e430a
Reviewed-on: https://go-review.googlesource.com/c/go/+/339891
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Simple change - added some comments, but also removed some TODO comments
which are now done or no longer a question. Cleaned up the initial check
for generic methods.
The one remaining TODO that really needs to be done is generating
dictionary wrappers for any methods involving embedded fields. Given we
are not doing this, I think this would only affect if a struct with an
embedded field with methods was converted to an interface containing the
embedded method, and then the method was called via that interface.
Change-Id: I6a8a2885de33ad60b313c1899b659daef7550dfb
Reviewed-on: https://go-review.googlesource.com/c/go/+/340260
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Do the transformCall using the original types2-derived type of the call
(in particular, the types of the params as non-shapes). Currently, since
we were using the param types of the instantiation, we might add in
interface conversions to an interface with shapes in the one case of a
full-instantiated generic call. So, we do the transformCall() before
installing the shaped-based instantiation. transformCall() works
correctly even in the case of OCALL/FUNCINST.
Fixed two related bugs:
- Fixed case where we still were not correctly substituting the types
for a function instantiation.
- The type substituter needs to copy field flags while substituting in
tstruct.
Change-Id: I14e960737d6840a75846ede480e6650534ba3af3
Reviewed-on: https://go-review.googlesource.com/c/go/+/340259
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Closures inside generic functions were being added to the g.target.Decls
list during noding, just like other closures. We remove generic
functions/methods from g.target.Decls, so they don't get compiled
(they're only available for export and stenciling). Most closures inside
generic functions/methods were similarly being removed from
g.target.Decls, because they have a generic parameter. But we need to
ensure no closures in generic function/methods are left remaining in
g.target.Decls, since we don't want them transformed and compiled.
So, we set a flag in (*irgen) that records when we are noding a
top-level generic function/method, and don't add any closures to
g.target.Decls when the flag is true.
Updates #47514
Change-Id: Id66b4c41d307ffa8f54cab6ce3646ade81606862
Reviewed-on: https://go-review.googlesource.com/c/go/+/340258
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
DLLs built with recent Microsoft toolchains for ARM64 test for ARMv8.1
atomics by potentially calling an illegal instruction, and then trapping
the exception to disable use of them by way of a structured exception
handler. However, vectored exception handlers are always called before
structured exception handlers. When LoadLibrary-ing DLLs that do this
probing during initialization, our lastcontinuehandler winds up being
called, and then crashing, but actually it should give execution back to
the library to handle the exception and fix up the state. So special
case this for arm64 with illegal instructions, and hope that we're not
masking other things in external DLLs that might more fatally trigger an
illegal instruction exception.
Updates #47576.
Change-Id: I341ab99cd8d513ae999b75596749d49779072022
Reviewed-on: https://go-review.googlesource.com/c/go/+/340070
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Even experienced users occasionally mistake that runtime.KeepAlive can
be used as a workaround for following the unsafe.Pointer safety rules,
but it cannot. Add an explicit warning to this effect to dissuade
users from trying to use it as such.
Fixes#47562.
Change-Id: I842e33a3e1c080933c6b1bd1b6318448adbf495c
Reviewed-on: https://go-review.googlesource.com/c/go/+/340269
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
End-users are not expected to deal with the details of panics,
so providing extra information such as an "internal error" prefix
or the name of the function invoking the panic are not helpful.
Remove unnecessary panic verbiage if it is readily available from
a stack trace (such as the function where it happens, and the fact
that is is an "internal error").
Change-Id: I5f86bae6d2cca7c04ce692d17257da7ddee206d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/339969
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TestIncompleteInterfaces is not useful anymore because interface
printing always shows the syntactic type structure of an interface.
Also remove the respective support code in interface printing and
simplify that code.
Move the newDefined and nopos support declarations unchanged into
api_test.go where they are used.
Updates #46167.
Change-Id: I23e303bc4ae4271912ba75f201bd2b7cd4a17b3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/339832
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This flag is not needed by types2 (and possibly can also be removed
from go/types). Removed some unnecessary comments along the way.
Updates #46174.
Change-Id: I1a7a99f724205a084d1c9850bce6f6f5d33f83ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/339831
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This CL resolves several known issues and TODOs.
- Represent type sets with term lists and using term list abstractions.
- Represent Unions internally as a list of (syntactical) terms.
Use term operations to print terms and detect overlapping union
entries.
- Compute type sets corresponding to unions lazily, on demand.
- Adjust code throughout.
- Adjusted error check in test/typeparam/mincheck.dir/main.go
to make test pass.
Change-Id: Ib36fb7e1d343c2b6aec51d304f0f7d1ad415f999
Reviewed-on: https://go-review.googlesource.com/c/go/+/338310
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Change-Id: Iaf8ec7665282f4f8c0cb09a652e78aa97959274b
Reviewed-on: https://go-review.googlesource.com/c/go/+/340150
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
- Removed gcshapeType - we're going with more granular shapes for now, and gradually
coarsening later if needed.
- Put in early return in getDictionarySym(), so the entire rest of the
function can be un-indented by one level.
- Removed some duplicated infoprint calls, and fixed one infoprint
message in getGfInfo.
Change-Id: I13acce8fdabdb21e903275b53ff78a1e6a378de2
Reviewed-on: https://go-review.googlesource.com/c/go/+/339901
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
In this case, we can't use an itab for doing a bound call, since we're
converting from an interface to an interface. We do a static or dynamic
type assert in new function assertToBound().
The dynamic type assert in assertToBound() is only needed if a bound is
parameterized. In that case, we must do a dynamic type assert, and
therefore need a dictionary entry for the type bound (see change in
getGfInfo). I'm not sure if we can somehow limit this case, since using
an interface as a type arg AND having the type bound of the type
arg be parameterized is a very unlikely case.
Had to add the TUNION case to parameterizedBy1() (which is only used for
extra checking).
Added a bunch of these test cases to 13.go, which now passes.
Change-Id: Ic22eed637fa879b5bbb46d36b40aaad6f90b9d01
Reviewed-on: https://go-review.googlesource.com/c/go/+/339898
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Remove a stale comment from when the new types.Info API was guarded
behind the typeparams build constraint.
Change-Id: I319ad0a9e4e4958efdb96c967bf13a0119b5647b
Reviewed-on: https://go-review.googlesource.com/c/go/+/340010
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>
As with other go/types APIs, we should not expose the underlying
Named.targs slice.
Change-Id: Iba869298fbd3856022ffe8ec2c3273341598c324
Reviewed-on: https://go-review.googlesource.com/c/go/+/340009
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>
Prerequisite for clean implementation of type sets
on top of term lists.
Change-Id: Ice87f2f47327aa6b1f3eaad7f9af20ad7c548155
Reviewed-on: https://go-review.googlesource.com/c/go/+/339596
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Put shape types in the top level package called ".shape".
Name them using the serialization of the shape name, instead of
the .shapeN names.
This allows the linker to deduplicate instantiations across packages.
Not sure that this is entirely correct, as shapes in this package
may reference other packages (e.g. a field of a struct). But it seems
to work for now.
For the added test, when you look at the resulting binary (use the -k
option with run.go) it has only one instantiation of F, and 4 call sites:
$ objdump -d a.exe | grep _a\.F
1053cb0: e8 8b 00 00 00 callq 139 <_a.F[.shape.*uint8]>
1053ce9: e8 52 00 00 00 callq 82 <_a.F[.shape.*uint8]>
_a.F[.shape.*uint8]:
1053d90: e8 ab ff ff ff callq -85 <_a.F[.shape.*uint8]>
1053dc9: e8 72 ff ff ff callq -142 <_a.F[.shape.*uint8]>
Change-Id: I627f7e50210aabe4a10d0e2717d87b75ac82e99b
Reviewed-on: https://go-review.googlesource.com/c/go/+/339595
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
CL 339396 allowed stack copying on entry to and during freedefer, but
this introduced a subtle bug: if d is heap-allocated, and d.link
points to a stack-allocated defer, stack copying during freedefer can
briefly introduce a stale pointer, which the garbage collector can
discover and panic about. This happens because d has already been
unlinked from the defer chain when freedefer is called, so stack
copying won't update stack pointers in it.
Fix this by making freedefer nosplit again and immediately clearing
d.link.
This should fix the longtest builders, which currently fail on
GOMAXPROCS=2 runtime -cpu=1,2,4 -quick in the TestDeferHeapAndStack
test.
This seems like the simplest fix, but it just deals with the subtlety
rather than eliminating it. Really, every call site of freedefer (of
which there are surprisingly many) has hidden subtlety between
unlinking the defer and calling freedefer. We could consolidate the
subtlety into each call site by requiring that they unlink the defer
and set d.link to nil before calling freedefer. freedefer could check
this condition like it checks that various other fields have already
been zeroed. A more radical option is to replace freedefer with
"popDefer", which would both pop the defer off the link and take care
of freeing it. There would still be a brief moment of subtlety, but it
would be in one place, in popDefer. Annoyingly, *almost* every call to
freedefer just pops the defer from the head of the G's list, but
there's one place when handling open-coded defers where we have to
remove a defer from the middle of the list. I'm inclined to first fix
that subtlety by only expanding open-coded defer records when they're
at the head of the defer list, and then revisit the popDefer idea.
Change-Id: I3130d2542c01a421a5d60e8c31f5379263219627
Reviewed-on: https://go-review.googlesource.com/c/go/+/339730
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
This test made many requests over the same connection for 10
seconds, trusting that this will exercise the request cancelation
race from #41600.
Change the test to exhibit the specific race in a targeted fashion
with only two requests.
Updates #41600.
Updates #47016.
Change-Id: If99c9b9331ff645f6bb67fe9fb79b8aab8784710
Reviewed-on: https://go-review.googlesource.com/c/go/+/339594
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
This is a port of CL 338469 to go/types.
Change-Id: I3ee655fa2dc7e789f210c8dec171b3358c4ff132
Reviewed-on: https://go-review.googlesource.com/c/go/+/339677
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>
This is a clean port of CL 338309 to go/types.
Change-Id: Ie2c9e2ea51d6321af8bf149e43cd71b7ac282d13
Reviewed-on: https://go-review.googlesource.com/c/go/+/339676
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>
This is a straightforward port of CL 338196 to go/types, minus the
deprecated TypeParam.Bound() method (since it is not needed), plus an
adjustment for methodset.go.
Change-Id: Ie372bfeec245094102a2c3257a43499d75981447
Reviewed-on: https://go-review.googlesource.com/c/go/+/339675
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>
This is a straightforward port of CL 338092 to go/types.
Change-Id: I414ec0ad95648c201e85fd2b4f494b1206c658e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/339674
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>
When static == false, missingMethod incorrectly continues with a nil
Func.
Also remove some unnecessary type names from typeterm_test.go, which was
done in the go/types port.
Change-Id: I21fa637ac82b115563d3601314a470a5a43f9ae0
Reviewed-on: https://go-review.googlesource.com/c/go/+/339672
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>
This is a port of CL 338049 to go/types. It identical to that CL, except
for eliding unnecessary typenames from the testTerms declaration.
Change-Id: Ieb04d7bbc20063044eb63ea985f75d529f030cd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/339653
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>
This is a port of CL 337354 to go/types, adjusted for the error
reporting API and to reposition a couple error messages in
issue47411.go2 (the go/types position is probably better).
A panic is also fixed in lookup.go when method lookup fails and static
== false. I'll send a fix for types2 in a separate CL.
For #47411
Change-Id: Icc48f03c3958695f581f10e8675c1f32434c424b
Reviewed-on: https://go-review.googlesource.com/c/go/+/339652
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>
This is a port of CL 337353 to go/types, adjusted for the error API and
to comment out a test for MethodSet.
Some nearby error messages that were using errorf rather than error were
also adjusted.
Fixes#43621
Change-Id: I28c9747e044ec7a2863f6890db69475fb8c29231
Reviewed-on: https://go-review.googlesource.com/c/go/+/339651
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>
This is a clean port of CL 336989 to go/types.
Change-Id: Ib8dbe03f420d28ada6d5fc7003ab0c82c7e06c41
Reviewed-on: https://go-review.googlesource.com/c/go/+/339650
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>
This is a port of CL 335413 to go/types, adjusted for the parsing API of
go/parser.
Change-Id: Ie6836add7d027aaf5d6d3dae65222b1d15bd7558
Reviewed-on: https://go-review.googlesource.com/c/go/+/339649
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>
Currently, freedefer manually zeros all the fields in the _defer
because simply assigning _defer{} used to cause a nosplit stack
overflow. freedefer is no longer nosplit, so go back to the simpler,
more robust code.
Change-Id: I881f557bab3b1ee7ab29b68e7fb56d0fe6d35d8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/339669
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Currently, deferreturn runs deferred functions by backing up its
return PC to the deferreturn call, and then effectively tail-calling
the deferred function (via jmpdefer). The effect of this is that the
deferred function appears to be called directly from the deferee, and
when it returns, the deferee calls deferreturn again so it can run the
next deferred function if necessary.
This unusual flow control leads to a large number of special cases and
complications all over the tool chain.
This used to be necessary because deferreturn copied the deferred
function's argument frame directly into its caller's frame and then
had to invoke that call as if it had been called from its caller's
frame so it could access it arguments. But now that we've simplified
defer processing so the runtime only deals with argument-less
closures, this approach is no longer necessary.
This CL simplifies all of this by making deferreturn simply call
deferred functions in a loop.
This eliminates the need for jmpdefer, so we can delete a bunch of
per-architecture assembly code.
This eliminates several special cases on Wasm, since it couldn't
support these calling shenanigans directly and thus had to simulate
the loop a different way. Now Wasm can largely work the way the other
platforms do.
This eliminates the per-architecture Ginsnopdefer operation. On PPC64,
this was necessary to reload the TOC pointer after the tail call
(since TOC pointers in general make tail calls impossible). The tail
call is gone, and in the case where we do force a jump to the
deferreturn call when recovering from an open-coded defer, we go
through gogo (via runtime.recovery), which handles the TOC. On other
platforms, we needed a NOP so traceback didn't get confused by seeing
the return to the CALL instruction, rather than the usual return to
the instruction following the CALL instruction. Now we don't inject a
return to the CALL instruction at all, so this NOP is also
unnecessary.
The one potential effect of this is that deferreturn could now appear
in stack traces from deferred functions. However, this could already
happen from open-coded defers, so we've long since marked deferreturn
as a "wrapper" so it gets elided not only from printed stack traces,
but from runtime.Callers*.
This is a retry of CL 337652 because we had to back out its parent.
There are no changes in this version.
Change-Id: I3f54b7fec1d7ccac71cc6cf6835c6a46b7e5fb6c
Reviewed-on: https://go-review.googlesource.com/c/go/+/339397
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Prior to regabi, the compiler passed defer arguments to the runtime as
untyped values on the stack. This meant a lot of defer-related runtime
functions had to be very careful not to grow the stack or allow
preemption since the stack could not be safely scanned or moved.
However, with regabi, every defer is now simply a func() from the
runtime's perspective, which means we no longer have untyped values on
the stack when we enter defer-related runtime code.
Hence, this CL removes a lot of the now-unnecessary carefulness in the
defer implementation. Specifically, deferreturn no longer needs to be
nosplit because it doesn't copy untyped defer arguments to its
caller's frame (we also update some stale comments in deferreturn).
freedefer no longer needs to be nosplit because it's none of its
callers are deeply nosplit. And newdefer and freedefer no longer need
to switch to the systemstack on their slow paths to avoid stack
growth.
deferprocStack is the only function that still needs to be nosplit,
but that's because the compiler calls it with uninitialized live
pointer slots on the stack (maybe we should change that, but that's a
very different fix).
This is a retry of CL 337651, which was rolled back. This version
disables preemption in newdefer and freedefer while they hold the
current P.
Change-Id: Ibf469addc0b69dc3ba9a3d1a5e0c2804b7b4b244
Reviewed-on: https://go-review.googlesource.com/c/go/+/339396
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>