aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/malloc2.go
AgeCommit message (Collapse)Author
2015-02-19runtime: reorganize memory codeRuss Cox
Move code from malloc1.go, malloc2.go, mem.go, mgc0.go into appropriate locations. Factor mgc.go into mgc.go, mgcmark.go, mgcsweep.go, mstats.go. A lot of this code was in certain files because the right place was in a C file but it was written in Go, or vice versa. This is one step toward making things actually well-organized again. Change-Id: I6741deb88a7cfb1c17ffe0bcca3989e10207968f Reviewed-on: https://go-review.googlesource.com/5300 Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Rick Hudson <rlh@golang.org>
2015-02-04runtime: cleanup some left-overs of the C pastDmitry Vyukov
Change-Id: I3e280ca7d922f6ab14b2477361327ed076a95779 Reviewed-on: https://go-review.googlesource.com/3743 Reviewed-by: Keith Randall <khr@golang.org>
2015-01-19runtime: factor out bitmap, finalizer code from malloc/mgcRuss Cox
The code in mfinal.go is moved from malloc*.go and mgc*.go and substantially unchanged. The code in mbitmap.go is also moved from those files, but cleaned up so that it can be called from those files (in most cases the code being moved was not already a standalone function). I also renamed the constants and wrote comments describing the format. The result is a significant cleanup and isolation of the bitmap code, but, roughly speaking, it should be treated and reviewed as new code. The other files changed only as much as necessary to support this code movement. This CL does NOT change the semantics of the heap or type bitmaps at all, although there are now some obvious opportunities to do so in followup CLs. Change-Id: I41b8d5de87ad1d3cd322709931ab25e659dbb21d Reviewed-on: https://go-review.googlesource.com/2991 Reviewed-by: Keith Randall <khr@golang.org>
2015-01-15all: update old comments referencing *.goc filesBrad Fitzpatrick
Change-Id: Ibf05e55ffe3bb454809cd3450b790e44061511c7 Reviewed-on: https://go-review.googlesource.com/2890 Reviewed-by: Alan Donovan <adonovan@google.com>
2015-01-14runtime: change tinyalloc, persistentalloc not to point past allocated dataRuss Cox
During all.bash I got a crash in the GOMAXPROCS=2 runtime test reporting that the write barrier in the assignment 'c.tiny = add(x, size)' had been given a pointer pointing into an unexpected span. The problem is that the tiny allocation was at the end of a span and c.tiny was now pointing to the end of the allocation and therefore to the end of the span aka the beginning of the next span. Rewrite tinyalloc not to do that. More generally, it's not okay to call add(p, size) unless you know that p points at > (not just >=) size bytes. Similarly, pretty much any call to roundup doesn't know how much space p points at, so those are all broken. Rewrite persistentalloc not to use add(p, totalsize) and not to use roundup. There is only one use of roundup left, in vprintf, which is dead code. I will remove that code and roundup itself in a followup CL. Change-Id: I211e307d1a656d29087b8fd40b2b71010722fb4a Reviewed-on: https://go-review.googlesource.com/2814 Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-01-07runtime: increase number of stack orders to 4Keith Randall
Cache 2KB, 4KB, 8KB, and 16KB stacks. Larger stacks will be allocated directly. There is no point in cacheing 32KB+ stacks as we ask for and return 32KB at a time from the allocator. Note that the minimum stack is 8K on windows/64bit and 4K on windows/32bit and plan9. For these os/arch combinations, the number of stack orders is less so that we have the same maximum cached size. Fixes #9045 Change-Id: Ia4195dd1858fb79fc0e6a91ae29c374d28839e44 Reviewed-on: https://go-review.googlesource.com/2098 Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-07runtime: remove trailing empty arrays in structsKeith Randall
The ones at the end of M and G are just used to compute their size for use in assembly. Generate the size explicitly. The one at the end of itab is variable-sized, and at least one. The ones at the end of interfacetype and uncommontype are not needed, as the preceding slice references them (the slice was originally added for use by reflect?). The one at the end of stackmap is already accessed correctly, and the runtime never allocates one. Update #9401 Change-Id: Ia75e3aaee38425f038c506868a17105bd64c712f Reviewed-on: https://go-review.googlesource.com/2420 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-06runtime: add GODEBUG wbshadow for finding missing write barriersRuss Cox
This is the detection code. It works well enough that I know of a handful of missing write barriers. However, those are subtle enough that I'll address them in separate followup CLs. GODEBUG=wbshadow=1 checks for a write that bypassed the write barrier at the next write barrier of the same word. If a bug can be detected in this mode it is typically easy to understand, since the crash says quite clearly what kind of word has missed a write barrier. GODEBUG=wbshadow=2 adds a check of the write barrier shadow copy during garbage collection. Bugs detected at garbage collection can be difficult to understand, because there is no context for what the found word means. Typically you have to reproduce the problem with allocfreetrace=1 in order to understand the type of the badly updated word. Change-Id: If863837308e7c50d96b5bdc7d65af4969bf53a6e Reviewed-on: https://go-review.googlesource.com/2061 Reviewed-by: Austin Clements <austin@google.com>
2014-12-18runtime: fix a minor typo in commentsGuobiao Mei
Change-Id: I13a8aacd1b8243c992b539ab6bf7b5dff2a1393a Reviewed-on: https://go-review.googlesource.com/1757 Reviewed-by: Minux Ma <minux@golang.org>
2014-12-16runtime: gofmtBrad Fitzpatrick
Fixes #9339 Change-Id: I22faf2593cb73f42612c2c2bfe38de001fb2746b Reviewed-on: https://go-review.googlesource.com/1630 Reviewed-by: Andrew Gerrand <adg@golang.org>
2014-12-10runtime: fix finalizer iteratorKeith Randall
It could only handle one finalizer before it raised an out-of-bounds error. Fixes issue #9172 Change-Id: Ibb4d0c8aff2d78a1396e248c7129a631176ab427 Reviewed-on: https://go-review.googlesource.com/1201 Reviewed-by: Russ Cox <rsc@golang.org>
2014-11-24[dev.garbage] all: merge dev.cc (493ad916c3b1) into dev.garbageRuss Cox
TBR=austin CC=golang-codereviews https://golang.org/cl/179290043
2014-11-20[dev.garbage] runtime: Turn concurrent GC on by default. Avoid write ↵Rick Hudson
barriers for GC internal structures such as free lists. LGTM=rsc R=rsc CC=golang-codereviews, rsc https://golang.org/cl/179000043
2014-11-18[dev.cc] runtime: generate GOOS- and GOARCH-specific files with go generateRuss Cox
Eventually I'd like almost everything cmd/dist generates to be done with 'go generate' and checked in, to simplify the bootstrap process. The only thing cmd/dist really needs to do is write things like the current experiment info and the current version. This is a first step toward that. It replaces the _NaCl etc constants with generated ones goos_nacl, goos_darwin, goarch_386, and so on. LGTM=dave, austin R=austin, dave, bradfitz CC=golang-codereviews, iant, r https://golang.org/cl/174290043
2014-11-15[dev.garbage] all: merge dev.cc into dev.garbageRuss Cox
The garbage collector is now written in Go. There is plenty to clean up (just like on dev.cc). all.bash passes on darwin/amd64, darwin/386, linux/amd64, linux/386. TBR=rlh R=austin, rlh, bradfitz CC=golang-codereviews https://golang.org/cl/173250043
2014-11-11[dev.cc] runtime: convert memory allocator and garbage collector to GoRuss Cox
The conversion was done with an automated tool and then modified only as necessary to make it compile and run. [This CL is part of the removal of C code from package runtime. See golang.org/s/dev.cc for an overview.] LGTM=r R=r CC=austin, dvyukov, golang-codereviews, iant, khr https://golang.org/cl/167540043