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

3132 Commits

Author SHA1 Message Date
Russ Cox
10e85dfee4 Make.pkg: fix cgo for TARG=a/b
R=dho, phf
CC=golang-dev
https://golang.org/cl/180082
2009-12-17 17:28:22 -08:00
Russ Cox
044ebae2f0 cgo: include line number information to keep go/printer happy
Fixes #443.

R=dho
CC=golang-dev
https://golang.org/cl/179095
2009-12-17 17:04:48 -08:00
Kai Backman
d85bb81878 first stub for softfloats, intercepts float instructions and skips
them in the stream.

R=rsc
https://golang.org/cl/174052
2009-12-17 16:08:42 -08:00
Robert Griesemer
4ddcb0ea73 fix for gofmt rewrite matcher bug
R=rsc
CC=golang-dev
https://golang.org/cl/179096
2009-12-17 15:23:19 -08:00
Russ Cox
6a4b2492b3 gc: fix compiler crash
R=ken2
CC=dho
https://golang.org/cl/179097
2009-12-17 15:08:55 -08:00
Robert Griesemer
7fcf422181 use new tab indentation format in godoc, but convert
leading tabs into spaces to ensure a good outcome in
most browsers

R=rsc
https://golang.org/cl/165051
2009-12-17 14:10:49 -08:00
Ben Olive
d2a835fbf3 time: add ISO 8601 time format
Fixes #431.

R=r, rsc
CC=golang-dev
https://golang.org/cl/179079
2009-12-17 13:39:13 -08:00
Devon H. O'Dell
9277b02537 Allow cgo to accept multiple .go inputs for a package
Fixes #342.

R=rsc
CC=golang-dev
https://golang.org/cl/179062
2009-12-17 13:20:56 -08:00
Devon H. O'Dell
7a5f4be97e Use BitSize instead of the field's type native ByteSize when calculating
structs containing bitfields.

Fixes #163.

R=rsc
CC=golang-dev
https://golang.org/cl/180059
2009-12-17 12:38:29 -08:00
Tor Andersson
a812332151 Updated the XGB python script to generate semicolon-free
source for xproto.go.

R=rsc
CC=golang-dev
https://golang.org/cl/180074
2009-12-17 12:19:40 -08:00
Russ Cox
08579c26dd runtime: if os/signal is not in use, crash on
most signals, so that ordinary programs
	can be killed, for example.

Fixes #434.

R=dsymonds1
CC=golang-dev, hoisie
https://golang.org/cl/180064
2009-12-16 20:20:50 -08:00
Robert Griesemer
59a3cae402 - Parse expressions as opposed to statements for gofmt rewrite patterns.
Allows stand-alone types (e.g. []int as patterns) and doesn't require
a semicolon at the end (which are now mandatory terminators).

- Fix a matcher bug.

R=rsc
CC=golang-dev
https://golang.org/cl/179088
2009-12-16 16:53:56 -08:00
Nigel Tao
8bf58725b2 Basic image/jpeg decoder.
This is not a complete JPEG implementation (e.g. it does not handle
progressive JPEGs or restart markers), but I was able to take a photo
with my phone, and view the resultant JPEG in pure Go.

The decoder is simple, but slow. The Huffman decoder in particular
should be easily improvable, but optimization is left to future
changelists. Being able to inline functions in the inner loop should
also help performance.

The output is not pixel-for-pixel identical to libjpeg, although
identical behavior isn't necessarily a goal, since JPEG is a lossy
codec. There are at least two reasons for the discrepancy.

First, the inverse DCT algorithm used is the same as Plan9's
src/cmd/jpg, which has different rounding errors from libjpeg's
default IDCT implementation. Note that libjpeg actually has three
different IDCT implementations: one floating point, and two fixed
point. Out of those four, Plan9's seemed the simplest to understand,
partly because it has no #ifdef's or C macros.

Second, for 4:2:2 or 4:2:0 chroma sampling, this implementation does
nearest neighbor upsampling, compared to libjpeg's triangle filter
(e.g. see h2v1_fancy_upsample in jdsample.c).

The difference from the first reason is typically zero, but sometimes
1 (out of 256) in YCbCr space, or double that in RGB space. The
difference from the second reason can be as large as 8/256 in YCbCr
space, in regions of steep chroma gradients. Informal eyeballing
suggests that the net difference is typically imperceptible, though.

R=r
CC=golang-dev, rsc
https://golang.org/cl/164056
2009-12-17 10:32:17 +11:00
Robert Griesemer
b6bac1c0a5 Don't ignore flags controlling the amount of source code parsed
in parser's ParsePkgFile and ParsePackage functions.

R=rsc
CC=golang-dev, rog
https://golang.org/cl/180070
2009-12-16 14:12:24 -08:00
Rob Pike
42a2e95989 add the ability to invoke niladic single-valued methods in templates.
Fixes #389.

R=rsc
CC=golang-dev
https://golang.org/cl/180061
2009-12-16 03:10:50 -08:00
Moriyoshi Koizumi
a8fbf5dc2c This patch enables cgo utility to correctly convert enums in the C source
into consts in the resulting Go source.  Previously known as issue 161047,
which I deleted accidentally.  Fixes issue 207.

R=rsc
https://golang.org/cl/166059
2009-12-15 21:24:17 -08:00
William Josephson
52114724b7 rand: Zipf distributed random variates.
R=rsc
https://golang.org/cl/176070
2009-12-15 21:10:37 -08:00
Andrey Mirtchovski
7f501c06f7 bytes, strings: add new function Fields
R=rsc, r, phf
CC=golang-dev
https://golang.org/cl/170046
2009-12-15 21:09:55 -08:00
Charles L. Dorian
d5bcf7bf41 math: special cases for Pow
R=rsc
CC=golang-dev
https://golang.org/cl/176064
2009-12-15 20:43:12 -08:00
David Symonds
b5866494ea os/signal: new package
Fixes #71.

R=rsc, r
https://golang.org/cl/162056
2009-12-15 18:21:29 -08:00
Robert Griesemer
a47a45ec77 Fix for scanner bug (introduced with most recent change).
Fixes #433.

R=rsc
CC=golang-dev
https://golang.org/cl/179072
2009-12-15 18:03:59 -08:00
Russ Cox
69bed164a7 syscall: RawSyscall must not call exitsyscall
Fixes #405.

