new Atts code.

This commit is contained in:
Vitor Santos Costa 2010-03-08 09:23:58 +00:00
parent d48be6406b
commit 34ca485e42
8 changed files with 46 additions and 141 deletions

View File

@ -33,10 +33,6 @@
#define strncat(s0,s1,sz) strcat(s0,s1)
#endif
#if !COROUTINING
#define DelayTop() H0
#endif
typedef enum {
STACK_SHIFTING = 0,
STACK_COPYING = 1,
@ -134,7 +130,6 @@ SetHeapRegs(int copying_threads)
OldTR = TR;
OldHeapBase = Yap_HeapBase;
OldHeapTop = HeapTop;
OldDelayTop = CurrentDelayTop;
/* Adjust stack addresses */
Yap_TrailBase = TrailAddrAdjust(Yap_TrailBase);
Yap_TrailTop = TrailAddrAdjust(Yap_TrailTop);
@ -172,8 +167,6 @@ SetHeapRegs(int copying_threads)
HB = PtoGloAdjust(HB);
if (B)
B = ChoicePtrAdjust(B);
if (CurrentDelayTop)
CurrentDelayTop = PtoDelayAdjust(CurrentDelayTop);
#ifdef TABLING
if (B_FZ)
B_FZ = ChoicePtrAdjust(B_FZ);
@ -195,12 +188,8 @@ SetHeapRegs(int copying_threads)
if (!copying_threads) {
if (GlobalArena)
GlobalArena = AbsAppl(PtoGloAdjust(RepAppl(GlobalArena)));
if (GlobalDelayArena)
GlobalDelayArena = GlobalAdjust(GlobalDelayArena);
}
#ifdef COROUTINING
if (DelayedVars)
DelayedVars = AbsAppl(PtoGloAdjust(RepAppl(DelayedVars)));
if (AttsMutableList)
AttsMutableList = AbsAppl(PtoGloAdjust(RepAppl(AttsMutableList)));
if (WokenGoals)
@ -256,7 +245,7 @@ worker_p_binding(int worker_p, CELL *aux_ptr)
reg = AdjustGlobTerm(reg);
return reg;
} else {
CELL reg = ThreadHandle[worker_p].current_yaam_regs->H0_[aux_ptr-H0];
CELL reg = ThreadHandle[worker_p].current_yaam_regs-> H0_[aux_ptr-H0];
reg = AdjustGlobTerm(reg);
return reg;
}
@ -567,12 +556,12 @@ AdjustGlobal(long sz, int thread_copying)
pt_max = (CELL *) (LOCAL_end_global_copy);
} else {
#endif
pt = CurrentDelayTop;
pt = H0;
pt_max = (H-sz/CellSize);
#if defined(YAPOR) && defined(THREADS)
}
#endif
pt = CurrentDelayTop;
pt = H0;
while (pt < pt_max) {
CELL reg;
@ -777,7 +766,6 @@ static_growheap(long size, int fix_code, struct intermediates *cip, tr_fr_ptr *o
int gc_verbose;
UInt minimal_request = 0L;
CurrentDelayTop = (CELL *)DelayTop();
/* adjust to a multiple of 256) */
if (size < YAP_ALLOC_SIZE)
size = YAP_ALLOC_SIZE;
@ -859,7 +847,7 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit)
{
UInt start_growth_time, growth_time;
int gc_verbose;
char *omax = (ADDR)DelayTop();
char *omax = (char *)H0;
ADDR old_GlobalBase = Yap_GlobalBase;
UInt minimal_request = 0L;
long size = request;
@ -874,7 +862,6 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit)
do_grow is whether we expand stacks
*/
CurrentDelayTop = (CELL *)omax;
if (hsplit) {
/* just a little bit of sanity checking */
if (hsplit < H0 && hsplit > (CELL *)Yap_GlobalBase) {
@ -1492,7 +1479,6 @@ execute_growstack(long size0, int from_trail, int in_parser, tr_fr_ptr *old_trp,
long size = size0;
ADDR old_Yap_GlobalBase = Yap_GlobalBase;
CurrentDelayTop = (CELL *)DelayTop();
if (!Yap_AllowGlobalExpansion) {
Yap_ErrorMessage = "Database crashed against stacks";
return FALSE;
@ -1869,7 +1855,6 @@ Yap_CopyThreadStacks(int worker_q, int worker_p, int incremental)
Yap_REGS.CUT_C_TOP = ThreadHandle[worker_p].current_yaam_regs->CUT_C_TOP;
#endif
DelayedVars = ThreadHandle[worker_p].current_yaam_regs->DelayedVars_;
CurrentDelayTop = (CELL *)DelayTop();
DynamicArrays = NULL;
StaticArrays = NULL;
GlobalVariables = NULL;

View File

@ -34,8 +34,8 @@ static char SccsId[] = "%W% %G%";
STATIC_PROTO(Int p_inform_gc, (void));
STATIC_PROTO(Int p_gc, (void));
STATIC_PROTO(void push_registers, (Int, yamop *));
STATIC_PROTO(void marking_phase, (tr_fr_ptr, CELL *, yamop *, CELL *));
STATIC_PROTO(void compaction_phase, (tr_fr_ptr, CELL *, yamop *, CELL *));
STATIC_PROTO(void marking_phase, (tr_fr_ptr, CELL *, yamop *));
STATIC_PROTO(void compaction_phase, (tr_fr_ptr, CELL *, yamop *));
STATIC_PROTO(void pop_registers, (Int, yamop *));
STATIC_PROTO(void init_dbtable, (tr_fr_ptr));
STATIC_PROTO(void mark_db_fixed, (CELL *));
@ -442,7 +442,6 @@ push_registers(Int num_regs, yamop *nextop)
ArrayEntry *al = DynamicArrays;
GlobalEntry *gl = GlobalVariables;
TrailTerm(TR++) = GlobalArena;
TrailTerm(TR++) = GlobalDelayArena;
while (al) {
check_pr_trail(TR);
TrailTerm(TR++) = al->ValueOfVE;
@ -474,8 +473,7 @@ push_registers(Int num_regs, yamop *nextop)
#ifdef COROUTINING
TrailTerm(TR) = WokenGoals;
TrailTerm(TR+1) = AttsMutableList;
TrailTerm(TR+2) = DelayedVars;
TR += 3;
TR += 2;
#endif
for (i = 1; i <= num_regs; i++) {
check_pr_trail(TR);
@ -521,7 +519,6 @@ pop_registers(Int num_regs, yamop *nextop)
GlobalEntry *gl = GlobalVariables;
GlobalArena = TrailTerm(ptr++);
GlobalDelayArena = TrailTerm(ptr++);
while (al) {
al->ValueOfVE = TrailTerm(ptr++);
al = al->NextAE;
@ -549,7 +546,6 @@ pop_registers(Int num_regs, yamop *nextop)
#ifdef MULTI_ASSIGNMENT_VARIABLES
WokenGoals = TrailTerm(ptr++);
AttsMutableList = TrailTerm(ptr++);
DelayedVars = TrailTerm(ptr++);
#endif
#endif
for (i = 1; i <= num_regs; i++)
@ -1580,6 +1576,18 @@ mark_environments(CELL_PTR gc_ENV, OPREG size, CELL *pvbmap)
}
}
static void
mark_att_var(CELL *hp)
{
attvar_record *attv = RepAttVar(hp);
Functor *cptr = &(attv->AttFunc);
mark_external_reference2(CellPtr(cptr));
mark_external_reference2(&attv->Done);
mark_external_reference2(&attv->Value);
mark_external_reference2(&attv->Atts);
}
/*
Cleaning the trail should be quick and simple, right? Well, not
really :-(. The problem is that the trail includes a dumping ground
@ -1596,20 +1604,6 @@ mark_environments(CELL_PTR gc_ENV, OPREG size, CELL *pvbmap)
*/
static void
mark_att_var(CELL *hp)
{
attvar_record *top = (attvar_record *)Yap_GlobalBase;
Int relpos = top-(attvar_record *)hp;
attvar_record *attv = top-relpos;
if (attv != (attvar_record *)hp)
attv--;
mark_external_reference2(&attv->Done);
mark_external_reference2(&attv->Value);
mark_external_reference2(&attv->Atts);
}
static void
mark_trail(tr_fr_ptr trail_ptr, tr_fr_ptr trail_base, CELL *gc_H, choiceptr gc_B)
{
@ -1652,7 +1646,7 @@ mark_trail(tr_fr_ptr trail_ptr, tr_fr_ptr trail_base, CELL *gc_H, choiceptr gc_B
#endif
discard_trail_entries++;
} else {
if ( hp > (CELL*)Yap_GlobalBase && hp < H0) {
if ( IsAttVar(hp)) {
if (!detatt || hp >= detatt) {
mark_att_var(hp);
} else {
@ -1712,9 +1706,7 @@ mark_trail(tr_fr_ptr trail_ptr, tr_fr_ptr trail_base, CELL *gc_H, choiceptr gc_B
*/
if (cptr < (CELL *)gc_B && cptr >= gc_H) {
goto remove_trash_entry;
} else if (!detatt && cptr == RepAppl(DelayedVars)+1) {
/* detatt = cptr; */
} else if (cptr > (CELL*)Yap_GlobalBase && cptr < H0) {
} else if (IsAttVar(cptr)) {
/* MABINDING that should be recovered */
if (detatt && cptr < detatt) {
goto remove_trash_entry;
@ -1847,24 +1839,6 @@ mark_slots(CELL *ptr)
}
#ifdef COROUTINING
static void
mark_delays(attvar_record *top, attvar_record *bottom)
{
attvar_record *attv = (attvar_record *)top;
for (; attv < bottom; attv++) {
/* only mark what is accessible */
if (IsVarTerm(attv->Done) && IsUnboundVar(&attv->Done)) {
mark_external_reference2(&attv->Done);
mark_external_reference2(&attv->Value);
mark_external_reference2(&attv->Atts);
}
}
}
#else
#define mark_delays(T,B)
#endif
#ifdef TABLING
static choiceptr
youngest_cp(choiceptr gc_B, dep_fr_ptr *depfrp)
@ -3595,7 +3569,7 @@ set_conditionals(tr_fr_ptr str) {
*/
static void
marking_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp, CELL *max)
marking_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp)
{
#ifdef EASY_SHUNTING
@ -3615,7 +3589,6 @@ marking_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp, CELL *max)
values */
mark_regs(old_TR); /* active registers & trail */
/* active environments */
mark_delays((attvar_record *)max, (attvar_record *)H0);
mark_environments(current_env, EnvSize(curp), EnvBMap(curp));
mark_choicepoints(B, old_TR, is_gc_very_verbose()); /* choicepoints, and environs */
#ifdef EASY_SHUNTING
@ -3640,22 +3613,6 @@ sweep_oldgen(CELL *max, CELL *base)
}
}
#ifdef COROUTINING
static void
sweep_delays(CELL *max, CELL *myH0)
{
while (max < myH0) {
if (MARKED_PTR(max)) {
UNMARK(max);
if (HEAP_PTR(*max)) {
into_relocation_chain(max, GET_NEXT(*max));
}
}
max++;
}
}
#endif
/*
* move marked heap objects upwards over unmarked objects, and reset all
@ -3663,9 +3620,9 @@ sweep_delays(CELL *max, CELL *myH0)
*/
static void
compaction_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp, CELL *max)
compaction_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp)
{
CELL *CurrentH0 = NULL, *myH0 = H0;
CELL *CurrentH0 = NULL;
int icompact = (iptop < (CELL_PTR *)ASP && 10*total_marked < H-H0);
@ -3682,9 +3639,6 @@ compaction_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp, CELL *max)
sweep_oldgen(HGEN, CurrentH0);
}
}
#ifdef COROUTINING
sweep_delays(max, myH0);
#endif
sweep_environments(current_env, EnvSize(curp), EnvBMap(curp));
sweep_choicepoints(B);
sweep_trail(B, old_TR);
@ -3738,7 +3692,6 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
int gc_verbose;
volatile tr_fr_ptr old_TR = NULL;
UInt m_time, c_time, time_start, gc_time;
CELL *max;
Int effectiveness, tot;
int gc_trace;
UInt gc_phase;
@ -3795,24 +3748,9 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
}
current_env = (CELL *)*ASP;
ASP++;
#if COROUTINING
max = (CELL *)DelayTop();
#endif
}
#endif
time_start = Yap_cputime();
#if COROUTINING
max = (CELL *)DelayTop();
while (max - (CELL*)Yap_GlobalBase < 1024+(2*NUM_OF_ATTS)) {
if (!Yap_growglobal(&current_env)) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
return -1;
}
max = (CELL *)DelayTop();
}
#else
max = NULL;
#endif
if (setjmp(Yap_gc_restore) == 2) {
UInt sz;
@ -3838,9 +3776,6 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
discard_trail_entries = 0;
current_env = (CELL *)*ASP;
ASP++;
#if COROUTINING
max = (CELL *)DelayTop();
#endif
}
}
#if EASY_SHUNTING
@ -3862,9 +3797,6 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
return -1;
current_env = (CELL *)*ASP;
ASP++;
#if COROUTINING
max = (CELL *)DelayTop();
#endif
}
memset((void *)Yap_bp, 0, alloc_sz);
#ifdef HYBRID_SCHEME
@ -3882,7 +3814,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
OldTR = (tr_fr_ptr)(old_TR = TR);
push_registers(predarity, nextop);
/* make sure we clean bits after a reset */
marking_phase(old_TR, current_env, nextop, max);
marking_phase(old_TR, current_env, nextop);
if (total_oldies > ((HGEN-H0)*8)/10) {
total_marked -= total_oldies;
tot = total_marked+(HGEN-H0);
@ -3922,7 +3854,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
#endif
}
time_start = m_time;
compaction_phase(old_TR, current_env, nextop, max);
compaction_phase(old_TR, current_env, nextop);
TR = old_TR;
pop_registers(predarity, nextop);
TR = new_TR;

View File

@ -1167,7 +1167,6 @@ InitCodes(void)
Yap_heap_regs->wl[i].global_variables = NULL;
Yap_heap_regs->wl[i].global_arena = 0L;
Yap_heap_regs->wl[i].global_arena_overflows = 0;
Yap_heap_regs->wl[i].global_delay_arena = 0L;
Yap_heap_regs->wl[i].allow_restart = FALSE;
Yap_heap_regs->wl[i].tot_gc_time = 0;
Yap_heap_regs->wl[i].tot_gc_recovered = 0;
@ -1193,7 +1192,6 @@ InitCodes(void)
Yap_heap_regs->wl.global_arena = 0L;
Yap_heap_regs->wl.global_arena_overflows = 0;
Yap_heap_regs->wl.allow_restart = FALSE;
Yap_heap_regs->wl.global_delay_arena = 0L;
Yap_heap_regs->wl.tot_gc_time = 0;
Yap_heap_regs->wl.tot_gc_recovered = 0;
Yap_heap_regs->wl.gc_calls = 0;

View File

@ -628,7 +628,7 @@ p_functor(void) /* functor(?,?,?) */
BIND(pt0, d0, bind_func_nvar_var);
#ifdef COROUTINING
DO_TRAIL(pt0, d0);
if (pt0 < H0) Yap_WakeUp(pt0);
if (IsAttVar(pt0)) Yap_WakeUp(pt0);
bind_func_nvar_var:
#endif
/* have to buffer ENDP and label */
@ -655,7 +655,7 @@ p_functor(void) /* functor(?,?,?) */
/* Done */
#ifdef COROUTINING
DO_TRAIL(pt0, d0);
if (pt0 < H0) Yap_WakeUp(pt0);
if (IsAttVar(pt0)) Yap_WakeUp(pt0);
bind_func_nvar3_var:
#endif
return(TRUE);
@ -738,7 +738,7 @@ p_functor(void) /* functor(?,?,?) */
BIND(pt0, d0, bind_func_var_3nvar);
#ifdef COROUTINING
DO_TRAIL(pt0, d0);
if (pt0 < H0) Yap_WakeUp(pt0);
if (IsAttVar(pt0)) Yap_WakeUp(pt0);
bind_func_var_3nvar:
#endif
return(TRUE);

View File

@ -409,9 +409,6 @@ save_regs(int mode)
putcellptr((CELL *)P);
putout(CreepFlag);
putout(EX);
#ifdef COROUTINING
putout(DelayedVars);
#endif
#if defined(SBA) || defined(TABLING)
putcellptr(H_FZ);
putcellptr((CELL *)B_FZ);
@ -807,11 +804,6 @@ get_regs(int flag)
EX = get_cell();
if (Yap_ErrorMessage)
return -1;
#ifdef COROUTINING
DelayedVars = get_cell();
if (Yap_ErrorMessage)
return -1;
#endif
#if defined(SBA) || defined(TABLING)
H_FZ = get_cellptr();
if (Yap_ErrorMessage)
@ -1035,12 +1027,7 @@ restore_regs(int flag)
S = PtoGloAdjust(S);
if (EX)
EX = AbsAppl(PtoGloAdjust(RepAppl(EX)));
#ifdef COROUTINING
DelayedVars = AbsAppl(PtoGloAdjust(RepAppl(DelayedVars)));
#ifdef MULTI_ASSIGNMENT_VARIABLES
WokenGoals = AbsAppl(PtoGloAdjust(RepAppl(WokenGoals)));
#endif
#endif
}
}

