]> Cypherpunks repositories - gostls13.git/log
gostls13.git
10 years ago[dev.cc] cmd/asm: make 4(SP) illegal except on 386
Rob Pike [Wed, 18 Feb 2015 02:30:27 +0000 (18:30 -0800)]
[dev.cc] cmd/asm: make 4(SP) illegal except on 386

Require a name to be specified when referencing the pseudo-stack.
If you want a real stack offset, use the hardware stack pointer (e.g.,
R13 on arm), not SP.

Fix affected assembly files.

Change-Id: If3545f187a43cdda4acc892000038ec25901132a
Reviewed-on: https://go-review.googlesource.com/5120
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
10 years ago[dev.cc] cmd/yacc: introduce yyParser to expose parser state
Russ Cox [Thu, 12 Feb 2015 01:37:56 +0000 (20:37 -0500)]
[dev.cc] cmd/yacc: introduce yyParser to expose parser state

Historically, yacc has supported various kinds of inspections
and manipulations of the parser state, exposed as global variables.
The Go implementation of yacc puts that state (properly) in local
stack variables, so it can only be exposed explicitly.

There is now an explicit parser type, yyParser, returned by a
constructor, yyNewParser.

type yyParser interface {
Parse(yyLexer) int
Lookahead() int
}

Parse runs a parse. A call to the top-level func Parse
is equivalent to calling yyNewParser().Parse, but constructing
the parser explicitly makes it possible to access additional
parser methods, such as Lookahead.

Lookahead can be called during grammar actions to read
(but not consume) the value of the current lookahead token,
as returned by yylex.Lex. If there is no current lookahead token,
Lookahead returns -1. Invoking Lookahead corresponds to
reading the global variable yychar in a traditional Unix yacc grammar.

To support Lookahead, the internal parsing code now separates
the return value from Lex (yychar) from the reencoding used
by the parsing tables (yytoken). This has the effect that grammars
that read yychar directly in the action (possible since the actions
are in the same function that declares yychar) now correctly see values
from the Lex return value space, not the internal reencoding space.
This can fix bugs in ported grammars not even using SetParse and Lookahead.
(The reencoding was added on Plan 9 for large character sets.
No Plan 9 programs using yacc looked at yychar.)

Other methods may be added to yyParser later as needed.
Obvious candidates include equivalents for the traditional
yyclearin and yyerrok macros.

Change-Id: Iaf7649efcf97e09f44d1f5bc74bb563a11f225de
Reviewed-on: https://go-review.googlesource.com/4850
Reviewed-by: Rob Pike <r@golang.org>
10 years ago[dev.cc] cmd/asm/internal/asm: add operand parsing tests for 386 and arm
Rob Pike [Wed, 18 Feb 2015 01:23:13 +0000 (17:23 -0800)]
[dev.cc] cmd/asm/internal/asm: add operand parsing tests for 386 and arm

Change-Id: If2aafc4dd3f91650fc7727ea7d534ad7aa627c8c
Reviewed-on: https://go-review.googlesource.com/5090
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] cmd/internal/gc, cmd/new6g etc: convert from cmd/gc, cmd/6g etc
Russ Cox [Fri, 13 Feb 2015 19:40:36 +0000 (14:40 -0500)]
[dev.cc] cmd/internal/gc, cmd/new6g etc: convert from cmd/gc, cmd/6g etc

First draft of converted Go compiler, using rsc.io/c2go rev 83d795a.

Change-Id: I29f4c7010de07d2ff1947bbca9865879d83c32c3
Reviewed-on: https://go-review.googlesource.com/4851
Reviewed-by: Rob Pike <r@golang.org>
10 years ago[dev.cc] cmd/go: install new6g etc (once they are committed) to tool directory
Russ Cox [Fri, 13 Feb 2015 19:43:08 +0000 (14:43 -0500)]
[dev.cc] cmd/go: install new6g etc (once they are committed) to tool directory

Change-Id: I2853535ab6c79d14f430c780161e4c35c52d9fb3
Reviewed-on: https://go-review.googlesource.com/4839
Reviewed-by: Rob Pike <r@golang.org>
10 years ago[dev.cc] cmd/gc, cmd/ld, runtime: minor tweaks for c2go
Russ Cox [Fri, 13 Feb 2015 19:42:31 +0000 (14:42 -0500)]
[dev.cc] cmd/gc, cmd/ld, runtime: minor tweaks for c2go

Change-Id: I3be69a4ebf300ad24b55b5f43fd7ad1f001c762e
Reviewed-on: https://go-review.googlesource.com/4838
Reviewed-by: Rob Pike <r@golang.org>
10 years ago[dev.cc] cmd/dist: write default GO386 for cmd/internal/obj
Russ Cox [Fri, 6 Feb 2015 10:57:42 +0000 (05:57 -0500)]
[dev.cc] cmd/dist: write default GO386 for cmd/internal/obj

Change-Id: Ida60c30041505c321fbfc48b22b8ff5af1a3f474
Reviewed-on: https://go-review.googlesource.com/4837
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
10 years ago[dev.cc] cmd/asm: clean up jumps
Rob Pike [Tue, 17 Feb 2015 22:49:04 +0000 (14:49 -0800)]
[dev.cc] cmd/asm: clean up jumps

Set TYPE_BRANCH for x(PC) in the parser and the assembler has less work to do.
This also makes the operand test handle -4(PC) correctly.

Also add a special test case for AX:DX, which should be fixed in obj really.

Change-Id: If195e3a8cf3454a73508633e9b317d66030da826
Reviewed-on: https://go-review.googlesource.com/5071
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] misc/cgo/test: fix PC reference in arm assembler
Rob Pike [Tue, 17 Feb 2015 21:37:06 +0000 (13:37 -0800)]
[dev.cc] misc/cgo/test: fix PC reference in arm assembler

Use R15.
May fix build.

Change-Id: Ia25b0936c5aab2a427f8e6531688c3e537fbfdd0
Reviewed-on: https://go-review.googlesource.com/5070
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] cmd/asm/internal/asm: add operand parsing test
Rob Pike [Tue, 17 Feb 2015 19:21:57 +0000 (11:21 -0800)]
[dev.cc] cmd/asm/internal/asm: add operand parsing test

Generated by reducing all the amd64 operands in the core.
Will add 386 and ARM later; this is a trial balloon.

NOTE: There is at least one anomaly: AX:DX doesn't print correctly in this situation.

Change-Id: I9f327c1890b100e3edb7b1b2a1c01f3e4b798f43
Reviewed-on: https://go-review.googlesource.com/4967
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] runtime/cgo: change PC to R15 in asm_arm.s
Rob Pike [Tue, 17 Feb 2015 17:49:57 +0000 (09:49 -0800)]
[dev.cc] runtime/cgo: change PC to R15 in asm_arm.s

R15 is the real register. PC is a pseudo-register that we are making
illegal in this context as part of the grand assembly unification.

Change-Id: Ie0ea38ce7ef4d2cf4fcbe23b851a570fd312ce8d
Reviewed-on: https://go-review.googlesource.com/4966
Reviewed-by: Minux Ma <minux@golang.org>
10 years ago[dev.cc] cmd/asm: fix build: handle g in register lists on ARM
Rob Pike [Tue, 17 Feb 2015 16:24:08 +0000 (08:24 -0800)]
[dev.cc] cmd/asm: fix build: handle g in register lists on ARM

Handle the special name of R10 on the ARM - it's g - when it appears
in a register list [R0, g, R3]. Also simplify the pseudo-register parsing
a little.

Should fix the ARM build.

Change-Id: Ifcafc8195dcd3622653b43663ced6e4a144a3e51
Reviewed-on: https://go-review.googlesource.com/4965
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] runtime: remove comma at the end of DIVL instruction (fixes windows build)
Alex Brainman [Tue, 17 Feb 2015 05:48:31 +0000 (16:48 +1100)]
[dev.cc] runtime: remove comma at the end of DIVL instruction (fixes windows build)