R=r
CC=golang-dev, hoisie
https://golang.org/cl/180056
2009-12-15 17:37:47 -08:00
Russ Cox
f64bb56bae rand: add explicit Int31n to avoid 64-bit divide on 32-bit machines
use Int31n in Intn when possible.

Fixes #390.

(using 8g)
Intn1000      50000000         38 ns/op
Int31n1000    50000000         39 ns/op
Int63n1000    20000000        114 ns/op

R=r
CC=golang-dev, skybrian
https://golang.org/cl/180054
2009-12-15 17:21:34 -08:00
Russ Cox
1e9e7ec4b3 math: faster, easier to inline IsNaN, IsInf
R=r
CC=golang-dev
https://golang.org/cl/180046
2009-12-15 17:21:01 -08:00
Russ Cox
d16bc7a9f2 runtime: return zero value in x, ok = <-c when ok == false
Fixes #401.

R=ken2
https://golang.org/cl/180053
2009-12-15 16:59:23 -08:00
Russ Cox
c715b58dad gc: fix import name resolution
Fixes #403.

R=ken2
https://golang.org/cl/180052
2009-12-15 16:44:28 -08:00
Ivan Krasin
8e2608eca8 Add basic http authentication support.
Fixes #407.

R=rsc, ajstarks
CC=ushakov
https://golang.org/cl/176076
2009-12-15 16:27:45 -08:00
Russ Cox
5d754bfaea gc: bug fixes.
* better error for lookup of unexported field
  * do not assign "ideal string" type to typed string literal
  * do not confuse methods and fields during interface check

Fixes #410.
Fixes #411.
Fixes #426.

R=ken2
https://golang.org/cl/179069
2009-12-15 16:22:04 -08:00
Russ Cox
101f499fa5 gc: allow ... in method lists
R=ken2
https://golang.org/cl/179070
2009-12-15 16:20:37 -08:00
Robert Griesemer
45ca9f7a9e 1) Change default gofmt default settings for
parsing and printing to new syntax.

   Use -oldparser to parse the old syntax,
   use -oldprinter to print the old syntax.

2) Change default gofmt formatting settings
   to use tabs for indentation only and to use
   spaces for alignment. This will make the code
   alignment insensitive to an editor's tabwidth.

   Use -spaces=false to use tabs for alignment.

3) Manually changed src/exp/parser/parser_test.go
   so that it doesn't try to parse the parser's
   source files using the old syntax (they have
   new syntax now).

4) gofmt -w src misc test/bench

5th and last set of files.

R=rsc
CC=golang-dev
https://golang.org/cl/180050
2009-12-15 15:41:46 -08:00
Robert Griesemer
d65a5cce89 1) Change default gofmt default settings for
parsing and printing to new syntax.

   Use -oldparser to parse the old syntax,
   use -oldprinter to print the old syntax.

2) Change default gofmt formatting settings
   to use tabs for indentation only and to use
   spaces for alignment. This will make the code
   alignment insensitive to an editor's tabwidth.

   Use -spaces=false to use tabs for alignment.

3) Manually changed src/exp/parser/parser_test.go
   so that it doesn't try to parse the parser's
   source files using the old syntax (they have
   new syntax now).

4) gofmt -w src misc test/bench

4th set of files.

R=rsc
CC=golang-dev
https://golang.org/cl/180049
2009-12-15 15:40:16 -08:00
Robert Griesemer
a3d1045fb7 1) Change default gofmt default settings for
parsing and printing to new syntax.

   Use -oldparser to parse the old syntax,
   use -oldprinter to print the old syntax.

2) Change default gofmt formatting settings
   to use tabs for indentation only and to use
   spaces for alignment. This will make the code
   alignment insensitive to an editor's tabwidth.

   Use -spaces=false to use tabs for alignment.

3) Manually changed src/exp/parser/parser_test.go
   so that it doesn't try to parse the parser's
   source files using the old syntax (they have
   new syntax now).

4) gofmt -w src misc test/bench

3rd set of files.

R=rsc
CC=golang-dev
https://golang.org/cl/180048
2009-12-15 15:35:38 -08:00
Robert Griesemer
5a1d3323fe 1) Change default gofmt default settings for
parsing and printing to new syntax.

                  Use -oldparser to parse the old syntax,
                  use -oldprinter to print the old syntax.

               2) Change default gofmt formatting settings
                  to use tabs for indentation only and to use
                  spaces for alignment. This will make the code
                  alignment insensitive to an editor's tabwidth.

                  Use -spaces=false to use tabs for alignment.

               3) Manually changed src/exp/parser/parser_test.go
                  so that it doesn't try to parse the parser's
                  source files using the old syntax (they have
                  new syntax now).

               4) gofmt -w src misc test/bench

	       1st set of files.

R=rsc
CC=agl, golang-dev, iant, ken2, r
https://golang.org/cl/180047
2009-12-15 15:33:31 -08:00
Robert Griesemer
1c72959999 1) Change default gofmt default settings for
parsing and printing to new syntax.

                  Use -oldparser to parse the old syntax,
                  use -oldprinter to print the old syntax.

               2) Change default gofmt formatting settings
                  to use tabs for indentation only and to use
                  spaces for alignment. This will make the code
                  alignment insensitive to an editor's tabwidth.

                  Use -spaces=false to use tabs for alignment.

               3) Manually changed src/exp/parser/parser_test.go
                  so that it doesn't try to parse the parser's
                  source files using the old syntax (they have
                  new syntax now).

               4) gofmt -w src misc test/bench

	       2nd set of files.

R=rsc
CC=golang-dev
https://golang.org/cl/179067
2009-12-15 15:27:16 -08:00
Russ Cox
d122bb2193 gc: double-check usage of ...
Fixes #423.

R=ken2
https://golang.org/cl/180045
2009-12-15 14:26:50 -08:00
Russ Cox
0282cc5e74 gc: var x, ok = m[y]
Fixes #384.

R=ken2
https://golang.org/cl/179061
2009-12-15 14:26:33 -08:00
Robert Griesemer
55ca7a2644 fix TODO: insert semicolons before any sequence of comments
that introduce the newline (important for correct placement
of comments with gofmt when parsing new syntax)

