]> Cypherpunks repositories - gostls13.git/commit
runtime: grow stack by copying
authorKeith Randall <khr@golang.org>
Thu, 27 Feb 2014 07:28:44 +0000 (23:28 -0800)
committerKeith Randall <khr@golang.org>
Thu, 27 Feb 2014 07:28:44 +0000 (23:28 -0800)
commit1665b006a57099d7bdf5c9f1277784d36b7168d9
treeb580dcbc40283a9ee36d08d65e9588c65b7d313a
parente5f01aee04dc6313c85dab78305adf499e1f7bfa
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
17 files changed:
src/pkg/runtime/malloc.h
src/pkg/runtime/mem_darwin.c
src/pkg/runtime/mem_dragonfly.c
src/pkg/runtime/mem_freebsd.c
src/pkg/runtime/mem_linux.c
src/pkg/runtime/mem_netbsd.c
src/pkg/runtime/mem_openbsd.c
src/pkg/runtime/mem_plan9.c
src/pkg/runtime/mem_solaris.c
src/pkg/runtime/mem_windows.c
src/pkg/runtime/mgc0.c
src/pkg/runtime/proc.c
src/pkg/runtime/runtime.h
src/pkg/runtime/stack.c
src/pkg/runtime/stack.h
src/pkg/runtime/traceback_arm.c
src/pkg/runtime/traceback_x86.c