Change-Id: Ia47e1e387acd30f30559d766aa6fca18cbb098f9
Reviewed-on: https://go-review.googlesource.com/5010
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years ago[dev.cc] cmd/go: enable verifyAsm for asm on ARM
Rob Pike [Sun, 15 Feb 2015 23:45:06 +0000 (15:45 -0800)]
[dev.cc] cmd/go: enable verifyAsm for asm on ARM

Change-Id: I182ea770110255a5ac1c91cf30dd650696a8f1db
Reviewed-on: https://go-review.googlesource.com/4961
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] cmd/asm: fix build for x86 architectures
Rob Pike [Tue, 17 Feb 2015 04:42:55 +0000 (20:42 -0800)]
[dev.cc] cmd/asm: fix build for x86 architectures

Mishandled the complex addressing mode in masks<>(SB)(CX*8)
as a casualty of the ARM work. Fix by backing all the flows up to
the state where registerIndirect is always called with the input
sitting on the opening paren.

With this, build passes for me with linux-arm, linux-386, and linux-amd64.

Change-Id: I7cae69a6fa9b635c79efd93850bd1e744b22bc79
Reviewed-on: https://go-review.googlesource.com/4964
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] cmd/internal/asm: fix build: was mishandling SP reference on amd64
Rob Pike [Tue, 17 Feb 2015 04:14:37 +0000 (20:14 -0800)]
[dev.cc] cmd/internal/asm: fix build: was mishandling SP reference on amd64

A consequence of the ARM work overlooked that SP is a real register
on x86, so we need to detect it specially.

This will be done better soon, but this is a fast fix for the build.

Change-Id: Ia30d111c3f42a5f0b5f4eddd4cc4d8b10470c14f
Reviewed-on: https://go-review.googlesource.com/4963
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] cmd/internal/obj/arm: delete trailing space from AND instruction
Rob Pike [Tue, 17 Feb 2015 03:50:35 +0000 (19:50 -0800)]
[dev.cc] cmd/internal/obj/arm: delete trailing space from AND instruction

The tools have been fixed to not do this, but verifyAsm depends on this
being fixed.

TBR=rsc

Change-Id: Ia8968cc803b3498dfa2f98188c6ed1cf2e11c66d
Reviewed-on: https://go-review.googlesource.com/4962
Reviewed-by: Rob Pike <r@golang.org>
10 years ago[dev.cc] cmd/internal/obj/arm: add a couple of missing settings of Ctxt
Rob Pike [Sun, 15 Feb 2015 23:37:28 +0000 (15:37 -0800)]
[dev.cc] cmd/internal/obj/arm: add a couple of missing settings of Ctxt

Change-Id: Ic33431cdcc93db300fc2c3467eafdb5340ee4896
Reviewed-on: https://go-review.googlesource.com/4924
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] cmd/asm: support ARM
Rob Pike [Sat, 14 Feb 2015 01:01:43 +0000 (17:01 -0800)]
[dev.cc] cmd/asm: support ARM

There are many peculiarites of the ARM architecture that require work:
condition codes, new instructions, new instruction arg counts, and more.

Rewrite the parser to do a cleaner job, flowing left to right through the
sequence of elements of an operand.

Add ARM to arch.
Add ARM-specific details to the arch in a new file, internal/arch/arm.
These are probably better kept away from the "portable" asm. However
there are some pieces, like MRC, that are hard to disentangle. They
can be cleaned up later.

Change-Id: I8c06aedcf61f8a3960a406c094e168182d21b972
Reviewed-on: https://go-review.googlesource.com/4923
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] cmd/asm: fix macro definition bug in the lexer
Rob Pike [Sat, 14 Feb 2015 00:55:33 +0000 (16:55 -0800)]
[dev.cc] cmd/asm: fix macro definition bug in the lexer

Because text/scanner hides the spaces, the lexer treated
#define A(x)
and
#define A (x)
the same, but they are not: the first is an argument with macros, the
second is a simple one-word macro whose definition contains parentheses.
Fix this by noticing the relative column number as we move from A to (.
Hacky but simple.

Also add a helper to recognize the peculiar ARM shifted register operators.

Change-Id: I2cad22f5f1e11d8dad40ad13955793d178afb3ae
Reviewed-on: https://go-review.googlesource.com/4872
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] crypto/md5: fix arm assembler in md5block_arm.s
Rob Pike [Sat, 14 Feb 2015 00:06:28 +0000 (16:06 -0800)]
[dev.cc] crypto/md5: fix arm assembler in md5block_arm.s

The mechanical edit in the last round managed to miss ROUND1, among
other indgnities.

Change-Id: Ie3e19d00435a9e701b9872167e4bc7756a9fb5a5
Reviewed-on: https://go-review.googlesource.com/4870
Reviewed-by: Minux Ma <minux@golang.org>
10 years ago[dev.cc] doc/go1.5.txt: assembler changes
Rob Pike [Fri, 13 Feb 2015 23:12:03 +0000 (15:12 -0800)]
[dev.cc] doc/go1.5.txt: assembler changes

Change-Id: Id544d435620efffaf5757dd9d9ebbc6e969a052c
Reviewed-on: https://go-review.googlesource.com/4823
Reviewed-by: Rob Pike <r@golang.org>
10 years ago[dev.cc] all: edit assembly source for ARM to be more regular
Rob Pike [Fri, 13 Feb 2015 22:21:18 +0000 (14:21 -0800)]
[dev.cc] all: edit assembly source for ARM to be more regular

Several .s files for ARM had several properties the new assembler will not support.
These include:

- mentioning SP or PC as a hardware register
These are always pseudo-registers except that in some contexts
they're not, and it's confusing because the context should not affect
which register you mean. Change the references to the hardware
registers to be explicit: R13 for SP, R15 for PC.
- constant creation using assignment
The files say a=b when they could instead say #define a b.
There is no reason to have both mechanisms.
- R(0) to refer to R0.
Some macros use this to a great extent. Again, it's easy just to
use a #define to rename a register.

Change-Id: I002335ace8e876c5b63c71c2560533eb835346d2
Reviewed-on: https://go-review.googlesource.com/4822
Reviewed-by: Dave Cheney <dave@cheney.net>
10 years ago[dev.cc] liblink: disable GOOBJ=2 default
Russ Cox [Fri, 23 Jan 2015 19:18:31 +0000 (14:18 -0500)]
[dev.cc] liblink: disable GOOBJ=2 default

The point of GOOBJ=2 was to have an active test of the cmd/internal/obj code.
Now we have end-to-end tests of the assembler, and soon the compiler,
so we don't need this halfway test on by default anymore.
(It's still possible to enable during debugging with the
environment variable.)

The problem it causes on the builders is that this particular testing
mode ends up with both the C process and the Go objwriter subprocess
having the same very large Prog list in memory simultaneously,
which causes basically a 2x memory blowup. In large programs
(such as the one generated by test/rotate.go) this is significant.

Disabling GOOBJ=2 should help with the current dev.cc builder
failures.

Change-Id: I1b11e4f29ea575659f02d2234242a904f7c867e4
Reviewed-on: https://go-review.googlesource.com/4832
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years ago[dev.cc] all: merge master (5f1efe7) into dev.cc
Russ Cox [Fri, 13 Feb 2015 17:50:23 +0000 (12:50 -0500)]
[dev.cc] all: merge master (5f1efe7) into dev.cc

Conflicts:
src/cmd/dist/build.go

Change-Id: I98a4b5e010bee91507b85bb8efd9c74e1a1f649c

10 years agocmd/ld: make cmd/ld a real library
Russ Cox [Thu, 12 Feb 2015 03:27:49 +0000 (22:27 -0500)]
cmd/ld: make cmd/ld a real library

Make cmd/ld a real library invoked by the individual linkers.
There are no reverse symbol references anymore
(symbols referred to in cmd/ld but defined in cmd/5l etc).

This means that in principle we could do an automatic
conversion of these to Go, as a stopgap until cmd/link is done
or as a replacement for cmd/link.

