]> Cypherpunks.ru repositories - gostls13.git/commit
runtime, cmd/compile: optimize open-coded defers
authorMatthew Dempsky <mdempsky@google.com>
Fri, 4 Aug 2023 21:10:59 +0000 (14:10 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 7 Aug 2023 18:05:54 +0000 (18:05 +0000)
commitbb5974e0cb507487ab7a164c08452456840d3ad7
tree1d6b24875ced4f1fab960c2a365e0f8f208adefd
parent65d4723b49cedaf533a21845013814fc4d0a467f
runtime, cmd/compile: optimize open-coded defers

This CL optimizes open-coded defers in two ways:

1. It modifies local variable sorting to place all open-coded defer
closure slots in order, so that rather than requiring the metadata to
contain each offset individually, we just need a single offset to the
first slot.

2. Because the slots are in ascending order and can be directly
indexed, we can get rid of the count of how many defers are in the
frame. Instead, we just find the top set bit in the active defers
bitmask, and load the corresponding closure.

Change-Id: I6f912295a492211023a9efe12c94a14f449d86ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/516199
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/compile/internal/ssagen/pgen.go
src/cmd/compile/internal/ssagen/ssa.go
src/runtime/panic.go
src/runtime/runtime2.go