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

554 Commits

Author SHA1 Message Date
Russ Cox
434f1e32a0 runtime: remove tiny
It is unmaintained and untested, and I think it's broken too.
It was a toy to show that Go can run on real hardware,
and it served its purpose.

The source code will of course remain in the repository
history, so it could be brought back if needed later.

R=r, r2, uriel
CC=golang-dev
https://golang.org/cl/3996047
2011-01-26 08:41:23 -05:00
Alex Brainman
b7949035d6 runtime: fix windows build
R=golang-dev
CC=golang-dev
https://golang.org/cl/4052046
2011-01-26 09:50:15 +11:00
Russ Cox
afc6928ad9 runtime: prefer fixed stack allocator over general memory allocator
* move stack constants from proc.c to runtime.h
  * make memclr take uintptr length

R=r
CC=golang-dev
https://golang.org/cl/3985046
2011-01-25 16:35:36 -05:00
Hector Chu
90294a08c8 runtime: make Walk webbrowser example work
R=rsc, brainman, lxn
CC=golang-dev
https://golang.org/cl/4005045
2011-01-25 17:56:33 +11:00
Alex Brainman
f0b8f84d37 runtime: implementation of callback functions for windows
R=rsc, lxn, alex.brainman, dho
CC=golang-dev
https://golang.org/cl/1696051
2011-01-22 13:55:53 +11:00
Russ Cox
27c74d3499 spec, runtime, tests: send on closed channel panics
Close of closed channel panics.
Receive from closed channel never panics,
even if done repeatedly.

Fixes #1349.
Fixes #1419.

R=gri, iant, ken2, r, gri1, r2, iant2, rog, albert.strasheim, niemeyer, ejsherry
CC=golang-dev
https://golang.org/cl/3989042
2011-01-21 15:07:13 -05:00
Russ Cox
3c7104479c runtime: drop CLONE_PARENT
The functionality we want (shared ppid) is implied
by CLONE_THREAD already, and CLONE_PARENT
causes problems if the Go program is pid 1 (init).

See issue 1406 for more details.

Fixes #1406.

R=adg, iant
CC=golang-dev
https://golang.org/cl/3971044
2011-01-20 13:36:00 -05:00
Wei Guangjing
1aa2d88739 cgo: windows/386 port
R=rsc, peterGo, brainman
CC=golang-dev
https://golang.org/cl/3733046
2011-01-20 10:22:20 -05:00
Hector Chu
6c240d7671 runtime: fix tabs in windows/386/sys.s
R=rsc, brainman
CC=golang-dev
https://golang.org/cl/4030043
2011-01-20 09:21:04 -05:00
Russ Cox
4f269d3060 runtime: make select fairer
The o+i*p approach to visiting select cases in random
order stops being fair when there is some case that
is never ready.  If that happens, then the case that follows
it in the order gets more chances than the others.

In general the only way to ensure fairness is to make
all permutations equally likely.  I've done that by computing
one explicitly.

Makes the permutations correct for n >= 4 where
previously they were broken.  For n > 12, there's not
enough randomness to do a perfect job but this should
still be much better than before.

Fixes #1425.

R=r, ken2, ejsherry
CC=golang-dev
https://golang.org/cl/4037043
2011-01-20 09:20:47 -05:00
Russ Cox
f2b5a07453 delete float, complex - code changes
also:
	cmplx -> complex
	float64(1.0) -> 1.0
	float64(1) -> 1.0

R=gri, r, gri1, r2
CC=golang-dev
https://golang.org/cl/3991043
2011-01-19 23:09:00 -05:00
Rob Pike
b99a6d465a runtime/debug: fix build (missing Makefile)
Why does this happen so often?

R=rsc
CC=golang-dev
https://golang.org/cl/4067042
2011-01-19 12:36:52 -08:00
Rob Pike
89993544c2 runtime/debug: new package
Facilities for printing stack traces from within a running goroutine.

R=rsc
CC=golang-dev
https://golang.org/cl/4031041
2011-01-19 12:28:38 -08:00
Hector Chu
aae5f91213 windows: implement exception handling
R=rsc, brainman
CC=golang-dev
https://golang.org/cl/4079041
2011-01-19 15:10:15 -05:00
Russ Cox
bcd910cfe2 runtime: add per-pause gc stats
R=r, r2
CC=golang-dev
https://golang.org/cl/3980042
2011-01-19 13:41:42 -05:00
Russ Cox
b0543ddd8a gc, runtime: make range on channel safe for multiple goroutines
Fixes #397.

R=ken2
CC=golang-dev
https://golang.org/cl/3994043
2011-01-18 15:59:19 -05:00
Russ Cox
12307008e9 runtime: print signal information during panic
$ 6.out
panic: runtime error: invalid memory address or nil pointer dereference

[signal 11 code=0x1 addr=0x0 pc=0x1c16]

runtime.panic+0xa7 /Users/rsc/g/go/src/pkg/runtime/proc.c:1089
	runtime.panic(0xf6c8, 0x25c010)
runtime.panicstring+0x69 /Users/rsc/g/go/src/pkg/runtime/runtime.c:88
	runtime.panicstring(0x24814, 0x0)
runtime.sigpanic+0x144 /Users/rsc/g/go/src/pkg/runtime/darwin/thread.c:465
	runtime.sigpanic()
main.f+0x16 /Users/rsc/x.go:5
	main.f()
main.main+0x1c /Users/rsc/x.go:9
	main.main()
runtime.mainstart+0xf /Users/rsc/g/go/src/pkg/runtime/amd64/asm.s:77
	runtime.mainstart()
runtime.goexit /Users/rsc/g/go/src/pkg/runtime/proc.c:149
	runtime.goexit()

R=r
CC=golang-dev
https://golang.org/cl/4036042
2011-01-18 14:15:11 -05:00
Russ Cox
141a4a1759 runtime: fix arm reflect.call boundary case
The fault was lucky: when it wasn't faulting it was silently
copying a word from some other block and later putting
that same word back.  If some other goroutine had changed
that word of memory in the interim, too bad.

The ARM code was inconsistent about whether the
"argument frame" included the saved LR.  Including it made
some things more regular but mostly just caused confusion
in the places where the regularity broke.  Now the rule
reflects reality: argp is always a pointer to arguments,
never a saved link register.

Renamed struct fields to make meaning clearer.

Running ARM in QEMU, package time's gotest:
  * before: 27/58 failed
  * after: 0/50

R=r, r2
CC=golang-dev
https://golang.org/cl/3993041
2011-01-14 14:05:20 -05:00
Ian Lance Taylor
b97005c1d3 runtime/cgo: Don't define crosscall2 in dummy _cgo_main.c.
In this specific package crosscall2 is already defined in a .S
file anyhow.  This avoids a warning about mismatched
alignment.

R=rsc
CC=golang-dev
https://golang.org/cl/4000043
2011-01-14 10:51:47 -08:00
Alex Brainman
a41d85498e runtime: revert 6974:1f3c3696babb
I missed that environment is used during runtime setup,
well before go init() functions run. Implemented os-dependent
runtime.goenvs functions to allow for different unix, plan9 and
windows versions of environment discovery.

R=rsc, paulzhol
CC=golang-dev
https://golang.org/cl/3787046
2011-01-12 11:48:15 +11:00
Ian Lance Taylor
17d50d8664 runtime/cgo: Add callbacks to support SWIG.
R=rsc, iant2, r
CC=golang-dev
https://golang.org/cl/3886041
2011-01-11 09:36:44 -08:00
Ian Lance Taylor
2d39303429 runtime: Restore scheduler stack position if cgo callback panics.
If we don't do this, then when C code calls back to Go code
which panics, we lose space on the scheduler stack.  If that
happens a lot, eventually there is no space left on the
scheduler stack.