Change-Id: I4a94570257a3a7acc31601bfe0fad9dea0aea054
Reviewed-on: https://go-review.googlesource.com/4649
Reviewed-by: Rob Pike <r@golang.org>
10 years agocmd/dist: avoid trailing space in instruction name strings
Russ Cox [Thu, 12 Feb 2015 03:39:21 +0000 (22:39 -0500)]
cmd/dist: avoid trailing space in instruction name strings

Change-Id: I2db4db852492eaddaf09dd7bae2fbd49f916e78a
Reviewed-on: https://go-review.googlesource.com/4648
Reviewed-by: Rob Pike <r@golang.org>
10 years agocmd/gc: minor adjustments for C to Go translation
Russ Cox [Thu, 5 Feb 2015 16:53:33 +0000 (11:53 -0500)]
cmd/gc: minor adjustments for C to Go translation

- remove a few uses of ? :
- rename variables named len
- rewrite a few gotos as nested switches
- move goto targets to scope allowed by Go
- use consistent return type of anyregalloc
  (was int or int32 in different places)
- remove unused nr variable in agen
- include proper headers in generated builtin1.c
- avoid strange sized %E formats (%-6E, %2E)
- change gengcmask argument from uint8[16] to uint8*
  (diagnosed by c2go; not an array in any real sense).
- replace #ifdef XXX with comment block in 5g/peep.c
- expand and remove FAIL macro from 5g
- expand and remove noimpl macro from 9g
- print regalloc errors to stdout in 8g
  (only use of fprint(2, ...) in all compilers)

Still producing bit-for-bit identical output.

Change-Id: Id46efcd2a89241082b234f63f375b66f2754d695
Reviewed-on: https://go-review.googlesource.com/4646
Reviewed-by: Austin Clements <austin@google.com>
10 years agocmd/gc: eliminate some pointer arithmetic
Russ Cox [Thu, 5 Feb 2015 15:47:44 +0000 (10:47 -0500)]
cmd/gc: eliminate some pointer arithmetic

In mparith, all the a1-- are problematic. Rewrite it all without pointers.
It's clearer anyway.

In popt, v is problematic because it is used both as a fixed pointer
(v = byvar[i]) and as a moving pointer (v = var; v++) aka slice.
Eliminate pointer movement.

Tested that this still produces bit-for-bit output for 'go build -a std'
compared to d260756 (current master).

Change-Id: I1a1bed0f98b594c3864fe95075dd95f9b52113e0
Reviewed-on: https://go-review.googlesource.com/4645
Reviewed-by: Austin Clements <austin@google.com>
10 years agocmd/gc: rename arch to thearch
Russ Cox [Thu, 5 Feb 2015 16:55:51 +0000 (11:55 -0500)]
cmd/gc: rename arch to thearch

Otherwise the exported variable collides with the type Arch.

While we're here, remove arch.dumpit (now in portable code)
and add arch.defframe (forgotten originally, somehow).

Change-Id: I1b3a7dd7e96c5f632dba7cd6c1217b42a2004d72
Reviewed-on: https://go-review.googlesource.com/4644
Reviewed-by: Austin Clements <austin@google.com>
10 years agocmd/gc: add .y to error about missing x in x.y
Russ Cox [Thu, 5 Feb 2015 17:31:13 +0000 (12:31 -0500)]
cmd/gc: add .y to error about missing x in x.y

If the Go source says x.y, and x is undefined, today we get

undefined: x

Change to:

undefined: x in x.y

Change-Id: I8ea95503bd469ea933c6bcbd675b7122a5d454f3
Reviewed-on: https://go-review.googlesource.com/4643
Reviewed-by: Austin Clements <austin@google.com>
10 years agocmd/gc: add debugging to liveness analysis
Russ Cox [Wed, 11 Feb 2015 00:27:49 +0000 (19:27 -0500)]
cmd/gc: add debugging to liveness analysis

Even with debugmerge = 1, the debugging output only happens
with the -v command-line flag. This is useful because it gets added
in automatically when debugging things like registerization with -R -v.

Change-Id: I9a5c7f562507b72e8e2fe2686fd07d069721345a
Reviewed-on: https://go-review.googlesource.com/4641
Reviewed-by: Austin Clements <austin@google.com>
10 years agocmd/gc: correct errors in constant parsing
Russ Cox [Wed, 11 Feb 2015 04:49:26 +0000 (23:49 -0500)]
cmd/gc: correct errors in constant parsing

Change-Id: I36f77e7ac7f727d8f3b51133f4b3ef93c35b09f6
Reviewed-on: https://go-review.googlesource.com/4640
Reviewed-by: Austin Clements <austin@google.com>
10 years agocmd/gc: avoid writing past end of region array
Russ Cox [Fri, 13 Feb 2015 16:54:15 +0000 (11:54 -0500)]
cmd/gc: avoid writing past end of region array

Noticed last week.
Just saw a strange build failure in the revised rcmp (called by qsort on region)
and this fixed it.

Submitting first to avoid finding out which of my pending CLs tickled the
problem.

Change-Id: I4cafd611e2bf8e813e57ad0025e48bde5ae54359
Reviewed-on: https://go-review.googlesource.com/4830
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/yacc: adjust expansion of $n to be more useful in errors
Russ Cox [Fri, 6 Feb 2015 18:48:42 +0000 (13:48 -0500)]
cmd/yacc: adjust expansion of $n to be more useful in errors

When the compiler echoes back an expression, it shows the
generated yacc expression. Change the generated code to
use a slice so that $3 shows up as yyDollar[3] in such messages.

Consider changing testdata/expr/expr.y to say:

$$.Sub(float64($1), $3)

(The float64 conversion is incorrect.)

Before:
expr.y:70[expr.go:486]: cannot convert exprS[exprpt - 2].num (type *big.Rat) to type float64

After:
expr.y:70[expr.go:492]: cannot convert exprDollar[1].num (type *big.Rat) to type float64

Change-Id: I74e494069df588e62299d1fccb282f3658d8f8f4
Reviewed-on: https://go-review.googlesource.com/4630
Reviewed-by: Rob Pike <r@golang.org>
10 years agoencoding/xml: encoding name spaces correctly
Roger Peppe [Sat, 10 Jan 2015 14:00:21 +0000 (14:00 +0000)]
encoding/xml: encoding name spaces correctly

The current XML printer does not understand the xmlns
attribute. This change changes it so that it interprets the
xmlns attributes in the tokens being printed, and uses
appropriate prefixes.

Fixes #7535.

Change-Id: I20fae291d20602d37deb41ed42fab4c9a50ec85d
Reviewed-on: https://go-review.googlesource.com/2660
Reviewed-by: Nigel Tao <nigeltao@golang.org>
10 years agoruntime: fix stack corruption in race mode
Dmitry Vyukov [Fri, 13 Feb 2015 14:14:48 +0000 (17:14 +0300)]
runtime: fix stack corruption in race mode

MOVQ RARG0, 0(SP) smashes exactly what was saved by PUSHQ R15.
This code managed to work somehow with the current race runtime,
but corrupts caller arguments with new race runtime that I am testing.

Change-Id: I9ffe8b5eee86451db36e99dbf4d11f320192e576
Reviewed-on: https://go-review.googlesource.com/4810
Reviewed-by: Keith Randall <khr@golang.org>
10 years agoruntime/race: fix test in preparation for new race runtime
Dmitry Vyukov [Fri, 13 Feb 2015 14:19:33 +0000 (17:19 +0300)]
runtime/race: fix test in preparation for new race runtime

New race runtime is more scrupulous about env flags format.

Change-Id: I2828bc737a8be3feae5288ccf034c52883f224d8
Reviewed-on: https://go-review.googlesource.com/4811
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoruntime: rename drainworkbuf and drainobjects
Austin Clements [Thu, 12 Feb 2015 20:39:29 +0000 (15:39 -0500)]
runtime: rename drainworkbuf and drainobjects

