]> Cypherpunks repositories - gostls13.git/log
gostls13.git
10 years ago[dev.cc] cmd/asm: rewrite the macro processor
Rob Pike [Fri, 30 Jan 2015 00:33:36 +0000 (16:33 -0800)]
[dev.cc] cmd/asm: rewrite the macro processor

The previous one was too broken, so just rewrite the code that invokes
a macro. Basically it was evaluating things too early, and mishandling
nested invocations. It's also easier to understand now.

Keep backslash-newline around in macro definitions. They get
processed when the body is evaluated.

Write some golden tests.

Change-Id: I27435f77f258a0873f80932bdc8d13ad39821ac1
Reviewed-on: https://go-review.googlesource.com/3550
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] cmd/asm: delete overflow checking, make labels function-scoped
Rob Pike [Thu, 29 Jan 2015 20:07:50 +0000 (12:07 -0800)]
[dev.cc] cmd/asm: delete overflow checking, make labels function-scoped

The overflow checking was causing more problems than it was avoiding,
so get rid of it. But because arithmetic is done with uint64s, to simplify
dealing with large constants, complain about right shift and divide with
huge numbers to avoid ambiguity about signed shifts.

Change-Id: I5b5ea55d8e8c02846605f4a3f8fd7a176b1e962b
Reviewed-on: https://go-review.googlesource.com/3531
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] cmd/asm: set the flags to production settings (turn off debug)
Rob Pike [Wed, 28 Jan 2015 23:41:12 +0000 (15:41 -0800)]
[dev.cc] cmd/asm: set the flags to production settings (turn off debug)

Set -S to false and add -debug to control the other debugging print.

Change-Id: I864866c3d264a33e6dd0ce12a86a050a5fe0f875
Reviewed-on: https://go-review.googlesource.com/3453
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] cmd/asm: check for overflow on multiply and left shift
Rob Pike [Wed, 28 Jan 2015 21:34:13 +0000 (13:34 -0800)]
[dev.cc] cmd/asm: check for overflow on multiply and left shift

The internal size of integers is not part of the definition of the assembler,
so if bits roll out the top it's a portability problem at best.

If you need to use shift to create a mask, use & to restrict the bit count
before shifting. That will make it portable, too.

Change-Id: I24f9a4d2152c3f9f253e22ff75270fe50c18612b
Reviewed-on: https://go-review.googlesource.com/3451
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] cmd/asm: fix the expression parser and add tests
Rob Pike [Wed, 28 Jan 2015 19:11:33 +0000 (11:11 -0800)]
[dev.cc] cmd/asm: fix the expression parser and add tests

Rewrite the grammar to have one more production so it parses
~0*0
correctly and write tests to prove it.

Change-Id: I0dd652baf65b48a3f26c9287c420702db4eaec59
Reviewed-on: https://go-review.googlesource.com/3443
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] cmd/asm: the text flag argument to TEXT psudo-op is optional
Rob Pike [Wed, 28 Jan 2015 18:21:04 +0000 (10:21 -0800)]
[dev.cc] cmd/asm: the text flag argument to TEXT psudo-op is optional

Allow TEXT to have two or three operands.
In
TEXT foo(SB),flag,$0
the flag can be missing, in which case we take it to be zero.

Change-Id: I7b88543b52019f7890baac4b95f9e63884d43c83
Reviewed-on: https://go-review.googlesource.com/3440
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] cmd/asm: rewrite parsing of TEXT $3-2
Rob Pike [Tue, 27 Jan 2015 19:43:33 +0000 (11:43 -0800)]
[dev.cc] cmd/asm: rewrite parsing of TEXT $3-2

It was too complicated, assuming the syntax is more general than reality.
It must be a possibly negative integer followed by an optional minus sign
and positive integer. Literals only, no expresssions.

Also put in a TODO about address parsing and clean up a couple of types.

Change-Id: If8652249c742e42771ccf2e3024f77307b2e5d9a
Reviewed-on: https://go-review.googlesource.com/3370
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] cmd/asm: changes to get identical output as new6a
Rob Pike [Fri, 23 Jan 2015 19:24:42 +0000 (11:24 -0800)]
[dev.cc] cmd/asm: changes to get identical output as new6a

Fix up a couple of minor things pointed out in the last review.
Also:

1. If the symbol starts with center dot, prefix the name with "".
2. If there is no locals size specified, use ArgsSizeUnknown (sic).
3. Do not emit a history point at the start of a macro invocation,
since we do not pop it at the end, behavior consistent with the
old code.

With these changes, old and new assemblers produce identical
output at least for my simple test case, so that provides a verifiable
check for future cleanups.

Change-Id: Iaa91d8e453109824b4be44321ec5e828f39f0299
Reviewed-on: https://go-review.googlesource.com/3242
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] cmd/dist: show bootstrap build progress in real time
Russ Cox [Fri, 23 Jan 2015 16:08:51 +0000 (11:08 -0500)]
[dev.cc] cmd/dist: show bootstrap build progress in real time

Change-Id: I97bbf7a276c8f99554f0e3a9bcc8d3792a5e0f65
Reviewed-on: https://go-review.googlesource.com/3221
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years ago[dev.cc] cmd/asm: the assembler proper
Rob Pike [Thu, 22 Jan 2015 18:48:33 +0000 (10:48 -0800)]
[dev.cc] cmd/asm: the assembler proper

Add main.go, the simple driver for the assembler, and the
subdirectory internal/asm, which contains the parser and
instruction generator.

It's likely that much of the implementation is superstition,
or at best experimental phenomenology, but it does generate
working binaries.

Change-Id: I322a9ae8a20174b6693153f30e39217ba68f8032
Reviewed-on: https://go-review.googlesource.com/3196
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] cmd/asm: add lex internal package
Rob Pike [Thu, 22 Jan 2015 18:48:02 +0000 (10:48 -0800)]
[dev.cc] cmd/asm: add lex internal package

Add the lexing code for the new portable assembler.
It is internal to the assembler, so lives in a subdirectory of cmd/asm/internal.

Its only new dependency is the flags package for the assembler, so
add that too; it's trivial. That package manages the command-line
flags in a central place.

The lexer builds on text/scanner to lex the input, including doing a
Plan 9-level implementation of the C preprocessor.

Change-Id: I262e8717b8c797010afaa5051920839906c0dd19
Reviewed-on: https://go-review.googlesource.com/3195
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] cmd/asm: add addr package
Rob Pike [Thu, 22 Jan 2015 18:42:08 +0000 (10:42 -0800)]
[dev.cc] cmd/asm: add addr package

This simple package holds the definition of the Addr (address) type
that represents addresses inside the assembler.

It has no dependencies.

Change-Id: I7573fd70f1847ef68e3d6b663dc4c39eb2ebf8b3
Reviewed-on: https://go-review.googlesource.com/3193
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] cmd/asm: add arch package
Rob Pike [Thu, 22 Jan 2015 18:46:50 +0000 (10:46 -0800)]
[dev.cc] cmd/asm: add arch package

This package builds the representation of the machine architecture
for the new assembler.

Almost nothing in it is likely to last but this will get things running.

Change-Id: I8edd891f927a81f76d2dbdcd7484b9c87ac0fb2e
Reviewed-on: https://go-review.googlesource.com/3194
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] cmd/internal/obj, cmd/new9a: use ctxt.NewProg
Russ Cox [Thu, 22 Jan 2015 02:45:29 +0000 (21:45 -0500)]
[dev.cc] cmd/internal/obj, cmd/new9a: use ctxt.NewProg

