David Crawshaw [Sat, 28 Feb 2015 22:06:06 +0000 (17:06 -0500)]
runtime/cgo: no-op getwd call as test breakpoint
This is to be used by an lldb script inside go_darwin_arm_exec to pause
the execution of tests on iOS so the working directory can be adjusted
into something resembling a GOROOT.
Change-Id: I69ea2d4d871800ae56634b23ffa48583559ddbc6
Reviewed-on: https://go-review.googlesource.com/6363 Reviewed-by: Minux Ma <minux@golang.org>
Rob Pike [Fri, 27 Feb 2015 21:50:26 +0000 (13:50 -0800)]
cmd/internal/obj: clean up handling of register list operand on ARM
ARM operands for MOVM have lists of registers: [R1,R2,R5-R8].
Handle them cleanly.
It was TYPE_CONST with special handling, which meant operand printing
didn't work right and the special handling was ugly. Add a new TYPE_REGLIST
for this case and it all gets cleaner.
Brad Fitzpatrick [Sat, 28 Feb 2015 03:34:56 +0000 (19:34 -0800)]
syscall: make pwd process-wide on Plan 9
On Plan 9, the pwd is apparently per-thread not per process. That
means different goroutines saw different current directories, even
changing within a goroutine as they were scheduled.
Instead, track the the process-wide pwd protected by a mutex in the
syscall package and set the current goroutine thread's pwd to the
correct once at critical points.
Fixes #9428
Change-Id: I928e90886355be4a95c2be834f5883e2b50fc0cf
Reviewed-on: https://go-review.googlesource.com/6350 Reviewed-by: David du Colombier <0intro@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Looks like introducing file_darwin_arm.go is confusing something in the API checker (probably go/types) into ignoring file.go, so the O_SYNC symbol is being lost.
No actual bug in this CL AFAIK, but I'll fix the other bug later and then roll this forward.
Change-Id: Ic132fb101e4b5f2716f7a0d15872bf35bdf42139
Reviewed-on: https://go-review.googlesource.com/6331 Reviewed-by: David Crawshaw <crawshaw@golang.org>
David Crawshaw [Sat, 28 Feb 2015 00:52:11 +0000 (19:52 -0500)]
os: fix tests on darwin/arm
Tests that fork are skipped. Tests that create files do so in a
temporary directory, as the initial PWD is read-only. And
darwin/arm returns a strange mkdir error when trying to write to /.
Rob Pike [Fri, 27 Feb 2015 20:36:15 +0000 (12:36 -0800)]
cmd/internal/obj: make ppc64's CR subregisters print as CRn rather than Cn
These 8 registers are windows into the CR register. They are officially CR0
through CR7 and that is what the assembler accepts, but for some reason
they have always printed as C0 through C7. Fix the naming and printing.
Sebastien Binet [Fri, 27 Feb 2015 19:42:18 +0000 (20:42 +0100)]
cmd/internal/gc: add missing verb to Yyerror
When a function had no body, Yyerror was called with an extra
argument, leading to extraneous printouts.
Add the missing verb to the Yyerror call and display the name of the
bodiless function.
Fixes #10030
Change-Id: I76d76c4547fb9cad1782cb11f7a5c63065a6e0c5
Reviewed-on: https://go-review.googlesource.com/6263 Reviewed-by: Rob Pike <r@golang.org>
David Crawshaw [Fri, 27 Feb 2015 13:58:54 +0000 (08:58 -0500)]
runtime/pprof: skip tests that fork on darwin/arm
Change-Id: I9b08b74214e5a41a7e98866a993b038030a4c073
Reviewed-on: https://go-review.googlesource.com/6251 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Austin Clements [Fri, 27 Feb 2015 17:41:20 +0000 (12:41 -0500)]
runtime: trivial clean ups to greyobject
Previously, the typeDead check in greyobject was under a separate
!useCheckmark conditional. Put it with the rest of the !useCheckmark
code. Also move a comment about atomic update of the marked bit to
where we actually do that update now.
Change-Id: Ief5f16401a25739ad57d959607b8d81ffe0bc211
Reviewed-on: https://go-review.googlesource.com/6271 Reviewed-by: Rick Hudson <rlh@golang.org>
David Crawshaw [Fri, 27 Feb 2015 14:08:35 +0000 (09:08 -0500)]
crypto/x509: skip tests not made for darwin/arm
Change-Id: I8b18dc840425b72d7172a35cb0ba004bd156492d
Reviewed-on: https://go-review.googlesource.com/6252 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
David Crawshaw [Fri, 27 Feb 2015 12:06:34 +0000 (07:06 -0500)]
cmd/objdump: skip fork test on darwin/arm
Change-Id: I1d1eb71014381452d1ef368431cb2556245a35ab
Reviewed-on: https://go-review.googlesource.com/6250 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Rob Pike [Fri, 27 Feb 2015 01:09:16 +0000 (17:09 -0800)]
cmd/internal/obj: make Rconv a global function
Clean up the obj API by making Rconv (register pretty printer) a top-level
function. This means that Dconv (operand pretty printer) doesn't need
an Rconv argument.
To do this, we make the register numbers, which are arbitrary inside an
operand (obj.Addr), disjoint sets for each architecture. Each architecture
registers (ha) a piece of the space and then the global Rconv knows which
architecture-specific printer to use.
Clean up all the code that uses Dconv.
Now register numbers are large, so a couple of fields in Addr need to go
from int8 to int16 because they sometimes hold register numbers. Clean
up their uses, which meant regenerating the yacc grammars for the
assemblers. There are changes in this CL triggered by earlier changes
to yacc, which had not been run in this directory.
There is still cleanup to do in Addr, but we're getting closer to that being
easy to do.
David Crawshaw [Thu, 26 Feb 2015 23:05:47 +0000 (18:05 -0500)]
runtime: skip tests that need fork on darwin/arm
Change-Id: I1bb0b8b11e8c7686b85657050fd7cf926afe4d29
Reviewed-on: https://go-review.googlesource.com/6200 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Dave Cheney [Wed, 25 Feb 2015 03:52:17 +0000 (14:52 +1100)]
syscall: Reimplement linux syscalls in terms of their *at replacements.
Updates #9974
This proposal tackles the body of syscalls which have been replaced,
and are now deprecated in linux. This is needed for the arm64 port as
arm64 is the first linux architecture to remove the "legacy" forms of
these syscalls.
The *AT variants were added in kernel 2.6.16, so well before our 2.6.23
cutoff (hey, it'll even work on RHEL5).
David Crawshaw [Thu, 26 Feb 2015 22:49:59 +0000 (17:49 -0500)]
cmd/nm: exclude Go tool test on darwin/arm
Change-Id: I44f1240a766f20de5997faca4f13f96af6da3534
Reviewed-on: https://go-review.googlesource.com/6190 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
David Crawshaw [Thu, 26 Feb 2015 22:27:52 +0000 (17:27 -0500)]
net/http/cgi: skip exec test on darwin/arm
Change-Id: I2fc3cf94b465bf9d7ff8d7bf935b45e334b401e3
Reviewed-on: https://go-review.googlesource.com/6180 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
David du Colombier [Thu, 26 Feb 2015 21:41:33 +0000 (22:41 +0100)]
runtime: fix memory allocator on Plan 9
Previously, the memory allocator on Plan 9 did
not free memory properly. It was only able to
free the last allocated block.
This change implements a variant of the
Kernighan & Ritchie memory allocator with
coalescing and splitting.
The most notable differences are:
- no header is prefixing the allocated blocks, since
the size is always specified when calling sysFree,
- the free list is nil-terminated instead of circular.
Dave Cheney [Thu, 26 Feb 2015 09:29:58 +0000 (20:29 +1100)]
runtime: disable scavenger on 64k page size kernels
Update #9993
If the physical page size of the machine is larger than the logical
heap size, for example 8k logical, 64k physical, then madvise(2) will
round up the requested amount to a 64k boundary and may discard pages
close to the page being madvised.
This patch disables the scavenger in these situations, which at the moment
is only ppc64 and ppc64le systems. NaCl also uses a 64k page size, but
it's not clear if it is affected by this problem.
Russ Cox [Tue, 24 Feb 2015 17:19:01 +0000 (12:19 -0500)]
cmd/internal/gc: transitive inlining
Inlining refuses to inline bodies containing an actual function call, so that
if that call or a child uses runtime.Caller it cannot observe
the inlining.
However, inlining was also refusing to inline bodies that contained
function calls that were themselves inlined away. For example:
func f() int {
return f1()
}
func f1() int {
return f2()
}
func f2() int {
return 2
}
The f2 call in f1 would be inlined, but the f1 call in f would not,
because f1's call to f2 blocked the inlining, despite itself eventually
being inlined away.
Account properly for this kind of transitive inlining and enable.
Also bump the inlining budget a bit, so that the runtime's
heapBits.next is inlined.
This reduces the time for '6g *.go' in html/template by around 12% (!).
(For what it's worth, closing Chrome reduces the time by about 17%.)
David Crawshaw [Thu, 26 Feb 2015 15:01:37 +0000 (10:01 -0500)]
runtime: skip test on darwin/arm
Needs the Go tool, which we do not have on iOS. (No Fork.)
Change-Id: Iedf69f5ca81d66515647746546c9b304c8ec10c4
Reviewed-on: https://go-review.googlesource.com/6102 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Joe Shaw [Thu, 12 Feb 2015 22:21:01 +0000 (17:21 -0500)]
archive/zip: fix size value in ZIP64 end central directory record
Section 4.3.14.1 of the ZIP file format
spec (https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT) says,
The value stored into the "size of zip64 end of central directory
record" should be the size of the remaining record and should not
include the leading 12 bytes.
We were previously writing the full size, including the 12 bytes.
David Crawshaw [Thu, 26 Feb 2015 14:21:19 +0000 (09:21 -0500)]
go/build: disable deps test on darwin/arm
Change-Id: Ief78a10c4aaa43f300f34519911ff73b6f510d73
Reviewed-on: https://go-review.googlesource.com/6100 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Dmitry Vyukov [Wed, 11 Feb 2015 16:11:32 +0000 (19:11 +0300)]
runtime: do not do futile netpolls
There is no sense in trying to netpoll while there is
already a thread blocked in netpoll. And in most cases
there must be a thread blocked in netpoll, because
the first otherwise idle thread does blocking netpoll.
On some program I see that netpoll called from findrunnable
consumes 3% of time.
Matthew Dempsky [Wed, 25 Feb 2015 05:41:21 +0000 (14:41 +0900)]
runtime: simplify CPU profiling code
This makes Go's CPU profiling code somewhat more idiomatic; e.g.,
using := instead of forward declaring variables, using "int" for
element counts instead of "uintptr", and slices instead of C-style
pointer+length. This makes the code easier to read and eliminates a
lot of type conversion clutter.
Additionally, in sigprof we can collect just maxCPUProfStack stack
frames, as cpuprof won't use more than that anyway.
cmd/gc: reduce lexer allocs when parsing numeric constants
This reduces the number of allocs when
running the rotate.go tests by
about 20%, after applying CL 5700.
Combining
s = "const str"
s += <another string>
generally saves an alloc and might be a candidate for
rsc's grind tool. However, I'm sending this CL now
because this also reuses the result of calling lexbuf.String.
Nigel Tao [Wed, 25 Feb 2015 23:40:15 +0000 (10:40 +1100)]
encoding/xml: add more marshalTests tests.
There are no behavior changes in this CL, only specifying the status
quo. A follow-up CL, https://go-review.googlesource.com/#/c/5910/, will
change marshaling behavior.
Change-Id: Ib3f4d62e8c4758da2f11a6d26b285c10d3b0d98a
Reviewed-on: https://go-review.googlesource.com/6040 Reviewed-by: Andrew Gerrand <adg@golang.org>
Carlos Castillo [Tue, 24 Feb 2015 10:35:55 +0000 (02:35 -0800)]
os: Use GetComputerNameEx to get Hostname on win32
The existing Hostname function uses the GetComputerName system
function in windows to determine the hostname. It has some downsides:
- The name is limited to 15 characters.
- The name returned is for NetBIOS, other OS's return a DNS name
This change adds to the internal/syscall/windows package a
GetComputerNameEx function, and related enum constants. They are used
instead of the syscall.ComputerName function to implement os.Hostname
on windows.
Fixes #9982
Change-Id: Idc8782785eb1eea37e64022bd201699ce9c4b39c
Reviewed-on: https://go-review.googlesource.com/5852 Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Carlos Castillo <cookieo9@gmail.com> Reviewed-by: Yasuhiro MATSUMOTO <mattn.jp@gmail.com>
David Crawshaw [Wed, 25 Feb 2015 22:30:40 +0000 (17:30 -0500)]
runtime/cgo: fix darwin/arm build
Macro definition ordering.
Change-Id: I0def4702d19a21a68ffa52ea5b7c22578830c578
Reviewed-on: https://go-review.googlesource.com/6030 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
David Crawshaw [Wed, 25 Feb 2015 21:11:53 +0000 (16:11 -0500)]
runtime/cgo: set the initial working directory
Gives tests a way to find the bundle that contains their testdata, and
is generally useful for finding resources.
Change-Id: Idfa03e8543af927c17bc8ec8aadc5014ec82df28
Reviewed-on: https://go-review.googlesource.com/6000 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Dave Cheney [Wed, 25 Feb 2015 20:48:50 +0000 (07:48 +1100)]
runtime: skip failing gdb test on linux/arm
Updates #10002
The gdb test added in 1c82e236f5ee is failing on most arm systems.
Temporarily disable this test so that we can return to a working arm build.
Change-Id: Iff96ea8d5a99e1ceacf4979e864ff196e5503535
Reviewed-on: https://go-review.googlesource.com/5902 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Keith Randall [Mon, 23 Feb 2015 21:58:05 +0000 (13:58 -0800)]
runtime: mark pages we return to kernel as NOHUGEPAGE
We return memory to the kernel with madvise(..., DONTNEED).
Also mark returned memory with NOHUGEPAGE to keep the kernel from
merging this memory into a huge page, effectively reallocating it.
Only known to be a problem on linux/{386,amd64,amd64p32} at the moment.
It may come up on other os/arch combinations in the future.
Keith Randall [Tue, 24 Feb 2015 17:25:09 +0000 (09:25 -0800)]
runtime: handle holes in the heap
We need to distinguish pointers to free spans, which indicate bugs in
our pointer analysis, from pointers to never-in-the-heap spans, which
can legitimately arise from sysAlloc/mmap/etc. This normally isn't a
problem because the heap is contiguous, but in some situations (32
bit, particularly) the heap must grow around an already allocated
region.
The bad pointer test is disabled so this fix doesn't actually do
anything, but it removes one barrier from reenabling it.
Rob Pike [Wed, 25 Feb 2015 17:07:02 +0000 (09:07 -0800)]
cmd/internal/obj: make Dconv a portable top-level function
Each architecture had its own Dconv (operand printer) but the syntax is
close to uniform and the code overlap was considerable. Consolidate these
into a single top-level function. A similar but smaller unification is done
for Mconv ("Name" formatter) as well.
The signature is changed. The flag was unused so drop it. Add a
function argument, Rconv, that must be supplied by the caller.
TODO: A future change will unify Rconv as well and this argument
will go away.
Some formats changed, because of the automatic consistency
created by unification. For instance, 0(R1) always prints as (R1)
now, and foo+0(SB) is just foo(SB). Before, some made these
simplifications and some didn't; now they all do.
David Crawshaw [Tue, 24 Feb 2015 16:11:56 +0000 (11:11 -0500)]
runtime: fallback to 128M address space on 32bit
Available darwin/arm devices sporadically have trouble mapping 256M.
I would really appreciate it if anyone could check my working on
this, and make sure sure there aren't obviously bad consequences I
haven't considered.
Change-Id: Id1a8edae104d974fcf5f9333274f958625467f79
Reviewed-on: https://go-review.googlesource.com/5752 Reviewed-by: Keith Randall <khr@golang.org>
Rob Pike [Tue, 24 Feb 2015 22:28:49 +0000 (14:28 -0800)]
cmd/go: make asm the first assembler
verifyAsm is still on, but this CL changes the order to asm then 6a.
Before, it was 6a then asm, but that meant that any bugs in asm
for bad input would be prevented from happening because 6a would
catch them. Now asm gets first crack, as it must.
Also implement the -trimpath flag in asm. It's necessary and trivial.
Previously, we had three loops in the garbage collector that all
cleared the per-G GC flags. Consolidate these into one function.
This one function is designed to work in a concurrent setting. As a
result, it's slightly more expensive than the loops it replaces during
STW phases, but these happen at most twice per GC.
Matthew Dempsky [Wed, 25 Feb 2015 08:28:52 +0000 (17:28 +0900)]
runtime: remove gogetcallerpc and gogetcallersp functions
Package runtime's Go code was converted to directly call getcallerpc
and getcallersp in https://golang.org/cl/138740043, but the assembly
implementations were not removed.
Matthew Dempsky [Mon, 23 Feb 2015 08:05:30 +0000 (17:05 +0900)]
runtime: simplify NetBSD semaphores
NetBSD's semaphore implementation is derived from OpenBSD's, but has
subsequently diverged due to cleanups that were only applied to the
latter (https://golang.org/cl/137960043, https://golang.org/cl/5563).
This CL applies analogous cleanups for NetBSD.
Notably, we can also remove the scary NetBSD deadlock warning.
NetBSD's manual pages document that lwp_unpark on a not-yet-parked LWP
will cause that LWP's next lwp_park system call to return immediately,
so there's no race hazard.
Change-Id: Ib06844c420d2496ac289748eba13eb4700bbbbb2
Reviewed-on: https://go-review.googlesource.com/5564 Reviewed-by: Dmitry Vyukov <dvyukov@google.com> Reviewed-by: Joel Sing <jsing@google.com>
Dave Cheney [Wed, 25 Feb 2015 01:56:44 +0000 (12:56 +1100)]
syscall: generate AT_* constants and regenerate ztypes_linux_*.go
Updates #9974
The *at family of syscalls requires some constants to be defined in the
syscall package for linux. Add the necessary constants and regenerate
the ztypes_linux_*.go files.
Jan Kratochvil [Sat, 21 Feb 2015 17:18:33 +0000 (18:18 +0100)]
gdb: fix map prettyprinter
(gdb) p x
Python Exception <class 'gdb.error'> There is no member named b.:
$2 = map[string]string
->
(gdb) p x
$1 = map[string]string = {["shane"] = "hansen"}
Change-Id: I874d02a029f2ac9afc5ab666afb65760ec2c3177
Reviewed-on: https://go-review.googlesource.com/5522 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Matthew Dempsky [Mon, 23 Feb 2015 08:05:30 +0000 (17:05 +0900)]
runtime: simplify OpenBSD semaphores
OpenBSD's thrsleep system call includes an "abort" parameter, which
specifies a memory address to be tested after being registered on the
sleep channel (i.e., capable of being woken up by thrwakeup). By
passing a pointer to waitsemacount for this parameter, we avoid race
conditions without needing a lock. Instead we just need to use
atomicload, cas, and xadd to mutate the semaphore count.
Change-Id: If9f2ab7cfd682da217f9912783cadea7e72283a8
Reviewed-on: https://go-review.googlesource.com/5563 Reviewed-by: Dmitry Vyukov <dvyukov@google.com> Reviewed-by: Joel Sing <jsing@google.com>
Because mksycall.pl does not sort symbols before generating the output file
the diff includes some unavoidable code moves as Dup2 is processed latter in
the run.
Adam Langley [Wed, 25 Feb 2015 00:06:08 +0000 (16:06 -0800)]
doc/go1.5: mention the change in certificate wildcard handling.
https://go-review.googlesource.com/#/c/5691/ shouldn't affect anyone
because it reflects the RFC and behaviour of modern browsers, but it's
probably worth mentioning.
Change-Id: I8a8eedaac5226b1d8018dc56de6b2d41bd82a642
Reviewed-on: https://go-review.googlesource.com/5862 Reviewed-by: Rob Pike <r@golang.org>
Dave Cheney [Tue, 24 Feb 2015 23:20:13 +0000 (10:20 +1100)]
syscall: split implementation of Pipe/Pipe2 per GOOS
Updates #9974
This proposal moves the definition of Pipe an Pipe2 from the generic
syscall_linux.go to the GOOS specific variants. This is in preparation
for the arm64 port.
For platforms where pipe2(2) is not supported in the minimum 2.6.23 kernel,
amd64 and 386, we retain pipe(2). For all other platforms pipe(2) is removed
and Pipe forwards to pipe2(2).
Because mksycall.pl does not sort symbols before generating the output file
the diff includes some unavoidable code moves as Pipe and Pipe2 are processed
latter in the run.
Rick Hudson [Tue, 24 Feb 2015 22:49:55 +0000 (17:49 -0500)]
runtime: reset gcscanvalid and gcworkdone when GODEBUG=gctrace=2
When GODEBUG=gctrace=2 two gcs are preformed. During the first gc
the stack scan sets the g's gcscanvalid and gcworkdone flags to true
indicating that the stacks have to be scanned and do not need to
be rescanned. These need to be reset to false for the second GC so the
stacks are rescanned, otherwise if the only pointer to an object is
on the stack it will not be discovered and the object will be freed.
Typically this will include the object that was just allocated in
the mallocgc call that initiated the GC.
Robert Griesemer [Tue, 24 Feb 2015 07:51:05 +0000 (23:51 -0800)]
go/ast, go/parser: correct End() position for *ast.EmptyStmt
- added a new field ast.EmptyStmt.Implicit to indicate explicit
or implicit semicolon
- fix ast.EmptyStmt.End() accordingly
- adjusted parser and added test case
Adam Langley [Mon, 23 Feb 2015 22:51:40 +0000 (14:51 -0800)]
crypto/tls: allow larger initial records.
Some servers which misunderstood the point of the CertificateRequest
message send huge reply records. These records are large enough that
they were considered “insane” by the TLS code and rejected.
This change removes the sanity test for record lengths. Although the
maxCiphertext test still remains, just above, which (roughly) enforces
the 16KB protocol limit on record sizes:
https://tools.ietf.org/html/rfc5246#section-6.2.1
Adam Langley [Mon, 23 Feb 2015 22:27:50 +0000 (14:27 -0800)]
crypto/x509: don't reject certs with critical policy extensions.
There was a missing continue that caused certificates with critical
certificate-policy extensions to be rejected. Additionally, that code
structure in general was prone to exactly that bug so I changed it
around to hopefully be more robust in the future.
Fixes #9964.
Change-Id: I58fc6ef3a84c1bd292a35b8b700f44ef312ec1c1
Reviewed-on: https://go-review.googlesource.com/5670 Reviewed-by: Andrew Gerrand <adg@golang.org>
Dmitry Vyukov [Fri, 20 Feb 2015 08:50:56 +0000 (11:50 +0300)]
sync: add active spinning to Mutex
Currently sync.Mutex is fully cooperative. That is, once contention is discovered,
the goroutine calls into scheduler. This is suboptimal as the resource can become
free soon after (especially if critical sections are short). Server software
usually runs at ~~50% CPU utilization, that is, switching to other goroutines
is not necessary profitable.
This change adds limited active spinning to sync.Mutex if:
1. running on a multicore machine and
2. GOMAXPROCS>1 and
3. there is at least one other running P and
4. local runq is empty.
As opposed to runtime mutex we don't do passive spinning,
because there can be work on global runq on on other Ps.