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
386d1cf6
Commit
386d1cf6
authored
Jan 18, 2016
by
Laszlo Domoszlai
Browse files
fix a B-stack leak: PermSort works
parent
e72c4e2f
Changes
5
Hide whitespace changes
Inline
Side-by-side
interpreter/code.c
View file @
386d1cf6
...
...
@@ -613,7 +613,10 @@ void exec(Code* expr, int frame_ptr, int root_frame_ptr)
placeholder
();
exec
(((
IfEntry
*
)
expr
)
->
cond
,
frame_ptr
,
stack_top_a
);
Thunk
*
cond
=
pop_a
();
// safe to do it before read as nothing can overwrite it inbetween
stack_top_b
--
;
if
(
readB
(
cond
))
{
expr
=
((
IfEntry
*
)
expr
)
->
texpr
;
continue
;
...
...
tests/PermSort.exp
0 → 100644
View file @
386d1cf6
[1]
\ No newline at end of file
tests/broken/Queens2.sapl
deleted
100644 → 0
View file @
e72c4e2f
main = Queens2.Start
Queens2.Start::I = Queens2.nqueens 11
Queens2.nqueens::I !n_0::I = Queens2.len (Queens2.solve n_0 (Queens2.replicate n_0 Flite.Nil))
:: Flite.List = Flite.Nil | Flite.Cons a1 a2
Queens2.replicate !n_0::I x_1 = if (eqI n_0 0) Flite.Nil (Flite.Cons x_1 (Queens2.replicate (subI n_0 1) x_1))
Queens2.solve !n_0::I mask_1 = if (eqI n_0 0) (Flite.Cons Flite.Nil Flite.Nil) (Queens2.concatMap (Queens2.sol (subI n_0 1)) (Queens2.fill mask_1))
Queens2.fill !_x_0 = select _x_0 (Flite.Nil -> Flite.Nil) (Flite.Cons x_1_0 xs_1_1 -> Queens2.append (Queens2.lrd x_1_0 xs_1_1) (Queens2.map (Flite.Cons x_1_0) (Queens2.fill xs_1_1)))
Queens2.map f_0 !_x_1 = select _x_1 (Flite.Nil -> Flite.Nil) (Flite.Cons x_1_0 xs_1_1 -> Flite.Cons (f_0 x_1_0) (Queens2.map f_0 xs_1_1))
Queens2.lrd !_x_0 ys_1 = select _x_0 (Flite.Nil -> Flite.Cons (Flite.Cons (Flite.Cons Queens2.l (Flite.Cons Queens2.r (Flite.Cons Queens2.d Flite.Nil))) ys_1) Flite.Nil) (Flite.Cons x_1_0 xs_1_1 -> Flite.Nil)
Queens2.d::I = 2
Queens2.r::I = 1
Queens2.l::I = 0
Queens2.append !_x_0 ys_1 = select _x_0 (Flite.Nil -> ys_1) (Flite.Cons x_1_0 xs_1_1 -> Flite.Cons x_1_0 (Queens2.append xs_1_1 ys_1))
Queens2.sol !n_0::I row_1 = Queens2.map (Flite.Cons row_1) (Queens2.solve n_0 (Queens2.next row_1))
Queens2.next !mask_0 = Queens2.merge (Queens2.merge (Queens2.down mask_0) (Queens2.left mask_0)) (Queens2.right mask_0)
Queens2.right xs_0 = Flite.Cons Flite.Nil (Queens2.map (Queens2.onep (Queens2.eq_22 Queens2.r)) xs_0)
Queens2.eq_22::B !x_0::I !y_1::I = eqI x_0 y_1
Queens2.onep p_0 !_x_1 = select _x_1 (Flite.Nil -> Flite.Nil) (Flite.Cons x_1_0 xs_1_1 -> if (p_0 x_1_0) (Flite.Cons x_1_0 Flite.Nil) (Queens2.onep p_0 xs_1_1))
Queens2.left !xs_0 = Queens2.map (Queens2.onep (Queens2.eq_22 Queens2.l)) (Queens2.tail xs_0)
Queens2.tail !_x_0 = select _x_0 (Flite.Cons x_1_0 xs_1_1 -> xs_1_1)
Queens2.down !xs_0 = Queens2.map (Queens2.onep (Queens2.eq_22 Queens2.d)) xs_0
Queens2.merge !_x_0 ys_1 = select _x_0 (Flite.Nil -> Flite.Nil) (Flite.Cons x_1_0 xs_1_1 -> select ys_1 (Flite.Nil -> Flite.Cons x_1_0 xs_1_1) (Flite.Cons y_2_0 ys_2_1 -> Flite.Cons (Queens2.append x_1_0 y_2_0) (Queens2.merge xs_1_1 ys_2_1)) )
Queens2.concatMap f_0 !_x_1 = select _x_1 (Flite.Nil -> Flite.Nil) (Flite.Cons x_1_0 xs_1_1 -> Queens2.append (f_0 x_1_0) (Queens2.concatMap f_0 xs_1_1))
Queens2.len::I !_x_0 = select _x_0 (Flite.Nil -> 0) (Flite.Cons x_1_0 xs_1_1 -> addI 1 (Queens2.len xs_1_1))
tests/postponed/PermSort.sapl
deleted
100644 → 0
View file @
e72c4e2f
main = PermSort.Start
PermSort.Start::I = PermSort.head (PermSort.permSort_12 (Flite.Cons 10 (Flite.Cons 9 (Flite.Cons 8 (Flite.Cons 7 (Flite.Cons 6 (Flite.Cons 5 (Flite.Cons 4 (Flite.Cons 3 (Flite.Cons 2 (Flite.Cons 1 Flite.Nil)))))))))))
:: Flite.List = Flite.Nil | Flite.Cons a1 a2
PermSort.permSort_12 !xs_0 = PermSort.head (PermSort.filter PermSort.ord_13 (PermSort.perm xs_0))
PermSort.perm !_x_0 = select _x_0 (Flite.Nil -> Flite.Cons Flite.Nil Flite.Nil) (Flite.Cons x_1_0 xs_1_1 -> PermSort.concatMap (PermSort.place x_1_0) (PermSort.perm xs_1_1))
PermSort.place x_0 !_x_1 = select _x_1 (Flite.Nil -> Flite.Cons (Flite.Cons x_0 Flite.Nil) Flite.Nil) (Flite.Cons y_1_0 ys_1_1 -> Flite.Cons (Flite.Cons x_0 (Flite.Cons y_1_0 ys_1_1)) (PermSort.map (Flite.Cons y_1_0) (PermSort.place x_0 ys_1_1)))
PermSort.map f_0 !_x_1 = select _x_1 (Flite.Nil -> Flite.Nil) (Flite.Cons x_1_0 xs_1_1 -> Flite.Cons (f_0 x_1_0) (PermSort.map f_0 xs_1_1))
PermSort.concatMap f_0 !_x_1 = select _x_1 (Flite.Nil -> Flite.Nil) (Flite.Cons x_1_0 xs_1_1 -> PermSort.append (f_0 x_1_0) (PermSort.concatMap f_0 xs_1_1))
PermSort.append !_x_0 ys_1 = select _x_0 (Flite.Nil -> ys_1) (Flite.Cons x_1_0 xs_1_1 -> Flite.Cons x_1_0 (PermSort.append xs_1_1 ys_1))
PermSort.ord_13::B !_x_0 = select _x_0 (Flite.Nil -> True) (Flite.Cons x_1_0 _x_1_1 -> select _x_1_1 (Flite.Nil -> True) (Flite.Cons y_2_0 ys_2_1 -> PermSort.and (<{PermSort.<=_14}> x_1_0 y_2_0) (PermSort.ord_13 (Flite.Cons y_2_0 ys_2_1))) )
<{PermSort.<=_14}>::B !x_0::I !y_1::I = not (ltI y_1 x_0)
PermSort.and::B !_x_0::B x_1::B = if _x_0 x_1 False
PermSort.filter p_0 !_x_1 = select _x_1 (Flite.Nil -> Flite.Nil) (Flite.Cons x_1_0 xs_1_1 -> if (p_0 x_1_0) (Flite.Cons x_1_0 (PermSort.filter p_0 xs_1_1)) (PermSort.filter p_0 xs_1_1))
PermSort.head !_x_0 = select _x_0 (Flite.Cons x_1_0 xs_1_1 -> x_1_0)
tests/postponed/reptwice.sapl
View file @
386d1cf6
main = Benchmarks.Start
Benchmarks.Start = Benchmarks.reptwice 400
Benchmarks.reptwice !n_0 = Benchmarks.sumrem (Benchmarks.map1 Benchmarks.tinc_90 (Benchmarks.fromto 1 n_0))
Benchmarks.fromto !n_0 !m_1 = Benchmarks.take1 (add (sub m_1 n_0) 1) (Benchmarks.fr n_0)
Benchmarks.fr n_0 = Benchmarks.Cons n_0 (Benchmarks.fr (add n_0 1))
Benchmarks.Start
::I
= Benchmarks.reptwice 400
Benchmarks.reptwice
::I
!n_0
::I
= Benchmarks.sumrem (Benchmarks.map1 Benchmarks.tinc_90 (Benchmarks.fromto 1 n_0))
Benchmarks.fromto !n_0
::I
!m_1
::I
= Benchmarks.take1 (add
I
(sub
I
m_1 n_0) 1) (Benchmarks.fr n_0)
Benchmarks.fr n_0
::I
= Benchmarks.Cons n_0 (Benchmarks.fr (add
I
n_0 1))
:: Benchmarks.List1 = Benchmarks.Nill | Benchmarks.Cons a1 a2
Benchmarks.take1 n_0 !_x_1 = select _x_1 (Benchmarks.Nill -> Benchmarks.Nill) (Benchmarks.Cons x_1_0 xs_1_1 -> if (eqI n_0 0) Benchmarks.Nill (Benchmarks.Cons x_1_0 (Benchmarks.take1 (sub n_0 1) xs_1_1)))
Benchmarks.tinc_90 n_0 = StdFunc.twice StdFunc.twice StdFunc.twice StdFunc.twice Benchmarks.inc_91 n_0
Benchmarks.inc_91 !x_0 = add x_0 1
Benchmarks.take1 n_0
::I
!_x_1 = select _x_1 (Benchmarks.Nill -> Benchmarks.Nill) (Benchmarks.Cons x_1_0 xs_1_1 -> if (eqI n_0 0) Benchmarks.Nill (Benchmarks.Cons x_1_0 (Benchmarks.take1 (sub
I
n_0 1) xs_1_1)))
Benchmarks.tinc_90
::I
n_0
::I
= StdFunc.twice StdFunc.twice StdFunc.twice StdFunc.twice Benchmarks.inc_91 n_0
Benchmarks.inc_91
::I
!x_0
::I
= add
I
x_0 1
StdFunc.twice !f_0 x_1 = f_0 (f_0 x_1)
Benchmarks.map1 f_0 !_x_1 = select _x_1 (Benchmarks.Nill -> Benchmarks.Nill) (Benchmarks.Cons x_1_0 xs_1_1 -> Benchmarks.Cons (f_0 x_1_0) (Benchmarks.map1 f_0 xs_1_1))
Benchmarks.sumrem !_x_0 = select _x_0 (Benchmarks.Nill -> 0) (Benchmarks.Cons a_1_0 as_1_1 -> mod (add a_1_0 (Benchmarks.sumrem as_1_1)) 7)
Benchmarks.sumrem
::I
!_x_0 = select _x_0 (Benchmarks.Nill -> 0) (Benchmarks.Cons a_1_0 as_1_1 -> mod (add
I
a_1_0 (Benchmarks.sumrem as_1_1)) 7)
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