drainworkbuf is now gcDrain, since it drains until there's
nothing left to drain.  drainobjects is now gcDrainN because it's
the bounded equivalent to gcDrain.

The new names use the Go camel case convention because we have to
start somewhere.  The "gc" prefix is because we don't have runtime
packages yet and just "drain" is too ambiguous.

Change-Id: I88dbdf32e8ce4ce6c3b7e1f234664be9b76cb8fd
Reviewed-on: https://go-review.googlesource.com/4785
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
10 years agoruntime: remove drainallwbufs argument to drainworkbuf
Austin Clements [Thu, 12 Feb 2015 20:30:08 +0000 (15:30 -0500)]
runtime: remove drainallwbufs argument to drainworkbuf

All calls to drainworkbuf now pass true for this argument, so remove
the argument and update the documentation to reflect the simplified
interface.

At a higher level, there are no longer any situations where we drain
"one wbuf" (though drainworkbuf didn't guarantee this anyway).  We
either drain everything, or we drain a specific number of objects.

Change-Id: Ib7ee0fde56577eff64232ee1e711ec57c4361335
Reviewed-on: https://go-review.googlesource.com/4784
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
10 years agoruntime: eliminate drainworkbufs from scanblock
Austin Clements [Thu, 12 Feb 2015 20:22:49 +0000 (15:22 -0500)]
runtime: eliminate drainworkbufs from scanblock

scanblock is only called during _GCscan and _GCmarktermination.
During _GCscan, scanblock didn't call drainworkbufs anyway.  During
_GCmarktermination, there's really no point in draining some (largely
arbitrary) amount of work during the scanblock, since the GC is about
to drain everything anyway, so simply eliminate this case.

Change-Id: I7f3c59ce9186a83037c6f9e9b143181acd04c597
Reviewed-on: https://go-review.googlesource.com/4783
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime: eliminate b == 0 special case from scanblock
Austin Clements [Thu, 12 Feb 2015 20:20:13 +0000 (15:20 -0500)]
runtime: eliminate b == 0 special case from scanblock

We no longer ever call scanblock with b == 0.

Change-Id: I9b01da39595e0cc251668c24d58748d88f5f0792
Reviewed-on: https://go-review.googlesource.com/4782
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
10 years agoruntime: replace scanblock(0, 0, nil, nil) with drainworkbuf
Austin Clements [Thu, 12 Feb 2015 20:05:55 +0000 (15:05 -0500)]
runtime: replace scanblock(0, 0, nil, nil) with drainworkbuf

scanblock(0, 0, nil, nil) was just a confusing way of saying

  wbuf = getpartialorempty()
  drainworkbuf(wbuf, true)

Make drainworkbuf accept a nil workbuf and perform the
getpartialorempty itself and replace all uses of scanblock(0, 0, nil,
nil) with direct calls to drainworkbuf(nil, true).

Change-Id: I7002a2f8f3eaf6aa85bbf17ccc81d7288acfef1c
Reviewed-on: https://go-review.googlesource.com/4781
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
10 years agoruntime: move checknocurrentwbuf() from scanblock to drainworkbuf
Austin Clements [Thu, 12 Feb 2015 20:00:54 +0000 (15:00 -0500)]
runtime: move checknocurrentwbuf() from scanblock to drainworkbuf

Previously, scanblock called checknocurrentwbuf() after
drainworkbuf().  Move this call into drainworkbuf so that every return
path from drainworkbuf calls checknocurrentwbuf().  This is equivalent
to the previous code because scanblock was the only caller of
drainworkbuf.

Change-Id: I96ef2168c8aa169bfc4d368f296342fa0fbeafb4
Reviewed-on: https://go-review.googlesource.com/4780
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
10 years agocmd/gc: transform closure calls to function calls
Dmitry Vyukov [Fri, 6 Feb 2015 12:09:46 +0000 (15:09 +0300)]
cmd/gc: transform closure calls to function calls

Currently we always create context objects for closures that capture variables.
However, it is completely unnecessary for direct calls of closures
(whether it is func()(), defer func()() or go func()()).
This change transforms any OCALLFUNC(OCLOSURE) to normal function call.
Closed variables become function arguments.
This transformation is especially beneficial for go func(),
because we do not need to allocate context object on heap.
But it makes direct closure calls a bit faster as well (see BenchmarkClosureCall).

On implementation level it required to introduce yet another compiler pass.
However, the pass iterates only over xtop, so it should not be an issue.
Transformation consists of two parts: closure transformation and call site
transformation. We can't run these parts on different sides of escape analysis,
because tree state is inconsistent. We can do both parts during typecheck,
we don't know how to capture variables and don't have call site.
We can't do both parts during walk of OCALLFUNC, because we can walk
OCLOSURE body earlier.
So now capturevars pass only decides how to capture variables
(this info is required for escape analysis). New transformclosure
pass, that runs just before order/walk, does all transformations
of a closure. And later walk of OCALLFUNC(OCLOSURE) transforms call site.

benchmark                            old ns/op     new ns/op     delta
BenchmarkClosureCall                 4.89          3.09          -36.81%
BenchmarkCreateGoroutinesCapture     1634          1294          -20.81%

benchmark                            old allocs     new allocs     delta
BenchmarkCreateGoroutinesCapture     6              2              -66.67%

benchmark                            old bytes     new bytes     delta
BenchmarkCreateGoroutinesCapture     176           48            -72.73%

Change-Id: Ic85e1706e18c3235cc45b3c0c031a9c1cdb7a40e
Reviewed-on: https://go-review.googlesource.com/4050
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/go: make consistent use of leading Tabs
Shenghou Ma [Sun, 8 Feb 2015 23:09:23 +0000 (18:09 -0500)]
cmd/go: make consistent use of leading Tabs

The only remaining uses of four spaces instead of a tab is
when the line is too long (e.g. type Package).

Fixes #9809

Change-Id: Ifffd3639aa9264e795686ef1879a7686f182d2e5
Reviewed-on: https://go-review.googlesource.com/4182
Reviewed-by: Andrew Gerrand <adg@golang.org>
10 years agocmd/gc: restore amd64p32 hack for bucket size
Dmitry Vyukov [Thu, 12 Feb 2015 19:31:27 +0000 (22:31 +0300)]
cmd/gc: restore amd64p32 hack for bucket size

This was accidentially removed in:
https://go-review.googlesource.com/#/c/3508/8/src/cmd/gc/reflect.c

Change-Id: I06dd5bb0cb3e2811bd4ef605d7a5225cfa033fe0
Reviewed-on: https://go-review.googlesource.com/4731
Reviewed-by: Keith Randall <khr@golang.org>
10 years agoruntime: cleanup after conversion to Go
Dmitry Vyukov [Thu, 12 Feb 2015 07:18:31 +0000 (10:18 +0300)]
runtime: cleanup after conversion to Go

Change-Id: I7c41cc6a5ab9fb3b0cc3812cf7e9776884658778
Reviewed-on: https://go-review.googlesource.com/4671
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agocmd/5g, cmd/6g, cmd/8g, cmd/9g: use a register to zero in componentgen
Josh Bleecher Snyder [Fri, 9 Jan 2015 20:26:48 +0000 (12:26 -0800)]
cmd/5g, cmd/6g, cmd/8g, cmd/9g: use a register to zero in componentgen

Using a zero register results in shorter, faster code.
5g already did this. Bring 6g, 8g, and 9g up to speed.
Reduces godoc binary size by 0.29% using 6g.

This CL includes cosmetic changes to 5g and 8g.
With those cosmetic changes included, componentgen is now
character-for-character equivalent across the four architectures.

Change-Id: I0e13dd48374bad830c725b117a1c86d4197d390c
Reviewed-on: https://go-review.googlesource.com/2606
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>

10 years agocmd/5g, cmd/6g, cmd/8g, cmd/9g: zero more in componentgen
Josh Bleecher Snyder [Fri, 9 Jan 2015 19:57:51 +0000 (11:57 -0800)]
cmd/5g, cmd/6g, cmd/8g, cmd/9g: zero more in componentgen

