diff options
author | Ian Lance Taylor <iant@google.com> | 2013-06-18 23:49:49 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-06-18 23:49:49 +0000 |
commit | fdbc38a6e8d7c920eea6c6231c7fe2c987fa8aa2 (patch) | |
tree | 1a7d38cd8be5484451189338ed6f4b76d8521f31 /libgo/runtime/mfinal.c | |
parent | 25e00ab67444a01dce446e95308521d1a73f8232 (diff) | |
download | gcc-fdbc38a6e8d7c920eea6c6231c7fe2c987fa8aa2.zip gcc-fdbc38a6e8d7c920eea6c6231c7fe2c987fa8aa2.tar.gz gcc-fdbc38a6e8d7c920eea6c6231c7fe2c987fa8aa2.tar.bz2 |
compiler, runtime: Use function descriptors.
This changes the representation of a Go value of function type
from being a pointer to function code (like a C function
pointer) to being a pointer to a struct. The first field of
the struct points to the function code. The remaining fields,
if any, are the addresses of variables referenced in enclosing
functions. For each call to a function, the address of the
function descriptor is passed as the last argument.
This lets us avoid generating trampolines, and removes the use
of writable/executable sections of the heap.
From-SVN: r200181
Diffstat (limited to 'libgo/runtime/mfinal.c')
-rw-r--r-- | libgo/runtime/mfinal.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libgo/runtime/mfinal.c b/libgo/runtime/mfinal.c index 7c906da..407092b 100644 --- a/libgo/runtime/mfinal.c +++ b/libgo/runtime/mfinal.c @@ -11,7 +11,7 @@ enum { debug = 0 }; typedef struct Fin Fin; struct Fin { - void (*fn)(void*); + FuncVal *fn; const struct __go_func_type *ft; }; @@ -42,7 +42,7 @@ static struct { } fintab[TABSZ]; static void -addfintab(Fintab *t, void *k, void (*fn)(void*), const struct __go_func_type *ft) +addfintab(Fintab *t, void *k, FuncVal *fn, const struct __go_func_type *ft) { int32 i, j; @@ -137,7 +137,7 @@ resizefintab(Fintab *tab) } bool -runtime_addfinalizer(void *p, void (*f)(void*), const struct __go_func_type *ft) +runtime_addfinalizer(void *p, FuncVal *f, const struct __go_func_type *ft) { Fintab *tab; byte *base; @@ -175,7 +175,7 @@ runtime_addfinalizer(void *p, void (*f)(void*), 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, void (**fn)(void*), const struct __go_func_type **ft) +runtime_getfinalizer(void *p, bool del, FuncVal **fn, const struct __go_func_type **ft) { Fintab *tab; bool res; |