Commit 9d7ba75d authored by Laszlo Domoszlai's avatar Laszlo Domoszlai
Browse files

- more debug stuff

- select literal can be real as well
parent cdbe907d
......@@ -93,6 +93,7 @@ void create_thunk_app_dyn(Code* expr, Thunk** target, int frame_ptr)
void create_thunk_var(Code* expr, Thunk** target, int frame_ptr)
{
*target = local(frame_ptr, ((VarEntry*) expr)->index);
assert(!instackb(*target));
}
void create_thunk_var_unboxed(Code* expr, Thunk** target, int frame_ptr)
......@@ -110,11 +111,14 @@ void create_thunk_var_unboxed(Code* expr, Thunk** target, int frame_ptr)
{
*target = arg;
}
assert(!instackb(*target));
}
void create_thunk_thunk(Code* expr, Thunk** target, int frame_ptr)
{
*target = &((ThunkEntry*) expr)->thunk;
assert(!instackb(*target));
}
void set_create_thunk_fun(Code* code)
......@@ -284,6 +288,12 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
int argmask = 1;
arg_from_code(slice, ((AppEntry*) expr)->args[0]);
#ifdef DEBUG_EXEC
printf("FUN1: <");
printDesc(slice);
printf(">\n");
#endif
expr = ((FunEntry*) slice)->body;
frame_ptr = stack_top_a - 1;
continue;
......@@ -296,7 +306,13 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
arg_from_code(slice, ((AppEntry*) expr)->args[0]);
arg_from_code(slice, ((AppEntry*) expr)->args[1]);
#ifdef DEBUG_EXEC
printf("FUN2: <");
printDesc(slice);
printf(">\n");
#endif
expr = ((FunEntry*) slice)->body;
frame_ptr = stack_top_a - 2;
continue;
......@@ -312,7 +328,14 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
arg_from_code(slice, ((AppEntry*) expr)->args[i]);
}
#ifdef DEBUG_EXEC
printf("FUN: <");
printDesc(slice);
printf(">\n");
#endif
expr = ((FunEntry*) slice)->body;
frame_ptr = new_frame_ptr;
continue;
}
......@@ -330,6 +353,12 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
memcpy(&stack_a[frame_ptr], &stack_a[new_frame_ptr], sizeof(void*) * expr->nr_args);
stack_top_a = frame_ptr + expr->nr_args;
#ifdef DEBUG_EXEC
printf("FUN TR: <");
printDesc(slice);
printf(">\n");
#endif
expr = ((FunEntry*) slice)->body;
continue;
......@@ -339,6 +368,12 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
Desc* slice = ((AppEntry*) expr)->f;
Thunk* thunk = get_dst(root_frame_ptr);
#ifdef DEBUG_EXEC
printf("APP THUNK: <");
printDesc(slice);
printf(">\n");
#endif
// no need to check for array length, thunks in HNF are never overwritten
int newsize = slice->thunk_size;
......@@ -529,6 +564,10 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
assert(is_hnf(arg));
#ifdef DEBUG_EXEC
printf("VAR@: %d\n", ((VarEntry*) expr)->index);
#endif
// no need to check for array length, thunks in HNF are never overwritten
if(get_dst(root_frame_ptr) != NULL)
{
......@@ -559,6 +598,10 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
assert(is_hnf(arg));
#ifdef DEBUG_EXEC
printf("VAR!: %d\n", ((VarEntry*) expr)->index);
#endif
// no need to check for array length, thunks in HNF are never overwritten
// arrays always referenced
if(get_dst(root_frame_ptr) != NULL && arg->desc->thunk_size <= sizeof(Thunk) && arg->desc != (Desc*) __ARRAY__)
......@@ -579,6 +622,10 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
{
Thunk* thunk = local(frame_ptr, ((VarEntry*) expr)->index);
#ifdef DEBUG_EXEC
printf("VAR: %d\n", ((VarEntry*) expr)->index);
#endif
assert(!instackb(thunk));
follow_thunk(thunk);
......@@ -678,9 +725,17 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
{
assert(caseEntry->lit->thunk.desc == (Desc*) __INT__ ||
caseEntry->lit->thunk.desc == (Desc*) __BOOL__ ||
caseEntry->lit->thunk.desc == (Desc*) __CHAR__);
caseEntry->lit->thunk.desc == (Desc*) __CHAR__ ||
caseEntry->lit->thunk.desc == (Desc*) __REAL__);
if(caseEntry->lit->thunk._int != lit->_int) continue;
if(caseEntry->lit->thunk.desc == (Desc*) __REAL__)
{
if(caseEntry->lit->thunk._real != lit->_real) continue;
}
else
{
if(caseEntry->lit->thunk._int != lit->_int) continue;
}
}
// must be SC_DEFAULT now
......@@ -769,7 +824,7 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
push_a(NULL);
exec(select->expr, frame_ptr, stack_top_a);
Thunk* cons = pop_a();
expr = select->bodies[((ADTEntry*)cons->desc)->idx];
if(expr != NULL)
......
......@@ -2,6 +2,7 @@
#define DEBUG_H
#define DEBUG
//#define DEBUG_EXEC
//#define DEBUG_GC
#define BENCHMARK
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment