compiler, runtime: allocate defer records on the stack

Programming / Compilers / GCC - ian [138bc75d-0d04-0410-961f-82ee72b054a4] - 17 August 2019 23:43 EDT

When a defer is executed at most once in a function body, we can allocate the defer record for it on the stack instead of on the heap.

This should make defers like this (which are very common) faster.

This is a port of CL 171758 from the gc repo.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/190410

2d5ff4cbd29 compiler, runtime: allocate defer records on the stack
gcc/go/gofrontend/MERGE | 2 +-
gcc/go/gofrontend/runtime.def | 4 +++
gcc/go/gofrontend/statements.cc | 42 ++++++++++++++++++++++++++--
gcc/go/gofrontend/statements.h | 19 ++++++++++++-
libgo/go/runtime/mgcmark.go | 5 ++++
libgo/go/runtime/panic.go | 38 +++++++++++++++++++++++++
libgo/go/runtime/runtime2.go | 9 ++++++
libgo/go/runtime/stack_test.go | 62 +++++++++++++++++++++++++++++++++++++++++
8 files changed, 176 insertions(+), 5 deletions(-)

Upstream: gcc.gnu.org


  • Share