Fix a flipped nil check.
The flipped check prevented componentgen
from zeroing a non-cadable nl.
This fix reduces the number of non-SB LEAQs
in godoc from 35323 to 34920 (-1.1%).

Update #1914

Change-Id: I15ea303068835f606f883ddf4a2bb4cb2287e9ae
Reviewed-on: https://go-review.googlesource.com/2605
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>

10 years agocmd/gc: evaluate concrete == interface without allocating
Josh Bleecher Snyder [Wed, 24 Dec 2014 02:28:02 +0000 (18:28 -0800)]
cmd/gc: evaluate concrete == interface without allocating

Consider an interface value i of type I and concrete value c of type C.

Prior to this CL, i==c was evaluated as
I(c) == i

Evaluating I(c) can allocate.

This CL changes the evaluation of i==c to
x, ok := i.(C); ok && x == c

The new generated code is shorter and does not allocate directly.

If C is small, as it is in every instance in the stdlib,
the new code also uses less stack space
and makes one runtime call instead of two.

If C is very large, the original implementation is used.
The cutoff for "very large" is 1<<16,
following the stack vs heap cutoff used elsewhere.

This kind of comparison occurs in 38 places in the stdlib,
mostly in the net and os packages.

benchmark                     old ns/op     new ns/op     delta
BenchmarkEqEfaceConcrete      29.5          7.92          -73.15%
BenchmarkEqIfaceConcrete      32.1          7.90          -75.39%
BenchmarkNeEfaceConcrete      29.9          7.90          -73.58%
BenchmarkNeIfaceConcrete      35.9          7.90          -77.99%

Fixes #9370.

Change-Id: I7c4555950bcd6406ee5c613be1f2128da2c9a2b7
Reviewed-on: https://go-review.googlesource.com/2096
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>

10 years agocmd/6g, cmd/8g: make 2/3 word sgen more efficient
Josh Bleecher Snyder [Fri, 9 Jan 2015 20:41:47 +0000 (12:41 -0800)]
cmd/6g, cmd/8g: make 2/3 word sgen more efficient

When compiling the stdlib most of the calls
to sgen are for exactly 2 or 3 words:
85% for 6g and 70% for 8g.
Special case them for performance.
This optimization is not relevant to 5g and 9g.

6g

benchmark                old ns/op     new ns/op     delta
BenchmarkCopyFat16       3.25          0.82          -74.77%
BenchmarkCopyFat24       5.47          0.95          -82.63%

8g

benchmark               old ns/op     new ns/op     delta
BenchmarkCopyFat8       3.84          2.42          -36.98%
BenchmarkCopyFat12      4.94          2.15          -56.48%

Change-Id: I8bc60b453f12597dfd916df2d072a7d5fc33ab85
Reviewed-on: https://go-review.googlesource.com/2607
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>

10 years agocmd/6g: allocate fewer new registers in sgen
Josh Bleecher Snyder [Fri, 9 Jan 2015 21:03:55 +0000 (13:03 -0800)]
cmd/6g: allocate fewer new registers in sgen

When possible, generate nodl/nodr directly into DI/SI
rather than going through a temporary register.

CX has already been saved; use it during trailing bytes cleanup.

Change-Id: I4ec6209bcc5d3bfdc927c5c132009bd8d791ada3
Reviewed-on: https://go-review.googlesource.com/2608
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>

10 years agomath/big: implemented Float.Int64, simplified Float.Uint64
Robert Griesemer [Wed, 11 Feb 2015 19:22:45 +0000 (11:22 -0800)]
math/big: implemented Float.Int64, simplified Float.Uint64

Change-Id: Ic270ffa7ec6f6dd4b0a951c64ad965447cce1417
Reviewed-on: https://go-review.googlesource.com/4571
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agoruntime: move wbuf-related functions to new gcwork.go
Austin Clements [Thu, 12 Feb 2015 14:58:25 +0000 (09:58 -0500)]
runtime: move wbuf-related functions to new gcwork.go

No code modifications.

This is in preparation for improving the wbuf abstraction.

Change-Id: I719543a345c34d079b7e39b251eccd5dd8a07826
Reviewed-on: https://go-review.googlesource.com/4710
Reviewed-by: Rick Hudson <rlh@golang.org>
10 years agoruntime: on Plan 9, zero memory returned to the brk by sysFree
Austin Clements [Thu, 12 Feb 2015 15:37:01 +0000 (10:37 -0500)]
runtime: on Plan 9, zero memory returned to the brk by sysFree

Plan 9's sysFree has an optimization where if the object being freed
is the last object allocated, it will roll back the brk to allow the
memory to be reused by sysAlloc.  However, it does not zero this
"returned" memory, so as a result, sysAlloc can return non-zeroed
memory after a sysFree.  This leads to corruption because the runtime
assumes sysAlloc returns zeroed memory.

Fix this by zeroing the memory returned by sysFree.

Fixes #9846.

Change-Id: Id328c58236eb7c464b31ac1da376a0b757a5dc6a
Reviewed-on: https://go-review.googlesource.com/4700
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: David du Colombier <0intro@gmail.com>
10 years agodoc: update pre-requisites for bootstrapping
Andrew Gerrand [Wed, 11 Feb 2015 01:44:50 +0000 (12:44 +1100)]
doc: update pre-requisites for bootstrapping

Change-Id: Id86994c8692e29f9d073b6322733ce9219887dc3
Reviewed-on: https://go-review.googlesource.com/4520
Run-TryBot: Andrew Gerrand <adg@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
10 years agocmd/gc: allocate non-escaping maps on stack
Dmitry Vyukov [Thu, 29 Jan 2015 16:40:02 +0000 (19:40 +0300)]
cmd/gc: allocate non-escaping maps on stack

Extend escape analysis to make(map[k]v).
If it does not escape, allocate temp buffer for hmap and one bucket on stack.

There are 75 cases of non-escaping maps in std lib.

benchmark                                    old allocs     new allocs     delta
BenchmarkConcurrentStmtQuery                 16161          15161          -6.19%
BenchmarkConcurrentTxQuery                   17658          16658          -5.66%
BenchmarkConcurrentTxStmtQuery               16157          15156          -6.20%
BenchmarkConcurrentRandom                    13637          13114          -3.84%
BenchmarkManyConcurrentQueries               22             20             -9.09%
BenchmarkDecodeComplex128Slice               250            188            -24.80%
BenchmarkDecodeFloat64Slice                  250            188            -24.80%
BenchmarkDecodeInt32Slice                    250            188            -24.80%
BenchmarkDecodeStringSlice                   2250           2188           -2.76%
BenchmarkNewEmptyMap                         1              0              -100.00%
BenchmarkNewSmallMap                         2              0              -100.00%

benchmark                old ns/op     new ns/op     delta
BenchmarkNewEmptyMap     124           55.7          -55.08%
BenchmarkNewSmallMap     317           148           -53.31%

benchmark                old allocs     new allocs     delta
BenchmarkNewEmptyMap     1              0              -100.00%
BenchmarkNewSmallMap     2              0              -100.00%

benchmark                old bytes     new bytes     delta
BenchmarkNewEmptyMap     48            0             -100.00%
BenchmarkNewSmallMap     192           0             -100.00%

Fixes #5449

Change-Id: I24fa66f949d2f138885d9e66a0d160240dc9e8fa
Reviewed-on: https://go-review.googlesource.com/3508
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>

10 years agocmd/gc: restore stack frame debugging
Dmitry Vyukov [Wed, 4 Feb 2015 08:26:22 +0000 (11:26 +0300)]
cmd/gc: restore stack frame debugging

Dump frames of functions.
Add function name and var width to output.

Change-Id: Ida06b8def96178fa550ca90836eb4a2509b9e13f
Reviewed-on: https://go-review.googlesource.com/3870
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime: fix race instrumentation of append
Dmitry Vyukov [Tue, 10 Feb 2015 12:26:07 +0000 (15:26 +0300)]
runtime: fix race instrumentation of append

