PR go/89199
sync/atomic: use strong form of atomic_compare_exchange_n
In the recent change to use atomic_compare_exchange_n I thought we
could use the weak form, which can spuriously fail. But that is not
how it is implemented in the gc library, and it is not what the rest
of the library expects.
Thanks to Lynn Boger for identifying the problem.
Fixes https://gcc.gnu.org/PR89199
Reviewed-on: https://go-review.googlesource.com/c/161359
From-SVN: r268591
GCC has supported the __atomic intrinsics since 4.7. They are better
than the __sync intrinsics in that they specify a memory model and,
more importantly for our purposes, they are reliably implemented
either in the compiler or in libatomic.
Fixes https://gcc.gnu.org/PR52084
Reviewed-on: https://go-review.googlesource.com/c/160820
From-SVN: r268458
If sigtramp and sigtrampgo are both on stack, n -= framesToDiscard
is executed twice, which should actually run only once.
Reviewed-on: https://go-review.googlesource.com/c/159238
From-SVN: r268366
If a panic happens in the runtime we turn that into a fatal error.
We use the caller's PC to determine if the panic call is inside
the runtime. getcallerpc returns the PC immediately after the
call instruction. If the call is the very last instruction of a
function, it may not find this PC belong to a runtime function,
giving false result. We need to back off the PC by 1 to the call
instruction.
The gc runtime doesn't do this because the gc compiler always
emit an instruction following a panic call, presumably an UNDEF
instruction which turns into an architecture-specific illegal
instruction. Our compiler doesn't do this.
Reviewed-on: https://go-review.googlesource.com/c/159437
From-SVN: r268358
Precise stack scan uses SIGURG to trigger a stack scan. We need
to have Go signal handler installed for SIGURG.
Reviewed-on: https://go-review.googlesource.com/c/159097
From-SVN: r268230
For the gofrontend copy, change calls to types.SizesFor to pass
"gccgo" rather than "gc". Leave the asmdecl pass unchanged since that
pass is gc-specific anyhow.
This has been fixed in a better way in the external repo by
https://golang.org/cl/158317 and friends, but that is not in 1.12, so
use this approach for now.
Reviewed-on: https://go-review.googlesource.com/c/158842
From-SVN: r268153
PR go/88927
runtime, internal/cpu: fix build for ARM GNU/Linux
Was failing with
../../../libgo/go/internal/cpu/cpu.go:138:2: error: reference to undefined name 'doinit'
138 | doinit()
| ^
Fix it by adding in Go 1.12 internal/cpu/cpu_arm.go, and the code in
runtime that initializes the values.
Fixes https://gcc.gnu.org/PR88927.
Reviewed-on: https://go-review.googlesource.com/c/158717
From-SVN: r268131
Restore some of the fixes that were applied to golang_org/x/net/lif
but were lost when 1.12 moved the directory to internal/x/net/lif.
Add support for reading /proc to fetch argc/argv/env for c-archive mode.
Reviewed-on: https://go-review.googlesource.com/c/158640
From-SVN: r268130
Reviewed-on: https://go-review.googlesource.com/c/158019
gotools/:
* Makefile.am (go_cmd_vet_files): Update for Go1.12beta2 release.
(GOTOOLS_TEST_TIMEOUT): Increase to 600.
(check-runtime): Export LD_LIBRARY_PATH before computing GOARCH
and GOOS.
(check-vet): Copy golang.org/x/tools into check-vet-dir.
* Makefile.in: Regenerate.
gcc/testsuite/:
* go.go-torture/execute/names-1.go: Stop using debug/xcoff, which
is no longer externally visible.
From-SVN: r268084
Currently, we dropg (which clears gp.m) after we CAS the g status
to _Grunnable or _Gwaiting. Immediately after CASing the g status,
another thread may CAS it to _Gscan status and scan its stack.
With precise stack scan, it accesses gp.m in order to switch to g
and back (in doscanstackswitch). This races with dropg. If
doscanstackswitch reads gp.m, then dropg runs, when we restore
the m at the end of the scan it will set to a stale value. Worse,
if dropg runs after doscanstackswitch sets the new m, gp will be
running with a nil m.
To fix this, we do dropg before CAS g status to _Grunnable or
_Gwaiting. We can do this safely if we are CASing from _Grunning,
as we own the g when it is in _Grunning. There is one case where
we CAS from _Gsyscall to _Grunnable. It is not safe to dropg when
it is in _Gsyscall, as precise stack scan needs to read gp.m in
order to signal the m. So we need to introduce a transient state,
_Gexitingsyscall, between _Gsyscall and _Grunnable, where the GC
should not scan its stack.
In is a little unfortunate that we have to add another g status.
We could reuse an existing one (e.g. _Gcopystack), but it is
clearer and safer to just use a new one, as Austin suggested.
Reviewed-on: https://go-review.googlesource.com/c/158157
From-SVN: r268001
Many C syscall functions take pointer arguments. The pointers
don't escape in the C functions. Mark the C functions noescape so
calling them doesn't need allocation.
Reviewed-on: https://go-review.googlesource.com/c/158158
From-SVN: r267989
CL 157557 changes the compiler to add one byte padding to
non-empty struct ending with a zero-sized field. Add the same
padding to the FFI type, so reflect.Call works.
This fixes test/fixedbugs/issue26335.go in the main repo.
Reviewed-on: https://go-review.googlesource.com/c/158018
From-SVN: r267956
This ports https://golang.org/cl/155918 from the master repo.
runtime: panic on uncomparable map key, even if map is empty
Reorg map flags a bit so we don't need any extra space for the extra flag.
This is a pre-req for updating libgo to the Go 1.12beta2 release.
Reviewed-on: https://go-review.googlesource.com/c/157858
From-SVN: r267950
This is following CL 156038. doscanstackswitch uses the same
mechanism of switching goroutines as getTraceback, and so has
the same problem as described in issue golang/go#29448. This CL
applies the same fix.
Reviewed-on: https://go-review.googlesource.com/c/156697
From-SVN: r267661
This is the gccgo version of https://golang.org/cl/141822:
Only return a pointer p to the new slices backing array from makeslice.
Makeslice callers then construct sliceheader{p, len, cap} explictly
instead of makeslice returning the slice.
This change caused the GCC backend to break the runtime/pprof test by
merging together the identical functions allocateReflectTransient and
allocateTransient2M. This caused the traceback to be other than
expected. Fix that by making the functions not identical.
This is a step toward updating libgo to the Go1.12beta1 release.
Reviewed-on: https://go-review.googlesource.com/c/155937
From-SVN: r267660
Currently, when collecting a traceback for another goroutine,
getTraceback calls gogo(gp) switching to gp, which will resume in
mcall, which will call gtraceback, which will set up gp->m. There
is a gap between setting the current running g to gp and setting
gp->m. If a profiling signal arrives in between, sigtramp will
see a non-nil gp with a nil m, and will seg fault. Fix this by
setting up gp->m first.
Fixesgolang/go#29448.
Reviewed-on: https://go-review.googlesource.com/c/156038
From-SVN: r267658
Traceback routines, e.g. callers and funcentry, may call
__go_get_backtrace_state. If a profiling signal arrives while we
are in the critical section of __go_get_backtrace_state, it tries
to do a traceback, which also calls __go_get_backtrace_state,
which tries to enter the same critical section and will deadlock.
Prevent this deadlock by setting up runtime_in_callers before
calling __go_get_backtrace_state.
Found while investigating golang/go#29448. Will add a test in the
next CL.
Updates golang/go#29448.
Reviewed-on: https://go-review.googlesource.com/c/156037
From-SVN: r267590
Precise stack scan needs to unwind the stack. When it is
unwinding the stack, if a profiling signal arrives, which also
does a traceback, it may deadlock in dl_iterate_phdr. Prevent
this deadlock by setting up runtime_in_callers before traceback.
Reviewed-on: https://go-review.googlesource.com/c/155766
From-SVN: r267457
On ARM32 EABI, unlike other platforms, the personality function is
called during _Unwind_Backtrace (libgcc/unwind-arm-common.inc:581).
In this case, simply unwind the frame without returning any
handlers. Otherwise traceback will loop if there is a frame with
a defer on stack.
Reviewed-on: https://go-review.googlesource.com/c/155759
From-SVN: r267434
On ARM32 EABI, when the "compact" unwinding model is used, it
does not have standard LSDA and _Unwind_GetLanguageSpecificData
will not return data that is parseable by us. Check this
conditon before calling _Unwind_GetLanguageSpecificData.
Fix ARM32 build.
Reviewed-on: https://go-review.googlesource.com/c/155758
From-SVN: r267428
The type table encoding can be DW_EH_PE_absptr, but this case
was missing, which was causing abort on ARM32 EABI. Add the
missing case.
Reviewed-on: https://go-review.googlesource.com/c/153857
From-SVN: r267070
This increases the time to wait for signals to be delivered in the
TestAtomicStop testcase. When running gccgo tests on ppc64 or ppc64le,
there are intermittent failures in this test because the wait time is
too small.
Updates golang/go#29046
Reviewed-on: https://go-review.googlesource.com/c/153879
From-SVN: r267068
ARM32 EABI unwinder does not define _URC_NORMAL_STOP. Instead,
it has _URC_FAILURE. Use _URC_FAILURE there.
Should fix ARM32 build.
Reviewed-on: https://go-review.googlesource.com/c/153417
From-SVN: r267033
This CL adds support of precise stack scan using stack maps to
the runtime. The stack maps are generated by the compiler (if
supported). Each safepoint is associated with a (real or dummy)
landing pad, and its "type info" in the exception table is a
pointer to the stack map. When a stack is scanned, the stack map
is found by the stack unwinding code by inspecting the exception
table (LSDA).
For precise stack scan we need to unwind the stack. There are
three cases:
- If a goroutine is scanning its own stack, it can unwind the
stack and scan the frames.
- If a goroutine is scanning another, stopped, goroutine, it
cannot directly unwind the target stack. We handle this by
switching (runtime.gogo) to the target g, letting it unwind
and scan the stack, and switch back.
- If we are scanning a goroutine that is blocked in a syscall,
we send a signal to the target goroutine's thread, and let the
signal handler unwind and scan the stack. Extra care is needed
as this races with enter/exit syscall.
Currently this is only implemented on linux.
Reviewed-on: https://go-review.googlesource.com/c/140518
From-SVN: r266832
In buildmodeinit, the c-archive buildmode is flagged as invalid
on linux/ppc64 for gccgo when it should be valid. This happens
because the check against the gccgo flag is done after the checks
for valid GOOS/GOARCH pairs instead of before as is done for all
other buildmode cases in this switch. This corrects the problem and
allows several of the gccgo gotools testcases to pass on linux/ppc64.
Updates #29046
Reviewed-on: https://go-review.googlesource.com/c/152137
From-SVN: r266764
For inlined function bodies we're going to need to refer to variables,
so change the existing export data to add a '$' to names that look
like identifiers: true, false, nil, convert.
While we're here drop an unnecessary space character after operators.
Reviewed-on: https://go-review.googlesource.com/c/150067
From-SVN: r266529
Create a framework for putting function bodies in export data. At
present only empty functions will be put there, and they will be
ignored on import. Later patches will get this to the point of
supporting inlining of (some) functions defined in other packages.
Reviewed-on: https://go-review.googlesource.com/c/150061
From-SVN: r266490
PR go/88060
syscall: always define _AT_FDCWD and IPv6MTUInfo
They aren't defined by old versions of glibc, but are required by the
code in syscall_linux.go.
Reviewed-on: https://go-review.googlesource.com/c/150697
From-SVN: r266333
The code to implement new-style gccgo name mangling had a recipe that
didn't quite match the one in the compiler (incorrect handling for
'.'). This showed up as a failure in the gotools cgo test if the
directory containing the test run included a "." character.
Reviewed-on: https://go-review.googlesource.com/c/147917
From-SVN: r265981
PR bootstrap/82856
libgo: update to autoconf 2.69 and automake 1.15.1
Initial patch from Joseph Myers.
Reviewed-on: https://go-review.googlesource.com/c/146417
From-SVN: r265701
Fix asm name directive for the C version of log/syslog.syslog_c,
which didn't get included in the recent name mangling change.
Reviewed-on: https://go-review.googlesource.com/c/145017
From-SVN: r265533
The current implementation of Gogo::pkgpath_for_symbol was written in
a way that allowed two distinct package paths to map to the same
symbol, which could cause collisions at link- time or compile-time.
Switch to a better mangling scheme to insure that we get a unique
packagepath symbol for each package. In the new scheme instead of having
separate mangling schemes for identifiers and package paths, the
main identifier mangler ("go_encode_id") now handles mangling of
both packagepath characters and identifier characters.
The new mangling scheme is more intrusive: "foo/bar.Baz" is mangled as
"foo..z2fbar.Baz" instead of "foo_bar.Baz". To mitigate this, this
patch also adds a demangling capability so that function names
returned from runtime.CallersFrames are converted back to their
original unmangled form.
Changing the pkgpath_for_symbol scheme requires updating a number of
//go:linkname directives and C "__asm__" directives to match the new
scheme, as well as updating the 'gotest' driver (which makes
assumptions about the correct mapping from pkgpath symbol to package
name).
Fixesgolang/go#27534.
Reviewed-on: https://go-review.googlesource.com/c/135455
From-SVN: r265510
PR go/87661
runtime: remove unused armArch, hwcap and hardDiv
After CL 140057 these are only written but never read in gccgo.
Reviewed-on: https://go-review.googlesource.com/c/141077
From-SVN: r265439
Introduce a new "types" command to the export data to record the
number of types and the size of their export data. It is immediately
followed by new "type" commands that can be indexed. Parse all the
exported types immediately so that we register them, but parse other
type data only as needed.
Reviewed-on: https://go-review.googlesource.com/c/143022
From-SVN: r265409
Previously when export data referred to a type that was not defined in
a directly imported package, we would write the package name as
additional information in the type's export data. That approach
required all type information to be read in order. This patch changes
the compiler to find all references to indirectly imported packages,
and write them out as an indirectimport line in the import data. This
will permit us to read exported type data out of order.
The type traversal used to find indirect imports is a little more
complicated than necessary in preparation for later patches in this
series.
Reviewed-on: https://go-review.googlesource.com/c/143020
From-SVN: r265296
The export data, which is approximately readable and looks something
like Go, was first implemented back when Go still used semicolons.
Drop the semicolons, to make it look slightly more Go like and make it
slightly smaller.
This updates the compiler and the gccgoimporter package.
This introduces a new version of the export data. There are going to
be more changes to the export data, so this version is still subject
to change.
Reviewed-on: https://go-review.googlesource.com/c/143018
From-SVN: r265284
LLVM doesn't support non-call exception. This test was passing
more or less by luck: if the faulting instruction is between two
calls with the same landing pad (in instruction layout order,
not the program's logic order), it generates a merged PC range
that covers the faulting instruction. If the instruction layout
order changes, or it uses two different (but may be degenerate)
landing pads, this doesn't work.
Reviewed-on: https://go-review.googlesource.com/c/140517
From-SVN: r264985
Use inline assembly in the implementation of internal_cpu.xgetbv as
opposed to a call to the intrinsic _xgetbv(), since non-gcc compilers
(e.g. clang) may or may not have support for it.
Reviewed-on: https://go-review.googlesource.com/c/140137
From-SVN: r264882
This reportedly happens on CentOS 5.11. The real code will work fine;
this test is assuming that the unexported slice function will handle
the splice, but if pipe2 does not work then it doesn't. The relevant
code in internal/poll/splice_linux.go says "Falling back to pipe is
possible, but prior to 2.6.29 splice returns -EAGAIN instead of 0 when
the connection is closed."
Reviewed-on: https://go-review.googlesource.com/138838
From-SVN: r264793
This is enough to let libgo build when configured using
--with-multilib-list=m64,m32,mx32. I don't have an x32-enabled kernel
so I haven't tested whether it executes correctly.
For https://gcc.gnu.org/PR87470
Reviewed-on: https://go-review.googlesource.com/138817
From-SVN: r264772
Rewrite the arm64 AES hashing code from gc assembler to C code using
intrinsics. The resulting code generates the same hash code for the
same input as the gc code--that doesn't matter as such, but testing it
ensures that the C code does something useful.
Reviewed-on: https://go-review.googlesource.com/138535
From-SVN: r264771
On Alpha GNU/Linux there is no geteuid system call, there is only
getresuid. The raw geteuid system call is only used for testing, so
just skip the test if it's not available.
Reviewed-on: https://go-review.googlesource.com/137655
From-SVN: r264647
In internal/bytealg correct a +build tag to never build indexbyte_generic.go
for the gofrontend, where we always use indexbyte_native.go.
For internal/cpu let the Makefile define CacheLineSize using goarch.sh,
rather than trying to enumerate all the possibilities in cpu_ARCH.go files.
In internal/poll call the C fcntl function rather than using SYS_FCNTL.
Change mksysinfo.sh to ensure that F_GETPIPE_SZ is always defined,
and check that in internal/poll.
Reviewed-on: https://go-review.googlesource.com/137256
From-SVN: r264572
This permits TestScript to work when gccgo is not installed.
Previous testing was using a previously installed gccgo, not the newly
built one.
This revealed that the testing of whether an internal package is
permitted was incorrect for standard library packages, since the
uninstalled gccgo can see internal packages in the uninstalled libgo.
Fix the internal package tests.
This permitted removing a couple of gccgo-specific changes in the
testsuite.
Reviewed-on: https://go-review.googlesource.com/137255
From-SVN: r264570
Reviewed-on: https://go-review.googlesource.com/136435
gotools/:
* Makefile.am (mostlyclean-local): Run chmod on check-go-dir to
make sure it is writable.
(check-go-tools): Likewise.
(check-vet): Copy internal/objabi to check-vet-dir.
* Makefile.in: Rebuild.
From-SVN: r264546
In 1.11 writebarrierptr is going away, so change the compiler to call
gcWriteBarrier instead. We weren't using gcWriteBarrier before;
adjust the implementation to use the putFast method.
This revealed a problem in the kickoff function. When using cgo,
kickoff can be called on the g0 of an m allocated by newExtraM. In
that case the m will generally have a p, but systemstack may be called
by wbBufFlush as part of flushing the write barrier buffer. At that
point the buffer is full, so we can not do a write barrier. So adjust
the existing code in kickoff so that in the case where we are g0,
don't do any write barrier at all.
Reviewed-on: https://go-review.googlesource.com/131395
From-SVN: r264295
In the sweep code we can sometimes see incorrect counts when
conservative stack scanning causes us to grey an object that we
earlier decided could be freed. We already ignored this check, but
adjust this case to maintain correct span counts when it happens.
This gives us slightly more correct numbers in MemStats, and helps
avoid a rare failure in TestReadMemStats.
Also fix the free index, and cope with finding a full span when
allocating a new one.
Reviewed-on: https://go-review.googlesource.com/134216
From-SVN: r264294
Unlike the gc runtime, libgo stores traceback information in location
structs, which contain strings. Therefore, copying location structs
around appears to require write barriers, although in fact write
barriers are never important because the strings are never allocated
in Go memory. They come from libbacktrace.
Some of the generated write barriers come at times when write barriers
are not permitted. For example, exitsyscall, marked
nowritebarrierrec, calls exitsyscallfast which calls traceGoSysExit
which calls traceEvent which calls traceStackID which calls
trace.stackTab.put which copies location values into memory allocated
by tab.newStack. This write barrier can be invoked when there is no
p, causing a crash.
This change fixes the problem by ensuring that location values are
copied around in the tracing code with no write barriers.
This was found by fixing the compiler to fully implement
//go:nowritebarrierrec; CL to follow.
Reviewed-on: https://go-review.googlesource.com/134226
From-SVN: r264282
To reduce the amount of time spent in write barrier processing
(specifically runtime.bulkBarrierPreWrite), add support for building a
'GC roots index', basically a sorted list of all roots, so as to
allow more efficient lookups of gcdata structures for globals. The
previous implementation worked on the raw (unsorted) roots list
itself, which did not scale well.
Reviewed-on: https://go-review.googlesource.com/132595
From-SVN: r264276
This is the gofrontend version of https://golang.org/cl/91796.
This is part of that CL, just the compiler change and required runtime
changes, in preparation for updating libgo to 1.11.
Relevant part of original CL description:
The hmap field in the maptype is only used by the runtime to check the sizes of
the hmap structure created by the compiler and runtime agree.
Comments are already present about the hmap structure definitions in the
compiler and runtime needing to be in sync.
Reviewed-on: https://go-review.googlesource.com/130976
From-SVN: r263941
This is a port of https://golang.org/cl/109596 to the gofrontend, in
preparation for updating libgo to 1.11.
Original CL description:
getcallersp is intrinsified, and so the dummy arg is no longer
needed. Remove it, as well as a few dummy args that are solely
to feed getcallersp.
Reviewed-on: https://go-review.googlesource.com/131116
From-SVN: r263840
Fix up the testing package to insure that execution traces
work properly (e.g. "-test.trace=<XXX>" command line option). The
call to stop tracing and emit the output file was stubbed out.
Reviewed-on: https://go-review.googlesource.com/128275
From-SVN: r263363
When writing stack frames to the pprof CPU profile machinery, it is
very important to insure that the frames emitted do not contain any
frames corresponding to artifacts of the profiling process itself
(signal handlers, sigprof, etc). This patch changes runtime.sigprof to
strip out those frames from the raw stack generated by
"runtime.callers".
Fixesgolang/go#26595.
Reviewed-on: https://go-review.googlesource.com/126175
From-SVN: r263035
The libffi library doesn't understand zero-sized objects.
When we see a zero-sized field in a struct, just skip it when
converting to the FFI data structures. There is no value to pass in
any case, so not telling libffi about the field doesn't affect
anything.
The test case for this is https://golang.org/cl/123316.
Fixesgolang/go#26335
Reviewed-on: https://go-review.googlesource.com/123335
From-SVN: r262651
PR go/86331
os: check return value as well as error from waitid
https://gcc.gnu.org/PR86331 indicates that if a signal handler runs it
is possible for syscall.Syscall6 to return a non-zero errno value even
if no error occurs. That is a problem in general, but this fix will
let us work around the general problem for the specific case of
calling waitid.
Reviewed-on: https://go-review.googlesource.com/121595
From-SVN: r262313
USING_SPLIT_STACK is configured as defined/undefined, not 0/1.
Most of the places test USING_SPLIT_STACK with #ifdef, with a
few exceptions. This CL fixes the exceptions.
Reviewed-on: https://go-review.googlesource.com/120596
From-SVN: r261980
Adjust the hash and string fields computed by StructOf to match the
values that the compiler computes for a struct type with the same
field names and types. This makes the reflect code match the
compiler's Type::hash_for_method and Type::reflection methods.
Fixesgolang/go#25284
Reviewed-on: https://go-review.googlesource.com/116515
From-SVN: r261235
Background: since gccgo does not currently merge identical types at link time,
the reflect function canonicalize() exists to choose a canonical specimen
for each set of identical types.
In this way, user code has the guarantee that identical types
will always compare as ==
Change: arrange reflect functions MapOf(), SliceOf(), StructOf() etc.
to call canonicalize() on the types they create, before storing the types
in internal lookup caches and returning them.
This fixes known cases where canonicalize() is needed but was missing.
Supersedes https://golang.org/cl/112575 and mostly fixes issue 25284.
Updates golang/go#25284
Reviewed-on: https://go-review.googlesource.com/115577
From-SVN: r261216
Backport https://golang.org/cl/113715 and https://golang.org/cl/113716:
cmd/go: don't pass -compiler flag to vet
Without this running go vet -compiler=gccgo causes vet to fail.
The vet tool does need to know the compiler, but it is passed in
vetConfig.Compiler.
cmd/go, cmd/vet, go/internal/gccgoimport: make vet work with gccgo
When using gccgo/GoLLVM, there is no package file for a standard
library package. Since it is impossible for the go tool to rebuild the
package, and since the package file exists only in the form of a .gox
file, this seems like the best choice. Unfortunately it was confusing
vet, which wanted to see a real file. This caused vet to report errors
about missing package files for standard library packages. The
gccgoimporter knows how to correctly handle this case. Fix this by
1) telling vet which packages are standard;
2) letting vet skip those packages;
3) letting the gccgoimporter handle this case.
As a separate required fix, gccgo/GoLLVM has no runtime/cgo package,
so don't try to depend on it (as it happens, this fixesgolang/go#25324).
The result is that the cmd/go vet tests pass when using -compiler=gccgo.
Reviewed-on: https://go-review.googlesource.com/114516
From-SVN: r260913
Several recent changes to the gc version of cmd/go improve the
gofrontend support. These changes are partially copies of existing
gofrontend differences, and partially new code. This CL makes the
gofrontend match the upstream code.
The changes included here come from:
https://golang.org/cl/111575https://golang.org/cl/111595https://golang.org/cl/111635https://golang.org/cl/111636
For the record, the following recent gc changes are based on code
already present in the gofrontend repo:
https://golang.org/cl/110915https://golang.org/cl/111615
For the record, a gc change, partially based on earlier gofrontend
work, also with new gc code, was already copied to gofrontend repo in
CL 111099:
https://golang.org/cl/111097
This moves the generated list of standard library packages from
cmd/go/internal/load to go/build.
Reviewed-on: https://go-review.googlesource.com/112475
gotools/:
* Makefile.am (check-go-tool): Don't copy zstdpkglist.go.
* Makefile.in: Rebuild.
From-SVN: r260097
In https://golang.org/cl/111097 the gc version of cmd/go was updated
to include some gofrontend-specific changes. The gofrontend code
already has different versions of those changes; this CL makes the
gofrontend match the upstream code.
Reviewed-on: https://go-review.googlesource.com/111099
From-SVN: r259918
These tests used to be disabled in the gofrontend since the go tool
didn't support build IDs for the gofrontend. It does now, so enable
the tests again.
Reviewed-on: https://go-review.googlesource.com/111098
From-SVN: r259875
This patch adds explicit references to various types and constants
defined by the header files included by sysinfo.c (used to drive the
generation of gen-sysinfo.go as part of the libgo build via the GCC
"-fdump-go-spec" option).
The intent is to enable clients to gather the same info generated by
"-fdump-go-spec" by instead reading the generated DWARF from a
sysinfo.o object file compiled with "-g". Some compilers (notably
clang) try to omit DWARF records for a given type unless there is an
explicit use of it in the translation unit; the additional references
are to insure that everything we want to see in the DWARF shows up.
Reviewed-on: https://go-review.googlesource.com/99063
From-SVN: r259868
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
From-SVN: r259865
Move the list of libgo, gotool, and check-target packages into
separate files, then read the file contents as part of the build
process on the fly. This is intended to enable other build tooling to
share the canonical list of target packages (avoid duplication).
Reviewed-on: https://go-review.googlesource.com/89515
libgo: revise rules for runtime.inc generation
Refactor code for generating runtime.inc: extract out the relevant
commands and place them in a separate shell script ("mkruntimeinc.sh").
Update rules to avoid generating macros whose names begin with "$",
such as "#define $sinkconst0 0".
Reviewed-on: https://go-review.googlesource.com/85955
From-SVN: r259863
The C portion of the Go runtime includes the header "unwind-pe.h" from
libgcc, which contains some constants and a few small routines for
decoding pointer values within unwind info. This patch gets rid of
that include and instead adds a re-implementation of that
functionality in the single file that uses it. The intent is to allow
the C runtime portion of libgo to be built without a companion GCC
installation.
Reviewed-on: https://go-review.googlesource.com/90235
From-SVN: r259861
Bring in https://golang.org/cl/98616 from gc tip.
Original CL description:
This change modifies Go to disable loading of users' shell history for
TestTerminalSignal tests. TestTerminalSignal, as part of its workload,
will execute a new interactive bash shell. Bash will attempt to load the
user's history from the file pointed to by the HISTFILE environment
variable. For users with large histories that may take up to several
seconds, pushing the whole test past the 5 second timeout and causing
it to fail.
Reviewed-on: https://go-review.googlesource.com/107624
From-SVN: r259452
The gccgo runtime is never stale, and on a system with gc sources in
~/go the test may wind up checking whether the gc runtime is stale.
Reviewed-on: https://go-review.googlesource.com/102282
From-SVN: r258865
Also add noinst_DATA to CHECK_DEPS; it's not needed in practice since
`make` will build noinst_DATA, but it's logically required and will
make a difference if any of the noinst_DATA sources change between
`make` and `make check`.
Tony Reix figured out why omitting packages from noinst_DATA didn't
seem to matter: because if gccgo can't find foo.gox, it will fall back
to reading the export data in foo.o, and foo.o will exist because
these packages go into libgo.a.
Reviewed-on: https://go-review.googlesource.com/101077
From-SVN: r258606
Makefile: add internal/trace to noinst_DATA
The internal/trace package is only imported by tests (specifically the
tests in runtime/trace) so it must be in noinst_DATA to ensure that it
is built before running the tests.
This was mostly working because internal/trace has tests itself, and
is listed in check-packages.txt before runtime/trace, so typical
invocations of make would build internal/trace for checking purposes
before checking runtime/trace. But we need this change to make that
reliable.
Reviewed-on: https://go-review.googlesource.com/99836
From-SVN: r258392
This implements the same choices made in the gc runtime, except that
for 32-bit x86 we only use the fence instruction if the processor
supports SSE2.
The code here is hacked up for speed; the gc runtime uses straight
assembler.
Reviewed-on: https://go-review.googlesource.com/97715
From-SVN: r258336
PR go/84484
libgo: add support for riscv64
Patch by Andreas Schwab.
Reviewed-on: https://go-review.googlesource.com/96377
* go.test/go-test.exp (go-set-goarch): Recognize riscv64-*-*.
From-SVN: r257914
Let a fast syscall return be a preemption point. This helps with
tight loops that make system calls, as in BenchmarkSyscallExcessWork.
Reviewed-on: https://go-review.googlesource.com/94895
From-SVN: r257848
Long long long ago Go permitted writing
func F()
in one file and writing
func F() {}
in another file. This was removed from the language, and that is now
considered to be a multiple definition error. Gccgo never caught up
to that, and it has been permitting this invalid code for some time.
Stop permitting it, so that we give correct errors. Since we've
supported it for a long time, the compiler uses it in a couple of
cases: it predeclares the hash/equal methods if it decides to create
them while compiling another function, and it predeclares main.main as
a mechanism for getting the right warning if a program uses the wrong
signature for main. For simplicity, keep those existing uses.
This required a few minor changes in libgo which were relying,
unnecessarily, on the current behavior.
Reviewed-on: https://go-review.googlesource.com/93083
From-SVN: r257600
PR go/84215
runtime, sync/atomic: use write barrier for atomic pointer functions
This copies atomic_pointer.go from 1.10rc2. It was omitted during the
transition of the runtime from C to Go, and I forgot about it.
This may help with https://gcc.gnu.org/PR84215.
Reviewed-on: https://go-review.googlesource.com/93197
From-SVN: r257599
If we trace back through code that has no debug info, as when calling
through C code compiled with -g0, we won't have a function name.
Try to fetch the function name using the symbol table.
Adding the test case revealed that gotest failed to use the gccgo tag
when matching files, so add that.
Reviewed-on: https://go-review.googlesource.com/92756
From-SVN: r257495
The escape analysis support is not yet good enough to avoid escaping
the argument to funcPC. This causes unnecessary and often harmful
memory allocation. E.g., (*cpuProfile).addExtra can be called from a
signal handler, and it must not allocate memory.
Move the calls to funcPC to use variables instead. This was done in
the original migration to using funcPC, but was not done for newer code.
In one case, in signal handling code, use getSigtramp.
Reviewed-on: https://go-review.googlesource.com/92735
From-SVN: r257463
The quoting code that read _cgo_flags, currently only in the gccgo
version of cmd/go, was losing the last flag read from the file.
Fixesgolang/go#23666
Reviewed-on: https://go-review.googlesource.com/91655
From-SVN: r257373
They were disabled due to the lack of escape analysis. Now that
we have escape analysis, unskip these tests.
Reviewed-on: https://go-review.googlesource.com/86248
From-SVN: r257324
On ia64, a separate stack is used for saving/restoring register frames,
occupying the other end of the stack mapping. This must also be scanned
for pointers into the heap.
Reviewed-on: https://go-review.googlesource.com/85276
From-SVN: r257323
We were using special compilation flags for the math package, but we
weren't using them when testing. That meant that our tests were not
checking the real code we were providing. Fix that.
Fixing that revealed that we were not using a good set of flags, or at
least were not using flags that let the tests pass. Adjust the flags
to stop using -funsafe-math-optimizations on x86. Instead always use
-ffp-contract=off -fno-math-errno -fno-trapping-math for all targets.
Fixesgolang/go#23647
Reviewed-on: https://go-review.googlesource.com/91355
From-SVN: r257312
Otherwise on a 64-bit system we will read the 32-bit value as a 64-bit
value. Since getaddrinfo returns negative numbers as error values,
these will be interpreted as numbers like 0xfffffffe rather than -2,
and the comparisons with values like syscall.EAI_NONAME will fail.
Fixesgolang/go#23645
Reviewed-on: https://go-review.googlesource.com/91296
From-SVN: r257299
I forgot to update the name of the map[string]bool type descriptor
used in go-fieldtrack.c. This didn't cause any errors because it's a
weak symbol, and the current testsuite has no field tracking tests.
Reviewed-on: https://go-review.googlesource.com/91096
From-SVN: r257249
On AIX nm displays symbols with a leading dot; don't discard such
symbols.
While we're here stop doing fgrep -v '$', symbol names no longer
contain '$' anyhow.
Reviewed-on: https://go-review.googlesource.com/91095
From-SVN: r257247
On ppc64 gotest treats data variables whose names begin with "Test" as
tests to run. This is to support the function descriptors used for
ppc64 ELF ABI v1. This causes gotest to think that TestAddr6 is a
test, when it is actually a variable. For a simple fix until we can
figure out how to write gotest properly, rename the variable.
Fixesgolang/go#23623
Reviewed-on: https://go-review.googlesource.com/90995
From-SVN: r257235
CL 84555 added support for the SuperH architecture, but didn't add the
randomTrap definition to be used for the getrandom syscall on Linux.
Add it now.
Reviewed-on: https://go-review.googlesource.com/90535
From-SVN: r257171
This was the original intent, as reflected in the long comment at the
start of names.cc, but I forgot to implement it.
Also, remove a leading ".0" from the final name. That could occur for
a method whose receiver type starts with 'u', as in that case we
prepend a space to the mangled name, to avoid confusion with the
Unicode mangling, and the space turns into ".0".
Also, if the Unicode encoding would cause the final to start with
"..u" or "..U", add a leading underscore.
Patch gotest to not get fooled by some names.
The result of these changes is that all symbols start with a letter or
an underscore.
Reviewed-on: https://go-review.googlesource.com/90015
From-SVN: r257068
The top three region number bits must be masked out before
right-shifting the address bits into place, otherwise they will be
copied down into the lower always-zero address bits.
Reviewed-on: https://go-review.googlesource.com/84535
From-SVN: r257061
Encode all external symbol names using only ASCII alphanumeric
characters, underscore, and dot. Use a scheme that can be reliably
demangled to a somewhat readable version as described in the long
comment in names.cc.
A minor cleanup discovered during this was that we were treating
function types as different if one had a NULL parameters_ field and
another has a non-NULL parameters_ field that has no parameters. This
worked because we mangled them slightly differently. We now mangle
them the same, so we treat them as equal, as we should anyhow.
Reviewed-on: https://go-review.googlesource.com/89555
* go.go-torture/execute/names-1.go: New test.
From-SVN: r257033
This makes no difference on most systems, because <sys/resource.h>
renames the type appropriately anyhow, but apparently it makes a
difference on AIX.
Reviewed-on: https://go-review.googlesource.com/88076
From-SVN: r256877
Solaris 10 uses int32 for the Pw_uid and Pw_gid fields of Passwd,
but most systems, including Solaris 11, use uint32. Force uint32
for consistency and to fix the build.
Reviewed-on: https://go-review.googlesource.com/88195
From-SVN: r256875
PR go/83787
compiler: pass int to makechan, call makechan64 when appropriate
The update to 1.10beta1 changed makechan to take int instead of int64,
and added a makechan64 call for large values. Since the size is the
last argument to makechan, the old compiler which always passed a
64-bit int worked fine on 64-bit systems and little-endian 32-bit
systems, but broke on big-endian 32-bit systems. This CL fixes the
compiler to use the appropriate types.
This fixes GCC PR 83787.
Reviewed-on: https://go-review.googlesource.com/88077
From-SVN: r256835
Move the architecture-specific settings out of configure.ac into a new
shell script goarch.sh. Use the new script to collect the values for
all architectures to make them available in go/types.
Also fix cmd/vet to pass the right compiler when it calls SizesFor.
This fixes cmd/vet for systems that are not implemented in the gc
toolchain, such as alpha and ia64.
Reviewed-on: https://go-review.googlesource.com/87635
From-SVN: r256655
Add missing .a files. These should have been committed with the
update to go1.10beta1, but were skipped because by default Subversion
ignores all files matching *.a.
From-SVN: r256442
PR c/82922
runtime, syscall: use full prototypes in C code
Based on patch by Martin Sebor.
Reviewed-on: https://go-review.googlesource.com/86815
From-SVN: r256437
GCC always recognizes the -fsplit-stack option, but then tests whether
it is supported by the selected target. If not, it reports
cc1: error: ‘-fsplit-stack’ is not supported by this compiler configuration
Check for that error message when deciding whether a compiler option works.
Reviewed-on: https://go-review.googlesource.com/87137
From-SVN: r256433
The signature of makemap changed with the update to 1.10beta1,
but I forgot to update the call from C code.
Reviewed-on: https://go-review.googlesource.com/87135
From-SVN: r256431
When compiling runtime, it is not allowed for local variables
and closures to be heap allocated. In one test, there is a go
statement with a closure. In the gc compiler, it distinguishes
capturing variable by value vs. by address, and rewrites it to
passing the captured values as arguments. Currently we don't
have this, and the escape analysis decides to heap allocate the
closure and also the captured variables, which is not allowed.
Work around it by passing the variables explicitly.
This is in preparation of turning on escape analysis for the
runtime.
Reviewed-on: https://go-review.googlesource.com/86245
From-SVN: r256419
This is in preparation of turning on escape analysis for the
runtime.
- In gccgo, systemstack is implemented with mcall, which is not
go:noescape. Wrap the closure in noescape so the escape analysis
does not think it escapes.
- Mark some C functions go:noescape. They do not leak arguments.
- Use noescape function to make a few local variables' addresses
not escape. The escape analysis cannot figure out because they
are assigned to pointer indirections.
Reviewed-on: https://go-review.googlesource.com/86244
From-SVN: r256418
Update the Go library to the 1.10beta1 release.
Requires a few changes to the compiler for modifications to the map
runtime code, and to handle some nowritebarrier cases in the runtime.
Reviewed-on: https://go-review.googlesource.com/86455
gotools/:
* Makefile.am (go_cmd_vet_files): New variable.
(go_cmd_buildid_files, go_cmd_test2json_files): New variables.
(s-zdefaultcc): Change from constants to functions.
(noinst_PROGRAMS): Add vet, buildid, and test2json.
(cgo$(EXEEXT)): Link against $(LIBGOTOOL).
(vet$(EXEEXT)): New target.
(buildid$(EXEEXT)): New target.
(test2json$(EXEEXT)): New target.
(install-exec-local): Install all $(noinst_PROGRAMS).
(uninstall-local): Uninstasll all $(noinst_PROGRAMS).
(check-go-tool): Depend on $(noinst_PROGRAMS). Copy down
objabi.go.
(check-runtime): Depend on $(noinst_PROGRAMS).
(check-cgo-test, check-carchive-test): Likewise.
(check-vet): New target.
(check): Depend on check-vet. Look at cmd_vet-testlog.
(.PHONY): Add check-vet.
* Makefile.in: Rebuild.
From-SVN: r256365
Remove -fplan9-extensions from the CFLAGS used for libgo (no
longer needed since the runtime was converted from C to Go).
Reviewed-on: https://go-review.googlesource.com/82177
From-SVN: r255445
The functions cgoCheckPointer and cgoCheckResult are called by code
generated by cgo. That means that we need to export them using
go:linkname, as otherwise they are local symbols. The cgo code
currently uses weak references to only call the symbols if they are
defined, which is why it has been working--the cgo code has not been
doing any checks.
Reviewed-on: https://go-review.googlesource.com/80295
From-SVN: r255347
Fix a small bug in the libgo Makefile recipe that constructs the
directory from which to pick up libgcc_s.so ; the gccgo invocation
with -print-libgcc-file-name was missing the flags, which meant that
for -m32 builds we'd see the 64-bit libgcc dir.
Reviewed-on: https://go-review.googlesource.com/78836
From-SVN: r254984
With the change in the Solaris release model (no more major releases
like Solaris 12 but only minor ones like 11.4), the Solaris 12
references in GCC need to be adapted.
Patch by Rainer Orth.
Reviewed-on: https://go-review.googlesource.com/77490
From-SVN: r254729
For a misaligned address force a panic rather than assuming that reading
from the address 0 will cause one.
Reviewed-on: https://go-review.googlesource.com/69850
From-SVN: r254610
"make check" runs make recursively to check each package. Pass
the flags through. So it is possible to run "make check" with
different settings easily.
Reviewed-on: https://go-review.googlesource.com/76029
From-SVN: r254475
Also fix 64-bit DWARF to read a 64-bit abbrev offset in the
compilation unit.
This is a backport of https://golang.org/cl/71171, which will be in
the Go 1.10 release, to the gofrontend copy. Doing it now because AIX
is pretty much the only system that uses 64-bit DWARF.
Reviewed-on: https://go-review.googlesource.com/72250
From-SVN: r253955
With -enable-static=no we don't build non-pic objects, but libgotool.a
is built from non-pic objects. Build the packages that go into
libgotool.a in static mode in all cases.
Also ensure that internal test packages are built, since nothing
explicitly depended on them.
Reviewed-on: https://go-review.googlesource.com/65050
From-SVN: r253042
In preparation for upgrading libgo to the 1.9 release, this
approximately incorporates https://golang.org/cl/37661 and
https://golang.org/cl/38351.
CL 37661 changed the gc compiler such that the select statement simply
returns an integer which is then used as the argument for a switch.
Since gccgo already worked that way, this just adjusts the switch code
to look like the gc switch code by removing the explicit case index
expression and calculating it from the order of calls to selectsend,
selectrecv, and selectdefault.
CL 38351 simplifies the channel code by not passing the unused channel
type descriptor pointer.
Reviewed-on: https://go-review.googlesource.com/62730
From-SVN: r252749
This adds much of https://golang.org/cl/35731 and
https://golang.org/cl/35732 to the gofrontend code.
This is a step toward updating libgo to the 1.9 release. The
gofrontend already supports type aliases, and this is required for
correct support of type aliases when used as embedded fields.
The change to expressions.cc is to handle the << 1, used for the
newly renamed offsetAnon field, in the constant context used for type
descriptor initialization.
Reviewed-on: https://go-review.googlesource.com/62710
From-SVN: r252746
Using -funwind-tables is necessary to permit Go code to correctly
throw a panic through C code. This hasn't been necessary in the past
as -funwind-tables is the default on x86. However, it is not the
default for PPC AIX.
Reviewed-on: https://go-review.googlesource.com/56650
From-SVN: r251179
Libgo's implementation of math.Ldexp declared the libc "ldexp" as
taking an 'int' exponent argument, which is not quite right for 64-bit
platforms (exp arg is always int32); this could yield incorrect
results for exponent values outside the range of Minint32/Maxint32.
Fix by upating the type for the libc version of ldexp, and adding
guards to screen for out-of-range exponents.
Fixes#21323.
Reviewed-on: https://go-review.googlesource.com/54250
From-SVN: r250992
We unconditionally set _FILE_OFFSET_BITS to 64 in configure.ac, so we
should unconditionally call the statfs64 and fstatfs64 functions.
These functions should be available on all versions of GNU/Linux since 2.6.
On 64-bit systems they are aliased to statfs/fstatfs, and on 32-bit
systems they use the 64-bit data structures.
Fixesgolang/go#20922
Reviewed-on: https://go-review.googlesource.com/50635
From-SVN: r250443
If getSiginfo does not know how to determine the PC, it will call
runtime_callers. That can happen in a thread that was started by
non-Go code, in which case the TLS variable g will not be set, in
which case runtime_lock will crash.
Avoid the problem by using atomic operations for the lock. This is OK
since creating a backtrace state is fast and never blocks.
The test case is TestCgoExternalThreadSIGPROF in the runtime package
on a system that getSiginfo doesn't handle specially.
Updates golang/go#20931
Reviewed-on: https://go-review.googlesource.com/50650
From-SVN: r250439
Allocate enough stack space so that the test will work on a system
that does not support split stacks.
This test is actually not very meaningful for gccgo at present, but it
doesn't hurt to keep running it.
Updates golang/go#20931
Reviewed-on: https://go-review.googlesource.com/50630
From-SVN: r250433
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/81324
sysinfo.c: ignore ptrace_peeksiginfo_args from <linux/ptrace.h>
With some versions of glibc and GNU/Linux ptrace_pseeksiginfo_args is
defined in both <sys/ptrace.h> and <linux/ptrace.h>. We don't actually
care about the struct, so use a #define to avoid a redefinition error.
This fixes https://gcc.gnu.org/PR81324.
Reviewed-on: https://go-review.googlesource.com/49290
From-SVN: r250324
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
Copy all the misc/cgo files from the gc toolchain into libgo/misc.
These will be used for testing purposes by later changes to the
gotools directory.
Reviewed-on: https://go-review.googlesource.com/46721
From-SVN: r249674
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
The test for this is TestGoNil in the runtime package, which we don't
run yet but will run with a subsequent gotools patch.
Updates golang/go#8045
Reviewed-on: https://go-review.googlesource.com/46392
From-SVN: r249494
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
This means that the gc tools and gofrontend agree on the architecture names
for the 3 MIPS ABIs which should allow a gofrontend compiler to build go.
Reviewed-on: https://go-review.googlesource.com/46153
From-SVN: r249476
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
Ensure that the packages vendored into the standard library do not
have the same pkgpath as the actual packages. If we don't, attempts
to build and test the actual packages will get confused. The specific
error I was seeing was import loops, causing some of the packages to
fail to get initialized, causing an obscure run time crash.
Reviewed-on: https://go-review.googlesource.com/43610
From-SVN: r248168
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
On MIPS, SIGABRT is defined like this:
#define SIGIOT 6
#define SIGABRT SIGIOT
This breaks addsig which tries to append __SIGIOT_ to SIGLIST. Signal
number 6 is later added to the output and go complains about a
duplicate signal number.
Fix by recursing once when obtaining the signal number from
gen-sysinfo.go if the signal is defined as an alias of another signal.
Also modify the sed expression to 's/.* = //' which is equivalent to
the original expression but is less misleading given that it might not
match a number.
Reviewed-on: https://go-review.googlesource.com/43252
From-SVN: r247948
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
The quoting was causing us to never add the system-specific signals.
The test for this is misc/cgo/testcarchive in the master repo, which
we don't yet run for gccgo.
Reviewed-on: https://go-review.googlesource.com/37453
From-SVN: r245776
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
I typoed the argument passed to getcontext in getTraceback, and the
error was hidden by ucontext_arg. This would have been caught by some
of the runtime package tests, but we don't run most of them because
they rely on `go build`, and the go tool is not available while
running the libgo testsuite. We should fix the libgo testsuite,
somehow, so that they run.
Reviewed-on: https://go-review.googlesource.com/35837
From-SVN: r244946
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
PR go/79037
compiler, runtime: align gc data for m68k
The current GC requires that the gc data be aligned to at least a 4
byte boundary, because it uses the lower two bits of the address for
flags (see LOOP and PRECISE in runtime/mgc0.c). As the gc data is
stored as a [...]uintptr, that is normally always true. However, on
m68k, that only guarantees 2 byte alignment. Fix it by forcing the
alignment.
The parfor code used by the current GC requires that the parfor data
be aligned to at least an 8 byte boundary. The code in parfor.c
verifies this. This is normally true, as the data uses uint64_t
values, but, again, this must be enforced explicitly on m68k.
Fixes GCC PR 79037.
Reviewed-on: https://go-review.googlesource.com/35478
From-SVN: r244824
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/78978
libgo: build with -Wa,-nH if possible on Solaris
By default the Solaris assembler records the required hardware
capability in the object file. This means that the AES hashing code
breaks on systems that do not support AES, even though the code uses a
runtime check to only actually invoke the AES instructions on systems
that support it. An earlier fix for the problem only fixed the shared
library, not the static libgo.a. Fix the problem for real by using an
assembler option to not record the hardware capability.
For GCC PR 78978.
Patch by Rainer Orth.
Reviewed-on: https://go-review.googlesource.com/34910
From-SVN: r244165