cmd/internal/obj reconverted using rsc.io/c2go rev 40275b8.

All Prog*s need Ctxt field set so that the printer can tell
which architecture the Prog belongs to.
Use ctxt.NewProg consistently for this.

Change-Id: Ic981b3d68f24931ffae74a772e83a3dc2fdf518a
Reviewed-on: https://go-review.googlesource.com/3152
Reviewed-by: Rob Pike <r@golang.org>
10 years ago[dev.cc] cmd/internal/obj: export more symbols, rename Type_ to Type
Russ Cox [Wed, 21 Jan 2015 19:48:18 +0000 (14:48 -0500)]
[dev.cc] cmd/internal/obj: export more symbols, rename Type_ to Type

For new assembler, reconvert using rsc.io/c2go rev f9db76e.
- Removes trailing _ from Go keywords that are exported.
- Export regstr as Register, anames[5689] as Anames.

Also update clients.

Change-Id: I41c8fd2d14490236f548b4aa0ed0b9bd7571d2d7
Reviewed-on: https://go-review.googlesource.com/3151
Reviewed-by: Rob Pike <r@golang.org>
10 years agoinclude: declare getgohostos and getgohostarch on Plan 9
David du Colombier [Wed, 21 Jan 2015 20:19:58 +0000 (21:19 +0100)]
include: declare getgohostos and getgohostarch on Plan 9

The function getgohostos and getgohostarch
were declared in include/libc.h in CL 3042.

Change-Id: Ib4ff5182cb71cc79a99663ce727fa4c28d15d7ad
Reviewed-on: https://go-review.googlesource.com/3122
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agoinclude: declare runcmd on Plan 9
David du Colombier [Wed, 21 Jan 2015 20:18:03 +0000 (21:18 +0100)]
include: declare runcmd on Plan 9

The function runcmd was declared in
include/libc.h in CL 7523043.

Change-Id: I3839b96b2ac0d63e5c2eb4c216710442d0962119
Reviewed-on: https://go-review.googlesource.com/3125
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years ago[dev.cc] cmd/go: run C and Go assemblers side by side and verify matching output
Russ Cox [Wed, 21 Jan 2015 17:04:35 +0000 (12:04 -0500)]
[dev.cc] cmd/go: run C and Go assemblers side by side and verify matching output

When an assembly file must be assembled, cmd/go now runs
both (say) 6a and new6a and checks that they write identical
output files.

This serves as a build-time test that the new assemblers are accurate
conversions of the old ones. As long as they are producing identical
bytes, there's no need for run-time testing.

Once the C conversion is done, we'll throw away the C code
and this checking.

Change-Id: I0216dad56b7e79011eecd27f1aff4fe79bfe720b
Reviewed-on: https://go-review.googlesource.com/3145
Reviewed-by: Rob Pike <r@golang.org>
10 years ago[dev.cc] cmd/dist: build new5a etc during bootstrap
Russ Cox [Wed, 21 Jan 2015 17:10:35 +0000 (12:10 -0500)]
[dev.cc] cmd/dist: build new5a etc during bootstrap

The change to the bootstrap import conversion is
for the a.y files, which use import dot.

While we're editing the tool list, add "cmd/dist".
Right now 'go install cmd/dist' installs to $GOROOT/bin/dist.
(A new bug since cmd/dist has been rewritten in Go.
When cmd/dist was a C program, go install cmd/dist just didn't work.)

Change-Id: I362208dcfb4ae64c987f60b95dc946829fa506d8
Reviewed-on: https://go-review.googlesource.com/3144
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
10 years ago[dev.cc] cmd/new5a etc, cmd/internal/asm: edit to produce working Go code
Russ Cox [Wed, 21 Jan 2015 17:01:38 +0000 (12:01 -0500)]
[dev.cc] cmd/new5a etc, cmd/internal/asm: edit to produce working Go code

These assemblers produce byte-for-byte identical output
to the ones written in C.

They are primarily a proof that cmd/internal/obj can be used
standalone to produce working object files. (The use via objwriter
starts by deserializing an already-constructed internal representation,
so objwriter does not exercise the code in cmd/internal/obj that
creates such a representation from scratch.)

Change-Id: I1793d8d010046cfb9d8b4d2d4469e7f47a3d3ac7
Reviewed-on: https://go-review.googlesource.com/3143
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years ago[dev.cc] cmd/new5a etc, cmd/internal/asm: initial C → Go conversion
Russ Cox [Wed, 21 Jan 2015 16:36:15 +0000 (11:36 -0500)]
[dev.cc] cmd/new5a etc, cmd/internal/asm: initial C → Go conversion

This is the raw output of c2go. It needs fixes to make it compile.
Rather than make c2go do a 100% conversion (like we're doing for
liblink and the Go compilers), since this is so trivial I'm going to
make the remaining changes by hand in a followup CL.
This CL makes the next CL's diffs useful.

Also copy unmodified .y files (5a/a.y → new5a/a.y and so on)

The converted 6a/lex.c has been written to new6a/lex.go
but also to internal/asm/asm.go, because I'm going to factor
out some common code rather than convert it four times.

Change-Id: I01d5dfd6a9be3ef6191581560bdddd0ac0e8bc58
Reviewed-on: https://go-review.googlesource.com/3142
Reviewed-by: Rob Pike <r@golang.org>
10 years ago[dev.cc] cmd/internal/obj: reconvert from liblink
Russ Cox [Wed, 21 Jan 2015 17:27:36 +0000 (12:27 -0500)]
[dev.cc] cmd/internal/obj: reconvert from liblink

Using rsc.io/c2go repo revision 60c9302.

- Export a few symbols needed by assemblers.
- Implement Getgoroot etc directly, and add Getgoversion.
- Removes dependency on Go 1.4 go/build.
- Change magic history name <no name> to <pop>

The <pop> change requires adjustment to the liblink serializer.

Change-Id: If5fb52ac9e91d50805263070b3fc5cc05d8b7632
Reviewed-on: https://go-review.googlesource.com/3141
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
10 years ago[dev.cc] cmd/dist: write cmd/internal/obj/zbootstrap.go
Russ Cox [Wed, 21 Jan 2015 17:09:20 +0000 (12:09 -0500)]
[dev.cc] cmd/dist: write cmd/internal/obj/zbootstrap.go

cmd/internal/obj needs information about the default
values of GOROOT, GOARM, GOEXPERIMENT, Version, and so on.
It cannot ask package runtime, because during bootstrap
package runtime comes from Go 1.4.
So it must have its own copy.

Change-Id: I73d3e75a3d47210b3184a51a810ebb44826b81e5
Reviewed-on: https://go-review.googlesource.com/3140
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
10 years ago[dev.cc] liblink: invoke 'go tool objwriter' to implement writeobj, if directed
Russ Cox [Mon, 19 Jan 2015 18:24:43 +0000 (13:24 -0500)]
[dev.cc] liblink: invoke 'go tool objwriter' to implement writeobj, if directed

This CL enables moving the bulk of the object writing code
out of liblink and into translated Go libraries in cmd/internal/obj,
but it does not do the move.

This CL introduces two new environment variables,
$GOOBJ and $GOOBJWRITER, but both will be deleted along with
the rest of the liblink C code.

The default behavior of a build is unchanged by this CL:
the C version of liblink uses the C object layout and writing code.

If $GOOBJ=1, liblink invokes go tool objwriter instead.

If $GOOBJ=2, liblink does its own layout and then invokes
go tool objwriter, which checks that it gets the same answer.

That is, in $GOOBJ=2 mode, both the C and the Go version of
the code run, and the operation fails if the two produce different
answers. This provides a very strong check that the translation
is working correctly.

Change-Id: I56ab49b07ccb2c7b81085f1d6950131047c6aa3c
Reviewed-on: https://go-review.googlesource.com/3048
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years ago[dev.cc] cmd/objwriter: implement using cmd/internal/obj
Russ Cox [Mon, 19 Jan 2015 19:41:34 +0000 (14:41 -0500)]
[dev.cc] cmd/objwriter: implement using cmd/internal/obj

New code but nothing interesting.
It's nearly all parsing code for the format written by liblink.
The interesting part is the call to obj.Writeobjdirect, which
is the Go translation of the C liblink writeobjdirect function.

Change-Id: I2e9e755e7a3c999302e2ef2c7475c0af9c5acdd2
Reviewed-on: https://go-review.googlesource.com/3047
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years ago[dev.cc] cmd/internal/obj: convert liblink C to Go
Russ Cox [Mon, 19 Jan 2015 19:34:58 +0000 (14:34 -0500)]
[dev.cc] cmd/internal/obj: convert liblink C to Go

This CL adds the real cmd/internal/obj packages.
Collectively they correspond to the liblink library.
The conversion was done using rsc.io/c2go's run script
at rsc.io/c2go repo version 706fac7.

This is not the final conversion, just the first working draft.
There will be more updates, but this works well enough
to use with go tool objwriter and pass all.bash.

Change-Id: I9359e835425f995a392bb2fcdbebf29511477bed
Reviewed-on: https://go-review.googlesource.com/3046
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years ago[dev.cc] build: do not 'clean -i std' between dist and go_bootstrap
Russ Cox [Wed, 21 Jan 2015 02:17:17 +0000 (21:17 -0500)]
[dev.cc] build: do not 'clean -i std' between dist and go_bootstrap

Executing 'clean -i std' removes installed Go programs,
including the toolchain binaries we need for building.
It's not clear why the 'clean -i std' is here in the first place.
cmd/dist just removed the entire pkg tree, so everything is new.
The only reason for 'clean -i std' would be if you don't trust
that dist compiled the packages properly. If that's true for
some reason, we can fix cmd/dist, or add -a to the install
commands that follow. Perhaps clean -i std should not
remove tools, or perhaps std should not expand to any tools.
Not sure.

Also remove banner from make.bat and make.rc that was
already removed from make.bash. cmd/dist prints it now.

Also fix array size error in liblink/objfile.c.

Fixes dev.cc build.

Change-Id: I60855e001a682efce55ad9aa307a8f3ee47f7366
Reviewed-on: https://go-review.googlesource.com/3100
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] liblink: invoke go tool objwriter during writeobj
Russ Cox [Mon, 19 Jan 2015 16:38:53 +0000 (11:38 -0500)]
[dev.cc] liblink: invoke go tool objwriter during writeobj

