aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/reflect/value.go
AgeCommit message (Collapse)AuthorFilesLines
2022-02-11libgo: update to Go1.18beta2Ian Lance Taylor1-91/+364
gotools/ * Makefile.am (go_cmd_cgo_files): Add ast_go118.go (check-go-tool): Copy golang.org/x/tools directories. * Makefile.in: Regenerate. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/384695
2021-08-12libgo: update to Go1.17rc2Ian Lance Taylor1-8/+58
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/341629
2020-12-30libgo: update to Go1.16beta1 releaseIan Lance Taylor1-4/+33
This does not yet include support for the //go:embed directive added in this release. * Makefile.am (check-runtime): Don't create check-runtime-dir. (mostlyclean-local): Don't remove check-runtime-dir. (check-go-tool, check-vet): Copy in go.mod and modules.txt. (check-cgo-test, check-carchive-test): Add go.mod file. * Makefile.in: Regenerate. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/280172
2020-11-10libgo: update to Go 1.15.4 releaseIan Lance Taylor1-1/+11
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/268177
2020-10-13reflect: ensure uniqueness of type descriptors on AIX.Clément Chigot1-1/+1
On AIX, duplication of type descriptors can occur if one is declared in the libgo and one in the Go program being compiled. The AIX linker isn't able to merge them together as Linux one does. One solution is to always load libgo first but that needs a huge mechanism in gcc core. Thus, this patch ensures that the duplication isn't visible for the end user. In reflect and internal/reflectlite, the comparison of rtypes is made on their name and not only on their addresses. In reflect, toType() function is using a canonicalization map to force rtypes having the same rtype.String() to return the same Type. This can't be made in internal/reflectlite as it needs sync package. But, for now, it doesn't matter as internal/reflectlite is not widely used. Fixes golang/go#39276 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/260158
2020-08-01libgo: update to go1.15rc1Ian Lance Taylor1-45/+73
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/245157
2020-07-17libgo: update to Go 1.14.6 releaseIan Lance Taylor1-0/+1
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/243317
2020-01-21libgo: update to Go1.14beta1Ian Lance Taylor1-1/+16
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/214297
2020-01-02compiler, runtime, reflect: generate hash functions only for map keysIan Lance Taylor1-0/+3
Right now we generate hash functions for all types, just in case they are used as map keys. That's a lot of wasted effort and binary size for types which will never be used as a map key. Instead, generate hash functions only for types that we know are map keys. Just doing that is a bit too simple, since maps with an interface type as a key might have to hash any concrete key type that implements that interface. So for that case, implement hashing of such types at runtime (instead of with generated code). It will be slower, but only for maps with interface types as keys, and maybe only a bit slower as the aeshash time probably dominates the dispatch time. Reorg where we keep the equals and hash functions. Move the hash function from the key type to the map type, saving a field in every non-map type. That leaves only one function in the alg structure, so get rid of that and just keep the equal function in the type descriptor itself. While we're here, reorganize the rtype struct to more closely match the gc version. This is the gofrontend version of https://golang.org/cl/191198. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/212843 From-SVN: r279848
2019-09-06libgo: update to Go 1.13beta1 releaseIan Lance Taylor1-16/+69
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/193497 From-SVN: r275473
2019-05-08reflect: correctly handle direct interface typed receiver in Value.callIan Lance Taylor1-1/+1
A direct interface type's value method takes value receiver now. Don't pass pointer to the method function. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/175798 From-SVN: r271000
2019-01-18libgo: update to Go1.12beta2Ian Lance Taylor1-18/+92
Reviewed-on: https://go-review.googlesource.com/c/158019 gotools/: * Makefile.am (go_cmd_vet_files): Update for Go1.12beta2 release. (GOTOOLS_TEST_TIMEOUT): Increase to 600. (check-runtime): Export LD_LIBRARY_PATH before computing GOARCH and GOOS. (check-vet): Copy golang.org/x/tools into check-vet-dir. * Makefile.in: Regenerate. gcc/testsuite/: * go.go-torture/execute/names-1.go: Stop using debug/xcoff, which is no longer externally visible. From-SVN: r268084
2018-10-08libgo: update to Go 1.11.1 releaseIan Lance Taylor1-9/+9
Reviewed-on: https://go-review.googlesource.com/c/140277 From-SVN: r264932
2018-09-24libgo: update to Go 1.11Ian Lance Taylor1-13/+17
Reviewed-on: https://go-review.googlesource.com/136435 gotools/: * Makefile.am (mostlyclean-local): Run chmod on check-go-dir to make sure it is writable. (check-go-tools): Likewise. (check-vet): Copy internal/objabi to check-vet-dir. * Makefile.in: Rebuild. From-SVN: r264546
2018-01-09libgo: update to Go1.10beta1Ian Lance Taylor1-60/+93
Update the Go library to the 1.10beta1 release. Requires a few changes to the compiler for modifications to the map runtime code, and to handle some nowritebarrier cases in the runtime. Reviewed-on: https://go-review.googlesource.com/86455 gotools/: * Makefile.am (go_cmd_vet_files): New variable. (go_cmd_buildid_files, go_cmd_test2json_files): New variables. (s-zdefaultcc): Change from constants to functions. (noinst_PROGRAMS): Add vet, buildid, and test2json. (cgo$(EXEEXT)): Link against $(LIBGOTOOL). (vet$(EXEEXT)): New target. (buildid$(EXEEXT)): New target. (test2json$(EXEEXT)): New target. (install-exec-local): Install all $(noinst_PROGRAMS). (uninstall-local): Uninstasll all $(noinst_PROGRAMS). (check-go-tool): Depend on $(noinst_PROGRAMS). Copy down objabi.go. (check-runtime): Depend on $(noinst_PROGRAMS). (check-cgo-test, check-carchive-test): Likewise. (check-vet): New target. (check): Depend on check-vet. Look at cmd_vet-testlog. (.PHONY): Add check-vet. * Makefile.in: Rebuild. From-SVN: r256365
2017-09-14libgo: update to go1.9Ian Lance Taylor1-8/+13
Reviewed-on: https://go-review.googlesource.com/63753 From-SVN: r252767
2017-09-14compiler, runtime: simplify select and channel operationsIan Lance Taylor1-4/+4
In preparation for upgrading libgo to the 1.9 release, this approximately incorporates https://golang.org/cl/37661 and https://golang.org/cl/38351. CL 37661 changed the gc compiler such that the select statement simply returns an integer which is then used as the argument for a switch. Since gccgo already worked that way, this just adjusts the switch code to look like the gc switch code by removing the explicit case index expression and calculating it from the order of calls to selectsend, selectrecv, and selectdefault. CL 38351 simplifies the channel code by not passing the unused channel type descriptor pointer. Reviewed-on: https://go-review.googlesource.com/62730 From-SVN: r252749
2017-09-14compiler, reflect: fix struct field names for embedded aliasesIan Lance Taylor1-2/+2
This adds much of https://golang.org/cl/35731 and https://golang.org/cl/35732 to the gofrontend code. This is a step toward updating libgo to the 1.9 release. The gofrontend already supports type aliases, and this is required for correct support of type aliases when used as embedded fields. The change to expressions.cc is to handle the << 1, used for the newly renamed offsetAnon field, in the constant context used for type descriptor initialization. Reviewed-on: https://go-review.googlesource.com/62710 From-SVN: r252746
2017-01-14libgo: update to Go 1.8 release candidate 1Ian Lance Taylor1-2/+2
Compiler changes: * Change map assignment to use mapassign and assign value directly. * Change string iteration to use decoderune, faster for ASCII strings. * Change makeslice to take int, and use makeslice64 for larger values. * Add new noverflow field to hmap struct used for maps. Unresolved problems, to be fixed later: * Commented out test in go/types/sizes_test.go that doesn't compile. * Commented out reflect.TestStructOf test for padding after zero-sized field. Reviewed-on: https://go-review.googlesource.com/35231 gotools/: Updates for Go 1.8rc1. * Makefile.am (go_cmd_go_files): Add bug.go. (s-zdefaultcc): Write defaultPkgConfig. * Makefile.in: Rebuild. From-SVN: r244456
2016-07-22libgo: update to go1.7rc3Ian Lance Taylor1-34/+33
Reviewed-on: https://go-review.googlesource.com/25150 From-SVN: r238662
2016-04-12reflect: change Value.Call results to not be addressableIan Lance Taylor1-3/+5
Leaving them incorrectly marked as addressable broke a use of the text/template package, because state.evalField checks CanAddr and takes the address if it is addressable. Reviewed-on: https://go-review.googlesource.com/21908 From-SVN: r234923
2016-02-03libgo: Update to go1.6rc1.Ian Lance Taylor1-7/+15
Reviewed-on: https://go-review.googlesource.com/19200 From-SVN: r233110
2015-11-07re PR go/66138 (json decoder Decode function fails for some structure return ↵Ian Lance Taylor1-11/+18
values) PR go/66138 reflect, encoding/json, encoding/xml: fix unexported embedded structs Bring in three changes from the master Go repository. These changes will be in Go 1.6, but they are appropriate for gccgo now because they resolve a long-standing discrepancy between how gc and gccgo handle the PkgPath field for embedded unexported struct fields. The core issue is described at https://golang.org/cl/7247. This has been reported against gccgo as https://gcc.gnu.org/PR66138. The three changes being brought over are: https://golang.org/cl/14010 reflect: adjust access to unexported embedded structs This CL changes reflect to allow access to exported fields and methods in unexported embedded structs for gccgo and after gc has been adjusted to disallow access to embedded unexported structs. Adresses #12367, #7363, #11007, and #7247. https://golang.org/cl/14011 encoding/json: check for exported fields in embedded structs Addresses issue #12367. https://golang.org/cl/14012 encoding/xml: check for exported fields in embedded structs Addresses issue #12367. Reviewed-on: https://go-review.googlesource.com/16723 From-SVN: r229907
2015-10-31runtime: Remove now unnecessary pad field from ParFor.Ian Lance Taylor1-41/+73
It is not needed due to the removal of the ctx field. Reviewed-on: https://go-review.googlesource.com/16525 From-SVN: r229616
2015-01-16compiler, reflect, runtime: Use static chain for closures.Richard Henderson1-24/+0
Change from using __go_set_closure to passing the closure value in the static chain field. Uses new backend support for setting the closure chain in a call from C via __builtin_call_with_static_chain. Uses new support in libffi for Go closures. The old architecture specific support for reflect.MakeFunc is removed, replaced by the libffi support. All work done by Richard Henderson. * go-gcc.cc (Gcc_backend::call_expression): Add chain_expr argument. (Gcc_backend::static_chain_variable): New method. From-SVN: r219776
2015-01-15libgo, compiler: Upgrade libgo to Go 1.4, except for runtime.Ian Lance Taylor1-412/+181
This upgrades all of libgo other than the runtime package to the Go 1.4 release. In Go 1.4 much of the runtime was rewritten into Go. Merging that code will take more time and will not change the API, so I'm putting it off for now. There are a few runtime changes anyhow, to accomodate other packages that rely on minor modifications to the runtime support. The compiler changes slightly to add a one-bit flag to each type descriptor kind that is stored directly in an interface, which for gccgo is currently only pointer types. Another one-bit flag (gcprog) is reserved because it is used by the gc compiler, but gccgo does not currently use it. There is another error check in the compiler since I ran across it during testing. gotools/: * Makefile.am (go_cmd_go_files): Sort entries. Add generate.go. * Makefile.in: Rebuild. From-SVN: r219627
2014-10-20reflect: allocate correct type in assignTo and cvtT2IIan Lance Taylor1-11/+11
Backport https://codereview.appspot.com/155450044 from the master Go library. Original description: I came across this while debugging a GC problem in gccgo. There is code in assignTo and cvtT2I that handles assignment to all interface values. It allocates an empty interface even if the real type is a non-empty interface. The fields are then set for a non-empty interface, but the memory is recorded as holding an empty interface. This means that the GC has incorrect information. This is extremely unlikely to fail, because the code in the GC that handles empty interfaces looks like this: obj = nil; typ = eface->type; if(typ != nil) { if(!(typ->kind&KindDirectIface) || !(typ->kind&KindNoPointers)) obj = eface->data; In the current runtime the condition is always true--if KindDirectIface is set, then KindNoPointers is clear--and we always want to set obj = eface->data. So the question is what happens when we incorrectly store a non-empty interface value in memory marked as an empty interface. In that case eface->type will not be a *rtype as we expect, but will instead be a pointer to an Itab. We are going to use this pointer to look at a *rtype kind field. The *rtype struct starts out like this: type rtype struct { size uintptr hash uint32 // hash of type; avoids computation in hash tables _ uint8 // unused/padding align uint8 // alignment of variable with this type fieldAlign uint8 // alignment of struct field with this type kind uint8 // enumeration for C An Itab always has at least two pointers, so on a little-endian 64-bit system the kind field will be the high byte of the second pointer. This will normally be zero, so the test of typ->kind will succeed, which is what we want. On a 32-bit system it might be possible to construct a failing case by somehow getting the Itab for an interface with one method to be immediately followed by a word that is all ones. The effect would be that the test would sometimes fail and the GC would not mark obj, leading to an invalid dangling pointer. I have not tried to construct this test. I noticed this in gccgo, where this error is much more likely to cause trouble for a rather random reason: gccgo uses a different layout of rtype, and in gccgo the kind field happens to be the low byte of a pointer, not the high byte. From-SVN: r216489
2014-07-20runtime: remove unused variableIan Lance Taylor1-4/+3
This variable is unused apparently as a result of local changes. gccgo accepts this variable declaration, but other frontends may not. From-SVN: r212873
2014-07-19libgo: Update to Go 1.3 release.Ian Lance Taylor1-16/+29
From-SVN: r212837
2014-06-06libgo: Merge to master revision 19184.Ian Lance Taylor1-102/+116
The next revision, 19185, renames several runtime files, and will be handled in a separate change. From-SVN: r211328
2014-06-04libgo: Merge from revision 18783:00cce3a34d7e of master library.Ian Lance Taylor1-263/+435
This revision was committed January 7, 2014. The next revision deleted runtime/mfinal.c. That will be done in a subsequent merge. This merge changes type descriptors to add a zero field, pointing to a zero value for that type. This is implemented as a common variable. * go-gcc.cc (Gcc_backend::implicit_variable): Add is_common and alignment parameters. Permit init parameter to be NULL. From-SVN: r211249
2013-12-12compiler, reflect, runtime: Implement method values in reflect.Ian Lance Taylor1-30/+13
From-SVN: r205913
2013-11-06libgo: Update to October 24 version of master library.Ian Lance Taylor1-58/+76
From-SVN: r204466
2013-10-01reflect: Fix reflect.Call with function following non-pointer.Ian Lance Taylor1-2/+4
From-SVN: r203052
2013-09-27reflect: Implement MakeFunc for amd64.Ian Lance Taylor1-69/+0
From-SVN: r202982
2013-09-17reflect: Fix bug calling method on indirect value.Ian Lance Taylor1-1/+7
The gccgo-specific iword function was checking v.kind, but for a method value that is always Func. Fix to check v.typ.Kind() instead. From-SVN: r202670
2013-09-03compiler, runtime: Use runtime functions to pass closure value.Ian Lance Taylor1-7/+0
This changes the compiler and runtime to not pass a closure value as the last argument, but to instead pass it via __go_set_closure and retrieve it via __go_get_closure. This eliminates the need for function descriptor wrapper functions. It will make it possible to retrieve the closure value in a reflect.MakeFunc function. From-SVN: r202233
2013-07-16libgo: Update to Go 1.1.1.Ian Lance Taylor1-59/+137
From-SVN: r200974
2013-06-18compiler, runtime: Use function descriptors.Ian Lance Taylor1-8/+31
This changes the representation of a Go value of function type from being a pointer to function code (like a C function pointer) to being a pointer to a struct. The first field of the struct points to the function code. The remaining fields, if any, are the addresses of variables referenced in enclosing functions. For each call to a function, the address of the function descriptor is passed as the last argument. This lets us avoid generating trampolines, and removes the use of writable/executable sections of the heap. From-SVN: r200181
2013-01-29libgo: Update Go library to master revision 15489/921e53d4863c.Ian Lance Taylor1-2/+2
From-SVN: r195560
2012-11-21libgo: Update to current version of master library.Ian Lance Taylor1-77/+105
From-SVN: r193688
2012-11-19reflect: Fix invalid sharing in valueInterface.Ian Lance Taylor1-4/+4
From-SVN: r193614
2012-10-23libgo: Update to current sources.Ian Lance Taylor1-8/+536
From-SVN: r192704
2012-10-03libgo: Update to Go 1.0.3.Ian Lance Taylor1-1/+2
From-SVN: r192025
2012-03-30libgo: Update to weekly.2012-03-22.Ian Lance Taylor1-0/+9
From-SVN: r186026
2012-03-30libgo: Update to weekly.2012-03-13.Ian Lance Taylor1-0/+4
From-SVN: r186023
2012-03-06libgo: Update to weekly.2012-03-04 release.Ian Lance Taylor1-2/+14
From-SVN: r185010
2012-03-02libgo: Update to weekly.2012-02-14 release.Ian Lance Taylor1-17/+31
From-SVN: r184798
2012-01-23compiler: Give an error if a variable is defined but not used.Ian Lance Taylor1-6/+5
From-SVN: r183458
2012-01-12libgo: Update to weekly.2011-12-14.Ian Lance Taylor1-1/+1
From-SVN: r183118