aboutsummaryrefslogtreecommitdiff
path: root/libgo
AgeCommit message (Collapse)AuthorFilesLines
2019-11-11libgo: fix DejaGNU testsuite compiler when using build sysrootIan Lance Taylor6-8/+34
Patch by Maciej W. Rozycki. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/206577 From-SVN: r278070
2019-10-14runtime: correct facilities names in s390 CPU supportIan Lance Taylor1-5/+7
Patch from Andreas Krebbel. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/201038 From-SVN: r276964
2019-10-14internal/cpu: define kdsaQuery for s390Ian Lance Taylor1-0/+15
Patch from Andreas Krebbel. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/201037 From-SVN: r276962
2019-10-02runtime: mark go-context.S as no-executable-stack and split-stack supportedIan Lance Taylor1-0/+4
The .note.GNU-stack section tells the linker that this object does not require an executable stack. The .note.GNU-split-stack section tells the linker that functions in this object can be called directly by split-stack functions, without require a large stack. The .note.GNU-no-split-stack section tells the linker that functions in this object do not have a split-stack prologue. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/198440 From-SVN: r276488
2019-09-19libgo: support gollvm build on arm64 linuxIan Lance Taylor3-0/+16
This CL serves as part of an initial change for enabling gollvm building on arm64 linux, the rest of the change will be covered by another one to the gollvm repo. Incorporate type definition of 'uint128' to 'runtime' and 'syscall' packges, the change is not specific to arm64 linux but made available for all platforms. Verified by building and unit-testing gollvm on linux x86-64 and arm64. Verified by building and checking gccgo on linux x86-64 and arm64. Fixes golang/go#33711 Change-Id: I4720c7d810cfd4ef720962fb4104c5641b2459c0 From-SVN: r275919
2019-09-17runtime: for FFI, treat directIface types as pointersIan Lance Taylor1-0/+6
This only matters on systems that pass a struct with a single pointer field differently than passing a single pointer. I noticed it on 32-bit PPC, where the reflect package TestDirectIfaceMethod failed. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/195878 From-SVN: r275814
2019-09-17re PR go/91781 (r275691 breaks go test "reflect")Ian Lance Taylor3-17/+40
PR go/91781 reflect: promote integer closure return to full word The libffi library expects an integer return type to be promoted to a full word. Implement that when returning from a closure written in Go. This only matters on big-endian systems when returning an integer smaller than the pointer size, which is why we didn't notice it until now. Fixes https://gcc.gnu.org/PR91781. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/195858 From-SVN: r275813
2019-09-17reflect: unexport FFICallbackGo; use go:linkname insteadIan Lance Taylor2-8/+9
The function was always intended to be internal-only, but was exported so that C code could call it. Now that have go:linkname for that, use it. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/195857 From-SVN: r275809
2019-09-13libgo: don't use \? in grep patternIan Lance Taylor2-2/+2
It's not supported by Solaris grep. Just use * instead; it matches more but it shouldn't matter. Fixes https://gcc.gnu.org/PR91764 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/195238 From-SVN: r275700
2019-09-12libgo: update to Go1.13Ian Lance Taylor205-1693/+3543
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194698 From-SVN: r275691
2019-09-11golang.org/x/sys/cpu: define doinit when neededIan Lance Taylor1-0/+9
Should fix the build on riscv64 and other systems. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194641 From-SVN: r275650
2019-09-11gotest: force test package to be imported firstIan Lance Taylor1-2/+11
When compiling the x_test package, force the test package to be imported first. That ensures that we will see the types defined in the test package before the types defined in the non-test version of the package. This matters if the types differ in some way, such as by adding a new method. This avoids a failure in internal/poll on Solaris, in which the test package adds a method to a type (FD.EOFError). I think it was Solaris- specific because files are sorted in a different order by default. The go tool handles this kind of thing correctly, by rebuilding dependent packages. This is just a hack sufficient to run the libgo testsuite without using the go tool. Fixes https://gcc.gnu.org/PR91712 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194637 From-SVN: r275648
2019-09-10libgo: Solaris and x/sys/cpu compatibility fixesIan Lance Taylor15-120/+49
Restore Solaris compatibility fixes lost when internal/x/net/lif moved to golang.org/x/net/lif. Also fix the Makefile for x/net/lif and x/net/route. Change x/sys/cpu to get the cache line size from goarch.sh as the gofrontend version of internal/cpu does. Partially based on work by Rainer Orth. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194438 From-SVN: r275611
2019-09-10re PR go/91621 (libgo/mksysinfo.sh: please avoid test ==)Ian Lance Taylor1-1/+1
PR go/91621 mksysinfo: change test == to test = Fixes https://gcc.gnu.org/PR91621 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194569 From-SVN: r275608
2019-09-10go/internal/gccgoimporter: support embedded field in pointer loopIan Lance Taylor4-25/+74
Backport of https://golang.org/cl/194440. Original description: If an embedded field refers to a type via a pointer, the parser needs to know the name of the embedded field. It is possible that the pointer type is not yet resolved. This CL fixes the parser to handle that case by setting the pointer element type to the unresolved named type while the pointer is being resolved. Updates golang/go#34182 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194562 From-SVN: r275606
2019-09-10cmd/go: look for tool build ID before hashing entire fileIan Lance Taylor1-4/+9
Also fix the key used to store the ID. This is a significant speedup in cmd/go run time. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194257 From-SVN: r275559
2019-09-09misc/cgo/testcshared: restore gofrontend-local changesIan Lance Taylor2-2/+2
They were lost when the files were moved in the update to Go1.13beta1. These changes should be made in the master repo for the 1.14 release, as riscv64 support is added there. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194343 From-SVN: r275551
2019-09-09libgo: only build x/sys/cpu/cpu_gccgo.c on x86 systemsIan Lance Taylor4-13/+39
The C file has a build tag, but the procedure we use for building C files ignores build tags. This should fix the libgo build on non-x86 systems. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194378 From-SVN: r275544
2019-09-06libgo: update to Go 1.13beta1 releaseIan Lance Taylor1837-63536/+122473
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/193497 From-SVN: r275473
2019-08-31compiler, runtime: support and use single argument go:linknameIan Lance Taylor34-284/+259
The gc compiler has started permitting go:linkname comments with a single argument to mean that a function should be externally visible outside the package. Implement this in the Go frontend. Change the libgo runtime package to use it, rather than repeating the name just to export a function. Remove a couple of unnecessary go:linkname comments on declarations. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/192197 From-SVN: r275239
2019-08-31runtime: always build panic32.goIan Lance Taylor1-2/+0
Avoids problems with arm64 ILP32 mode. We might want to handle that mode better in general, but always building panic32.go is simple and fixes the build. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/192723 From-SVN: r275237
2019-08-30compile, runtime: permit anonymous and empty fields in C headerIan Lance Taylor10-331/+97
Permit putting structs with anonymous and empty fields in the C header file runtime.inc that is used to build the C runtime code. This is required for upcoming 1.13 support, as the m struct has picked up an anonymous field. Doing this lets the C header contain all the type descriptor structs, so start using those in the C code. This cuts the number of copies of type descriptor definitions from 3 to 2. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/192343 From-SVN: r275227
2019-08-28runtime: move osinit to GoIan Lance Taylor29-738/+493
This is a step toward updating libgo to 1.13. This adds the 1.13 version of the osinit function to Go code, and removes the corresponding code from the C runtime. This should simplify future updates. Some additional 1.13 code was brought in to simplify this change. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/191717 From-SVN: r275010
2019-08-28compiler, runtime: provide index information on bounds check failureIan Lance Taylor4-33/+358
This implements https://golang.org/cl/161477 in the gofrontend. Updates golang/go#30116 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/191881 From-SVN: r274998
2019-08-27libgo: rebuild runtime.inc if mkruntimeinc.sh changesIan Lance Taylor2-4/+6
The Makefile was missing a dependency. Also remove runtime.inc.raw in mostlyclean. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/191958 From-SVN: r274956
2019-08-23compiler: record pointer var values to remove write barriersIan Lance Taylor1-0/+1
Record when a local pointer variable is set to a value such that indirecting through the pointer does not require a write barrier. Use that to eliminate write barriers when indirecting through that local pointer variable. Only keep this information per-block, so it's not all that applicable. This reduces the number of write barriers generated when compiling the runtime package from 553 to 524. The point of this is to eliminate a bad write barrier in the bytes function in runtime/print.go. Mark that function nowritebarrier so that the problem does not recur. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/191581 From-SVN: r274890
2019-08-20compiler, runtime: implement shifts by signed amountsIan Lance Taylor1-1/+7
Shifting by signed types is a new language feature in Go 1.13. This requires a patch to the testsuite. Updates golang/go#19113 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/190977 * go.test/test/fixedbugs/bug073.go: Update for language changes. From-SVN: r274755
2019-08-19runtime: be more strict in GCIan Lance Taylor3-54/+12
With CL 190599, along with what we do in greyobject, we ensure that we only mark allocated heap objects. As a result we can be more strict in GC: - Enable "sweep increased allocation count" check, which checks that the number of mark bits set are no more than the number of allocation bits. - Enable invalid pointer check on heap scan. We only trace allocated heap objects, which should not contain invalid pointer. This also makes the libgo runtime more convergent with the gc runtime. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/190797 From-SVN: r274678
2019-08-17compiler, runtime: allocate defer records on the stackIan Lance Taylor4-0/+114
When a defer is executed at most once in a function body, we can allocate the defer record for it on the stack instead of on the heap. This should make defers like this (which are very common) faster. This is a port of CL 171758 from the gc repo. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/190410 From-SVN: r274613
2019-08-17runtime: scan write barrier buffer conservativelyIan Lance Taylor1-1/+8
In gccgo, we insert the write barriers in the frontend, and so we cannot completely prevent write barriers on stack writes. So it is possible for a bad pointer appearing in the write barrier buffer. When flushing the write barrier, treat it the same as sacnning the stack. In particular, don't mark a pointer if it does not point to an allocated object. We already have similar logic in greyobject. With this, hopefully, we can prevent an unallocated object from being marked completely. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/190599 From-SVN: r274598
2019-07-15runtime: expose the g variableIan Lance Taylor1-2/+2
Currently, getg is implemented in C, which loads the thread-local g variable. The g variable is declared static in C. This CL exposes the g variable, so it can be accessed from the Go side. This allows the Go compiler to inline getg calls to direct access of g. Currently, the actual inlining is only implemented in the gollvm compiler. The g variable is thread-local and the compiler backend may choose to cache the TLS address in a register or on stack. If a thread switch happens the cache may become invalid. I don't know how to disable the TLS address cache in gccgo, therefore the inlining of getg is not implemented. In the future gccgo may gain this if we know how to do it safely. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/186238 From-SVN: r273499
2019-07-04compiler: optimize 0,1,2-case select statementIan Lance Taylor2-0/+4
For a select statement with zero-, one-, or two-case with a default case, we can generate simpler code instead of calling the generic selectgo. A zero-case select is just blocking the execution. A one-case select is mostly just executing the case. A two-case select with a default case is a non-blocking send or receive. We add these special cases for lowering a select statement. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/184998 From-SVN: r273034
2019-06-26libgo/testsuite: ignore symbols with a leading dot in symtogoIan Lance Taylor1-0/+7
On AIX, a function has two symbols, a text symbol (with a leading dot) and a data one (without it). As the tests must be run only once, only the data symbol can be used to retrieve the final go symbol. Therefore, all symbols beginning with a dot are ignored by symtogo. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/177837 From-SVN: r272666
2019-06-26cmd/go: silence ar with D flag failuresIan Lance Taylor1-1/+8
The first call of ar must not show its output in order to avoid useless error messages about D flag. The corresponding Go toolchain patch is CL 182077. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/183817 From-SVN: r272661
2019-06-25runtime: mark memequal and memclrNoHeapPointers nosplitIan Lance Taylor2-2/+4
They are wrappers of libc functions that use no stack. Mark them nosplit so the linker won't patch it to call __morestack_non_split. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/183629 From-SVN: r272633
2019-06-24compiler: open code string equalityIan Lance Taylor2-13/+0
Open code string equality with builtin memcmp. This allows further optimizations in the backend. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/183538 From-SVN: r272624
2019-06-24compiler: use builtin memcmp directlyIan Lance Taylor3-20/+2
Instead of going through a C function __go_memcmp, we can just use __builtin_memcmp directly. This allows more optimizations in the compiler backend. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/183537 From-SVN: r272620
2019-06-21runtime: inline and remove eqtypeIan Lance Taylor3-16/+11
Now that type equality is just a pointer equality, write it inlined and remove the eqtype function. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/182978 From-SVN: r272578
2019-06-21compiler: open code some type assertionsIan Lance Taylor1-33/+4
Now that type equality is just simple pointer equality, we can open code some type assertions instead of making runtime calls. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/182977 From-SVN: r272577
2019-06-21compiler: open code string slice expressionsIan Lance Taylor3-41/+6
Currently a string slice expression is implemented with a runtime call __go_string_slice. Change it to open code it, which is more efficient, and allows the backend to further optimize it. Also omit the write barrier for length-only update (i.e. s = s[:n]). Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/182540 From-SVN: r272549
2019-06-19compiler: optimize string concatenationsIan Lance Taylor1-21/+3
runtime.concatstring{2,3,4,5} are just wrappers of concatstrings. These wrappers don't provide any benefit, at least in the C calling convention we use, where passing arrays by value isn't an efficient thing. Change it to always use concatstrings. Also, the cap field of the slice passed to concatstrings is not necessary. So change it to pass a pointer and a length directly, which is more efficient than passing a slice header by value. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/182539 From-SVN: r272476
2019-06-07go/internal/gccgoimporter: ignore unexported and imported namesIan Lance Taylor1-26/+27
Due to inlining, we can now see unexported functions and variables, and functions and variables imported from different packages. Ignore them rather than reporting them from this package. Handle $hash and $equal functions consistently, so that we discard the inline body if there is one. Ignore names created for result parameters for inlining purposes. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/180758 From-SVN: r272023
2019-06-06compiler: make use of specialized fast map routinesIan Lance Taylor3-0/+26
In the runtime there are specialized fast map routines for certain kep types. This CL lets the compiler make use of these functions, instead of always using the generic ones. As we now generate multiple versions of map delete calls, to make things easier we delay the expansion of the built-in delete function to flatten phase. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/180858 From-SVN: r271983
2019-06-05compiler: inline call expressions and function referencesIan Lance Taylor1-2/+15
Scan inlinable methods for references to global variables and functions (forgot to do that earlier). Track all packages mentioned by exports (that should have been done earlier too). Record assembler name in export data, so that we can inline calls to non-Go functions. Modify gccgoimporter code to skip assembler name. This increases the number of inlinable functions in the standard library from 215 to 439. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/180677 From-SVN: r271976
2019-06-03compiler, runtime, reflect: generate unique type descriptorsIan Lance Taylor2-79/+130
Currently, the compiler already generates common symbols for type descriptors, so the type descriptors are unique. However, when a type is created through reflection, it is not deduplicated with compiler-generated types. As a consequence, we cannot assume type descriptors are unique, and cannot use pointer equality to compare them. Also, when constructing a reflect.Type, it has to go through a canonicalization map, which introduces overhead to reflect.TypeOf, and lock contentions in concurrent programs. In order for the reflect package to deduplicate types with compiler-created types, we register all the compiler-created type descriptors at startup time. The reflect package, when it needs to create a type, looks up the registry of compiler-created types before creates a new one. There is no lock contention since the registry is read-only after initialization. This lets us get rid of the canonicalization map, and also makes it possible to compare type descriptors with pointer equality. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/179598 From-SVN: r271894
2019-06-03libgo: delay applying profile stack-frame skip until fixupIan Lance Taylor3-23/+31
When the runtime collects a stack trace to associate it with some profiling event (mem alloc, mutex, etc) there is a skip count passed to runtime.Callers (or equivalent) to skip some known count of frames in order to get to the "interesting" frame corresponding to the profile event. Now that the profiling mechanism uses lazy fixup (when removing compiler artifacts like thunks, morestack calls etc), we also need to move the frame skipping logic after the fixup, so as to insure that the skip count isn't thrown off by these artifacts. Fixes golang/go#32290. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/179740 From-SVN: r271892
2019-06-03runtime: remove unnecessary functions calling between C and GoIan Lance Taylor5-90/+1
These functions were needed during the transition of the runtime from C to Go, but are no longer necessary. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/179879 From-SVN: r271890
2019-06-03runtime: fix assembly syntaxIan Lance Taylor1-1/+1
Some assembler doesn't accept ULL suffix. In fact the suffix is not really necessary. Drop it. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/180217 From-SVN: r271883
2019-05-31runtime: drop unused C type reflection codeIan Lance Taylor7-199/+9
In particular, drop __go_type_descriptors_equal, which is no longer used, and will be made obsolete by CL 179598. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/179858 From-SVN: r271823
2019-05-31compiler: optimize append of makeIan Lance Taylor1-9/+15
The gc compiler recognizes append(s, make([]T, n)...), and generates code to directly zero the tail instead of allocating a new slice and copying. This CL lets the Go frontend do basically the same. The difficulty is that at the point we handle append, there may already be temporaries introduced (e.g. in order_evaluations), which makes it hard to find the append-of-make pattern. The compiler could "see through" the value of a temporary, but it is only safe to do if the temporary is not assigned multiple times. For this, we add tracking of assignments and uses for temporaries. This also helps in optimizing non-escape slice make. We already optimize non-escape slice make with constant len/cap to stack allocation. But it failed to handle things like f(make([]T, n)) (where the slice doesn't escape and n is constant), because of the temporary. With tracking of temporary assignments and uses, it can handle this now as well. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/179597 From-SVN: r271822