This doesn't actually use objwriter for any real work.
It's just to check that objwriter is available.
The real work will be moved once the bootstrapping
mechanisms are working.

Change-Id: I5f41c8910c4b11b9d80cb0b0847ff9cb582fc2be
Reviewed-on: https://go-review.googlesource.com/3045
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years ago[dev.cc] cmd/dist: bootstrap Go toolchain using Go 1.4
Russ Cox [Mon, 19 Jan 2015 17:57:35 +0000 (12:57 -0500)]
[dev.cc] cmd/dist: bootstrap Go toolchain using Go 1.4

Bootstrap the Go parts of the Go toolchain using Go 1.4,
as described in https://golang.org/s/go15bootstrap.

The first Go part of the Go toolchain will be cmd/objwriter,
but for now that's just an empty program to test that this
new code works.

Once the build dashboard is okay with this change,
we'll make objwriter a real program depended upon by the build.

Change-Id: Iad3dce675571cbdb5ab6298fe6f98f53ede47d5c
Reviewed-on: https://go-review.googlesource.com/3044
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years ago[dev.cc] cmd/objwriter: add placeholder program
Russ Cox [Mon, 19 Jan 2015 16:45:48 +0000 (11:45 -0500)]
[dev.cc] cmd/objwriter: add placeholder program

cmd/internal/obj is the name for the Go translation of the C liblink library.

cmd/objwriter is the name of a Go binary that runs liblink's writeobj function.
When the bulk of liblink has been converted to Go but the assemblers and
compilers are still written in C, the C writeobj will shell out to the Go objwriter
to actually write the object file. This lets us manage the transition in smaller
pieces.

The objwriter tool is purely transitional.
It will not ship in any release (enforced in cmd/dist).

Adding a dummy program and some dummy imports here so that we
can work on the bootstrap mechanisms that will be necessary to build it.
Once the build process handles objwriter properly,
we'll work on the actual implementation.

Change-Id: I675c818b3a513c26bb91c6dba564c6ace3b7fcd4
Reviewed-on: https://go-review.googlesource.com/3043
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years ago[dev.cc] cmd/dist, lib9: make GOHOSTARCH, GOHOSTOS available to C programs
Russ Cox [Mon, 19 Jan 2015 16:33:46 +0000 (11:33 -0500)]
[dev.cc] cmd/dist, lib9: make GOHOSTARCH, GOHOSTOS available to C programs

Needed for invoking a Go subprocess in the C code.
The Go tools live in $GOROOT/pkg/tool/$GOHOSTARCH_$GOHOSTOS.

Change-Id: I961b6b8a07de912de174b758b2fb87d77080546d
Reviewed-on: https://go-review.googlesource.com/3042
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years ago[dev.cc] liblink: arrange for Prog* argument in vaddr
Russ Cox [Mon, 19 Jan 2015 21:26:14 +0000 (16:26 -0500)]
[dev.cc] liblink: arrange for Prog* argument in vaddr

The argument is unused in the C code but will be used in the Go translation,
because the Prog holds information needed to invoke the right meaning
of %A in the ctxt->diag calls in vaddr.

Change-Id: I501830f8ea0e909aafd8ec9ef5d7338e109d9548
Reviewed-on: https://go-review.googlesource.com/3041
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agonet/http/fcgi: Fix resource leaks
Evan Kroske [Sun, 21 Dec 2014 17:25:12 +0000 (09:25 -0800)]
net/http/fcgi: Fix resource leaks

Close the pipe for the body of a request when it is aborted and close
all pipes when child.serve terminates.

Fixes #6934

Change-Id: I1c5e7d2116e1ff106f11a1ef8e99bf70cf04162a
Reviewed-on: https://go-review.googlesource.com/1923
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agocmd/go: make use of Runnable method
Mikio Hara [Mon, 19 Jan 2015 08:19:46 +0000 (17:19 +0900)]
cmd/go: make use of Runnable method

Reported via unsupported Github pull request: #9299

Change-Id: I0e98dd68cbc68fcc6bcec15c5b33f20b6a861ec6
Reviewed-on: https://go-review.googlesource.com/3025
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agomisc/dashboard/codereview: delete
Andrew Gerrand [Mon, 19 Jan 2015 22:12:24 +0000 (09:12 +1100)]
misc/dashboard/codereview: delete

This dashboard is no longer in use, and doesn't work with Gerrit.

Change-Id: Ib7c367dcad97322566610157b15e23db5bec58ff
Reviewed-on: https://go-review.googlesource.com/3028
Reviewed-by: David Symonds <dsymonds@golang.org>
10 years agocmd/dist: fix deadlock when compilation command fails
Russ Cox [Sat, 17 Jan 2015 03:12:41 +0000 (22:12 -0500)]
cmd/dist: fix deadlock when compilation command fails

