compiler: rewrite defer support to better support them

This costs a bit in code size, but should be more flexible for the
future to implement recover() and running deferred functions while
panicking.
This commit is contained in:
Ayke van Laethem
2018-09-05 19:59:03 +02:00
parent 87dd1a1fe5
commit f44d2f718f
2 changed files with 120 additions and 32 deletions
+17
View File
@@ -0,0 +1,17 @@
package runtime
import "unsafe"
type deferContext unsafe.Pointer
type _defer struct {
callback func(*_defer)
next *_defer
}
func rundefers(stack *_defer) {
for stack != nil {
stack.callback(stack)
stack = stack.next
}
}