R=rsc
https://golang.org/cl/179055
2009-12-15 08:41:50 -08:00
Arvindh Rajesh Tamilmani
dec5bb7882 xml: handle unexpected EOF while parsing and fix a bug in name
mustgetc reports unexpected EOF as SyntaxError.  using
mustgetc seems to be a better approach than letting the
caller handle unexpected EOF every time.

name: the second if statement should explicitly return
ok==false.

R=rsc
https://golang.org/cl/174083
2009-12-14 19:28:36 -08:00
Russ Cox
19c18358ca runtime: in exitsyscall, avoid confusing garbage collector
R=r
CC=golang-dev
https://golang.org/cl/178046
2009-12-14 19:06:20 -08:00
Robert Griesemer
31de4d4c5d improved formatting of import declarations and
multi-line expressions with comments

Fixes #414.

R=rsc
https://golang.org/cl/179047
2009-12-14 17:35:12 -08:00
Andy Davis
2a52782f5c crypto/sha256: new package
R=rsc
CC=golang-dev
https://golang.org/cl/176062
2009-12-14 15:09:49 -08:00
Rob Pike
0d3f5a84b8 simpler fix for the negative rune problem, spotted seconds after submitting the previous fix.
R=rsc
https://golang.org/cl/178044
2009-12-15 09:31:24 +11:00
Rob Pike
a9e8befb49 generate replacement rune when asked to encode a negative rune value.
Fixes #425.

R=rsc
https://golang.org/cl/178043
2009-12-15 09:19:54 +11:00
Christopher Wedgwood
fe0eb17fad archive/tar: bug fixes.
1. If all data is exhausted using Read then a following Next will
   fail as if it saw EOF.  (Test case added.)
2. Seeking isn't always possible (i.e. sockets and pipes).  Fallback
   to read.  (Test case added.)
3. Fix to readHeader (cleaner fix pointed out by rsc).
   (TestReader modified.)
4. When Read has consumed all the data, don't try to read 0 bytes from reader.
   In cases where tr.nb is zero we attempt to read zero bytes and thus
   never see an EOF (this is most easily seen when the 'tar source' is
   something like bytes.Buffer{} as opposed to os.File).
5. If write is used to the point of ErrWriteTooLong, allow additional file entries.
6. Make close work as expected.  That is any further Write or
   WriteHeader attempts will result in ErrWriteAfterClose.
Fixes #419.

R=rsc, dsymonds1
https://golang.org/cl/162062
2009-12-14 11:35:02 -08:00
Robert Griesemer
8793f622e6 don't show semicolons anymore with godoc
R=rsc
https://golang.org/cl/174078
2009-12-14 09:14:00 -08:00
Rob Pike
d14c813377 When the buffer is empty, reset b.off to the beginning of the buffer
to avoid growing unnecessarily.

R=rsc
CC=golang-dev
https://golang.org/cl/176071
2009-12-14 13:13:01 +11:00
Christopher Wedgwood
58578905ba syscall: fix error return bug for 64-bit return on 32-bit platform
R=dho, rsc
CC=r
https://golang.org/cl/176058
2009-12-13 13:05:49 -08:00
Hector Chu
977e19d69f 8l: add support for PE output.
R=rsc
https://golang.org/cl/166080
2009-12-13 12:39:20 -08:00
Christopher Wedgwood
2ef330ebd9 clean.bash: stop if $GOROOT is not set
Doing rm -rf /pkg/.. blindly isn't nice.  It could have
unintended consequences.

Secondly set bash to abort on (unexpected) errors.

R=dho, rsc
CC=golang-dev
https://golang.org/cl/176056
2009-12-13 12:27:19 -08:00
Hector Chu
31645cc0bb Ported godefs to Windows.
R=rsc
https://golang.org/cl/164049
2009-12-13 12:21:44 -08:00
Russ Cox
978c3e96d1 gc: fix comment
R=gri
CC=golang-dev
https://golang.org/cl/174077
2009-12-13 12:11:56 -08:00
Rob Pike
f646296185 Update goyacc to new syntax, still with semicolons.
Update units.y too.
Fixes #417.

R=rsc
CC=golang-dev
https://golang.org/cl/176063
2009-12-14 06:34:51 +11:00
Ken Thompson
bedfc2c2f1 more on the optimizer
trying to get alizses
to optimize

R=rsc
https://golang.org/cl/176061
2009-12-12 14:36:52 -08:00
Rob Pike
687777710b fix bug for large counts: used a one-byte buffer.
R=rsc
CC=golang-dev
https://golang.org/cl/174082
2009-12-13 07:27:43 +11:00
Robert Griesemer
222462ed4f Various cleanups:
- no need to replace comments for stand-alone blocks
- always print string concatenations with interspersed "+"
  (remove option)
- minor cleanups

R=rsc
https://golang.org/cl/174076
2009-12-11 16:42:14 -08:00
Russ Cox
3997495dc3 gc: semicolons
Fixes #89.
Fixes #92.
Fixes #118.
Fixes #182.
Fixes #328.
Fixes #340.

R=ken2, ken3
CC=golang-dev
https://golang.org/cl/172049
2009-12-11 15:59:41 -08:00
Ken Thompson
cd00bc78da bug in 6g optimizer
8g still needs fixing

R=rsc
https://golang.org/cl/176057
2009-12-11 15:55:09 -08:00
Robert Griesemer
97a08f7a81 parser changed to reflect new semicolon rules
R=rsc
https://golang.org/cl/175046
2009-12-11 15:31:24 -08:00
Robert Griesemer
b9b89f56ad fix printer test for new syntax
R=rsc
https://golang.org/cl/175048
2009-12-11 15:31:06 -08:00
Devon H. O'Dell
857d4cf1a9 Remove GOBIN in PATH dependency; don't assume cwd is $GOROOT/src
This change removes the necessity to have GOBIN in $PATH,
and also doesn't assume that the build is being run from
$GOROOT/src. This is a minimal set of necessary changes
to get Go to build happily from the FreeBSD ports
collection.

R=rsc
CC=golang-dev
https://golang.org/cl/171044
2009-12-11 15:14:09 -08:00
Maxim Ushakov
349095885e encoding/binary: Add support for slices of arrays of fixed-size values.
R=rsc
CC=krasin
https://golang.org/cl/167050
2009-12-11 13:04:03 -08:00
Devon H. O'Dell
ddde7f6625 Add a Makefile in place of all.bash. Update docs to reflect
this change.

