Commit Graph

1360 Commits

Author SHA1 Message Date
Ian Lance Taylor 92bea423c2 gotest: explicitly skip type descriptors
Type descriptors are normally weak and nm will report them as V,
so we will skip them when collecting the list of symbols.
But when not using GNU nm, they may be reported as D,
so also skip them in symstogo.

This fixes go/doc/check on Solaris.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/215900
2020-01-22 20:53:43 -08:00
Ian Lance Taylor 9e16359ce8 runtime: for Solaris, add osinit, and drop duplicate getncpu
Fixes a build breakage introduced in the 1.14beta1 upgrade.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/215857
2020-01-22 15:08:25 -08:00
Andrew Pinski 26afdf5070 internal/syscall/unix: use getrandom_linux_generic.go on arm64be
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/215342
2020-01-22 15:05:26 -08:00
Ian Lance Taylor 68cbbe7cdc runtime: call runtime_nanotime1, not runtime_nanotime
The function name was changed in 1.14beta1. Fix the non-x86, non-s390 code.

Fixes golang/go#36694

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/215724
2020-01-22 11:14:52 -08:00
Ian Lance Taylor 5a8ea16592 libgo: update to Go1.14beta1
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/214297
2020-01-21 23:53:22 -08:00
Ian Lance Taylor 3a33f87ffb gotest: don't use local
It's not part of the POSIX shell standard.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/214300

From-SVN: r280118
2020-01-10 15:28:20 +00:00
Ian Lance Taylor fcee603081 libgo: compile examples in _test packages
Previously if the only names defined by _test packages were examples,
    the gotest script would emit an incorrect _testmain.go file.
    I worked around that by marking the example_test.go files +build ignored.
    
    This CL changes the gotest script to handle this case correctly,
    and removes the now-unnecessary build tags.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/214039

From-SVN: r280085
2020-01-09 23:14:57 +00:00
Ian Lance Taylor 81f025b580 compiler, runtime: stop using __go_runtime_error
Use specific panic functions instead, which are mostly already in the
    runtime package.
    
    Also correct "defer nil" to panic when we execute the defer, rather
    than throw when we queue it.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/213642

From-SVN: r279979
2020-01-07 23:13:24 +00:00
Ian Lance Taylor 10172a64ce compiler, runtime, reflect: generate hash functions only for map keys
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
2020-01-02 21:55:32 +00:00
Ian Lance Taylor f2a8799309 re PR go/93020 (Final patches to build gcc-10 on GNU/Hurd)
PR go/93020
    libgo: Hurd portability patches
    
    By Svante Signell.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/212409

From-SVN: r279724
2019-12-24 05:05:32 +00:00
Ian Lance Taylor 763c9f4a85 re PR go/92861 (Passes relative time to sem_timedwait on GNU/Hurd)
PR go/92861
    runtime: don't define CLOCK_REALTIME in os_hurd.go
    
    It's already defined in sysinfo.go.
    
    Patch by Samuel Thibault.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/210538

From-SVN: r279136
2019-12-09 18:03:53 +00:00
Ian Lance Taylor 9135a6ffc5 re PR go/92861 (Passes relative time to sem_timedwait on GNU/Hurd)
PR go/92861
    runtime: use absolute time for sem_timedwait
    
    Patch by Samuel Thibault.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/210457

From-SVN: r279106
2019-12-09 03:43:33 +00:00
Ian Lance Taylor eff6af8e0e re PR go/92820 (libgo.so.15 has executable stack)
PR go/92820
    runtime: only build go-context for x86 GNU/Linux
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/210258

From-SVN: r279063
2019-12-06 19:52:46 +00:00
Ian Lance Taylor 5ec7a413d1 re PR other/29842 ([meta-bug] outstanding patches / issues from STMicroelectronics)
PR go/29842
    runtime: update HURD support for mOS now being embedded
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/210285

From-SVN: r279062
2019-12-06 19:37:39 +00:00
Ian Lance Taylor 9961856c3a re PR go/92810 (Compiling GCC go for aarch64_be-marvell-linux-gnu fails)
PR go/92810
    libgo: recognize aarch64_be as arm64be
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/210038

From-SVN: r279032
2019-12-06 05:32:49 +00:00
Ian Lance Taylor 9bcee9c9a1 re PR go/92820 (libgo.so.15 has executable stack)
PR go/92820
    runtime: always mark assembly file as non-executable stack
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/210037

From-SVN: r279010
2019-12-05 17:51:10 +00:00
Ian Lance Taylor b4b7464b57 re PR go/92605 (r278509 causes/reveals issue in building go library)
PR go/92605
    runtime: declare runtime_usestackmaps in stack.c, not runtime.h
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/208161

From-SVN: r278540
2019-11-21 01:06:47 +00:00
Ian Lance Taylor 025f56b7d3 mksysinfo: use type aliases for time struct field types
Also fix a case where grep wasn't redirecting to /dev/null.
    
    Fixes golang/go#35713
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/208160

From-SVN: r278539
2019-11-21 01:03:55 +00:00
Ian Lance Taylor 0c6ce0ae55 libgo: better cmd/cgo handling for '.' in pkgpath
Updates cgo's gccgoPkgpathToSymbolNew() to bring it into
    conformance with the way that gccgo now handles package
    paths with embedded dots (see CL 200838). See also
    https://gcc.gnu.org/PR61880, a related bug. This CL is a
    copy of CL 207957 in the main Go repo.
    
    Updates golang/go#35623.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/207977

From-SVN: r278470
2019-11-19 23:04:08 +00:00
Ian Lance Taylor ae0b0fc6ae testmain.exp: link against GOLIBS
Patch by Maciej W. Rozycki.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/207458

From-SVN: r278316
2019-11-15 21:14:29 +00:00
Ian Lance Taylor b72813a68c libgo: fix DejaGNU testsuite compiler when using build sysroot
Patch by Maciej W. Rozycki.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/206577

From-SVN: r278070
2019-11-11 23:28:54 +00:00
Ian Lance Taylor 2dccdbcff6 runtime: correct facilities names in s390 CPU support
Patch from Andreas Krebbel.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/201038

From-SVN: r276964
2019-10-14 14:10:16 +00:00
Ian Lance Taylor d2317d50ae internal/cpu: define kdsaQuery for s390
Patch from Andreas Krebbel.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/201037

From-SVN: r276962
2019-10-14 14:01:15 +00:00
Ian Lance Taylor b7c4123032 runtime: mark go-context.S as no-executable-stack and split-stack supported
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-10-02 20:11:35 +00:00
Ian Lance Taylor ab2d47a87f libgo: support gollvm build on arm64 linux
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-19 00:03:25 +00:00
Ian Lance Taylor 7e6fecf500 runtime: for FFI, treat directIface types as pointers
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-17 20:26:21 +00:00
Ian Lance Taylor 033425d0ed re PR go/91781 (r275691 breaks go test "reflect")
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-17 20:24:00 +00:00
Ian Lance Taylor 99a28ee8c1 reflect: unexport FFICallbackGo; use go:linkname instead
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-17 17:22:18 +00:00
Ian Lance Taylor 57cccc860e libgo: don't use \? in grep pattern
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-13 17:07:20 +00:00
Ian Lance Taylor 656297e1fe libgo: update to Go1.13
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194698