Can't use bgwait, both because it can only be used from
one goroutine at a time and because it ends up queued
behind all the other pending commands. Use a separate
signaling mechanism so that we can notice we're dying
sooner.

Change-Id: I8652bfa2f9bb5725fa5968d2dd6a745869d01c01
Reviewed-on: https://go-review.googlesource.com/3010
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agoruntime: factor out bitmap, finalizer code from malloc/mgc
Russ Cox [Fri, 16 Jan 2015 19:43:38 +0000 (14:43 -0500)]
runtime: factor out bitmap, finalizer code from malloc/mgc

The code in mfinal.go is moved from malloc*.go and mgc*.go
and substantially unchanged.

The code in mbitmap.go is also moved from those files, but
cleaned up so that it can be called from those files (in most cases
the code being moved was not already a standalone function).
I also renamed the constants and wrote comments describing
the format. The result is a significant cleanup and isolation of
the bitmap code, but, roughly speaking, it should be treated
and reviewed as new code.

The other files changed only as much as necessary to support
this code movement.

This CL does NOT change the semantics of the heap or type
bitmaps at all, although there are now some obvious opportunities
to do so in followup CLs.

Change-Id: I41b8d5de87ad1d3cd322709931ab25e659dbb21d
Reviewed-on: https://go-review.googlesource.com/2991
Reviewed-by: Keith Randall <khr@golang.org>
10 years agonet/http: remove unused test type
Jongmin Kim [Mon, 19 Jan 2015 12:13:13 +0000 (21:13 +0900)]
net/http: remove unused test type

Change-Id: Ia8d4459a39425583027f00410fe17b9686b768db
Reviewed-on: https://go-review.googlesource.com/3026
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoruntime: move write barrier code into mbarrier.go
Russ Cox [Thu, 15 Jan 2015 02:47:49 +0000 (21:47 -0500)]
runtime: move write barrier code into mbarrier.go

I also added new comments at the top of mbarrier.go,
but the rest of the code is just copy-and-paste.

Change-Id: Iaeb2b12f8b1eaa33dbff5c2de676ca902bfddf2e
Reviewed-on: https://go-review.googlesource.com/2990
Reviewed-by: Austin Clements <austin@google.com>
10 years agoruntime: rename float64 constants to avoid name space pollution
Russ Cox [Fri, 16 Jan 2015 19:33:27 +0000 (14:33 -0500)]
runtime: rename float64 constants to avoid name space pollution

Otherwise, if you mistakenly refer to an undeclared 'shift' variable, you get 52.

Change-Id: I845fb29f23baee1d8e17b37bde0239872eb54316
Reviewed-on: https://go-review.googlesource.com/2909
Reviewed-by: Austin Clements <austin@google.com>
10 years agofmt: reword the document for [n].
Shenghou Ma [Mon, 19 Jan 2015 01:05:44 +0000 (20:05 -0500)]
fmt: reword the document for [n].

Fixes #9632.

Change-Id: Ic4d7cad8ff62023c1beecd2d62e48eb9258f5306
Reviewed-on: https://go-review.googlesource.com/3013
Reviewed-by: Rob Pike <r@golang.org>
10 years agonet: more accurate parsing of IPv4 header on IPConn
Mikio Hara [Sun, 18 Jan 2015 07:28:15 +0000 (16:28 +0900)]
net: more accurate parsing of IPv4 header on IPConn

As shown in #9395, inaccurate implementation would be a cause of parsing
IPv4 header twice and corrupted upper-layer message issues.

Change-Id: Ia1a042e7ca58ee4fcb38fe9ec753c2ab100592ca
Reviewed-on: https://go-review.googlesource.com/3001
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agostrings: remove overengineered Compare implementation
Russ Cox [Sun, 18 Jan 2015 17:50:22 +0000 (12:50 -0500)]
strings: remove overengineered Compare implementation

The function is here ONLY for symmetry with package bytes.
This function should be used ONLY if it makes code clearer.
It is not here for performance. Remove any performance benefit.

If performance becomes an issue, the compiler should be fixed to
recognize the three-way compare (for all comparable types)
rather than encourage people to micro-optimize by using this function.

Change-Id: I71f4130bce853f7aef724c6044d15def7987b457
Reviewed-on: https://go-review.googlesource.com/3012
Reviewed-by: Rob Pike <r@golang.org>
10 years agocmd/go: set $GOROOT during 'go tool' invocations
Russ Cox [Sat, 17 Jan 2015 03:15:01 +0000 (22:15 -0500)]
cmd/go: set $GOROOT during 'go tool' invocations

cmd/dist now requires $GOROOT to be set explicitly.
Set it when invoking via 'go tool dist' so that users are unaffected.

Also, change go tool -n to drop trailing space in output
for 'go tool -n <anything>'.

Change-Id: I9b2c020e0a2f3fa7c9c339fadcc22cc5b6cb7cac
Reviewed-on: https://go-review.googlesource.com/3011
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agocmd/dist: do not leave go-tool-dist-* temporary directories behind
Shenghou Ma [Sat, 17 Jan 2015 03:08:22 +0000 (22:08 -0500)]
cmd/dist: do not leave go-tool-dist-* temporary directories behind

Change-Id: I3f6ba5591130b2c4762d33bd4553220765ad9fc5
Reviewed-on: https://go-review.googlesource.com/2996
Reviewed-by: Andrew Gerrand <adg@golang.org>
10 years agocmd/dist: produce a properly formatted zversion.go
Michael Matloob [Mon, 19 Jan 2015 00:04:47 +0000 (16:04 -0800)]
cmd/dist: produce a properly formatted zversion.go

gofmt inserts a blank line line between const and var declarations

Change-Id: I3f2ddbd9e66a74eb3f37a2fe641b93820b02229e
Reviewed-on: https://go-review.googlesource.com/3022
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agodoc: update go1.5.txt
Brad Fitzpatrick [Mon, 19 Jan 2015 00:00:10 +0000 (16:00 -0800)]
doc: update go1.5.txt

Change-Id: I58d66a7fc25b172baf0df6b634e9e2cc792967d5
Reviewed-on: https://go-review.googlesource.com/3021
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoruntime, syscall: use SYSCALL instruction on FreeBSD.
Bill Thiede [Sun, 18 Jan 2015 05:09:15 +0000 (21:09 -0800)]
runtime, syscall: use SYSCALL instruction on FreeBSD.

This manually reverts 555da73 from #6372 which implies a
minimum FreeBSD version of 8-STABLE.
Updates docs to mention new minimum requirement.

Fixes #9627

Change-Id: I40ae64be3682d79dd55024e32581e3e5e2be8aa7
Reviewed-on: https://go-review.googlesource.com/3020
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agomisc/makerelease: workaround the go install -a restriction on release branches
Shenghou Ma [Sat, 17 Jan 2015 02:07:23 +0000 (21:07 -0500)]
misc/makerelease: workaround the go install -a restriction on release branches

Fixes #9619.

Change-Id: I71931b0d546163e5451d7d72e552b08540e3c2a7
Reviewed-on: https://go-review.googlesource.com/2995
Reviewed-by: Andrew Gerrand <adg@golang.org>
10 years agodoc: direct people to the mailing list
Brad Fitzpatrick [Sun, 18 Jan 2015 18:56:00 +0000 (10:56 -0800)]
doc: direct people to the mailing list

