Commit 4a9b1363 authored by Laszlo Domoszlai's avatar Laszlo Domoszlai
Browse files

inline updateF

parent a8bd0e39
......@@ -283,9 +283,18 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
case CT_APP_THUNK:
{
Desc* slice = ((AppEntry*) expr)->f;
Thunk* thunk = get_dst(root_frame_ptr);
int newsize = slice->thunk_size;
if (thunk->desc->thunk_size < newsize) {
Thunk* target = thunk;
thunk = (Thunk*) alloc_heap(newsize);
target->desc = (Desc*) __FORWARD_PTR__;
target->_forward_ptr = thunk;
}
Thunk* thunk = updateF(get_dst(root_frame_ptr), slice);
thunk->desc = slice;
assert(thunk->desc->arity == expr->nr_args);
for (int i = 0; i < expr->nr_args; i++) {
......@@ -353,8 +362,18 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
case FT_ADT:
case FT_RECORD:
{
Thunk* thunk = updateF(get_dst(root_frame_ptr), slice);
Thunk* thunk = get_dst(root_frame_ptr);
int newsize = slice->thunk_size;
if (thunk->desc->thunk_size < newsize) {
Thunk* target = thunk;
thunk = (Thunk*) alloc_heap(newsize);
target->desc = (Desc*) __FORWARD_PTR__;
target->_forward_ptr = thunk;
}
thunk->desc = slice;
assert(thunk->desc->arity == basethunk->desc->arity + expr->nr_args);
memcpy(&thunk->_args, &basethunk->_args, sizeof(Thunk*) * basethunk->desc->arity);
......
......@@ -34,24 +34,6 @@ int readB(Thunk* thunk) {
}
#endif
struct Thunk* updateF(Thunk* target, Desc* f) {
assert(f != NULL);
Thunk* thunk = target;
int newsize = f->thunk_size;
if (target->desc->thunk_size < newsize) {
thunk = (Thunk*) alloc_heap(newsize);
target->desc = (Desc*) __FORWARD_PTR__;
target->_forward_ptr = thunk;
}
assert(thunk != NULL);
thunk->desc = f;
return thunk;
}
bool is_hnf(Thunk* thunk)
{
return thunk->desc->hnf;
......
......@@ -46,8 +46,6 @@ int readB(Thunk* thunk);
#endif
struct Thunk* updateF(Thunk* target, Desc* f);
bool is_hnf(Thunk* thunk);
// Thunk is supposed to be in HNF
......
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