typedslicecopy is another write barrier that is not
understood by racewalk. It seems quite complex to handle it
in the compiler, so instead just instrument it in runtime.

Update #9796

Change-Id: I0eb6abf3a2cd2491a338fab5f7da22f01bf7e89b
Reviewed-on: https://go-review.googlesource.com/4370
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/gc: remove several copies of outervalue
Dmitry Vyukov [Tue, 3 Feb 2015 09:48:35 +0000 (12:48 +0300)]
cmd/gc: remove several copies of outervalue

Walk calls it outervalue, racewalk calls it basenod,
isstack does it manually and slightly differently.

Change-Id: Id5b5d32b8faf143fe9d34bd08457bfab6fb33daa
Reviewed-on: https://go-review.googlesource.com/3745
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/gc: allocate buffers for non-escaping string conversions on stack
Dmitry Vyukov [Fri, 30 Jan 2015 06:14:13 +0000 (09:14 +0300)]
cmd/gc: allocate buffers for non-escaping string conversions on stack

Support the following conversions in escape analysis:
[]rune("foo")
[]byte("foo")
string([]rune{})

If the result does not escape, allocate temp buffer on stack
and pass it to runtime functions.

Change-Id: I1d075907eab8b0109ad7ad1878104b02b3d5c690
Reviewed-on: https://go-review.googlesource.com/3590
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime: remove obsolete SELinux execmem comment
Brad Fitzpatrick [Thu, 12 Feb 2015 07:20:15 +0000 (23:20 -0800)]
runtime: remove obsolete SELinux execmem comment

We don't have executable memory anymore.

Change-Id: I9835f03a7bcd97d809841ecbed8718b3048bfb32
Reviewed-on: https://go-review.googlesource.com/4681
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
10 years agoruntime: move all stdFunctions into os1_windows.go (no code changes)
Alex Brainman [Thu, 12 Feb 2015 03:25:59 +0000 (14:25 +1100)]
runtime: move all stdFunctions into os1_windows.go (no code changes)

Change-Id: I40291561a18bed3ca6be9dca12a664bdf28cb2f1
Reviewed-on: https://go-review.googlesource.com/4660
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years ago[dev.cc] liblink, cmd/internal/obj: fix printing of TYPE_REGREG and TYPE_REGREG2
Russ Cox [Thu, 12 Feb 2015 02:16:00 +0000 (21:16 -0500)]
[dev.cc] liblink, cmd/internal/obj: fix printing of TYPE_REGREG and TYPE_REGREG2

Now:

0x0000 00000 (/tmp/x.s:2) MULLU R6,R3,(R7, R6)

The space is a little odd but I'd rather fix the usual printing to add spaces
than delete that one. But in a different CL, once C is gone.

Change-Id: I344e0b06eedaaf53cd79d370fa13c444a1e69c81
Reviewed-on: https://go-review.googlesource.com/4647
Reviewed-by: Rob Pike <r@golang.org>
10 years agoruntime: remove unused signals_windows.h
Alex Brainman [Thu, 12 Feb 2015 01:29:37 +0000 (12:29 +1100)]
runtime: remove unused signals_windows.h

Change-Id: I35fe76661c80ca808a711acf608a23c77aeb0608
Reviewed-on: https://go-review.googlesource.com/4651
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agosyscall: Readlink doesn't handle junction on windows
mattn [Tue, 6 Jan 2015 00:47:37 +0000 (09:47 +0900)]
syscall: Readlink doesn't handle junction on windows

Fixes #9190

Change-Id: I22177687ed834feed165454019d28c11fcbf0fa2
Reviewed-on: https://go-review.googlesource.com/2307
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
10 years agocmd/gc: avoid %#016x, which really means Go's %#014x
Russ Cox [Sat, 7 Feb 2015 11:51:44 +0000 (06:51 -0500)]
cmd/gc: avoid %#016x, which really means Go's %#014x

(In non-Go print formats, the 016 includes the leading 0x prefix.
No one noticed, but we were printing hex numbers with a minimum
of 30 digits, not 32.)

Change-Id: I10ff7a51a567ad7c8440418ac034be9e4b2d6bc1
Reviewed-on: https://go-review.googlesource.com/4592
Reviewed-by: Austin Clements <austin@google.com>
10 years agocmd/gc: use go.builtin as package prefix, not go%2ebuiltin
Russ Cox [Wed, 11 Feb 2015 03:22:33 +0000 (22:22 -0500)]
cmd/gc: use go.builtin as package prefix, not go%2ebuiltin

This matches all the other pseudo-packages.
The line was simply forgotten.

Change-Id: I278f6cbcfc883ea7efad07f99fc8c853b9b5d274
Reviewed-on: https://go-review.googlesource.com/4591
Reviewed-by: Austin Clements <austin@google.com>
10 years agocmd/gc: make qsort comparisons totally ordered
Russ Cox [Wed, 11 Feb 2015 03:22:50 +0000 (22:22 -0500)]
cmd/gc: make qsort comparisons totally ordered

Otherwise different qsort implementations might result
in different sort orders and therefore different compiled
object files.

Change-Id: Ie783ba55a55af06941307e150b0c406e0a8128b0
Reviewed-on: https://go-review.googlesource.com/4590
Reviewed-by: Austin Clements <austin@google.com>
10 years agocmd/gc: remove C subclassing trick from popt.c
Russ Cox [Thu, 5 Feb 2015 10:18:08 +0000 (05:18 -0500)]
cmd/gc: remove C subclassing trick from popt.c

It does not convert to Go well.

