summaryrefslogtreecommitdiff
path: root/libgo/runtime/mfinal.c
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/runtime/mfinal.c')
-rw-r--r--libgo/runtime/mfinal.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/libgo/runtime/mfinal.c b/libgo/runtime/mfinal.c
index 407092bf392..625af528e1e 100644
--- a/libgo/runtime/mfinal.c
+++ b/libgo/runtime/mfinal.c
@@ -5,6 +5,7 @@
#include "runtime.h"
#include "arch.h"
#include "malloc.h"
+#include "go-type.h"
enum { debug = 0 };
@@ -13,6 +14,7 @@ struct Fin
{
FuncVal *fn;
const struct __go_func_type *ft;
+ const struct __go_ptr_type *ot;
};
// Finalizer hash table. Direct hash, linear scan, at most 3/4 full.
@@ -42,7 +44,7 @@ static struct {
} fintab[TABSZ];
static void
-addfintab(Fintab *t, void *k, FuncVal *fn, const struct __go_func_type *ft)
+addfintab(Fintab *t, void *k, FuncVal *fn, const struct __go_func_type *ft, const struct __go_ptr_type *ot)
{
int32 i, j;
@@ -67,6 +69,7 @@ ret:
t->fkey[i] = k;
t->val[i].fn = fn;
t->val[i].ft = ft;
+ t->val[i].ot = ot;
}
static bool
@@ -87,6 +90,7 @@ lookfintab(Fintab *t, void *k, bool del, Fin *f)
t->fkey[i] = (void*)-1;
t->val[i].fn = nil;
t->val[i].ft = nil;
+ t->val[i].ot = nil;
t->ndead++;
}
return true;
@@ -117,13 +121,13 @@ resizefintab(Fintab *tab)
newtab.max *= 3;
}
- newtab.fkey = runtime_mallocgc(newtab.max*sizeof newtab.fkey[0], FlagNoPointers, 0, 1);
- newtab.val = runtime_mallocgc(newtab.max*sizeof newtab.val[0], 0, 0, 1);
+ newtab.fkey = runtime_mallocgc(newtab.max*sizeof newtab.fkey[0], 0, FlagNoInvokeGC|FlagNoScan);
+ newtab.val = runtime_mallocgc(newtab.max*sizeof newtab.val[0], 0, FlagNoInvokeGC);
for(i=0; i<tab->max; i++) {
k = tab->fkey[i];
if(k != nil && k != (void*)-1)
- addfintab(&newtab, k, tab->val[i].fn, tab->val[i].ft);
+ addfintab(&newtab, k, tab->val[i].fn, tab->val[i].ft, tab->val[i].ot);
}
runtime_free(tab->fkey);
@@ -137,7 +141,7 @@ resizefintab(Fintab *tab)
}
bool
-runtime_addfinalizer(void *p, FuncVal *f, const struct __go_func_type *ft)
+runtime_addfinalizer(void *p, FuncVal *f, const struct __go_func_type *ft, const struct __go_ptr_type *ot)
{
Fintab *tab;
byte *base;
@@ -166,7 +170,7 @@ runtime_addfinalizer(void *p, FuncVal *f, const struct __go_func_type *ft)
resizefintab(tab);
}
- addfintab(tab, p, f, ft);
+ addfintab(tab, p, f, ft, ot);
runtime_setblockspecial(p, true);
runtime_unlock(tab);
return true;
@@ -175,7 +179,7 @@ runtime_addfinalizer(void *p, FuncVal *f, const struct __go_func_type *ft)
// get finalizer; if del, delete finalizer.
// caller is responsible for updating RefHasFinalizer (special) bit.
bool
-runtime_getfinalizer(void *p, bool del, FuncVal **fn, const struct __go_func_type **ft)
+runtime_getfinalizer(void *p, bool del, FuncVal **fn, const struct __go_func_type **ft, const struct __go_ptr_type **ot)
{
Fintab *tab;
bool res;
@@ -189,6 +193,7 @@ runtime_getfinalizer(void *p, bool del, FuncVal **fn, const struct __go_func_typ
return false;
*fn = f.fn;
*ft = f.ft;
+ *ot = f.ot;
return true;
}