add new eval compiler

fix garbage collector for new big allocation scheme.
This commit is contained in:
Vítor Santos Costa 2008-12-05 16:08:44 +00:00
parent 8bcafd417a
commit 2e8d898e86
4 changed files with 21 additions and 20 deletions

View File

@ -50,13 +50,13 @@ static char SccsId[] = "%W% %G%";
static UInt
big2arena_sz(CELL *arena_base)
{
return ((MP_INT*)(arena_base+1))->_mp_alloc + (sizeof(MP_INT) + sizeof(Functor)+sizeof(CELL))/sizeof(CELL);
return ((MP_INT*)(arena_base+2))->_mp_alloc + (sizeof(MP_INT) + sizeof(Functor)+2*sizeof(CELL))/sizeof(CELL);
}
static UInt
arena2big_sz(UInt sz)
{
return sz - (sizeof(MP_INT) + sizeof(Functor) + sizeof(CELL))/sizeof(CELL);
return sz - (sizeof(MP_INT) + sizeof(Functor) + 2*sizeof(CELL))/sizeof(CELL);
}
@ -85,16 +85,16 @@ ArenaSz(Term arena)
static Term
CreateNewArena(CELL *ptr, UInt size)
{
Term t = AbsAppl(ptr);
MP_INT *dst;
Term t = AbsAppl(ptr);
MP_INT *dst;
ptr[0] = (CELL)FunctorBigInt;
ptr[1] = EMPTY_ARENA;
dst = (MP_INT *)(ptr+2);
dst->_mp_size = 0L;
dst->_mp_alloc = arena2big_sz(size);
ptr[size-1] = EndSpecials;
return t;
ptr[0] = (CELL)FunctorBigInt;
ptr[1] = EMPTY_ARENA;
dst = (MP_INT *)(ptr+2);
dst->_mp_size = 0L;
dst->_mp_alloc = arena2big_sz(size);
ptr[size-1] = EndSpecials;
return t;
}
#if COROUTINING

View File

@ -1346,7 +1346,7 @@ mark_variable(CELL_PTR current)
POP_CONTINUATION();
case (CELL)FunctorBigInt:
{
UInt sz = (sizeof(MP_INT)+1+
UInt sz = (sizeof(MP_INT)+CellSize+
((MP_INT *)(next+2))->_mp_alloc*sizeof(mp_limb_t))/CellSize;
MARK(next);
/* size is given by functor + friends */

View File

@ -1,13 +1,11 @@
:- style_check(all).
:- yap_flag(unknown,error).
:- source.
:- module('$eval',
[compile_arithmetic/2]).
:- module('eval',
['$compile_arithmetic'/2]).
'$compile_arithmetic'((Head :- Body), (Head :- NBody)) :-
term_variables(Head, LVs),
process_body(Body, LVs, NBody).
'$compile_arithmetic'(G, G).
process_body((G,Body), InputVs, NewBody) :-
arithmetic_exp(G), !,
@ -507,7 +505,7 @@ compile_op(fdiv(x(A),F,x(B)), fdiv_c1(A,B,F)) :- float(F), !.
compile_op(fdiv(x(A),I,x(B)), fdiv_c1(A,B,F)) :- integer(I), !, F is truncate(I).
compile_op(fdiv(x(A),x(B),F), fdiv_c2(A,B,F)) :- float(F), !.
compile_op(fdiv(x(A),x(B),I), fdiv_c2(A,B,F)) :- integer(I), !, F is truncate(I).
`compile_op(fdiv(x(A),x(B),x(C)), fdiv(A,B,C)).
compile_op(fdiv(x(A),x(B),x(C)), fdiv(A,B,C)).
compile_op(idiv(x(A),I,x(B)), idiv_c1(A,B,I)) :- integer(I), !.
compile_op(idiv(x(A),x(B),I), idiv_c2(A,B,I)) :- integer(I), !.
compile_op(idiv(x(A),x(B),x(C)), idiv(A,B,C)).
@ -579,4 +577,5 @@ compile_op(ceiling(x(A),x(B)), ceiling(A,B)).
compile_op(msb(x(A),x(B)), msb(A,B)).
compile_op(random(x(A),x(B)), random(A,B)).
compile_op(lgamma(x(A),x(B)), lgamma(A,B)).
*/
*/

View File

@ -48,7 +48,7 @@ otherwise.
:- compile_expressions.
:- [ 'eval.yap',
:- [
'yio.yap',
'debug.yap',
'checker.yap',
@ -60,6 +60,8 @@ otherwise.
% modules must be after preds, otherwise we will have trouble
% with meta-predicate expansion being invoked
'modules.yap',
% must follow grammar
'eval.yap',
'signals.yap',
'profile.yap',
'callcount.yap',