Since the move to Github, we've started to receive lots of
introductory questions to the bug tracker. I posit this is because
most projects on Github don't have mailing lists, so the culture on
Github is to use the Issue Tracker as a discussion forum.

The Go project doesn't use the Issue Tracker as our first point of
communication. This CL updates CONTRIBUTING.md (which is linked when
you file a bug or send a pull request), to mention that we have a
mailing list.

It certainly won't stop all the errant bug reports, but it should
help.

Change-Id: Id8fbfd35b73f5117617dff53b1e72d5b5276388b
Reviewed-on: https://go-review.googlesource.com/3002
Reviewed-by: Rob Pike <r@golang.org>
10 years agonet/http/cgi: correctly handle pathnames for cygwin perl on windows
Martin Möhrmann [Sat, 17 Jan 2015 12:37:04 +0000 (13:37 +0100)]
net/http/cgi: correctly handle pathnames for cygwin perl on windows

Cygwin perl uses unix pathnames in windows. Include cygwin perl in the
list of special cases for unix pathname handling in test.cgi.

Change-Id: I30445a9cc79d62d022ecc232c35aa5015b7418dc
Reviewed-on: https://go-review.googlesource.com/2973
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
10 years agotest: generate tests for arithmetic on narrow types
Keith Randall [Fri, 16 Jan 2015 05:02:51 +0000 (21:02 -0800)]
test: generate tests for arithmetic on narrow types

Fixes #9607
Related to #9604
Inadvertently found #9609

Change-Id: I8a8ddf84ac72d3e18986fd8e9288734459f3f174
Reviewed-on: https://go-review.googlesource.com/2962
Reviewed-by: Minux Ma <minux@golang.org>
10 years agoall: merge dev.cc (929f321) into master
Russ Cox [Fri, 16 Jan 2015 23:52:30 +0000 (18:52 -0500)]
all: merge dev.cc (929f321) into master

This brings in cmd/dist written in Go, which is working on the primary builders.

If this breaks your build, you need to get Go 1.4 and put it in $HOME/go1.4
(or, if you want to use some other directory, set $GOROOT_BOOTSTRAP
to that directory).

To build Go 1.4 from source:

git clone -b release-branch.go1.4 $GOROOT $HOME/go1.4
cd $HOME/go1.4/src
./make.bash

Or use a binary release: https://golang.org/dl/.

See https://golang.org/s/go15bootstrap for more information.

Change-Id: Ie4ae834c76ea35e39cc54e9878819a9e51b284d9

10 years agomisc/android: choose the right subdirectory for bin under GOPATH.
Hyang-Ah Hana Kim [Thu, 15 Jan 2015 21:47:41 +0000 (16:47 -0500)]
misc/android: choose the right subdirectory for bin under GOPATH.

This change includes the cleanup of temporary files created during
the binary execution as well.

Change-Id: Ic01a0a537d1daafcaa3acda1ec344aff5dcddfc2
Reviewed-on: https://go-review.googlesource.com/2903
Reviewed-by: David Crawshaw <crawshaw@golang.org>
10 years agomisc/cgo: skip testso on ppc64
Austin Clements [Fri, 16 Jan 2015 15:34:07 +0000 (10:34 -0500)]
misc/cgo: skip testso on ppc64

This test requires external linking, but we don't yet implement
external linking on ppc64 (tracked in issue #8912).  Disable the test
on ppc64 until external linking is implemented.

This makes all.bash pass on ppc64le.

Change-Id: I741498d4d9321607e7a65792a33faf8187bd18e4
Reviewed-on: https://go-review.googlesource.com/2908
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agomath/big: bug in AndNot(x,y) for x>0,y<0.
Keith Randall [Fri, 16 Jan 2015 04:45:07 +0000 (20:45 -0800)]
math/big: bug in AndNot(x,y) for x>0,y<0.

The comment says to use (y-1), but then we did add(y.abs, natOne).  We meant sub.

Fixes #9609

Change-Id: I4fe4783326ca082c05588310a0af7895a48fc779
Reviewed-on: https://go-review.googlesource.com/2961
Reviewed-by: Robert Griesemer <gri@golang.org>
10 years agosyscall: use name+(NN)FP on linux/arm
David Crawshaw [Wed, 14 Jan 2015 19:36:17 +0000 (14:36 -0500)]
syscall: use name+(NN)FP on linux/arm

Generated with a modified version of go vet and tested on android.

Change-Id: I1ff20135c5ab9de5a6dbf76ea2991167271ee70d
Reviewed-on: https://go-review.googlesource.com/2815
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agomisc/makerelease: a couple of small fixes
Andrew Gerrand [Fri, 16 Jan 2015 02:49:06 +0000 (13:49 +1100)]
misc/makerelease: a couple of small fixes

Change-Id: Iec19d6152b95ba67daac366b32d42f69e1dba9a4
Reviewed-on: https://go-review.googlesource.com/2951
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agocmd/5g: make sure we normalize after unary ops on small types
Keith Randall [Thu, 15 Jan 2015 22:39:58 +0000 (14:39 -0800)]
cmd/5g: make sure we normalize after unary ops on small types

We were failing ^uint16(0xffff) == 0, as we computed 0xffff0000 instead.

I could only trigger a failure for the above case, the other two tests
^uint16(0xfffe) == 1 and -uint16(0xffff) == 1 didn't seem to fail
previously.  Somehow they get MOVHUs inserted for other reasons (used
by CMP instead of TST?).  I fixed OMINUS anyway, better safe than
sorry.

Fixes #9604

Change-Id: I4c2d5bdc667742873ac029fdbe3db0cf12893c27
Reviewed-on: https://go-review.googlesource.com/2940
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
10 years agonet: fix some typos in comments
Ian Lance Taylor [Thu, 15 Jan 2015 05:25:26 +0000 (21:25 -0800)]
net: fix some typos in comments

Change-Id: I1bf1ab930a5c258f5fcc85ca3037692c71bf3cb2
Reviewed-on: https://go-review.googlesource.com/2870
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Minux Ma <minux@golang.org>
10 years agomisc/makerelease: use built in "del" to remove files
Andrew Gerrand [Thu, 15 Jan 2015 22:11:17 +0000 (09:11 +1100)]
misc/makerelease: use built in "del" to remove files

Git marks some of its files read only, so os.RemoveAll isn't sufficient
to remove them from the ".git" directory.

Change-Id: I3150596931d1c77e7cf9fb8da1a999d2c6730121
Reviewed-on: https://go-review.googlesource.com/2930
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agostrings: add Compare(x, y string) int, for symmetry with bytes.Compare
Alan Donovan [Wed, 14 Jan 2015 23:09:36 +0000 (18:09 -0500)]
strings: add Compare(x, y string) int, for symmetry with bytes.Compare

The implementation is the same assembly (or Go) routine.

Change-Id: Ib937c461c24ad2d5be9b692b4eed40d9eb031412
Reviewed-on: https://go-review.googlesource.com/2828
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoall: update old comments referencing *.goc files
Brad Fitzpatrick [Thu, 15 Jan 2015 16:26:01 +0000 (08:26 -0800)]
all: update old comments referencing *.goc files

Change-Id: Ibf05e55ffe3bb454809cd3450b790e44061511c7
Reviewed-on: https://go-review.googlesource.com/2890
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agobuild: androidtest.bash has to use copy for files to adb-sync.
Hyang-Ah Hana Kim [Wed, 14 Jan 2015 17:13:17 +0000 (12:13 -0500)]
build: androidtest.bash has to use copy for files to adb-sync.

androidtest.bash copies some go source to the android device
where the tests are going to run. It's necessary because some
tests require files and resources to be present. The copy is
done through adb sync. The script hoped faking the directory
using symlinks to work, but it doesn't. (adb sync doesn't follow
the symlinks) We need proper copy.

