Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-and-itasks
sapl-interpreter
Commits
4a9b1363
Commit
4a9b1363
authored
Sep 21, 2015
by
Laszlo Domoszlai
Browse files
inline updateF
parent
a8bd0e39
Changes
3
Hide whitespace changes
Inline
Side-by-side
interpreter/code.c
View file @
4a9b1363
...
...
@@ -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
);
...
...
interpreter/thunk.c
View file @
4a9b1363
...
...
@@ -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
;
...
...
interpreter/thunk.h
View file @
4a9b1363
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment