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

4981 Commits

Author SHA1 Message Date
Keith Randall
483cb61921 runtime: convert interface routines from C to Go.
LGTM=dvyukov
R=golang-codereviews, dave, bradfitz, dvyukov, khr
CC=golang-codereviews
https://golang.org/cl/98510044
2014-08-07 13:58:42 -07:00
Ian Lance Taylor
5ecbdb049b cmd/go: don't pass --buildid=none on FreeBSD
According to the FreeBSD builder, it doesn't work.

TBR=bradfitz
CC=golang-codereviews
https://golang.org/cl/121400043
2014-08-07 13:51:29 -07:00
Ian Lance Taylor
7fdb0292a5 cmd/go: pass --build-id=none when generating a cgo .o
Some systems, like Ubuntu, pass --build-id when linking.  The
effect is to put a note in the output file.  This is not
useful when generating an object file with the -r option, as
it eventually causes multiple build ID notes in the final
executable, all but one of which are for tiny portions of the
file and are therefore useless.

Disable that by passing an explicit --build-id=none when
linking with -r on systems that might do this.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/119460043
2014-08-07 12:38:39 -07:00
Russ Cox
08033f9816 cmd/addr2line, cmd/nm: factor object reading into cmd/internal/objfile
To do in another CL: make cmd/objdump use cmd/internal/objfile too.

There is a package placement decision in this CL:
cmd/internal/objfile instead of internal/objfile.
I chose to put internal under cmd to make clear (and enforce)
that no standard library packages should use this
(it's a bit dependency-heavy).

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/123910043
2014-08-07 12:33:06 -04:00
Andrew Gerrand
fad69a7b77 cmd/fix: mention -help instead of the non-existent -? flag
Update #8314

TBR=r
R=golang-codereviews
CC=golang-codereviews
https://golang.org/cl/123890043
2014-08-07 23:24:32 +10:00
Peter Collingbourne
e03bce158f cmd/cc, runtime: eliminate use of the unnamed substructure C extension
Eliminating use of this extension makes it easier to port the Go runtime
to other compilers. This CL also disables the extension in cc to prevent
accidental use.

LGTM=rsc, khr
R=rsc, aram, khr, dvyukov
CC=axwalk, golang-codereviews
https://golang.org/cl/106790044
2014-08-07 09:00:02 -04:00
Russ Cox
689995a73e cmd/gc: remove ignored debugging arguments in Fconv print
LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/123880043
2014-08-07 08:17:41 -04:00
Russ Cox
fef54b22f8 cmd/go: revise disallowInternal
This fixes two problems: x/internal/y/z was using parent = x/internal/y instead of x,
and hasPathPrefix only looks at /, not \ for Windows.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/121280045
2014-08-06 17:59:30 -04:00
Russ Cox
1338f327b2 cmd/go: implement 'internal' convention
See golang.org/s/go14internal for design.

LGTM=r
R=r, adg
CC=golang-codereviews
https://golang.org/cl/120600043
2014-08-06 16:45:06 -04:00
Keith Randall
ea3ac6ba75 runtime: shorten hash declarations
LGTM=iant
R=dvyukov, iant
CC=golang-codereviews
https://golang.org/cl/117680044
2014-08-06 13:42:00 -07:00
Russ Cox
7aa3031eba cmd/gc: make liveness ~10x faster
1) The arrayindexof lookup function is O(n). Replace with O(1) lookups.

2) The checkptxt function is O(n²) and is purely for debugging.
Only run when the debugging flags are turned on.

3) Iterating over sparse bitmaps can be done faster word by word.
Introduce and use bvnext for that.

Run times before and after, on my 2.5 GHz Core i5 MacBook Pro.

x.go       9.48  0.84  issue 8259

x100.go    0.01  0.01  issue 8354
x1000.go   0.10  0.10
x2000.go   0.62  0.19
x3000.go   1.33  0.34
x4000.go   2.29  0.49
x5000.go   3.89  0.67
x6000.go   5.00  0.90
x7000.go   6.70  1.13
x8000.go   9.44  1.38
x9000.go  11.23  1.87
x10000.go 13.78  2.09