R=rsc
CC=golang-dev
https://golang.org/cl/3898042
2011-01-08 10:22:37 -08:00
Anthony Martin
db89e19d26 runtime/cgo: fix stackguard on FreeBSD/amd64
A cursory reading of the cgo code suggests this
should be necessary, though I don't have access
to a FreeBSD machine for testing.

R=rsc, adg
CC=golang-dev
https://golang.org/cl/3746047
2011-01-06 11:36:47 -05:00
Russ Cox
3832389036 fix cgo build
R=r
CC=golang-dev
https://golang.org/cl/3750041
2010-12-17 13:22:20 -08:00
Russ Cox
0cd3475386 misc/cgo/life: fix, add to build
#pragma dynexport is no longer needed for
this use of cgo, since the gcc and gc code are
now linked together into the same binary.
It may still be necessary later.

On the Mac, you cannot use the GOT to resolve
symbols that exist in the current binary, so 6l and 8l
translate the GOT-loading mov instructions into lea
instructions.

On ELF systems, we could use the GOT for those
symbols, but for consistency 6l and 8l apply the
same translation.

The translation is sketchy in the extreme
(depending on the relocation being in a mov
instruction) but it verifies that the instruction
is a mov before rewriting it to lea.

Also makes typedefs global across files.

Fixes #1335.
Fixes #1345.

R=iant, r
CC=golang-dev
https://golang.org/cl/3650042
2010-12-17 09:51:55 -08:00
Russ Cox
b3e8fdce8d darwin, freebsd: ignore write failure (during print, panic)
The other operating systems already ignore write failures.

Fixes #1279.

R=r, r2
CC=golang-dev
https://golang.org/cl/3723041
2010-12-16 12:46:56 -08:00
Alex Brainman
c83451971e runtime: move windows goargs implementation from runtime and into os package
R=rsc
CC=golang-dev
https://golang.org/cl/3702041
2010-12-16 12:18:18 +11:00
Russ Cox
33405ecc86 fix freebsd build
R=iant, r
CC=dho, golang-dev
https://golang.org/cl/3687041
2010-12-15 17:20:26 -05:00
Russ Cox
0c54225b51 remove nacl
The recent linker changes broke NaCl support
a month ago, and there are no known users of it.

The NaCl code can always be recovered from the
repository history.

R=adg, r
CC=golang-dev
https://golang.org/cl/3671042
2010-12-15 11:49:23 -05:00
Luuk van Dijk
7a4ce23d65 [68]l and runtime: GDB support for interfaces and goroutines.
R=rsc
CC=golang-dev
https://golang.org/cl/3477041
2010-12-15 12:00:43 +01:00
Russ Cox
d110ae8dd0 runtime: write only to standard error
Will mail a warning to golang-nuts once this is submitted.

R=r, niemeyer
CC=golang-dev
https://golang.org/cl/3573043
2010-12-14 11:52:42 -05:00
Russ Cox
951318c0df runtime: remove paranoid mapping at 0
Too many programs complain that we even try.
This was a bit of security paranoia and not worth
the bother.

Fixes #1340.