From-SVN: r275691
2019-09-12 23:22:53 +00:00
Ian Lance Taylor debae5232b golang.org/x/sys/cpu: define doinit when needed
Should fix the build on riscv64 and other systems.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194641

From-SVN: r275650
2019-09-11 14:06:05 +00:00
Ian Lance Taylor d694576e17 gotest: force test package to be imported first
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-11 12:44:12 +00:00
Ian Lance Taylor efc864927f libgo: Solaris and x/sys/cpu compatibility fixes
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-10 20:41:04 +00:00
Ian Lance Taylor 4d7bfeec42 re PR go/91621 (libgo/mksysinfo.sh: please avoid test ==)
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-10 20:32:20 +00:00
Ian Lance Taylor a1fc3891eb go/internal/gccgoimporter: support embedded field in pointer loop
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-10 20:25:32 +00:00
Ian Lance Taylor c96fc08123 cmd/go: look for tool build ID before hashing entire file
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-10 02:48:24 +00:00
Ian Lance Taylor 8bdcbd0135 misc/cgo/testcshared: restore gofrontend-local changes
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-09 23:13:08 +00:00
Ian Lance Taylor de0f55dbb3 libgo: only build x/sys/cpu/cpu_gccgo.c on x86 systems
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-09 20:08:32 +00:00
Ian Lance Taylor aa8901e9bb libgo: update to Go 1.13beta1 release
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/193497

