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
c51700b1
Commit
c51700b1
authored
Mar 14, 2016
by
Laszlo Domoszlai
Browse files
properly GC unboxed arrays
parent
2866c938
Changes
1
Hide whitespace changes
Inline
Side-by-side
interpreter/gc.c
View file @
c51700b1
...
...
@@ -59,15 +59,7 @@ void gc()
if
(
ptr
->
desc
==
(
Desc
*
)
__ARRAY__
)
{
if
(
ptr
->
_array
.
is_boxed
)
{
size
=
sizeof
(
Desc
)
+
sizeof
(
Array
)
+
(
ptr
->
_array
.
bytes_per_elem
*
ptr
->
_array
.
length
);
}
else
{
// TODO: other cases
}
size
=
sizeof
(
Desc
)
+
sizeof
(
Array
)
+
(
ptr
->
_array
.
bytes_per_elem
*
ptr
->
_array
.
length
);
}
else
{
...
...
@@ -86,6 +78,9 @@ void gc()
#ifdef DEBUG_GC
printf
(
"ALLOC AFTER FIRST STAGE: %i
\n
"
,
allocptr
-
heap_base_swap
);
#endif
int
arity
;
Thunk
**
args
=
NULL
;
while
(
scanptr
<
allocptr
)
{
...
...
@@ -94,15 +89,27 @@ void gc()
if
(
ptr
->
desc
==
(
Desc
*
)
__ARRAY__
)
{
scanptr
+=
sizeof
(
Desc
)
+
sizeof
(
Array
)
+
(
ptr
->
_array
.
bytes_per_elem
*
ptr
->
_array
.
length
);
if
(
ptr
->
_array
.
is_boxed
)
{
arity
=
0
;
}
else
{
arity
=
ptr
->
_array
.
length
;
args
=
ptr
->
_array
.
_elems
;
}
}
else
{
scanptr
+=
ptr
->
desc
->
thunk_size
;
arity
=
ptr
->
desc
->
arity
;
args
=
ptr
->
_args
;
}
for
(
int
i
=
0
;
i
<
ptr
->
desc
->
arity
;
i
++
)
for
(
int
i
=
0
;
i
<
arity
;
i
++
)
{
Thunk
*
arg
=
(
Thunk
*
)
ptr
->
_
args
[
i
];
Thunk
*
arg
=
(
Thunk
*
)
args
[
i
];
// do not copy forward pointers
// also do it outside, because the final thunk may be out of the heap
...
...
@@ -128,15 +135,7 @@ void gc()
if
(
arg
->
desc
==
(
Desc
*
)
__ARRAY__
)
{
if
(
arg
->
_array
.
is_boxed
)
{
size
=
sizeof
(
Desc
)
+
sizeof
(
Array
)
+
(
arg
->
_array
.
bytes_per_elem
*
arg
->
_array
.
length
);
}
else
{
// TODO: other cases
}
size
=
sizeof
(
Desc
)
+
sizeof
(
Array
)
+
(
arg
->
_array
.
bytes_per_elem
*
arg
->
_array
.
length
);
}
else
{
...
...
Write
Preview
Markdown
is supported
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