Jan Ziak [Mon, 17 Dec 2012 00:32:12 +0000 (19:32 -0500)]
runtime: struct Obj in mgc0.c and buffers in scanblock()
Details:
- This CL is the conceptual skeleton of code found in CL 6114046
- The garbage collector uses struct Obj to specify memory blocks
- scanblock() is putting found memory blocks into an intermediate buffer
(xbuf) before adding/flushing them to the main work buffer (wbuf)
- The main loop in scanblock() is replaced with a skeleton code that
in the future will be able to recognize the type of objects and
thus will improve the garbage collector's precision.
For now, all objects are simply sequences of pointers so
the precision of the garbage collector remains unchanged.
- The code plugs .gcdata and .gcbss sections into the garbage collector.
scanblock() in this CL is unable to make any use of this.
Mikio Hara [Sun, 16 Dec 2012 02:51:47 +0000 (11:51 +0900)]
net: change ListenUnixgram signature to return UnixConn instead of UDPConn
This CL breaks Go 1 API compatibility but it doesn't matter because
previous ListenUnixgram doesn't work in any use cases, oops.
The public API change is:
-pkg net, func ListenUnixgram(string, *UnixAddr) (*UDPConn, error)
+pkg net, func ListenUnixgram(string, *UnixAddr) (*UnixConn, error)
Fixes #3875.
R=rsc, golang-dev, dave
CC=golang-dev
https://golang.org/cl/6937059
Alex Brainman [Fri, 14 Dec 2012 06:33:59 +0000 (17:33 +1100)]
cmd/go: handle os signals
Ignore signals during "go run" and wait for running child
process to exit. Stop executing further tests during "go test",
wait for running tests to exit and report error exit code.
Ian Lance Taylor [Thu, 13 Dec 2012 23:11:31 +0000 (15:11 -0800)]
test: s/float/float32/
I just committed a patch to gccgo that notices that float was
never defined, causing an additional unmatched error message.
Rename the type to avoid that message.
Nick Craig-Wood [Thu, 13 Dec 2012 21:02:39 +0000 (13:02 -0800)]
os: Improve the accuracy of os.Chtimes
I've been writing some code which involves syncing files (like
rsync) and it became apparent that under Linux I could read
modification times (os.Lstat) with nanosecond precision but
only write them with microsecond precision. This difference
in precision is rather annoying when trying to discover
whether files need syncing or not!
I've patched syscall and os to increases the accuracy of of
os.Chtimes for Linux and Windows. This involved exposing the
utimensat system call under Linux and a bit of extra code
under Windows. I decided not to expose the "at" bit of the
system call as it is impossible to replicate under Windows, so
the patch adds syscall.Utimens() to all architectures along
with a ImplementsUtimens flag.
If the utimensat syscall isn't available (utimensat was added
to Linux in 2.6.22, Released, 8 July 2007) then it silently
falls back to the microsecond accuracy version it uses now.
The improved accuracy for Windows should be good for all
versions of Windows.
Unfortunately Darwin doesn't seem to have a utimensat system
call that I could find so I couldn't implement it there. The
BSDs do, but since they share their syscall implementation
with Darwin I couldn't figure out how to define a syscall for
*BSD and not Darwin. I've left this as a TODO in the code.
In the process I implemented the missing methods for Timespec
under Windows which I needed which just happened to round out
the Timespec API for all platforms!
Dave Cheney [Thu, 13 Dec 2012 05:26:20 +0000 (16:26 +1100)]
log/syslog: fix flakey test on slow hosts
Fixes #4467.
The syslog tests can fail if the timeout fires before the data arrives at the mock server. Moving the timeout onto the goroutine that is calling ReadFrom() and always processing the data returned before handling the error should improve the reliability of the test.
Rémy Oudompheng [Wed, 12 Dec 2012 07:35:08 +0000 (08:35 +0100)]
cmd/6g, cmd/8g: simplify integer division code.
Change suggested by iant. The compiler generates
special code for a/b when a is -0x80...0 and b = -1.
A single instruction can cover the case where b is -1,
so only one comparison is needed.
The code inside the casee and casep labels can perfectly be merged since
they essentially do the same. The character to be stored where cp points is
just the character contained by the c variable.
Brad Fitzpatrick [Tue, 11 Dec 2012 17:07:27 +0000 (12:07 -0500)]
net/http, net/url: permit Request-URI "*"
Also, implement a global OPTIONS * handler, like Apache.
Permit sending "*" requests to handlers, but not path-based
(ServeMux) handlers. That means people can go out of their
way to support SSDP or SIP or whatever, but most users will be
unaffected.
See RFC 2616 Section 5.1.2 (Request-URI)
See RFC 2616 Section 9.2 (OPTIONS)
Robert Griesemer [Mon, 10 Dec 2012 19:55:57 +0000 (11:55 -0800)]
spec: consistently use "indices" (rather than "indexes")
We have been using all three terms "indices", "indexes",
and "index expressions" indiscriminatly for index values.
With this change, "index" refers to an index value,
"indices" is the plural of "index", and "index expression"
refers to an array, slice, or map indexed by an index: a[x].
Russ Cox [Sun, 9 Dec 2012 08:59:33 +0000 (03:59 -0500)]
time: add Round and Truncate
New in Go 1 will be nanosecond precision in the result of time.Now on Linux.
This will break code that stores time in external formats at microsecond
precision, reads it back, and expects to get exactly the same time.
Code like that can be fixed by using time.Now().Round(time.Microsecond)
instead of time.Now() in those contexts.
When giving the same seeds to Go 1.0 and Go 1.1 programs
I would like them to generate the same random numbers.
««« original CL description
math/rand: remove noop iteration in Perm
The first iteration always do `m[0], m[0] = m[0], m[0]`, because
`rand.Intn(1)` is 0.
fun note: IIRC in TAOCP version of this algorithm, `i` goes
backward (n-1->1), meaning that the "already" shuffled part of the
array is never altered betweens iterations, while in the current
implementation the "not-yet" shuffled part of the array is
conserved between iterations.
Robert Griesemer [Thu, 6 Dec 2012 17:17:20 +0000 (09:17 -0800)]
spec: type assertions and type switches must be valid
The spec didn't preclude invalid type assertions and
type switches, i.e., cases where a concrete type doesn't
implement the interface type in the assertion in the first
place. Both, the gc and gccgo compiler exclude these cases.
This is documenting the status quo.
Also:
- minor clean up of respective examples
- added sentence about default case in select statements
Fixes #4472.
R=rsc, iant, r, ken
CC=golang-dev
https://golang.org/cl/6869050
Rémy Oudompheng [Thu, 6 Dec 2012 06:20:03 +0000 (07:20 +0100)]
cmd/6c, cmd/8c: add fixjmp step to regopt.
The fixjmp step eliminates redundant chains of JMP
instructions that are produced by the compiler during
code generation.
It is already implemented in gc, and can be adapted to 6c/8c with
the exception that JMPs refer to destination by pc instead of by
pointer. The algorithm is modified to operate on Regs instead of Progs
for this reason. The pcs are already restored later by regopt.
Russ Cox [Thu, 6 Dec 2012 05:00:20 +0000 (00:00 -0500)]
cmd/ld: skip 0-length write in cwrite
The 0-length part is fine, but some callers that write 0 bytes
also pass nil as the data pointer, and the Plan 9 kernel kills the
process with 'invalid address in sys call' in that case.
Brad Fitzpatrick [Thu, 6 Dec 2012 03:08:42 +0000 (19:08 -0800)]
net/http: fix bug parsing http_proxy lacking a protocol
Per the curl man page, the http_proxy configuration can be
of the form:
[protocol://]<host>[:port]
And we had a test that <ip>:<port> worked, but if
the host began with a letter, url.Parse parsed the hostname
as the scheme instead, confusing ProxyFromEnvironment.
Dave Cheney [Wed, 5 Dec 2012 21:01:33 +0000 (08:01 +1100)]
cmd/5g: use MOVB for fixed array nil check
Fixes #4396.
For fixed arrays larger than the unmapped page, agenr would general a nil check by loading the first word of the array. However there is no requirement for the first element of a byte array to be word aligned, so this check causes a trap on ARMv5 hardware (ARMv6 since relaxed that restriction, but it probably still comes at a cost).
Switching the check to MOVB ensures alignment is not an issue. This check is only invoked in a few places in the code where large fixed arrays are embedded into structs, compress/lzw is the biggest offender, and switching to MOVB has no observable performance penalty.
Thanks to Rémy and Daniel Morsing for helping me debug this on IRC last night.