R=rsc
CC=golang-dev
https://golang.org/cl/171048
2009-12-11 12:48:55 -08:00
Yves Junqueira
7835b7994e syslog: new package
R=golang-dev, rsc
https://golang.org/cl/157168
2009-12-11 12:41:51 -08:00
Yongjian Xu
8b3b1edc04 mkbuiltin: generate builtin.c directly
R=golang-dev, rsc
https://golang.org/cl/173041
2009-12-11 12:41:33 -08:00
Kei Son
128974adfd bytes, strings: allow -1 in Map to mean "drop this character".
xml: drop invalid characters in attribute names
    when constructing struct field names.

R=rsc
CC=r
https://golang.org/cl/157104
2009-12-11 10:37:48 -08:00
Robert Griesemer
67aa1399d6 - make make test working again
- some factoring for easier experimentation

R=rsc
https://golang.org/cl/174048
2009-12-10 19:07:10 -08:00
Robert Griesemer
bda2074193 New flags for gofmt:
- oldparser            parse old syntax (required semicolons)
- oldprinter           print old syntax (required semicolons)

By default, these flags are enabled for now.
Setting -oldparser=false has no effect until go/parser is changed
to accept the new syntax.

Enabled exp/parser in Makefile; update dependent exp/eval.

R=rsc
https://golang.org/cl/174051
2009-12-10 19:03:28 -08:00
Robert Griesemer
02d41ec7df rename exp/parser package to oldParser
to allow simultaneous import with the
current go/parser

R=rsc
https://golang.org/cl/174053
2009-12-10 18:27:48 -08:00
Robert Griesemer
57909b54e9 implement NoSemis and NoStringConcat mode for go/printer
R=rsc
https://golang.org/cl/174050
2009-12-10 15:45:57 -08:00
Robert Griesemer
a70caf4463 implemented InsertSemis mode for go/scanner
R=rsc
https://golang.org/cl/175047
2009-12-10 15:31:02 -08:00
Robert Griesemer
2b3813d0e2 - unmodified copy of existing go/parser, not yet hooked up
R=rsc
CC=r
https://golang.org/cl/175045
2009-12-10 14:26:25 -08:00
Kai Backman
d08d33f389 fix calling convention and make memmove restore the g and m
registers.

R=rsc
https://golang.org/cl/166049
2009-12-10 11:42:01 -08:00
Kai Backman
76f7803a2a added SHUT_RD, SHOT_WR and xSHUT_RDWR to fix net compilation error
R=rsc
https://golang.org/cl/165044
2009-12-10 11:40:11 -08:00
Robert Griesemer
2e4334eb3a minor manual format corrections
R=rsc
https://golang.org/cl/172042
2009-12-09 16:54:24 -08:00
Robert Griesemer
295ceb4526 remove uses of string concatenation from src and misc directory
R=rsc
https://golang.org/cl/172041
2009-12-09 16:54:07 -08:00
Roger Peppe
a8ed75d27c added benchmarks to rand_test.go;
removed superfluous field name in lockedSource.

R=r, rsc
https://golang.org/cl/170043
2009-12-09 14:23:43 -08:00
Rob Pike
51f2932082 syscalls can return negative i/o counts. fix bugs in ReadAt and WriteAt not to include
negative counts in return values.

R=rsc
CC=golang-dev
https://golang.org/cl/170044
2009-12-09 14:18:32 -08:00
Roger Peppe
916533119e Make the operations on the global rng thread safe.
R=r, rsc
CC=golang-dev
https://golang.org/cl/168041
2009-12-09 12:55:19 -08:00
Charles L. Dorian
3ca1b1d27f Continuation of issue 221 fix. When 8g or 6g or 5g are called with a
UTF-8 string, Yconv() converts it into an octal sequence. If the
string converted to more than 30 bytes, the str buffer would
overflow. For example, 4 Greek runes became 32 bytes, 3 Hiragana
runes became 36 bytes, and 2 Gothic runes became 32 bytes. In
8l, 6l and 5l the function is Sconv(). For some reason, only 5l uses
the constant STRINGSZ (defined as 200) for the buffer size.

R=rsc
https://golang.org/cl/168045
2009-12-09 11:56:45 -08:00
Ross Light
8a5b76ce5c json package: Fixed handling of nil values
Fixes #400.

R=golang-dev, rsc
https://golang.org/cl/167058
2009-12-09 10:36:03 -08:00
Adrian O'Grady
6ebfd1eff2 Added XTEA block cipher package to src/pkg/crypto
This is an adaption of the code from http://en.wikipedia.org/wiki/XTEA. The package also implements the block.Cipher
interface so that it can be used with the various block modes.

R=rsc
https://golang.org/cl/157152
2009-12-09 00:06:20 -08:00
Russ Cox
0400a7f8b1 runtime: start new darwin/amd64 threads on correct stack,
then enable stack check.

R=r
https://golang.org/cl/165100
2009-12-08 23:34:45 -08:00
Russ Cox
132c42ff73 bufio: use copy - significant speedup for writers
R=r
https://golang.org/cl/167047
2009-12-08 18:19:48 -08:00
Devon H. O'Dell
5a4a08fab8 Fix stack on FreeBSD / add stack check across the board
FreeBSD was passing stk as the new thread's stack base, while
stk is the top of the stack in go. The added check should cause
a trap if this ever comes up in any new ports, or regresses
in current ones.

R=rsc
CC=golang-dev
https://golang.org/cl/167055
2009-12-08 18:19:30 -08:00
Devon H. O'Dell
cdce7325c8 When SA_SIGINFO is set, we should use __sa_sigaction on FreeBSD
R=rsc
CC=golang-dev
https://golang.org/cl/165097
2009-12-08 18:18:04 -08:00
Russ Cox
b73b43ea31 6l, 8l: make string buffer big enough for 8 chars (and then some)
Fixes #221.

R=ken2
https://golang.org/cl/165086
2009-12-07 22:01:59 -08:00
Russ Cox
0d3301a557 runtime: don't touch pages of memory unnecessarily.
cuts working size for hello world from 6 MB to 1.2 MB.
still some work to be done, but diminishing returns.

R=r
https://golang.org/cl/165080
2009-12-07 15:52:14 -08:00
Russ Cox
33649bd278 runtime: introduce unsafe.New and unsafe.NewArray
to provide functionality previously hacked in to
    reflect and gob.