From-SVN: r275473
2019-09-06 18:12:46 +00:00
Ian Lance Taylor c70ff9f9be compiler, runtime: support and use single argument go:linkname
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-31 03:01:15 +00:00
Ian Lance Taylor d24c41ef1a runtime: always build panic32.go
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-31 02:55:09 +00:00
Ian Lance Taylor 4a14082645 compile, runtime: permit anonymous and empty fields in C header
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-30 21:49:49 +00:00
Ian Lance Taylor 32b1d51f16 runtime: move osinit to Go
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-28 20:39:32 +00:00
Ian Lance Taylor fc4f90f0c8 compiler, runtime: provide index information on bounds check failure
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-28 18:27:30 +00:00
Ian Lance Taylor 433f84bffa libgo: rebuild runtime.inc if mkruntimeinc.sh changes
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-27 14:25:04 +00:00
Ian Lance Taylor 6ae361ae45 compiler: record pointer var values to remove write barriers
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-23 22:38:58 +00:00
Ian Lance Taylor 43055d2379 compiler, runtime: implement shifts by signed amounts
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-20 21:15:46 +00:00
Ian Lance Taylor 4f6bdb08ba runtime: be more strict in GC
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-19 19:09:50 +00:00
Ian Lance Taylor e68035acfd compiler, runtime: allocate defer records on the stack
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-17 23:43:08 +00:00
Ian Lance Taylor 777c028252 runtime: scan write barrier buffer conservatively
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-08-17 04:35:37 +00:00
Ian Lance Taylor 4e62f891cd runtime: expose the g variable
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-15 21:17:16 +00:00
Ian Lance Taylor 0e68d70b7f compiler: optimize 0,1,2-case select statement
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-07-04 02:20:37 +00:00
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
Ian Lance Taylor cba8a572c2 re PR go/89172 (FAIL: runtime/pprof)
PR go/89172
    internal/cpu, runtime, runtime/pprof: handle function descriptors
    
    When using PPC64 ELF ABI v1 a function address is not a PC, but is the
    address of a function descriptor.  The first field in the function
    descriptor is the actual PC (see
    http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html#FUNC-DES).
    The libbacktrace library knows about this, and libgo uses actual PC
    values consistently except for the helper function funcPC that appears
    in both runtime and runtime/pprof.
    
    This patch fixes funcPC by recording, in the internal/cpu package,
    whether function descriptors are being used.  We have to check for
    function descriptors using a C compiler check, because GCC can be
    configured using --with-abi to select the ELF ABI to use.
    
    Fixes https://gcc.gnu.org/PR89172
    
    Reviewed-on: https://go-review.googlesource.com/c/162978

From-SVN: r269266
2019-02-27 22:35:10 +00:00
Ian Lance Taylor b91dfdcc68 runtime: align first persistentalloc chunk as requested
Backport of upstream https://golang.org/cl/163859.
    
    This fixes various failures on 32-bit SPARC.
    
    Patch from Eric Boctazou.
    
    Reviewed-on: https://go-review.googlesource.com/c/163860

From-SVN: r269258
2019-02-27 15:51:49 +00:00
Ian Lance Taylor 15994bfbca cmd/go: preserve CC for TestScript child processes
Reviewed-on: https://go-review.googlesource.com/c/158838

From-SVN: r269240
2019-02-27 01:11:20 +00:00
Ian Lance Taylor 4fd3c8aad9 libgo: update to Go 1.12 release
Reviewed-on: https://go-review.googlesource.com/c/163742

From-SVN: r269216
2019-02-26 15:38:12 +00:00
Ian Lance Taylor 5c98b419f7 re PR go/86535 (FreeBSD/PowerPC64 - Building Go Frontend support for gcc 7.3.0 fails)
PR go/86535
    runtime: always declare nanotime in Go
    
    For libgo it's always defined in C.
    
    Updates https://gcc.gnu.org/PR86535
    
    Reviewed-on: https://go-review.googlesource.com/c/163743

From-SVN: r269214
2019-02-26 14:46:56 +00:00
Ian Lance Taylor 99e20ba51d libgo: update to Go1.12rc1
Reviewed-on: https://go-review.googlesource.com/c/162881

From-SVN: r269202
2019-02-26 01:00:39 +00:00
Ian Lance Taylor f08e60e988 re PR go/89406 (Go testing leaves many temporary directories in /tmp around)
PR go/89406
    net: remove unixgram test sockets
    
    Backport https://golang.org/cl/163277 from the master library.
    
    Updates https://gcc.gnu.org/PR89406
    
    Reviewed-on: https://go-review.googlesource.com/c/163200

From-SVN: r269087
2019-02-22 00:47:30 +00:00
Ian Lance Taylor 8aef6e02ad cmd/go: remove work directory on usage error
Backport https://golang.org/cl/163237 from the master library:
    
        Ensure that cmd/go consistently calls base.Exit rather than os.Exit,
        so that we don't incorrectly leave the work directory around on exit.
    
        Test this by modifying the testsuite to run all the tests with TMPDIR
        set to a temporary directory, and then check that no files are left
        behind in that temporary directory. Adjust a couple of tests to make
        this approach work.
    
    Updates https://gcc.gnu.org/PR89406
    
    Reviewed-on: https://go-review.googlesource.com/c/163198

From-SVN: r269086
2019-02-22 00:41:25 +00:00
Ian Lance Taylor 556bef7efc re PR go/89407 (go bootstrap failure on s390x starting with r268941)
PR go/89407
    internal/cpu: use #ifdef __s390x__ in C code
    
    Patch by Jakub Jelinek.
    
    Fixes https://gcc.gnu.org/PR89407
    
    Reviewed-on: https://go-review.googlesource.com/c/163297

From-SVN: r269063
2019-02-21 01:06:01 +00:00
Ian Lance Taylor b05b2dba3d re PR go/89169 (FAIL: internal/cpu)
PR go/89169
    internal/cpu: do not require POWER8
    
    Although the gc toolchain requires POWER8, the gccgo toolchain does not.
    
    Fixes https://gcc.gnu.org/PR89169
    
    Reviewed-on: https://go-review.googlesource.com/c/162979

From-SVN: r269019
2019-02-19 15:42:09 +00:00
Ian Lance Taylor 6bd37418a3 runtime: abort stack scan in cases that we cannot unwind the stack
In signal-triggered stack scan, if the signal is delivered at
    certain bad time (e.g. in vdso, or in the middle of setcontext?),
    the unwinder may not be able to unwind the whole stack, while it
    still reports _URC_END_OF_STACK. So we cannot rely on _URC_END_OF_STACK
    to tell if it successfully scanned the stack. Instead, we check
    the last Go frame to see it actually reached the end of the stack.
    For Go-created stack, this is runtime.kickoff. For C-created
    stack, we need to record the outermost Go frame when it enters
    the Go side.
    
    Also we cannot unwind the stack if the signal is delivered in the
    middle of runtime.gogo, halfway through a goroutine switch, where
    the g and the stack don't match. Give up in this case as well.
    
    Reviewed-on: https://go-review.googlesource.com/c/159098

From-SVN: r269018
2019-02-19 15:32:34 +00:00
Cherry Zhang fba70f605e compiler,runtime: use __builtin_dwarf_cfa for getcallersp
Currently, the compiler lowers runtime.getcallersp to
    __builtin_frame_address(1). In the C side of the runtime,
    getcallersp is defined as __builtin_frame_address(0). They don't
    match. Further, neither of them actually returns the caller's SP.
    On AMD64, __builtin_frame_address(0) just returns the frame
    pointer. __builtin_frame_address(1) returns the memory content
    where the frame pointer points to, which is typically the
    caller's frame pointer but can also be garbage if the frame
    pointer is not enabled.
    
    This CL changes it to use __builtin_dwarf_cfa(), which returns
    the caller's SP at the call site. This matches the SP we get
    from unwinding the stack.
    
    Currently getcallersp is not used for anything real. It will be
    used for precise stack scan (a new version of CL 159098).
    
    Reviewed-on: https://go-review.googlesource.com/c/162905

	* go-gcc.cc (Gcc_backend::Gcc_backend): Define __builtin_dwarf_cfa
	instead of __builtin_frame_address.

From-SVN: r268952
2019-02-15 23:22:29 +00:00
Ian Lance Taylor a72128258b re PR go/89123 (Too many go test failures on s390x-linux)
PR go/89123
    internal/cpu, runtime: add S/390 CPU capability support
    
    Patch by Robin Dapp.
    
    Updates https://gcc.gnu.org/PR89123
    
    Reviewed-on: https://go-review.googlesource.com/c/162887

From-SVN: r268941
2019-02-15 14:51:10 +00:00
Ian Lance Taylor 7b54753033 runtime: include <syscall.h> and <sys/syscall.h> if available
Fixes Solaris build.
    
    Reviewed-on: https://go-review.googlesource.com/c/162885

From-SVN: r268940
2019-02-15 14:25:12 +00:00
Ian Lance Taylor d86dd2490f runtime: add type cast for non-split-stack calls to scanstackblock
Reviewed-on: https://go-review.googlesource.com/c/162884

From-SVN: r268939
2019-02-15 13:54:45 +00:00
Ian Lance Taylor 8a9f2a6bbd compiler, runtime: harmonize types referenced by both C and Go
Compiling with LTO revealed a number of cases in the runtime and
    standard library where C and Go disagreed about the type of an object or
    function (or where Go and code generated by the compiler disagreed). In
    all cases the underlying representation was the same (e.g., uintptr vs.
    void*), so this wasn't causing actual problems, but it did result in a
    number of annoying warnings when compiling with LTO.
    
    Reviewed-on: https://go-review.googlesource.com/c/160700

From-SVN: r268923
2019-02-15 01:57:51 +00:00
Ian Lance Taylor c8530c4109 re PR go/89168 (FAIL: cmd/go/internal/load)
PR go/89168
    libgo: change gotest to run examples with output
    
    Change the gotest script to act like "go test" and run examples that
    have "output" comments.  This is not done with full generality, but
    just enough to run the libgo tests.  Other packages should be tested
    with "go test" as usual.
    
    While we're here clean up some old bits of gotest, and only run
    TestXXX functions that are actually in *_test.go files.  The latter
    change should fix https://gcc.gnu.org/PR89168.
    
    Reviewed-on: https://go-review.googlesource.com/c/162139

From-SVN: r268922
2019-02-15 00:36:50 +00:00
Ian Lance Taylor 2faf2a305d syscall: don't assume that WIFCONTINUED is defined
It's not defined on the Hurd.
    
    Reviewed-on: https://go-review.googlesource.com/c/161963

From-SVN: r268828
2019-02-12 21:29:52 +00:00
Ian Lance Taylor 42ee82045d mksysinfo: remove incorrect quotes in st_fsid handling for Hurd
Also stop converting st_dev on Hurd; it shouldn't appear, but if it
    somehow does we don't want to convert it.
    
    Reviewed-on: https://go-review.googlesource.com/c/161961

From-SVN: r268785
2019-02-12 00:15:34 +00:00
Ian Lance Taylor 18591d3ee7 os, syscall: Hurd fixes for a couple of tests
Based on patch by Svante Signell.
    
    Reviewed-on: https://go-review.googlesource.com/c/161520

From-SVN: r268605
2019-02-07 05:02:26 +00:00
Ian Lance Taylor 4a3e25712f os, net, crypto/x509: add hurd support
Patch by Svante Signell.
    
    Reviewed-on: https://go-review.googlesource.com/c/161519

From-SVN: r268604
2019-02-07 04:45:01 +00:00
Ian Lance Taylor 4321f202f9 syscall: add Hurd support
Loosely based on a patch by Svante Signell.
    
    Reviewed-on: https://go-review.googlesource.com/c/161518

From-SVN: r268603
2019-02-07 03:11:47 +00:00
Ian Lance Taylor 9fa4b2aa45 internal/syscall/unix: add constants for hurd
Patch by Svante Signell.
    
    Reviewed-on: https://go-review.googlesource.com/c/161517

From-SVN: r268602
2019-02-07 02:22:57 +00:00
Ian Lance Taylor 73fe55d752 re PR go/89199 (libgo regression in implementation of CompareAndSwap functions resulting in intermittent testcase failures on ppc64le power9 after r268458)
PR go/89199
    sync/atomic: use strong form of atomic_compare_exchange_n
    
    In the recent change to use atomic_compare_exchange_n I thought we
    could use the weak form, which can spuriously fail. But that is not
    how it is implemented in the gc library, and it is not what the rest
    of the library expects.
    
    Thanks to Lynn Boger for identifying the problem.
    
    Fixes https://gcc.gnu.org/PR89199
    
    Reviewed-on: https://go-review.googlesource.com/c/161359

From-SVN: r268591
2019-02-06 20:46:00 +00:00
Ian Lance Taylor fc34dbfdb0 runtime: add hurd netpoll and semaphore support
Patch by Svante Signell.
    
    Reviewed-on: https://go-review.googlesource.com/c/160827

From-SVN: r268465
2019-02-01 23:57:08 +00:00
Ian Lance Taylor cf5773c116 runtime: add getproccount for hurd
Patch by Svante Signell.
    
    Reviewed-on: https://go-review.googlesource.com/c/160825

From-SVN: r268463
2019-02-01 22:55:55 +00:00
Ian Lance Taylor d9f0237f70 libgo: add configury and sysinfo support for hurd
Patch by Svante Signell.
    
    Reviewed-on: https://go-review.googlesource.com/c/160824

From-SVN: r268461
2019-02-01 22:46:39 +00:00
Ian Lance Taylor 59ea40d0f2 libgo: add hurd build tags to test files
Patch by Svante Signell.
    
    Reviewed-on: https://go-review.googlesource.com/c/160823

From-SVN: r268460
2019-02-01 22:11:50 +00:00
Ian Lance Taylor 27d6b51071 libgo: add hurd build tags
Patch by Svante Signell.
    
    Reviewed-on: https://go-review.googlesource.com/c/160822

From-SVN: r268459
2019-02-01 21:57:36 +00:00
Ian Lance Taylor b52a3881f0 runtime, sync: use __atomic intrinsics instead of __sync
GCC has supported the __atomic intrinsics since 4.7.  They are better
    than the __sync intrinsics in that they specify a memory model and,
    more importantly for our purposes, they are reliably implemented
    either in the compiler or in libatomic.
    
    Fixes https://gcc.gnu.org/PR52084
    
    Reviewed-on: https://go-review.googlesource.com/c/160820

From-SVN: r268458
2019-02-01 21:55:38 +00:00
Ian Lance Taylor 6065f1c588 runtime: fix sigprof frame counting
If sigtramp and sigtrampgo are both on stack, n -= framesToDiscard
    is executed twice, which should actually run only once.
    
    Reviewed-on: https://go-review.googlesource.com/c/159238

From-SVN: r268366
2019-01-29 15:31:10 +00:00
Ian Lance Taylor 053a1f2320 runtime: use the call instruction's PC for panic-in-runtime detection
If a panic happens in the runtime we turn that into a fatal error.
    We use the caller's PC to determine if the panic call is inside
    the runtime. getcallerpc returns the PC immediately after the
    call instruction. If the call is the very last instruction of a
    function, it may not find this PC belong to a runtime function,
    giving false result. We need to back off the PC by 1 to the call
    instruction.
    
    The gc runtime doesn't do this because the gc compiler always
    emit an instruction following a panic call, presumably an UNDEF
    instruction which turns into an architecture-specific illegal
    instruction. Our compiler doesn't do this.
    
    Reviewed-on: https://go-review.googlesource.com/c/159437

From-SVN: r268358
2019-01-29 00:49:23 +00:00
Ian Lance Taylor 52c9cfeb08 runtime: install SIGURG handler on C created threads
Precise stack scan uses SIGURG to trigger a stack scan. We need
    to have Go signal handler installed for SIGURG.
    
    Reviewed-on: https://go-review.googlesource.com/c/159097

From-SVN: r268230
2019-01-24 05:31:14 +00:00
Ian Lance Taylor 494df8753b golang.org/x/tools/go/analysis: pass "gccgo" to types.SizesFor
For the gofrontend copy, change calls to types.SizesFor to pass
    "gccgo" rather than "gc".  Leave the asmdecl pass unchanged since that
    pass is gc-specific anyhow.
    
    This has been fixed in a better way in the external repo by
    https://golang.org/cl/158317 and friends, but that is not in 1.12, so
    use this approach for now.
    
    Reviewed-on: https://go-review.googlesource.com/c/158842

From-SVN: r268153
2019-01-22 15:43:40 +00:00
Ian Lance Taylor 3d338229dc re PR go/88927 (Bootstrap failure on arm in libgo starting with r268084)
PR go/88927
    runtime, internal/cpu: fix build for ARM GNU/Linux
    
    Was failing with
    
    ../../../libgo/go/internal/cpu/cpu.go:138:2: error: reference to undefined name 'doinit'
      138 |  doinit()
          |  ^
    
    Fix it by adding in Go 1.12 internal/cpu/cpu_arm.go, and the code in
    runtime that initializes the values.
    
    Fixes https://gcc.gnu.org/PR88927.
    
    Reviewed-on: https://go-review.googlesource.com/c/158717

From-SVN: r268131
2019-01-22 00:06:44 +00:00
Ian Lance Taylor ea31c98dab libgo: fix building, and some testing, on Solaris
Restore some of the fixes that were applied to golang_org/x/net/lif
    but were lost when 1.12 moved the directory to internal/x/net/lif.
    
    Add support for reading /proc to fetch argc/argv/env for c-archive mode.
    
    Reviewed-on: https://go-review.googlesource.com/c/158640

From-SVN: r268130
2019-01-21 23:05:52 +00:00
Ian Lance Taylor 4f4a855d82 libgo: update to Go1.12beta2
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
2019-01-18 19:04:36 +00:00
Ian Lance Taylor aee6ed4a2c re PR go/88202 (FAIL: runtime/pprof)
PR go/88202
    runtime: in sigprof, skip to sigtrampgo if we don't find sigtramp
    
    Fixes https://gcc.gnu.org/PR88202
    
    Reviewed-on: https://go-review.googlesource.com/c/158218

From-SVN: r268057
2019-01-18 03:29:38 +00:00
Ian Lance Taylor f41bf58736 runtime: dropg before CAS g status to _Grunnable/_Gwaiting
Currently, we dropg (which clears gp.m) after we CAS the g status
    to _Grunnable or _Gwaiting. Immediately after CASing the g status,
    another thread may CAS it to _Gscan status and scan its stack.
    With precise stack scan, it accesses gp.m in order to switch to g
    and back (in doscanstackswitch). This races with dropg. If
    doscanstackswitch reads gp.m, then dropg runs, when we restore
    the m at the end of the scan it will set to a stale value. Worse,
    if dropg runs after doscanstackswitch sets the new m, gp will be
    running with a nil m.
    
    To fix this, we do dropg before CAS g status to _Grunnable or
    _Gwaiting. We can do this safely if we are CASing from _Grunning,
    as we own the g when it is in _Grunning. There is one case where
    we CAS from _Gsyscall to _Grunnable. It is not safe to dropg when
    it is in _Gsyscall, as precise stack scan needs to read gp.m in
    order to signal the m. So we need to introduce a transient state,
    _Gexitingsyscall, between _Gsyscall and _Grunnable, where the GC
    should not scan its stack.
    
    In is a little unfortunate that we have to add another g status.
    We could reuse an existing one (e.g. _Gcopystack), but it is
    clearer and safer to just use a new one, as Austin suggested.
    
    Reviewed-on: https://go-review.googlesource.com/c/158157

From-SVN: r268001
2019-01-17 02:14:28 +00:00
Ian Lance Taylor a6804ea929 syscall: mark C syscall functions noescape
Many C syscall functions take pointer arguments. The pointers
    don't escape in the C functions. Mark the C functions noescape so
    calling them doesn't need allocation.
    
    Reviewed-on: https://go-review.googlesource.com/c/158158

From-SVN: r267989
2019-01-16 22:38:33 +00:00
Ian Lance Taylor b7ec44e82b runtime: add padding to FFI type of struct ending with zero-sized field
CL 157557 changes the compiler to add one byte padding to
    non-empty struct ending with a zero-sized field. Add the same
    padding to the FFI type, so reflect.Call works.
    
    This fixes test/fixedbugs/issue26335.go in the main repo.
    
    Reviewed-on: https://go-review.googlesource.com/c/158018

From-SVN: r267956
2019-01-15 23:21:24 +00:00
Ian Lance Taylor 6a0c8e77f2 compiler, runtime: panic on uncomparable map key, even if map is empty
This ports https://golang.org/cl/155918 from the master repo.
    
        runtime: panic on uncomparable map key, even if map is empty
    
        Reorg map flags a bit so we don't need any extra space for the extra flag.
    
    This is a pre-req for updating libgo to the Go 1.12beta2 release.
    
    Reviewed-on: https://go-review.googlesource.com/c/157858

From-SVN: r267950
2019-01-15 20:32:39 +00:00
Jakub Jelinek 831a2e2f86 Remove svn:executable property from a couple of text files
which shouldn't be executable.

From-SVN: r267873
2019-01-12 01:20:04 +01:00
Ian Lance Taylor 33a5d8ccb5 runtime: in doscanstackswitch, set gp->m before gogo
This is following CL 156038. doscanstackswitch uses the same
    mechanism of switching goroutines as getTraceback, and so has
    the same problem as described in issue golang/go#29448. This CL
    applies the same fix.
    
    Reviewed-on: https://go-review.googlesource.com/c/156697

From-SVN: r267661
2019-01-07 22:07:26 +00:00
Ian Lance Taylor fdcef314bc compiler: move slice construction to callers of makeslice
This is the gccgo version of https://golang.org/cl/141822:
    
        Only return a pointer p to the new slices backing array from makeslice.
        Makeslice callers then construct sliceheader{p, len, cap} explictly
        instead of makeslice returning the slice.
    
    This change caused the GCC backend to break the runtime/pprof test by
    merging together the identical functions allocateReflectTransient and
    allocateTransient2M.  This caused the traceback to be other than
    expected.  Fix that by making the functions not identical.
    
    This is a step toward updating libgo to the Go1.12beta1 release.
    
    Reviewed-on: https://go-review.googlesource.com/c/155937

From-SVN: r267660
2019-01-07 21:44:06 +00:00
Ian Lance Taylor 575eb8f58b runtime: in getTraceback, set gp->m before gogo
Currently, when collecting a traceback for another goroutine,
    getTraceback calls gogo(gp) switching to gp, which will resume in
    mcall, which will call gtraceback, which will set up gp->m. There
    is a gap between setting the current running g to gp and setting
    gp->m. If a profiling signal arrives in between, sigtramp will
    see a non-nil gp with a nil m, and will seg fault. Fix this by
    setting up gp->m first.
    
    Fixes golang/go#29448.
    
    Reviewed-on: https://go-review.googlesource.com/c/156038

From-SVN: r267658
2019-01-07 20:12:39 +00:00
Ian Lance Taylor f6be1179bb runtime: prevent deadlock when profiling signal arrives during traceback
Traceback routines, e.g. callers and funcentry, may call
    __go_get_backtrace_state. If a profiling signal arrives while we
    are in the critical section of __go_get_backtrace_state, it tries
    to do a traceback, which also calls __go_get_backtrace_state,
    which tries to enter the same critical section and will deadlock.
    Prevent this deadlock by setting up runtime_in_callers before
    calling __go_get_backtrace_state.
    
    Found while investigating golang/go#29448. Will add a test in the
    next CL.
    
    Updates golang/go#29448.
    
    Reviewed-on: https://go-review.googlesource.com/c/156037

From-SVN: r267590
2019-01-05 00:40:04 +00:00
Ian Lance Taylor e20bfbd18e runtime: prevent deadlock when profiling signal arrives in stack scan
Precise stack scan needs to unwind the stack. When it is
    unwinding the stack, if a profiling signal arrives, which also
    does a traceback, it may deadlock in dl_iterate_phdr. Prevent
    this deadlock by setting up runtime_in_callers before traceback.
    
    Reviewed-on: https://go-review.googlesource.com/c/155766

From-SVN: r267457
2018-12-29 00:07:06 +00:00
Ian Lance Taylor dc65168eb6 runtime: delete export_arm_test.go
The only thing export_arm_test.go does is to export usplit,
    which does not exist in gccgo.
    
    Reviewed-on: https://go-review.googlesource.com/c/155760

From-SVN: r267435
2018-12-27 16:34:50 +00:00
Ian Lance Taylor f1410e7e2e runtime: let ARM32 EABI personality function continue unwind when called from traceback
On ARM32 EABI, unlike other platforms, the personality function is
    called during _Unwind_Backtrace (libgcc/unwind-arm-common.inc:581).
    In this case, simply unwind the frame without returning any
    handlers. Otherwise traceback will loop if there is a frame with
    a defer on stack.
    
    Reviewed-on: https://go-review.googlesource.com/c/155759

From-SVN: r267434
2018-12-27 16:31:50 +00:00
Ian Lance Taylor 75e479a8b5 runtime: on ARM32 EABI, don't get LSDA if compact model is used
On ARM32 EABI, when the "compact" unwinding model is used, it
    does not have standard LSDA and _Unwind_GetLanguageSpecificData
    will not return data that is parseable by us. Check this
    conditon before calling _Unwind_GetLanguageSpecificData.
    
    Fix ARM32 build.
    
    Reviewed-on: https://go-review.googlesource.com/c/155758

From-SVN: r267428
2018-12-27 03:13:11 +00:00
Ian Lance Taylor e7db55f636 runtime: handle DW_EH_PE_absptr in type table encoding
The type table encoding can be DW_EH_PE_absptr, but this case
    was missing, which was causing abort on ARM32 EABI. Add the
    missing case.
    
    Reviewed-on: https://go-review.googlesource.com/c/153857

From-SVN: r267070
2018-12-12 23:26:58 +00:00
Ian Lance Taylor 44cacba39d os/signal: increase deliver time for signal testcase
This increases the time to wait for signals to be delivered in the
    TestAtomicStop testcase. When running gccgo tests on ppc64 or ppc64le,
    there are intermittent failures in this test because the wait time is
    too small.
    
    Updates golang/go#29046
    
    Reviewed-on: https://go-review.googlesource.com/c/153879

From-SVN: r267068
2018-12-12 22:48:46 +00:00
Ian Lance Taylor be68937be2 runtime: use _URC_FAILURE on ARM32
ARM32 EABI unwinder does not define _URC_NORMAL_STOP. Instead,
    it has _URC_FAILURE. Use _URC_FAILURE there.
    
    Should fix ARM32 build.
    
    Reviewed-on: https://go-review.googlesource.com/c/153417

From-SVN: r267033
2018-12-11 20:50:59 +00:00
Ian Lance Taylor 5a58929be8 runtime: add missing return for non-GNU/Linux version of tgkill
Path from Rainer Orth.
    
    Reviewed-on: https://go-review.googlesource.com/c/153118

From-SVN: r266890
2018-12-07 14:22:55 +00:00
Ian Lance Taylor c43137e800 runtime: add precise stack scan support
This CL adds support of precise stack scan using stack maps to
    the runtime. The stack maps are generated by the compiler (if
    supported). Each safepoint is associated with a (real or dummy)
    landing pad, and its "type info" in the exception table is a
    pointer to the stack map. When a stack is scanned, the stack map
    is found by the stack unwinding code by inspecting the exception
    table (LSDA).
    
    For precise stack scan we need to unwind the stack. There are
    three cases:
    
    - If a goroutine is scanning its own stack, it can unwind the
      stack and scan the frames.
    
    - If a goroutine is scanning another, stopped, goroutine, it
      cannot directly unwind the target stack. We handle this by
      switching (runtime.gogo) to the target g, letting it unwind
      and scan the stack, and switch back.
    
    - If we are scanning a goroutine that is blocked in a syscall,
      we send a signal to the target goroutine's thread, and let the
      signal handler unwind and scan the stack. Extra care is needed
      as this races with enter/exit syscall.
    
    Currently this is only implemented on linux.
    
    Reviewed-on: https://go-review.googlesource.com/c/140518

From-SVN: r266832
2018-12-05 23:09:51 +00:00
Ian Lance Taylor 9cf3cb7c25 syscall: remove Flock for aix/ppc64
CL 152397 removed it from gc's syscall package.
    
    Updates golang/go#29084
    
    Reviewed-on: https://go-review.googlesource.com/c/152557

From-SVN: r266812
2018-12-05 01:11:02 +00:00
Ian Lance Taylor 8f80bd8972 cmd/vet: use default compiler when determining type sizes
Fixes a segfault running vet on alpha.
    
    Patch by Uros Bizjak.
    
    Reviewed-on: https://go-review.googlesource.com/c/152437

From-SVN: r266781
2018-12-04 14:29:11 +00:00
Ian Lance Taylor ab25c42d05 cmd/go: allow buildmode c-archive for gccgo on ppc64
In buildmodeinit, the c-archive buildmode is flagged as invalid
    on linux/ppc64 for gccgo when it should be valid. This happens
    because the check against the gccgo flag is done after the checks
    for valid GOOS/GOARCH pairs instead of before as is done for all
    other buildmode cases in this switch. This corrects the problem and
    allows several of the gccgo gotools testcases to pass on linux/ppc64.
    
    Updates #29046
    
    Reviewed-on: https://go-review.googlesource.com/c/152137

From-SVN: r266764
2018-12-03 20:25:11 +00:00
Ian Lance Taylor 80d7d30d24 compiler: add '$' to names in expression export data
For inlined function bodies we're going to need to refer to variables,
    so change the existing export data to add a '$' to names that look
    like identifiers: true, false, nil, convert.
    
    While we're here drop an unnecessary space character after operators.
    
    Reviewed-on: https://go-review.googlesource.com/c/150067

From-SVN: r266529
2018-11-27 21:25:58 +00:00
Ian Lance Taylor 0abbc8f15e syscall: always define WEXITED and WNOWAIT on GNU/Linux
Fixes https://gcc.gnu.org/PR88135
    
    Reviewed-on: https://go-review.googlesource.com/c/150897

From-SVN: r266495
2018-11-26 23:58:34 +00:00
Ian Lance Taylor 1e4cc1d4b0 compiler: initial support for exporting function bodies
Create a framework for putting function bodies in export data.  At
    present only empty functions will be put there, and they will be
    ignored on import.  Later patches will get this to the point of
    supporting inlining of (some) functions defined in other packages.
    
    Reviewed-on: https://go-review.googlesource.com/c/150061

From-SVN: r266490
2018-11-26 21:44:20 +00:00
Ian Lance Taylor d3d684c642 re PR go/88060 (../../../gcc-8.2.0/libgo/go/syscall/libcall_linux_utimesnano.go:17:18: error: reference to undefined name ‘_AT_FDCWD’)
PR go/88060
    syscall: always define _AT_FDCWD and IPv6MTUInfo
    
    They aren't defined by old versions of glibc, but are required by the
    code in syscall_linux.go.
    
    Reviewed-on: https://go-review.googlesource.com/c/150697

From-SVN: r266333
2018-11-21 02:16:15 +00:00
Ian Lance Taylor 0d26cdf1cf cmd/cgo: fix typo in gccgo name mangling recipe
The code to implement new-style gccgo name mangling had a recipe that
    didn't quite match the one in the compiler (incorrect handling for
    '.'). This showed up as a failure in the gotools cgo test if the
    directory containing the test run included a "." character.
    
    Reviewed-on: https://go-review.googlesource.com/c/147917

