diff options
| author | Keith Randall <khr@golang.org> | 2014-02-26 23:28:44 -0800 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2014-02-26 23:28:44 -0800 |
| commit | 1665b006a57099d7bdf5c9f1277784d36b7168d9 (patch) | |
| tree | b580dcbc40283a9ee36d08d65e9588c65b7d313a /src/pkg/runtime/malloc.h | |
| parent | e5f01aee04dc6313c85dab78305adf499e1f7bfa (diff) | |
| download | go-1665b006a57099d7bdf5c9f1277784d36b7168d9.tar.xz | |
runtime: grow stack by copying
On stack overflow, if all frames on the stack are
copyable, we copy the frames to a new stack twice
as large as the old one. During GC, if a G is using
less than 1/4 of its stack, copy the stack to a stack
half its size.
TODO
- Do something about C frames. When a C frame is in the
stack segment, it isn't copyable. We allocate a new segment
in this case.
- For idempotent C code, we can abort it, copy the stack,
then retry. I'm working on a separate CL for this.
- For other C code, we can raise the stackguard
to the lowest Go frame so the next call that Go frame
makes triggers a copy, which will then succeed.
- Pick a starting stack size?
The plan is that eventually we reach a point where the
stack contains only copyable frames.
LGTM=rsc
R=dvyukov, rsc
CC=golang-codereviews
https://golang.org/cl/54650044
Diffstat (limited to 'src/pkg/runtime/malloc.h')
| -rw-r--r-- | src/pkg/runtime/malloc.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/pkg/runtime/malloc.h b/src/pkg/runtime/malloc.h index c1e7d30e76..84e438d455 100644 --- a/src/pkg/runtime/malloc.h +++ b/src/pkg/runtime/malloc.h @@ -175,6 +175,9 @@ struct MLink // location if that one is unavailable. // // SysMap maps previously reserved address space for use. +// +// SysFault marks a (already SysAlloc'd) region to fault +// if accessed. Used only for debugging the runtime. void* runtime·SysAlloc(uintptr nbytes, uint64 *stat); void runtime·SysFree(void *v, uintptr nbytes, uint64 *stat); @@ -182,6 +185,7 @@ void runtime·SysUnused(void *v, uintptr nbytes); void runtime·SysUsed(void *v, uintptr nbytes); void runtime·SysMap(void *v, uintptr nbytes, uint64 *stat); void* runtime·SysReserve(void *v, uintptr nbytes); +void runtime·SysFault(void *v, uintptr nbytes); // FixAlloc is a simple free-list allocator for fixed size objects. // Malloc uses a FixAlloc wrapped around SysAlloc to manages its @@ -572,6 +576,31 @@ enum DebugTypeAtBlockEnd = 0, }; +// Information from the compiler about the layout of stack frames. +typedef struct BitVector BitVector; +struct BitVector +{ + int32 n; // # of bits + uint32 data[]; +}; +typedef struct StackMap StackMap; +struct StackMap +{ + int32 n; + uint32 data[]; +}; +enum { + // Pointer map + BitsPerPointer = 2, + BitsNoPointer = 0, + BitsPointer = 1, + BitsIface = 2, + BitsEface = 3, +}; +// Returns pointer map data for the given stackmap index +// (the index is encoded in PCDATA_StackMapIndex). +BitVector* runtime·stackmapdata(StackMap *stackmap, int32 n); + // defined in mgc0.go void runtime·gc_m_ptr(Eface*); void runtime·gc_itab_ptr(Eface*); |