R=r
https://golang.org/cl/165076
2009-12-07 15:51:58 -08:00
Robert Griesemer
a4a8224152 use a bootstrap array to avoid allocation for short vectors
R=r
https://golang.org/cl/165078
2009-12-07 12:46:20 -08:00
Christopher Wedgwood
8c22dd24e0 Remove copyBytes completely in favor of copy.
R=r, rsc
https://golang.org/cl/165068
2009-12-07 11:31:56 -08:00
Rob Pike
20c1ec263a pick off special one-byte case in copy. worth 2x in benchmarks (38ns->16ns).
the one-item case could be generalized easily with no cost. worth considering.

R=rsc
CC=golang-dev, cw
https://golang.org/cl/167044
2009-12-07 11:28:02 -08:00
Roger Peppe
80e17d6797 the AST walker currently provides no way to find out how the
nodes in the tree are nested with respect to one another.
a simple change to the Visitor interface makes it possible
to do this (for example to maintain a current node-depth, or a
knowledge of the name of the current function).

Visit(nil) is called at the end of a node's children;
this make possible the channel-based interface below,
amongst other possibilities.

It is still just as simple to get the original behaviour - just
return the same Visitor from Visit.

Here are a couple of possible Visitor types.

// closure-based
type FVisitor func(n interface{}) FVisitor
func (f FVisitor) Visit(n interface{}) Visitor {
	return f(n);
}

// channel-based
type CVisitor chan Visit;
type Visit struct {
	node interface{};
	reply chan CVisitor;
};
func (v CVisitor) Visit(n interface{}) Visitor
{
	if n == nil {
		close(v);
	} else {
		reply := make(chan CVisitor);
		v <- Visit{n, reply};
		r := <-reply;
		if r == nil {
			return nil;
		}
		return r;
	}
	return nil;
}

R=gri
CC=rsc
https://golang.org/cl/166047
2009-12-07 10:33:45 -08:00
Rob Pike
f91cd44736 save a few ns by inlining (which mostly simplifies things anyway).
a couple of cleanups.
don't keep big buffers in the free list.

R=rsc
CC=golang-dev
https://golang.org/cl/166078
2009-12-06 15:01:07 -08:00
Rob Pike
353ef80f65 unexport Fmt. it's not needed outside this package any more
cleans up godoc's output for package fmt substantially.

R=rsc
CC=golang-dev
https://golang.org/cl/165070
2009-12-06 12:58:16 -08:00
Rob Pike
4c0e51cd43 Make printing faster by avoiding mallocs and some other advances.
Roughly 33% faster for simple cases, probably more for complex ones.

Before:

mallocs per Sprintf(""): 4
mallocs per Sprintf("xxx"): 6
mallocs per Sprintf("%x"): 10
mallocs per Sprintf("%x %x"): 12

Now:

mallocs per Sprintf(""): 2
mallocs per Sprintf("xxx"): 3
mallocs per Sprintf("%x"): 5
mallocs per Sprintf("%x %x"): 7

Speed improves because of avoiding mallocs and also by sharing a bytes.Buffer
between print.go and format.go rather than copying the data back after each
printed item.

Before:

fmt_test.BenchmarkSprintfEmpty	1000000	      1346 ns/op
fmt_test.BenchmarkSprintfString	500000	      3461 ns/op
fmt_test.BenchmarkSprintfInt	500000	      3671 ns/op

Now:

fmt_test.BenchmarkSprintfEmpty	 2000000	       995 ns/op
fmt_test.BenchmarkSprintfString	 1000000	      2745 ns/op
fmt_test.BenchmarkSprintfInt	 1000000	      2391 ns/op
fmt_test.BenchmarkSprintfIntInt	  500000	      3751 ns/op

I believe there is more to get but this is a good milestone.

R=rsc
CC=golang-dev, hong
https://golang.org/cl/166076
2009-12-06 12:03:52 -08:00
Russ Cox
ed6fd1bcbe runtime: disable pointer scan optimization
* broken by reflect, gob

TBR=r
https://golang.org/cl/166077
2009-12-06 08:18:58 -08:00
Ian Lance Taylor
44c1eb6bed Fix syscall.Statfs and syscall.Fstatfs for 386 GNU/Linux.
For 386 we use the [f]statfs64 system call, which takes three
parameters: the filename, the size of the statfs64 structure,
and a pointer to the structure itself.

R=rsc
https://golang.org/cl/166073
2009-12-04 21:58:32 -08:00
Russ Cox
864c757a1c gc/runtime: pass type structure to makeslice.
* inform garbage collector about memory with no pointers in it

1.9s	gcc reverse-complement.c

reverse-complement.go
4.5s / 3.5s	original, with/without bounds checks
3.5s / 3.3s	bounds check reduction
3.3s / 2.8s	smarter garbage collector
2.6s / 2.3s		assembler bytes.IndexByte
2.5s / 2.1s	even smarter garbage collector (this CL)

R=r
https://golang.org/cl/165064
2009-12-04 21:44:05 -08:00
Russ Cox
6f14cada11 gc: walk pointer in range on slice/array
R=ken2
https://golang.org/cl/166071
2009-12-04 20:40:21 -08:00
Russ Cox
7c4aeec868 6g/8g optimizer fix: throw functions now in runtime
R=ken2
https://golang.org/cl/166070
2009-12-04 20:37:32 -08:00
Russ Cox
d7402cea8c gotest: stop if the // gotest commands fail
R=r
https://golang.org/cl/166067
2009-12-04 18:34:59 -08:00
Russ Cox
2807621d01 net: more fiddling with the udp test.
i don't know why the timeout needs
  to be so big.

R=r
https://golang.org/cl/165063
2009-12-04 18:34:45 -08:00
Russ Cox
d539d079ad libmach: fix disassembly of MOVLQSX
R=r
https://golang.org/cl/166068
2009-12-04 18:34:35 -08:00
Russ Cox
01f0f16ebc gotest: ignore *_test.pb.go
R=r
https://golang.org/cl/166064
2009-12-04 17:08:54 -08:00
Ian Lance Taylor
9e0b68d1ee Add syscall.Rename for NaCl. Fixes NaCl build.
R=rsc
https://golang.org/cl/165062
2009-12-04 13:49:58 -08:00
Adam Langley
e79bcf8bfd runtime: shift the index for the sort by one.
Makes the code look cleaner, even if it's a little harder to figure
out from the sort invariants.

