aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/malloc.c
AgeCommit message (Collapse)Author
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
2014-09-24cmd/cc, cmd/ld, runtime: disallow conservative data/bss objectsRuss Cox
In linker, refuse to write conservative (array of pointers) as the garbage collection type for any variable in the data/bss GC program. In the linker, attach the Go type to an already-read C declaration during dedup. This gives us Go types for C globals for free as long as the cmd/dist-generated Go code contains the declaration. (Most runtime C declarations have a corresponding Go declaration. Both are bss declarations and so the linker dedups them.) In cmd/dist, add a few more C files to the auto-Go-declaration list in order to get Go type information for the C declarations into the linker. In C compiler, mark all non-pointer-containing global declarations and all string data as NOPTR. This allows them to exist in C files without any corresponding Go declaration. Count C function pointers as "non-pointer-containing", since we have no heap-allocated C functions. In runtime, add NOPTR to the remaining pointer-containing declarations, none of which refer to Go heap objects. In runtime, also move os.Args and syscall.envs data into runtime-owned variables. Otherwise, in programs that do not import os or syscall, the runtime variables named os.Args and syscall.envs will be missing type information. I believe that this CL eliminates the final source of conservative GC scanning in non-SWIG Go programs, and therefore... Fixes #909. LGTM=iant R=iant CC=golang-codereviews https://golang.org/cl/149770043
2014-09-18runtime: delete panicstring; move its checks into gopanicRuss Cox
In Go 1.3 the runtime called panicstring to report errors like divide by zero or memory faults. Now we call panic (gopanic) with pre-allocated error values. That new path is missing the checking that panicstring did, so add it there. The only call to panicstring left is in cnew, which is problematic because if it fails, probably the heap is corrupt. In that case, calling panicstring creates a new errorCString (no allocation there), but then panic tries to print it, invoking errorCString.Error, which does a string concatenation (allocating), which then dies. Replace that one panicstring with a throw: cnew is for allocating runtime data structures and should never ask for an inappropriate amount of memory. With panicstring gone, delete newErrorCString, errorCString. While we're here, delete newErrorString, not called by anyone. (It can't be: that would be C code calling Go code that might block or grow the stack.) Found while debugging a malloc corruption. This resulted in 'panic during panic' instead of a more useful message. LGTM=khr R=khr CC=golang-codereviews https://golang.org/cl/138290045
2014-09-17runtime: account for tiny allocs, for testing.AllocsPerRunRuss Cox
Fixes #8734. LGTM=r, bradfitz, dvyukov R=bradfitz, r, dvyukov CC=golang-codereviews, iant, khr https://golang.org/cl/143150043
2014-09-16runtime: remove untyped allocation of ParForRuss Cox
Now it's two allocations. I don't see much downside to that, since the two pieces were in different cache lines anyway. Rename 'conservative' to 'cgo_conservative_type' and make clear that _cgo_allocate is the only allowed user. This depends on CL 141490043, which removes the other use of conservative (in defer). LGTM=dvyukov, iant R=khr, dvyukov, iant CC=golang-codereviews, rlh https://golang.org/cl/139610043
2014-09-16runtime: remove duplicated Go constantsRuss Cox
The C header files are the single point of truth: every C enum constant Foo is available to Go as _Foo. Remove or redirect duplicate Go declarations so they cannot be out of sync. Eventually we will need to put constants in Go, but for now having them be out of sync with C is too risky. These predate the build support for auto-generating Go constants from the C definitions. LGTM=iant R=iant CC=golang-codereviews https://golang.org/cl/141510043
2014-09-09runtime: merge mallocgc, gomallocgcRuss Cox
I assumed they were the same when I wrote cgocallback.go earlier today. Merge them to eliminate confusion. I can't tell what gomallocgc did before with a nil type but without FlagNoScan. I created a call like that in cgocallback.go this morning, translating from a C file. It was supposed to do what the C version did, namely treat the block conservatively. Now it will. LGTM=khr R=khr CC=golang-codereviews https://golang.org/cl/141810043
2014-09-08build: move package sources from src/pkg to srcRuss Cox
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.
2009-06-06move src/runtime -> src/lib/runtime;Russ Cox
only automatic g4 mv here. R=r OCL=30002 CL=30007
2009-06-04386-related fixes and guardsRuss Cox
R=r DELTA=44 (19 added, 1 deleted, 24 changed) OCL=29912 CL=29915
2009-05-29Fix godoc deadlock.Russ Cox
The code was already careful not to use malloc/free for stack growth during calls to malloc. Avoid them during calls to free too. R=r DELTA=9 (7 added, 0 deleted, 2 changed) OCL=29606 CL=29610
2009-03-30more 386 runtime - can run tiny c programs.Russ Cox
R=r DELTA=1926 (1727 added, 168 deleted, 31 changed) OCL=26876 CL=26878
2009-02-15build nitsRuss Cox
R=r DELTA=8 (0 added, 6 deleted, 2 changed) OCL=25045 CL=25045
2009-02-11fix gc bug. i think this is tgs's second bug.Russ Cox
i stumbled across it in all.bash. TBR=r OCL=24912 CL=24912
2009-02-06tgs's gc bug.Russ Cox
R=r DELTA=10 (7 added, 0 deleted, 3 changed) OCL=24577 CL=24577
2009-02-06closures - runtime and debugger support, test caseRuss Cox
R=r DELTA=257 (250 added, 1 deleted, 6 changed) OCL=24509 CL=24565
2009-01-28Use explicit allspan list instead ofRuss Cox
trying to find all the places where spans might be recorded. Free can cascade into complicated span manipulations that move them from list to list; the old code had the possibility of accidentally processing a span twice or jumping to a different list, causing an infinite loop. R=r DELTA=70 (28 added, 25 deleted, 17 changed) OCL=23704 CL=23710
2009-01-26gc #0. mark and sweep collector.Russ Cox
R=r,gri DELTA=472 (423 added, 2 deleted, 47 changed) OCL=23522 CL=23541
2009-01-14Add cgo2c program to translate mixed Go/C code into C. ThisIan Lance Taylor
lets us use a single source file for both 6c and gcc, handling the incompatible handling of return values. R=rsc DELTA=649 (613 added, 35 deleted, 1 changed) OCL=22682 CL=22730
2009-01-13Add USED declarations for SysUnused parameters.Ian Lance Taylor
R=rsc DELTA=2 (2 added, 0 deleted, 0 changed) OCL=22640 CL=22642
2009-01-13Tweak code to make it easier to compile with gcc.Ian Lance Taylor
+ Use macros to name symbols with non-ASCII characters. + Make some variables unsigned, because they are compared against unsigned values. + Fix a few void* pointers to be MLink*. R=rsc DELTA=94 (44 added, 3 deleted, 47 changed) OCL=22303 CL=22638
2009-01-09free(nil)Russ Cox
R=iant DELTA=3 (3 added, 0 deleted, 0 changed) OCL=22467 CL=22471
2008-12-19malloc bug fixes.Russ Cox
use malloc by default. free stacks. R=r DELTA=424 (333 added, 29 deleted, 62 changed) OCL=21553 CL=21584
2008-12-18malloc in runtime (not used by default)Russ Cox
R=r DELTA=1551 (1550 added, 0 deleted, 1 changed) OCL=21404 CL=21538