aboutsummaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)Author
2021-08-10[dev.typeparams] cmd/compile: handle interface type parameters in type switchesKeith Randall
Change-Id: I9bba21a64d7e9f42395b6fcdf8aa3ca01cf131dc Reviewed-on: https://go-review.googlesource.com/c/go/+/340912 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
2021-08-10[dev.typeparams] cmd/compile/internal/types2: parameterized functions must ↵Robert Griesemer
have a body Add the respective check and add missing bodies to tests. Use {} as body for functions that don't return a result. Use { panic(0) } as body for functions that return a result. For #47069. Change-Id: Ia5d7525c9c036baf8a955d13bff448401e08235e Reviewed-on: https://go-review.googlesource.com/c/go/+/340911 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-08-09[dev.typeparams] cmd/compile: call transformArgs before early typecheckaste ↵Dan Scales
in noder 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>
2021-08-09[dev.typeparams] cmd/compile: implement generic type switchesKeith Randall
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>
2021-08-09[dev.typeparams] cmd/compile: simplify interface conversionsKeith Randall
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>
2021-08-06[dev.typeparams] cmd/compile/internal/types2: fix make with type parameter ↵Robert Griesemer
argument 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>
2021-08-06[dev.typeparams] cmd/compile: make sure closures inside generic funcs are ↵Dan Scales
not compiled 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>
2021-08-05[dev.typeparams] cmd/compile/internal/types2: implement type sets with term ↵Robert Griesemer
lists 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>
2021-08-05[dev.typeparams] cmd/compile: fixing case where type arg is an interfaceDan Scales
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>
2021-08-04[dev.typeparams] cmd/compile: put shape types in their own packageKeith Randall
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>
2021-08-03[dev.typeparams] cmd/compile: make softfloat mode work with register ABICherry Mui
Previously, softfloat mode does not work with register ABI, mainly because the compiler doesn't know how to pass floating point arguments and results. According to the ABI it should be passed in FP registers, but there isn't any in softfloat mode. This CL makes it work. When softfloat is used, we define the ABI as having 0 floating point registers (because there aren't any). The integer registers are unchanged. So floating point arguments and results are passed in memory. Another option is to pass (the bit representation of) floating point values in integer registers. But this complicates things because it'd need to reorder integer argument registers. Change-Id: Ibecbeccb658c10a868fa7f2dcf75138f719cc809 Reviewed-on: https://go-review.googlesource.com/c/go/+/327274 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2021-07-31[dev.typeparams] cmd/compile: make all pointer types have the same shapeKeith Randall
Except unsafe.Pointer. It has a different Kind, which makes it trickier. Change-Id: I12582afb6e591bea35da9e43ac8d141ed19532a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/338749 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>
2021-07-30[dev.typeparams] cmd/compile: allow types with the same underlying type to ↵Keith Randall
have the same shape First baby step to sharing the underlying implementation among several types. Change-Id: I6a156176d2b7f0131a87285a03b881ce380c26ed Reviewed-on: https://go-review.googlesource.com/c/go/+/338610 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>
2021-07-29[dev.typeparams] cmd/compile: handle meth expressions on typeparamsDan Scales
Rewrite a method expression such as 'T.String' (where T is type param and String is part of its type bound Stringer) as: func(rcvr T, other params...) { return Stringer(rcvr).String(other params...) } New function buildClosure2 to create the needed closure. The conversion Stringer(rcvr) uses the dictionary in the outer function. For a method expression like 'Test[T].finish' (where finish is a method of Test[T]), we can already deal with this in buildClosure(). We just need fix transformDot() to allow the method lookup to fail, since shapes have no methods on them. That's fine, since for any instantiated receiver type, we always use the methods on the generic base type. Also removed the OMETHEXPR case in the main switch of node(), which isn't needed any (and removes one more potential unshapify). Also, fixed two small bugs with handling closures that have generic params or generic captured variables. Need to set the instInfo for the closure in the subst struct when descending into a closure during genericSubst() and was missing initializing the startItabConv and gfInfo fields in the closure info. Change-Id: I6dadedd1378477936a27c9c544c014cd2083cfb7 Reviewed-on: https://go-review.googlesource.com/c/go/+/338129 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>
2021-07-29[dev.typeparams] cmd/compile: implement generic .(T) operationsKeith Randall
Introduce new dynamic dottype operations which take a dynamic instead of static type to convert to. Change-Id: I5824a1fea056fe811b1226ce059e1e8da1baa335 Reviewed-on: https://go-review.googlesource.com/c/go/+/337609 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>
2021-07-28[dev.typeparams] test: rename blank functionsMatthew Dempsky
This CL renames blank functions in the test/ directory so that they don't rely on the compiler doing anything more than typechecking them. In particular, I ran this search to find files that used blank functions and methods: $ git grep -l '^func.*\b_(' | xargs grep -n '^' | grep '\.go:1:' | grep -v '// errorcheck$' I then skipped updating a few files: * blank.go * fixedbugs/issue11699.go * fixedbugs/issue29870.go These tests specifically check that blank functions/methods work. * interface/fail.go Not sure the motivation for the blank method here, but it's empty anyway. * typeparam/tparam1.go Type-checking test, but uses "-G" (to use types2 instead of typecheck). Updates #47446. Change-Id: I9ec1714f499808768bd0dcd7ae6016fb2b078e5e Reviewed-on: https://go-review.googlesource.com/c/go/+/338094 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-28[dev.typeparams] test/typeparam: gofmt -wMatthew Dempsky
We don't usually reformat the test directory, but all of the files in test/typeparam are syntactically valid. I suspect the misformattings here are because developers aren't re-installing gofmt with -tags=typeparams, not intentionally exercising non-standard formatting. Change-Id: I3767d480434c19225568f3c7d656dc8589197183 Reviewed-on: https://go-review.googlesource.com/c/go/+/338093 Trust: Matthew Dempsky <mdempsky@google.com> Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-28[dev.typeparams] cmd/compile: mark methods of instantiated interface types ↵Dan Scales
as used Fix the cons.go missing method error. Mark all the methods of instantiated interface types as used. We could try to record all the exact methods used for generic interface types, but for now, just mark all the methods as used so that their methods are not dead-code eliminated. Change-Id: I35685eda82476244371379b97691a1b8506ef0f7 Reviewed-on: https://go-review.googlesource.com/c/go/+/337349 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>
2021-07-26[dev.typeparams] cmd/compile/internal/types2: embedded type cannot be a ↵Robert Griesemer
(pointer to) a type parameter Change-Id: I5eb03ae349925f0799dd866e207221429bc9fb3c Reviewed-on: https://go-review.googlesource.com/c/go/+/337353 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>
2021-07-26[dev.typeparams] cmd/compile/internal/types2: fix a bug in package ↵Robert Griesemer
qualification logic This is a partial port of https://golang.org/cl/330629, containing only the actual bug fix and adjustements to another test file. The respective test case has not been ported yet as it requires some bigger adjustments. For #46905 Change-Id: Ibd20658b8a31855da20cf56e24bcce9560656ca0 Reviewed-on: https://go-review.googlesource.com/c/go/+/336350 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-07-26[dev.typeparams] all: merge master (ecaa681) into dev.typeparamsMatthew Dempsky
Conflicts: - src/cmd/compile/internal/ssagen/ssa.go CL 336629 touched code that had already been removed on dev.typeparams. Merge List: + 2021-07-26 ecaa6816bf doc: clarify non-nil zero length slice to array pointer conversion + 2021-07-26 1868f8296e crypto/x509: update iOS bundled roots to version 55188.120.1.0.1 + 2021-07-25 849b791129 spec: use consistent capitalization for rune literal hex constants + 2021-07-23 0914646ab9 doc/1.17: fix two dead rfc links + 2021-07-22 052da5717e cmd/compile: do not change field offset in ABI analysis Change-Id: Ie570ec3f6a3241e0495e39e8a73b3a09a9368605
2021-07-26[dev.typeparams] cmd/compile: fix unified IR support for //go:nointerfaceMatthew Dempsky
This CL changes fixedbugs/issue30862.go into a "runindir" test so that it can use '-goexperiment fieldtrack' and test that //go:nointerface works with cmd/compile. In particular, this revealed that -G=3 and unified IR did not handle it correctly. This CL also fixes unified IR's support for //go:nointerface and adds a test that checks that //go:nointerface, promoted methods, and generics all interact as expected. Updates #47045. Change-Id: Ib8acff8ae18bf124520d00c98e8915699cba2abd Reviewed-on: https://go-review.googlesource.com/c/go/+/332611 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-24[dev.typeparams] cmd/compile: fix HasShape, add dottype testKeith Randall
HasShape needs a TINTER case. Add a test for x.(T) in various situations. Needs the fix above. Also remove ONEW unshapify case. It is ok for ONEW to have a shape type, as it will just be passed to mallocgc, or possibly used as a stack object type, both of which are ok. Change-Id: Ibddf8f5c8c254d32cb5ebcaca7dc94b4c00ab893 Reviewed-on: https://go-review.googlesource.com/c/go/+/337231 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>
2021-07-24[dev.typeparams] transformDot() should set Selection and tc flag for added ODOTsDan Scales
Fixes -G=3 issue with issue44688.go. Change-Id: Ie98c0cbd48683dedd115332043f14c8f3160f46c Reviewed-on: https://go-review.googlesource.com/c/go/+/337029 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com>
2021-07-23[dev.typeparams] cmd/compile: add dictionary entries for itab conversionDan Scales
This fix the case where a type param or derived type is converted to a non-empty interface. Previously, we were converting to an empty interface and then using DOTTYPE to convert to the correct non-empty interface. In that case, we can get the needed itab directly from the dictionary. This is needed for correctness from shapes, if the destination interface is parameterized, else we will incorrectly convert to the shape version of the interface. Creating/writing an itab can involve generating wrappers for a bunch of methods, which may use dictionaries. So, all the dictionaries/instantiations are being generated on the fly and have recursive relationships, it is simplest to finish creating/writing the itabs at the end of the stenciling phase. So, we create a list of the dictionaries which need to be completed by writing out their itab entries. The existing tests ordered.go, ifaceconv.go, and issue44688.go make use of this optimization. Got itab conversions for bound calls working, except for 13.go. Also, want to get rid of the concretify, but I think we need more info on the Bound from types2. Change-Id: If552958a7b8a435500d6cc42c401572c367b30d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/336993 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>
2021-07-22cmd/compile: do not change field offset in ABI analysisCherry Mui
Currently, the ABI analysis assigns parameter/result offsets to the fields of function *Type. In some cases, we may have an ABI0 function reference and an ABIInternal reference share the same function *Type. For example, for an ABI0 function F, "f := F" will make f and (ABI0) F having the same *Type. But f, as a func value, should use ABIInternal. Analyses on F and f will collide and cause ICE. Also, changing field offsets in ABI analysis has to be done very carefully to avoid data races. It has been causing trickiness/difficulty. This CL removes the change of field offsets in ABI analysis altogether. The analysis result is stored in ABIParamAssignment, which is the only way to access parameter/result stack offset now. Fixes #47317. Fixes #47227. Change-Id: I23a3e081a6cf327ac66855da222daaa636ed1ead Reviewed-on: https://go-review.googlesource.com/c/go/+/336629 Trust: Cherry Mui <cherryyz@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Than McIntosh <thanm@google.com>
2021-07-22[dev.typeparams] cmd/compile: fix missing condition in usemethodCuong Manh Le
CL 330670 simplified usemethod, but dropped the previous condition to ensure the function have 1 or 2 result. This CL restore that condition, and also add a test for it. Change-Id: I434e3736785b43ceea0b386d8d9d01ad78a4ccd2 Reviewed-on: https://go-review.googlesource.com/c/go/+/336609 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-07-22[dev.typeparams] test: cleanup 'go env' and -goexperimentMatthew Dempsky
This CL makes two related changes: 1. It uses 'go env -json' to query the environment configuration, rather than attempting to manually reconstruct the values that cmd/go is going to use. 2. It changes the -goexperiment flag to *extend* any ambient GOEXPERIMENT configuration. Notably, this means that '-goexperiment fieldtrack' now tests fieldtracking in conjunction with any other experiments (e.g., unified IR). Tests that want to test an exact GOEXPERIMENT config should use '-goexperiment none,foo' instead. Change-Id: I96a97198209e540e934fe7035110c3ae3a8f0e6a Reviewed-on: https://go-review.googlesource.com/c/go/+/332610 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-22[dev.typeparams] Fix problem with 14.goDan Scales
Removed a case in transformCall() where we were setting a type on n, which isn't needed, since noder2 already set the type of n. More importantly, we are losing information, since the type of the results may be a shape type, but the actual type of call is the known type from types2, which may be a concrete type (in this case Zero[MyInt]). That concrete type will then be used correctly if the concrete result is converted to an interface. If we are inlining the call to Zero[MyInt], we need to add an implicit CONVNOP operation, since we are going to use the result variable directly, which has a shape type. So, add an implicit CONVNOP to remember that the known type is the concrete type. Also cleaned up 14.go a bit, so it is more understandable. Renamed type T to AnyInt, since T is used elsewhere as a type parameter. Reformatted Zero function and added a comment. Change-Id: Id917a2e054e0bbae9bd302232853fa8741d49b64 Reviewed-on: https://go-review.googlesource.com/c/go/+/336430 Trust: Dan Scales <danscales@google.com> Reviewed-by: Keith Randall <khr@golang.org>
2021-07-22[dev.typeparams] Get dictionaryCapture.go working.Dan Scales
METHVALUE in a generic function (that is not called) was not causing buildClosure() to be called and therefore not using dictionaries. Also, had to add an extra check to make sure that if we have a FUNCINST node above a METHVALUE, we only call buildClosure once. Change-Id: I49756152fc343e5ac1c449e697960fc2a0f482ae Reviewed-on: https://go-review.googlesource.com/c/go/+/336429 Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-07-21[dev.typeparams] cmd/compile: handle ++/-- in noder2 for operands with ↵Dan Scales
generic type types2 will have already proved the expression's type is compatible, so just assign the one const to have the same type as the operand. Fixes #47258. Change-Id: If0844e6bf6d0a5e6b11453b87df71353863ccc5d Reviewed-on: https://go-review.googlesource.com/c/go/+/336009 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com>
2021-07-21[dev.typeparams] cmd/compile: added a builtins.go test, fixed one bugDan Scales
The builtins.go test is derived from cmd/compile/internal/types2/testdata/check/builtins.go2, after removing the error cases. Added a few extra tests for len/cap/append. Fixed one bug, which is that DELETE operations can't be transformed if their argument is a typeparam. Also, the tranform of LEN/CAP calls does not need to be delayed. Removed out-date references to the old typechecker in the comments. Change-Id: If7a21506a7ff63ff7c8e87ccd614ef4ff3a0d3c8 Reviewed-on: https://go-review.googlesource.com/c/go/+/336010 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com>
2021-07-21[dev.typeparams] cmd/compile: disable failing generic testsKeith Randall
We'll have to revisit eventually, but disabling for now. Change-Id: Ic34cfe451939d61884079bb125b9290db1e05e47 Reviewed-on: https://go-review.googlesource.com/c/go/+/335829 Run-TryBot: Keith Randall <khr@golang.org> Trust: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com> Reviewed-by: Dan Scales <danscales@google.com>
2021-07-21[dev.typeparams] test: add regression test for go/defer wrapperCuong Manh Le
CL 330330 moved logic for wrapping go/defer from order to esacpe analysis. It introduced a bug involves go/defer statement with ABI0 functions. Consider this following code: package p //go:cgo_unsafe_args func g(*int) (r1 struct{}) { return } func f() { defer g(new(int)) } g is a cgo-like generated function with ABI0. While compiling g, we set the offset per ABI0. The function f is rewritten into: func f() { _0, _1 := g, new(int) defer func() { _0(_1) }() } The temporary _0 hold function value with the same type as g, but with class PAUTO. Thus ssagen/ssa.go:state.call cannot handle it and use ABIDefault to set the offset, causes the offset of r1 changed CL 330332 intended to optimize code generated for wrapping function, by rewriting the wrapper function into: func f() { _0 := new(int) defer func() { g(_0) }() } So it fixed the bug unintentionally. This CL add regression test for this bug, and also add a comment to explain while not wrapping declared function is important. Updates #47227 Change-Id: I75c83d1d9cc7fd4699e6b218a295d0c0a10ef471 Reviewed-on: https://go-review.googlesource.com/c/go/+/334882 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-07-20[dev.typeparams] all: merge master (c8f4e61) into dev.typeparamsMatthew Dempsky
Conflicts: - src/runtime/internal/sys/zgoarch_386.go - src/runtime/internal/sys/zgoarch_amd64.go - src/runtime/internal/sys/zgoarch_arm.go - src/runtime/internal/sys/zgoarch_arm64.go - src/runtime/internal/sys/zgoarch_arm64be.go - src/runtime/internal/sys/zgoarch_armbe.go - src/runtime/internal/sys/zgoarch_mips.go - src/runtime/internal/sys/zgoarch_mips64.go - src/runtime/internal/sys/zgoarch_mips64le.go - src/runtime/internal/sys/zgoarch_mips64p32.go - src/runtime/internal/sys/zgoarch_mips64p32le.go - src/runtime/internal/sys/zgoarch_mipsle.go - src/runtime/internal/sys/zgoarch_ppc.go - src/runtime/internal/sys/zgoarch_ppc64.go - src/runtime/internal/sys/zgoarch_ppc64le.go - src/runtime/internal/sys/zgoarch_riscv.go - src/runtime/internal/sys/zgoarch_riscv64.go - src/runtime/internal/sys/zgoarch_s390.go - src/runtime/internal/sys/zgoarch_s390x.go - src/runtime/internal/sys/zgoarch_sparc.go - src/runtime/internal/sys/zgoarch_sparc64.go - src/runtime/internal/sys/zgoarch_wasm.go On dev.typeparams, CL 328336 moved these files to internal/goarch; whereas on master, CL 333909 reserved GOARCH=loong64. For this CL, I resolved the conflict by simply running "go generate internal/goarch". Merge List: + 2021-07-19 c8f4e6152d spec: correct example comment in Conversions from slice to array + 2021-07-19 1d91551b73 time: correct typo in documentation for UnixMicro + 2021-07-19 404127c30f cmd/compile: fix off-by-one error in traceback argument counting + 2021-07-19 6298cfe672 cmd/compile: fix typo in fatal message of builtinCall + 2021-07-19 49402bee36 cmd/{compile,link}: fix bug in map.zero handling + 2021-07-18 a66190ecee test/bench/go1: fix size for RegexpMatchMedium_32 + 2021-07-18 650fc2117a text/scanner: use Go convention in Position doc comment + 2021-07-16 aa4e0f528e net/http: correct capitalization in cancelTimeBody comment + 2021-07-15 0941dbca6a testing: clarify in docs that TestMain is advanced + 2021-07-15 69728ead87 cmd/go: update error messages in tests to match CL 332573 + 2021-07-15 c1cc9f9c3d cmd/compile: fix lookup package of redeclared dot import symbol + 2021-07-15 21a04e3335 doc/go1.17: mention GOARCH=loong64 + 2021-07-14 2b00a54baf go/build, runtime/internal/sys: reserve GOARCH=loong64 + 2021-07-14 60ddf42b46 cmd/go: change link in error message from /wiki to /doc. + 2021-07-13 d8f348a589 cmd/go: remove a duplicated word from 'go help mod graph' + 2021-07-12 a98589711d crypto/tls: test key type when casting + 2021-07-12 cfbd73ba33 doc/go1.17: editing pass over the "Compiler" section + 2021-07-09 ab4085ce84 runtime/pprof: call runtime.GC twice in memory profile test Change-Id: I1490a4c7e4c560659c21a4eb67d243f35d1f908e
2021-07-19cmd/{compile,link}: fix bug in map.zero handlingThan McIntosh
In CL 326211 a change was made to switch "go.map.zero" symbols from non-pkg DUPOK symbols to hashed symbols. The intent of this change was ensure that in cases where there are multiple competing go.map.zero symbols feeding into a link, the largest map.zero symbol is selected. The change was buggy, however, and resulted in duplicate symbols in the final binary (see bug cited below for details). This duplication was relatively benign for linux/ELF, but causes duplicate definition errors on Windows. This patch switches "go.map.zero" symbols back from hashed symbols to non-pkg DUPOK symbols, and updates the relevant code in the loader to ensure that we do the right thing when there are multiple competing DUPOK symbols with different sizes. Fixes #47185. Change-Id: I8aeb910c65827f5380144d07646006ba553c9251 Reviewed-on: https://go-review.googlesource.com/c/go/+/334930 Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-07-18test/bench/go1: fix size for RegexpMatchMedium_32nimelehin
Change-Id: Idc67abb95248bc010820a89dd6096a2da334e723 GitHub-Last-Rev: ae9014b011efb2692f853888c1860920d1acc3cb GitHub-Pull-Request: golang/go#47254 Reviewed-on: https://go-review.googlesource.com/c/go/+/335189 Reviewed-by: Rob Pike <r@golang.org> Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Alberto Donizetti <alb.donizetti@gmail.com>
2021-07-16[dev.typeparams] cmd/compile: use dictionary to convert arguments of ==, != ↵Keith Randall
to interfaces When comparing a value whose type is a type parameter to an interface, we need to convert that type parameter to an interface using the dictionary entries. Change-Id: I409c9e36e376fe4ef8163407d0fd4e84496d5b65 Reviewed-on: https://go-review.googlesource.com/c/go/+/334150 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>
2021-07-16[dev.typeparams] cmd/compile: fix small -G=3 issues for tests disabled in run.goDan Scales
- set correct position for closure capture variable in (*irgen).use() (issue20250.go) Also, evaluate rhs, lhs in that order in assignment statements to match noder1 (affects ordering of closure variables). - make sure to set Assign flag properly in (*irgen).forStmt() for range variables which are map accesses (issue9691.go) - make sure CheckSize() is call on the base type for top-level types converted by (*irgen).typ() that are pointer types (issue20174.go and issue37837.go) - deal with parentheses properly in validation function (*irgen).validate() (issue17270.go) - avoid HasNil call on type TTYPEPARAM - types2 typechecker will have already checked validity of the typeparam having nil value (new test issue39755.go) Change-Id: Ie68004d964698aea047e19e7dcd79b297e9d47ca Reviewed-on: https://go-review.googlesource.com/c/go/+/334733 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>
2021-07-16[dev.typeparams] cmd/compile/internal/types2: more consistent handling of ↵Robert Griesemer
predeclared "any" Rather than removing "any" from the universe scope, keep it predeclared but provide a better error message. While at it, remove some unnecessary type assertions. Change-Id: I10603274282ea6afc107f703ab194f32bd334dd1 Reviewed-on: https://go-review.googlesource.com/c/go/+/334911 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>
2021-07-15cmd/compile: fix lookup package of redeclared dot import symbolCuong Manh Le
The compiler is relying on Sym.Def field to lookup symbol package in DotImportRefs map. But the Sym.Def field is clear whenever the compiler finish processing a file. If the dot import happen in file A, then the redeclaration happen in file B, then the symbol lookup in file B will see a nil Sym.Def, that cause the compiler crashes. To fix this, we can interate over DotImportRefs and check for matching symbol name and return the corresponding package. Though this operation can be slow, but it only happens in invalid program, when printing error message, so it's not worth to optimize it further. Fixes #47201 Change-Id: I4ca1cb0a8e7432b19cf71434592a4cbb58d54adf Reviewed-on: https://go-review.googlesource.com/c/go/+/334589 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-07-14[dev.typeparams] cmd/compile/internal/types2: embedding stand-alone type ↵Robert Griesemer
parameters is not permitted For #47127. Change-Id: Ie979ff56ae7c2dd0e5ce0ff39588f98ae68b5ee9 Reviewed-on: https://go-review.googlesource.com/c/go/+/334151 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>
2021-07-14[dev.typeparams] cmd/compile/internal/types2: implement close(ch) where ch ↵Robert Griesemer
is of type parameter type Change-Id: I45189468553e83390fd2640b5708c60a7852fbb5 Reviewed-on: https://go-review.googlesource.com/c/go/+/333713 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>
2021-07-14[dev.typeparams] cmd/compile: fix escape printout bugs for -G=3Dan Scales
Call SetPos() in g.expr() so it is available for any new nodes. Print out the actual type for a composite literal in exprFmt() if available, else use Ntype if available. Seems generally useful, since the type name is always more useful than just 'composite literal'. Fixes a bunch of cases that are excluded in run.go for -G=3. Change-Id: I40b9bba88027ea4f36d419e3989e7f14891bea04 Reviewed-on: https://go-review.googlesource.com/c/go/+/334609 Trust: Dan Scales <danscales@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-07-12[dev.typeparams] Add optional sub-dict entry for typeparam bound callsDan Scales
In the case that a generic function/method f does a method call on a type param allowed by its bound, an instantiation of f may do a direct method call of a concrete type or a method call defined on a generic type, depending on whether the passed type in a concrete type or an instantiated type with the appropriate method defined. See the test case boundmethod.go added to this change. In order to keep the dictionary format the same for all instantiations of a generic function/method, I decided to have an optional sub-dictionary entry for "bounds" calls. At the point that we are creating the actual dictionary, we can then fill in the needed sub-dictionary, if the type arg is an instantiated type, or a zeroed dictionary entry, if type arg is not instantiated and the method will be on a concrete type. In order to implement this, I now fill in n.Selection for "bounds" method calls in generic functions as well. Also, I need to calculate n.Selection correctly during import for the case where it is now set - method calls on generic types, and bounds calls on typeparams. With this change, the dictionaries/sub-dictionaries are correct for absdiff.go. The new test boundmethod.go illustrates the case where the bound sub-dict entry is not used for a dictionary for stringify[myint], but is used for a dictionary for stringify[StringInt[myint]]. Change-Id: Ie2bcb971b7019a9f1da68c97eb03da2333327457 Reviewed-on: https://go-review.googlesource.com/c/go/+/333456 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com>
2021-07-09[dev.typeparams] cmd/compile: report mismatch between types because of ↵Dan Scales
//go:notinheap types2 currently ignores pragmas, so it does not catch a conversion error when converting a pointer to a type which is NOT marked notinheap to a pointer to a convertible type, but which is marked notinheap. So, we specifically check for this error in transformConv() and report it during noder2. Change-Id: I6e9c9ee29f53fa5e490c1ac8306e2191db59eeb4 Reviewed-on: https://go-review.googlesource.com/c/go/+/333369 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> Trust: Robert Griesemer <gri@golang.org> Trust: Dan Scales <danscales@google.com>
2021-07-08[dev.typeparams] all: merge master (296ddf2) into dev.typeparamsMatthew Dempsky
Conflicts: - src/runtime/runtime2.go On master, CL 317191 fixed the mentions of gc/reflect.go in comments to reflectdata/reflect.go; but on dev.typeparams, CL 325921 fixed that the same comment to reflect that deferstruct actually ended up in ssagen/ssa.go. Merge List: + 2021-07-08 296ddf2a93 net: filter bad names from Lookup functions instead of hard failing + 2021-07-08 ce76298ee7 Update oudated comment + 2021-07-08 2ca44fe221 doc/go1.17: linkify time.UnixMilli and time.UnixMicro + 2021-07-07 5c59e11f5e cmd/compile: remove special-casing of blank in types.sconv{,2} + 2021-07-07 b003a8b1ae cmd/compile: optimize types.sconv + 2021-07-07 11f5df2d67 cmd/compile: extract pkgqual from symfmt + 2021-07-07 991fd381d5 cmd/go: don't lock .mod and .sum files for read in overlay + 2021-07-07 186a3bb4b0 cmd/go/internal/modfetch/codehost: skip hg tests if no hg binary is present + 2021-07-07 00c00558e1 cmd/go/internal/modload: remove unused functions + 2021-07-07 f264879f74 cmd/go/internal/modload: fix an apparent typo in the AutoRoot comment + 2021-07-07 c96833e5ba doc: remove stale comment about arm64 port Change-Id: I849046b6d8f7421f60323549f3f763ef418bf9e7
2021-07-08[dev.typeparams] cmd/compile: fix bunch of -G=3 bugs for test cases in ↵Dan Scales
test/typeparams/mdempsky 1.go, 12.go: similar to calculating type sizes, we delay computing instantiations during import until we get up to a top-level type, in order to make sure recursive types are complete. But we should always delay calculating sizes when we delay instantiating types, since otherwise we may try to calculate the size of an incomplete type. So, needed to add Defer/ResumeCheckSize in (*importReader).typ where we also defer instantiations. (iimport.go) 2.go: when doing type substition, we have to handle named, parameterized basic types i.e. the type has a type parameter even though the underlying type is a basic type that doesn't depend on the parameter. (subr.go) 3.go: for go 1.18, we allow arbitrary types in interfaces. We had already allowed union types and tilde types, but didn't allow regular non-interface types in Go 1.17 for compatibility. Just skip an error in the case of 1.18. (size.go) 5.go: types2 and types1 differ in how they print out interfaces. types1 puts a space between "interface" and "{", types2 does not. So, since some typenames come from types2 and some from types1, we need to remove the space when printing out type arguments. (iimport.go/subr.go) 9.go: in subst.node(), we were missing the KeyExpr case where a node has no type. The assertion is just there, to make sure we understand all the cases where there is no type to translate. We could just remove the whole error check. (stencil.go) 13.go: in subst.node(), missed handling the case where a method expression is immediate called (which of course, is quite unusual, since then there's no real reason to have used the method expression syntax in that case). Just needed to add ir.OMETHEXPR in the OCALL switch statement. (stencil.go) Change-Id: I202cbe9541dfafe740e3b84b44982d6181738ea0 Reviewed-on: https://go-review.googlesource.com/c/go/+/333165 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>
2021-07-07[dev.typeparams] cmd/compile: fix bug with types2.Instantiate with interface ↵Dan Scales
type param types2.subst has an assertion that check is non-nil, but which breaks Instantiate() with an interface type param (used when re-importing instatiated type to types2). But this check was added when Instantiate() was added, and things seem to work fine when the assertion is removed. Fixes test/typeparam/mdempsky/7.go. Change-Id: I4980f0b202a0b310a3c91a7a87f97576f54911de Reviewed-on: https://go-review.googlesource.com/c/go/+/333155 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>
2021-07-07cmd/compile: remove special-casing of blank in types.sconv{,2}Matthew Dempsky
I'm not sure why blank was special-cased here before, but it's wrong. Blank is a non-exported identifier, and writing it out without package-qualification can result in linker symbol collisions. Fixes #47087. Change-Id: Ie600037c8e54e3d4fdaeec21e2ca212badbd830b Reviewed-on: https://go-review.googlesource.com/c/go/+/333163 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>