R=rsc
CC=golang-dev
https://golang.org/cl/165061
2009-12-04 13:31:18 -08:00
Ian Lance Taylor
0b5cc31693 Add os.Rename.
R=rsc
https://golang.org/cl/166058
2009-12-04 11:46:56 -08:00
Adam Langley
d1740bb3a6 Remove global chanlock.
On a microbenchmark that ping-pongs on lots of channels, this makes
the multithreaded case about 20% faster and the uniprocessor case
about 1% slower. (Due to cache effects, I expect.)

R=rsc, agl
CC=golang-dev
https://golang.org/cl/166043
2009-12-04 10:57:01 -08:00
Russ Cox
d6b3f37e1e bytes: asm for bytes.IndexByte
PERFORMANCE DIFFERENCE

SUMMARY

                                                   amd64           386
2.2 GHz AMD Opteron 8214 HE (Linux)             3.0x faster    8.2x faster
3.60 GHz Intel Xeon (Linux)                     2.2x faster    6.2x faster
2.53 GHz Intel Core2 Duo E7200 (Linux)          1.5x faster    4.4x faster
2.66 Ghz Intel Xeon 5150 (Mac Pro, OS X)        1.5x SLOWER    3.0x faster
2.33 GHz Intel Xeon E5435 (Linux)               1.5x SLOWER    3.0x faster
2.33 GHz Intel Core2 T7600 (MacBook Pro, OS X)  1.4x SLOWER    3.0x faster
1.83 GHz Intel Core2 T5600 (Mac Mini, OS X)        none*       3.0x faster

* but yesterday I consistently saw 1.4x SLOWER.

DETAILS

2.2 GHz AMD Opteron 8214 HE (Linux)

amd64 (3x faster)

IndexByte4K            500000           3733 ns/op     1097.24 MB/s
IndexByte4M               500        4328042 ns/op      969.10 MB/s
IndexByte64M               50       67866160 ns/op      988.84 MB/s

IndexBytePortable4K    200000          11161 ns/op      366.99 MB/s
IndexBytePortable4M       100       11795880 ns/op      355.57 MB/s
IndexBytePortable64M       10      188675000 ns/op      355.68 MB/s

386 (8.2x faster)

IndexByte4K            500000           3734 ns/op     1096.95 MB/s
IndexByte4M               500        4209954 ns/op      996.28 MB/s
IndexByte64M               50       68031980 ns/op      986.43 MB/s

IndexBytePortable4K     50000          30670 ns/op      133.55 MB/s
IndexBytePortable4M        50       31868220 ns/op      131.61 MB/s
IndexBytePortable64M        2      508851500 ns/op      131.88 MB/s

3.60 GHz Intel Xeon (Linux)

amd64 (2.2x faster)

IndexByte4K            500000           4612 ns/op      888.12 MB/s
IndexByte4M               500        4835250 ns/op      867.44 MB/s
IndexByte64M               20       77388450 ns/op      867.17 MB/s

IndexBytePortable4K    200000          10306 ns/op      397.44 MB/s
IndexBytePortable4M       100       11201460 ns/op      374.44 MB/s
IndexBytePortable64M       10      179456800 ns/op      373.96 MB/s

386 (6.3x faster)

IndexByte4K            500000           4631 ns/op      884.47 MB/s
IndexByte4M               500        4846388 ns/op      865.45 MB/s
IndexByte64M               20       78691200 ns/op      852.81 MB/s

IndexBytePortable4K    100000          28989 ns/op      141.29 MB/s
IndexBytePortable4M        50       31183180 ns/op      134.51 MB/s
IndexBytePortable64M        5      498347200 ns/op      134.66 MB/s

2.53 GHz Intel Core2 Duo E7200  (Linux)

amd64 (1.5x faster)

IndexByte4K            500000           6502 ns/op      629.96 MB/s
IndexByte4M               500        6692208 ns/op      626.74 MB/s
IndexByte64M               10      107410400 ns/op      624.79 MB/s

IndexBytePortable4K    200000           9721 ns/op      421.36 MB/s
IndexBytePortable4M       100       10013680 ns/op      418.86 MB/s
IndexBytePortable64M       10      160460800 ns/op      418.23 MB/s

386 (4.4x faster)

IndexByte4K            500000           6505 ns/op      629.67 MB/s
IndexByte4M               500        6694078 ns/op      626.57 MB/s
IndexByte64M               10      107397600 ns/op      624.86 MB/s

IndexBytePortable4K    100000          28835 ns/op      142.05 MB/s
IndexBytePortable4M        50       29562680 ns/op      141.88 MB/s
IndexBytePortable64M        5      473221400 ns/op      141.81 MB/s

2.66 Ghz Intel Xeon 5150  (Mac Pro, OS X)

amd64 (1.5x SLOWER)

IndexByte4K            200000           9290 ns/op      440.90 MB/s
IndexByte4M               200        9568925 ns/op      438.33 MB/s
IndexByte64M               10      154473600 ns/op      434.44 MB/s

IndexBytePortable4K    500000           6202 ns/op      660.43 MB/s
IndexBytePortable4M       500        6583614 ns/op      637.08 MB/s
IndexBytePortable64M       20      107166250 ns/op      626.21 MB/s

386 (3x faster)

IndexByte4K            200000           9301 ns/op      440.38 MB/s
IndexByte4M               200        9568025 ns/op      438.37 MB/s
IndexByte64M               10      154391000 ns/op      434.67 MB/s

IndexBytePortable4K    100000          27526 ns/op      148.80 MB/s
IndexBytePortable4M       100       28302490 ns/op      148.20 MB/s
IndexBytePortable64M        5      454170200 ns/op      147.76 MB/s

2.33 GHz Intel Xeon E5435  (Linux)

amd64 (1.5x SLOWER)

IndexByte4K            200000          10601 ns/op      386.38 MB/s
IndexByte4M               100       10827240 ns/op      387.38 MB/s
IndexByte64M               10      173175500 ns/op      387.52 MB/s