From-SVN: r265981
2018-11-09 19:03:59 +00:00
Ian Lance Taylor 71caffb725 syscall: change RLIM_INFINITY from 0xffffffffffffffff to -1
For compatibility with the gc toolchain's syscall package.
    
    Fixes golang/go#28665
    
    Reviewed-on: https://go-review.googlesource.com/c/148697

From-SVN: r265974
2018-11-09 15:30:51 +00:00
Ian Lance Taylor 73b6d7a990 re PR bootstrap/82856 (--enable-maintainter-mode broken by incompatiblity of gcc's required automake and modern Perl)
PR bootstrap/82856

    libgo: update to autoconf 2.69 and automake 1.15.1
    
    Initial patch from Joseph Myers.
    
    Reviewed-on: https://go-review.googlesource.com/c/146417

From-SVN: r265701
2018-10-31 20:46:17 +00:00
Ian Lance Taylor 827651b074 libgo: simplify gotest script to avoid sed substitution to \n
Reviewed-on: https://go-review.googlesource.com/c/145057

From-SVN: r265541
2018-10-26 18:36:44 +00:00
Ian Lance Taylor dbd93b9dbb libgo: avoid use of 'local' directive in shell script
Avoid declaring shell variables with 'local' (not supported
    on all systems of interest).
    
    Reviewed-on: https://go-review.googlesource.com/c/145021

From-SVN: r265534
2018-10-26 16:58:13 +00:00
Ian Lance Taylor 797ea25427 libgo: fix improperly mangled linker symbol directive
Fix asm name directive for the C version of log/syslog.syslog_c,
    which didn't get included in the recent name mangling change.
    
    Reviewed-on: https://go-review.googlesource.com/c/145017

From-SVN: r265533
2018-10-26 16:53:24 +00:00
Ian Lance Taylor c404b3b9c6 libgo: don't use wc in gotest
The wc command is not in the GNU approved list of Makefile utilities
    (https://www.gnu.org/prep/standards/html_node/Utilities-in-Makefiles.html#Utilities-in-Makefiles).
    
    Reviewed-on: https://go-review.googlesource.com/c/144897

From-SVN: r265515
2018-10-26 02:43:35 +00:00
Ian Lance Taylor 34489eb2af compiler: improve name mangling for packpaths
The current implementation of Gogo::pkgpath_for_symbol was written in
    a way that allowed two distinct package paths to map to the same
    symbol, which could cause collisions at link- time or compile-time.
    
    Switch to a better mangling scheme to insure that we get a unique
    packagepath symbol for each package. In the new scheme instead of having
    separate mangling schemes for identifiers and package paths, the
    main identifier mangler ("go_encode_id") now handles mangling of
    both packagepath characters and identifier characters.
    
    The new mangling scheme is more intrusive: "foo/bar.Baz" is mangled as
    "foo..z2fbar.Baz" instead of "foo_bar.Baz". To mitigate this, this
    patch also adds a demangling capability so that function names
    returned from runtime.CallersFrames are converted back to their
    original unmangled form.
    
    Changing the pkgpath_for_symbol scheme requires updating a number of
    //go:linkname directives and C "__asm__" directives to match the new
    scheme, as well as updating the 'gotest' driver (which makes
    assumptions about the correct mapping from pkgpath symbol to package
    name).
    
    Fixes golang/go#27534.
    
    Reviewed-on: https://go-review.googlesource.com/c/135455

From-SVN: r265510
2018-10-25 22:18:08 +00:00
Ian Lance Taylor 8dd2ae4bc7 re PR go/87661 (libgo bootstrap failure on arm-linux-gnueabihf (redefinition of constants))
PR go/87661
    runtime: remove unused armArch, hwcap and hardDiv
    
    After CL 140057 these are only written but never read in gccgo.
    
    Reviewed-on: https://go-review.googlesource.com/c/141077

From-SVN: r265439
2018-10-23 19:02:29 +00:00
Ian Lance Taylor a847d2b7b1 compiler: export indexed type data, read unexported types lazily
Introduce a new "types" command to the export data to record the
    number of types and the size of their export data. It is immediately
    followed by new "type" commands that can be indexed. Parse all the
    exported types immediately so that we register them, but parse other
    type data only as needed.
    
    Reviewed-on: https://go-review.googlesource.com/c/143022

From-SVN: r265409
2018-10-23 02:46:41 +00:00
Ian Lance Taylor dbf9376f9e compiler: list indirect imports separately in export data
Previously when export data referred to a type that was not defined in
    a directly imported package, we would write the package name as
    additional information in the type's export data.  That approach
    required all type information to be read in order.  This patch changes
    the compiler to find all references to indirectly imported packages,
    and write them out as an indirectimport line in the import data.  This
    will permit us to read exported type data out of order.
    
    The type traversal used to find indirect imports is a little more
    complicated than necessary in preparation for later patches in this
    series.
    
    Reviewed-on: https://go-review.googlesource.com/c/143020

From-SVN: r265296
2018-10-18 23:22:01 +00:00
Ian Lance Taylor e8ce849a48 compiler: drop semicolons in export data
The export data, which is approximately readable and looks something
    like Go, was first implemented back when Go still used semicolons.
    Drop the semicolons, to make it look slightly more Go like and make it
    slightly smaller.
    
    This updates the compiler and the gccgoimporter package.
    
    This introduces a new version of the export data.  There are going to
    be more changes to the export data, so this version is still subject
    to change.
    
    Reviewed-on: https://go-review.googlesource.com/c/143018

From-SVN: r265284
2018-10-18 19:35:46 +00:00
Ian Lance Taylor 91b01194c9 runtime: skip testSetPanicOnFault for gollvm
LLVM doesn't support non-call exception. This test was passing
    more or less by luck: if the faulting instruction is between two
    calls with the same landing pad (in instruction layout order,
    not the program's logic order), it generates a merged PC range
    that covers the faulting instruction. If the instruction layout
    order changes, or it uses two different (but may be degenerate)
    landing pads, this doesn't work.
    
    Reviewed-on: https://go-review.googlesource.com/c/140517

From-SVN: r264985
2018-10-09 16:51:10 +00:00
Ian Lance Taylor 3cbb7cbb09 libgo: update to Go 1.11.1 release
Reviewed-on: https://go-review.googlesource.com/c/140277

From-SVN: r264932
2018-10-08 14:21:30 +00:00
Ian Lance Taylor 7fc9c2e52f libgo: use inline assembly in favor of call to _xgetbv()
Use inline assembly in the implementation of internal_cpu.xgetbv as
    opposed to a call to the intrinsic _xgetbv(), since non-gcc compilers
    (e.g. clang) may or may not have support for it.
    
    Reviewed-on: https://go-review.googlesource.com/c/140137

From-SVN: r264882
2018-10-05 17:51:57 +00:00
Ian Lance Taylor cbba2e1e47 runtime: remove checkgoarm function
Nothing in libgo calls checkgoarm, and it relies on a variable, goarm,
    that is not set.
    
    Reviewed-on: https://go-review.googlesource.com/c/140057

From-SVN: r264872
2018-10-05 14:21:01 +00:00
Ian Lance Taylor d8ccfadbf2 internal/bytealg: support systems that don't have memmem
Reviewed-on: https://go-review.googlesource.com/138839

From-SVN: r264798
2018-10-02 16:45:51 +00:00
Ian Lance Taylor 4913fc07e0 net: don't fail test if splice fails because pipe2 is missing
This reportedly happens on CentOS 5.11.  The real code will work fine;
    this test is assuming that the unexported slice function will handle
    the splice, but if pipe2 does not work then it doesn't.  The relevant
    code in internal/poll/splice_linux.go says "Falling back to pipe is
    possible, but prior to 2.6.29 splice returns -EAGAIN instead of 0 when
    the connection is closed."
    
    Reviewed-on: https://go-review.googlesource.com/138838

From-SVN: r264793
2018-10-02 15:07:14 +00:00
Ian Lance Taylor 44ef03008c libgo: support x32 as GOARCH=amd64p32 GOOS=linux
This is enough to let libgo build when configured using
    --with-multilib-list=m64,m32,mx32.  I don't have an x32-enabled kernel
    so I haven't tested whether it executes correctly.
    
    For https://gcc.gnu.org/PR87470
    
    Reviewed-on: https://go-review.googlesource.com/138817

From-SVN: r264772
2018-10-01 20:17:11 +00:00
Ian Lance Taylor 1b28253347 runtime: add arm64 version of AES hash code
Rewrite the arm64 AES hashing code from gc assembler to C code using
    intrinsics.  The resulting code generates the same hash code for the
    same input as the gc code--that doesn't matter as such, but testing it
    ensures that the C code does something useful.
    
    Reviewed-on: https://go-review.googlesource.com/138535

From-SVN: r264771
2018-10-01 20:14:29 +00:00
Ian Lance Taylor dd554b787d syscall: don't assume we have a GETEUID system call
On Alpha GNU/Linux there is no geteuid system call, there is only
    getresuid.  The raw geteuid system call is only used for testing, so
    just skip the test if it's not available.
    
    Reviewed-on: https://go-review.googlesource.com/137655

From-SVN: r264647
2018-09-26 15:17:30 +00:00
Ian Lance Taylor 201054a7f0 runtime, os: fix the build on Solaris
Reviewed-on: https://go-review.googlesource.com/137535

From-SVN: r264593
2018-09-26 03:29:07 +00:00
Ian Lance Taylor f5ec13f15d internal/bytealg, internal/cpu, internal/poll: portability fixes
In internal/bytealg correct a +build tag to never build indexbyte_generic.go
    for the gofrontend, where we always use indexbyte_native.go.
    
    For internal/cpu let the Makefile define CacheLineSize using goarch.sh,
    rather than trying to enumerate all the possibilities in cpu_ARCH.go files.
    
    In internal/poll call the C fcntl function rather than using SYS_FCNTL.
    Change mksysinfo.sh to ensure that F_GETPIPE_SZ is always defined,
    and check that in internal/poll.
    
    Reviewed-on: https://go-review.googlesource.com/137256

From-SVN: r264572
2018-09-25 14:31:57 +00:00
Ian Lance Taylor b16084d244 cmd/go: pass down testing gccgo in TestScript
This permits TestScript to work when gccgo is not installed.
    Previous testing was using a previously installed gccgo, not the newly
    built one.
    
    This revealed that the testing of whether an internal package is
    permitted was incorrect for standard library packages, since the
    uninstalled gccgo can see internal packages in the uninstalled libgo.
    Fix the internal package tests.
    
    This permitted removing a couple of gccgo-specific changes in the
    testsuite.
    
    Reviewed-on: https://go-review.googlesource.com/137255

From-SVN: r264570
2018-09-25 14:16:32 +00:00
Ian Lance Taylor dd931d9b48 libgo: update to Go 1.11
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-09-24 21:46:21 +00:00
Ian Lance Taylor e47515aa89 cmd/go: correct gccgo buildid file on ARM
Bring in https://golang.org/cl/135297 from the gc repository to fix a
    GCC bug report.
    
    Original CL description:
    
        The GNU assembler for ARM treats @ as a comment character, so section
        types must be written using % instead.
    
        Fixes https://gcc.gnu.org/PR87260.
    
    Reviewed-on: https://go-review.googlesource.com/135360

From-SVN: r264330
2018-09-14 19:42:01 +00:00
Ian Lance Taylor cec07c4759 compiler, runtime: call gcWriteBarrier instead of writebarrierptr
In 1.11 writebarrierptr is going away, so change the compiler to call
    gcWriteBarrier instead.  We weren't using gcWriteBarrier before;
    adjust the implementation to use the putFast method.
    
    This revealed a problem in the kickoff function.  When using cgo,
    kickoff can be called on the g0 of an m allocated by newExtraM.  In
    that case the m will generally have a p, but systemstack may be called
    by wbBufFlush as part of flushing the write barrier buffer.  At that
    point the buffer is full, so we can not do a write barrier.  So adjust
    the existing code in kickoff so that in the case where we are g0,
    don't do any write barrier at all.
    
    Reviewed-on: https://go-review.googlesource.com/131395

From-SVN: r264295
2018-09-13 22:25:58 +00:00
Ian Lance Taylor 38fab7369d runtime: correct counters in sweep
In the sweep code we can sometimes see incorrect counts when
    conservative stack scanning causes us to grey an object that we
    earlier decided could be freed.  We already ignored this check, but
    adjust this case to maintain correct span counts when it happens.
    This gives us slightly more correct numbers in MemStats, and helps
    avoid a rare failure in TestReadMemStats.
    
    Also fix the free index, and cope with finding a full span when
    allocating a new one.
    
    Reviewed-on: https://go-review.googlesource.com/134216

From-SVN: r264294
2018-09-13 22:06:16 +00:00
Ian Lance Taylor 84cdf51de4 compiler, runtime: open code select
This is the gofrontend version of https://golang.org/cl/37933,
    https://golang.org/cl/37934, and https://golang.org/cl/37935.
    Open code the initialization of select cases.
    
    This is a step toward updating libgo to the 1.11 release.
    
    Reviewed-on: https://go-review.googlesource.com/135000

From-SVN: r264290
2018-09-13 21:32:24 +00:00
Ian Lance Taylor f0d89c7759 runtime: avoid write barriers with traceback info
Unlike the gc runtime, libgo stores traceback information in location
    structs, which contain strings.  Therefore, copying location structs
    around appears to require write barriers, although in fact write
    barriers are never important because the strings are never allocated
    in Go memory.  They come from libbacktrace.
    
    Some of the generated write barriers come at times when write barriers
    are not permitted.  For example, exitsyscall, marked
    nowritebarrierrec, calls exitsyscallfast which calls traceGoSysExit
    which calls traceEvent which calls traceStackID which calls
    trace.stackTab.put which copies location values into memory allocated
    by tab.newStack.  This write barrier can be invoked when there is no
    p, causing a crash.
    
    This change fixes the problem by ensuring that location values are
    copied around in the tracing code with no write barriers.
    
    This was found by fixing the compiler to fully implement
    //go:nowritebarrierrec; CL to follow.
    
    Reviewed-on: https://go-review.googlesource.com/134226

From-SVN: r264282
2018-09-13 17:30:00 +00:00
Ian Lance Taylor 2919ad1ee3 libgo: build roots index to speed up bulkBarrierPreWrite
To reduce the amount of time spent in write barrier processing
    (specifically runtime.bulkBarrierPreWrite), add support for building a
    'GC roots index', basically a sorted list of all roots, so as to
    allow more efficient lookups of gcdata structures for globals. The
    previous implementation worked on the raw (unsorted) roots list
    itself, which did not scale well.
    
    Reviewed-on: https://go-review.googlesource.com/132595

From-SVN: r264276
2018-09-13 16:44:43 +00:00
Ian Lance Taylor 347462bfee compiler, runtime: remove hmap field from maptypes
This is the gofrontend version of https://golang.org/cl/91796.
    
    This is part of that CL, just the compiler change and required runtime
    changes, in preparation for updating libgo to 1.11.
    
    Relevant part of original CL description:
    
        The hmap field in the maptype is only used by the runtime to check the sizes of
        the hmap structure created by the compiler and runtime agree.
    
        Comments are already present about the hmap structure definitions in the
        compiler and runtime needing to be in sync.
    
    Reviewed-on: https://go-review.googlesource.com/130976

From-SVN: r263941
2018-08-29 00:20:25 +00:00
Ian Lance Taylor 1d29bb0408 runtime: remove the dummy arg of getcallersp
This is a port of https://golang.org/cl/109596 to the gofrontend, in
    preparation for updating libgo to 1.11.
    
    Original CL description:
    
        getcallersp is intrinsified, and so the dummy arg is no longer
        needed. Remove it, as well as a few dummy args that are solely
        to feed getcallersp.
    
    Reviewed-on: https://go-review.googlesource.com/131116

From-SVN: r263840
2018-08-24 18:15:04 +00:00
Ian Lance Taylor b7d7c92f24 runtime: use poll rather than pollset for netpoll on AIX
Updates golang/go#26634
    
    Reviewed-on: https://go-review.googlesource.com/126857

From-SVN: r263364
2018-08-07 17:29:50 +00:00
Ian Lance Taylor 9be4d77249 libgo: uncomment trace.Stop() call in testing package
Fix up the testing package to insure that execution traces
    work properly (e.g. "-test.trace=<XXX>" command line option). The
    call to stop tracing and emit the output file was stubbed out.
    
    Reviewed-on: https://go-review.googlesource.com/128275

From-SVN: r263363
2018-08-07 17:28:22 +00:00