summaryrefslogtreecommitdiffstats
path: root/libgo/runtime/time.goc
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2013-06-18 23:49:49 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2013-06-18 23:49:49 +0000
commit8381eda7ff1e5a2874d708573654e64a4efcfb4f (patch)
tree1a7d38cd8be5484451189338ed6f4b76d8521f31 /libgo/runtime/time.goc
parent2851d736ebf1e8cceebb9106cab69d2c3fdc7624 (diff)
downloadppe42-gcc-8381eda7ff1e5a2874d708573654e64a4efcfb4f.tar.gz
ppe42-gcc-8381eda7ff1e5a2874d708573654e64a4efcfb4f.zip
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@200181 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/runtime/time.goc')
-rw-r--r--libgo/runtime/time.goc13
1 files changed, 8 insertions, 5 deletions
diff --git a/libgo/runtime/time.goc b/libgo/runtime/time.goc
index 9a5cbdfed3b..e9f087ac884 100644
--- a/libgo/runtime/time.goc
+++ b/libgo/runtime/time.goc
@@ -49,13 +49,16 @@ static void siftdown(int32);
// Ready the goroutine e.data.
static void
-ready(int64 now, Eface e)
+ready(int64 now, Eface e, void *closure)
{
USED(now);
+ USED(closure);
runtime_ready(e.__object);
}
+static FuncVal readyv = {(void(*)(void))ready};
+
// Put the current goroutine to sleep for ns nanoseconds.
void
runtime_tsleep(int64 ns, const char *reason)
@@ -70,7 +73,7 @@ runtime_tsleep(int64 ns, const char *reason)
t.when = runtime_nanotime() + ns;
t.period = 0;
- t.f = ready;
+ t.fv = &readyv;
t.arg.__object = g;
runtime_lock(&timers);
addtimer(&t);
@@ -158,7 +161,7 @@ timerproc(void* dummy __attribute__ ((unused)))
{
int64 delta, now;
Timer *t;
- void (*f)(int64, Eface);
+ void (*f)(int64, Eface, void *);
Eface arg;
for(;;) {
@@ -184,12 +187,12 @@ timerproc(void* dummy __attribute__ ((unused)))
siftdown(0);
t->i = -1; // mark as removed
}
- f = t->f;
+ f = (void*)t->fv->fn;
arg = t->arg;
runtime_unlock(&timers);
if(raceenabled)
runtime_raceacquire(t);
- f(now, arg);
+ f(now, arg, &t->fv);
runtime_lock(&timers);
}
if(delta < 0) {
OpenPOWER on IntegriCloud