Commit Graph

663 Commits

Author SHA1 Message Date
Ian Lance Taylor 1e156d9b21 internal/cpu: don't define CacheLinePadSize for riscv64
In libgo CacheLinePadSize is defined by the generated file cpugen.go.

Keep cpu_riscv64.go around, even though it is now empty, so that
we will pick up changes to it in future merges.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/216077
2020-01-23 16:05:47 -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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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
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