Change-Id: If55abca4958f159859e58512b0045f23654167e3
Reviewed-on: https://go-review.googlesource.com/2827
Reviewed-by: David Crawshaw <crawshaw@golang.org>
10 years agoencoding/xml: remove unnecessary memory allocation in Unmarshal
Dmitry Vyukov [Wed, 14 Jan 2015 18:32:05 +0000 (21:32 +0300)]
encoding/xml: remove unnecessary memory allocation in Unmarshal

benchmark              old ns/op     new ns/op     delta
BenchmarkUnmarshal     75256         72626         -3.49%

benchmark              old allocs     new allocs     delta
BenchmarkUnmarshal     259            219            -15.44%

Change-Id: I7fd30739b045e35b95e6ef6a8ef2f15b0dd6839c
Reviewed-on: https://go-review.googlesource.com/2758
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoruntime: fix runtime-gdb script loading
Paul Nasrat [Wed, 14 Jan 2015 19:32:01 +0000 (14:32 -0500)]
runtime: fix runtime-gdb script loading

runtime.rtype was a copy of reflect.rtype - update script to use that directly.
Introduces a basic test which will skip on systems without appropriate GDB.

Fixes #9326

Change-Id: I6ec74e947bd2e1295492ca34b3a8c1b49315a8cb
Reviewed-on: https://go-review.googlesource.com/2821
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agodoc: document Go 1.4.1
Andrew Gerrand [Thu, 15 Jan 2015 04:28:12 +0000 (15:28 +1100)]
doc: document Go 1.4.1

Change-Id: I4e9737497f4995657c46e52e0722d921499f8d17
Reviewed-on: https://go-review.googlesource.com/2854
Reviewed-by: Rob Pike <r@golang.org>
10 years agobuild: fix typo in androidtest.bash
Burcu Dogan [Thu, 15 Jan 2015 02:49:03 +0000 (18:49 -0800)]
build: fix typo in androidtest.bash

Change-Id: Idd72e095ad64e1a398058982422c2c5497a23ce5
Reviewed-on: https://go-review.googlesource.com/2739
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agocrypto/x509: write exact BitLength in ASN.1 encoding for certificate KeyUsage
Adam Langley [Mon, 12 Jan 2015 21:58:30 +0000 (13:58 -0800)]
crypto/x509: write exact BitLength in ASN.1 encoding for certificate KeyUsage

The encoded value of the certificate KeyUsage did contain additonal padding
that was not present with other certificate generators. According to ITU-T
X.690 the BitLength value should have no padding in a DER encoding.

See discussion:
https://groups.google.com/forum/#!topic/golang-nuts/dzaJ3hMpDcs

This CL has been discussed at: http://golang.org/cl/168990043

Change-Id: I1eff3f441b0566966a2d279631901ad9287c917d
Reviewed-on: https://go-review.googlesource.com/2255
Reviewed-by: Adam Langley <agl@golang.org>
10 years ago[dev.cc] all: merge master (d1210ac) into dev.cc
Russ Cox [Thu, 15 Jan 2015 00:39:34 +0000 (19:39 -0500)]
[dev.cc] all: merge master (d1210ac) into dev.cc

Change-Id: I068d617175776c2f5df00b17ff0d404a584ab570

10 years agotime: correctly parse large input durations and avoid precision loss
Martin Möhrmann [Wed, 7 Jan 2015 18:56:06 +0000 (19:56 +0100)]
time: correctly parse large input durations and avoid precision loss

Do not lose precision for durations specified without fractions
that can be represented by an int64 such as 1<<53+1 nanoseconds.
Previously there was some precision lost in floating point conversion.

Handle overflow for durations above 1<<63-1 nanoseconds but not earlier.

Add tests to cover the above cases.

Change-Id: I4bcda93cee1673e501ecb6a9eef3914ee29aecd2
Reviewed-on: https://go-review.googlesource.com/2461
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
10 years agotest: comment the behavior and use of cmplxdivide*
Rob Pike [Wed, 14 Jan 2015 23:43:04 +0000 (10:43 +1100)]
test: comment the behavior and use of cmplxdivide*

The various files are confusingly named and their operation
not easy to see. Add a comment to cmplxdivide.c, one of the few
C files that will endure in the repository, to explain how to build
and run the test.

Change-Id: I1fd5c564a14217e1b9815b09bc24cc43c54c096f
Reviewed-on: https://go-review.googlesource.com/2850
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime: fix *bsd/amd64 build
Matthew Dempsky [Wed, 14 Jan 2015 21:30:34 +0000 (13:30 -0800)]
runtime: fix *bsd/amd64 build

6g does not implement dead code elimination for const switches like it
does for const if statements, so the undefined raiseproc() function
was resulting in a link-time failure.

Change-Id: Ie4fcb3716cb4fe6e618033071df9de545ab3e0af
Reviewed-on: https://go-review.googlesource.com/2830
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agomisc/makerelease: check out core from git repo, use new oauth2 package
Andrew Gerrand [Wed, 14 Jan 2015 10:39:18 +0000 (21:39 +1100)]
misc/makerelease: check out core from git repo, use new oauth2 package

Change-Id: I072cf2b9149a05901cc19e7aeb0e9d0936a8dbe3
Reviewed-on: https://go-review.googlesource.com/2793
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoruntime: delete dead code called from C.
Russ Cox [Wed, 14 Jan 2015 21:41:39 +0000 (16:41 -0500)]
runtime: delete dead code called from C.

printf, vprintf, snprintf, gc_m_ptr, gc_g_ptr, gc_itab_ptr, gc_unixnanotime.

These were called from C.
There is no more C.

Now that vprintf is gone, delete roundup, which is unsafe (see CL 2814).

Change-Id: If8a7b727d497ffa13165c0d3a1ed62abc18f008c
Reviewed-on: https://go-review.googlesource.com/2824
Reviewed-by: Austin Clements <austin@google.com>
10 years agoruntime: avoid race checking for preemption
Russ Cox [Wed, 14 Jan 2015 21:36:41 +0000 (16:36 -0500)]
runtime: avoid race checking for preemption

Moving the "don't really preempt" check up earlier in the function
introduced a race where gp.stackguard0 might change between
the early check and the later one. Since the later one is missing the
"don't really preempt" logic, it could decide to preempt incorrectly.
Pull the result of the check into a local variable and use an atomic
to access stackguard0, to eliminate the race.

I believe this will fix the broken OS X and Solaris builders.

Change-Id: I238350dd76560282b0c15a3306549cbcf390dbff
Reviewed-on: https://go-review.googlesource.com/2823
Reviewed-by: Austin Clements <austin@google.com>
10 years agoruntime: define netpollinited on Plan 9
David du Colombier [Wed, 14 Jan 2015 21:20:03 +0000 (22:20 +0100)]
runtime: define netpollinited on Plan 9

Since CL 2750, the build is broken on Plan 9,
because a new function netpollinited was added
and called from findrunnable in proc1.go.
However, netpoll is not implemented on Plan 9.
Thus, we define netpollinited in netpoll_stub.go.

Fixes #9590

