aboutsummaryrefslogtreecommitdiff
path: root/libgo
AgeCommit message (Collapse)AuthorFilesLines
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
2019-05-31runtime: implement cheaper context switch on Linux/AMD64Ian Lance Taylor9-24/+333
Currently, goroutine switches are implemented with libc getcontext/setcontext functions, which saves/restores the machine register states and also the signal context. This does more than what we need, and performs an expensive syscall. This CL implements a simplified version of getcontext/setcontext, in assembly, that only saves/restores the necessary part, i.e. the callee-save registers, and the PC, SP. A simplified version of makecontext, written in C, is also added. Currently this is only implemented on Linux/AMD64. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/178298 From-SVN: r271818
2019-05-27re PR go/90635 (typo in libgo/configure.ac)Ian Lance Taylor2-2/+2
PR go/90635 libgo: correct typo in USE_LIBFFI AM_CONDITIONAL Only affects the case of passing --without-libffi to configure. Fixes https://gcc.gnu.org/PR90635 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/178998 From-SVN: r271640
2019-05-27re PR go/90614 (gcc-9.1.0/libgo/go/syscall/wait.c:54:22: error: unused ↵Ian Lance Taylor1-1/+1
parameter ‘w’ [-Werror=unused-parameter] Continued (uint32_t *w)) PR go/90614 syscall: avoid unused parameter error if WIFCONTINUED not defined Fixes https://gcc.gnu.org/PR90614 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/178997 From-SVN: r271638
2019-05-14libgo: reduce overhead for memory/block/mutex profilingIan Lance Taylor10-92/+359
Revise the gccgo version of memory/block/mutex profiling to reduce runtime overhead. The main change is to collect raw stack traces while the profile is on line, then post-process the stacks just prior to the point where we are ready to use the final product. Memory profiling (at a very low sampling rate) is enabled by default, and the overhead of the symbolization / DWARF-reading from backtrace_full was slowing things down relative to the main Go runtime. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/171497 From-SVN: r271172
2019-05-13libgo: drop Solaris 10 supportIan Lance Taylor4-11/+2
Based on patch by Rainer Orth. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/176938 From-SVN: r271135
2019-05-11runtime: set up g earlyIan Lance Taylor4-7/+15
runtime.throw needs a g to work properly. Set up g early, to ensure that if something goes wrong in the runtime startup (e.g. runtime.check fails), the program terminates in a reasonable way. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/176657 From-SVN: r271088
2019-05-08libgo: add Debugging section to READMEIan Lance Taylor1-0/+25
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/176001 From-SVN: r271019
2019-05-08runtime: use builtin memmove directlyCherry Zhang4-31/+10
We can use the intrinsic memmove directly, without going through C. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/170004 * go-gcc.cc (Gcc_backend::Gcc_backend): Define memmove builtin. From-SVN: r271016
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-05-03compiler: recognize and optimize array range clearIan Lance Taylor1-0/+1
Recognize for i := range a { a[i] = zero } for array or slice a, and rewrite it to call memclr, as the gc compiler does. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/169398 From-SVN: r270862
2019-05-03os/user: disable TestGroupIds for AIXIan Lance Taylor1-0/+3
The corresponding Go Toolchain patch is CL 164039 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/175079 From-SVN: r270857
2019-05-01compiler: recognize and optimize map range clearIan Lance Taylor1-0/+1
Recognize for k := range m { delete(m, k) } for map m, and rewrite it to runtime.mapclear, as the gc compiler does. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/169397 From-SVN: r270780
2019-05-01compiler,runtime: do more direct interfacesIan Lance Taylor6-16/+31
A direct interface is an interface whose data word contains the actual data value, instead of a pointer to it. The gc toolchain creates a direct interface if the value is pointer shaped, that includes pointers (including unsafe.Pointer), functions, channels, maps, and structs and arrays containing a single pointer-shaped field. In gccgo, we only do this for pointers. This CL unifies direct interface types with gc. This reduces allocations when converting such types to interfaces. Our method functions used to always take pointer receivers, to make interface calls easy. Now for direct interface types, their value methods will take value receivers. For a pointer to those types, when converted to interface, the interface data contains the pointer. For that interface to call a value method, it will need a wrapper method that dereference the pointer and invokes the value method. The wrapper method, instead of the actual one, is put into the itable of the pointer type. In the runtime, adjust funcPC for the new layout of interfaces of functions. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/168409 From-SVN: r270779
2019-05-01runtime: persistentalloc and cache itabsIan Lance Taylor1-31/+225
Previously, each time we do an interface conversion for which the method table is not known at compile time, we allocate a new method table. This CL ports the mechanism of itab caching from the gc runtime, adapted to our itab representation and method finding mechanism. With the cache, we reuse the same itab for the same (interface, concrete) type pair. This reduces allocations in interface conversions. Unlike the gc runtime, we don't prepopulate the cache with statically allocated itabs, as currently we don't have a way to find them. This means we don't deduplicate run-time allocated itabs with compile-time allocated ones. But that is not too bad -- it is just a cache anyway. As now itabs are never freed, it is also possible to drop the write barrier for writing the first word of an interface header. I'll leave this optimization for the future. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/171617 From-SVN: r270778
2019-04-26runtime: fix TestPhysPageSize on AIXIan Lance Taylor1-0/+5
AIX doesn't allow to mmap an address range which is already mmap. Therefore, once the region has been allocated, it must munmap before being able to play with it. The corresponding Go Toolchain patch is CL 174059. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/174138 From-SVN: r270615
2019-04-24re PR target/89093 (C++ exception handling clobbers d8 VFP register)Ian Lance Taylor1-1/+4
PR target/89093 runtime: mark unwind functions general-regs-only on ARM For https://gcc.gnu.org/PR89093. Change-Id: Ic426b43d633c77104bda01d4e7835bc9ab4695ef Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/173657 Reviewed-by: Ian Lance Taylor <iant@golang.org> From-SVN: r270542
2019-04-19libgo/go/syscall: add SockAddrDatalink on AIXIan Lance Taylor1-0/+24
This patch is required in order to build golang.org/x/net. The corresponding Go Toolchain patch is CL 170537. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/172898 From-SVN: r270458
2019-04-08libgo: update to Go 1.12.2Ian Lance Taylor20-73/+269
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/170706 From-SVN: r270214
2019-03-19compiler,runtime: pass old slice's ptr/len/cap by value to growsliceIan Lance Taylor1-15/+15
In the C calling convention, on AMD64, and probably a number of other architectures, a 3-word struct argument is passed on stack. This is less efficient than passing in three registers. Further, this may affect the code generation in other part of the program, even if the function is not actually called. Slices are common in Go and append is a common slice operation, which calls growslice in the growing path. To improve the code generation, pass the slice header's three fields as separate values, instead of a struct, to growslice. The drawback is that this makes the runtime implementation slightly diverges from the gc runtime. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/168277 From-SVN: r269811
2019-03-19libgo: fix build on AIXIan Lance Taylor28-201/+139
Since aix/ppc64 has been added to GC toolchain, a mix between new and old files were created in gcc toolchain. This commit corrects this merge for aix/ppc64 and aix/ppc. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/167658 From-SVN: r269797
2019-03-18libgo: update to Go 1.12.1Ian Lance Taylor22-137/+397
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/167749 From-SVN: r269780
2019-03-09re PR go/89447 (libgo largefile support is incomplete and inconsistent)Ian Lance Taylor11-9/+75
PR go/89447 syscall, internal/syscall: adjust use of largefile functions Consistently call __go_openat for openat. Use fstatat64, creat64, sendfile64, and getdents64 where needed. Based on patch by Rainer Orth. Fixes https://gcc.gnu.org/PR89447 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/166420 From-SVN: r269521
2019-03-06mksysinfo: actually use modified Statfs_t valueIan Lance Taylor1-5/+4
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/165737 From-SVN: r269424
2019-03-05runtime: enable precise GC checks when using stack mapsIan Lance Taylor3-5/+9
In the runtime there are bad pointer checks that currently don't work with the concervative collector. With stack maps, the GC is precise and the checks should work. Enable them. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/153871 From-SVN: r269406
2019-03-05cmd/go: pass -X64 to ar on aix/ppc64Ian Lance Taylor1-3/+10
On aix/ppc64, ar tool must always have -X64 argument if it aims to create 64 bits archives. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/165317 From-SVN: r269404
2019-03-05sysinfo: add Flags to Statfs_t if not already thereIan Lance Taylor1-0/+4
If there is no f_flags field in statfs_t then rename one of the f_spare fields, as happened in Linux kernel version 2.6.36. This fixes the build on CentOS 5.11. The CentOS kernel will hopefully not fill in the f_spare field, so the resulting flags will be zero. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/165417 From-SVN: r269401
2019-03-02re PR go/89406 (Go testing leaves many temporary directories in /tmp around)Ian Lance Taylor1-6/+6
PR go/89406 go/internal/gccgoimporter: remove temporary directories in test Backport of https://golang.org/cl/164862. Updates https://gcc.gnu.org/PR89406 Reviewed-on: https://go-review.googlesource.com/c/164863 From-SVN: r269338
2019-03-01cmd/go: restore passing D to arIan Lance Taylor1-3/+6
This restores part of https://golang.org/cl/45695 that was accidentally lost in https://golang.org/cl/158019 (the update to Go1.12beta2). Reviewed-on: https://go-review.googlesource.com/c/164737 From-SVN: r269333
2019-03-01runtime: call execname and getpagesize on SolarisIan Lance Taylor1-34/+8
Interpreting auxv as []uintptr is incorrect on 64-bit big-endian, as auxv alternates a 32-bit int with a 64-bit pointer. Patch from Rainer Orth. Reviewed-on: https://go-review.googlesource.com/c/164739 From-SVN: r269315
2019-03-01cmd/go: add -O2 to invocation of gccgoIan Lance Taylor1-1/+1
When using the go tool with gccgo, this changes the default compilation to use -O2. The -gccgoflags option can be used to override this default. I think this change better corresponds to what people expect when using the go tool. Reviewed-on: https://go-review.googlesource.com/c/164378 From-SVN: r269299
2019-03-01commit 66ac9466852d11e968f8fd2ad6ffc7386cee49e1Ian Lance Taylor1-5/+9
gotest: avoid using echo inside $() The handling of newlines is not portable between bash and ksh. Reviewed-on: https://go-review.googlesource.com/c/164597 From-SVN: r269298