Commit graph

21298 commits

Author SHA1 Message Date
Alex Brainman 0438182c30 [dev.cc] runtime: convert netpoll_windows.c to Go
LGTM=rsc
R=rsc
CC=dvyukov, golang-codereviews
https://golang.org/cl/172530043
2014-11-14 14:07:28 +11:00
Yasuhiro Matsumoto 59439f8ea3 doc: fix small typo in doc
LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/170660043
2014-11-14 14:05:14 +11:00
Joel Sing ba603c3100 [dev.cc] runtime: convert openbsd/amd64 port to Go
LGTM=rsc
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/171660043
2014-11-14 13:01:12 +11:00
Nigel Tao 891abf9cc7 net/http: add comment to clarify whether Dir is '/' or '\'.
LGTM=bradfitz
R=bradfitz, alex.brainman
CC=golang-codereviews
https://golang.org/cl/168600044
2014-11-14 11:43:01 +11:00
Austin Clements 743bdf612a [dev.power64] 9g: implement regopt
This adds registerization support to 9g equivalent to what the
other compilers have.

LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/174980043
2014-11-13 13:51:44 -05:00
Austin Clements 231b8d61e9 [dev.power64] 9l: remove enum as's tag for c2go
None of the other compilers have a tag for this enum.
Cleaning all of this up to use proper types will happen after
the conversion.

LGTM=minux, rsc
R=rsc, minux
CC=golang-codereviews
https://golang.org/cl/166690043
2014-11-13 13:48:59 -05:00
Austin Clements c3dadb3d19 [dev.power64] 6g,8g: remove unnecessary and incorrect reg use scanning
Previously, the 6g and 8g registerizers scanned for used
registers beyond the end of a region being considered for
registerization.  This ancient artifact was copied from the C
compilers, where it was probably necessary to track implicitly
used registers.  In the Go compilers it's harmless (because it
can only over-restrict the set of available registers), but no
longer necessary because the Go compilers correctly track
register use/set information.  The consequences of this extra
scan were (at least) that 1) we would not consider allocating
the AX register if there was a deferproc call in the future
because deferproc uses AX as a return register, so we see the
use of AX, but don't track that AX is set by the CALL, and 2)
we could not consider allocating the DX register if there was
a MUL in the future because MUL implicitly sets DX and (thanks
to an abuse of copyu in this code) we would also consider DX
used.

This commit fixes these problems by nuking this code.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/174110043
2014-11-13 13:34:20 -05:00
Joel Sing b2ec4cf50c [dev.cc] runtime: make SIGSYS notifiable on freebsd (again)
This was originally done to the C port in rev 17d3b45534b5 and
seemingly got lost during the conversion.

LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/167700043
2014-11-14 04:29:03 +11:00
Aram Hăvărneanu e088e16256 [dev.cc] runtime: convert Solaris port to Go
Memory management was consolitated with the BSD ports, since
it was almost identical.

Assembly thunks are gone, being replaced by the new //go:linkname
feature.

This change supersedes CL 138390043 (runtime: convert solaris
netpoll to Go), which was previously reviewed and tested.

This change is only the first step, the port now builds,
but doesn't run. Binaries fail to exec:

    ld.so.1: 6.out: fatal: 6.out: TLS requirement failure : TLS support is unavailable
    Killed

This seems to happen because binaries don't link with libc.so
anymore. We will have to solve that in a different CL.

Also this change is just a rough translation of the original
C code, cleanup will come in a different CL.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=rsc
R=rsc, dave
CC=golang-codereviews, iant, khr, minux, r, rlh
https://golang.org/cl/174960043
2014-11-13 16:07:10 +01:00
Alex Brainman a0862a175d [dev.cc] runtime: convert mem_windows.c to Go
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/175000043
2014-11-13 14:53:13 +11:00
Alex Brainman e5d01a5ffc [dev.cc] runtime: add missing cb_max const
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/169490043
2014-11-13 12:05:36 +11:00
Brad Fitzpatrick 38ea0ae05f net/url: add example of using URL.Opaque with http.Request
Per private thread soliciting help. I realized part of this is
documented in several places, but we lacked a unifying
example.

