Skip to content
GitLab
Menu
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
6e5493c4
Commit
6e5493c4
authored
Feb 01, 2016
by
Laszlo Domoszlai
Browse files
move thunk allocation a bit later for prims, so GC cannot screw up everything
parent
b9ecfe99
Changes
2
Hide whitespace changes
Inline
Side-by-side
interpreter/code.c
View file @
6e5493c4
...
...
@@ -172,13 +172,7 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
switch
(
expr
->
type
)
{
case
CT_APP_PRIM1
:
{
if
(
get_dst
(
root_frame_ptr
)
==
NULL
&&
(((
AppEntry
*
)
expr
)
->
f
)
->
unboxable_return
)
{
Thunk
*
tmp
=
(
Thunk
*
)
alloc_heap
(
sizeof
(
Thunk
));
set_return
(
root_frame_ptr
,
tmp
);
}
{
switch
(
expr
->
arg_pattern
)
{
case
1
:
...
...
@@ -192,7 +186,13 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
exec
(((
AppEntry
*
)
expr
)
->
args
[
0
],
frame_ptr
,
stack_top_a
);
break
;
}
if
(
get_dst
(
root_frame_ptr
)
==
NULL
&&
(((
AppEntry
*
)
expr
)
->
f
)
->
unboxable_return
)
{
Thunk
*
tmp
=
(
Thunk
*
)
alloc_heap
(
sizeof
(
Thunk
));
set_return
(
root_frame_ptr
,
tmp
);
}
((
PrimEntry
*
)
((
AppEntry
*
)
expr
)
->
f
)
->
exec
(
root_frame_ptr
);
destroy_stack_frame
(
root_frame_ptr
);
...
...
@@ -200,13 +200,7 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
return
;
}
case
CT_APP_PRIM2
:
{
if
(
get_dst
(
root_frame_ptr
)
==
NULL
&&
(((
AppEntry
*
)
expr
)
->
f
)
->
unboxable_return
)
{
Thunk
*
tmp
=
(
Thunk
*
)
alloc_heap
(
sizeof
(
Thunk
));
set_return
(
root_frame_ptr
,
tmp
);
}
{
// careful, "exec" may trigger garbage collection
// read local variables only after the last exec
switch
(
expr
->
arg_pattern
)
...
...
@@ -250,6 +244,12 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
exec
(((
AppEntry
*
)
expr
)
->
args
[
1
],
frame_ptr
,
stack_top_a
);
}
if
(
get_dst
(
root_frame_ptr
)
==
NULL
&&
(((
AppEntry
*
)
expr
)
->
f
)
->
unboxable_return
)
{
Thunk
*
tmp
=
(
Thunk
*
)
alloc_heap
(
sizeof
(
Thunk
));
set_return
(
root_frame_ptr
,
tmp
);
}
((
PrimEntry
*
)
((
AppEntry
*
)
expr
)
->
f
)
->
exec
(
root_frame_ptr
);
destroy_stack_frame
(
root_frame_ptr
);
...
...
@@ -258,12 +258,6 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
}
case
CT_APP_PRIM
:
{
if
(
get_dst
(
root_frame_ptr
)
==
NULL
&&
(((
AppEntry
*
)
expr
)
->
f
)
->
unboxable_return
)
{
Thunk
*
tmp
=
(
Thunk
*
)
alloc_heap
(
sizeof
(
Thunk
));
set_return
(
root_frame_ptr
,
tmp
);
};
PrimEntry
*
desc
=
(
PrimEntry
*
)
((
AppEntry
*
)
expr
)
->
f
;
int
argmask
=
1
;
...
...
@@ -283,6 +277,12 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
argmask
<<=
1
;
}
if
(
get_dst
(
root_frame_ptr
)
==
NULL
&&
(((
AppEntry
*
)
expr
)
->
f
)
->
unboxable_return
)
{
Thunk
*
tmp
=
(
Thunk
*
)
alloc_heap
(
sizeof
(
Thunk
));
set_return
(
root_frame_ptr
,
tmp
);
}
desc
->
exec
(
root_frame_ptr
);
destroy_stack_frame
(
root_frame_ptr
);
...
...
@@ -414,6 +414,12 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
exec
(((
AppEntry
*
)
expr
)
->
args
[
i
],
frame_ptr
,
stack_top_a
);
}
if
(
get_dst
(
root_frame_ptr
)
==
NULL
&&
slice
->
unboxable_return
)
{
Thunk
*
tmp
=
(
Thunk
*
)
alloc_heap
(
sizeof
(
Thunk
));
set_return
(
root_frame_ptr
,
tmp
);
}
((
PrimEntry
*
)
slice
)
->
exec
(
root_frame_ptr
);
destroy_stack_frame
(
root_frame_ptr
);
destroy_stack_frame_b
(
root_frame_ptr_b
);
...
...
interpreter/main.c
View file @
6e5493c4
...
...
@@ -74,7 +74,7 @@ int main ( int argc, char *argv[] )
parse
(
&
line
,
len
);
input
=
"..
\\
tests
\\
parsetest1
.bsapl"
;
input
=
"..
\\
tests
\\
static_os
.bsapl"
;
if
(
argc
==
2
)
{
...
...
@@ -109,9 +109,7 @@ int main ( int argc, char *argv[] )
gettimeofday
(
&
t1
,
NULL
);
#endif
Thunk
*
res
=
alloc_b
();
res
->
desc
=
(
Desc
*
)
__INT__
;
// does not matter, but should be a proper descriptor
push_a
(
res
);
push_a
(
NULL
);
exec
(
expr
,
stack_top_a
,
stack_top_a
);
print
(
true
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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