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) ...@@ -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) void create_thunk_var(Code* expr, Thunk** target, int frame_ptr)
{ {
*target = local(frame_ptr, ((VarEntry*) expr)->index); *target = local(frame_ptr, ((VarEntry*) expr)->index);
assert(!instackb(*target));
} }
void create_thunk_var_unboxed(Code* expr, Thunk** target, int frame_ptr) 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) ...@@ -110,11 +111,14 @@ void create_thunk_var_unboxed(Code* expr, Thunk** target, int frame_ptr)
{ {
*target = arg; *target = arg;
} }
assert(!instackb(*target));
} }
void create_thunk_thunk(Code* expr, Thunk** target, int frame_ptr) void create_thunk_thunk(Code* expr, Thunk** target, int frame_ptr)
{ {
*target = &((ThunkEntry*) expr)->thunk; *target = &((ThunkEntry*) expr)->thunk;
assert(!instackb(*target));
} }
void set_create_thunk_fun(Code* code) void set_create_thunk_fun(Code* code)
...@@ -284,6 +288,12 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr) ...@@ -284,6 +288,12 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
int argmask = 1; int argmask = 1;
arg_from_code(slice, ((AppEntry*) expr)->args[0]); arg_from_code(slice, ((AppEntry*) expr)->args[0]);
#ifdef DEBUG_EXEC
printf("FUN1: <");
printDesc(slice);
printf(">\n");
#endif
expr = ((FunEntry*) slice)->body; expr = ((FunEntry*) slice)->body;
frame_ptr = stack_top_a - 1; frame_ptr = stack_top_a - 1;
continue; continue;
...@@ -296,7 +306,13 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr) ...@@ -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[0]);
arg_from_code(slice, ((AppEntry*) expr)->args[1]); arg_from_code(slice, ((AppEntry*) expr)->args[1]);
#ifdef DEBUG_EXEC
printf("FUN2: <");
printDesc(slice);
printf(">\n");
#endif
expr = ((FunEntry*) slice)->body; expr = ((FunEntry*) slice)->body;
frame_ptr = stack_top_a - 2; frame_ptr = stack_top_a - 2;
continue; continue;
...@@ -312,7 +328,14 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr) ...@@ -312,7 +328,14 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
arg_from_code(slice, ((AppEntry*) expr)->args[i]); arg_from_code(slice, ((AppEntry*) expr)->args[i]);
} }
#ifdef DEBUG_EXEC
printf("FUN: <");
printDesc(slice);
printf(">\n");
#endif
expr = ((FunEntry*) slice)->body; expr = ((FunEntry*) slice)->body;
frame_ptr = new_frame_ptr; frame_ptr = new_frame_ptr;
continue; continue;
} }
...@@ -330,6 +353,12 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr) ...@@ -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); memcpy(&stack_a[frame_ptr], &stack_a[new_frame_ptr], sizeof(void*) * expr->nr_args);
stack_top_a = frame_ptr + 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; expr = ((FunEntry*) slice)->body;
continue; continue;
...@@ -339,6 +368,12 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr) ...@@ -339,6 +368,12 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
Desc* slice = ((AppEntry*) expr)->f; Desc* slice = ((AppEntry*) expr)->f;
Thunk* thunk = get_dst(root_frame_ptr); 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 // no need to check for array length, thunks in HNF are never overwritten
int newsize = slice->thunk_size; int newsize = slice->thunk_size;
...@@ -529,6 +564,10 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr) ...@@ -529,6 +564,10 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
assert(is_hnf(arg)); 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 // no need to check for array length, thunks in HNF are never overwritten
if(get_dst(root_frame_ptr) != NULL) if(get_dst(root_frame_ptr) != NULL)
{ {
...@@ -559,6 +598,10 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr) ...@@ -559,6 +598,10 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
assert(is_hnf(arg)); 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 // no need to check for array length, thunks in HNF are never overwritten
// arrays always referenced // arrays always referenced
if(get_dst(root_frame_ptr) != NULL && arg->desc->thunk_size <= sizeof(Thunk) && arg->desc != (Desc*) __ARRAY__) 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) ...@@ -579,6 +622,10 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
{ {
Thunk* thunk = local(frame_ptr, ((VarEntry*) expr)->index); Thunk* thunk = local(frame_ptr, ((VarEntry*) expr)->index);
#ifdef DEBUG_EXEC
printf("VAR: %d\n", ((VarEntry*) expr)->index);
#endif
assert(!instackb(thunk)); assert(!instackb(thunk));
follow_thunk(thunk); follow_thunk(thunk);
...@@ -678,9 +725,17 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr) ...@@ -678,9 +725,17 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
{ {
assert(caseEntry->lit->thunk.desc == (Desc*) __INT__ || assert(caseEntry->lit->thunk.desc == (Desc*) __INT__ ||
caseEntry->lit->thunk.desc == (Desc*) __BOOL__ || 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 // must be SC_DEFAULT now
...@@ -769,7 +824,7 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr) ...@@ -769,7 +824,7 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
push_a(NULL); push_a(NULL);
exec(select->expr, frame_ptr, stack_top_a); exec(select->expr, frame_ptr, stack_top_a);
Thunk* cons = pop_a(); Thunk* cons = pop_a();
expr = select->bodies[((ADTEntry*)cons->desc)->idx]; expr = select->bodies[((ADTEntry*)cons->desc)->idx];
if(expr != NULL) if(expr != NULL)
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define DEBUG_H #define DEBUG_H
#define DEBUG #define DEBUG
//#define DEBUG_EXEC
//#define DEBUG_GC //#define DEBUG_GC
#define BENCHMARK #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