Templatized cilk_call functions

上级 6ec84747
#if CILKENABLE
template<typename A1>
static void
cilk_call(void (*fn)(A1), A1 a1)
{
cilk_push((void(*)(uptr, uptr))fn, (uptr)a1, (uptr)0);
}
template<typename A1, typename A2>
static void
cilk_call(void (*fn)(A1, A2), A1 a1, A2 a2)
{
cilk_push((void(*)(uptr, uptr))fn, (uptr)a1, (uptr)a2);
}
#else // !CILKENABLE
template<typename A1>
static void
cilk_call(void (*fn)(A1), A1 a1)
{
fn(a1);
}
template<typename A1, typename A2>
static void
cilk_call(void (*fn)(A1, A2), A1 a1, A2 a2)
{
fn(a1, a2);
}
#endif
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#include "elf.hh" #include "elf.hh"
#include "cpu.hh" #include "cpu.hh"
#include "prof.hh" #include "prof.hh"
#include "wq.hh"
#include "cilk.hh"
#define USTACKPAGES 2 #define USTACKPAGES 2
#define BRK (USERTOP >> 1) #define BRK (USERTOP >> 1)
...@@ -28,10 +30,8 @@ struct eargs { ...@@ -28,10 +30,8 @@ struct eargs {
}; };
static void static void
dosegment(uptr a0, u64 a1) dosegment(struct eargs *args, u64 off)
{ {
struct eargs *args = (eargs*) a0;
u64 off = a1;
struct vmnode *vmn = nullptr; struct vmnode *vmn = nullptr;
struct proghdr ph; struct proghdr ph;
uptr va_start, va_end; uptr va_start, va_end;
...@@ -69,10 +69,10 @@ bad: ...@@ -69,10 +69,10 @@ bad:
cilk_abort(-1); cilk_abort(-1);
} }
static void __attribute__((unused)) dostack(uptr a0, u64 a1) static void
dostack(struct eargs *args)
{ {
struct vmnode *vmn = nullptr; struct vmnode *vmn = nullptr;
struct eargs *args = (eargs*) a0;
int argc; int argc;
uptr sp; uptr sp;
uptr ustack[1+MAXARG+1]; uptr ustack[1+MAXARG+1];
...@@ -123,10 +123,10 @@ bad: ...@@ -123,10 +123,10 @@ bad:
cilk_abort(-1); cilk_abort(-1);
} }
static void __attribute__((unused)) doheap(uptr a0, u64 a1) static void
doheap(struct eargs *args)
{ {
struct vmnode *vmn = nullptr; struct vmnode *vmn = nullptr;
struct eargs *args = (eargs*) a0;
prof_start(doheap_prof); prof_start(doheap_prof);
// Allocate a vmnode for the heap. // Allocate a vmnode for the heap.
...@@ -188,7 +188,7 @@ exec(const char *path, char **argv) ...@@ -188,7 +188,7 @@ exec(const char *path, char **argv)
goto bad; goto bad;
if(type != ELF_PROG_LOAD) if(type != ELF_PROG_LOAD)
continue; continue;
cilk_push(dosegment, (uptr)&args, (uptr)off); cilk_call(dosegment, &args, off);
} }
if (odp) { if (odp) {
...@@ -199,12 +199,11 @@ exec(const char *path, char **argv) ...@@ -199,12 +199,11 @@ exec(const char *path, char **argv)
ip = 0; ip = 0;
} }
cilk_push(doheap, (uptr)&args, (uptr)0); cilk_call(doheap, &args);
// dostack reads from the user address space. The wq // dostack reads from the user vm space. wq workers don't switch
// stuff doesn't switch to the user address space. // the user vm.
//cilk_push(dostack, (uptr)&args, (uptr)0); dostack(&args);
dostack((uptr)&args, (uptr)0);
if (cilk_end()) if (cilk_end())
goto bad; goto bad;
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论