View File

@ -259,7 +259,7 @@ loop:
BIND_GLOBAL(ptd1, d0, bind_ocunify1);
#ifdef COROUTINING
DO_TRAIL(ptd1, d0);
if (ptd1 < H0) Yap_WakeUp(ptd1);
if (IsAttVar(ptd1)) Yap_WakeUp(ptd1);
bind_ocunify1:
#endif
if (Yap_rational_tree_loop(ptd1-1, ptd1, (CELL **)to_visit, (CELL **)unif))
@ -282,7 +282,7 @@ loop:
BIND_GLOBAL(ptd0, d1, bind_ocunify2);
#ifdef COROUTINING
DO_TRAIL(ptd0, d1);
if (ptd0 < H0) Yap_WakeUp(ptd0);
if (IsAttVar(ptd0)) Yap_WakeUp(ptd0);
bind_ocunify2:
#endif
if (Yap_rational_tree_loop(ptd0-1, ptd0, (CELL **)to_visit, (CELL **)unif))
@ -403,7 +403,7 @@ oc_unify_nvar_nvar:
BIND(pt1, d0, bind_ocunify4);
#ifdef COROUTINING
DO_TRAIL(pt1, d0);
if (pt1 < H0) Yap_WakeUp(pt1);
if (IsAttVar(pt1)) Yap_WakeUp(pt1);
bind_ocunify4:
#endif
/* local variables cannot be in a term */
@ -421,7 +421,7 @@ oc_unify_var_nvar:
BIND(pt0, d1, bind_ocunify5);
#ifdef COROUTINING
DO_TRAIL(pt0, d1);
if (pt0 < H0) Yap_WakeUp(pt0);
if (IsAttVar(pt0)) Yap_WakeUp(pt0);
bind_ocunify5:
#endif
/* local variables cannot be in a term */
@ -436,14 +436,14 @@ oc_unify_var_nvar:
UnifyCells(pt0, pt1, uc1, uc2);
#ifdef COROUTINING
DO_TRAIL(pt0, (CELL)pt1);
if (pt0 < H0) Yap_WakeUp(pt0);
if (IsAttVar(pt0)) Yap_WakeUp(pt0);
uc1:
#endif
return (TRUE);
#ifdef COROUTINING
uc2:
DO_TRAIL(pt1, (CELL)pt0);
if (pt1 < H0) {
if (IsAttVar(pt1)) {
Yap_WakeUp(pt1);
}
#endif
@ -550,7 +550,7 @@ unify_nvar_nvar:
BIND(pt1, d0, bind_unify3);
#ifdef COROUTINING
DO_TRAIL(pt1, d0);
if (pt1 < H0) Yap_WakeUp(pt1);
if (IsAttVar(pt1)) Yap_WakeUp(pt1);
bind_unify3:
#endif
return (TRUE);
@ -563,7 +563,7 @@ unify_var_nvar:
BIND(pt0, d1, bind_unify4);
#ifdef COROUTINING
DO_TRAIL(pt0, d1);
if (pt0 < H0) Yap_WakeUp(pt0);
if (IsAttVar(pt0)) Yap_WakeUp(pt0);
bind_unify4:
#endif
return TRUE;
@ -579,14 +579,14 @@ unify_var_nvar_trail:
UnifyCells(pt0, pt1, uc1, uc2);
#ifdef COROUTINING
DO_TRAIL(pt0, (CELL)pt1);
if (pt0 < H0) Yap_WakeUp(pt0);
if (IsAttVar(pt0)) Yap_WakeUp(pt0);
uc1:
#endif
return (TRUE);
#ifdef COROUTINING
uc2:
DO_TRAIL(pt1, (CELL)pt0);
if (pt1 < H0) {
if (IsAttVar(pt1)) {
Yap_WakeUp(pt1);
}
return (TRUE);

View File

@ -254,7 +254,7 @@ copy_complex_term(CELL *pt0, CELL *pt0_end, int share, int newattvs, CELL *ptf,
struct cp_frame *bp[1];
if (dvars == NULL) {
dvars = (CELL *)DelayTop();
dvars = H0;
}
if (ptd0 < dvars) {
*ptf++ = (CELL) ptd0;

View File

@ -406,8 +406,8 @@ write_var(CELL *t, struct write_globs *wglb, struct rewind_term *rwt)
wrputc('_', wglb->writewch);
/* make sure we don't get no creepy spaces where they shouldn't be */
lastw = separator;
if (CellPtr(t) < H0) {
Int vcount = (H0-t);
if (IsAttVar(t)) {
Int vcount = (t-H0);
#if COROUTINING
#if DEBUG
if (Yap_Portray_delays) {
@ -415,7 +415,7 @@ write_var(CELL *t, struct write_globs *wglb, struct rewind_term *rwt)
Yap_Portray_delays = FALSE;
if (ext == attvars_ext) {
attvar_record *attv = (attvar_record *)t;
attvar_record *attv = RepAttVar(t);
long sl = 0;
Term l = attv->Atts;
@ -613,6 +613,9 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb, str
case (CELL)FunctorDouble:
wrputf(FloatOfTerm(t),wglb->writewch);
return;
case (CELL)FunctorAttVar:
write_var(RepAppl(t)+1, wglb, &nrwt);
return;
case (CELL)FunctorDBRef:
wrputref(RefOfTerm(t), wglb->Quote_illegal, wglb->writewch);
return;