LGTM=rsc
R=golang-codereviews
CC=adg, golang-codereviews, iant, rsc
https://golang.org/cl/171620043
2014-11-12 14:27:27 -08:00
Austin Clements 8c060d9392 [dev.power64] liblink: improve documentation of struct Prog
LGTM=dave, rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/169460043
2014-11-12 17:19:02 -05:00
Joel Sing 37cae806cb [dev.cc] [dev.cc] runtime: fix freebsd cgo __progname export
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/174050043
2014-11-12 17:18:22 -05:00
Austin Clements 60f66aa817 [dev.power64] 9g: proginfo fixes
For D_OREG addresses, store the used registers in regindex
instead of reguse because they're really part of addressing.

Add implicit register use/set for DUFFZERO/DUFFCOPY.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/174050044
2014-11-12 14:58:43 -05:00
Russ Cox 656be317d0 [dev.cc] runtime: delete scalararg, ptrarg; rename onM to systemstack
Scalararg and ptrarg are not "signal safe".
Go code filling them out can be interrupted by a signal,
and then the signal handler runs, and if it also ends up
in Go code that uses scalararg or ptrarg, now the old
values have been smashed.
For the pieces of code that do need to run in a signal handler,
we introduced onM_signalok, which is really just onM
except that the _signalok is meant to convey that the caller
asserts that scalarg and ptrarg will be restored to their old
values after the call (instead of the usual behavior, zeroing them).

Scalararg and ptrarg are also untyped and therefore error-prone.

Go code can always pass a closure instead of using scalararg
and ptrarg; they were only really necessary for C code.
And there's no more C code.

For all these reasons, delete scalararg and ptrarg, converting
the few remaining references to use closures.

Once those are gone, there is no need for a distinction between
onM and onM_signalok, so replace both with a single function
equivalent to the current onM_signalok (that is, it can be called
on any of the curg, g0, and gsignal stacks).

The name onM and the phrase 'm stack' are misnomers,
because on most system an M has two system stacks:
the main thread stack and the signal handling stack.

Correct the misnomer by naming the replacement function systemstack.

Fix a few references to "M stack" in code.

The main motivation for this change is to eliminate scalararg/ptrarg.
Rick and I have already seen them cause problems because
the calling sequence m.ptrarg[0] = p is a heap pointer assignment,
so it gets a write barrier. The write barrier also uses onM, so it has
all the same problems as if it were being invoked by a signal handler.
We worked around this by saving and restoring the old values
and by calling onM_signalok, but there's no point in keeping this nice
home for bugs around any longer.

This CL also changes funcline to return the file name as a result
instead of filling in a passed-in *string. (The *string signature is
left over from when the code was written in and called from C.)
That's arguably an unrelated change, except that once I had done
the ptrarg/scalararg/onM cleanup I started getting false positives
about the *string argument escaping (not allowed in package runtime).
The compiler is wrong, but the easiest fix is to write the code like
Go code instead of like C code. I am a bit worried that the compiler
is wrong because of some use of uninitialized memory in the escape
analysis. If that's the reason, it will go away when we convert the
compiler to Go. (And if not, we'll debug it the next time.)

LGTM=khr
R=r, khr
CC=austin, golang-codereviews, iant, rlh
https://golang.org/cl/174950043
2014-11-12 14:54:31 -05:00
Russ Cox e98f2d597e [dev.cc] runtime/cgo: add comment about import _ "unsafe"
LGTM=bradfitz, r
R=r, bradfitz
CC=golang-codereviews
https://golang.org/cl/167650043
2014-11-12 14:54:04 -05:00
Rick Hudson 18ed947ee1 [dev.garbage] runtime: Add write barriers to c code
Also improve missing GC mark diagnostics.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/169450043
2014-11-12 14:20:53 -05:00
Austin Clements c1e8c57c3d [dev.power64] 9g: fix width check and width calculation for OADDR
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/174970043
2014-11-12 14:16:49 -05:00
Emil Hessman 1a60ea1c01 A+C: add another email address for Emil Hessman
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/143470043
2014-11-12 10:01:23 -08:00
Nigel Tao de7d1c4094 hash/crc32: fix comment that the IEEE polynomial applies to MPEG-2.
LGTM=minux
R=adg, minux
CC=golang-codereviews
https://golang.org/cl/170520043
2014-11-12 18:48:00 +11:00
Russ Cox a9695a5d38 [dev.cc] runtime/cgo: fix freebsd build?
Last try and then someone with a FreeBSD has to do it.

TBR=r
CC=golang-codereviews
https://golang.org/cl/171590043
2014-11-11 23:28:26 -05:00
Russ Cox 9e719ceefe [dev.cc] runtime: fix arm5 build
TBR=r
CC=golang-codereviews
https://golang.org/cl/168600043
2014-11-11 23:24:54 -05:00
Russ Cox 22293bb1a4 [dev.cc] runtime/cgo: add missing import _ "unsafe" for //go:linkname
Will prod freebsd build along.
Not claiming it will fix it.

TBR=r
CC=golang-codereviews
https://golang.org/cl/171580044
2014-11-11 23:19:59 -05:00
Russ Cox aac17fd4e1 [dev.cc] runtime: convert freebsd to Go
It builds.
Don't know if it works, but it's a lot closer than having everything in C.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/168590043
2014-11-11 23:00:29 -05:00
Russ Cox c81d248eca [dev.cc] runtime: convert softfloat_arm.c to Go + build fixes
Also include onM_signalok fix from issue 8995.

Fixes linux/arm build.
Fixes #8995.

LGTM=r
R=r, dave
CC=golang-codereviews
https://golang.org/cl/168580043
2014-11-11 22:30:02 -05:00
Robin Eklind 04c7b68b4a regexp/syntax: Clarify comment of OpAnyCharNotNL.
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/171560043
2014-11-11 18:52:07 -08:00
Russ Cox 8420df622a [dev.cc] runtime: bring back mgc0.h
This was recorded as an hg mv instead of an hg cp.
For now a C version is needed for the Go compiler.

TBR=r
CC=golang-codereviews
https://golang.org/cl/174020043
2014-11-11 18:50:02 -05:00
Russ Cox 9204821731 [dev.cc] runtime: convert arch-specific .c and .h files to Go
The conversion was done with an automated tool and then
modified only as necessary to make it compile and run.

vlrt.c was only called from C. Pure delete.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=r
R=r, austin
CC=dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/174860043
2014-11-11 17:09:09 -05:00
Russ Cox e785e3acf8 [dev.cc] runtime: convert operating system support code from C to Go
The conversion was done with an automated tool and then
modified only as necessary to make it compile and run.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=r
R=r
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/174830044
2014-11-11 17:08:54 -05:00
Russ Cox b2cdf30eb6 [dev.cc] runtime: convert scheduler from C to Go
The conversion was done with an automated tool and then
modified only as necessary to make it compile and run.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=r
R=r, daniel.morsing
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/172260043
2014-11-11 17:08:33 -05:00
Russ Cox 59e3e5354d [dev.cc] runtime: convert race implementation from C to Go
The conversion was done with an automated tool and then
modified only as necessary to make it compile and run.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=r
R=r
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/172250044
2014-11-11 17:08:14 -05:00
Russ Cox ece09790af [dev.cc] runtime: convert parallel support code from C to Go
The conversion was done with an automated tool and then
modified only as necessary to make it compile and run.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=r
R=r, austin
CC=dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/172250043
2014-11-11 17:07:54 -05:00
Russ Cox 580ef3e4af [dev.cc] runtime: convert defs_$GOOS_$GOARCH.h to Go
The conversion was done with an automated tool and then
modified only as necessary to make it compile and run.

In a few cases, defs_$GOOS_$GOARCH.go already existed,
so the target here is defs1_$GOOS_$GOARCH.go.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=r
R=r
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/171490043
2014-11-11 17:07:37 -05:00
Russ Cox 0c3c2c1724 [dev.cc] runtime: convert basic library routines from C to Go
float.c held bit patterns for special float64 values,
hiding from the real uses. Rewrite Go code not to
refer to those values directly.

Convert library routines in runtime.c and string.c.

LGTM=r
R=r, dave
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/170330043
2014-11-11 17:07:06 -05:00
Russ Cox 7b3ebb131f [dev.cc] build: disable API check until all systems build
Otherwise no system will get an 'ok' until they all do.

LGTM=r, dave
R=r, dave
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/170320044
2014-11-11 17:06:41 -05:00
Russ Cox 15ced2d008 [dev.cc] runtime: convert assembly files for C to Go transition
The main change is that #include "zasm_GOOS_GOARCH.h"
is now #include "go_asm.h" and/or #include "go_tls.h".

Also, because C StackGuard is now Go _StackGuard,
the assembly name changes from const_StackGuard to
const__StackGuard.

In asm_$GOARCH.s, add new function getg, formerly
implemented in C.

The renamed atomics now have Go wrappers, to get
escape analysis annotations right. Those wrappers
are in CL 174860043.

LGTM=r, aram
R=r, aram
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/168510043
2014-11-11 17:06:22 -05:00
Russ Cox 2d917c0c26 [dev.cc] runtime: convert signal handlers from C to Go
This code overused macros and could not be
converted automatically. Instead a new sigctxt
type had to be defined for each os/arch combination,
with a common (implicit) interface used by the
arch-specific signal handler code.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=r
R=r
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/168500044
2014-11-11 17:05:55 -05:00
Russ Cox 9f99d531a0 [dev.cc] runtime/cgo: convert from C to Go
The conversion was done with an automated tool and then
modified only as necessary to make it compile and run.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=r
R=r
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/168500043
2014-11-11 17:05:37 -05:00
Russ Cox fee9e47559 [dev.cc] runtime: convert header files to Go
The conversion was done with an automated tool and then
modified only as necessary to make it compile and run.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=r
R=r, austin
CC=dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/167550043
2014-11-11 17:05:19 -05:00
Russ Cox 1e2d2f0947 [dev.cc] runtime: convert memory allocator and garbage collector to Go
The conversion was done with an automated tool and then
modified only as necessary to make it compile and run.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=r
R=r
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/167540043
2014-11-11 17:05:02 -05:00
Russ Cox d98553a727 [dev.cc] runtime: convert panic and stack code from C to Go
The conversion was done with an automated tool and then
modified only as necessary to make it compile and run.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=r
R=r, dave
CC=austin, dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/166520043
2014-11-11 17:04:34 -05:00
Russ Cox 9eded54fa3 [dev.garbage] runtime: concurrent mark fixes
Add missing write barrier when initializing state
for newly created goroutine. Add write barrier for
same slot when preempting a goroutine.

Disable write barrier during goroutine death,
because dopanic does pointer writes.

With concurrent mark enabled (not in this CL), all.bash passed once.
The second time, TestGoexitCrash-2 failed.

LGTM=rlh
R=rlh
CC=golang-codereviews
https://golang.org/cl/167610043
2014-11-11 16:54:50 -05:00
Robert Griesemer 40818cfe1c spec: method selectors don't auto-deref named pointer types
Language clarification.

The existing rules for selector expressions imply
automatic dereferencing of pointers to struct fields.
They also implied automatic dereferencing of selectors
denoting methods. In almost all cases, such automatic
dereferencing does indeed take place for methods but the
reason is not the selector rules but the fact that method
sets include both methods with T and *T receivers; so for
a *T actual receiver, a method expecting a formal T
receiver, also accepts a *T (and the invocation or method
value expression is the reason for the auto-derefering).

However, the rules as stated so far implied that even in
case of a variable p of named pointer type P, a selector
expression p.f would always be shorthand for (*p).f. This
is true for field selectors f, but cannot be true for
method selectors since a named pointer type always has an
empty method set.

Named pointer types may never appear as anonymous field
types (and method receivers, for that matter), so this
only applies to variables declared of a named pointer
type. This is exceedingly rare and perhaps shouldn't be
permitted in the first place (but we cannot change that).

Amended the selector rules to make auto-deref of values
of named pointer types an exception to the general rules
and added corresponding examples with explanations.

Both gc and gccgo have a bug where they do auto-deref
pointers of named types in method selectors where they
should not:

See http://play.golang.org/p/c6VhjcIVdM , line 45.

Fixes #5769.
Fixes #8989.

LGTM=r, rsc
R=r, rsc, iant, ken
CC=golang-codereviews
https://golang.org/cl/168790043
2014-11-11 13:19:47 -08:00
Rob Pike 0f8cd1438d doc/gopher: add jpgs of the 5th anniversary image
LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/172980043
2014-11-11 23:46:20 +11:00
Russ Cox 0d49f7b5fc [dev.cc] cmd/dist: adjust for build process without cmd/cc
[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

- Remove references to C compiler directories.
- Remove generation of special header files.
- Remove generation of Go source files from C declarations.

- Compile Go sources before rest of package (was after),
  so that Go compiler can write go_asm.h for use in assembly.

- Move TLS information from cmd/dist (was embedding in output)
  to src/runtime/go_tls.h, which it can be maintained directly.

LGTM=r
R=r, dave
CC=austin, golang-codereviews, iant, khr
https://golang.org/cl/172960043
2014-11-11 01:29:05 -05:00
Russ Cox 0185ba76ed [dev.cc] liblink: resolve bss vs other conflict regardless of order found
If the linker finds the same name given a BSS and a non-BSS
symbol, the assumption is that the non-BSS symbol is the
true one, and the BSS symbol is just the best Go can do toward
an "extern" declaration. This has always been the case,
as long as the object files were read in the right order.

The old code worked when the BSS symbol is found before
the non-BSS symbol. This CL adds equivalent logic for when
the non-BSS symbol is found before the BSS symbol.
This comes up when Go must refer to symbols defined in
host object files.

LGTM=r
R=r
CC=austin, golang-codereviews, iant, khr
https://golang.org/cl/171480043
2014-11-11 01:28:26 -05:00
Russ Cox 729847cf8a [dev.cc] cmd/go: adjust go, cgo builds & disable cc
[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

Make gcToolchain.cc return an error (no C compiler!).

Adjust expectations of cgo, now that cgo does not write any C files
(no C compiler!).

For packages with .s files, invoke Go compiler with -asmhdr go_asm.h
so that assembly files can use it. This applies to all packages but is only
needed today by package runtime.

LGTM=r
R=r
CC=austin, golang-codereviews, iant, khr
https://golang.org/cl/171470043
2014-11-11 01:27:55 -05:00
Russ Cox fd2bc95d53 [dev.cc] cmd/gc: changes for removing runtime C code
[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

export.c, lex.c:
Add -asmhdr flag to write assembly header file with struct
field offsets and const values. cmd/dist used to construct this
file by interpreting output from the C compiler.
Generate it from the Go definitions instead.
Also, generate the form we need directly, instead of relying
on cmd/dist for reprocessing.

lex.c, obj.c:
If the C compiler accepted #pragma cgo_xxx, recognize
a directive //go:cgo_xxx instead. The effect is the same as
in the C compiler: accumulate text into a buffer and emit in the
output file, where the linker will find and use it.

lex.c, obj.c:
Accept //go:linkname to control the external symbol name
used for a particular top-level Go variable. This makes it
possible to refer to C symbol names but also symbols from
other packages. It has always been possible to do this from
C and assembly. To drive home the point that this should not
be done lightly, require import "unsafe" in any file containing
//go:linkname.

plive.c, reflect.c, subr.c:
Hard-code that interfaces contain only pointers.
This means code handling multiword values in the garbage
collector and the stack copier can be deleted instead of being
converted. This change is already present in the dev.garbage
branch.

LGTM=r
R=r
CC=austin, golang-codereviews, iant, khr
https://golang.org/cl/169360043
2014-11-11 01:27:30 -05:00
Russ Cox 25f9f5d082 [dev.cc] cmd/cgo: generate only Go source files
[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

We changed cgo to write the actual function wrappers in Go
for Go 1.4. The only code left in C output files was the definitions
for pointers to C data and the #pragma cgo directives.
Write both of those to Go outputs instead, using the new
compiler directives introduced in CL 169360043.

(Still generating C files in gccgo mode.)

LGTM=r
R=r
CC=austin, golang-codereviews, iant, khr
https://golang.org/cl/169330045
2014-11-11 01:23:19 -05:00