summaryrefslogtreecommitdiff
path: root/src/runtime/mfinal.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-02-19 13:38:46 -0500
committerRuss Cox <rsc@golang.org>2015-02-19 20:17:01 +0000
commit484f801ff4125d86f8c4072f070611afea9c79f7 (patch)
tree6609ead9e0e6dabd5565800a5c5f80a89211ef75 /src/runtime/mfinal.go
parentd384545a4580cf1f6990efee5f0047ec60f4258d (diff)
downloadgo-git-484f801ff4125d86f8c4072f070611afea9c79f7.tar.gz
runtime: reorganize memory code
Move code from malloc1.go, malloc2.go, mem.go, mgc0.go into appropriate locations. Factor mgc.go into mgc.go, mgcmark.go, mgcsweep.go, mstats.go. A lot of this code was in certain files because the right place was in a C file but it was written in Go, or vice versa. This is one step toward making things actually well-organized again. Change-Id: I6741deb88a7cfb1c17ffe0bcca3989e10207968f Reviewed-on: https://go-review.googlesource.com/5300 Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Rick Hudson <rlh@golang.org>
Diffstat (limited to 'src/runtime/mfinal.go')
-rw-r--r--src/runtime/mfinal.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/runtime/mfinal.go b/src/runtime/mfinal.go
index 525aa0955a..d066b609b7 100644
--- a/src/runtime/mfinal.go
+++ b/src/runtime/mfinal.go
@@ -8,6 +8,14 @@ package runtime
import "unsafe"
+type finblock struct {
+ alllink *finblock
+ next *finblock
+ cnt int32
+ _ int32
+ fin [(_FinBlockSize - 2*ptrSize - 2*4) / unsafe.Sizeof(finalizer{})]finalizer
+}
+
var finlock mutex // protects the following variables
var fing *g // goroutine that runs finalizers
var finq *finblock // list of finalizers that are to be executed
@@ -17,6 +25,15 @@ var fingwait bool
var fingwake bool
var allfin *finblock // list of all blocks
+// NOTE: Layout known to queuefinalizer.
+type finalizer struct {
+ fn *funcval // function to call
+ arg unsafe.Pointer // ptr to object
+ nret uintptr // bytes of return values from fn
+ fint *_type // type of first argument of fn
+ ot *ptrtype // type of ptr to object
+}
+
var finalizer1 = [...]byte{
// Each Finalizer is 5 words, ptr ptr uintptr ptr ptr.
// Each byte describes 4 words.