diff -ruN klic-3.003-2002-03-08/runtime/faisus.c klic-3.003-2002-03-08a/runtime/faisus.c --- klic-3.003-2002-03-08/runtime/faisus.c Mon Mar 4 12:32:50 2002 +++ klic-3.003-2002-03-08a/runtime/faisus.c Fri Mar 8 16:48:58 2002 @@ -49,12 +49,12 @@ } -static Inline q* record_susp(allocp, goal) - q* allocp; +static Inline void record_susp(goal) struct goalrec* goal; { declare_globals; struct suspended_goal_rec* sm; + heapalloc(sm, sizeof(struct suspended_goal_rec)/sizeof(q), (struct suspended_goal_rec*)); sm->goal = goal; @@ -63,17 +63,13 @@ if (count_suspension) { record_suspended_pred(goal); } - - return allocp; } -extern q* -suspend_goal(allocp, goal, reason, spontaneous) - q* allocp; +extern void +suspend_goal(goal, reason) struct goalrec* goal; q reason; - int spontaneous; { declare_globals; int suspended = 0; @@ -101,7 +97,7 @@ */ if ( !isref(susp) || reason != derefone(susp) ) { resume_same_prio(goal); - return allocp; + return; } #endif /* SHM */ @@ -115,7 +111,7 @@ struct generator_susp* gsusp = generator_suspp(susp); q ref = gsusp->backpt; struct generator_object* gobj = untag_generator_susp(gsusp->u.o); - q tmp = generic_generate(gobj, allocp); + q tmp = generic_generate(gobj, heapp()); if (tmp != (q)0) { if ( tmp == makecons(0) ) { q retval = generic_suspend(gobj, ref, goal); @@ -125,7 +121,6 @@ suspended = 1; } } else { - allocp = heapp(); derefone(ref) = tmp; resume_same_prio(goal); } @@ -136,7 +131,7 @@ * 2. enqueue unification goal between ``newvar'' and ``ref'' */ struct susprec* susp; q newvar; - struct goalrec* newgp = (struct goalrec*) allocp; + struct goalrec* newgp = (struct goalrec*) klic_alloc(4); suspended = 1; @@ -146,18 +141,15 @@ newgp->pred = &predicate_unify__term__dcode_xunify__goal_2; newgp->args[0] = reason; newgp->args[1] = newvar; - allocp += 4; resume_same_prio(newgp); } } } if (suspended) { - allocp = record_susp(allocp, goal); + record_susp(goal); suspensions0 ++; } - - return allocp; } @@ -167,9 +159,7 @@ q* reasonp; { declare_globals; - q* allocp = klic_alloc(pred->arity + 2); - struct goalrec* goal = (struct goalrec*) allocp; - allocp = heapp(); + struct goalrec* goal = (struct goalrec*) klic_alloc(pred->arity + 2); goal->pred = pred; if (reasonp == NULL) { @@ -178,7 +168,6 @@ /* - Garbage collection required */ /* In such cases, the interrupted goal is pushed down to the queue. */ add_resumed_goal(goal); - set_heapp(allocp); return; } else if (reasonp == reasons) { do_fail(goal, reasons[0]); @@ -194,7 +183,6 @@ if (!isref(tmp)) { derefone(iv) = tmp; resume_same_prio(goal); - set_heapp(allocp); return; } ov = v; @@ -205,7 +193,6 @@ if (reasonp > reasons) { if (stepping_flag) { - set_heapp(allocp); step_susp(goal, reasonp, 0); return; } else if (trace_flag) { @@ -224,7 +211,6 @@ tmp1 = derefone(tmp); if ( !isref(tmp1) ) { resume_same_prio(goal); - set_heapp(allocp); return; } if (derefone(tmp1) == tmp) break; @@ -234,7 +220,7 @@ /* no goals suspended yet on this variable */ struct susprec* susp; q newvar; - makenewsusp(newvar, susp, allocp); + makenewsusp(newvar, susp, heapp()); susp->u.first_hook.u.g = goal; derefone(tmp) = newvar; } else { @@ -248,7 +234,7 @@ because of the loop structure of the hook chain. */ } else { struct hook* newhook; - addhook(&susp->u.first_hook, newhook, allocp); + addhook(&susp->u.first_hook, newhook, heapp()); newhook->u.g = goal; } } else { @@ -256,7 +242,7 @@ struct generator_susp* gsusp = generator_suspp(susp); q ref = gsusp->backpt; struct generator_object* gobj = untag_generator_susp(gsusp->u.o); - q tmp = generic_generate(gobj, allocp); + q tmp = generic_generate(gobj, heapp()); if(tmp == makecons(0)) { q retval = generic_suspend(gobj, ref, goal); @@ -266,7 +252,6 @@ } else { redo_request = 1; if(tmp != makeref(0)) { - allocp = heapp(); derefone(ref) = tmp; } /* else GC request */ } @@ -276,11 +261,10 @@ if (redo_request) { resume_same_prio(goal); } else { - allocp = record_susp(allocp, goal); + record_susp(goal); suspensions0 ++; } } - set_heapp(allocp); return; } } diff -ruN klic-3.003-2002-03-08/runtime/generic.c klic-3.003-2002-03-08a/runtime/generic.c --- klic-3.003-2002-03-08/runtime/generic.c Tue Mar 5 21:36:01 2002 +++ klic-3.003-2002-03-08a/runtime/generic.c Fri Mar 8 16:37:26 2002 @@ -18,7 +18,7 @@ #define G_NEW_GOAL &predicate_generic_xnew_3 #define GD_GENERIC_GOAL &predicate_generic_xgeneric_2 -extern q* suspend_goal(); +extern void suspend_goal(); extern q gd_new_pointer(); extern q gd_new_termarray(); @@ -32,8 +32,7 @@ struct goalrec* goal; { G_STD_DECL; - q* g_allocp = heapp(); - set_heapp (suspend_goal (g_allocp, goal, x, 1)); + suspend_goal(goal, x); } extern q*