Being able to do this just once, instead of 4 times, was the primary
motivation for all the recent refactoring (not that it wasn't overdue).

Still bit-for-bit identical.

Change-Id: Ia01f17948441bf64fa78ec4226f0bb40af0bbaab
Reviewed-on: https://go-review.googlesource.com/3962
Reviewed-by: Austin Clements <austin@google.com>
10 years agocmd/gc: move reg.c into portable code
Russ Cox [Wed, 4 Feb 2015 00:23:18 +0000 (19:23 -0500)]
cmd/gc: move reg.c into portable code

Now there is only one registerizer shared among all the systems.
There are some unfortunate special cases based on arch.thechar
in reg.c, to preserve bit-for-bit compatibility during the refactoring.
Most are probably bugs one way or another and should be revisited.

Change-Id: I153b435c0eaa05bbbeaf8876822eeb6dedaae3cf
Reviewed-on: https://go-review.googlesource.com/3883
Reviewed-by: Austin Clements <austin@google.com>
10 years agocmd/gc: remove cgen_asop, no longer used
Russ Cox [Tue, 3 Feb 2015 20:27:54 +0000 (15:27 -0500)]
cmd/gc: remove cgen_asop, no longer used

gc/order.c rewrites OASOP nodes into ordinary assignments.
The back ends never see them anymore.

Change-Id: I268ac8bdc92dccd7123110a21f99ada3ceeb2baa
Reviewed-on: https://go-review.googlesource.com/3882
Reviewed-by: Austin Clements <austin@google.com>
10 years agocmd/gc: factor newly-portable code into gc directory
Russ Cox [Fri, 30 Jan 2015 04:50:10 +0000 (23:50 -0500)]
cmd/gc: factor newly-portable code into gc directory

This isn't everything, but it's a start.
Still producing bit-identical compiler output.

The semantics of the old back ends is preserved,
even when they are probably buggy.
There are some TODOs in gc/gsubr.c to
remove special cases to preserve bugs in 5g and 8g.

Change-Id: I28ae295fbfc94ef9df43e13ab96bd6fc2f194bc4
Reviewed-on: https://go-review.googlesource.com/3802
Reviewed-by: Austin Clements <austin@google.com>
10 years ago[dev.cc] liblink: fix printing of SHRL CX, DX:AX
Russ Cox [Fri, 6 Feb 2015 21:57:38 +0000 (16:57 -0500)]
[dev.cc] liblink: fix printing of SHRL CX, DX:AX

Change-Id: I6a119109c8dea7fecb32de2c4b1b5ba54bc485be
Reviewed-on: https://go-review.googlesource.com/4100
Reviewed-by: Rob Pike <r@golang.org>
10 years agostrconv: simplified logic resulting in faster float formatting
Robert Griesemer [Wed, 4 Feb 2015 23:07:04 +0000 (15:07 -0800)]
strconv: simplified logic resulting in faster float formatting

benchmark                               old ns/op     new ns/op     delta
BenchmarkFormatFloatDecimal             300           283           -5.67%
BenchmarkFormatFloat                    383           381           -0.52%
BenchmarkFormatFloatExp                 359           357           -0.56%
BenchmarkFormatFloatNegExp              357           358           +0.28%
BenchmarkFormatFloatBig                 468           430           -8.12%
BenchmarkAppendFloatDecimal             104           92.5          -11.06%
BenchmarkAppendFloat                    199           190           -4.52%
BenchmarkAppendFloatExp                 172           167           -2.91%
BenchmarkAppendFloatNegExp              172           169           -1.74%
BenchmarkAppendFloatBig                 280           235           -16.07%
BenchmarkAppendFloat32Integer           104           92.4          -11.15%
BenchmarkAppendFloat32ExactFraction     168           171           +1.79%
BenchmarkAppendFloat32Point             206           199           -3.40%
BenchmarkAppendFloat32Exp               167           167           +0.00%
BenchmarkAppendFloat32NegExp            167           166           -0.60%
BenchmarkAppendFloat64Fixed1            134           129           -3.73%
BenchmarkAppendFloat64Fixed2            144           136           -5.56%
BenchmarkAppendFloat64Fixed3            138           134           -2.90%
BenchmarkAppendFloat64Fixed4            145           138           -4.83%

Change-Id: Ia143840cb34cbd1cebd6b691dd0a45b7264b406c
Reviewed-on: https://go-review.googlesource.com/3920
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agomath/big: completed Float.Uint64
Robert Griesemer [Wed, 11 Feb 2015 00:38:51 +0000 (16:38 -0800)]
math/big: completed Float.Uint64

Change-Id: Ib3738492a2ec8fc99323e687168b17b7239db6ad
Reviewed-on: https://go-review.googlesource.com/4511
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agomath/big: add test cases for Float.Abs and Float.Neg
Robert Griesemer [Tue, 10 Feb 2015 22:51:16 +0000 (14:51 -0800)]
math/big: add test cases for Float.Abs and Float.Neg

Change-Id: Ic5f3864bc6d94d60b754e3ccf72b1d40c5c09117
Reviewed-on: https://go-review.googlesource.com/4510
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agomath/big: implemented Float.Int (truncation of Floats to Ints)
Robert Griesemer [Tue, 10 Feb 2015 22:28:25 +0000 (14:28 -0800)]
math/big: implemented Float.Int (truncation of Floats to Ints)

Change-Id: Id98f7333fe6ae1b64e0469c6d01f02360c1f8f55
Reviewed-on: https://go-review.googlesource.com/4481
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agomath/big: When result prec == 0, use at least prec == 64 for SetInt, SetRat.
Robert Griesemer [Tue, 10 Feb 2015 19:49:54 +0000 (11:49 -0800)]
math/big: When result prec == 0, use at least prec == 64 for SetInt, SetRat.

This avoids surprises.

Change-Id: Iaae67da2d12e29c4e797ad6313e0895f7ce80cb1
Reviewed-on: https://go-review.googlesource.com/4480
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agoruntime: cache workbufs on Ms and add consistency checks
Rick Hudson [Fri, 6 Feb 2015 00:58:18 +0000 (19:58 -0500)]
runtime: cache workbufs on Ms and add consistency checks

Add local workbufs to the m struct in order to reduce contention.
Add consistency checks for workbuf ownership.
Chain workbufs through call change to avoid swapping them
to and from the m struct.
Adjust the size of the workbuf so that the mutators can
more frequently pass modifications to the GC thus shifting
some work from the STW mark termination phase to the concurrent
mark phase.

Change-Id: I557b53af34ad9972265e0ed9f5996e52d548563d
Reviewed-on: https://go-review.googlesource.com/3972
Reviewed-by: Austin Clements <austin@google.com>
10 years agoruntime: never show system goroutines in traceback
Dmitry Vyukov [Sat, 7 Feb 2015 12:31:18 +0000 (15:31 +0300)]
runtime: never show system goroutines in traceback

Fixes #9791

g.issystem flag setup races with other code wherever we set it.
Even if we set both in parent goroutine and in the system goroutine,
it is still possible that some other goroutine crashes
before the flag is set. We could pass issystem flag to newproc1,
but we start all goroutines with go nowadays.

Instead look at g.startpc to distinguish system goroutines (similar to topofstack).

Change-Id: Ia3467968dee27fa07d9fecedd4c2b00928f26645
Reviewed-on: https://go-review.googlesource.com/4113
Reviewed-by: Keith Randall <khr@golang.org>
10 years agoreflect: mark map access functions as go:noescape
Dmitry Vyukov [Tue, 3 Feb 2015 08:54:11 +0000 (11:54 +0300)]
reflect: mark map access functions as go:noescape

benchmark                                  old allocs     new allocs     delta
BenchmarkSkipValue                         14914          14202          -4.77%

Change-Id: I40e1fe8843cc6a099a2abfcd814ecc2a2d6a5b1f
Reviewed-on: https://go-review.googlesource.com/3744
Reviewed-by: Keith Randall <khr@golang.org>
10 years agoruntime: fix span unusedsince setup
Dmitry Vyukov [Tue, 10 Feb 2015 15:51:13 +0000 (18:51 +0300)]
runtime: fix span unusedsince setup

Update #8832

This is probably not the root cause of the issue.
Resolve TODO about setting unusedsince on a wrong span.

Change-Id: I69c87e3d93cb025e3e6fa80a8cffba6ad6ad1395
Reviewed-on: https://go-review.googlesource.com/4390
Reviewed-by: Keith Randall <khr@golang.org>
10 years agocmd/dist: fetch version when needed, instead of at init
Austin Clements [Wed, 11 Feb 2015 04:51:25 +0000 (23:51 -0500)]
cmd/dist: fetch version when needed, instead of at init

Currently, if there is a VERSION.cache, running make.bash will set
runtime.theVersion to the revision as of the *last* make.bash run
instead of the current make.bash run.

For example,

$ git rev-parse --short HEAD
5c4a86d
$ ./make.bash
...
$ cat ../VERSION.cache
devel +5c4a86d Tue Feb 10 01:46:30 2015 +0000
$ git checkout a1dbb92
$ ./make.bash
...
$ go version
go version devel +5c4a86d Tue Feb 10 01:46:30 2015 +0000 linux/amd64
$ ./make.bash
...
$ go version
go version devel +a1dbb92 Tue Feb 10 02:31:27 2015 +0000 linux/amd64

This happens because go tool dist reads the potentially stale
VERSION.cache into goversion during early initialization; then cleans,
which deletes VERSION.cache; then builds the runtime using the stale
revision read in to goversion.  It isn't until make later in the build
process, when make.bash invokes go tool dist again, that VERSION.cache
gets updated with the current revision.

To address this, simply don't bother fetching the version until go
tool dist needs it and don't bother caching the value in memory.  This
is more robust since it interacts with cleaning in the expected ways.
Futhermore, there's no downside to eliminating the in-memory cache;
the file system cache is perfectly reasonable for the whole three
times make.bash consults it.

Change-Id: I8c480100e56bb2db0816e8a088177004d9e87973
Reviewed-on: https://go-review.googlesource.com/4540
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] cmd/asm: fix dev.cc 386 build: implement CALL *x(SB)
Rob Pike [Wed, 11 Feb 2015 04:22:41 +0000 (20:22 -0800)]
[dev.cc] cmd/asm: fix dev.cc 386 build: implement CALL *x(SB)

Also clean up the branch code a bit

TBR=rsc

