From 2e8d898e86100b28b02480b55fdd2ca00b516c29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Fri, 5 Dec 2008 16:08:44 +0000 Subject: [PATCH] add new eval compiler fix garbage collector for new big allocation scheme. --- C/globals.c | 22 +++++++++++----------- C/heapgc.c | 2 +- pl/eval.yap | 13 ++++++------- pl/init.yap | 4 +++- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/C/globals.c b/C/globals.c index c2aa6798b..4f639e00a 100644 --- a/C/globals.c +++ b/C/globals.c @@ -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 diff --git a/C/heapgc.c b/C/heapgc.c index 36b28a437..7f3270a7e 100644 --- a/C/heapgc.c +++ b/C/heapgc.c @@ -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 */ diff --git a/pl/eval.yap b/pl/eval.yap index bd3167ec3..1c38490c4 100644 --- a/pl/eval.yap +++ b/pl/eval.yap @@ -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)). -*/ \ No newline at end of file +*/ + diff --git a/pl/init.yap b/pl/init.yap index 509881dfa..da689ac2b 100644 --- a/pl/init.yap +++ b/pl/init.yap @@ -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',