Commit Graph

1158 Commits

Author SHA1 Message Date
Ian Lance Taylor 07525dad06 libgo/testsuite: ignore symbols with a leading dot in symtogo
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-26 00:17:32 +00:00
Ian Lance Taylor c31a34018a cmd/go: silence ar with D flag failures
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-26 00:04:36 +00:00
Ian Lance Taylor 81fadf1c8d runtime: mark memequal and memclrNoHeapPointers nosplit
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-25 06:16:21 +00:00
Ian Lance Taylor 609c7da9ab compiler: open code string equality
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-24 17:54:07 +00:00
Ian Lance Taylor 2b92d5c69b compiler: use builtin memcmp directly
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-24 16:54:22 +00:00
Ian Lance Taylor f4e7200b1d runtime: inline and remove eqtype
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-21 22:21:40 +00:00
Ian Lance Taylor 0514cb3374 compiler: open code some type assertions
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-21 22:00:57 +00:00
Ian Lance Taylor c9b236e5ca compiler: open code string slice expressions
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-21 14:14:58 +00:00
Ian Lance Taylor 4349775a30 compiler: optimize string concatenations
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-19 15:13:53 +00:00
Ian Lance Taylor ffaa3a1c74 go/internal/gccgoimporter: ignore unexported and imported names
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-07 00:07:50 +00:00
Ian Lance Taylor 269f05ff58 compiler: make use of specialized fast map routines
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-06 00:44:01 +00:00
Ian Lance Taylor 5a9422664e compiler: inline call expressions and function references
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-05 21:05:38 +00:00
Ian Lance Taylor 39c0aa5f74 compiler, runtime, reflect: generate unique type descriptors
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-03 23:37:04 +00:00
Ian Lance Taylor c533ffe04d libgo: delay applying profile stack-frame skip until fixup
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-03 23:07:54 +00:00
Ian Lance Taylor a920eb0cb0 runtime: remove unnecessary functions calling between C and Go
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-03 23:02:43 +00:00
Ian Lance Taylor fdb1849a6c runtime: fix assembly syntax
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-06-03 20:06:50 +00:00
Ian Lance Taylor 2099d44658 runtime: drop unused C type reflection code
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-31 21:32:47 +00:00
Ian Lance Taylor 6303331c33 compiler: optimize append of make
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-31 21:18:39 +00:00
Ian Lance Taylor 4d12cf3cc3 runtime: implement cheaper context switch on Linux/AMD64
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-31 17:56:36 +00:00
Ian Lance Taylor 8b9cfd766d re PR go/90635 (typo in libgo/configure.ac)
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-27 00:14:02 +00:00
Ian Lance Taylor 8b33101442 re PR go/90614 (gcc-9.1.0/libgo/go/syscall/wait.c:54:22: error: unused 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-27 00:10:34 +00:00
Ian Lance Taylor 1ac09ef2c6 libgo: reduce overhead for memory/block/mutex profiling
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-14 14:59:42 +00:00
Ian Lance Taylor 93ee143d18 libgo: drop Solaris 10 support
Based on patch by Rainer Orth.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/176938

From-SVN: r271135
2019-05-13 20:26:24 +00:00
Ian Lance Taylor c130ab6aad runtime: set up g early
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-11 01:12:37 +00:00
Ian Lance Taylor 8238b660fb libgo: add Debugging section to README
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/176001

From-SVN: r271019
2019-05-08 22:07:40 +00:00
Cherry Zhang fbe4e644c0 runtime: use builtin memmove directly
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-08 17:40:45 +00:00
Ian Lance Taylor b65b77cc80 reflect: correctly handle direct interface typed receiver in Value.call
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-08 04:39:19 +00:00
Ian Lance Taylor 08c8a26e9c compiler: recognize and optimize array range clear
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-03 21:45:35 +00:00
Ian Lance Taylor 16df703871 os/user: disable TestGroupIds for AIX
The corresponding Go Toolchain patch is CL 164039
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/175079

From-SVN: r270857
2019-05-03 17:15:54 +00:00
Ian Lance Taylor 58dbd45339 compiler: recognize and optimize map range clear
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-01 21:37:00 +00:00
Ian Lance Taylor 5e87c2806f compiler,runtime: do more direct interfaces
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-01 21:34:16 +00:00
Ian Lance Taylor 1da37f43b2 runtime: persistentalloc and cache itabs
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-05-01 20:27:36 +00:00
Ian Lance Taylor 8d266165b9 runtime: fix TestPhysPageSize on AIX
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-26 17:20:55 +00:00
Ian Lance Taylor 972206e0c2 re PR target/89093 (C++ exception handling clobbers d8 VFP register)
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-24 12:45:45 +00:00
Ian Lance Taylor f4488799b2 libgo/go/syscall: add SockAddrDatalink on AIX
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-19 14:20:16 +00:00
Ian Lance Taylor 04862afe9f libgo: update to Go 1.12.2
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/170706

From-SVN: r270214
2019-04-08 18:36:25 +00:00
Ian Lance Taylor ea5ac5a69b compiler,runtime: pass old slice's ptr/len/cap by value to growslice
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-19 18:42:43 +00:00
Ian Lance Taylor 9195aa172b libgo: fix build on AIX
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-19 14:00:59 +00:00
Ian Lance Taylor a8b58d84bf libgo: update to Go 1.12.1
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/167749

From-SVN: r269780
2019-03-18 20:27:59 +00:00
Ian Lance Taylor ee973155b2 re PR go/89447 (libgo largefile support is incomplete and inconsistent)
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-09 02:10:22 +00:00
Ian Lance Taylor 0e1a6d2700 mksysinfo: actually use modified Statfs_t value
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/165737

From-SVN: r269424
2019-03-06 14:19:56 +00:00
Ian Lance Taylor 03ac8302a6 runtime: enable precise GC checks when using stack maps
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-05 23:05:38 +00:00
Ian Lance Taylor b211cd1b46 cmd/go: pass -X64 to ar on aix/ppc64
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-05 22:40:21 +00:00
Ian Lance Taylor 9bf54c938a sysinfo: add Flags to Statfs_t if not already there
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-05 20:49:21 +00:00
Ian Lance Taylor 64ef1e96ff re PR go/89406 (Go testing leaves many temporary directories in /tmp around)
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-02 00:50:30 +00:00
Ian Lance Taylor 8ea1c33cb3 cmd/go: restore passing D to ar
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-01 22:22:18 +00:00
Ian Lance Taylor 337f1caed6 runtime: call execname and getpagesize on Solaris
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-01 14:21:24 +00:00
Ian Lance Taylor 3eba09884e cmd/go: add -O2 to invocation of gccgo
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-01 01:23:09 +00:00
Ian Lance Taylor 5b2eaa1170 commit 66ac9466852d11e968f8fd2ad6ffc7386cee49e1
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
2019-03-01 01:03:54 +00:00
Ian Lance Taylor b0cf10e423 libgo: fix go_export extraction on Darwin
On Darwin, the section name is prefixed with the segment name, __GNU_GO.
    
    Reviewed-on: https://go-review.googlesource.com/c/151097

From-SVN: r269271
2019-02-28 01:01:46 +00:00