IndexBytePortable4K    500000           7082 ns/op      578.37 MB/s
IndexBytePortable4M       500        7391792 ns/op      567.43 MB/s
IndexBytePortable64M       20      122618550 ns/op      547.30 MB/s

386 (3x faster)

IndexByte4K            200000          11074 ns/op      369.88 MB/s
IndexByte4M               100       10902620 ns/op      384.71 MB/s
IndexByte64M               10      181292800 ns/op      370.17 MB/s

IndexBytePortable4K     50000          31725 ns/op      129.11 MB/s
IndexBytePortable4M        50       32564880 ns/op      128.80 MB/s
IndexBytePortable64M        2      545926000 ns/op      122.93 MB/s

2.33 GHz Intel Core2 T7600 (MacBook Pro, OS X)

amd64 (1.4x SLOWER)

IndexByte4K            200000          11120 ns/op      368.35 MB/s
IndexByte4M               100       11531950 ns/op      363.71 MB/s
IndexByte64M               10      184819000 ns/op      363.11 MB/s

IndexBytePortable4K    500000           7419 ns/op      552.10 MB/s
IndexBytePortable4M       200        8018710 ns/op      523.06 MB/s
IndexBytePortable64M       10      127614900 ns/op      525.87 MB/s

386 (3x faster)

IndexByte4K            200000          11114 ns/op      368.54 MB/s
IndexByte4M               100       11443530 ns/op      366.52 MB/s
IndexByte64M               10      185212000 ns/op      362.34 MB/s

IndexBytePortable4K     50000          32891 ns/op      124.53 MB/s
IndexBytePortable4M        50       33930580 ns/op      123.61 MB/s
IndexBytePortable64M        2      545400500 ns/op      123.05 MB/s

1.83 GHz Intel Core2 T5600  (Mac Mini, OS X)

amd64 (no difference)

IndexByte4K            200000          13497 ns/op      303.47 MB/s
IndexByte4M               100       13890650 ns/op      301.95 MB/s
IndexByte64M                5      222358000 ns/op      301.81 MB/s

IndexBytePortable4K    200000          13584 ns/op      301.53 MB/s
IndexBytePortable4M       100       13913280 ns/op      301.46 MB/s
IndexBytePortable64M       10      222572600 ns/op      301.51 MB/s

386 (3x faster)

IndexByte4K            200000          13565 ns/op      301.95 MB/s
IndexByte4M               100       13882640 ns/op      302.13 MB/s
IndexByte64M                5      221411600 ns/op      303.10 MB/s

IndexBytePortable4K     50000          39978 ns/op      102.46 MB/s
IndexBytePortable4M        50       41038160 ns/op      102.20 MB/s
IndexBytePortable64M        2      656362500 ns/op      102.24 MB/s

R=r
CC=golang-dev
https://golang.org/cl/166055
2009-12-04 10:23:43 -08:00
Russ Cox
609eeee817 make Native Client support build again,
add README explaining how to try the
web demos.

Fixes #339.

R=r
CC=barry.d.silverman, bss, vadim
https://golang.org/cl/165057
2009-12-04 10:11:32 -08:00
Russ Cox
11384eecf8 testing: compute MB/s in benchmarks
R=r
https://golang.org/cl/166060
2009-12-04 09:56:31 -08:00
Rob Pike
4ed57173b4 avoid an allocation inside bytes.Buffer by providing a static array.
R=rsc
https://golang.org/cl/165058
2009-12-04 00:26:08 -08:00
Russ Cox
f2c7a20142 8l: fix print line number format, buffer overflow
R=ken2
https://golang.org/cl/165059
2009-12-03 23:29:48 -08:00
Russ Cox
3b858fb808 net: turn off empty packet test by default
Fixes #374.

R=r
https://golang.org/cl/166053
2009-12-03 22:19:55 -08:00
Russ Cox
9da6666a8a gc: check for assignment to private fields during initialization
R=ken2
https://golang.org/cl/165055
2009-12-03 22:09:58 -08:00
Ken Thompson
62be24d949 6g code gen bug
R=rsc
https://golang.org/cl/166052
2009-12-03 20:28:24 -08:00
Michael Elkins
f3d63bea42 Add Count, Cycle, ZipWith, GroupBy, Repeat, RepeatTimes, Unique to exp/iterable.
Modify iterFunc to take chan<- instead of just chan.

R=rsc, dsymonds1
CC=golang-dev, r
https://golang.org/cl/160064
2009-12-03 20:03:07 -08:00
Adam Langley
e93132c982 crypto/rsa: fix shadowing error.
Fixes bug 375.

R=rsc
https://golang.org/cl/165045
2009-12-03 19:33:23 -08:00
Russ Cox
cf37254b1c runtime: fix Caller crash on 386.
Fixes #176.

R=r
https://golang.org/cl/166044
2009-12-03 17:24:14 -08:00
Russ Cox
aaa2374b74 Make.conf: fix if $HOME has spaces
R=r
https://golang.org/cl/164086
2009-12-03 17:22:43 -08:00
Russ Cox
7e5055ceea runtime: malloc fixes
* throw away dead code
  * add mlookup counter
  * add malloc counter
  * set up for blocks with no pointers

Fixes #367.

R=r
https://golang.org/cl/165050
2009-12-03 17:22:23 -08:00
Rob Pike
10a349a7c1 The String() method requires global state that makes it not work outside of this package,
so make it a local method (_String()).

R=rsc
CC=golang-dev
https://golang.org/cl/165049
2009-12-03 17:14:32 -08:00
Rob Pike
fcc4dd6d64 error propagation in gob/encoder.
R=rsc
CC=golang-dev
https://golang.org/cl/165048
2009-12-03 17:12:57 -08:00
Rob Pike
bc3e34759c Add ReadFrom and WriteTo methods to bytes.Buffer, to enable i/o without buffer allocation.
Use them in Copy and Copyn.
Speed up ReadFile by using ReadFrom and avoiding Copy altogether (a minor win).

R=rsc, gri
CC=golang-dev
https://golang.org/cl/166041
2009-12-03 12:56:16 -08:00
Christopher Wedgwood
7e7008fa5e gc: Allow allow data types up to 1GB
R=rsc
https://golang.org/cl/164095
2009-12-03 12:46:34 -08:00
Robert Griesemer
6db683fe4d - include type-associated consts and vars when filtering a PackageDoc
- fixes a godoc issue (for instance, "godoc os EOF" now shows an entry)