R=r, r2
CC=golang-dev
https://golang.org/cl/3579042
2010-12-13 16:57:35 -05:00
Russ Cox
dc9a3b2791 gc: align structs according to max alignment of fields
cc: same
runtime: test cc alignment (required moving #define of offsetof to runtime.h)
fix bug260

Fixes #482.
Fixes #609.

R=ken2, r
CC=golang-dev
https://golang.org/cl/3563042
2010-12-13 16:22:19 -05:00
Russ Cox
cc1556d9a2 runtime/linux/386: set FPU to 64-bit precision
Fixes #550.

R=r
CC=golang-dev
https://golang.org/cl/3469044
2010-12-13 10:04:53 -05:00
Wei Guangjing
e04ef7769e Fix windows build.
R=brainman, rsc
CC=golang-dev
https://golang.org/cl/3533041
2010-12-13 16:41:02 +11:00
Ken Thompson
ae60526848 arm floating point simulation
R=rsc
CC=golang-dev
https://golang.org/cl/3565041
2010-12-09 14:45:27 -08:00
Russ Cox
85d9ab61d2 arm: more fixes
R=ken2
CC=golang-dev
https://golang.org/cl/3523041
2010-12-08 16:49:49 -05:00
Russ Cox
7eeebf49be runtime/cgo: adapt files copied from libcgo
Necessary but not sufficient step toward
making those builds work.

R=r
CC=golang-dev
https://golang.org/cl/3411043
2010-12-08 16:35:05 -05:00
Russ Cox
98b2d7062e libcgo: delete (replaced by runtime/cgo)
Move unported files (freebsd*, windows*, nacl*) to runtime/cgo.

Step toward fixing FreeBSD build.

R=r
TBR=r
CC=golang-dev
https://golang.org/cl/3497042
2010-12-08 14:33:17 -05:00
Russ Cox
b07b04d35f runtime/cgo: take 2
This is a second attempt at submitting
https://golang.org/cl/3420043

A Mercurial problem lost the new files
in that submit.

TBR=r
CC=golang-dev
https://golang.org/cl/3511043
2010-12-08 14:10:00 -05:00
Russ Cox
9042c2ce68 runtime/cgo: runtime changes for new cgo
Formerly known as libcgo.
Almost no code here is changing; the diffs
are shown relative to the originals in libcgo.

R=r
CC=golang-dev
https://golang.org/cl/3420043
2010-12-08 13:53:30 -05:00
Alex Brainman
60c91bbf4c runtime: fix windows build
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/3419043
2010-12-08 12:52:36 +11:00
Keith Rarick
51a2183851 runtime: add Goroutines
R=rsc
CC=golang-dev
https://golang.org/cl/3508041
2010-12-07 18:06:31 -05:00
Russ Cox
7e14bd81f4 runtime: debugging help on 386
R=r
CC=golang-dev
https://golang.org/cl/3502041
2010-12-07 17:19:36 -05:00
Wei Guangjing
70deac67cf 8l : add dynimport to import table in Windows PE, initial make cgo dll work.
R=rsc, brainman, Joe Poirier, mattn
CC=golang-dev
https://golang.org/cl/2166041
2010-12-07 15:28:33 -05:00
Andrew Gerrand
79dcf180a2 runtime: fix build for nacl
R=lvd
CC=golang-dev
https://golang.org/cl/3391044
2010-12-07 15:24:46 +11:00
Yuval Pavel Zholkover
8221eb9103 8l, runtime: fix Plan 9 386 build.
8l was broken by commit 7ac0d2eed9, it caused .data to be page aligned in the file - which is not how Plan 9 expects things to be.
Also .rodata was layed out in a similar fashion.

Not sure when signame was introduced, but added a stub.
Removed the symo assignment in asm.c as it is not currently used.

Fix runtime breakage after commit 629c065d36 which prefixes all external symbols with runtime·.

R=rsc
CC=golang-dev
https://golang.org/cl/2674041
2010-12-06 16:38:28 -05:00
Luuk van Dijk
9a71bb00bb [68]l: generate debug info for builtin structured types. prettyprinting in gdb.
R=rsc
CC=golang-dev
https://golang.org/cl/3309041
2010-12-03 19:19:33 +01:00
Luuk van Dijk
555feea117 runtime: fix windows breakage
R=iant
CC=golang-dev
https://golang.org/cl/3344044
2010-12-01 00:19:00 +01:00
Luuk van Dijk
85cae877f5 runtime: parallel definitions in Go for all C structs.
R=rsc
CC=golang-dev
https://golang.org/cl/3308041
2010-11-30 18:21:26 +01:00
Alex Brainman
4e69976a60 runtime: fix SysFree to really free memory on Windows
Fixes #1294.

R=golang-dev, PeterGo, iant
CC=golang-dev
https://golang.org/cl/3271041
2010-11-24 11:47:35 +11:00
Ian Lance Taylor
1fab0cd12a Makefiles: Don't define _64BIT now that 6c does it by default.
R=rsc
CC=golang-dev
https://golang.org/cl/3207041
2010-11-18 12:34:47 -08:00
Ken Thompson
8613eb56b2 last of the arm conversions
R=rsc
CC=golang-dev
https://golang.org/cl/3053041
2010-11-11 19:54:35 -08:00
Alex Brainman
b611137098 runtime: free memory allocated by windows CommandLineToArgv
R=golang-dev, r2
CC=golang-dev
https://golang.org/cl/3003043
2010-11-11 10:38:45 +11:00
Ian Lance Taylor
e8605b1279 runtime: omit runtime· prefix from static functions (in ARM code).
R=r
CC=golang-dev
https://golang.org/cl/3026041
2010-11-10 15:23:20 -08:00
Ian Lance Taylor
7e69c90ade runtime: Add some missing runtime· prefixes to ARM asm code.
R=r, r2
CC=golang-dev
https://golang.org/cl/3024041
2010-11-10 15:10:19 -08:00
Russ Cox
9ce0eb2d07 runtime: explain nacl closure failure
R=r, r2
CC=golang-dev
https://golang.org/cl/2889042
2010-11-05 14:00:46 -04:00
Alex Brainman
2b18b18263 runtime: fix windows build
R=rsc
CC=golang-dev
https://golang.org/cl/2923041
2010-11-05 17:27:12 +11:00
Graham Miller
23c41a1ef2 Small addition to previous optimization of memequal as discussed here: http://groups.google.com/group/golang-nuts/browse_thread/thread/f591ba36d83723c0/9aba02d344045f38
R=golang-dev, r, r2
CC=golang-dev
https://golang.org/cl/2880041
2010-11-04 13:45:18 -07:00
Russ Cox
68b4255a96 runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries.  The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.

The symbols left alone are:

	** known to cgo **
	_cgo_free
	_cgo_malloc
	libcgo_thread_start
	initcgo
	ncgocall

	** known to linker **
	_rt0_$GOARCH
	_rt0_$GOARCH_$GOOS
	text
	etext
	data
	end
	pclntab
	epclntab
	symtab
	esymtab

	** known to C compiler **
	_divv
	_modv
	_div64by32
	etc (arch specific)

Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.

Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.

R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 14:00:19 -04:00
Ken Thompson
9c6df3ca13 add hardware floating point.
currently, softfloat does not work and
there are some unsigned-to-float conversion errors.

R=rsc
CC=golang-dev
https://golang.org/cl/2886041
2010-11-03 17:31:07 -07:00
Russ Cox
d8b5d039cd gc: implement append
R=ken2
CC=golang-dev
https://golang.org/cl/2757042
2010-10-27 17:56:32 -07:00
Russ Cox
e48c0fb562 5g, 6g, 8g: generate code for string index
instead of calling function.

R=ken2
CC=golang-dev
https://golang.org/cl/2762041
2010-10-26 21:11:17 -07:00
Russ Cox
82c6f5e3d1 gc, runtime: copy([]byte, string)
R=ken2
CC=golang-dev
https://golang.org/cl/2741041
2010-10-26 08:36:07 -07:00
Russ Cox
8fff9166f6 arm: enable all tests
ARM functionality is now completely working.
(Or if it's not, we'll fix it.)

R=ken2
CC=golang-dev
https://golang.org/cl/2738041
2010-10-25 21:25:13 -07:00
Russ Cox
7c2b1597c6 arm: precise float64 software floating point
Adds softfloat64 to generic runtime
(will be discarded by linker when unused)
and adds test for it.  I used the test to check
the software code against amd64 hardware
and then check the software code against
the arm and its simulation of hardware.
The latter should have been a no-op (testing
against itself) but turned up a bug in 5c causing
the vlrt.c routines to miscompile.

These changes make the cmath, math,
and strconv tests pass without any special
accommodations for arm.

R=ken2
CC=golang-dev
https://golang.org/cl/2713042
2010-10-25 17:55:50 -07:00
Russ Cox
35f8a3f90e runtime: remove .c generated from .goc during make clean
R=r
CC=golang-dev
https://golang.org/cl/2704042
2010-10-25 16:54:59 -07:00
Russ Cox
079cbddbd8 arm: fix signal handler
R=ken2
CC=golang-dev
https://golang.org/cl/2670042
2010-10-26 01:32:36 +02:00
Luuk van Dijk
4228e62259 6l/8l: global and local variables and type info.
R=rsc
CC=golang-dev
https://golang.org/cl/2201044
2010-10-24 23:07:52 +02:00
Russ Cox
1dd0319be3 runtime: print unknown types in panic
R=r
CC=golang-dev
https://golang.org/cl/2683041
2010-10-22 17:04:32 -04:00
Russ Cox
4fd12c04c5 fix windows build
R=ken2
CC=golang-dev
https://golang.org/cl/2650041
2010-10-21 13:06:17 -04:00
Russ Cox
d10963b6d7 fix arm build
R=ken2
CC=golang-dev
https://golang.org/cl/2649041
2010-10-21 13:03:59 -04:00
Russ Cox
69188ad9bb arm: prop up software floating point
Just enough to make mov instructions work,
which in turn is enough to make strconv work
when it avoids any floating point calculations.
That makes a bunch of other packages pass
their tests.

Should suffice until hardware floating point
is available.

Enable package tests that now pass
(some due to earlier fixes).

Looks like there is a new integer math bug
exposed in the fmt and json tests.

R=ken2
CC=golang-dev
https://golang.org/cl/2638041
2010-10-21 06:56:20 +02:00
Russ Cox
6a3b29895f runtime: don't let select split stack
Fixes #1209.

R=ken2
CC=golang-dev
https://golang.org/cl/2612041
2010-10-20 15:54:17 -04:00
Russ Cox
c026c91b5c arm: fix typo in softfloat
R=kaib
CC=golang-dev
https://golang.org/cl/2608041
2010-10-20 15:35:37 -04:00
Russ Cox
c2b91d4889 6l: correct logic for morestack choice
The frame that gets allocated is for both
the args and the autos.  If together they
exceed the default frame size, we need to
tell morestack about both so that it allocates
a large enough frame.

Sanity check stack pointer in morestack
to catch similar bugs.

R=ken2
CC=golang-dev
https://golang.org/cl/2609041
2010-10-20 12:16:39 -07:00
Russ Cox
19fd5c787f 5l, 6l, 8l: link pclntab and symtab as ordinary rodata symbols
That is, move the pc/ln table and the symbol table
into the read-only data segment.  This eliminates
the need for a special load command to map the
symbol table into memory, which makes the
information available on systems that couldn't handle
the magic load to 0x99000000, like NaCl and ARM QEMU
and Linux without config_highmem=y.  It also
eliminates an #ifdef and some clumsy code to
find the symbol table on Windows.

The bad news is that the binary appears to be bigger
than it used to be.  This is not actually the case, though:
the same amount of data is being mapped into memory
as before, and the tables are still read-only, so they're
still shared across multiple instances of the binary as
they were before.  The difference is just that the tables
aren't squirreled away in some section that "size" doesn't
know to look at.

This is a checkpoint.
It probably breaks Windows and breaks NaCl more
than it used to be broken, but those will be fixed.
The logic involving -s needs to be revisited too.

Fixes #871.

R=ken2
CC=golang-dev
https://golang.org/cl/2587041
2010-10-19 18:07:19 -04:00
Russ Cox
2012604002 runtime: fix arm softfloat again for R12
Missed a case, so now generalized.

R=ken2
CC=golang-dev
https://golang.org/cl/2540042
2010-10-18 13:24:19 -04:00
Russ Cox
9cc8e9ef48 runtime: fix amd64 build (broke by 386 support for Plan 9)
TBR=r
CC=golang-dev
https://golang.org/cl/2556041
2010-10-18 13:01:10 -04:00
Yuval Pavel Zholkover
99a10eff16 8l, runtime: initial support for Plan 9
No multiple processes/locks, managed to compile
and run a hello.go (with print not fmt).  Also test/sieve.go
seems to run until 439 and stops with a
'throw: all goroutines are asleep - deadlock!'
- just like runtime/tiny.

based on Russ's suggestions at:
http://groups.google.com/group/comp.os.plan9/browse_thread/thread/cfda8b82535d2d68/243777a597ec1612

Build instructions:
cd src/pkg/runtime
make clean && GOOS=plan9 make install
this will build and install the runtime.

When linking with 8l, you should pass -s to suppress symbol
generation in the a.out, otherwise the generated executable will not run.

This is runtime only, the porting of the toolchain has already
been done: http://code.google.com/p/go-plan9/source/browse
in the plan9-quanstro branch.

R=rsc
CC=golang-dev
https://golang.org/cl/2273041
2010-10-18 12:32:55 -04:00
Russ Cox
6ac08ba638 runtime: update arm softfloat - no more R12
R=ken2
CC=golang-dev
https://golang.org/cl/2555041
2010-10-18 12:24:59 -04:00
Russ Cox
8052786e51 5l: stop using R12 as SB
Because the SB is only good for 8k and Go programs
tend to have much more data than that, SB doesn't
save very much.  A fmt.Printf-based hello world program
has  360 kB text segment.  Removing SB makes the text
500 bytes (0.14%) longer.

R=ken2, r2, ken3
CC=golang-dev
https://golang.org/cl/2487042
2010-10-17 11:41:23 -04:00
Russ Cox
9b15ad8c22 arm: adjust recover for new reflect.call
R=ken2
CC=golang-dev
https://golang.org/cl/2471043
2010-10-14 10:45:32 -04:00
Ken Thompson
b33f5d537f fix arm bug in reflect.call
R=rsc
CC=golang-dev
https://golang.org/cl/2475042
2010-10-13 13:24:14 -07:00
Andrew Gerrand
78d19b9b73 runtime: remove done TODO from SetFinalizer
R=rsc
CC=golang-dev
https://golang.org/cl/2472041
2010-10-13 14:40:02 +11:00
Russ Cox
ded12ee4b5 arm: fix build
Effectively reverts https://code.google.com/p/go/source/detail?r=8c52477401ad
Should make ARM build pass again, but untested.
Probably still bugs involving reflect.call somewhere.

R=ken2
CC=golang-dev
https://golang.org/cl/2416042
2010-10-11 23:58:51 -04:00
Ken Thompson
ed575dc2b9 bug in stack size in arm.
stack is off by one if calling
through reflect.Call

R=rsc
CC=golang-dev
https://golang.org/cl/2400041
2010-10-08 16:46:05 -07:00
Russ Cox
1b6282a799 runtime: fix tiny build
Reported by Jeff Allen.

R=r, r2
CC=golang-dev
https://golang.org/cl/2385042
2010-10-07 06:46:01 -04:00
Russ Cox
7eb13b95a3 runtime: fix argument dump in traceback
Was printing words at SP instead of at FP
after shuffle due to nascent flag.

R=r, r2
CC=golang-dev
https://golang.org/cl/2316044
2010-10-07 06:45:40 -04:00
Graham Miller
62355959c6 runtime: faster strequal, memequal
Fixes #1161.

R=rsc, cwvh
CC=golang-dev
https://golang.org/cl/2317044
2010-10-07 03:13:24 -04:00
Russ Cox
8599a83727 runtime: correct iteration of large map values
The hash_next_and_deref was a dreg from a
previous large value scheme.

Fixes #1163.

R=r, r2
CC=golang-dev
https://golang.org/cl/2369043
2010-10-06 11:54:41 -04:00
Russ Cox
7389ab8d21 runtime: serialize mcache allocation
Fixes racy regex-dna-parallel crashes.

R=r, r2
CC=golang-dev
https://golang.org/cl/2308042
2010-09-30 14:09:19 -04:00
Russ Cox
5b7e50a0aa runtime: fix freebsd build
TBR=r
CC=golang-dev
https://golang.org/cl/2296041
2010-09-28 21:37:12 -04:00
Russ Cox
81041369b2 runtime: fix build
On systems where the mmap succeeds
(e.g., sysctl -w vm.mmap_min_addr=0)
it changes the signal code delivered for a
nil fault from ``page not mapped'' to
``invalid permissions for page.''

TBR=r
CC=golang-dev
https://golang.org/cl/2294041
2010-09-28 20:50:00 -04:00
Russ Cox
649aab835f runtime: add mmap of null page just in case
R=r, iant, robert.swiecki, rsc1
CC=golang-dev
https://golang.org/cl/1904044
2010-09-28 20:30:01 -04:00
Russ Cox
929fdd860b runtime: correct stats in SysFree
R=r
CC=golang-dev
https://golang.org/cl/2254047
2010-09-27 12:50:01 -04:00
Russ Cox
34d413f562 runtime: fix unwindstack crash
Bug and fix identified by Alexey Gokhberg.
Fixes #1135.

R=r, brainman
CC=golang-dev
https://golang.org/cl/2198046
2010-09-23 23:04:32 -04:00
Russ Cox
a2450c1456 cgo: bug fixes
* Add documentation about array arguments.  Fixes issue 1125.
* Do not interpret x, y := z, w as special errno form.  Fixes issue 952.
* Fix nested Go calls (brainman).  Fixes issue 907.

R=r
CC=golang-dev
https://golang.org/cl/2214044
2010-09-21 22:41:19 -04:00
Russ Cox
d4baf3ccb7 runtime: better panic for send to nil channel
*Much* better on NaCl, where memory faults are deadly.

R=r
CC=golang-dev
https://golang.org/cl/2249041
2010-09-19 23:28:12 -04:00
Russ Cox
af12feb8d5 6l, 8l: clean up ELF code, fix NaCl
R=r
CC=golang-dev
https://golang.org/cl/2221042
2010-09-19 22:10:34 -04:00
Russ Cox
f47d403cb4 gc: make string x + y + z + ... + w efficient
1 malloc per concatenation.

R=ken2
CC=golang-dev
https://golang.org/cl/2124045
2010-09-12 00:53:04 -04:00
Alex Brainman
f95a2f2b97 runtime(windows): make sure scheduler runs on os stack and new stdcall implementation
R=rsc
CC=golang-dev
https://golang.org/cl/2009045
2010-09-12 11:45:16 +10:00
Russ Cox
befecf6b59 runtime: fix crash trace on amd64
g is not in r15 anymore.
now it's in a per-thread memory segment,
which is valid even inside a signal handler,
so we can just refer to g directly.

Fixes #1082.

R=r
CC=golang-dev
https://golang.org/cl/2149045
2010-09-11 00:26:56 -04:00
Rob Pike
66f676b8ef arm: fix a couple of build bugs.
tests have not been run yet

R=stephenm
CC=golang-dev
https://golang.org/cl/2165046
2010-09-09 23:31:33 -07:00
Rob Pike
ba5175401e runtime: fix bug in tracebacks
Need to correct for deferproc's extra 2 words of stack or in some
cases (such as memory profiling) traceback can cause a crash.
Also bulletproof the closure test.

R=rsc
CC=golang-dev
https://golang.org/cl/2138047
2010-09-09 14:28:56 +10:00
Alex Brainman
89e9231865 runtime: fix windows build
R=rsc, r2
CC=golang-dev
https://golang.org/cl/2135045
2010-09-09 12:09:10 +10:00
Russ Cox
636342292c runtime: fix linux/amd64 build: wrong name for munmap
TBR=r
CC=golang-dev
https://golang.org/cl/2140043
2010-09-07 13:17:10 -04:00
Russ Cox
d4cc557b0d runtime: use manual stack for garbage collection
Old code was using recursion to traverse object graph.
New code uses an explicit stack, cutting the per-pointer
footprint to two words during the recursion and avoiding
the standard allocator and stack splitting code.

in test/garbage:

Reduces parser runtime by 2-3%
Reduces Peano runtime by 40%
Increases tree runtime by 4-5%

R=r
CC=golang-dev
https://golang.org/cl/2150042
2010-09-07 09:57:22 -04:00
Russ Cox
4e64555894 runtime: add GOOS, GOARCH; fix FuncLine
Changes to FuncLine sync it with symtab.c's funcline.

R=r
CC=girard.m1, golang-dev
https://golang.org/cl/2083041
2010-09-02 14:19:12 -04:00
Christian Himpel
5c603dbb75 build: remove unnecessary references to GOBIN and GOROOT
All scripts and makefiles assume that GOBIN is correctly set
in PATH.

R=rsc
CC=golang-dev
https://golang.org/cl/2043041
2010-08-30 15:40:56 -04:00
Kyle Consalus
4d903504b3 runtime: special case copy, equal for one-word interface values
Based on the observation that a great number of the types that
are copied or compared in interfaces, maps, and channels are
word-sized, this uses specialized copy and equality functions
for them that use a word instead of 4 or 8 bytes. Seems to yield
0-6% improvements in performance in the benchmarks I've run.
For example, with the regexp benchmarks:

Before:
regexp.BenchmarkLiteral   500000       3.26 µs/op
regexp.BenchmarkNotLiteral    100000      13.67 µs/op
regexp.BenchmarkMatchClass    100000      18.72 µs/op
regexp.BenchmarkMatchClass_InRange    100000      20.04 µs/op
regexp.BenchmarkReplaceAll    100000      27.85 µs/op

After:
regexp.BenchmarkLiteral   500000       3.11 µs/op
regexp.BenchmarkNotLiteral    200000      13.29 µs/op
regexp.BenchmarkMatchClass    100000      17.65 µs/op
regexp.BenchmarkMatchClass_InRange    100000      18.49 µs/op
regexp.BenchmarkReplaceAll    100000      26.34 µs/op

R=rsc
CC=golang-dev
https://golang.org/cl/1967047
2010-08-26 13:32:40 -04:00
Ian Lance Taylor
bbaef5f4dc runtime: Correct commonType.kind values to match compiler.
The copy of these values in the reflect package is already
correct.

R=rsc
CC=golang-dev
https://golang.org/cl/2009044
2010-08-26 08:08:57 -07:00
Russ Cox
e1e829b786 runtime: fix freebsd/386 mmap
The runtime only passes 32 bits of file offset,
but the kernel wants 64 bits, so have to add
zeros explicitly in a copy of the arguments.

R=adg, Martin Neubauer
CC=golang-dev
https://golang.org/cl/1933044
2010-08-24 13:04:02 -04:00
Eric Clark
95fa16a892 cgo: add C.GoStringN
Function to create a GoString with a known length so it can contain NUL
bytes anywhere in the string. Some C libraries have strings like this.

R=rsc
CC=golang-dev
https://golang.org/cl/2007042
2010-08-18 22:29:05 -04:00
Russ Cox
da392d9136 build: no required environment variables
R=adg, r, PeterGo
CC=golang-dev
https://golang.org/cl/1942044
2010-08-18 10:08:49 -04:00
Luuk van Dijk
340f28deab runtime: correct line numbers for .goc files.
Linenumbers start at 1.
Also call goc2c with an absolute pathi to preserve debug info.

R=rsc, r, ken2
CC=golang-dev
https://golang.org/cl/1954049
2010-08-18 00:16:05 +02:00
Russ Cox
e2bde5cf9b runtime: fix another stack split bug
Makes godoc --http=:1234 not crash on linux/amd64.

R=r
CC=golang-dev
https://golang.org/cl/1975044
2010-08-12 23:26:54 -07:00
Alex Brainman
bc4a9caa41 runtime: free memory returned by windows GetEnvironmentStrings
R=golang-dev
CC=golang-dev
https://golang.org/cl/1917048
2010-08-09 11:30:33 +10:00
Kai Backman
df88fc6109 arm: bugfixes and syscall
- integer divide by zero raises panic
- float comparisons involving NaNs work
- syscall interface actually handles return
  values and errno correctly.

R=rsc, bradfitzpatrick
CC=golang-dev
https://golang.org/cl/1847047
2010-08-06 16:57:49 -07:00
Russ Cox
e473f42b2d amd64: use segment memory for thread-local storage
Returns R14 and R15 to the available register pool.
Plays more nicely with ELF ABI C code.
In particular, our signal handlers will no longer crash
when a signal arrives during execution of a cgo C call.

Fixes #720.

R=ken2, r
CC=golang-dev
https://golang.org/cl/1847051
2010-08-04 17:50:22 -07:00
Russ Cox
3f19d8ae8d gc: empty select
R=ken2
CC=golang-dev
https://golang.org/cl/1871057
2010-08-03 01:07:57 -07:00
Russ Cox
9bac9d23d3 gc: index bounds tests and fixes
move constant index checking to front end
x[2:1] is a compile-time error now too

R=ken2
CC=golang-dev
https://golang.org/cl/1848056
2010-08-03 00:26:02 -07:00
Russ Cox
68b0a87966 runtime: do not fall through in SIGBUS/SIGSEGV
Faults beyond the first page are not expected
and should fail loudly.  They are not subject to recover.

R=r
CC=golang-dev
https://golang.org/cl/1915042
2010-07-30 11:32:55 -07:00
Alex Brainman
45e12c7cd3 runtime: fix bug introduced in revision 4a01b8d28570
R=rsc
CC=golang-dev
https://golang.org/cl/1874046
2010-07-29 16:54:01 +10:00
Kai Backman
fa4da33315 arm: minor bugfixes.
R=rsc
CC=golang-dev
https://golang.org/cl/1692057
2010-07-28 15:58:35 +03:00
Peter Mundy
036584395d runtime: fix goc2c for rename to goc2c and *.goc
Release 2010-04-27. runtime: rename cgo2c, *.cgo to goc2c, *.goc
to avoid confusion with real cgo.

R=rsc
CC=golang-dev
https://golang.org/cl/1868047
2010-07-26 16:21:27 -07:00
Alex Brainman
eee095399f syscall: improve windows errno handling
R=rsc, Joe Poirier, PeterGo
CC=golang-dev
https://golang.org/cl/1872045
2010-07-26 10:24:48 +10:00
Daniel Theophanes
7f9e247489 syscall: add ForkExec, Syscall12 on Windows
R=brainman, rsc
CC=golang-dev
https://golang.org/cl/1578041
2010-07-26 09:43:35 +10:00
Vinu Rajashekhar
e57657683f runtime/extern.go: clear a small error in a comment.
R=iant, rsc
CC=golang-dev
https://golang.org/cl/1741058
2010-07-24 19:10:21 -07:00
Kai Backman
36057e721e more soft float support. passes several basic tests
but with less precision than hardware counterparts.

fixed a number of tests to output BUG when they failed.
changed the runner to distinghuish between output
and output containing ^BUG

R=rsc
CC=dho, golang-dev
https://golang.org/cl/1778041
2010-07-20 15:53:16 +03:00
Russ Cox
2d6ae385e1 linux/386: use Xen-friendly ELF TLS instruction sequence
Fixes #465.

R=iant
CC=golang-dev
https://golang.org/cl/1665051
2010-07-17 16:54:03 -07:00
Ian Lance Taylor
385bfd4ca0 Remove unused declaration.
R=rsc
CC=golang-dev
https://golang.org/cl/1686054
2010-07-16 11:05:38 -07:00
Ian Lance Taylor
5958fd7f89 Clarify that a new goroutine is not started for each finalizer.
R=rsc
CC=golang-dev
https://golang.org/cl/1698051
2010-07-15 12:32:38 -07:00
Russ Cox
cec007d3d2 runtime: better error for send/recv on nil channel
R=ken2
CC=golang-dev
https://golang.org/cl/1835041
2010-07-13 17:27:26 -07:00
Andrew Gerrand
da795fcefc runtime/tiny: style and doc tweaks
R=r, rsc
CC=golang-dev
https://golang.org/cl/1821041
2010-07-13 10:47:52 +10:00
Markus Duft
d49c0d71f6 runtime/tiny: add destroyLock stub, and docs for additional VMs
updated thread.c to provide destroylock, which seems to be
	      required to link.
        updated README with different virtualization programs.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/1746047
2010-07-08 00:15:47 +10:00
Russ Cox
774333685e runtime: fix scheduling bug - world wasn't stopping
Fixes #886.

R=r
CC=golang-dev
https://golang.org/cl/1667051
2010-06-29 17:47:27 -07:00
Alex Brainman
059c7ba996 runtime: fix windows build
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/1747041
2010-06-29 07:12:14 -07:00
Ian Lance Taylor
807605d0fc Only catch all signals if os/signal package imported.
Fixes #776.

R=rsc
CC=golang-dev
https://golang.org/cl/1745041
2010-06-28 17:14:17 -07:00
Russ Cox
e63ae242e6 runtime: split extern.go into debug.go, extern.go, sig.go.
move mal next to the other malloc functions.

R=r
CC=golang-dev
https://golang.org/cl/1701045
2010-06-21 20:53:49 -07:00
Russ Cox
121a16fa95 runtime: delete old types
R=r
CC=golang-dev
https://golang.org/cl/1715043
2010-06-21 18:03:25 -07:00
Russ Cox
45bdf0367e reflect: add Kind, remove Int8Type, Int8Value, etc.
update other code to match.

R=r
CC=golang-dev
https://golang.org/cl/1680044
2010-06-20 12:16:25 -07:00
Russ Cox
21ff75bc0e complex divide: match C99 implementation
R=iant, ken2, r, r2, ken3
CC=golang-dev
https://golang.org/cl/1686044
2010-06-18 15:46:00 -07:00
Russ Cox
c9172fb2a3 runtime: correct fault for 16-bit divide on Leopard
R=r
CC=golang-dev
https://golang.org/cl/1703041
2010-06-14 18:07:17 -07:00
Russ Cox
53a529ab2b runtime: fix 386 signal handler bug
Cannot assume that g == m->curg at time of signal.
Must save actual g and restore.

Fixes flaky crashes with messages like

throw: malloc mlookup
throw: malloc/free - deadlock
throw: unwindstack on self
throw: free mlookup

(and probably others) when running cgo.

R=iant
CC=golang-dev
https://golang.org/cl/1648043
2010-06-12 10:48:04 -07:00
Alex Brainman
c1e20720f7 runtime: switch to OS stack during Windows syscall
R=rsc
CC=golang-dev
https://golang.org/cl/1381041
2010-06-11 01:38:12 -07:00
Alex Brainman
fdb460ec11 runtime: free lock handles on Windows
R=rsc
CC=golang-dev
https://golang.org/cl/1652041
2010-06-11 00:53:54 -07:00
Russ Cox
565b5dc076 gc: new typechecking rules
* Code for assignment, conversions now mirrors spec.
* Changed some snprint -> smprint.
* Renamed runtime functions to separate
  interface conversions from type assertions:
  convT2I, assertI2T, etc.
* Correct checking of \U sequences.

Fixes #840.
Fixes #830.
Fixes #778.

R=ken2
CC=golang-dev
https://golang.org/cl/1303042
2010-06-08 18:50:02 -07:00
Daniel Theophanes
129c6c14d1 runtime: finish pchw -> tiny, added gettime for tiny
R=rsc
CC=golang-dev
https://golang.org/cl/1514041
2010-06-07 14:18:42 -07:00
Evan Shaw
69879f0414 runtime: Fix printing -Inf
R=rsc
CC=golang-dev
https://golang.org/cl/1258044
2010-06-01 14:08:15 -07:00
Alex Brainman
d5a8647d80 syscall: windows SysAlloc should use stdcall_raw not syscall
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/1382041
2010-05-28 11:47:09 -07:00
Russ Cox
21518ea2af runtime: free old hashmap pieces during resizing
R=r
CC=golang-dev
https://golang.org/cl/1254044
2010-05-24 14:31:10 -07:00
Russ Cox
f58ba18a08 runtime: correct tracebacks for nascent goroutines, even closures
Fixes #780.

R=r
CC=golang-dev
https://golang.org/cl/1221042
2010-05-21 14:40:21 -07:00
Russ Cox
4843b130bb runtime: avoid allocation for fixed strings
R=r
CC=golang-dev
https://golang.org/cl/1083041
2010-05-19 21:33:31 -07:00
Russ Cox
b198c8612e runtime: allow large map values
Fixes #772.

R=ken2
CC=golang-dev
https://golang.org/cl/1206043
2010-05-19 12:57:47 -07:00
Ian Lance Taylor
e1b47159ab Save the scheduling state even predawn.
This permits cgo callbacks to work when run in init code.
Otherwise cgocallback switches to the wrong stack address.

R=rsc
CC=golang-dev
https://golang.org/cl/1123043
2010-05-06 22:07:03 -07:00
Rob Pike
eb48bfbbda runtime.GOMAXPROCS: hack it to have it return the old value.
R=rsc
CC=golang-dev
https://golang.org/cl/1140041
2010-05-06 11:50:47 -07:00
Russ Cox
7d7ebd2fe1 runtime, strconv: tiny cleanups
R=r
CC=golang-dev
https://golang.org/cl/1081042
2010-05-03 17:47:40 -07:00
Russ Cox
23c0aa3916 runtime/arm: fix build
Import _mulv from Inferno again, change R9 to R2.
Not sure what the other differences were for, but
they weren't working.

TBR=kaib
CC=golang-dev
https://golang.org/cl/1079041
2010-05-03 13:24:39 -07:00
Giles Lean
3c32300c4d runtime: update godefs usage comment for GOARCH=386 GOOS={darwin,freebsd}
When trying to regenerate src/pkg/runtime/darwin/386/defs.h
on a 64 bit capable Snow Leopard (OS X 10.6.3) system I
needed to add -f -m32 to godefs, as this OS and hardware
combination defaults to 64 bit compilation.

For safety, make the same change to the 32 bit FreeBSD
instructions in .../freebsd/defs.c.  (Tested OK and no
problems introduced.)

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/1052042
2010-05-03 01:26:39 -07:00
Russ Cox
6361f52fc4 gc: be pickier about slice, chan, array, and map sizes
Fixes #589.

R=ken2
CC=golang-dev
https://golang.org/cl/1032044
2010-05-01 13:15:42 -07:00
Alex Brainman
f81d471940 rename GOOS=mingw to GOOS=windows
R=rsc, Joe Poirier
CC=golang-dev
https://golang.org/cl/1015043
2010-04-29 23:45:14 -07:00
Russ Cox
718da3339a darwin: bsdthread_create can fail; print good error
Fixes #549.

R=adg
CC=golang-dev
https://golang.org/cl/1019042
2010-04-28 19:36:42 -07:00
Russ Cox
000ab98df6 5l, 6l, 8l, runtime: make -s binaries work
5l, 6l, 8l: change ELF header so that strip doesn't destroy binary

Fixes #261.

R=iant, r
CC=golang-dev
https://golang.org/cl/994044
2010-04-27 22:40:26 -07:00
Russ Cox
c6138efbcb runtime: closures, defer bug fix for Native Client
Enable package tests for Native Client build.

R=r
CC=golang-dev
https://golang.org/cl/957042
2010-04-22 17:52:22 -07:00
Russ Cox
214a55b06a runtime: switch state back to Grunning after recovery
Fixes #733.

R=r
CC=golang-dev
https://golang.org/cl/958041
2010-04-21 16:27:41 -07:00
Russ Cox
20c50cf0f8 runtime: rename cgo2c, *.cgo to goc2c, *.goc
to avoid confusion with real cgo

R=r
CC=golang-dev
https://golang.org/cl/904046
2010-04-20 17:03:25 -07:00
Kai Backman
26e846429d support for printing floats:
fmt.Printf("float32 %f\n", float32(1234.56789))
fmt.Printf("float64 %f\n", float64(1234.56789))
->
float32 1234.567871
float64 1234.567890

this is a snapshot. extended instruction support, corner cases
and fixes coming in subseuent cls.

R=rsc
CC=dpx, golang-dev
https://golang.org/cl/876045
2010-04-15 12:43:49 +03:00
Russ Cox
c3e54f0988 runtime: better trace for fault due to nil pointer call
R=r
CC=golang-dev
https://golang.org/cl/854048
2010-04-13 22:31:47 -07:00
Russ Cox
6363542695 runtime: delete malx, skip_depth argument to malloc
remove internal functions from traces in gopprof instead.

R=r
CC=golang-dev
https://golang.org/cl/855046
2010-04-09 15:30:40 -07:00
Ian Lance Taylor
a4f8d36ba5 Run initcgo for all amd64 targets, not just GNU/Linux.
This is required to make cgo export work on Darwin.  Note that
this corrects the stack alignment when calling initcgo to that
required by gcc on amd64.

R=rsc
CC=golang-dev
https://golang.org/cl/907041
2010-04-09 14:15:15 -07:00
Ian Lance Taylor
2e20386fc7 Library support for cgo export.
These functions are used to call from a C function back to a
Go function.  This only includes 386 support.

R=rsc
CC=golang-dev
https://golang.org/cl/834045
2010-04-09 13:30:35 -07:00
Ian Lance Taylor
2d0ff3f1a6 Support cgo export on amd64.
R=rsc
CC=golang-dev
https://golang.org/cl/857045
2010-04-09 13:30:11 -07:00
Russ Cox
c60d048594 runtime: fix build (panic) for FreeBSD
R=adg
CC=golang-dev
https://golang.org/cl/867046
2010-04-08 21:13:42 -07:00
Russ Cox
5963dbac08 runtime: turn divide by zero, nil dereference into panics
tested on linux/amd64, linux/386, linux/arm, darwin/amd64, darwin/386.
freebsd untested; will finish in a separate CL.

for now all the panics are errorStrings.
richer structures can be added as necessary
once the mechanism is shaked out.

R=r
CC=golang-dev
https://golang.org/cl/906041
2010-04-08 18:15:30 -07:00
Russ Cox
72157c300b runtime: fix bad status throw
when garbage collector sees recovering goroutine

Fixes #711.

R=r
CC=golang-dev
https://golang.org/cl/869045
2010-04-08 13:24:53 -07:00
Russ Cox
2f0cae46d8 runtime: work around kernel bug in Snow Leopard signal handling
Could not take a signal on threads other than the main thread.
If you look at the spinning binary with dtrace, you can see a
fault happening over and over:

    $ dtrace -n '
    fbt::user_trap:entry /execname=="boot32" && self->count < 10/
    {
        self->count++;
        printf("%s %x %x %x %x", probefunc, arg1, arg2, arg3, arg4);
        stack();
        tracemem(arg4, 256);
    }'

    dtrace: description 'fbt::user_trap:entry ' matched 1 probe
    CPU     ID                    FUNCTION:NAME
      1  17015                  user_trap:entry user_trap 0 10 79af0a0 79af0a0
                  mach_kernel`lo_alltraps+0x12a

             0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f  0123456789abcdef
         0: 0e 00 00 00 37 00 00 00 00 00 00 00 1f 00 00 00  ....7...........
        10: 1f 00 00 00 a8 33 00 00 00 00 00 01 00 00 00 00  .....3..........
        20: 98 ba dc fe 07 09 00 00 00 00 00 00 98 ba dc fe  ................
        30: 06 00 00 00 0d 00 00 00 34 00 00 00 9e 1c 00 00  ........4.......
        40: 17 00 00 00 00 02 00 00 ac 30 00 00 1f 00 00 00  .........0......
        50: 00 00 00 00 00 00 00 00 0d 00 00 00 e0 e6 29 00  ..............).
        60: 34 00 00 00 00 00 00 00 9e 1c 00 00 00 00 00 00  4...............
        70: 17 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00  ................
        80: ac 30 00 00 00 00 00 00 1f 00 00 00 00 00 00 00  .0..............
        90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        a0: 48 00 00 00 10 00 00 00 85 00 00 00 a0 f2 29 00  H.............).
        b0: 69 01 00 02 00 00 00 00 e6 93 04 82 ff 7f 00 00  i...............
        c0: 2f 00 00 00 00 00 00 00 06 02 00 00 00 00 00 00  /...............
        d0: 78 ee 42 01 01 00 00 00 1f 00 00 00 00 00 00 00  x.B.............
        e0: 00 ed 9a 07 00 00 00 00 00 00 00 00 00 00 00 00  ................
        f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................

    ...

The memory dump shows a 32-bit exception frame:

    x86_saved_state32

    gs = 0x37
    fs = 0
    es = 0x1f
    ds = 0x1f
    edi = 0x33a8
    esi = 0x01000000
    ebp = 0
    cr2 = 0xfedcba98
    ebx = 0x0907
    edx = 0
    ecx = 0xfedcba98
    eax = 0x06
    trapno = 0x0d
    err = 0x34
    eip = 0x1c9e
    cs = 0x17
    efl = 0x0200
    uesp = 0x30ac
    ss = 0x1f

The cr2 of 0xfedcba98 is the address that the new thread read
to cause the fault, but note that the trap is now a GP fault with
error code 0x34, meaning it's moved past the cr2 problem and on
to an invaild segment selector.  The 0x34 is suspiciously similar
to the 0x37 in gs, and sure enough, OS X forces gs to have
that value in the signal handler, and if your thread hasn't set
up that segment (known as USER_CTHREAD), you'll fault on the IRET
into the signal handler and never be able to handle a signal.

The kernel bug is that it forces segment 0x37 without making sure
it is a valid segment.  Leopard also forced 0x37 but had the courtesy
to set it up first.

Since OS X requires us to set up that segment (using the
thread_fast_set_cthread_self system call), we might as well
use it instead of the more complicated i386_set_ldt call to
set up our per-OS thread storage.

Also add some more zeros to bsdthread_register for new arguments
in Snow Leopard (apparently unnecessary, but being careful).

Fixes #510.

R=r
CC=golang-dev
https://golang.org/cl/824046
2010-04-08 13:24:37 -07:00
Russ Cox
24c58174b2 runtime: use explicit flag when finalizer goroutine is waiting
Avoids spurious wakeups during other sleeping by that goroutine.
Fixes #711.

R=r
CC=golang-dev
https://golang.org/cl/902041
2010-04-07 20:38:02 -07:00
Ken Thompson
b57afc2f83 another try at clearing
channel recv data.

R=rsc
CC=golang-dev
https://golang.org/cl/896041
2010-04-06 17:33:43 -07:00
Ken Thompson
dec248c665 change channel read to clear
data just read from the channel.
this will make it easier to
recognize when to garbage
collect and finalize.

R=rsc
CC=golang-dev
https://golang.org/cl/882043
2010-04-06 16:58:52 -07:00
Russ Cox
88ce9ce40c runtime: two proc bug fixes
1. Fix bug in GOMAXPROCS when trying to cut number of procs
Race could happen on any system but was
manifesting only on Xen hosted Linux.

2. Fix recover on ARM, where FP != caller SP.

R=r
CC=golang-dev
https://golang.org/cl/880043
2010-04-06 13:48:31 -07:00
Russ Cox
6d69fd1fe3 runtime: fix Caller
log: add test of Caller

New regexp in log test is picky and will require some
maintenance, but it catches off-by-one mistakes too.

Fixes #710.

R=gri
CC=esko.luontola, golang-dev
https://golang.org/cl/887043
2010-04-05 23:36:37 -07:00
Russ Cox
d89b357f76 runtime: handle malloc > 2GB correctly
R=ken2
CC=golang-dev
https://golang.org/cl/821048
2010-04-05 17:26:59 -07:00
Russ Cox
6c196015e0 runtime: various arm fixes
* correct symbol table size
  * do not reorder functions in output
  * traceback
  * signal handling
  * use same code for go + defer
  * handle leaf functions in symbol table

R=kaib, dpx
CC=golang-dev
https://golang.org/cl/884041
2010-04-05 12:51:09 -07:00
Russ Cox
f75d0d224f runtime: turn run time errors checks into panics
R=ken2, r
CC=golang-dev
https://golang.org/cl/871042
2010-04-01 22:31:27 -07:00
Russ Cox
ec53627ed5 runtime: correct memory leak in select
* adds pass 3 to dequeue from channels eagerly

various other cleanup/churn:
  * use switch on cas->send in each pass to
    factor out common code.
  * longer goto labels, commented at target
  * be more agressive about can't happen:
    throw instead of print + cope.
  * use "select" instead of "selectgo" in errors
  * use printf for debug prints when possible

R=ken2, ken3
CC=golang-dev, r
https://golang.org/cl/875041
2010-04-01 11:56:18 -07:00
Russ Cox
63e878a750 runtime: make type assertion a runtime.Error, the first of many
R=r
CC=golang-dev
https://golang.org/cl/805043
2010-03-31 15:55:10 -07:00
Russ Cox
9b1507b050 gc: implement panic and recover
R=ken2, r, ken3
CC=golang-dev
https://golang.org/cl/831042
2010-03-31 11:46:01 -07:00
Russ Cox
7ecefdc03f runtime: fix arm build, slightly.
R=r
CC=golang-dev
https://golang.org/cl/842042
2010-03-30 17:00:27 -07:00
Russ Cox
01eaf780a8 gc: add panic and recover (still unimplemented in runtime)
main semantic change is to enforce single argument to panic.

runtime: change to 1-argument panic.
use String method on argument if it has one.

R=ken2, r
CC=golang-dev
https://golang.org/cl/812043
2010-03-30 10:53:16 -07:00
Christopher Wedgwood
d166d1629a runtime: Remove unused runtime.write from linux/amd64
Also minor reformatting.

R=rsc
CC=golang-dev
https://golang.org/cl/845041
2010-03-29 22:51:39 -07:00
Russ Cox
83727ccf7c runtime: run deferred calls at Goexit
baby step toward panic+recover.

Fixes #349.

R=r
CC=golang-dev
https://golang.org/cl/825043
2010-03-29 21:48:22 -07:00
Russ Cox
d99a3da7b2 runtime: a couple more memory stats.
now runtime.MemStats.Sys really is the sum of all the other Sys fields.

R=r
CC=golang-dev
https://golang.org/cl/843041
2010-03-29 17:30:07 -07:00
Russ Cox
a709876767 runtime: more malloc statistics
expvar: default publishings for cmdline, memstats
godoc: import expvar

R=r
CC=golang-dev
https://golang.org/cl/815041
2010-03-29 13:06:26 -07:00
Russ Cox
baf538406b pprof: dump extra heap information at end of heap profile
R=r
CC=golang-dev
https://golang.org/cl/786041
2010-03-26 15:32:53 -07:00
Russ Cox
4e28cfe970 runtime: run all finalizers in a single goroutine.
eliminate second pass of mark+sweep
by scanning finalizer table specially.

R=r
CC=golang-dev
https://golang.org/cl/782041
2010-03-26 14:15:30 -07:00
Alex Brainman
a24cf69fd8 runtime: fix mingw build, implement missing destroylock()
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/747041
2010-03-24 18:03:10 -07:00
Russ Cox
6eb251f244 runtime: malloc sampling, pprof interface
R=r
CC=golang-dev
https://golang.org/cl/719041
2010-03-24 09:40:09 -07:00
Russ Cox
596c16e045 runtime: add memory profiling, disabled.
no way to get the data out yet.

add prototype for runtime.Callers,
missing from last CL.

R=r
CC=golang-dev
https://golang.org/cl/713041
2010-03-23 20:48:23 -07:00
Russ Cox
2b7d147f1a runtime: add Callers
cut copies of traceback from 6 to 1.

R=r
CC=golang-dev
https://golang.org/cl/703041
2010-03-23 17:01:17 -07:00