- slots should be considered as always live for gc.
- make sure slots do not die when they should be live, and vice-versa. - improve a little on foreign_frame
This commit is contained in:
parent
7e1692bdb0
commit
247d59f0ef
|
@ -7530,10 +7530,7 @@ Yap_absmi(int inp)
|
||||||
Yap_PrologMode = UserCCallMode;
|
Yap_PrologMode = UserCCallMode;
|
||||||
{
|
{
|
||||||
PredEntry *p = PREG->u.Osbpp.p;
|
PredEntry *p = PREG->u.Osbpp.p;
|
||||||
#ifdef LOW_LEVEL_TRACER
|
|
||||||
if (Yap_do_low_level_trace)
|
|
||||||
low_level_trace(enter_pred,p,XREGS+1);
|
|
||||||
#endif /* LOW_LEVEL_TRACE */
|
|
||||||
PREG = NEXTOP(PREG, Osbpp);
|
PREG = NEXTOP(PREG, Osbpp);
|
||||||
saveregs();
|
saveregs();
|
||||||
save_machine_regs();
|
save_machine_regs();
|
||||||
|
@ -7541,6 +7538,7 @@ Yap_absmi(int inp)
|
||||||
SREG = (CELL *) YAP_Execute(p, p->cs.f_code);
|
SREG = (CELL *) YAP_Execute(p, p->cs.f_code);
|
||||||
EX = 0L;
|
EX = 0L;
|
||||||
}
|
}
|
||||||
|
Yap_CloseSlots();
|
||||||
|
|
||||||
restore_machine_regs();
|
restore_machine_regs();
|
||||||
setregs();
|
setregs();
|
||||||
|
@ -7714,6 +7712,7 @@ Yap_absmi(int inp)
|
||||||
restore_machine_regs();
|
restore_machine_regs();
|
||||||
setregs();
|
setregs();
|
||||||
Yap_PrologMode = UserMode;
|
Yap_PrologMode = UserMode;
|
||||||
|
Yap_CloseSlots();
|
||||||
if (!SREG) {
|
if (!SREG) {
|
||||||
FAIL();
|
FAIL();
|
||||||
}
|
}
|
||||||
|
@ -7756,6 +7755,7 @@ Yap_absmi(int inp)
|
||||||
restore_machine_regs();
|
restore_machine_regs();
|
||||||
setregs();
|
setregs();
|
||||||
Yap_PrologMode = UserMode;
|
Yap_PrologMode = UserMode;
|
||||||
|
Yap_CloseSlots();
|
||||||
if (!SREG) {
|
if (!SREG) {
|
||||||
#ifdef CUT_C
|
#ifdef CUT_C
|
||||||
/* Removes the cut functions from the stack
|
/* Removes the cut functions from the stack
|
||||||
|
|
|
@ -1382,6 +1382,7 @@ Yap_NewSlots(int n)
|
||||||
n--;
|
n--;
|
||||||
}
|
}
|
||||||
ASP[0] = MkIntTerm(old_slots+oldn);
|
ASP[0] = MkIntTerm(old_slots+oldn);
|
||||||
|
CurSlot = LCL0-ASP;
|
||||||
return((ASP+1)-LCL0);
|
return((ASP+1)-LCL0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1391,6 +1392,7 @@ Yap_InitSlot(Term t)
|
||||||
Int old_slots = IntOfTerm(ASP[0]);
|
Int old_slots = IntOfTerm(ASP[0]);
|
||||||
*ASP = t;
|
*ASP = t;
|
||||||
ASP--;
|
ASP--;
|
||||||
|
CurSlot ++;
|
||||||
ASP[0] = MkIntTerm(old_slots+1);
|
ASP[0] = MkIntTerm(old_slots+1);
|
||||||
return((ASP+1)-LCL0);
|
return((ASP+1)-LCL0);
|
||||||
}
|
}
|
||||||
|
@ -1403,6 +1405,7 @@ Yap_RecoverSlots(int n)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
ASP += n;
|
ASP += n;
|
||||||
|
CurSlot -= n;
|
||||||
ASP[0] = MkIntTerm(old_slots-n);
|
ASP[0] = MkIntTerm(old_slots-n);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1955,6 +1955,7 @@ YAP_RestartGoal(void)
|
||||||
Yap_PrologMode = UserCCallMode;
|
Yap_PrologMode = UserCCallMode;
|
||||||
if (out == FALSE) {
|
if (out == FALSE) {
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
|
Yap_CloseSlots();
|
||||||
Yap_trust_last();
|
Yap_trust_last();
|
||||||
Yap_AllowRestart = FALSE;
|
Yap_AllowRestart = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2719,6 +2720,7 @@ YAP_Predicate(Atom a, UInt arity, Term m)
|
||||||
} else {
|
} else {
|
||||||
Functor f = Yap_MkFunctor(a, arity);
|
Functor f = Yap_MkFunctor(a, arity);
|
||||||
return((void *)RepPredProp(PredPropByFunc(f,m)));
|
return((void *)RepPredProp(PredPropByFunc(f,m)));
|
||||||
|
fprintf(stderr,"here\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3299,7 +3299,10 @@ search_for_static_predicate_in_use(PredEntry *p, int check_everything)
|
||||||
only for retracts
|
only for retracts
|
||||||
*/
|
*/
|
||||||
while (env_ptr && b_ptr > (choiceptr)env_ptr) {
|
while (env_ptr && b_ptr > (choiceptr)env_ptr) {
|
||||||
PredEntry *pe = EnvPreg((yamop *)env_ptr[E_CP]);
|
yamop *cp = (yamop *)env_ptr[E_CP];
|
||||||
|
PredEntry *pe;
|
||||||
|
|
||||||
|
pe = EnvPreg(cp);
|
||||||
if (p == pe) return(TRUE);
|
if (p == pe) return(TRUE);
|
||||||
if (env_ptr != NULL)
|
if (env_ptr != NULL)
|
||||||
env_ptr = (CELL *)(env_ptr[E_E]);
|
env_ptr = (CELL *)(env_ptr[E_E]);
|
||||||
|
|
8
C/exec.c
8
C/exec.c
|
@ -994,6 +994,7 @@ exec_absmi(int top)
|
||||||
} else {
|
} else {
|
||||||
Yap_PrologMode = UserMode;
|
Yap_PrologMode = UserMode;
|
||||||
}
|
}
|
||||||
|
Yap_CloseSlots();
|
||||||
out = Yap_absmi(0);
|
out = Yap_absmi(0);
|
||||||
Yap_StartSlots();
|
Yap_StartSlots();
|
||||||
return out;
|
return out;
|
||||||
|
@ -1049,6 +1050,7 @@ init_stack(int arity, CELL *pt, int top, choiceptr saved_b)
|
||||||
#endif
|
#endif
|
||||||
YENV[E_CB] = Unsigned (B);
|
YENV[E_CB] = Unsigned (B);
|
||||||
CP = YESCODE;
|
CP = YESCODE;
|
||||||
|
Yap_StartSlots();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
|
@ -1200,7 +1202,6 @@ void
|
||||||
Yap_trust_last(void)
|
Yap_trust_last(void)
|
||||||
{
|
{
|
||||||
ASP = B->cp_env;
|
ASP = B->cp_env;
|
||||||
P = (yamop *)(B->cp_env[E_CP]);
|
|
||||||
CP = B->cp_cp;
|
CP = B->cp_cp;
|
||||||
H = B->cp_h;
|
H = B->cp_h;
|
||||||
#ifdef DEPTH_LIMIT
|
#ifdef DEPTH_LIMIT
|
||||||
|
@ -1209,6 +1210,7 @@ Yap_trust_last(void)
|
||||||
YENV= ASP = B->cp_env;
|
YENV= ASP = B->cp_env;
|
||||||
ENV = (CELL *)((B->cp_env)[E_E]);
|
ENV = (CELL *)((B->cp_env)[E_E]);
|
||||||
B = B->cp_b;
|
B = B->cp_b;
|
||||||
|
P = (yamop *)(ENV[E_CP]);
|
||||||
if (B) {
|
if (B) {
|
||||||
SET_BB(B);
|
SET_BB(B);
|
||||||
HB = PROTECT_FROZEN_H(B);
|
HB = PROTECT_FROZEN_H(B);
|
||||||
|
@ -1621,11 +1623,9 @@ Yap_InitYaamRegs(void)
|
||||||
CreepFlag = CalculateStackGap();
|
CreepFlag = CalculateStackGap();
|
||||||
UNLOCK(SignalLock);
|
UNLOCK(SignalLock);
|
||||||
EX = 0L;
|
EX = 0L;
|
||||||
/* for slots to work */
|
|
||||||
Yap_StartSlots();
|
|
||||||
init_stack(0, NULL, TRUE, NULL);
|
init_stack(0, NULL, TRUE, NULL);
|
||||||
/* the first real choice-point will also have AP=FAIL */
|
/* the first real choice-point will also have AP=FAIL */
|
||||||
Yap_StartSlots();
|
CurSlot = 0;
|
||||||
GlobalArena = TermNil;
|
GlobalArena = TermNil;
|
||||||
h0var = MkVarTerm();
|
h0var = MkVarTerm();
|
||||||
#if COROUTINING
|
#if COROUTINING
|
||||||
|
|
57
C/heapgc.c
57
C/heapgc.c
|
@ -1837,14 +1837,22 @@ mark_trail(tr_fr_ptr trail_ptr, tr_fr_ptr trail_base, CELL *gc_H, choiceptr gc_B
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mark_slots(CELL *ptr)
|
mark_slots(void)
|
||||||
{
|
{
|
||||||
Int ns = IntOfTerm(*ptr);
|
Int curslot = CurSlot;
|
||||||
ptr++;
|
while (curslot) {
|
||||||
while (ns > 0) {
|
CELL *ptr = LCL0-curslot;
|
||||||
mark_external_reference(ptr);
|
Int ns = IntegerOfTerm(*ptr);
|
||||||
|
|
||||||
ptr++;
|
ptr++;
|
||||||
ns--;
|
while (ns > 0) {
|
||||||
|
// Yap_DebugPlWrite(ptr);
|
||||||
|
//fprintf(stderr,"\n");
|
||||||
|
mark_external_reference(ptr);
|
||||||
|
ptr++;
|
||||||
|
ns--;
|
||||||
|
}
|
||||||
|
curslot = IntegerOfTerm(*ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1978,7 +1986,6 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose)
|
||||||
restart_cp:
|
restart_cp:
|
||||||
switch (opnum) {
|
switch (opnum) {
|
||||||
case _Nstop:
|
case _Nstop:
|
||||||
mark_slots(gc_B->cp_env);
|
|
||||||
if (gc_B->cp_b != NULL) {
|
if (gc_B->cp_b != NULL) {
|
||||||
nargs = 0;
|
nargs = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -2777,20 +2784,25 @@ sweep_environments(CELL_PTR gc_ENV, OPREG size, CELL *pvbmap)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sweep_slots(CELL *ptr)
|
sweep_slots(void)
|
||||||
{
|
{
|
||||||
Int ns = IntOfTerm(*ptr);
|
Int curslot = CurSlot;
|
||||||
ptr++;
|
while (curslot) {
|
||||||
while (ns > 0) {
|
CELL *ptr = LCL0-curslot;
|
||||||
CELL cp_cell = *ptr;
|
Int ns = IntOfTerm(*ptr);
|
||||||
if (MARKED_PTR(ptr)) {
|
|
||||||
UNMARK(ptr);
|
|
||||||
if (HEAP_PTR(cp_cell)) {
|
|
||||||
into_relocation_chain(ptr, GET_NEXT(cp_cell));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ptr++;
|
ptr++;
|
||||||
ns--;
|
while (ns > 0) {
|
||||||
|
CELL cp_cell = *ptr;
|
||||||
|
if (MARKED_PTR(ptr)) {
|
||||||
|
UNMARK(ptr);
|
||||||
|
if (HEAP_PTR(cp_cell)) {
|
||||||
|
into_relocation_chain(ptr, GET_NEXT(cp_cell));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ptr++;
|
||||||
|
ns--;
|
||||||
|
}
|
||||||
|
curslot = IntegerOfTerm(*ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2870,7 +2882,6 @@ sweep_choicepoints(choiceptr gc_B)
|
||||||
sweep_environments(gc_B->cp_env,
|
sweep_environments(gc_B->cp_env,
|
||||||
EnvSizeInCells,
|
EnvSizeInCells,
|
||||||
NULL);
|
NULL);
|
||||||
sweep_slots(gc_B->cp_env);
|
|
||||||
if (gc_B->cp_b != NULL) {
|
if (gc_B->cp_b != NULL) {
|
||||||
break;
|
break;
|
||||||
} else
|
} else
|
||||||
|
@ -3606,8 +3617,7 @@ marking_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp)
|
||||||
cont_top = (cont *)db_vec;
|
cont_top = (cont *)db_vec;
|
||||||
/* These two must be marked first so that our trail optimisation won't lose
|
/* These two must be marked first so that our trail optimisation won't lose
|
||||||
values */
|
values */
|
||||||
if (Yap_PrologMode & UserCCallMode)
|
mark_slots();
|
||||||
mark_slots(ASP);
|
|
||||||
mark_regs(old_TR); /* active registers & trail */
|
mark_regs(old_TR); /* active registers & trail */
|
||||||
/* active environments */
|
/* active environments */
|
||||||
mark_environments(current_env, EnvSize(curp), EnvBMap(curp));
|
mark_environments(current_env, EnvSize(curp), EnvBMap(curp));
|
||||||
|
@ -3660,8 +3670,7 @@ compaction_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp)
|
||||||
sweep_oldgen(HGEN, CurrentH0);
|
sweep_oldgen(HGEN, CurrentH0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Yap_PrologMode & UserCCallMode)
|
sweep_slots();
|
||||||
sweep_slots(ASP);
|
|
||||||
sweep_environments(current_env, EnvSize(curp), EnvBMap(curp));
|
sweep_environments(current_env, EnvSize(curp), EnvBMap(curp));
|
||||||
sweep_choicepoints(B);
|
sweep_choicepoints(B);
|
||||||
sweep_trail(B, old_TR);
|
sweep_trail(B, old_TR);
|
||||||
|
|
17
C/iopreds.c
17
C/iopreds.c
|
@ -3660,6 +3660,7 @@ int beam_write (void)
|
||||||
{
|
{
|
||||||
Yap_StartSlots();
|
Yap_StartSlots();
|
||||||
Yap_plwrite (ARG1, Stream[Yap_c_output_stream].stream_wputc, 0, 1200);
|
Yap_plwrite (ARG1, Stream[Yap_c_output_stream].stream_wputc, 0, 1200);
|
||||||
|
Yap_CloseSlots();
|
||||||
if (EX != 0L) {
|
if (EX != 0L) {
|
||||||
Term ball = EX;
|
Term ball = EX;
|
||||||
EX = 0L;
|
EX = 0L;
|
||||||
|
@ -3679,6 +3680,7 @@ p_write (void)
|
||||||
we cannot make recursive Prolog calls */
|
we cannot make recursive Prolog calls */
|
||||||
Yap_StartSlots();
|
Yap_StartSlots();
|
||||||
Yap_plwrite (ARG2, Stream[Yap_c_output_stream].stream_wputc, flags, 1200);
|
Yap_plwrite (ARG2, Stream[Yap_c_output_stream].stream_wputc, flags, 1200);
|
||||||
|
Yap_CloseSlots();
|
||||||
if (EX != 0L) {
|
if (EX != 0L) {
|
||||||
Term ball = EX;
|
Term ball = EX;
|
||||||
EX = 0L;
|
EX = 0L;
|
||||||
|
@ -3697,6 +3699,7 @@ p_write_prio (void)
|
||||||
we cannot make recursive Prolog calls */
|
we cannot make recursive Prolog calls */
|
||||||
Yap_StartSlots();
|
Yap_StartSlots();
|
||||||
Yap_plwrite (ARG3, Stream[Yap_c_output_stream].stream_wputc, flags, (int)IntOfTerm(Deref(ARG2)));
|
Yap_plwrite (ARG3, Stream[Yap_c_output_stream].stream_wputc, flags, (int)IntOfTerm(Deref(ARG2)));
|
||||||
|
Yap_CloseSlots();
|
||||||
if (EX != 0L) {
|
if (EX != 0L) {
|
||||||
Term ball = EX;
|
Term ball = EX;
|
||||||
EX = 0L;
|
EX = 0L;
|
||||||
|
@ -3720,6 +3723,7 @@ p_write2_prio (void)
|
||||||
we cannot make recursive Prolog calls */
|
we cannot make recursive Prolog calls */
|
||||||
Yap_StartSlots();
|
Yap_StartSlots();
|
||||||
Yap_plwrite (ARG4, Stream[Yap_c_output_stream].stream_wputc, (int) IntOfTerm (Deref (ARG2)), (int) IntOfTerm (Deref (ARG3)));
|
Yap_plwrite (ARG4, Stream[Yap_c_output_stream].stream_wputc, (int) IntOfTerm (Deref (ARG2)), (int) IntOfTerm (Deref (ARG3)));
|
||||||
|
Yap_CloseSlots();
|
||||||
Yap_c_output_stream = old_output_stream;
|
Yap_c_output_stream = old_output_stream;
|
||||||
if (EX != 0L) {
|
if (EX != 0L) {
|
||||||
Term ball = EX;
|
Term ball = EX;
|
||||||
|
@ -3744,6 +3748,7 @@ p_write2 (void)
|
||||||
we cannot make recursive Prolog calls */
|
we cannot make recursive Prolog calls */
|
||||||
Yap_StartSlots();
|
Yap_StartSlots();
|
||||||
Yap_plwrite (ARG3, Stream[Yap_c_output_stream].stream_wputc, (int) IntOfTerm (Deref (ARG2)), 1200);
|
Yap_plwrite (ARG3, Stream[Yap_c_output_stream].stream_wputc, (int) IntOfTerm (Deref (ARG2)), 1200);
|
||||||
|
Yap_CloseSlots();
|
||||||
Yap_c_output_stream = old_output_stream;
|
Yap_c_output_stream = old_output_stream;
|
||||||
if (EX != 0L) {
|
if (EX != 0L) {
|
||||||
Term ball = EX;
|
Term ball = EX;
|
||||||
|
@ -5089,6 +5094,7 @@ format(volatile Term otail, volatile Term oargs, int sno)
|
||||||
goto do_type_atom_error;
|
goto do_type_atom_error;
|
||||||
Yap_StartSlots();
|
Yap_StartSlots();
|
||||||
Yap_plwrite (t, f_putc, Handle_vars_f|To_heap_f, 1200);
|
Yap_plwrite (t, f_putc, Handle_vars_f|To_heap_f, 1200);
|
||||||
|
Yap_CloseSlots();
|
||||||
FormatInfo = &finfo;
|
FormatInfo = &finfo;
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
|
@ -5338,8 +5344,8 @@ format(volatile Term otail, volatile Term oargs, int sno)
|
||||||
t = targs[targ++];
|
t = targs[targ++];
|
||||||
Yap_StartSlots();
|
Yap_StartSlots();
|
||||||
Yap_plwrite (t, f_putc, Quote_illegal_f|Ignore_ops_f|To_heap_f , 1200);
|
Yap_plwrite (t, f_putc, Quote_illegal_f|Ignore_ops_f|To_heap_f , 1200);
|
||||||
|
Yap_CloseSlots();
|
||||||
FormatInfo = &finfo;
|
FormatInfo = &finfo;
|
||||||
ASP++;
|
|
||||||
break;
|
break;
|
||||||
case '@':
|
case '@':
|
||||||
t = targs[targ++];
|
t = targs[targ++];
|
||||||
|
@ -5368,6 +5374,7 @@ format(volatile Term otail, volatile Term oargs, int sno)
|
||||||
goto do_default_error;
|
goto do_default_error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Yap_CloseSlots();
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
if (targ > tnum-1 || has_repeats)
|
if (targ > tnum-1 || has_repeats)
|
||||||
|
@ -5381,6 +5388,7 @@ format(volatile Term otail, volatile Term oargs, int sno)
|
||||||
args = Yap_GetFromSlot(sl);
|
args = Yap_GetFromSlot(sl);
|
||||||
Yap_RecoverSlots(1);
|
Yap_RecoverSlots(1);
|
||||||
}
|
}
|
||||||
|
Yap_CloseSlots();
|
||||||
if (EX != 0L) {
|
if (EX != 0L) {
|
||||||
Term ball;
|
Term ball;
|
||||||
|
|
||||||
|
@ -5399,7 +5407,6 @@ format(volatile Term otail, volatile Term oargs, int sno)
|
||||||
Yap_JumpToEnv(ball);
|
Yap_JumpToEnv(ball);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
ASP++;
|
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
if (targ > tnum-1 || has_repeats)
|
if (targ > tnum-1 || has_repeats)
|
||||||
|
@ -5407,8 +5414,8 @@ format(volatile Term otail, volatile Term oargs, int sno)
|
||||||
t = targs[targ++];
|
t = targs[targ++];
|
||||||
Yap_StartSlots();
|
Yap_StartSlots();
|
||||||
Yap_plwrite (t, f_putc, Handle_vars_f|Quote_illegal_f|To_heap_f, 1200);
|
Yap_plwrite (t, f_putc, Handle_vars_f|Quote_illegal_f|To_heap_f, 1200);
|
||||||
|
Yap_CloseSlots();
|
||||||
FormatInfo = &finfo;
|
FormatInfo = &finfo;
|
||||||
ASP++;
|
|
||||||
break;
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
if (targ > tnum-1 || has_repeats)
|
if (targ > tnum-1 || has_repeats)
|
||||||
|
@ -5416,8 +5423,8 @@ format(volatile Term otail, volatile Term oargs, int sno)
|
||||||
t = targs[targ++];
|
t = targs[targ++];
|
||||||
Yap_StartSlots();
|
Yap_StartSlots();
|
||||||
Yap_plwrite (t, f_putc, Handle_vars_f|To_heap_f, 1200);
|
Yap_plwrite (t, f_putc, Handle_vars_f|To_heap_f, 1200);
|
||||||
|
Yap_CloseSlots();
|
||||||
FormatInfo = &finfo;
|
FormatInfo = &finfo;
|
||||||
ASP++;
|
|
||||||
break;
|
break;
|
||||||
case '~':
|
case '~':
|
||||||
if (has_repeats)
|
if (has_repeats)
|
||||||
|
@ -6262,10 +6269,10 @@ Yap_TermToString(Term t, char *s, unsigned int sz, int flags)
|
||||||
|
|
||||||
if (sno < 0)
|
if (sno < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
Yap_StartSlots();
|
|
||||||
Yap_c_output_stream = sno;
|
Yap_c_output_stream = sno;
|
||||||
Yap_StartSlots();
|
Yap_StartSlots();
|
||||||
Yap_plwrite (t, Stream[sno].stream_wputc, flags, 1200);
|
Yap_plwrite (t, Stream[sno].stream_wputc, flags, 1200);
|
||||||
|
Yap_CloseSlots();
|
||||||
s[Stream[sno].u.mem_string.pos] = '\0';
|
s[Stream[sno].u.mem_string.pos] = '\0';
|
||||||
Stream[sno].status = Free_Stream_f;
|
Stream[sno].status = Free_Stream_f;
|
||||||
Yap_c_output_stream = old_output_stream;
|
Yap_c_output_stream = old_output_stream;
|
||||||
|
|
4
H/Regs.h
4
H/Regs.h
|
@ -80,6 +80,7 @@ EXTERN void save_B(void);
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
Int CurSlot_;
|
||||||
CELL CreepFlag_; /* 13 */
|
CELL CreepFlag_; /* 13 */
|
||||||
CELL *HB_; /* 4 heap (global) stack top at latest c.p. */
|
CELL *HB_; /* 4 heap (global) stack top at latest c.p. */
|
||||||
#if defined(SBA) || defined(TABLING)
|
#if defined(SBA) || defined(TABLING)
|
||||||
|
@ -609,11 +610,10 @@ EXTERN inline void restore_B(void) {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define CurSlot Yap_REGS.CurSlot_
|
||||||
#define AuxBase Yap_REGS.AuxBase_
|
#define AuxBase Yap_REGS.AuxBase_
|
||||||
#define AuxSp Yap_REGS.AuxSp_
|
#define AuxSp Yap_REGS.AuxSp_
|
||||||
#define AuxTop Yap_REGS.AuxTop_
|
#define AuxTop Yap_REGS.AuxTop_
|
||||||
#define TopB Yap_REGS.TopB_
|
|
||||||
#define DelayedB Yap_REGS.DelayedB_
|
|
||||||
#define EX Yap_REGS.EX_
|
#define EX Yap_REGS.EX_
|
||||||
#define DEPTH Yap_REGS.DEPTH_
|
#define DEPTH Yap_REGS.DEPTH_
|
||||||
#if defined(SBA) || defined(TABLING)
|
#if defined(SBA) || defined(TABLING)
|
||||||
|
|
23
H/Yap.h
23
H/Yap.h
|
@ -1305,4 +1305,27 @@ typedef enum
|
||||||
COMPILE_ALL /* compile all predicates */
|
COMPILE_ALL /* compile all predicates */
|
||||||
} yap_exec_mode;
|
} yap_exec_mode;
|
||||||
|
|
||||||
|
/********* slots ***********************/
|
||||||
|
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
Yap_StartSlots(void) {
|
||||||
|
*--ASP = MkIntegerTerm(CurSlot);
|
||||||
|
*--ASP = MkIntTerm(0);
|
||||||
|
CurSlot = LCL0-ASP;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
Yap_CloseSlots(void) {
|
||||||
|
Int old_slots;
|
||||||
|
old_slots = IntOfTerm(ASP[0]);
|
||||||
|
ASP += (old_slots+1);
|
||||||
|
CurSlot = IntegerOfTerm(*ASP);
|
||||||
|
ASP++;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Int
|
||||||
|
Yap_CurrentSlot(void) {
|
||||||
|
return IntOfTerm(ASP[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,8 +59,6 @@ Term STD_PROTO(Yap_NWideStringToDiffListOfAtoms,(wchar_t *, Term, size_t));
|
||||||
int STD_PROTO(Yap_AtomIncreaseHold,(Atom));
|
int STD_PROTO(Yap_AtomIncreaseHold,(Atom));
|
||||||
int STD_PROTO(Yap_AtomDecreaseHold,(Atom));
|
int STD_PROTO(Yap_AtomDecreaseHold,(Atom));
|
||||||
|
|
||||||
#define Yap_StartSlots() (*--ASP = MkIntTerm(0))
|
|
||||||
#define Yap_CurrentSlot() IntOfTerm(ASP[0])
|
|
||||||
Int STD_PROTO(Yap_InitSlot,(Term));
|
Int STD_PROTO(Yap_InitSlot,(Term));
|
||||||
Int STD_PROTO(Yap_NewSlots,(int));
|
Int STD_PROTO(Yap_NewSlots,(int));
|
||||||
Term STD_PROTO(Yap_GetFromSlot,(Int));
|
Term STD_PROTO(Yap_GetFromSlot,(Int));
|
||||||
|
|
|
@ -2207,28 +2207,6 @@ X_API int PL_action(int action,...)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
X_API fid_t
|
|
||||||
PL_open_foreign_frame(void)
|
|
||||||
{
|
|
||||||
return (fid_t)ASP;
|
|
||||||
}
|
|
||||||
|
|
||||||
X_API void
|
|
||||||
PL_close_foreign_frame(fid_t f)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
X_API void
|
|
||||||
PL_rewind_foreign_frame(fid_t f)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
X_API void
|
|
||||||
PL_discard_foreign_frame(fid_t f)
|
|
||||||
{
|
|
||||||
/* Missing: undo Trail!! */
|
|
||||||
}
|
|
||||||
|
|
||||||
X_API term_t
|
X_API term_t
|
||||||
PL_exception(qid_t q)
|
PL_exception(qid_t q)
|
||||||
{
|
{
|
||||||
|
@ -2371,9 +2349,52 @@ typedef struct open_query_struct {
|
||||||
int open;
|
int open;
|
||||||
int state;
|
int state;
|
||||||
YAP_Term g;
|
YAP_Term g;
|
||||||
|
yamop *p, *cp;
|
||||||
|
Int slots;
|
||||||
|
struct open_query_struct *old;
|
||||||
} open_query;
|
} open_query;
|
||||||
|
|
||||||
open_query execution;
|
static open_query *execution = NULL;
|
||||||
|
|
||||||
|
X_API fid_t
|
||||||
|
PL_open_foreign_frame(void)
|
||||||
|
{
|
||||||
|
open_query *new = (open_query *)malloc(sizeof(open_query));
|
||||||
|
if (!new) return 0;
|
||||||
|
new->old = execution;
|
||||||
|
new->g = TermNil;
|
||||||
|
new->open = FALSE;
|
||||||
|
new->cp = CP;
|
||||||
|
new->p = P;
|
||||||
|
new->slots = CurSlot;
|
||||||
|
Yap_StartSlots();
|
||||||
|
execution = new;
|
||||||
|
return (fid_t)new;
|
||||||
|
}
|
||||||
|
|
||||||
|
X_API void
|
||||||
|
PL_close_foreign_frame(fid_t f)
|
||||||
|
{
|
||||||
|
CP = execution->cp;
|
||||||
|
P = execution->p;
|
||||||
|
CurSlot = execution->slots;
|
||||||
|
execution = execution->old;
|
||||||
|
}
|
||||||
|
|
||||||
|
X_API void
|
||||||
|
PL_rewind_foreign_frame(fid_t f)
|
||||||
|
{
|
||||||
|
CurSlot = execution->slots;
|
||||||
|
}
|
||||||
|
|
||||||
|
X_API void
|
||||||
|
PL_discard_foreign_frame(fid_t f)
|
||||||
|
{
|
||||||
|
CP = execution->cp;
|
||||||
|
P = execution->p;
|
||||||
|
CurSlot = execution->slots;
|
||||||
|
execution = execution->old;
|
||||||
|
}
|
||||||
|
|
||||||
X_API qid_t PL_open_query(module_t ctx, int flags, predicate_t p, term_t t0)
|
X_API qid_t PL_open_query(module_t ctx, int flags, predicate_t p, term_t t0)
|
||||||
{
|
{
|
||||||
|
@ -2382,11 +2403,14 @@ X_API qid_t PL_open_query(module_t ctx, int flags, predicate_t p, term_t t0)
|
||||||
Term t[2], m;
|
Term t[2], m;
|
||||||
|
|
||||||
/* ignore flags and module for now */
|
/* ignore flags and module for now */
|
||||||
if (execution.open != 0) {
|
if (execution == NULL)
|
||||||
|
PL_open_foreign_frame();
|
||||||
|
if (execution->open != 0) {
|
||||||
YAP_Error(0, 0L, "only one query at a time allowed\n");
|
YAP_Error(0, 0L, "only one query at a time allowed\n");
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
execution.open=1;
|
execution->open=1;
|
||||||
execution.state=0;
|
execution->state=0;
|
||||||
PredicateInfo((PredEntry *)p, &yname, &arity, &m);
|
PredicateInfo((PredEntry *)p, &yname, &arity, &m);
|
||||||
t[0] = SWIModuleToModule(ctx);
|
t[0] = SWIModuleToModule(ctx);
|
||||||
if (arity == 0) {
|
if (arity == 0) {
|
||||||
|
@ -2395,8 +2419,8 @@ X_API qid_t PL_open_query(module_t ctx, int flags, predicate_t p, term_t t0)
|
||||||
Functor f = Yap_MkFunctor(yname, arity);
|
Functor f = Yap_MkFunctor(yname, arity);
|
||||||
t[1] = Yap_MkApplTerm(f,arity,Yap_AddressFromSlot(t0));
|
t[1] = Yap_MkApplTerm(f,arity,Yap_AddressFromSlot(t0));
|
||||||
}
|
}
|
||||||
execution.g = Yap_MkApplTerm(FunctorModule,2,t);
|
execution->g = Yap_MkApplTerm(FunctorModule,2,t);
|
||||||
return &execution;
|
return execution;
|
||||||
}
|
}
|
||||||
|
|
||||||
X_API int PL_next_solution(qid_t qi)
|
X_API int PL_next_solution(qid_t qi)
|
||||||
|
@ -2405,7 +2429,6 @@ X_API int PL_next_solution(qid_t qi)
|
||||||
|
|
||||||
if (qi->open != 1) return 0;
|
if (qi->open != 1) return 0;
|
||||||
if (qi->state == 0) {
|
if (qi->state == 0) {
|
||||||
|
|
||||||
result = YAP_RunGoal(qi->g);
|
result = YAP_RunGoal(qi->g);
|
||||||
} else {
|
} else {
|
||||||
result = YAP_RestartGoal();
|
result = YAP_RestartGoal();
|
||||||
|
|
|
@ -9,7 +9,8 @@ BINDIR = $(ROOTDIR)/bin
|
||||||
#
|
#
|
||||||
# where YAP should look for binary libraries
|
# where YAP should look for binary libraries
|
||||||
#
|
#
|
||||||
LIBDIR=@libdir@/Yap
|
LIBDIR=@libdir@
|
||||||
|
YAPLIBDIR=@libdir@/Yap
|
||||||
#
|
#
|
||||||
# where YAP should look for architecture-independent Prolog libraries
|
# where YAP should look for architecture-independent Prolog libraries
|
||||||
#
|
#
|
||||||
|
|
|
@ -14,7 +14,8 @@ BINDIR = $(EROOTDIR)/bin
|
||||||
#
|
#
|
||||||
# where YAP should look for libraries
|
# where YAP should look for libraries
|
||||||
#
|
#
|
||||||
LIBDIR=@libdir@/Yap
|
LIBDIR=@libdir@
|
||||||
|
YAPLIBDIR=@libdir@/Yap
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
CC=@CC@
|
CC=@CC@
|
||||||
|
@ -60,4 +61,4 @@ clean:
|
||||||
rm -f *.o ProblogBDD Example
|
rm -f *.o ProblogBDD Example
|
||||||
|
|
||||||
install: default
|
install: default
|
||||||
$(INSTALL_PROGRAM) ProblogBDD $(DESTDIR)$(LIBDIR)
|
$(INSTALL_PROGRAM) ProblogBDD $(DESTDIR)$(YAPLIBDIR)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 9efaf4ce7063fbdae534b4555a80fa1373bb7e9a
|
Subproject commit c6b86a4c77da30c8e3a9eafcad76a54004a779de
|
|
@ -19,8 +19,8 @@ srcdir=@srcdir@
|
||||||
|
|
||||||
BINDIR = $(EROOTDIR)/bin
|
BINDIR = $(EROOTDIR)/bin
|
||||||
LIBDIR=@libdir@
|
LIBDIR=@libdir@
|
||||||
SHAREDIR=$(EROOTDIR)/share/Yap
|
|
||||||
YAPLIBDIR=@libdir@/Yap
|
YAPLIBDIR=@libdir@/Yap
|
||||||
|
SHAREDIR=$(EROOTDIR)/share/Yap
|
||||||
|
|
||||||
PL=@EXTEND_DYNLOADER_PATH@ $(DESTDIR)$(BINDIR)/yap $(DESTDIR)$(YAPLIBDIR)/startup.yss
|
PL=@EXTEND_DYNLOADER_PATH@ $(DESTDIR)$(BINDIR)/yap $(DESTDIR)$(YAPLIBDIR)/startup.yss
|
||||||
LN_S=@LN_S@
|
LN_S=@LN_S@
|
||||||
|
|
Reference in New Issue