R=r
CC=rsc
https://golang.org/cl/165042
2009-12-03 11:25:20 -08:00
Russ Cox
c6e316a4b9 gc: handle _ = <-c in select.
Fixes #238.

R=ken2
https://golang.org/cl/163098
2009-12-03 01:30:19 -08:00
Russ Cox
05a1eb1ab0 gc: recursive type error
Fixes #245.

R=ken2
https://golang.org/cl/164094
2009-12-03 01:12:02 -08:00
Russ Cox
41861a8812 gc: better diagnosis of initialization loops
Fixes bug 292.

R=ken2
https://golang.org/cl/164093
2009-12-03 00:51:03 -08:00
Russ Cox
e733766dda gc: minor import grammar bug fixes
Fixes #364.

R=ken2
https://golang.org/cl/164092
2009-12-03 00:10:32 -08:00
Rob Pike
d984f98996 minor improvement to formatting: don't allocate padding strings every time.
R=rsc
https://golang.org/cl/164090
2009-12-03 00:04:40 -08:00
Russ Cox
272d156357 gc: function argument ordering bug
Fixes #370.

R=ken2
https://golang.org/cl/163097
2009-12-02 23:54:51 -08:00
Russ Cox
8777759f59 gc: make 'invalid rune in string' a little less cryptic
Fixes #371.

R=ken2
https://golang.org/cl/164091
2009-12-02 23:23:11 -08:00
Rob Pike
b0683bd77a move ReadFile, WriteFile, and ReadDir into a separate io/ioutil package.
this breaks the dependency of package io on package bytes.

R=rsc
CC=golang-dev
https://golang.org/cl/163085
2009-12-02 22:02:14 -08:00
Peter Froehlich
1eba218e44 Runes: turn string into []int
Split: fixed typo in documentation

R=rsc, r, r1
https://golang.org/cl/157170
2009-12-02 20:47:38 -08:00
Robert Griesemer
c0efa07c65 updated documentation for gofmt
R=rsc
https://golang.org/cl/164085
2009-12-02 19:32:15 -08:00
Russ Cox
69c0edd59b 8g: discard tempalloc/tempfree experiment
in favor of tempname.
allows optimizer to do more.
unfortunately, optimizer seems to be broken; disable it.

R=ken2
https://golang.org/cl/163091
2009-12-02 18:31:29 -08:00
Russ Cox
fdb030d86f 6g etc: groundwork for eliminating redundant bounds checks.
drop check in range over array.
	drop check in [256]array indexed by byte.

R=ken2
https://golang.org/cl/163088
2009-12-02 17:30:07 -08:00
Robert Griesemer
dc7355a974 Add flag -tabindent to gofmt: forces use of
tabs for indentation even if -spaces is set.

Changes to gofmt:
- added -tabindent flag
- don't recompute parser and printer mode repeatedly

Changes to go/printer:
- provide new printing mode TabIndent

Changes to tabwriter:
- implement new mode TabIndent to use tabs independent
  of the actual padding character for leading empty columns
- distinguish between minimal cell width and tab width
  (tabwidth is only used if the output contains tabs,
  minwidth and padding are always considered)
- fixed and added more comments
- some additional factoring

By default, -tabindent is disabled and the default gofmt
behavior is unchanged. By setting -spaces and -tabindent,
gofmt will use tabs for indentation but do any other
alignment with spaces. This permits a user to change the
visible indentation by simply changing the editor's tab
width and the code will remain properly aligned without
the need to rerun gofmt.

R=rsc
https://golang.org/cl/163068
2009-12-02 16:57:15 -08:00
Russ Cox
e89441ba8f net: test and fix support for 0-length datagram packets.
Fixes #274.

R=r
CC=jonathan.r.hudson
https://golang.org/cl/163072
2009-12-02 15:17:49 -08:00
Fazlul Shahriar
0aa13c999b gofmt: race condition in error reporting and setting exit code
How to reproduce:

	$ mkdir /tmp/foo
	$ cp /dev/null /tmp/foo/bar.go
	$ chmod -r /tmp/foo/bar.go
	$ gofmt /tmp/foo
	open /tmp/foo/bar.go: permission denied
	$ echo $?		# should echo 2
	0
	$

Maybe you need to put a call to time.Sleep at the beginning of report().

R=gri
CC=golang-dev
https://golang.org/cl/164073
2009-12-02 13:02:42 -08:00
Robert Griesemer
d8bc797ed5 apply gofmt to json files
R=rsc
https://golang.org/cl/164071
2009-12-02 11:40:54 -08:00
Rob Pike
114f73f822 fix segfault printing errors. add test case and improve messages.
Fixes #338.

R=rsc
CC=golang-dev
https://golang.org/cl/163083
2009-12-02 10:41:28 -08:00
Rob Pike
f6c0eba741 test that arrays work properly.
can't mix slices and arrays now; perhaps that should be a TODO

R=rsc
https://golang.org/cl/164079
2009-12-02 10:25:14 -08:00
Russ Cox
9e55d0d018 time: another bug in SecondsToUTC.
added random test to look for more.

Fixes #363.

R=r, cw
https://golang.org/cl/163071
2009-12-02 08:27:57 -08:00
Ian Lance Taylor
952b91e4ad Add Shutdown to 32-bit GNU/Linux build.
Submitting as a TBR to fix the build.

R=dho, rsc
https://golang.org/cl/164078
2009-12-02 08:24:14 -08:00
Russ Cox
8d652ee8ce time: fix handling of Jan 1 1601, 1201, 801, ...
R=r
CC=hurtonm
https://golang.org/cl/164074
2009-12-01 23:38:06 -08:00
Devon H. O'Dell
eb16346dac net: fix netFD.Close races
Fixes #271.
Fixes #321.

R=rsc, agl, cw
CC=golang-dev
https://golang.org/cl/163052
2009-12-01 23:28:57 -08:00
Rob Pike
ff3ea68e52 explicitly catch attempt to decode into a value - must be a pointer to see the result.
R=rsc
https://golang.org/cl/163070
2009-12-01 21:47:00 -08:00
Rob Pike
f9810f1b12 make io.ReadFile use Stat.Size as a hint for preallocation
R=rsc
CC=golang-dev
https://golang.org/cl/163069
2009-12-01 21:44:24 -08:00