Change-Id: I0895607b86cbc7e94c1bfb2def2b1a368a8efbe6
Reviewed-on: https://go-review.googlesource.com/2759
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoruntime: fix bugs in previous commit
Russ Cox [Wed, 14 Jan 2015 20:48:32 +0000 (15:48 -0500)]
runtime: fix bugs in previous commit

These were fixed in my local commit,
but I forgot that the web Submit button can't see that.

Change-Id: Iec3a70ce3ccd9db2a5394ae2da0b293e45ac2fb5
Reviewed-on: https://go-review.googlesource.com/2822
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime: change tinyalloc, persistentalloc not to point past allocated data
Russ Cox [Wed, 14 Jan 2015 19:13:55 +0000 (14:13 -0500)]
runtime: change tinyalloc, persistentalloc not to point past allocated data

During all.bash I got a crash in the GOMAXPROCS=2 runtime test reporting
that the write barrier in the assignment 'c.tiny = add(x, size)' had been
given a pointer pointing into an unexpected span. The problem is that
the tiny allocation was at the end of a span and c.tiny was now pointing
to the end of the allocation and therefore to the end of the span aka
the beginning of the next span.

Rewrite tinyalloc not to do that.

More generally, it's not okay to call add(p, size) unless you know that p
points at > (not just >=) size bytes. Similarly, pretty much any call to
roundup doesn't know how much space p points at, so those are all
broken.

Rewrite persistentalloc not to use add(p, totalsize) and not to use roundup.

There is only one use of roundup left, in vprintf, which is dead code.
I will remove that code and roundup itself in a followup CL.

Change-Id: I211e307d1a656d29087b8fd40b2b71010722fb4a
Reviewed-on: https://go-review.googlesource.com/2814
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
10 years agoruntime: fix accounting race in printlock
Russ Cox [Wed, 14 Jan 2015 19:57:10 +0000 (14:57 -0500)]
runtime: fix accounting race in printlock

It could happen that mp.printlock++ happens, then on entry to lock,
the goroutine is preempted and then rescheduled onto another m
for the actual call to lock. Now the lock and the printlock++ have
happened on different m's. This can lead to printlock not being
unlocked, which either gives a printing deadlock or a crash when
the goroutine reschedules, because m.locks > 0.

Change-Id: Ib0c08740e1b53de3a93f7ebf9b05f3dceff48b9f
Reviewed-on: https://go-review.googlesource.com/2819
Reviewed-by: Rick Hudson <rlh@golang.org>
10 years ago[dev.cc] build: do not pass GOHOSTOS and GOHOSTARCH to Go 1.4 build
Russ Cox [Wed, 14 Jan 2015 20:14:54 +0000 (15:14 -0500)]
[dev.cc] build: do not pass GOHOSTOS and GOHOSTARCH to Go 1.4 build

Go 1.4 should build what it knows how to build.
GOHOSTOS and GOHOSTARCH are for the Go 1.5 build only.

Change-Id: Id0f367f03485100a896e61cfdace4ac44a22e16d
Reviewed-on: https://go-review.googlesource.com/2818
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoliblink: adjustments for c2go conversion
Russ Cox [Mon, 12 Jan 2015 20:17:10 +0000 (15:17 -0500)]
liblink: adjustments for c2go conversion

Mostly this is using uint32 instead of int32 for unsigned values
like instruction encodings or float32 bit representations,
removal of ternary operations, and removal of #defines.

Delete sched9.c, because it is not compiled (it is still in the history
if we ever need it).

Change-Id: I68579cfea679438a27a80416727a9af932b088ae
Reviewed-on: https://go-review.googlesource.com/2658
Reviewed-by: Austin Clements <austin@google.com>
10 years ago[dev.cc] build: fix cross-compilation
Russ Cox [Wed, 14 Jan 2015 16:50:21 +0000 (11:50 -0500)]
[dev.cc] build: fix cross-compilation

Fixes #9574.

Change-Id: Ifd7ecccb25e934f9aba284b2d72b6b22f18cb0b6
Reviewed-on: https://go-review.googlesource.com/2812
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoruntime: log all thread stack traces during GODEBUG=crash on Linux and OS X
Russ Cox [Wed, 14 Jan 2015 16:18:24 +0000 (11:18 -0500)]
runtime: log all thread stack traces during GODEBUG=crash on Linux and OS X

Normally, a panic/throw only shows the thread stack for the current thread
and all paused goroutines. Goroutines running on other threads, or other threads
running on their system stacks, are opaque. Change that when GODEBUG=crash,
by passing a SIGQUIT around to all the threads when GODEBUG=crash.
If this works out reasonably well, we might make the SIGQUIT relay part of
the standard panic/throw death, perhaps eliding idle m's.

Change-Id: If7dd354f7f3a6e326d17c254afcf4f7681af2f8b
Reviewed-on: https://go-review.googlesource.com/2811
Reviewed-by: Rick Hudson <rlh@golang.org>
10 years agosyscall: match seek argument size to signature
David Crawshaw [Wed, 14 Jan 2015 15:20:58 +0000 (10:20 -0500)]
syscall: match seek argument size to signature

Caught by go vet:
asm_linux_arm.s:110: [arm] seek: wrong argument size 32; expected $...-28

Change-Id: I62ec5327a25bff9ef501c42cc1e28ea7ec78510f
Reviewed-on: https://go-review.googlesource.com/2810
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agoruntime: fix spurious deadlock in netpoll
Dmitry Vyukov [Tue, 13 Jan 2015 17:12:50 +0000 (20:12 +0300)]
runtime: fix spurious deadlock in netpoll

There is a small possibility that runtime deadlocks when netpoll is just activated.
Consider the following scenario:
GOMAXPROCS=1
epfd=-1 (netpoll is not activated yet)
A thread is in findrunnable, sets sched.lastpoll=0, calls netpoll(true),
which returns nil. Now the thread is descheduled for some time.
Then sysmon retakes a P from syscall and calls handoffp.
The "If this is the last running P and nobody is polling network" check in handoffp fails,
since the first thread set sched.lastpoll=0. So handoffp decides that there is already
a thread that polls network and so it calls pidleput.
Now the first thread is scheduled again, finds no work and calls stopm.
There is no thread that polls network and so checkdead reports deadlock.

To fix this, don't set sched.lastpoll=0 when netpoll is not activated.

The deadlock can happen if cgo is disabled (-tag=netgo) and only on program startup
(when netpoll is just activated).

The test is from issue 5216 that lead to addition of the
"If this is the last running P and nobody is polling network" check in handoffp.

Update issue 9576.

Change-Id: I9405f627a4d37bd6b99d5670d4328744aeebfc7a
Reviewed-on: https://go-review.googlesource.com/2750
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agoruntime: rename var checkmark to checkmarkphase
Austin Clements [Mon, 12 Jan 2015 18:45:40 +0000 (13:45 -0500)]
runtime: rename var checkmark to checkmarkphase

The old name was too ambiguous (is it a verb?  is it a predicate?  is
it a constant?) and too close to debug.gccheckmark.  Hopefully the new
name conveys that this variable indicates that we are currently doing
mark checking.

Change-Id: I031cd48b0906cdc7774f5395281d3aeeb8ef3ec9
Reviewed-on: https://go-review.googlesource.com/2656
Reviewed-by: Rick Hudson <rlh@golang.org>
10 years agoruntime: fix a few GC-related bugs
Russ Cox [Tue, 13 Jan 2015 20:55:16 +0000 (15:55 -0500)]
runtime: fix a few GC-related bugs

1) Move non-preemption check even earlier in newstack.
This avoids a few priority inversion problems.

