PR go/81451
runtime: inline runtime_osinit
We had two identical copies of runtime_osinit. They set runtime_ncpu,
a variable that is no longer used. Removing that leaves us with two lines.
Inline those two lines in the two places the function was called.
This fixes GCC PR 81451.
Reviewed-on: https://go-review.googlesource.com/48862
From-SVN: r250326
PR go/81393
syscall: don't use GETREGS/SETREGS on s390
They were removed in recent glibc.
Patch by Andreas Krebbel for GCC PR 81393.
Reviewed-on: https://go-review.googlesource.com/48231
From-SVN: r250174
On AIX:
* mmap does not allow to map an already mapped range,
* mmap range start at 0x30000000 for 32 bits processes,
* mmap range start at 0x70000000_00000000 for 64 bits processes
This is adapted from change 37845.
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/46772
From-SVN: r249713
Fixes required now that we #include <linux/ptrace.h> in sysinfo.c.
Patch by Andreas Krebbel.
Reviewed-on: https://go-review.googlesource.com/46839
From-SVN: r249712
When C code calls a Go function, it actually calls a function
generated by cgo. That function is written in Go, and, among other
things, it calls the real Go function like this:
CgocallBack()
defer CgocallBackDone()
RealGoFunction()
The deferred CgocallBackDone function enters syscall mode as we return
to C. Typically the C function will then eventually return to Go.
However, in the case where the C function is running on a thread
created in C, it will not return to Go. For that case we will have
allocated an m struct, with an associated g struct, for the duration
of the Go code, and when the Go is complete we will return the m and g
to a free list.
That all works, but we are running in a deferred function, which means
that we have been invoked by deferreturn, and deferreturn expects to
do a bit of cleanup to record that the defer has been completed. Doing
that cleanup while using an m and g that have already been returned to
the free list is clearly a bad idea. It was kind of working because
deferreturn was holding the g pointer in a local variable, but there
were races with some other thread picking up and using the newly freed g.
It was also kind of working because of a special check in freedefer;
that check is no longer necessary.
This patch changes the special case of releasing the m and g to do the
defer cleanup in CgocallBackDone itself.
This patch also checks for the special case of a panic through
CgocallBackDone. In that special case, we don't want to release the m
and g. Since we are returning to C code that was not called by Go
code, we know that the panic is not going to be caught and we are
going to exit the program. So for that special case we keep the m and
g structs so that the rest of the panic code can use them.
Reviewed-on: https://go-review.googlesource.com/46530
From-SVN: r249611
The kickoff function for g0 can be invoked without a p, for example
from mcall(exitsyscall0) in exitsyscall after exitsyscall has cleared
the p field. The assignment gp.param = nil will invoke a write barrier.
If gp.param is not already nil, this will require a p. Avoid the problem
for a specific case that is known to be OK: when the value in gp.param
is a *g.
Reviewed-on: https://go-review.googlesource.com/46512
From-SVN: r249595
When a panic occurs while processing a deferred function that
recovered an earlier panic, we shouldn't report the recovered panic
in the panic stack trace. Stop doing so by keeping track of the panic
that triggered a defer, marking it as aborted if we see the defer again,
and discarding aborted panics when a panic is recovered. This is what
the gc runtime does.
The test for this is TestRecursivePanic in runtime/crash_test.go.
We don't run that test yet, but we will soon.
Reviewed-on: https://go-review.googlesource.com/46461
From-SVN: r249590
The CgocallbackDone function calls dropm after it calls entersyscall,
which means that dropm must not have any write barriers. Mark it
accordingly.
Reviewed-on: https://go-review.googlesource.com/46464
From-SVN: r249577
Use go:linkname to export the getm function. This makes it visible to
runtime/testdata/testprogcgo/dropm_stub.go, which uses it as part of
the TestEnsureDropM test in runtime/crash_cgo_test.go. That test is
not run today, but it will be soon.
Reviewed-on: https://go-review.googlesource.com/46462
From-SVN: r249576
In libgo system goroutines register themselves after they start.
That means that there is a small race between the goroutine being
seen by the scheduler and the scheduler knowing that the goroutine
is a system goroutine. That in turn means that runtime.NumGoroutines
can overestimate the number of goroutines at times.
This patch fixes the overestimate by counting the number of system
goroutines waiting to start, and pausing NumGoroutines until those
goroutines have all registered.
This is kind of a lot of mechanism for this not very important
problem, but I couldn't think of a better approach.
The test for this is TestNumGoroutine in runtime/proc_test.go.
The test is not currently run, but it will be soon.
Reviewed-on: https://go-review.googlesource.com/46457
From-SVN: r249565
With the gc toolchain apparently
var s *string
_ = *s
is enough to panic with a nil pointer dereference. The gccgo compiler
will simply discard the dereference, which I think is a reasonable and
acceptable optimization. Change the tests to use an exported variable
instead. The tests are not currently run, but they will be with a
later patch to gotools.
Reviewed-on: https://go-review.googlesource.com/46450
From-SVN: r249562
Because of how gccgo implements cgo calls, the code in dropm may not
have any write barriers. As a step toward implementing that, change
the gcstack, gcnextsegment, and gcnextsp fields of the g struct to
uintptr, so that assignments to them do not require write barriers.
The gcinitialsp field remains unsafe.Pointer, as on 32-bit systems
that do not support split stack it points to a heap allocated space
used for the goroutine stack.
The test for this is runtime tests like TestCgoCallbackGC, which are
not run today but will be run with a future gotools patch.
Reviewed-on: https://go-review.googlesource.com/46396
From-SVN: r249561
Calling a deferred function currently requires changing from a uintptr
to the function code to a Go function value. That is done by setting
the value of a func local variable using unsafe.Pointer. The local
variable will always be on the stack. Adjust the code that sets the
local variable to avoid generating a write barrier.
A write barrier is never needed here. Also, for deferreturn, we must
avoid write barriers entirely when called from a cgo function; that
requires more than just this, but this is a start.
The test for this is runtime tests that use the go tool; these are not
currently run, but they will be in the future.
Reviewed-on: https://go-review.googlesource.com/46455
From-SVN: r249559
The gc version of the _defer struct has a _panic field that has a
completely different meaning. We are going to want that bring that new
meaning into the gofrontend to improve panic reports with nested
panic calls. Simplify that by first renaming the existing _panic field.
Reviewed-on: https://go-review.googlesource.com/46454
From-SVN: r249558
- don't run tests that depend on SetCgoTraceback
- don't expect a '(' after the function name in a traceback
- change the expected name of nested functions in a traceback
These tests are not currently run, but they will be soon.
Reviewed-on: https://go-review.googlesource.com/46453
From-SVN: r249557
The gofrontend doesn't support the runtime.SetCgoTraceback function,
which is specifically for handling mixed Go and C tracebacks.
Use a build tag to avoid compiling the runtime/testdata/testprogcgo
files that refer to SetCgoTraceback. These files are not currently
compiled anyhow, but they will be with a future gotools patch.
Reviewed-on: https://go-review.googlesource.com/46452
From-SVN: r249556
Building this test with gccgo requires an explicit -pthread option to
be passed to the C compiler, so that it links against -lpthread.
This test is not built today, but it will be soon with a future patch.
Reviewed-on: https://go-review.googlesource.com/46451
From-SVN: r249555
The gc toolchain does the same thing, in gentraceback in
runtime/traceback.go.
The test for this is TestPanicTraceback in runtime/crash_test.go. We
don't yet run that test, but we will in a future change.
Reviewed-on: https://go-review.googlesource.com/46397
From-SVN: r249495
libgo: remove old MIPS architecture names
This removes the old names for the 3 main MIPS ABIs: mipso32, mipsn32
and mipsn64. It also removes the mipso64 ABI which has no equivalent
architecture name in go. This ABI has been dead for sometime and I doubt
anyone will miss it.
Change-Id: I087b243784edf6705fdaf9c32e3233da5e387283
From-SVN: r249485
This removes the old names for the 3 main MIPS ABIs: mipso32, mipsn32
and mipsn64. It also removes the mipso64 ABI which has no equivalent
architecture name in go. This ABI has been dead for sometime and I doubt
anyone will miss it.
Reviewed-on: https://go-review.googlesource.com/46154
From-SVN: r249477
Rename getrandom_linux_mipsn32.go to use the new architecture name for
the n32 ABI and enable building it on mips64p32 and mips64p32le.
Reviewed-on: https://go-review.googlesource.com/46151
From-SVN: r249474
On MIPS, the correct structure for PtraceRegs is 'struct pt_regs' which
is declared in linux/ptrace.h. Previously no PtraceRegs structure was
created on MIPS because 'struct user_regs_struct' doesn't exist there.
Fallback to using pt_regs when the PtraceRegs structure is generated in
mksysinfo.sh, then adjust syscall_linux_mipsx.go to read the program
counter from the correct field.
In addition, implement PtraceGetRegs and PtraceSetRegs on all 3 ABI
variants.
syscall_linux_mips64x.go can now be removed since the ptrace code on
all 3 ABIs is identical.
Reviewed-on: https://go-review.googlesource.com/46150
From-SVN: r249473
On MIPS, the correct structure for PtraceRegs is 'struct pt_regs' which
is declared in linux/ptrace.h. Previously no PtraceRegs structure was
created on MIPS because 'struct user_regs_struct' doesn't exist there.
Fallback to using pt_regs when the PtraceRegs structure is generated in
mksysinfo.sh, then adjust syscall_linux_mipsx.go to read the program
counter from the correct field.
In addition, implement PtraceGetRegs and PtraceSetRegs on all 3 ABI
variants.
syscall_linux_mips64x.go can now be removed since the ptrace code on
all 3 ABIs is identical.
Reviewed-on: https://go-review.googlesource.com/46150
From-SVN: r249472
The go tool will pass -I objdir as one of the flags, where objdir is
the temporary build directory. Remove that from _cgo_flags: we don't
need it, and it will be different each time.
Sort the flags to avoid the unpredictable map iteration order.
This matters for gccgo because for a package that uses cgo, the go
tool when building for gccgo will store the _cgo_flags file in the
archive. That means that we want to generate identical _cgo_flags for
every run.
The test for this is the cmd/go testsuite, to follow in a future CL.
Reviewed-on: https://go-review.googlesource.com/45692
From-SVN: r249199
Pass the -fdebug-prefix-map and -gno-record-gcc-switches compiler
options to gccgo to generate consistent results.
Fix the vendoring code to look for /vendor/, not just /vendor, to
avoid being confused by something like vendor/vendor.org.
Tested by the cmd/go tests in a followup CL.
Reviewed-on: https://go-review.googlesource.com/45695
From-SVN: r249198
These tests fail for various reasons, most commonly because gccgo
doesn't really have GOROOT, so things like `go build errors` fail.
Reviewed-on: https://go-review.googlesource.com/45696
From-SVN: r249197
Add the environment variable GCCGOTOOLDIR to permit overriding the default
directory where tools like cgo are found when building with gccgo.
This will be used by the cmd/go tests in a future CL.
Reviewed-on: https://go-review.googlesource.com/45694
From-SVN: r249196
If GO_TESTING_GOTOOLS is set in the environment, permit tests using
gccgo to run the go tool. Like GO_BUILDER_NAME, this should not be set
normally. But it is needed when testing the go tool itself, and will
be set by the gotools Makefile in a future CL.
Reviewed-on: https://go-review.googlesource.com/45693
From-SVN: r249195
If there is no function name, the traceback is generally
uninformative. In earlier versions we did not show such frames.
Restore that behavior. These frames can be seen with GOTRACEBACK=system.
Reviewed-on: https://go-review.googlesource.com/45431
From-SVN: r249156
Otherwise it may be set when the g struct is reused via gfput/gfget.
Test is golang.org/x/net/http2 with GOMAXPROCS=12.
Reviewed-on: https://go-review.googlesource.com/45430
From-SVN: r249143
Also always access the atomicstatus field atomically.
The effect of not checking the _Gscan bit is that if the GC decides to
scan the stack just as the goroutine is leaving the system call, the
goroutine might fail to call exitsyscall. Then then typically causes
a runtime assertion failure later on. If we do call exitsyscall as we
should, it will stall (in casgstatus) until the _Gscan bit is cleared.
No separate test. I've observed causing sporadic failures running the
misc/cgo tests, but we don't currently have a way to run those
routinely for gccgo. I should fix that.
Reviewed-on: https://go-review.googlesource.com/45392
From-SVN: r249138
Fix lfstack code to work with sparc64 GNU/Linux address map.
Force alignment of epollevent. To make this work reliably, pass
GOARCH explicitly to mkrsysinfo.sh.
Patch by Vladimir Mezentsev.
Reviewed-on: https://go-review.googlesource.com/44494
From-SVN: r248765
Change memory allocation accounting for stacks to use stacks_sys,
since that seems to be what it is for.
Reviewed-on: https://go-review.googlesource.com/43297
From-SVN: r247967
The gc toolchain decides whether a goroutine is a system goroutine by
comparing startpc to a list of saved special PCs. In gccgo that
approach does not work as startpc is often a thunk that invokes the
real function with arguments, so the thunk address never matches the
saved special PCs.
This patch fixes gccgo's understanding of system goroutines. Since
there are only a limited number of them, we simply change each one to
mark itself as special.
This fixes stack dumps and functions like runtime.NumGoroutine to
behave more like gc. It also fixes the goprint test in the gc
testsuite.
Reviewed-on: https://go-review.googlesource.com/43156
From-SVN: r247931
GCC release freeze.
* go-backend.c: Include "go-c.h".
* go-gcc.cc (Gcc_backend::write_export_data): New method.
* go-gcc.cc (Gcc_backend::Gcc_backend): Declare
__builtin_prefetch.
* Make-lang.in (GO_OBJS): Add go/wb.o.
commit 884c9f2cafb3fc1decaca70f1817ae269e4c6889
Author: Than McIntosh <thanm@google.com>
Date: Mon Jan 23 15:07:07 2017 -0500
compiler: insert additional conversion for type desc ptr expr
Change the method Type::type_descriptor_pointer to apply an additional
type conversion to its result Bexpression, to avoid type clashes in
the back end. The backend expression for a given type descriptor var
is given a type of "_type", however the virtual calls that create the
variable use types derived from _type, hence the need to force a
conversion.
Reviewed-on: https://go-review.googlesource.com/35506
commit 5f0647c71e3b29eddcd0eecc44e7ba44ae7fc8dd
Author: Than McIntosh <thanm@google.com>
Date: Mon Jan 23 15:22:26 2017 -0500
compiler: insure tree integrity in Call_expression::set_result
Depending on the back end, it can be problematic to reuse Bexpressions
(passing the same Bexpression to more than one Backend call to create
additional Bexpressions or Bstatements). The Call_expression::set_result
method was reusing its Bexpression input in more than one tree
context; the fix is to pass in an Expression instead and generate
multiple Bexpression references to it within the method.
Reviewed-on: https://go-review.googlesource.com/35505
commit 7a8e49870885af898c3c790275e513d1764a2828
Author: Ian Lance Taylor <iant@golang.org>
Date: Tue Jan 24 21:19:06 2017 -0800
runtime: copy more of the scheduler from the Go 1.8 runtime
Copies mstart, newm, m0, g0, and friends.
Reviewed-on: https://go-review.googlesource.com/35645
commit 3546e2f002d0277d805ec59c5403bc1d4eda4ed9
Author: Ian Lance Taylor <iant@golang.org>
Date: Thu Jan 26 19:47:37 2017 -0800
runtime: remove a few C functions that are no longer used
Reviewed-on: https://go-review.googlesource.com/35849
commit a71b835254f6d3164a0e6beaf54f2b175d1a6a92
Author: Ian Lance Taylor <iant@golang.org>
Date: Thu Jan 26 16:51:16 2017 -0800
runtime: copy over more of the Go 1.8 scheduler
In particular __go_go (aka newproc) and goexit[01].
Reviewed-on: https://go-review.googlesource.com/35847
commit c3ffff725adbe54d8283c373b6aa7dc95d6fc27f
Author: Ian Lance Taylor <iant@golang.org>
Date: Fri Jan 27 16:58:20 2017 -0800
runtime: copy syscall handling from Go 1.8 runtime
Entering a syscall still has to start in C, to save the registers.
Fix entersyscallblock to save them more reliably.
This copies over the tracing code for syscalls, which we previously
weren't doing, and lets us turn on runtime/trace/check.
Reviewed-on: https://go-review.googlesource.com/35912
commit d5b921de4a28b04000fc4c8dac7f529a4a624dfc
Author: Ian Lance Taylor <iant@golang.org>
Date: Fri Jan 27 18:34:11 2017 -0800
runtime: copy SIGPROF handling from Go 1.8 runtime
Also copy over Breakpoint.
Fix Func.Name and Func.Entry to not crash on a nil Func.
Reviewed-on: https://go-review.googlesource.com/35913
commit cc60235e55aef14b15c3d2114030245beb3adfef
Author: Than McIntosh <thanm@google.com>
Date: Mon Feb 6 11:12:12 2017 -0500
compiler: convert go_write_export_data to Backend method.
Convert the helper function 'go_write_export_data' into a Backend
class method, to allow for an implementation of this function that
needs to access backend state.
Reviewed-on: https://go-review.googlesource.com/36357
commit e387439bfd24d5e142874b8e68e7039f74c744d7
Author: Than McIntosh <thanm@google.com>
Date: Wed Feb 8 11:13:46 2017 -0500
compiler: insert backend conversion in temporary statement init
Insert an additional type conversion in Temporary_statement::do_get_backend
when assigning a Bexpression initializer to the temporary variable, to
avoid potential clashes in the back end. This can come up when assigning
something of concrete pointer-to-function type to a variable of generic
pointer-to-function type.
Reviewed-on: https://go-review.googlesource.com/36591
commit c5acf0ce09e61ff623847a35a99da465b8571609
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Wed Mar 1 17:57:53 2017 +0100
libgo: build tags for aix
Build tags for the libgo source files required to build
libgo on AIX.
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/37633
commit 67ed19616898ea18a101ec9325b82d028cd395d9
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Thu Mar 2 15:41:31 2017 +0100
libgo: handle AIX tag in match.sh and gotest
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/37638
commit 83ea2d694c10b2dd83fc8620c43da13d20db754e
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Wed Mar 1 17:48:16 2017 +0100
libgo: add AIX support in configure and Makefile
- support for GOOS=aix
- CFLAGS/GOCFLAGS/LDFLAGS for AIX
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/37632
commit 35d577fe22ffa16a3ccaadf5dae9f6f425c8ec8c
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Mon Mar 6 15:00:15 2017 +0100
runtime: adapt memory management to AIX mmap
On AIX:
* mmap does not allow to map an already mapped range,
* mmap range start at 0x30000000 for 32 bits processes,
* mmap range start at 0x70000000_00000000 for 64 bits processes
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/37845
commit 4e49e56a5fd4072b4ca7fcefe4158d6885d9ee62
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Mon Mar 6 13:42:26 2017 +0100
runtime: add getproccount implementation for AIX
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/37844
commit ff626470294237ac664127894826614edc46a3d0
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Mon Mar 6 17:31:21 2017 +0100
runtime: handle ERESTART errno with AIX's wait4
On AIX, wait4 may return with errno set to ERESTART, which causes unexepected
behavior (for instance, go build may exit with the message "wait: restart
system call" after running a command, even if it was successfull).
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/37846
commit 37daabbfc83d533b826ef9ab10e2dee7406e7198
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Mon Mar 6 11:02:58 2017 +0100
runtime: support for AIX's procfs tree
On AIX, the process executable file is available under /proc/<pid>/object/a.out
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/37842
commit a0275c039d56acf4bf48151978c1a4ec5758cc2c
Author: Ian Lance Taylor <iant@golang.org>
Date: Wed Mar 8 07:00:05 2017 -0800
libgo/Makefile.am: don't use nonportable \n or \t in sed expression
The resulting zstdpktlist.go is less pretty, but it works.
Reviewed-on: https://go-review.googlesource.com/37940
commit 29b190f76105aafa2b50b48249afdafecc97a4be
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Thu Mar 9 16:02:34 2017 +0100
runtime: netpoll and semaphores for AIX
semaphore implementation based on Solaris implementation in
libgo/go/runtime/os_solaris.go
netpoll is just a stub to avoid build failure on AIX.
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/37966
commit 55ca6d3f3cddf0ff9ccb074b2694da9fc54de7ec
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Thu Mar 9 15:38:30 2017 +0100
libmain: ensure initfn is called when loading a go library
AIX does not support .init_array.
The alterative is to export the __go_init function and tell the linker
it is an init function with the -Wl,-binitfini:__go_init option.
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/37965
commit 349a30d17d880ac8bc1a35e1a2ffee6d6e870ae9
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Fri Mar 10 11:15:08 2017 +0100
libgo: use an import list for missing symbols
libgo depends on symbols provided by Go programs at runtime. On AIX,
this requires either to build libgo with -Wl,-berok linker option and
the programs with -Wl,-brtl, or to provide a list of imported symbols
when building libgo. The second options seems preferable, to avoid
requiring an additional option for every Go program.
There are also some symbols that are specific to GNU ld and do not
exist when linking with AIX ld (__data_start, __edata, __etext and
__bss_start).
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/37969
commit 91db0ea1ff068ca1d97b9c99612100ea5b96ddb2
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Wed Mar 8 15:34:45 2017 +0100
crypto/x509: add certificate files locations for AIX
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/37952
commit 92e521c854e91709b949548c47e267377850f26a
Author: Ian Lance Taylor <iant@golang.org>
Date: Fri Mar 10 14:10:11 2017 -0800
compiler: fix check for pointer in Temporary_reference_expression
The check for an unrepresentable pointer in
Temporary_reference_expression::do_get_backend was incorrectly
translated from C to Go in https://golang.org/cl/14346043. Fix the
check to use points_to rather than has_pointer and deref. This should
not make any difference in practice as either way the condition will
only be true for a pointer to void, but points_to is correct and more
efficient.
Reviewed-on: https://go-review.googlesource.com/38009
commit 9a0b676e59e7171a630c48fdc3d4de6712bad0ca
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Thu Mar 16 16:51:53 2017 +0100
libgo: add missing _arpcom struct to *sysinfo.go
This struct is filtered due to having a field of type _in6_addr,
but other types exported to *sysinfo.go are depending on it.
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/38251
commit 61262a757bdd3d9a595ab6a90f68c0c4ebed7bc1
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Thu Mar 16 18:27:46 2017 +0100
syscall: raw_ptrace stub for AIX
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/38253
commit 8029632b50880fd9b5e39299c738b38e3386595f
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Wed Mar 15 16:58:37 2017 +0100
libgo: adapt runtime.inc to AIX
* Two AIX types are wrongfully exported to runtime.inc as their names
make them look like a Go type.
* The sigset go type conflicts with a system sigset type.
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/38192
commit 25f3a90d14bc268479369ecc0eada72791612f86
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Wed Mar 15 16:58:37 2017 +0100
libgo: update Makefile.in, accidentally omitted from last change
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/38310
commit d52b4895616b66f93b460366527e74336829aaa5
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Thu Mar 16 18:39:26 2017 +0100
syscall: TIOCSCTTY does not exist on AIX
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/38254
commit ff1ec3847a4472008e5d53a98b6694b1e54ca322
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Thu Mar 16 18:07:34 2017 +0100
syscall: syscall does not exist on AIX
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/38252
commit c1ee60dabf0b243a0b0286215481a5d326c34596
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Fri Mar 17 17:18:18 2017 +0100
net: EAI_OVERFLOW does not exist on AIX
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/38266
commit ad4ad29aed9f70b14b39b488bfeb9ee745382ec4
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Fri Mar 17 17:23:56 2017 +0100
net: sockopt/sockoptip stubs for AIX
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/38267
commit 5d7db2d7542fe7082f426d42f8c2ce14aad6df55
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Fri Mar 17 16:35:05 2017 +0100
os/user: add listgroups stub for AIX
This is required to build os/user.
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/38263
commit 4e57a7973e9fa4cb5ab977c6d792e62a8f7c5795
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Wed Mar 22 11:11:30 2017 +0100
os: fix readdirnames for AIX
Largefile implementation should be used on AIX.
readdir64_r function returns 9 and sets result to NULL when
reaching end of directory, so this return code should not
always be considered as an error.
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/38359
commit b34036967d1ec57b25e3debe077439b4210a1d4a
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Fri Mar 17 17:39:31 2017 +0100
libgo: adapt sigtab.go to AIX
On AIX, _NSIG is not directly defined to its integer value in
gen-sysinfo.go.
The real value is _SIGMAX32+1 or _SIGMAX64+1, depending if we are
building a 32bit ligbo or a 64bit libgo, so we need to read one of
those constants to set nsig value in mksigtab.sh
This change also ensures that all signal numbers from 0 to nsig-1
are referenced in sigtable.
Reviewed-on: https://go-review.googlesource.com/38268
commit 20991c32671a183ec859b4f285df37fdd4634247
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Thu Mar 23 17:28:09 2017 +0100
syscall: missing import in socket_bsd.go
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/38369
commit c34754bd9adf5496c4c26257eaa50793553c11e8
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Wed Mar 22 17:57:01 2017 +0100
sycall: WCOREDUMP macro is not defined on AIX
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/38363
commit 4f38813482227b12ea0ac6ac1b981ff9ef9853ef
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Thu Mar 23 17:44:43 2017 +0100
libgo: additional build tags for AIX
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/38510
commit d117ede6ff5a7083e9c40eba28a0f94f3535d773
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Thu Mar 23 17:48:46 2017 +0100
go/build: add AIX to "go build" command known OS
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/38511
commit 7b0ddaa6a6a71f9eb1c374122d29775b13c2cac5
Author: Ian Lance Taylor <iant@golang.org>
Date: Thu Mar 23 09:57:01 2017 -0700
compiler: don't crash if imported package imports this one
When building a test it's OK if test code imports a package that
imports this one. The go tool is supposed to catch cases where this
creates an impossible initialization order. The compiler already has
code to permit this in Gogo::add_import_init_fn. This CL avoids a
compiler crash on a similar case when writing out the export data.
I have no test case for this. Basically it pushes a compiler crash
into an error reported elsewhere.
Problem was reported by Tony Reix.
Reviewed-on: https://go-review.googlesource.com/38462
commit 925636975d075e3e3353823b09db3f933f23cb03
Author: Ian Lance Taylor <iant@golang.org>
Date: Wed Mar 29 14:14:18 2017 -0700
runtime: copy finalizer support from Go 1.8 runtime
Reviewed-on: https://go-review.googlesource.com/38794
commit 1ccb22b96cb3b1011db0e427877d9ddecb577fa9
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Thu Mar 30 15:21:06 2017 +0200
runtime: initcontext and setcontext stubs for AIX
Further investigations are required to understand the clobbering
issue and implement a proper fix. Until then, those stubs are
required to allow the build to complete.
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/38930
commit 27db481f369b54256063c72b911d22390c59199c
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Wed Mar 29 18:07:25 2017 +0200
os: fix Readlink failure on AIX
AIX readlink routine returns an error if the link is longer
than the buffer, instead of truncating the link.
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/38700
commit c93babbf48eddd0bc34d4179ffb302dc60087299
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Wed Mar 29 17:26:35 2017 +0200
compiler: implement support for reading AIX big archives
This is required to read go export from a Go library.
Code courtesy of Damien Bergamini from Atos Infogérance.
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/38698
commit 930dd53482bdee3a9074850d168d0b9d7819c135
Author: Ian Lance Taylor <iant@golang.org>
Date: Thu Apr 6 18:50:11 2017 -0700
compiler: fix whether conversions are static initializers
The compiler was incorrectly treating type conversions from string to
int or vice-versa as static initializers. That doesn't work, as those
conversions are implemented via a function call.
This case may never actually arise but it seems like the right thing to do.
Reviewed-on: https://go-review.googlesource.com/39872
commit f02691e4195728dbf06f4dde0853c6bccc922183
Author: Ian Lance Taylor <iant@golang.org>
Date: Thu Apr 6 17:24:08 2017 -0700
compiler, runtime: don't let slices point past end of memory block
When Go code uses a slice expression like [:len(str)] or [:cap(slice)],
it's natural for the resulting pointer to point just past the end of
the memory block. If the next memory block is not live, we now have a
live pointer to a dead block, which will unnecessarily keep the block
alive. That wastes space, and with the new Go 1.8 GC (not yet
committed) will trigger an error when using GODEBUG=gccheckmark=1.
This changes the implementation of slice expressions to not move the
pointer if the resulting string length or slice capacity is 0. When
the length/capacity is zero, the pointer is never used anyhow.
Reviewed-on: https://go-review.googlesource.com/39870
commit 17527c35b027e1afcc318faf5563909e1e9d44a6
Author: Ian Lance Taylor <iant@golang.org>
Date: Thu Apr 6 15:30:11 2017 -0700
compiler: emit write barriers
The Go 1.8 concurrent GC requires optional write barriers for all
assignments that may change pointer values in the heap or in a global
variable. For details see https://blog.golang.org/go15gc.
This changes the gofrontend code to emit write barriers as needed.
This is in preparation for future changes. At the moment the write
barriers will do nothing. They test runtime.writeBarrier.enabled,
which will never be non-zero. They call simple functions which just
do a move without doing any of the other operations required by the
write barrier.
Reviewed-on: https://go-review.googlesource.com/39852
commit c0b00f072bf34b2c288e1271ec8118b88c4f6f6f
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Tue Apr 11 17:47:29 2017 +0200
libgo: allow building gox files from PIC objects
libtool builds non-PIC objects in the same directory as .lo files
and PIC objects in a .libs subdirectory.
BUILDGOX rule uses the non-PIC objects to build the gox files,
but on AIX only the PIC objects are built.
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/40355
commit ea0f3da174c5503a209043f14ddda34871cfec52
Author: Ian Lance Taylor <iant@golang.org>
Date: Thu Apr 6 19:06:14 2017 -0700
compiler: add code to generate a ptrmask for a type
The Go 1.8 garbage collector uses a ptrmask for all types below a
certain size. A ptrmask is simply a bit vector with a single bit for
each pointer-sized word in the value. The bit is 1 if the type has a
pointer in that position, 0 if it does not.
This change adds code to the compiler to generate a ptrmask. The code
is not used by anything yet, it is just compiled. It will be used
when we switch over to the Go 1.8 garbage collector.
The new Array_type::int_length method, and the new memory_size
methods, will also be used by other patches coming later.
Reviewed-on: https://go-review.googlesource.com/39873
commit 3029e1df3be3614d196a03c15e50e68ff850aa4c
Author: Ian Lance Taylor <iant@golang.org>
Date: Fri Apr 7 10:31:39 2017 -0700
compiler: add code to generate a gcprog for a type
The Go 1.8 garbage collector uses a gcprog for all types above a
certain size. A gcprog describes where the pointers are in the type,
using a simple bytecode machine that supports repeating bits. The
effect is to permit using much less space to describe arrays. The
format is described in runtime/mbitmap.go in the docs for runGCProg.
This is not yet added to the gofrontend, but can be seen in the gc sources.
This change adds code to the compiler to generate a gcprog. The code
is not used by anything yet, it is just compiled. It will be used
when we switch over to the Go 1.8 garbage collector.
Reviewed-on: https://go-review.googlesource.com/39923
commit 8b01ef1e9176d20f4c9e667972fe031069a4d057
Author: Ian Lance Taylor <iant@golang.org>
Date: Thu Apr 13 07:00:35 2017 -0700
compiler: add ptrdata computations and expressions
For the upcoming Go 1.8 GC we need to compute the "ptrdata" of a type:
the number of bytes in the type that can contain pointers. For types
that do not contain pointers this number is zero. For many types it
is a number larger than zero but smaller than the total size of the
type. The Go 1.8 GC uses this number to make loops looking for
pointers run faster by not scanning the suffix of a value that can not
contain a pointer.
Unfortunately there are two subtly different definitions of ptrdata,
and we need both. The first is the simple one: the prefix that can
contain pointers. The second is the number of bytes described by the
gcprog for the type. Recall that we describe the exact position of
pointers in a type using either a ptrmask or a gcprog. The ptrmask is
simpler, the gcprog uses less space. We use the gcprog for large
types, currently defined as types that are more than 2048 bytes. When
the Go 1.8 runtime expands a gcprog, it verifies that the gcprog
describes exactly the same number of bytes as the ptrdata field in the
type descriptor. If the last pointer-containing portion of a type is
an array, and if the elements of the array have a ptrdata that is less
than the size of the element type, then the simple definition of the
ptrdata will not include the final non-pointer-containing bytes of the
last element of the array. However, the gcprog will define the array
using a repeat count, and will therefore include the full size of the
last element of the array. So for a type that needs a gcprog, the
ptrdata field in the type descriptor must be the size of the data
described by the gcprog, and that is not necessarily the same as the
simple ptrdata.
It might seem that we can always use the gcprog version of the ptrdata
calculation, since that is what will appear in a type descriptor, but
it turns out that for global variables we always use a ptrmask, not a
gcprog, even if the global variable is large. This is because gcprogs
are handled by expanding them into a ptrmask at runtime, and for a
global variable there is no natural place to put the ptrmask. Simpler
to always use the ptrmask. That means that we need to describe the
size of the ptrmask, and that means that we need an expression for the
simple form of the ptrdata.
This CL implements the ptrdata calculation. This code is not actually
used yet. It will be used later when the Go 1.8 GC is committed.
Reviewed-on: https://go-review.googlesource.com/40573
commit 7a37331303b572412179a08141f1dd35339d40c8
Author: Ian Lance Taylor <iant@golang.org>
Date: Fri Apr 14 06:55:48 2017 -0700
compiler: zero length arrays never contain pointers
Reviewed-on: https://go-review.googlesource.com/40696
commit c242f0508a64d3d74a28d498cbaeda785ff76258
Author: Ian Lance Taylor <iant@golang.org>
Date: Fri Apr 14 07:26:54 2017 -0700
bytes: disable allocations test on gccgo
It turns out that testing.AllocsPerRun has not been producing correct
results with the current gccgo memory allocator. When we update to
the Go 1.8 memory allocator, testing.AllocsPerRun will work again, and
this test will fail due to lack of escape analysis.
Reviewed-on: https://go-review.googlesource.com/40700
commit 0dc369f1d63376a36bfb0999a1b0377fd444bfab
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Tue Apr 11 16:22:38 2017 +0200
os: alternative way to find executable path, using Args[0]
AIX does not provide a proper way to find the original
executable path from procfs, which contains just an
hardlink.
Executable path can be found using Args[0], Getcwd and
$PATH.
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/40353
commit f9bad1342569b338e3b2ea9f12ffc6d3d3fa3028
Author: Ian Lance Taylor <iant@golang.org>
Date: Fri Apr 14 08:01:19 2017 -0700
compiler: don't write struct with multiple sink fields to C header file
When writing a struct to the C header file used by the C runtime code,
a single sink field is fine: it will be called "_", which is valid C.
There are structs with single sink fields that we want to write out,
such as finblock. As it happens, though, the Go 1.8 runtime has a
struct with two sink fields, gcControllerState, which will produce a C
definition with two fields named "_", which will fail. Since we don't
need to know that struct in C, rather than fix the general case, just
punt if the struct has multiple sink fields.
After the conversion to the Go 1.8 GC, we may be able to get rid of
the C header file anyhow. I'm not sure yet.
Reviewed-on: https://go-review.googlesource.com/40701
commit cfc28901a572aeb15b2f10a38f79eec04c64dfb2
Author: Ian Lance Taylor <iant@golang.org>
Date: Fri Apr 14 10:07:23 2017 -0700
runtime: disable allocations test on gccgo
It turns out that testing.AllocsPerRun has not been producing correct
results with the current gccgo memory allocator. When we update to
the Go 1.8 memory allocator, testing.AllocsPerRun will work again, and
these tests will fail due to lack of escape analysis.
Reviewed-on: https://go-review.googlesource.com/40703
commit 36fedd76edaa48b9ec09709a70d9e4abaddf0caf
Author: Ian Lance Taylor <iant@golang.org>
Date: Fri Apr 14 10:47:06 2017 -0700
runtime: remove unused size argument from hash/equal fns
The size argument was removed from hash and equal functions in CL
34983. Somehow I missed removing them from three of the predefined
functions.
Reviewed-on: https://go-review.googlesource.com/40770
commit 90f6accb48d2e78cad8955b9292933f6ce3fe4c8
Author: Ian Lance Taylor <iant@golang.org>
Date: Fri Apr 14 13:23:05 2017 -0700
runtime: remove unused stack.go
We're never going to use stack.go for gccgo. Although a build tag
keeps it from being built, even having it around can be confusing.
Remove it.
Reviewed-on: https://go-review.googlesource.com/40774
commit befa71603fc66a214e01ac219f2bba36e19f136f
Author: Ian Lance Taylor <iant@golang.org>
Date: Fri Apr 14 13:18:34 2017 -0700
runtime: build fastlog
Take out the build tags which were preventing fastlog2 from being
built. It's used by the upcoming Go 1.8 GC.
Reviewed-on: https://go-review.googlesource.com/40773
commit b7e19e9be4ab4c3cd8f4c9506d79a8cd56bace40
Author: Ian Lance Taylor <iant@golang.org>
Date: Fri Apr 14 10:04:23 2017 -0700
runtime: add tests from Go 1.8
Some runtime package tests never made it into the gofrontend repo for
some reason. Add them now.
Reviewed-on: https://go-review.googlesource.com/40869
commit 1feef185aebd71bc2a09b9a04287461806096610
Author: Ian Lance Taylor <iant@golang.org>
Date: Mon Apr 17 16:26:11 2017 -0700
runtime: change mcall to take a Go function value
For future work in bringing in the Go 1.8 GC, change the mcall
function to take a Go function value, which means that mcall can take
a closure rather than just a straight C function pointer.
As part of this change move kickoff from C to Go, which we want to do
anyhow so that we run the write barriers that it generates.
Reviewed-on: https://go-review.googlesource.com/40935
commit c3db34f4efc2d610f74a01dd2ad7775f48889b29
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Tue Apr 11 16:11:26 2017 +0200
runtime: netpoll implementation for AIX
Code courtesy of Damien Bergamini from Atos Infogérance.
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/40352
commit f5634dff40e53ad9ce61afd67fd07334e3af9d1f
Author: Ian Lance Taylor <iant@golang.org>
Date: Tue Apr 18 22:06:07 2017 -0700
runtime: move mstart from Go to C
The assignments done in mstart must be done without write barriers, as
mstart is running without an m or p. In the gc toolchain the
equivalent code to intialize g and g->m is written in assembler;
on GNU/Linux, it's in the clone function.
Reviewed-on: https://go-review.googlesource.com/40989
commit 671d7c74592f4b6fe3665af279482ba0ea47ca2d
Author: Ian Lance Taylor <iant@golang.org>
Date: Tue Apr 18 17:47:28 2017 -0700
compiler: varargs slices do not escape in runtime
Also, don't try to allocate an empty slice on the stack, as it will
confuse the GCC backend.
Also add a few trivial style, code formatting, and debug output fixes.
Updates golang/go#17431
Reviewed-on: https://go-review.googlesource.com/40983
commit 94699d25f31353bf03419eda56b15993a39f3275
Author: Ian Lance Taylor <iant@golang.org>
Date: Tue Apr 18 17:30:09 2017 -0700
compiler: add Ptrmask_symbol_expression
Add an expression to evaluate to the ptrmask for a type. This will be
used for global variables, which always use a ptrmask no matter how
large they are.
Reviewed-on: https://go-review.googlesource.com/40981
commit bfff1654eac5b9288fa6c431e66cba8c9da6a660
Author: Ian Lance Taylor <iant@golang.org>
Date: Mon Apr 17 10:51:16 2017 -0700
runtime: change g's in systemstack
The systemstack function in the gc toolchain changes to a different g.
This is often used to get more stack space; the gofrontend uses a
different stack growth mechanism that does not require changing g's,
so we've been running with a version of systemstack that keeps the
same g. However, the garbage collector has various tests to verify
that it is running on g0 rather than on a normal g. For simplicity,
change the gofrontend version of systemstack to change to a different
g just as the gc toolchain does.
This permits us to uncomment some sanity checks in notetsleep.
Doing that requires us to fix up a couple of places where C code calls
{start,stop}TheWorldWithSema while not on g0.
Note that this does slow down some code in the runtime package unnecessarily.
It may be useful to find some places where the runtime calls
systemstack only to get more stack space and change it to use some
other function. That other function would act like systemstack in the
gc toolchain but simply call the argument in the gofrontend.
Reviewed-on: https://go-review.googlesource.com/40973
commit b2ccc7601ce71a7c5732154cf9b2eeea64681469
Author: Ian Lance Taylor <iant@golang.org>
Date: Wed Apr 19 10:36:12 2017 -0700
compiler, runtime: include ptrmask in GC roots
Change the list of registered GC roots to include a ptrmask,
and change the data structures to be easily used from Go code.
The new ptrmask will be used by the Go 1.8 GC to only scan pointers.
Tweak the current GC to use the new structures, but ignore the new
ptrmask information for now.
The new GC root data includes the size of the variable. The size is
not currently used, but will be used later by the cgo checking code.
Reviewed-on: https://go-review.googlesource.com/41075
commit 9e065149970bc180e4ca83bb99c74d9c4f43b47b
Author: Ian Lance Taylor <iant@golang.org>
Date: Wed Apr 19 12:23:16 2017 -0700
compiler, runtime: don't pass size to __go_new
There is no reason to pass the size to __go_new, as the type
descriptor includes the size anyhow. This makes the function
correspond to the Go 1.8 function runtime.newobject, which is what we
will use when we update to the Go 1.8 memory allocator.
Reviewed-on: https://go-review.googlesource.com/41080
commit c321de7b738c4a3387c1842919c9305acfa04c57
Author: Ian Lance Taylor <iant@golang.org>
Date: Wed Apr 19 13:13:56 2017 -0700
compiler, runtime, reflect: make type descriptors more like Go 1.8
Change the type descriptor structure to be more like the one in the Go
1.8 runtime. Specifically we add the ptrdata field, rename the gc
field to gcdata and change the type to *byte, and rearrange a few of
the fields. The structure is still not identical to the Go 1.8
structure--we don't use any of the tricks to reduce overall executable
size--but it is more similar.
For now we don't use the new ptrdata field, and the gcdata field is
still the old format rather than the new Go 1.8 ptrmask/gcprog format.
Reviewed-on: https://go-review.googlesource.com/41081
commit 7b70c52cddeebea9ebeac003f8c6aad59497e5f0
Author: Ian Lance Taylor <iant@golang.org>
Date: Wed Apr 19 14:54:29 2017 -0700
reflect: make sure to clear unusable hash/equal function
Otherwise we wind up copying the one from the prototype, which is wrong.
Also rewrite the hash/equal functions to look like the ones in Go 1.8,
mainly a matter of changing names and using arrayAt.
Reviewed-on: https://go-review.googlesource.com/41133
commit 84d26f467f7de8bdbb0d230458135fe1b6b2a99d
Author: Ian Lance Taylor <iant@golang.org>
Date: Wed Apr 19 14:59:13 2017 -0700
runtime: remove duplicate declarations of SetFinalizer/KeepAlive
These should have been removed in CL 38794. It's a bug that the
compiler even permits these duplicate declarations.
Reviewed-on: https://go-review.googlesource.com/41134
commit f85ff7e64c24031f6d0bd7c9c426b6176cb95160
Author: Ian Lance Taylor <iant@golang.org>
Date: Wed Apr 19 15:56:32 2017 -0700
runtime: don't crash if panicstring called with no m
It's possible for runtime_panicstring to be called with no m if a
signal handler, or scheduler innards, do something wrong. If that
happens carry on with the panic rather than crashing.
Reviewed-on: https://go-review.googlesource.com/41137
commit 5b362b04f642afb8b20715930416fc3b7d91bb12
Author: Than McIntosh <thanm@google.com>
Date: Fri Mar 31 14:35:48 2017 -0400
compiler: fix for expr sharing introduced by Order_eval::statement.
When processing an expression statement with a top-level call
that returns multiple results, Order_eval::statement can wind up
creating a tree that has multiple references to the same call,
which results in a confusing AST dump. Change the implementation
to avoid introducing this unwanted sharing.
Reviewed-on: https://go-review.googlesource.com/39210
commit b05b4260a68695bf9c9cc29e14ae86ca2699458a
Author: Ian Lance Taylor <iant@golang.org>
Date: Wed Apr 19 16:00:28 2017 -0700
runtime: restore correct m in gtraceback
If gtraceback is used to get a stack trace of a g running in the same m,
as can happen if we collect a stack trace from a g0, then restore the
old m value, don't clear it.
Reviewed-on: https://go-review.googlesource.com/41138
commit ca8bbf4dfac19b3f4f7ce21a688b96a418c75031
Author: Ian Lance Taylor <iant@golang.org>
Date: Wed Apr 19 16:03:24 2017 -0700
runtime: set startpc field when starting a new goroutine
This puts the right value in a trace--previously it was always zero.
Reviewed-on: https://go-review.googlesource.com/41139
commit ca8bbf4dfac19b3f4f7ce21a688b96a418c75031
Author: Ian Lance Taylor <iant@golang.org>
Date: Wed Apr 19 16:03:24 2017 -0700
runtime: set startpc field when starting a new goroutine
This puts the right value in a trace--previously it was always zero.
Reviewed-on: https://go-review.googlesource.com/41139
commit 887690dce42d7bf8f711f8ea082e4928fb70f2a5
Author: Ian Lance Taylor <iant@golang.org>
Date: Wed Apr 19 17:06:11 2017 -0700
runtime: add prefetch functions
The Go 1.8 GC uses prefetch functions. Add versions for gccgo that
call __builtin_prefetch. Uncomment the test for them in testAtomic64.
Don't force the check function to return early, as now taking the
address of a local variable in the runtime package does not force it
onto the heap.
Reviewed-on: https://go-review.googlesource.com/41144
commit 4269db69f9184e5a45c54aaee7352425a1f88bff
Author: Ian Lance Taylor <iant@golang.org>
Date: Wed Apr 19 17:55:21 2017 -0700
runtime: split up ticks to get correct alignment
On 32-bit x86 a uint64 variable by itself is aligned to an 8-byte boundary.
A uint64 field in a struct is aligned to a 4-byte boundary.
The runtime.ticks variable has a uint64 field that must be aligned
to an 8-byte boundary. Rather than rely on luck, split up the struct
into separate vars so that the required alignment happens reliably.
It would be much nicer if issue golang/go#19057 were fixed somehow,
but that is for another day.
Reviewed-on: https://go-review.googlesource.com/41143
commit 66926cabdbdbf3431b4f172f7756e195c1c6c513
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Thu Apr 20 17:15:38 2017 +0200
libgo: fix bad value for O_CLOEXEC on AIX 7.1
On AIX 7.1, O_CLOEXEC is defined as 0x0000001000000000, which
creates an integer constant overflow error when building libgo.
This affects only 7.1, O_CLOEXEC is not defined on 6.1 (and
defaults to O in sysinfo.go) and is defined as 0x00800000 on
AIX 7.2.
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/41214
commit af288ff10aeafc47651f5def327ed56425d5be19
Author: Ian Lance Taylor <iant@golang.org>
Date: Thu Apr 20 17:15:02 2017 -0700
runtime: preserve stack context in tracebackothers
The tracebackothers function works by saving the current stack context
in the goroutine's context field and then calling gogo to switch to a
new goroutine. The new goroutine will collect its own stack trace and
then call gogo to switch back to the original goroutine. This works
fine, but if the original goroutine was called by mcall then the
contents of its context field are needed to return from the mcall.
Fix this by saving the stack context across the calls to the other
goroutines.
Reviewed-on: https://go-review.googlesource.com/41293
commit 43101e5956e793f1b4de05c15d7738c785e927df
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Fri Apr 21 10:58:52 2017 +0200
os/user: use _posix_* libc functions
libc getpwnam_r function has a different signature, we must use
_posix_getpwnam_r instead (by default, the pwd.h system include
file defines getpwnam_r as a static function calling
_posix_getpwnam_r, so a C program calling getpwnam_r will indeed
reference the _posix_getpwnam_r symbol).
Idem for getpwuid_r, getgrnam_r and getgrgid_r.
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/41334
commit 71e1fec4d2a536591ea6657a06916a17b5127071
Author: Ian Lance Taylor <iant@golang.org>
Date: Wed Apr 19 21:24:48 2017 -0700
runtime: don't use pointers in g_ucontext_t or stackcontext
The g_ucontext_t type holds registers saved for a goroutine. We have
to scan it for pointers, but since registers don't necessarily hold
pointers we have to scan it conservatively. That means that it should
not have a pointer type, since the GC will always scan pointers.
Instead it needs special treatment to be scanned conservatively.
The current GC doesn't care when a pointer type holds a non-pointer,
but the Go 1.8 GC does.
For the current GC this means we have to explicitly scan the
g_ucontext_t values in a G.
While we're at it change stackcontext to be uintptr too. The entries
in stackcontext never hold pointers that the Go GC cares about.
Reviewed-on: https://go-review.googlesource.com/41270
commit eab2960aee91d3e3a6baa5b1bce01262d24c714f
Author: Ian Lance Taylor <iant@golang.org>
Date: Thu Apr 20 17:08:19 2017 -0700
runtime/internal/sys: define Goexperiment
The gc toolchain defines Goexperiment based on the environment
variable GOEXPERIMENT when the toolchain is built. We just always set
Goexperiment to the empty string.
Reviewed-on: https://go-review.googlesource.com/41292
commit be4a751943265c0637da859d15a4faf162f5c478
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Thu Apr 20 14:04:35 2017 +0200
net: sockopt implementation for AIX
This is a copy of the Linux implementation, it allows to
run some simple client/server applications on AIX, while
the current sockopt stubs don't.
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/41213
commit 46a669c4ca5b80fd6f6a0a42095804d9f704611d
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Wed Mar 29 17:55:06 2017 +0200
math: fix sign for atan/expm1/log1p(-0)
AIX libc returns +0 for atan(-0), expm1(-0) and log1p(-0),
while matching Go functions must return -0.
Code courtesy of Tony Reix.
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/38699
commit 53b0e809130038a46f0a3d2870e3905f44ab888d
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Wed Apr 26 17:29:22 2017 +0200
runtime: fix context clobbering on AIX
On AIX 64-bits, r13 is a pointer to thread data.
setcontext() overwrites r13 with the value saved by getcontext().
So, when a goroutine is scheduled on a new thread, r13 will point
to the old thread data after calling setcontext().
Code courtesy of Damien Bergamini.
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/41854
commit f8d5ebd71c71e6e777200530d8204b92619157f8
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Wed Apr 26 18:01:19 2017 +0200
runtime: fix wrong time calculation in semasleep
tv_nsec is added twice when calculating the sleep end time.
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/41855
commit ef56097f4ea848d48fbf61eba1c757fe7fce99d3
Author: Matthieu Sarter <matthieu.sarter.external@atos.net>
Date: Fri Apr 28 10:27:32 2017 +0200
libgo: pass $(NM) value when running benchmarks
On AIX, we need to use "nm -B" instead of "nm", to have the
epxected output format, so the configured $(NM) value from
the Makefile should be exported before running gotest, which
defaults to "nm" if $NM is not set.
Issue golang/go#19200
Reviewed-on: https://go-review.googlesource.com/42051
commit 0fb550083ae474fb964435927b899ec8e4b62771
Author: Ian Lance Taylor <iant@golang.org>
Date: Wed Nov 16 21:12:53 2016 -0800
runtime: copy garbage collector from Go 1.8 runtime
This giant patch replaces the old Go 1.4 memory allocator and garbage
collector with the new Go 1.8 code. The memory allocator is fairly
similar, though now written in Go rather than C. The garbage
collector is completely different. It now uses ptrmask and gcprog
information, which requires changes in the compiler and the reflect
package as well as the runtime. And, of course, the garbage collector
now runs concurrently with program execution.
In the gc toolchain the garbage collector is strict and precise at all
levels. In the gofrontend we do not have stack maps, so stacks, and
register values, are collected conservatively. That means that an
old, no longer used, pointer on a stack or in a register can cause a
memory object to live longer than it should. That in turns means that
we must disable some checks for invalid pointers in the garbage
collection code. Not only can we get an invalid pointer on the stack;
the concurrent nature of the collector means that we can in effect
resurrect a block that was already unmarked but that the collector had
not yet gotten around to freeing, and that block can in turn point to
other blocks that the collector had managed to already free. So we
must disable pointer checks in general. In effect we are relying on
the fact that the strict pointer checks in the gc toolchain ensure
that the garbage collector is correct, and we just assume that it is
correct for the gofrontend since we are using the same code.
Reviewed-on: https://go-review.googlesource.com/41307
commit a95078d501175240d095500a8c5fbfb21bec65cb
Author: Ian Lance Taylor <iant@golang.org>
Date: Mon Apr 24 16:33:47 2017 -0700
libgo/Makefile: clean more files
Fix up the mostlyclean, clean, and distclean targets to better follow
https://www.gnu.org/prep/standards/html_node/Standard-Targets.html.
Reviewed-on: https://go-review.googlesource.com/41625
commit 5956bf1055451cf4239cdfeca259c23b1ded54d8
Author: Ian Lance Taylor <iant@golang.org>
Date: Mon May 8 13:35:11 2017 -0700
libgo: delete goc2c
The last .goc file has been removed, so remove goc2c.
The goc2c program was my first contribution to the gc repository that
was more than 100 lines:
2b57a1124e
The program was used in gc for a few years under various guises but
was finally removed in https://golang.org/cl/132680043. Now we can
remove it from gofrontend as well.
Reviewed-on: https://go-review.googlesource.com/42911
commit a222e35d041de0cd42506b61c93b8209e07702b9
Author: Than McIntosh <thanm@google.com>
Date: Tue May 9 10:33:10 2017 -0400
compiler: set "need_init_fn" when adding gc root
Variables that back slice initializers in certain cases have to be
added to the gc roots list, since they can be modified at runtime. The
code that was doing this addition did not update the flag that tracks
whether the package being compiled needs an initializer function,
which resulted in the call in question being left out of the final
generated code in certain cases. Fix is to change Gogo::add_gc_root()
to update the "needs init" flag.
Reviewed-on: https://go-review.googlesource.com/43030
commit 822ab419bf7d1c705cdce1c12133e7a11f56be2e
Author: Than McIntosh <thanm@google.com>
Date: Tue May 9 11:36:51 2017 -0400
compiler: fix variable context nit in write barrier generation
Update the write barrier generation code to insure that the "lvalue
context" tag on the space var expression is set only in the case where
the expr feeds directly into an assignment. This is somewhat
counter-intuitive, but needed in the case where the backend looks at
context tags.
Reviewed-on: https://go-review.googlesource.com/43031
From-SVN: r247848
PR go/77857
cmd/go: generate vendor paths for -I arg on compile
This change generates the vendor path to be used with -I
on a gccgo compile to find imports from the vendor directories.
Fixesgolang/go#15628
Reviewed-on: https://go-review.googlesource.com/39590
From-SVN: r246864
PR go/80302
time: make the ParseInLocation test more robust
This is a backport of https://golang.org/cl/37964 from the gc toolchain.
Original description:
The tzdata 2017a update (2017-02-28) changed the abbreviation of the
Asia/Baghdad time zone (used in TestParseInLocation) from 'AST' to the
numeric '+03'.
Update the test so that it skips the checks if we're using a recent
tzdata release.
Updates golang/go#19457
Fixes GCC PR 80302.
Reviewed-on: https://go-review.googlesource.com/39470
From-SVN: r246695
The use of &[1]uintptr{fn} was causing sigfwd to allocate memory, even
though it is being compiled for the runtime package. That is a bad
idea for this function, which is invoked by a signal handler. Rewrite
it to use only constructs that do not allocate memory when compiled
for the runtime package.
The test for this is misc/cgo/testcarchive in the main repo, which we
don't yet test.
Reviewed-on: https://go-review.googlesource.com/37454
From-SVN: r245777
Along with the update this fixes a problem that was always present but
only showed up with the new reflect test. When a program used a
**unsafe.Pointer and stored the value in an interface type, the
generated type descriptor pointed to the GC data for *unsafe.Pointer.
It did that by name, but we were not generating a variable with the
right name.
Reviewed-on: https://go-review.googlesource.com/37144
From-SVN: r245535
When I updated to Go 1.8, the initsig function moved from
signal1_unix.go to signal_unix.go, and lost a gccgo-specific change in
the move. Add it back.
This would have been caught by the misc/cgo/testcarchive tests in the
gc repository, but we don't run those in the gccgo repository. We
should fix that, somehow.
Reviewed-on: https://go-review.googlesource.com/35839
From-SVN: r244947
Fix a bug in the generation of the hash value in reflect.FuncOf.
The merge script missed a bunch of testdata files over the years.
Copy them over.
Reviewed-on: https://go-review.googlesource.com/35570
From-SVN: r244835
Some fixes that permit misc/cgo/test in the master gc repository to
pass using the current gccgo.
Install testing/internal/testdeps.gox; it is needed by `go test`.
Export runtime.lockedOSThread to enable calling via go:linkname; it is
used by misc/cgo/test.
Loop on EAGAIN when creating a new thread; this is what the gc code
does, and misc/cgo/test tests that it works.
Reviewed-on: https://go-review.googlesource.com/35479
From-SVN: r244733
PR go/79146
math/big: fix build on s390x
Don't build arith_decl_s390x.go for gccgo; it is only for assembly
code that has not yet been ported to gccgo.
For GCC PR 79146.
From-SVN: r244731
PR go/79146
crypto/elliptic: explicitly ignore p256_s390x.go
The file only works if used in conjunction with assembly code not
(yet) written for gccgo.
Fixes GCC PR 79146.
Reviewed-on: https://go-review.googlesource.com/35477
From-SVN: r244679
Since the name siginfo winds up in runtime.inc, this avoids a name
collision on systems that define "struct siginfo" in the system header
files.
Reviewed-on: https://go-review.googlesource.com/35239
From-SVN: r244484
Compiler changes:
* Change map assignment to use mapassign and assign value directly.
* Change string iteration to use decoderune, faster for ASCII strings.
* Change makeslice to take int, and use makeslice64 for larger values.
* Add new noverflow field to hmap struct used for maps.
Unresolved problems, to be fixed later:
* Commented out test in go/types/sizes_test.go that doesn't compile.
* Commented out reflect.TestStructOf test for padding after zero-sized field.
Reviewed-on: https://go-review.googlesource.com/35231
gotools/:
Updates for Go 1.8rc1.
* Makefile.am (go_cmd_go_files): Add bug.go.
(s-zdefaultcc): Write defaultPkgConfig.
* Makefile.in: Rebuild.
From-SVN: r244456
I looked at a diff of proc.go between Go 1.7 and gccgo, and copied
over all the easy stuff.
Reviewed-on: https://go-review.googlesource.com/35090
From-SVN: r244291
Drop the size arguments for the hash/equal functions stored in type
descriptors. Types know what size they are. To make this work,
generate hash/equal functions for types that can use an identity
comparison but are not a standard size and alignment.
Drop the multiplications by 33 in the generated hash code and the
reflect package hash code. They are not necessary since we started
passing a seed value around, as the seed includes the hash of the
earlier values.
Copy the algorithms for standard types from the Go 1.7 runtime,
replacing the C functions.
Reviewed-on: https://go-review.googlesource.com/34983
From-SVN: r244256
This started by moving procresize from C to Go so that we can pass the
right type to the memory allocator when allocating a p, which forced
the gomaxprocs variable to move from C to Go, and everything else
followed from that.
Reviewed-on: https://go-review.googlesource.com/34916
From-SVN: r244236
PR go/78789
runtime: don't build aeshash.c if the assembler doesn't support it
This is for CentOS 5, whose assembler does not know the aesinc
instruction.
Fixes GCC PR 78789.
Patch by Uros Bizjak.
Reviewed-on: https://go-review.googlesource.com/34796
From-SVN: r244031
Remove support for _cgo_allocate. It was removed from the gc
toolchain in Go 1.5, so it is unlikely that anybody is trying to use it.
Reviewed-on: https://go-review.googlesource.com/34557
From-SVN: r243805
Rewrite the 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.
Also change mips64pe32le to mips64p32le in configure script--noticed
during CL review.
Reviewed-on: https://go-review.googlesource.com/34022
From-SVN: r243445
The gc library allocates a _panic struct on the stack. This does not
work for gccgo, because when a deferred function recovers the panic we
unwind the stack up to that point so that returning from the function
will work correctly.
Allocating on the stack fine if the panic is not recovered, and it
works fine if the panic is recovered by a function that
returns. However, it fails if the panic is recovered by a function
that itself panics, and if that second panic is then recovered by a
function higher up on the stack. When we unwind the stack to that
second panic, the g will wind up pointing at a panic farther down on
the stack. Even then everything will often work fine, except when the
deferred function catching the second panic makes a bunch of calls
that use stack space before returning. In that case the code can
overwrite the panic struct, which will then cause disaster when we
remove the struct from the linked list, as the link field will be
garbage. This case is rare enough that all the x86 tests were passing,
but there was a failure on ppc64le.
Before https://golang.org/cl/33414 we allocated the panic struct on
the heap, so go back to doing that again.
Fixesgolang/go#18228.
Reviewed-on: https://go-review.googlesource.com/34027
From-SVN: r243444
The library initialization code in go-libmain.c sets the C variable
runtime_isarchive but failed to set the Go variable runtime.isarchive.
We don't currently have a way to let C code access an unexported Go
variable, but fortunately the only time the Go function initsig is
called with an argument of true is exactly where we want to set
isarchive. So let initsig do it.
Reviewed-on: https://go-review.googlesource.com/33753
From-SVN: r243094
Since gccgo can trace back through C code as easily as Go code, we
should print C functions in the traceback.
This worked before https://golang.org/cl/31230 for a dumb reason. The
default value for runtime.traceback_cache was, and is, 2 << 2, meaning
to print all functions. The old C code for runtime_parsedebugvars
would return immediately and do nothing if the environment variable
GODEBUG was not set (if GODEBUG was set it would later call
setTraceback. The new Go code for runtime.parsedebugvars does not
return immediately if GODEBUG is not set, and always calls
setTraceback. Either way, if GOTRACEBACK is not set, setTraceback
would set traceback_cache to 1 << 2, meaning to only print non-runtime
functions and having the effect of not printing plain C functions.
Keep the current handling of GODEBUG/GOTRACEBACK, which matches the gc
library, but add an extra check to print C functions by default.
Reviewed-on: https://go-review.googlesource.com/33717
From-SVN: r243083
With -buildmode=c-archive, initsig is called before the memory
allocator has been initialized. The code was doing a memory
allocation because of the call to funcPC(sigtramp). When escape
analysis is fully implemented, that call should not allocate. For
now, finesse the issue by calling a C function to get the C function
pointer value of sigtramp.
When returning from a call from C to a Go function, a deferred
function is run to go back to syscall mode. When the call occurs on a
non-Go thread, that call sets g to nil, making it impossible to add
the _defer struct back to the pool. Just drop it and let the garbage
collector clean it up.
Reviewed-on: https://go-review.googlesource.com/33675
From-SVN: r242992
The actual stack unwind code is still in C, but the rest of the code,
notably all the memory allocation, is now in Go. The names are changed
to the names used in the Go 1.7 runtime, but the code is necessarily
somewhat different.
The __go_makefunc_can_recover function is dropped, as the uses of it
were removed in https://golang.org/cl/198770044.
Reviewed-on: https://go-review.googlesource.com/33414
From-SVN: r242715
This doesn't change any actual code, it just starts using the Go
definition of the schedt type and the sched variable rather than the C
definitions.
The schedt type is tweaked slightly for gccgo. We aren't going to
release goroutine stacks, so we don't need separate gfreeStack and
gfreeNostack lists. We only have one size of defer function, so we
don't need a list of 5 different pools.
Reviewed-on: https://go-review.googlesource.com/33364
From-SVN: r242600
Correct gcc/go/gofrontend/lex.cc and libgo/aclocal.m4 to the versions
in the gofrontend repo, which is supposed to be the master copy.
Remove a few files in libgo that somehow were not deleted in the past.
From-SVN: r242583
Update a few binary files that were changed in the master gc repo,
copied into the gofrontend repo, but not correctly copied into the GCC
repo. The changes are all minor and do not affect any actual tests.
Two instances of "http" changed to "https", and two timestamps were
zeroed out.
From-SVN: r242582
As we move toward the Go 1.7 garbage collector, it's essential that all
allocation of values that can contain Go pointers be done using the
correct type descriptor. That is simplest if we do all such allocation
in Go code. This rewrites the code that converts from a Go type to a
libffi CIF into Go.
Reviewed-on: https://go-review.googlesource.com/33353
From-SVN: r242578
A step toward eliminating goc2c.
Drop the exported parfor code; it was needed for tests in the past, but
no longer is. The Go 1.7 runtime no longer uses parfor.
Reviewed-on: https://go-review.googlesource.com/33324
From-SVN: r242509
Apparently on Solaris 10 a SA_SIGINFO signal handler can be invoked with
a nil info argument. I would not have believed it but I've now seen it
happen, and the sigaction man page actually says "If the second argument
is not equal to NULL, it points to a siginfo_t structure...." So, if
that happens, don't crash.
Also fix another case where we want to make sure that &T{} does not
allocate.
Reviewed-on: https://go-review.googlesource.com/33150
From-SVN: r242403
Add a little shell script to auto-generate runtime.sigtable from the
known signal names.
Force the main package to always import the runtime package. Otherwise
some runtime package global variables may never be initialized.
Set the syscallsp and syscallpc fields of g when entering a syscall, so
that the runtime package knows when a g is executing a syscall.
Fix runtime.funcPC to avoid dead store elimination of the interface
value when the function is inlined.
Reviewed-on: https://go-review.googlesource.com/33025
From-SVN: r242060
When using cgo -gccgo calls to C.GoString, C.GoStringN, and C.GoBytes
are turned into calls to __go_byte_array_to_string and
__go_string_to_byte_array. Those functions were removed when the string
code was copied from Go 1.7, but we still need them for cgo. While cgo
should be updated, old versions will exist for some time.
Reviewed-on: https://go-review.googlesource.com/32474
From-SVN: r241743
Change the compiler handle append as the gc compiler does: call a
function to grow the slice, but otherwise assign the new elements
directly to the final slice.
For the current gccgo memory allocator the slice code has to call
runtime_newarray, not mallocgc directly, so that the allocator sets the
TypeInfo_Array bit in the type pointer.
Rename the static function cnew to runtime_docnew, so that the stack
trace ignores it when ignoring runtime functions. This was needed to
fix the runtime/pprof tests on 386.
Reviewed-on: https://go-review.googlesource.com/32218
From-SVN: r241667
PR go/78144
libgo: incorporate fix for timezone test
This brings over the test-only fix for issue 17276 into gccgo/libgo
(with tzdata-2016g there is a new zone abbreviation). This is a
copy of https://golang.org/cl/29995.
Reviewed-on: https://go-review.googlesource.com/32182
From-SVN: r241661
PR go/78143
runtime: build lfstack_32bit.go on ppc
Missed a build tag. This is GCC PR 78143.
Reviewed-on: https://go-review.googlesource.com/32295
From-SVN: r241659
Note that lfstack_64bit.go was modified for Solaris support in a
different, and better, way than the superseded lfstack.goc code.
Reviewed-on: https://go-review.googlesource.com/31673
From-SVN: r241427
I started to copy the Go 1.7 interface code, but the gc and gccgo
representations of interfaces are too different. So instead I rewrote
the gccgo interface code from C to Go. The code is largely the same as
it was, but the names are more like those used in the gc runtime.
I also copied over the string comparison functions, and tweaked the
compiler to use eqstring when comparing strings for equality.
Reviewed-on: https://go-review.googlesource.com/31591
From-SVN: r241384
The C definition is 1U << 31. Reportedly on some systems GCC's
-fgo-dump-spec can print this as -2147483648.
Reviewed-on: https://go-review.googlesource.com/31448
From-SVN: r241347
While we're at it, update the runtime/debug package, and start running
its testsuite by default. I'm not sure why runtime/debug was not
previously updated to 1.7. Doing that led me to fix some minor aspects
of runtime.Stack and the C function runtime/debug.readGCStats.
Reviewed-on: https://go-review.googlesource.com/31251
From-SVN: r241261
Fix handling of function values for -fgo-c-header to generate FuncVal*,
not simply FuncVal.
While we're here change runtime.nanotime to use clock_gettime with
CLOCK_MONOTONIC, rather than gettimeofday. This is what the gc library
does. It provides nanosecond precision and a monotonic clock.
Reviewed-on: https://go-review.googlesource.com/31232
From-SVN: r241197
Also create a gccgo version of some of the traceback code in
traceback_gccgo.go, replacing some code currently in C.
This required modifying the compiler so that when compiling the runtime
package a slice expression does not cause a local array variable to
escape to the heap.
Reviewed-on: https://go-review.googlesource.com/31230
From-SVN: r241189
In order to port stack backtraces to Go, we need the ability to look up
file/line information for PC values without allocating memory. This
patch moves the handling of Func from C code to Go code, and simplifies
the C code to just look up function/file/line/entry information for a PC.
Reviewed-on: https://go-review.googlesource.com/31150
From-SVN: r241172
This replaces runtime/cpuprof.goc with go/runtime/cpuprof.go and adjusts
the supporting code in runtime/proc.c.
This adds another case where the compiler needs to avoid heap allocation
in the runtime package: when evaluating a method expression into a
closure. Implementing this required moving the relevant code from
do_get_backend to do_flatten, so that I could easily add a temporary
variable. Doing that let me get rid of Bound_method_expression::do_lower.
Reviewed-on: https://go-review.googlesource.com/31050
From-SVN: r241163
This replaces mem.go and the C runtime_ReadMemStats function with the Go
1.7 mstats.go.
The GCStats code is commented out for now. The corresponding gccgo code
is in runtime/mgc0.c.
The variables memstats and worldsema are shared between the Go code and
the C code, but are not exported. To make this work, add temporary
accessor functions acquireWorldsema, releaseWorldsema, getMstats (the
latter known as mstats in the C code).
Check the preemptoff field of m when allocating and when considering
whether to start a GC. This works with the new stopTheWorld and
startTheWorld functions in Go, which are essentially the Go 1.7
versions.
Change the compiler to stack allocate closures when compiling the
runtime package. Within the runtime packages closures do not escape.
This is similar to what the gc compiler does, except that the gc
compiler, when compiling the runtime package, gives an error if escape
analysis shows that a closure does escape. I added this here because
the Go version of ReadMemStats calls systemstack with a closure, and
having that allocate memory was causing some tests that measure memory
allocations to fail.
Reviewed-on: https://go-review.googlesource.com/30972
From-SVN: r241124
Add compiler support for turning concatenating strings into a call to
a runtime function that takes the appropriate number of arguments.
Rename some local variables in mgc0.c to avoid macros that the new
rune.go causes to appear in runtime.inc.
Reviewed-on: https://go-review.googlesource.com/30827
From-SVN: r241074
This triggered a check in releaseSudog that g.param not nil, because
libgo uses the param field when starting a goroutine. Fixed by clearing
g->param in kickoff in proc.c.
Reviewed-on: https://go-review.googlesource.com/30951
From-SVN: r241067
Since sparc is a valid architecture, the name of
getrandom_linux_sparc.go means that it will be ignored on sparc64,
even though it's whitelisted with a +build line.
On SPARC, clone has a unique return value convention which requires
some inline assembly to convert it to the normal convention.
Reviewed-on: https://go-review.googlesource.com/30873
From-SVN: r241051
Update the compiler to use the new names. Add calls to printlock and
printunlock around print statements. Move expression evaluation before
the call to printlock. Update g's writebuf field to a slice, and adjust
C code accordingly.
Reviewed-on: https://go-review.googlesource.com/30717
From-SVN: r240958
Update the compiler to use the new names. Add calls to printlock and
printunlock around print statements. Move expression evaluation before
the call to printlock. Update g's writebuf field to a slice, and adjust
C code accordingly.
Reviewed-on: https://go-review.googlesource.com/30717
From-SVN: r240956
Change the compiler to use the new routines. Drop the separation of
small and large values when sending on a channel. Allocate the select
struct on the stack. Remove the old C implementation of channels. Adjust
the garbage collector for the new data structure.
Bring in part of the tracing code, enough for the channel code to call.
Bump the permitted number of allocations in one of the tests in
context_test.go. The difference is that now receiving from a channel
allocates a sudog, which the C code used to simply put on the
stack. This will be somewhat better when we port proc.go.
Reviewed-on: https://go-review.googlesource.com/30714
From-SVN: r240941
Remove the old locking code written in C.
Add a shell script mkrsysinfo.sh to generate the runtime_sysinfo.go
file, so that we can get Go copies of the system time structures and
other types.
Tweak the compiler so that when compiling the runtime package the
address operator does not cause local variables to escape. When the gc
compiler compiles the runtime, an escaping local variable is treated as
an error. We should implement that, instead of this change, when escape
analysis is turned on.
Tweak the compiler so that the generated C header does not include names
that start with an underscore followed by a non-upper-case letter,
except for the special cases of _defer and _panic. Otherwise we
translate C types to Go in runtime_sysinfo.go and then generate those Go
types back as C types in runtime.inc, which is useless and painful for
the C code.
Change entersyscall and friends to take a dummy argument, as the gc
versions do, to simplify calls from the shared code.
Reviewed-on: https://go-review.googlesource.com/30079
From-SVN: r240657
Also copy over cputicks.go, env_posix.go, vdso_none.go, stubs2.go, and a
part of os_linux.go. Remove the corresponding functions from the C code
in libgo/go/runtime. Add some transitional support functions to
stubs.go. This converts several minor functions from C to Go.
Reviewed-on: https://go-review.googlesource.com/29962
From-SVN: r240609
This change removes the gccgo-specific hashmap code and replaces it with
the hashmap code from the Go 1.7 runtime. The Go 1.7 hashmap code is
more efficient, does a better job on details like when to update a key,
and provides some support against denial-of-service attacks.
The compiler is changed to call the new hashmap functions instead of the
old ones.
The compiler now tracks which types are reflexive and which require
updating when used as a map key, and records the information in map type
descriptors.
Map_index_expression is simplified. The special case for a map index on
the right hand side of a tuple expression has been unnecessary for some
time, and is removed. The support for specially marking a map index as
an lvalue is removed, in favor of lowering an assignment to a map index
into a function call. The long-obsolete support for a map index of a
pointer to a map is removed.
The __go_new_map_big function (known to the compiler as
Runtime::MAKEMAPBIG) is no longer needed, as the new runtime.makemap
function takes an int64 hint argument.
The old map descriptor type and supporting expression is removed.
The compiler was still supporting the long-obsolete syntax `m[k] = 0,
false` to delete a value from a map. That is now removed, requiring a
change to one of the gccgo-specific tests.
The builtin len function applied to a map or channel p is now compiled
as `p == nil ? 0 : *(*int)(p)`. The __go_chan_len function (known to
the compiler as Runtime::CHAN_LEN) is removed.
Support for a shared zero value for maps to large value types is
introduced, along the lines of the gc compiler. The zero value is
handled as a common variable.
The hash function is changed to take a seed argument, changing the
runtime hash functions and the compiler-generated hash functions.
Unlike the gc compiler, both the hash and equal functions continue to
take the type length.
Types that can not be compared now store nil for the hash and equal
functions, rather than pointing to functions that throw. Interface hash
and comparison functions now check explicitly for nil. This matches the
gc compiler and permits a simple implementation for ismapkey.
The compiler is changed to permit marking struct and array types as
incomparable, meaning that they have no hash or equal function. We use
this for thunk types, removing the existing special code to avoid
generating hash/equal functions for them.
The C runtime code adds memclr, memequal, and memmove functions.
The hashmap code uses go:linkname comments to make the functions
visible, as otherwise the compiler would discard them.
The hashmap code comments out the unused reference to the address of the
first parameter in the race code, as otherwise the compiler thinks that
the parameter escapes and copies it onto the heap. This is probably not
needed when we enable escape analysis.
Several runtime map tests that ere previously skipped for gccgo are now
run.
The Go runtime picks up type kind information and stubs. The type kind
information causes the generated runtime header file to define some
constants, including `empty`, and the C code is adjusted accordingly.
A Go-callable version of runtime.throw, that takes a Go string, is
added to be called from the hashmap code.
Reviewed-on: https://go-review.googlesource.com/29447
* go.go-torture/execute/map-1.go: Replace old map deletion syntax
with call to builtin delete function.
From-SVN: r240334
Copy over the Go 1.7 runtime/internal/sys package, but instead of having
separate files for each GOARCH and GOOS value, set the values in
configure.ac and write them out in Makefile.am. Setting the values in
configure.ac should make it easier to add new processors.
Remove the automake GOARCH conditionals, which are no longer used.
Leave the GOOS conditionals for now, as they are used for the C runtime
package.
Reviewed-on: https://go-review.googlesource.com/29018
From-SVN: r240083
Copy over the Go 1.7 runtime/internal/atomic package, but implement the
functions in C using __atomic functions rather than using the
processor-specific assembler code.
Reviewed-on: https://go-review.googlesource.com/29010
From-SVN: r240070
Some systems, such as ia64 and PPC, require that a ucontext_t pointer
passed to getcontext and friends be aligned to a 16-byte boundary.
Currently the ucontext_t fields in the g structure are defined in Go,
and Go has no way to ensure a 16-byte alignment for a struct field.
The fields are currently represented by an array of unsafe.Pointer.
Enforce the alignment by making the array larger, and picking an offset
into the array that is 16-byte aligned.
Reviewed-on: https://go-review.googlesource.com/28910
From-SVN: r240044
Use the new -fgo-c-header option to build a header file for the Go
runtime code in libgo/go/runtime, and use the new header file in the C
runtime code in libgo/runtime. This will ensure that the Go code and C
code share the same data structures as we convert the runtime from C to
Go.
The new file libgo/go/runtime/runtime2.go is copied from the Go 1.7
release, and then edited to remove unnecessary data structures and
modify others for use with libgo.
The new file libgo/go/runtime/mcache.go is an initial version of the
same files in the Go 1.7 release, and will be replaced by the Go 1.7
file when we convert to the new memory allocator.
The new file libgo/go/runtime/type.go describes the gccgo version of the
reflection data structures, and replaces the Go 1.7 runtime file which
describes the gc version of those structures.
Using the new header file means changing a number of struct fields to
use Go naming conventions (that is, no underscores) and to rename
constants to have a leading underscore so that they are not exported
from the Go package. These names were updated in the C code.
The C code was also changed to drop the thread-local variable m, as was
done some time ago in the gc sources. Now the m field is always
accessed using g->m, where g is the single remaining thread-local
variable. This in turn required some adjustments to set g->m correctly
in all cases.
Also pass the new -fgo-compiling-runtime option when compiling the
runtime package, although that option doesn't do anything yet.
Reviewed-on: https://go-review.googlesource.com/28051
From-SVN: r239872
The go/build package does not know that gccgo's standard packages don't
have source, and will report an error saying that it can not find them.
Work around that in the cmd/go sources, since the go/build sources don't
currently have a list of standard packages.
This should get a real fix in the master sources, somehow.
Fixesgolang/go#16701.
Reviewed-on: https://go-review.googlesource.com/27052
From-SVN: r239486
These files are used to select s390x assembler support in the gc
toolchain. We don't currently have that support, as it is written in
the cmd/asm syntax rather than gas syntax. Mark the files to be ignored
for now, falling back to the default implementations.
Patch by Andreas Krebbel.
Reviewed-on: https://go-review.googlesource.com/26994
From-SVN: r239442
We want to build dir_regfile.go if not GNU/linux, and not solaris/386,
and not solaris/sparc. The latter two conditions were incorrect. To
write ! solaris/386 we have to write !solaris !386. I forgot De
Morgan's Law.
Reviewed-on: https://go-review.googlesource.com/26870
From-SVN: r239393
We already lowered the limit of recursive template invocations from
100,000 to 10,000, but the tests still fail occasionally on
x86_64-pc-linux-gnu when using GNU ld (so that split stacks are not
fully functional). Reduce the limit further, to 1000, enough so that
the test passes consistently.
Permitting 1000 recursive template invocations still seems capacious
enough for real world use.
Reviewed-on: https://go-review.googlesource.com/25590
From-SVN: r239261
Also change the configure script to set GOARCH correctly for ia64, and
add ia64 as a processor to match.sh and gotest.
Reviewed-on: https://go-review.googlesource.com/25549
From-SVN: r239225
Previously the libgo Makefile explicitly listed the set of files to
compile for each package. For packages that use build tags, this
required a lot of awkward automake conditionals in the Makefile.
This CL changes the build to look at the build tags in the files.
The new shell script libgo/match.sh does the matching. This required
adjusting a lot of build tags, and removing some files that are never
used. I verified that the exact same sets of files are compiled on
amd64 GNU/Linux. I also tested the build on i386 Solaris.
Writing match.sh revealed some bugs in the build tag handling that
already exists, in a slightly different form, in the gotest shell
script. This CL fixes those problems as well.
The old code used automake conditionals to handle systems that were
missing strerror_r and wait4. Rather than deal with those in Go, those
functions are now implemented in runtime/go-nosys.c when necessary, so
the Go code can simply assume that they exist.
The os testsuite looked for dir_unix.go, which was never built for gccgo
and has now been removed. I changed the testsuite to look for dir.go
instead.
Reviewed-on: https://go-review.googlesource.com/25546
From-SVN: r239189
When using gccgo on systems without full support for split stacks a
recursive template can overrun the available stack space. Reduce the
limit from 100000 to 10000 to make this less likely. It's still high
enough that real uses will work.
Reviewed-on: https://go-review.googlesource.com/25467
From-SVN: r239141
Leaving them incorrectly marked as addressable broke a use of the
text/template package, because state.evalField checks CanAddr and takes
the address if it is addressable.
Reviewed-on: https://go-review.googlesource.com/21908
From-SVN: r234923
PR go/69966
syscall: Add new Getsockopt functions.
Add GetsockoptICMPv6Filter, GetsockoptIPv6MTUInfo, GetsockoptUcred as
appropriate. These functions exist in the master library.
For GCC PR 69966.
Reviewed-on: https://go-review.googlesource.com/19960
From-SVN: r233747
PR go/66904
cmd/go: fix "#cgo pkg-config:" comments with gccgo
Copy of https://golang.org/cl/18790 by Michael Hudson-Doyle.
The unique difficulty of #cgo pkg-config is that the linker flags are recorded
when the package is compiled but (obviously) must be used when the package is
linked into an executable -- so the flags need to be stored on disk somewhere.
As it happens cgo already writes out a _cgo_flags file: nothing uses it
currently, but this change adds it to the lib$pkg.a file when compiling a
package, reads it out when linking (and passes a version of the .a file with
_cgo_flags stripped out of it to the linker). It's all fairly ugly but it works
and I can't really think of any way of reducing the essential level of
ugliness.
Update golang/go#11739.
GCC PR 66904.
Reviewed-on: https://go-review.googlesource.com/19431
From-SVN: r233290
PR go/65785
net: don't run multicast listen test on nil interface in short mode
This is a backport of https://golang.org/cl/17154.
The gccgo bug report https://gcc.gnu.org/PR65785 points out that the
multicast listen tests will use the network even with -test.short.
Fix test by checking testing.Short with a nil interface.
Reviewed-on: https://go-review.googlesource.com/17158
From-SVN: r230695
When using the go command built from gccgo to build and
install a go tool, use the value from runtime GCCGOTOOLDIR as
the install directory.
This also fixes the output from 'go tool' when used with the
gccgo-built go command, to only include the go tools and not
other binaries found in the same directory.
Reviewed-on: https://go-review.googlesource.com/16516
From-SVN: r230677
PR go/68255
cmd/go: always use --whole-archive for gccgo packages
This is a backport of https://golang.org/cl/16775.
This is, in effect, what the gc toolchain does. It fixes cases where Go
code refers to a C global variable; without this, if the global variable
was the only thing visible in the C code, the generated cgo file might
not get pulled in from the archive, leaving the Go variable
uninitialized.
This was reported against gccgo as https://gcc.gnu.org/PR68255 .
Reviewed-on: https://go-review.googlesource.com/16778
From-SVN: r230120
PR go/66138
reflect, encoding/json, encoding/xml: fix unexported embedded structs
Bring in three changes from the master Go repository. These changes
will be in Go 1.6, but they are appropriate for gccgo now because they
resolve a long-standing discrepancy between how gc and gccgo handle the
PkgPath field for embedded unexported struct fields. The core issue is
described at https://golang.org/cl/7247. This has been reported against
gccgo as https://gcc.gnu.org/PR66138.
The three changes being brought over are:
https://golang.org/cl/14010
reflect: adjust access to unexported embedded structs
This CL changes reflect to allow access to exported fields and
methods in unexported embedded structs for gccgo and after gc
has been adjusted to disallow access to embedded unexported structs.
Adresses #12367, #7363, #11007, and #7247.
https://golang.org/cl/14011
encoding/json: check for exported fields in embedded structs
Addresses issue #12367.
https://golang.org/cl/14012
encoding/xml: check for exported fields in embedded structs
Addresses issue #12367.
Reviewed-on: https://go-review.googlesource.com/16723
From-SVN: r229907
Only build net/hook_cloexec.go on GNU/Linux and FreeBSD, because those
are the only systems with accept4.
Add syscall/libcall_bsd.go to define sendfile for *BSD and Solaris.
Revert tcpsockopt_solaris.go back to the earlier version, so that it
works on Solaris 10.
Always pass the address of a Pid_t value to TIOCGPGRP and TIOCSPGRP.
Include <unistd.h> in runtime/go-varargs.c.
Reviewed-on: https://go-review.googlesource.com/16719
From-SVN: r229880
Type descriptors picked up a zero field because the gc map
implementation used it. However, it's since been dropped by the gc
library. It was never used by gccgo. Drop it now in preparation for
upgrading to the Go 1.5 library.
Reviewed-on: https://go-review.googlesource.com/16486
From-SVN: r229546
Change the type descriptor hash and equal functions from C code pointers
to Go func values. This permits them to be set to a Go function
closure. This is in preparation for the Go 1.5, so that we can use a
closure for the hash/equal functions returned by the new reflect.ArrayOf
function.
Reviewed-on: https://go-review.googlesource.com/16485
From-SVN: r229541
PR go/67874
net, runtime: Call C library fcntl function rather than syscall.Syscall.
Not all systems define a fcntl syscall; some only have fcntl64.
Fixes GCC PR go/67874.
Reviewed-on: https://go-review.googlesource.com/15497
From-SVN: r228576
This avoids linker warnings when linking against glibc, as apparently
arm64 GNU/Linux does not support the ustat system call.
Also update to automake 1.11.6, as that is the new GCC standard.
Reviewed-on: https://go-review.googlesource.com/14567
From-SVN: r227777
The struct RawSockaddr contains a field Data which
should be uint8 on ppc64 and ppc64le, but is declared
as int8 in gccgo. This change adds a two new files
which contain the structure declaration for
RawSockaddr, one with the correct types for for ppc64
and ppc64le, and the other for non-ppc64 platforms.
Fixesgolang/go#11469
Reviewed-on: https://go-review.googlesource.com/11946
From-SVN: r226533
The syscall for Getdents in syscall/libcall_linux.go
called Entersyscall and Exitsyscall, causing the
runtime_sched counts for goroutines to be incorrect.
Inconsistent counts caused checkdead in runtime/proc.c
to panic.
Fixesgolang/go#11406
Reviewed-on: https://go-review.googlesource.com/11761
From-SVN: r225745
PR go/64683
runtime/pprof: Assume function with no name is in runtime.
GCC PR 65797 causes some of the runtime functions to be
compiled with no name in the debug info. This in turn causes
the runtime/pprof test to fail as reported in GCC PR 64683.
There are no good choices when a function has no name in the
debug info, but here we assume that if we see such a function
while reading the runtime functions, we assume that it is also
a runtime function.
From-SVN: r222200
PR go/65755
compiler, runtime, reflect: Use reflection string for type comparisons.
Change the runtime and reflect libraries to always use only
the type reflection string to determine whether two types are
equal. It previously used the PkgPath and Name values for a
type name, but that required a PkgPath that did not match the
gc compiler.
Change the compiler to use the same PkgPath value as the gc
compiler in all cases.
Change the compiler to put the receiver type in the reflection
string for a type defined inside a method.
From-SVN: r222194
When linking complex packages that use both internal and external tests as well as many dependencies it is critical that the link order be external test package, internal test package, everything else.
This change is a back (forward?) port of the same change that canonical have been maintaining on their fork of the go tool for gccgo. Now that gccgo uses the go tool from upstream, this patch should be applied both to the gofrontend and golang/go repos.
From-SVN: r221800
PR go/65417
debug/elf: support reading debug info from 32-bit PPC objects
This is a backport of http://golang.org/7590 from the master
Go library.
From-SVN: r221644
PR go/65462
cmd: Fix dependencies for 'go get' with gccgo
Problem described in GCC BZ 65462.
Generate the list of the standard GO package names based on what was built into libgo in the libgo Makefile.
Change the var name from reqPkgSrc to reqStdPkgSrc to clarify it only affects standard GO packages.
Skip the attempted loading of a package only if it is a standard GO package and the flag is set indicating its source is not required to be available.
This requires a corresponding change to gotools to build and link in the new file containing the list of standard GO package names that was generated by the libgo Makefile.
gotools/:
PR go/65462
* Makefile.am (go_cmd_go_files): Add $(libgodir)/zstdpkglist.go.
* Makefile.in: Rebuild.
From-SVN: r221643
Add memprofilerate as a value recognized
in the GODEBUG env var. The value provided
is used as the new setting for
runtime.MemProfileRate, allowing the user
to adjust memory profiling.
From-SVN: r220470
PR go/64683
runtime/pprof: Let memory profiler test pass if value not collected.
Since gccgo's GC is not precise, the transient value may not
be collected. Let the regexp match that case as well.
From-SVN: r219900
Change from using __go_set_closure to passing the closure
value in the static chain field. Uses new backend support for
setting the closure chain in a call from C via
__builtin_call_with_static_chain. Uses new support in libffi
for Go closures.
The old architecture specific support for reflect.MakeFunc is
removed, replaced by the libffi support.
All work done by Richard Henderson.
* go-gcc.cc (Gcc_backend::call_expression): Add chain_expr argument.
(Gcc_backend::static_chain_variable): New method.
From-SVN: r219776
The version from the master repository seems to be appropriate
for OpenSolaris but not for Solaris itself. Solaris 11.2
proper does not define TCP_KEEPIDLE or TCP_KEEPINTVL.
From-SVN: r219749
This upgrades all of libgo other than the runtime package to
the Go 1.4 release. In Go 1.4 much of the runtime was
rewritten into Go. Merging that code will take more time and
will not change the API, so I'm putting it off for now.
There are a few runtime changes anyhow, to accomodate other
packages that rely on minor modifications to the runtime
support.
The compiler changes slightly to add a one-bit flag to each
type descriptor kind that is stored directly in an interface,
which for gccgo is currently only pointer types. Another
one-bit flag (gcprog) is reserved because it is used by the gc
compiler, but gccgo does not currently use it.
There is another error check in the compiler since I ran
across it during testing.
gotools/:
* Makefile.am (go_cmd_go_files): Sort entries. Add generate.go.
* Makefile.in: Rebuild.
From-SVN: r219627
Don't look it up on PATH. This lets a go tool built as part
of a GCC build use the gccgo from the same build.
Also pass -c when assembling a .s file with gccgo.
From-SVN: r219358
From Dominik Vogt.
* libgo/go/syscall/libcall_linux_s390.go: New file for s390 support.
* libgo/go/syscall/syscall_linux_s390.go: Ditto.
* libgo/go/syscall/libcall_linux_s390x.go: New file for s390x support.
* libgo/go/syscall/syscall_linux_s390x.go: Ditto.
* libgo/go/runtime/pprof/pprof.go (printStackRecord): Support s390 and
s390x.
* libgo/runtime/runtime.c (runtime_cputicks): Add support for s390 and
s390x
* libgo/mksysinfo.sh: Ditto.
(upcase_fields): New helper function
* libgo/go/debug/elf/file.go (applyRelocations): Implement relocations
on s390x.
(applyRelocationsS390x): Ditto.
(DWARF): Ditto.
* libgo/go/debug/elf/elf.go (R_390): New constants for S390 relocations.
(r390Strings): Ditto.
(String): Helper function for S390 relocations.
(GoString): Ditto.
* libgo/go/reflect/makefuncgo_s390.go: New file.
(S390MakeFuncStubGo): Implementation of s390 abi.
* libgo/go/reflect/makefuncgo_s390x.go: New file.
(S390xMakeFuncStubGo): Implementation of s390x abi.
* libgo/go/reflect/makefunc_s390.c: New file.
(makeFuncStub): s390 and s390x specific implementation of function.
* libgo/go/reflect/makefunc.go
(MakeFunc): Add support for s390 and s390x.
(makeMethodValue): Ditto.
(makeValueMethod): Ditto.
* libgo/Makefile.am (go_reflect_makefunc_s_file): Ditto.
(go_reflect_makefunc_file): Ditto.
* libgo/go/reflect/makefunc_dummy.c: Ditto.
* libgo/runtime/runtime.h (__go_makefunc_can_recover): Export prototype
for use in makefunc_s390.c.
(__go_makefunc_returning): Ditto.
* libgo/go/syscall/exec_linux.go (forkAndExecInChild): Fix order of the
arguments of the clone system call for s390[x].
* libgo/configure.ac (is_s390): New variable.
(is_s390x): Ditto
(LIBGO_IS_S390): Ditto.
(LIBGO_IS_S390X): Ditto.
(GOARCH): Support s390 and s390x.
* libgo/go/go/build/build.go (cgoEnabled): Ditto.
* libgo/go/go/build/syslist.go (goarchList): Ditto.
From-SVN: r217106
Backport https://codereview.appspot.com/155450044 from the
master Go library. Original description:
I came across this while debugging a GC problem in gccgo.
There is code in assignTo and cvtT2I that handles assignment
to all interface values. It allocates an empty interface even
if the real type is a non-empty interface. The fields are
then set for a non-empty interface, but the memory is recorded
as holding an empty interface. This means that the GC has
incorrect information.
This is extremely unlikely to fail, because the code in the GC
that handles empty interfaces looks like this:
obj = nil;
typ = eface->type;
if(typ != nil) {
if(!(typ->kind&KindDirectIface) || !(typ->kind&KindNoPointers))
obj = eface->data;
In the current runtime the condition is always true--if
KindDirectIface is set, then KindNoPointers is clear--and we
always want to set obj = eface->data. So the question is what
happens when we incorrectly store a non-empty interface value
in memory marked as an empty interface. In that case
eface->type will not be a *rtype as we expect, but will
instead be a pointer to an Itab. We are going to use this
pointer to look at a *rtype kind field. The *rtype struct
starts out like this:
type rtype struct {
size uintptr
hash uint32 // hash of type; avoids computation in hash tables
_ uint8 // unused/padding
align uint8 // alignment of variable with this type
fieldAlign uint8 // alignment of struct field with this type
kind uint8 // enumeration for C
An Itab always has at least two pointers, so on a
little-endian 64-bit system the kind field will be the high
byte of the second pointer. This will normally be zero, so
the test of typ->kind will succeed, which is what we want.
On a 32-bit system it might be possible to construct a failing
case by somehow getting the Itab for an interface with one
method to be immediately followed by a word that is all ones.
The effect would be that the test would sometimes fail and the
GC would not mark obj, leading to an invalid dangling
pointer. I have not tried to construct this test.
I noticed this in gccgo, where this error is much more likely
to cause trouble for a rather random reason: gccgo uses a
different layout of rtype, and in gccgo the kind field happens
to be the low byte of a pointer, not the high byte.
From-SVN: r216489
PR go/60406
runtime: Check callers in can_recover if return address doesn't match.
Also use __builtin_extract_return_address and tighten up the
checks in FFI code.
Fixes PR 60406.
From-SVN: r216003
PR go/61877
refect: fix direct call of variadic method value
As reported in bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61877
gcc mainline has regressed in this. This CL adds the tests proposed
for the main Go repository:
https://codereview.appspot.com/151280043/https://codereview.appspot.com/152060043/
restores the code from the amd64/386 path that makes this work and
was lost when the Go 1.3 stdlib was merged and changes the FFI path
to call into the same helper code as the amd64/386 path.
I've only tested this on amd64 but I did test a version that was
patched to unconditionally take the FFI path.
From-SVN: r215859
This variable is unused apparently as a result of local changes.
gccgo accepts this variable declaration, but other frontends may not.
From-SVN: r212873
This revision was committed January 7, 2014. The next
revision deleted runtime/mfinal.c. That will be done in a
subsequent merge.
This merge changes type descriptors to add a zero field,
pointing to a zero value for that type. This is implemented
as a common variable.
* go-gcc.cc (Gcc_backend::implicit_variable): Add is_common and
alignment parameters. Permit init parameter to be NULL.
From-SVN: r211249
A gccgo language extension allows a function to be declared multiple
times. Avoid the use of this extension by dedeplicating declarations
in mksyscall.awk.
From-SVN: r209508
Avoid the use of a gccgo language extension which allows unsafe.Sizeof
to accept a type by passing an expression of the relevant type.
From-SVN: r209503
I am reliably informed that the architecture name and letter for the
plan9/inferno compilers for 64-bit ARM systems will be "arm64" and "7"
respectively, so let's get that bit in nice and early.
From Michael Hudson-Doyle.
https://codereview.appspot.com/34830045/
From-SVN: r206374
On Solaris, if you do a in-progress connect, and then the
server accepts and closes the socket, the client's later
attempt to complete the connect will fail with EINVAL. Handle
this case by assuming that the connect succeeded. This code
is weird enough that it is implemented as Solaris-only so that
it doesn't hide a real error on a different OS.
See http://golang.org/issue/6828.
From-SVN: r206232
PR go/59506
net: use DialTimeout in TestSelfConnect
Backported from master repository.
This avoids problems with systems that take a long time to
find out nothing is listening, while still testing for the
self-connect misfeature since a self-connect should be fast.
With this we may be able to remove the test for non-Linux
systems.
Tested (on GNU/Linux) by editing selfConnect in
tcpsock_posix.go to always return false and verifying that
TestSelfConnect then fails with and without this change.
Idea from Uros Bizjak.
From-SVN: r206224
When a 386 function returns a struct, it needs to return using
an rtd instruction that pops the hidden struct parameter off
the stack. That wasn't happening.
From-SVN: r205551
In particular this means that the names Getsockname returns are not
truncated to 26 characters.
Fixes issue 6829
https://codereview.appspot.com/31840043/
From-SVN: r205368
Fixes issue 6761
This simple change seems to work fine, slightly to my surprise.
This includes the tests I submitted to the main Go repository at
https://codereview.appspot.com/26570046
From-SVN: r205001
If cmd/go is rebuilt using -compiler gccgo the version of go/build that is linked into that cmd/go will not function properly as the list of file suffixes know as operating systems or architectures is incorrect.
From-SVN: r204794
The gccgo-specific iword function was checking v.kind, but for
a method value that is always Func. Fix to check v.typ.Kind()
instead.
From-SVN: r202670
This changes the compiler and runtime to not pass a closure
value as the last argument, but to instead pass it via
__go_set_closure and retrieve it via __go_get_closure. This
eliminates the need for function descriptor wrapper functions.
It will make it possible to retrieve the closure value in a
reflect.MakeFunc function.
From-SVN: r202233
This changes the representation of a Go value of function type
from being a pointer to function code (like a C function
pointer) to being a pointer to a struct. The first field of
the struct points to the function code. The remaining fields,
if any, are the addresses of variables referenced in enclosing
functions. For each call to a function, the address of the
function descriptor is passed as the last argument.
This lets us avoid generating trampolines, and removes the use
of writable/executable sections of the heap.
From-SVN: r200181