Change-Id: I209dea750db3a6769e7ccd79bb65c4d809aba152
Reviewed-on: https://go-review.googlesource.com/4530
Reviewed-by: Rob Pike <r@golang.org>
10 years ago[dev.cc] cmd/go: add veryifyAsm test for the new assembler.
Rob Pike [Wed, 11 Feb 2015 01:10:40 +0000 (17:10 -0800)]
[dev.cc] cmd/go: add veryifyAsm test for the new assembler.

Enabled for adm64 and 386 only.

Depends on https://go-review.googlesource.com/4502

Change-Id: I61caf15f91297c12197b825dd70f750c4df02d3d
Reviewed-on: https://go-review.googlesource.com/4503
Reviewed-by: Russ Cox <rsc@golang.org>
10 years ago[dev.cc] cmd/asm: final fixups for correct assembly of runtime, the last package...
Rob Pike [Wed, 11 Feb 2015 01:11:36 +0000 (17:11 -0800)]
[dev.cc] cmd/asm: final fixups for correct assembly of runtime, the last package to verify

- obj: add a missing setting of the context for a generated JMP instruction
- asm:  correct the encoding of mode (R)(R*scale)
- asm: fix a silly bug in the test for macro recursion.
- asm: accept address mode sym(R)(R*8); was an oversight

Change-Id: I27112eaaa1faa0d2ba97e414f0571b70733ea087
Reviewed-on: https://go-review.googlesource.com/4502
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocrypto/x509: allow matchHostnames to work with absolute domain names
rubyist [Tue, 10 Feb 2015 15:24:01 +0000 (10:24 -0500)]
crypto/x509: allow matchHostnames to work with absolute domain names

If an absolute domain name (i.e. ends in a '.' like "example.com.") is used
with ssl/tls, the certificate will be reported as invalid. In matchHostnames,
the host and patterns are split on '.' and if the lengths of the resulting
slices do not match, the function returns false. When splitting an absolute
domain name on '.', the slice will have an extra empty string at the end. This
empty string should be discarded before comparison, if present.

Fixes #9828

Change-Id: I0e39674b44a6f93b5024497e76cf1b550832a61d
Reviewed-on: https://go-review.googlesource.com/4380
Reviewed-by: Adam Langley <agl@golang.org>
TryBot: Adam Langley <agl@golang.org>

10 years agoruntime: don't put container symbols in functab
Keith Randall [Tue, 10 Feb 2015 00:36:25 +0000 (16:36 -0800)]
runtime: don't put container symbols in functab

Container symbols shouldn't be considered as functions in the functab.
Having them present probably messes up function lookup, as you might get
the descriptor of the container instead of the descriptor of the actual
function on the stack.  It also messed up the findfunctab because these
entries caused off-by-one errors in how functab entries were counted.

Normal code is not affected - it only changes (& hopefully fixes) the
behavior for libraries linked as a unit, like:
  net
  runtime/cgo
  runtime/race

Fixes #9804

Change-Id: I81e036e897571ac96567d59e1f1d7f058ca75e85
Reviewed-on: https://go-review.googlesource.com/4290
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agonet: disable WriteMsgUDP tests on nacl, windows (fix build)
Mikio Hara [Tue, 10 Feb 2015 08:21:03 +0000 (17:21 +0900)]
net: disable WriteMsgUDP tests on nacl, windows (fix build)

Change-Id: I695b89ec2b63233d94c49c4a40a57b50350ec67c
Reviewed-on: https://go-review.googlesource.com/4350
TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agonet: update documentation for WriteMsgUDP
Mikio Hara [Tue, 10 Feb 2015 10:27:29 +0000 (19:27 +0900)]
net: update documentation for WriteMsgUDP

Change-Id: I69f24887601e491d6d722bfeb2952d927df8ad80
Reviewed-on: https://go-review.googlesource.com/4351
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agocmd/pprof/internal/report: fix typo in recognized output unit
Ian Lance Taylor [Mon, 9 Feb 2015 16:32:08 +0000 (08:32 -0800)]
cmd/pprof/internal/report: fix typo in recognized output unit

Fixes #9814.

Change-Id: I1be49efae0648038f590eeca1262037bf1af3df5
Reviewed-on: https://go-review.googlesource.com/4240
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agomath/big: implemented Frexp, Ldexp, IsInt, Copy, bug fixes, more tests
Robert Griesemer [Tue, 10 Feb 2015 00:59:31 +0000 (16:59 -0800)]
math/big: implemented Frexp, Ldexp, IsInt, Copy, bug fixes, more tests

- Frexp, Ldexp are equivalents to the corresponding math functions.
- Set now has the same prec behavior as the other functions
- Copy is a true assignment (replaces old version of Set)
- Cmp now handles infinities
- more tests

Change-Id: I0d33980c08be3095b25d7b3d16bcad1aa7abbd0f
Reviewed-on: https://go-review.googlesource.com/4292
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agonet: permit WriteMsgUDP to connected UDP sockets
Nicolas S. Dade [Thu, 5 Feb 2015 02:05:53 +0000 (18:05 -0800)]
net: permit WriteMsgUDP to connected UDP sockets

The sanity checks at the beginning of WriteMsgUDP were too
strict, and did not allow a case sendmsg(2) suppports: sending
to a connected UDP socket.

This fixes the sanity checks. Either the socket is unconnected,
and a destination addresses is required (what all existing callers
must have been doing), or the socket is connected and an explicit
destination address must not be used.

Fixes #9807

Change-Id: I08d4ec3c2bf830335c402acfc0680c841cfcec71
Reviewed-on: https://go-review.googlesource.com/3951
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
10 years agoruntime: simplify and comment some windows code
Alex Brainman [Tue, 13 Jan 2015 23:42:26 +0000 (10:42 +1100)]
runtime: simplify and comment some windows code

Change-Id: I5cedd9e53f4e020aea74d498d0db88d79a95260c
Reviewed-on: https://go-review.googlesource.com/2718
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agonet/http: fix test to check that requests to 'localhost' are not proxied
Rajat Goel [Tue, 10 Feb 2015 01:12:12 +0000 (17:12 -0800)]
net/http: fix test to check that requests to 'localhost' are not proxied

I think the test was meant to test requests to 'localhost:80' instead
of 'localhost:80:80'. It passes even with 'localhost:80:80' because
net.SplitHostPort fails inside useProxy. Please comment if you want to
leave old 'localhost:80' is the list too to check old code path.

Change-Id: Ic4cd21901563449e3d4e2f4c8caf723f4ca15bac
u
Reviewed-on: https://go-review.googlesource.com/4293
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agocmd/go: use current go source code when generating doc.go
Andrew Gerrand [Tue, 10 Feb 2015 02:24:47 +0000 (13:24 +1100)]
cmd/go: use current go source code when generating doc.go

Change-Id: Iad1764707d173a09467fd36e8c49a58147f12219
Reviewed-on: https://go-review.googlesource.com/4320
Reviewed-by: Minux Ma <minux@golang.org>
10 years agoruntime: introduce CPU access functions on windows
Alex Brainman [Wed, 14 Jan 2015 01:25:55 +0000 (12:25 +1100)]
runtime: introduce CPU access functions on windows

This CL introduces new methods for 'context' type, so we can
manipulate its values in an architecture independent way.

Use new methods to replace both 386 and amd64 versions of
dosigprof with single piece of code.

There is more similar code to be converted in the following CLs.

Also remove os_windows_386.go and os_windows_amd64.go. These
contain unused functions.

Change-Id: I28f76aeb97f6e4249843d30d3d0c33fb233d3f7f
Reviewed-on: https://go-review.googlesource.com/2790
Reviewed-by: Minux Ma <minux@golang.org>
10 years agocmd/go: document that -run isn't implemented
Rob Pike [Tue, 10 Feb 2015 00:54:06 +0000 (16:54 -0800)]
cmd/go: document that -run isn't implemented

I am an idiot but the failure to implement this means we can decide
exactly what its design should be for 1.5

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