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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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.
Fixesgolang/go#32290.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/179740
From-SVN: r271892
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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.
Fixesgolang/go#29448.
Reviewed-on: https://go-review.googlesource.com/c/156038
From-SVN: r267658
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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).
Fixesgolang/go#27534.
Reviewed-on: https://go-review.googlesource.com/c/135455
From-SVN: r265510
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
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
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
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
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
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
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