2) Always use atomic operations to update bitmap for 1-word objects.
This avoids lost mark bits during concurrent GC.

3) Stop using work.nproc == 1 as a signal for being single-threaded.
The concurrent GC runs with work.nproc == 1 but other procs are
running mutator code.

The use of work.nproc == 1 in getfull *is* safe, but remove it anyway,
since it is saving only a single atomic operation per GC round.

Fixes #9225.

Change-Id: I24134f100ad592ea8cb59efb6a54f5a1311093dc
Reviewed-on: https://go-review.googlesource.com/2745
Reviewed-by: Rick Hudson <rlh@golang.org>
10 years agocmd/go: adjust error for custom import checkout mismatch
Russ Cox [Wed, 14 Jan 2015 06:23:26 +0000 (01:23 -0500)]
cmd/go: adjust error for custom import checkout mismatch

Before:

...
imports golang.org/x/net/context: /Users/rsc/g/src/golang.org/x/net is from https://code.google.com/p/go.net, should be from https://go.googlesource.com/net

After:

...
imports golang.org/x/net/context: golang.org/x/net is a custom import path for https://go.googlesource.com/net, but /Users/rsc/g/src/golang.org/x/net is checked out from https://code.google.com/p/go.net

Change-Id: I93c35b85f955c7de684f71fbd4baecc717405318
Reviewed-on: https://go-review.googlesource.com/2808
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
10 years agosyscall: use name+(NN)FP for darwin
David Crawshaw [Tue, 13 Jan 2015 19:18:13 +0000 (14:18 -0500)]
syscall: use name+(NN)FP for darwin

Generated from a script using go vet then read by a human.

Change-Id: Ie5f7ab3a1075a9c8defbf5f827a8658e3eb55cab
Reviewed-on: https://go-review.googlesource.com/2746
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agoimage/draw: fold TestClipWithNilMP into TestClip.
Nigel Tao [Mon, 5 Jan 2015 05:08:40 +0000 (16:08 +1100)]
image/draw: fold TestClipWithNilMP into TestClip.

https://go-review.googlesource.com/#/c/1876/ introduced a new
TestClipWithNilMP test, along with a code change that fixed a panic,
but the existing TestClip test already contained almost enough machinery
to cover that bug.

There is a small code change in this CL, but it is a no-op: (*x).y is
equivalent to x.y for a pointer-typed x, but the latter is cleaner.

Change-Id: I79cf6952a4999bc4b91f0a8ec500acb108106e56
Reviewed-on: https://go-review.googlesource.com/2304
Reviewed-by: Dave Cheney <dave@cheney.net>
10 years agoruntime: use runtime.sysargs to parse auxv on linux/arm
Dave Cheney [Sun, 11 Jan 2015 03:40:08 +0000 (03:40 +0000)]
runtime: use runtime.sysargs to parse auxv on linux/arm

Make auxv parsing in linux/arm less of a special case.

* rename setup_auxv to sysargs
* exclude linux/arm from vdso_none.go
* move runtime.checkarm after runtime.sysargs so arm specific
  values are properly initialised

Change-Id: I1ca7f5844ad5a162337ff061a83933fc9a2b5ff6
Reviewed-on: https://go-review.googlesource.com/2681
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agocrypto/x509: add cert SmartOS cert path
Dave Cheney [Mon, 12 Jan 2015 23:43:43 +0000 (10:43 +1100)]
crypto/x509: add cert SmartOS cert path

Fix SmartOS build that was broken in 682922908f7.

SmartOS pretends to be Ubuntu/Debian with respect to its SSL
certificate location.

Change-Id: I5405c6472c8a1e812e472e7301bf6084c17549d6
Reviewed-on: https://go-review.googlesource.com/2704
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoruntime: make windows goenvs look more like Go
Alex Brainman [Tue, 13 Jan 2015 05:43:34 +0000 (16:43 +1100)]
runtime: make windows goenvs look more like Go

Change-Id: I4f84a89553f77382a8064f49db0f5eb575b64313
Reviewed-on: https://go-review.googlesource.com/2714
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agocrypto/tls: remove return parameter stutter
Brad Fitzpatrick [Tue, 13 Jan 2015 19:34:46 +0000 (11:34 -0800)]
crypto/tls: remove return parameter stutter

Per https://golang.org/s/style#named-result-parameters

Change-Id: If69d3e6d3dbef385a0f41e743fa49c25475ca40c
Reviewed-on: https://go-review.googlesource.com/2761
Reviewed-by: Adam Langley <agl@golang.org>
10 years agosort: reduce number of comparisons needed by medianOfThree
Martin Möhrmann [Fri, 9 Jan 2015 22:25:42 +0000 (23:25 +0100)]
sort: reduce number of comparisons needed by medianOfThree

For some cases we can ensure the correct order of elements in two
instead of three comparisons. It is unnecessary to compare m0 and
m1 again if m2 and m1 are not swapped.

benchmark                   old ns/op      new ns/op      delta
BenchmarkSortString1K       302721         299590         -1.03%
BenchmarkSortInt1K          124055         123215         -0.68%
BenchmarkSortInt64K         12291522       12203402       -0.72%
BenchmarkSort1e2            58027          57111          -1.58%
BenchmarkSort1e4            12426805       12341761       -0.68%
BenchmarkSort1e6            1966250030     1960557883     -0.29%

Change-Id: I2b17ff8dee310ec9ab92a6f569a95932538768a9
Reviewed-on: https://go-review.googlesource.com/2614
Reviewed-by: Robert Griesemer <gri@golang.org>
10 years agoreflect: remove extra word in comment
Ian Lance Taylor [Tue, 13 Jan 2015 18:40:15 +0000 (10:40 -0800)]
reflect: remove extra word in comment

Change-Id: I06881fc447a5fae0067557c317f69a0427bed337
Reviewed-on: https://go-review.googlesource.com/2760
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoruntime: move SetErrorMode constants into function so they are not exported
Alex Brainman [Tue, 13 Jan 2015 06:17:53 +0000 (17:17 +1100)]
runtime: move SetErrorMode constants into function so they are not exported

Change-Id: Ib1a2adbcdbd7d96f9b4177abc3c9cf0ab09c1df4
Reviewed-on: https://go-review.googlesource.com/2716
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
10 years agobuild: bootstrap on Plan 9
David du Colombier [Tue, 13 Jan 2015 07:01:18 +0000 (08:01 +0100)]
build: bootstrap on Plan 9

This change implements the requirement of
old Go to build new Go on Plan 9. Also fix
the build of the new cmd/dist written in Go.

This is similar to the make.bash change in
CL 2470, but applied to make.rc for Plan 9.

Change-Id: Ifd9a3bd8658e2cee6f92b4c7f29ce86ee2a93c53
Reviewed-on: https://go-review.googlesource.com/2662
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoruntime: allow fake time writes to both stdout and stderr
Andrew Gerrand [Tue, 13 Jan 2015 05:33:55 +0000 (16:33 +1100)]
runtime: allow fake time writes to both stdout and stderr

In the previous sandbox implementation we read all sandboxed output
from standard output, and so all fake time writes were made to
standard output. Now we have a more sophisticated sandbox server
(see golang.org/x/playground/sandbox) that is capable of recording
both standard output and standard error, so allow fake time writes to
go to either file descriptor.

Change-Id: I79737deb06fd8e0f28910f21f41bd3dc1726781e
Reviewed-on: https://go-review.googlesource.com/2713
Reviewed-by: Minux Ma <minux@golang.org>