1
0
mirror of https://github.com/golang/go synced 2024-10-02 04:28:33 -06:00
Commit Graph

21971 Commits

Author SHA1 Message Date
Russ Cox
09d7db3bbb [dev.cc] cmd/dist, cmd/go: build new6g etc and verify against 6g
Change-Id: Ide7cff506274ec76d26bdffe7890ca2c28737f2b
Reviewed-on: https://go-review.googlesource.com/4852
Reviewed-by: Rob Pike <r@golang.org>
2015-02-18 15:09:04 +00:00
Rob Pike
575bdd6753 [dev.cc] cmd/internal/obj/ppc64: set Ctxt when allocating Progs
This will get fixed properly upstream, but this will serve for now.

Change-Id: I25e5210d190bc7a06a5b9f80724e3360d1a6b10c
Reviewed-on: https://go-review.googlesource.com/5121
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-18 05:01:25 +00:00
Rob Pike
345350bf07 [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>
2015-02-18 03:41:29 +00:00
Russ Cox
c7fa3c625e [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>
2015-02-18 02:39:48 +00:00
Rob Pike
2633f2aad4 [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>
2015-02-18 01:49:41 +00:00
Russ Cox
8c195bdf12 [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>
2015-02-17 23:28:51 +00:00
Russ Cox
c11882bc3e [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>
2015-02-17 23:28:41 +00:00
Russ Cox
2286989912 [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>
2015-02-17 23:28:32 +00:00
Russ Cox
535f29c68e [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>
2015-02-17 23:28:24 +00:00
Rob Pike
aa55bd44b9 [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>
2015-02-17 23:17:51 +00:00
Rob Pike
e190e27143 [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>
2015-02-17 21:42:27 +00:00
Rob Pike
f14020a64e [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>
2015-02-17 20:23:52 +00:00
Rob Pike
0f3f2c4110 [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>
2015-02-17 18:23:08 +00:00
Rob Pike
09ce5d38d0 [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>
2015-02-17 17:23:10 +00:00
Alex Brainman
201b12499c [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>
2015-02-17 08:15:13 +00:00
Rob Pike
412ce1f7d6 [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>
2015-02-17 05:10:18 +00:00
Rob Pike
68bcc13291 [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>
2015-02-17 04:55:38 +00:00
Rob Pike
188296e5bf [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>
2015-02-17 04:20:19 +00:00
Rob Pike
bf2d611a85 [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>
2015-02-17 03:52:58 +00:00
Rob Pike
581c309d8f [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>
2015-02-17 03:37:27 +00:00
Rob Pike
c497349a5b [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>
2015-02-17 03:37:17 +00:00
Rob Pike
ae2b145da2 [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>
2015-02-17 03:37:01 +00:00
Rob Pike
7fbfbca2c4 [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>
2015-02-14 00:14:27 +00:00
Rob Pike
94d0b380b0 [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>
2015-02-13 23:12:33 +00:00
Rob Pike
69ddb7a408 [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>
2015-02-13 23:08:51 +00:00
Russ Cox
2ecefd41fa [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>
2015-02-13 18:37:31 +00:00
Russ Cox
87de9ce212 [dev.cc] all: merge master (5f1efe7) into dev.cc
Conflicts:
	src/cmd/dist/build.go

Change-Id: I98a4b5e010bee91507b85bb8efd9c74e1a1f649c
2015-02-13 12:51:56 -05:00
Russ Cox
5f1efe738b 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>
2015-02-13 17:31:38 +00:00
Russ Cox
892286419e 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>
2015-02-13 17:31:29 +00:00
Russ Cox
5c87cf7608 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>
2015-02-13 17:31:16 +00:00
Russ Cox
acba34e45f 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>
2015-02-13 17:31:04 +00:00
Russ Cox
ff81c14fb2 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>
2015-02-13 17:30:55 +00:00
Russ Cox
4b27c9d72e 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>
2015-02-13 17:30:37 +00:00
Russ Cox
fa7efa2cb0 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>
2015-02-13 17:30:24 +00:00
Russ Cox
bed481d683 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>
2015-02-13 17:30:14 +00:00
Russ Cox
be4ecd9815 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>
2015-02-13 17:30:05 +00:00
Russ Cox
2e78447baf 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>
2015-02-13 17:29:36 +00:00
Roger Peppe
3be158d6ab 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>
2015-02-13 17:28:45 +00:00
Dmitry Vyukov
f59f9b8527 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>
2015-02-13 16:29:54 +00:00
Dmitry Vyukov
6731063e42 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>
2015-02-13 15:55:09 +00:00
Austin Clements
6e5cc1f1ac 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>
2015-02-13 15:34:55 +00:00
Austin Clements
60a16ea367 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>
2015-02-13 15:34:49 +00:00
Austin Clements
15c9a2ef4e 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>
2015-02-13 15:34:39 +00:00
Austin Clements
1ac65f82ad 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>
2015-02-13 15:34:34 +00:00
Austin Clements
cf964e1653 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>
2015-02-13 15:34:24 +00:00
Austin Clements
c2de2f87f0 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>
2015-02-13 15:34:08 +00:00
Dmitry Vyukov
c4ee44b7b9 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>
2015-02-13 12:12:18 +00:00
Shenghou Ma
3813799931 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>
2015-02-13 07:29:28 +00:00
Dmitry Vyukov
612d78d681 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>
2015-02-13 07:02:54 +00:00
Dmitry Vyukov
8090f868fc 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>
2015-02-13 04:59:29 +00:00