Commit 6a42ac1c authored by Laszlo Domoszlai's avatar Laszlo Domoszlai
Browse files

clean up

parent 5bf5b0ce
......@@ -95,10 +95,17 @@ struct Thunk* create_thunk_var_unboxed(Code* expr, int frame_ptr)
{
Thunk* arg = local(frame_ptr, ((VarEntry*) expr)->index);
// TODO: check if its on heap
Thunk* target = (Thunk*) alloc_heap(sizeof (Thunk));
memcpy(target, arg, sizeof(Thunk));
return target;
if(instackb(arg))
{
// The likely case
Thunk* target = (Thunk*) alloc_heap(sizeof (Thunk));
memcpy(target, arg, sizeof(Thunk));
return target;
}
else
{
return arg;
}
}
struct Thunk* create_thunk_thunk(Code* expr, int frame_ptr)
......@@ -320,7 +327,7 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
thunk = (Thunk*) alloc_heap(newsize);
set_return(root_frame_ptr, thunk);
}
else if (newsize < sizeof(Thunk) || thunk->desc->thunk_size < newsize) {
else if (thunk->desc->thunk_size < newsize) {
Thunk* target = thunk;
thunk = (Thunk*) alloc_heap(newsize);
target->desc = (Desc*) __FORWARD_PTR__;
......
......@@ -108,11 +108,7 @@ void init_desc() {
__REAL_SHARED__ = alloc_prim("REAL", 0);
__STRING__ = alloc_prim("STRING", 0);
__ARRAY__ = alloc_prim("ARRAY", 0);
// Avoid to be overwritten by updateF
__STACK_PLACEHOLDER__ = alloc_prim("PLACEHOLDER", 0);
__STACK_PLACEHOLDER__->base.thunk_size = 0;
__ARRAY__ = alloc_prim("ARRAY", 0);
}
struct FunEntry* __INT__;
......@@ -128,5 +124,4 @@ struct FunEntry* __STRING__;
struct FunEntry* __ARRAY__;
struct FunEntry* __FORWARD_PTR__;
struct FunEntry* __STACK_PLACEHOLDER__;
......@@ -84,6 +84,5 @@ extern struct FunEntry* __STRING__;
extern struct FunEntry* __ARRAY__;
extern struct FunEntry* __FORWARD_PTR__;
extern struct FunEntry* __STACK_PLACEHOLDER__;
#endif // __DESC_H
\ No newline at end of file
......@@ -85,7 +85,7 @@ int main ( int argc, char *argv[] )
#endif
Thunk* res = alloc_b();
res->desc = (Desc*) __STACK_PLACEHOLDER__;
res->desc = (Desc*) __INT__; // does not matter, but should be a proper descriptor
push_a(res);
exec(expr, stack_top_a, stack_top_a);
......
......@@ -59,8 +59,6 @@ void print(bool force) {
}
} else if ((FunEntry*) thunk->desc == __CHAR__ || (FunEntry*) thunk->desc == __CHAR_SHARED__) {
printf("%c", thunk->_char);
} else if ((FunEntry*) thunk->desc == __STACK_PLACEHOLDER__) {
printf("STACKPLACEHOLDER");
} else {
printf("print: unhandled BOXED LIT\n");
printDesc(thunk->desc);
......
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