Fixes #8259.
Fixes #8354.

LGTM=iant, r
R=golang-codereviews, iant, r
CC=golang-codereviews
https://golang.org/cl/125720043
2014-08-06 15:46:33 -04:00
Matthew Dempsky
2b9f3fcead cmd/cgo: consistently map void* to *byte under -{c,go}defs
Fixes #8478.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/122150043
2014-08-06 10:28:19 -07:00
David du Colombier
de1ab89f03 dist: fix Plan 9 build
Since CL 115060044, mkanames declares an empty
array in anames8.c and anames6.c, which is not
valid for the Plan 9 compiler.

char* cnames8[] = {
};

This change makes mkanames not declaring the
cnames array when no C_ constants are found.

LGTM=iant
R=minux, iant
CC=golang-codereviews
https://golang.org/cl/117680043
2014-08-06 06:11:41 -07:00
Shenghou Ma
6503d40051 undo CL 114420043 / b613f2acdf69
Broke freebsd/amd64 due to exposure of a latent bug.

««« original CL description
cmd/ld: fix operator precedence

LGTM=rsc
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/114420043
»»»

TBR=dfc
R=dave
CC=golang-codereviews
https://golang.org/cl/120630043
2014-08-06 02:07:31 -04:00
Shenghou Ma
d69d0fe92b liblink, cmd/dist, cmd/5l: introduce %^ and move C_* constants.
The helps certain diagnostics and also removed duplicated enums as a side effect.

LGTM=dave, rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/115060044
2014-08-06 00:31:22 -04:00
Shenghou Ma
ae027f52fe cmd/cc, cmd/gc: set ctxt->debugvlog with debug['v']
LGTM=rsc
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/118610043
2014-08-06 00:27:14 -04:00
Shenghou Ma
45bd2f8c45 cmd/5l, cmd/6l, cmd/8l, cmd/ld: remove unused code, consolidate enums
LGTM=rsc
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/120220043
2014-08-06 00:25:52 -04:00
Shenghou Ma
2c181f0355 cmd/ld: fix operator precedence
LGTM=rsc
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/114420043
2014-08-06 00:25:05 -04:00
Matthew Dempsky
0da4b2dbc2 cmd/cgo: fix recursive type mapping
Instead of immediately completing pointer type mappings, add them to
a queue to allow them to be completed later.  This fixes issues	caused
by Type() returning arbitrary in-progress type mappings.

Fixes #8368.
Fixes #8441.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/122850043
2014-08-05 18:16:56 -07:00
Matthew Dempsky
f7a8adbd51 cmd/cgo: fix handling of defs_linux.go
Instead of including <sys/types.h> to get size_t, instead include
the ISO C standard <stddef.h> header, which defines fewer additional
types at risk of colliding with the user code.  In particular, this
prevents collisions between <sys/types.h>'s userspace definitions with
the kernel definitions needed by defs_linux.go.

Also, -cdefs mode uses #pragma pack, so we can keep misaligned fields.

Fixes #8477.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/120610043
2014-08-05 18:12:32 -07:00
Ian Lance Taylor
f2f17c0ff2 cmd/cgo: for -godefs, promote first field of anonymous union
Update #6677

When a struct contains an anonymous union, use the type and
name of the first field in the union.

This should make the glibc <sys/resource.h> file work; in that
file struct rusage has fields like

__extension__ union
{
        long int ru_maxrss;
        __syscall_slong_t __ru_maxrss_word;
};

in which the field that matters is ru_maxrss and
__ru_maxrss_word just exists to advance to the next field on
systems where the kernel uses long long fields but userspace
expects long fields.

LGTM=mikioh.mikioh
R=golang-codereviews, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/106260044
2014-08-05 17:10:15 -07:00
Dmitriy Vyukov
81674f3135 runtime: remove type.go
We have an autogenerated version in zruntime_defs.
I am not sure what are the consequences as gdb never printed any values for me.
But it looks unnecessary to manually duplicate it.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews, iant, khr
https://golang.org/cl/115660043
2014-08-05 22:32:24 +04:00
Peter Collingbourne
fe513d8b3e cmd/go: use correct link flags if main package contains C++/ObjC files
LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/117470043
2014-08-01 16:45:33 -07:00
Keith Randall
668a55a882 runtime: move constants from map header to map type
A good cleanup anyway, and it makes some room for an additional
field needed for issue 8412.

Update #8412

LGTM=iant
R=iant, khr
CC=golang-codereviews
https://golang.org/cl/112700043
2014-08-01 14:38:56 -07:00
Keith Randall
a2a9768414 runtime: convert hash functions to Go calling convention.
Create proper closures so hash functions can be called
directly from Go.  Rearrange calling convention so return
value is directly accessible.

LGTM=dvyukov
R=golang-codereviews, dvyukov, dave, khr
CC=golang-codereviews
https://golang.org/cl/119360043
2014-07-31 15:07:05 -07:00
Keith Randall
cc9ec52d73 runtime: convert slice operations to Go.
LGTM=bradfitz, dvyukov
R=golang-codereviews, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/120190044
2014-07-31 12:43:40 -07:00
Josh Bleecher Snyder
2c982ce9a0 cmd/gc: fix example flag in comment
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/118480044
2014-07-31 10:34:51 -07:00
Keith Randall
4aa50434e1 runtime: rewrite malloc in Go.
This change introduces gomallocgc, a Go clone of mallocgc.
Only a few uses have been moved over, so there are still
lots of uses from C. Many of these C uses will be moved
over to Go (e.g. in slice.goc), but probably not all.
What should remain of C's mallocgc is an open question.

LGTM=rsc, dvyukov
R=rsc, khr, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/108840046
2014-07-30 09:01:52 -07:00
Keith Randall
d2204e6c0e cmd/gc: don't allow escaping arguments in the runtime package.
This is a case that was missed in https://golang.org/cl/105280047/

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/120910043
2014-07-29 14:38:08 -07:00
Dmitriy Vyukov
9333fe8e92 cmd/ld: better diagnostics on unaligned symbols
Want to see why builders are failing.
Then decide whether to rollback or fix.

TBR=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/114510043
2014-07-29 11:22:57 +04:00
Dmitriy Vyukov
cd17a717f9 runtime: simpler and faster GC
Implement the design described in:
https://docs.google.com/document/d/1v4Oqa0WwHunqlb8C3ObL_uNQw3DfSY-ztoA-4wWbKcg/pub

Summary of the changes:
GC uses "2-bits per word" pointer type info embed directly into bitmap.
Scanning of stacks/data/heap is unified.
The old spans types go away.
Compiler generates "sparse" 4-bits type info for GC (directly for GC bitmap).
Linker generates "dense" 2-bits type info for data/bss (the same as stacks use).

Summary of results:
-1680 lines of code total (-1000+ in mgc0.c only)
-25% memory consumption
-3-7% binary size
-15% GC pause reduction
-7% run time reduction

LGTM=khr
R=golang-codereviews, rsc, christoph, khr
CC=golang-codereviews, rlh
https://golang.org/cl/106260045
2014-07-29 11:01:02 +04:00
Shenghou Ma
faa223459a cmd/ld: remove duplicated nuxiinit() call.
It is already called by linknew().

LGTM=dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/120760043
2014-07-26 17:45:45 -04:00
Shenghou Ma
a57dda74d9 cmd/5g: remove dead code.
LGTM=bradfitz, dave
R=rsc, bradfitz, dave
CC=golang-codereviews
https://golang.org/cl/115070043
2014-07-26 17:45:24 -04:00
Shenghou Ma
61864c09fc cmd/5l: remove unused noop.c
LGTM=dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/116330043
2014-07-26 17:44:47 -04:00
Shenghou Ma
595dcef80a cmd/5l, cmd/6l, cmd/8l: remove mkenam.
Unused. cmd/dist will generate enams as liblink/anames[568].c.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/119940043
2014-07-26 17:43:10 -04:00
Bobby Powers
0f2cde8bdc cmd/gc: don't mark select descriptor as EscNone
selv is created with temp() which calls tempname, which marks
the new n with EscNever, so there is no need to explicitly set
EscNone on the select descriptor.

Fixes #8396.

LGTM=dvyukov
R=golang-codereviews, dave, dvyukov
CC=golang-codereviews
https://golang.org/cl/112520043
2014-07-25 11:22:58 +04:00
Dmitriy Vyukov
8b20e7bb7e cmd/gc: mark auxiliary symbols as containing no pointers
They do not, but pretend that they do.
The immediate need is that it breaks the new GC because
these are weird symbols as if with pointers but not necessary
pointer aligned.

LGTM=rsc
R=golang-codereviews, dave, josharian, khr, rsc
CC=golang-codereviews, iant, khr, rlh
https://golang.org/cl/116060043
2014-07-23 17:36:10 +04:00
Dmitriy Vyukov
65e2b6f847 cmd/ld: mark hostobj sections as containing no pointers
Currently they are scanned conservatively.
But there is no reason to scan them. C world must not contain
pointers into Go heap. Moreover, we don't have enough information
to emit write barriers nor update pointers there in future.
The immediate need is that it breaks the new GC because
these are weird symbols as if with pointers but not necessary
pointer aligned.

LGTM=rsc
R=golang-codereviews, rlh, rsc
CC=golang-codereviews, iant, khr
https://golang.org/cl/117000043
2014-07-22 12:10:18 +04:00
Keith Randall
064acace5b cmd/gc: in the runtime package, don't promote any decls to the heap.
In the runtime, we want to control where allocations happen.
In particular, we don't want the code implementing malloc to
itself trigger a malloc.  This change prevents the compiler
from inserting mallocs on our behalf (due to escaping declarations).

This check does not trigger on the current runtime code.

Note: Composite literals are still allowed.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/105280047
2014-07-21 20:56:44 -07:00
Keith Randall
76f1b901db runtime: keep build version around in binaries
So we can tell from a binary which version of
Go built it.

LGTM=minux, rsc
R=golang-codereviews, minux, khr, rsc, dave
CC=golang-codereviews
https://golang.org/cl/117040043
2014-07-21 20:52:11 -07:00
Brad Fitzpatrick
4676e260e3 cmd/api: ignore internal packages
We might want to add a go/build.IsInternal(pkg string) bool
later, but this works for now.

LGTM=dave, rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/113300044
2014-07-21 12:06:30 -07:00
Dmitriy Vyukov
88b78b41c5 cmd/gc: do not mark PC as pointer on stack
GC thinks that it's an invalid pointer on plan9:
http://build.golang.org/log/f7da638a20544ef7f45e81f23fdbc4875044c296

LGTM=0intro
R=golang-codereviews, 0intro
CC=aram, golang-codereviews
https://golang.org/cl/113350043
2014-07-20 18:52:46 +04:00
Dmitriy Vyukov
40d7d5a656 cmd/gc: allocate select descriptor on stack
benchmark                      old ns/op     new ns/op     delta
BenchmarkSelectUncontended     220           165           -25.00%
BenchmarkSelectContended       209           161           -22.97%
BenchmarkSelectProdCons        1042          904           -13.24%

But more importantly this change will allow
to get rid of free function in runtime.

Fixes #6494.

LGTM=rsc, khr
R=golang-codereviews, rsc, dominik.honnef, khr
CC=golang-codereviews, remyoudompheng
https://golang.org/cl/107670043
2014-07-20 15:07:10 +04:00
David du Colombier
a91c1f5c83 cmd/addr2line, cmd/objdump: fix on amd64 Plan 9
Fix virtual address of the start of the text segment
on amd64 Plan 9.

This issue has been partially fixed in cmd/add2line,
as part of CL 106460044, but we forgot to report the
change to cmd/objdump.

In the meantime, we also fixed the textStart address
in both cmd/add2line and cmd/objdump.

LGTM=aram, ality, mischief
R=rsc, mischief, aram, ality
CC=golang-codereviews, jas
https://golang.org/cl/117920043
2014-07-19 12:16:16 +03:00
Shenghou Ma
040eeff71c undo CL 109640045 / f97fb06525e5
Breaks build for FreeBSD. Probably clang related?

««« original CL description
cmd/cgo: disable inappropriate warnings when the gcc struct is empty

package main
//#cgo CFLAGS: -Wall
//void test() {}
import "C"
func main() {
    C.test()
}

This code will cause gcc issuing warnings about unused variable.

This commit use offset of the second return value of
Packages.structType to detect whether the gcc struct is empty,
and if it's directly invoke the C function instead of writing an
unused code.

LGTM=dave, minux
R=golang-codereviews, iant, minux, dave
CC=golang-codereviews
https://golang.org/cl/109640045

»»»

TBR=dfc
R=dave
CC=golang-codereviews
https://golang.org/cl/114990044
2014-07-18 02:59:54 -04:00
snyh
086df1dc77 cmd/cgo: disable inappropriate warnings when the gcc struct is empty
package main
//#cgo CFLAGS: -Wall
//void test() {}
import "C"
func main() {
    C.test()
}

This code will cause gcc issuing warnings about unused variable.

This commit use offset of the second return value of
Packages.structType to detect whether the gcc struct is empty,
and if it's directly invoke the C function instead of writing an
unused code.

LGTM=dave, minux
R=golang-codereviews, iant, minux, dave
CC=golang-codereviews
https://golang.org/cl/109640045
2014-07-18 02:47:21 -04:00
Robert Griesemer
8158b8b686 gofmt: -s flag simplifies "for _ = range x"
LGTM=adonovan, rsc
R=rsc, adonovan
CC=golang-codereviews
https://golang.org/cl/117800043
2014-07-17 09:40:27 -07:00
Robert Griesemer
8a23c0021e src, misc: applied gofmt -s -w
Pending CL 113120043.

LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/112290043
2014-07-16 16:29:51 -07:00
Russ Cox
8d504c4e97 cmd/gc: implement 'for range x {'
Fixes #6102.

LGTM=gri
R=ken, r, gri
CC=golang-codereviews
https://golang.org/cl/113120043
2014-07-16 19:27:10 -04:00
Keith Randall
0c6b55e76b runtime: convert map implementation to Go.
It's a bit slower, but not painfully so.  There is still room for
improvement (saving space so we can use nosplit, and removing the
requirement for hash/eq stubs).

benchmark                              old ns/op     new ns/op     delta
BenchmarkMegMap                        23.5          24.2          +2.98%
BenchmarkMegOneMap                     14.9          15.7          +5.37%
BenchmarkMegEqMap                      71668         72234         +0.79%
BenchmarkMegEmptyMap                   4.05          4.93          +21.73%
BenchmarkSmallStrMap                   21.9          22.5          +2.74%
BenchmarkMapStringKeysEight_16         23.1          26.3          +13.85%
BenchmarkMapStringKeysEight_32         21.9          25.0          +14.16%
BenchmarkMapStringKeysEight_64         21.9          25.1          +14.61%
BenchmarkMapStringKeysEight_1M         21.9          25.0          +14.16%
BenchmarkIntMap                        21.8          12.5          -42.66%
BenchmarkRepeatedLookupStrMapKey32     39.3          30.2          -23.16%
BenchmarkRepeatedLookupStrMapKey1M     322353        322675        +0.10%
BenchmarkNewEmptyMap                   129           136           +5.43%
BenchmarkMapIter                       137           107           -21.90%
BenchmarkMapIterEmpty                  7.14          8.71          +21.99%
BenchmarkSameLengthMap                 5.24          6.82          +30.15%
BenchmarkBigKeyMap                     34.5          35.3          +2.32%
BenchmarkBigValMap                     36.1          36.1          +0.00%
BenchmarkSmallKeyMap                   26.9          26.7          -0.74%

LGTM=rsc
R=golang-codereviews, dave, dvyukov, rsc, gobot, khr
CC=golang-codereviews
https://golang.org/cl/99380043
2014-07-16 14:16:19 -07:00