WIN64 support (sill needs improvement)
This commit is contained in:
113
C/absmi.c
113
C/absmi.c
@@ -602,19 +602,18 @@ check_alarm_fail_int(int CONT USES_REGS)
|
||||
}
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
#endif
|
||||
if (LOCAL_ActiveSignals & (YAP_FAIL_SIGNAL|YAP_INT_SIGNAL)) {
|
||||
/* these should fail, INT should go up to top-level */
|
||||
if (LOCAL_ActiveSignals & YAP_INT_SIGNAL) {
|
||||
if (Yap_has_signals( YAP_INT_SIGNAL, YAP_FAIL_SIGNAL ) ) {
|
||||
if (Yap_undo_signal( YAP_INT_SIGNAL ) ) {
|
||||
Yap_Error(PURE_ABORT, TermNil, "abort from console");
|
||||
}
|
||||
LOCAL_ActiveSignals &= ~(YAP_FAIL_SIGNAL|YAP_INT_SIGNAL);
|
||||
if (!LOCAL_ActiveSignals) {
|
||||
/* no need to look into GC */
|
||||
CalculateStackGap( PASS_REGS1 );
|
||||
}
|
||||
// fail even if there are more signals, they will have to be dealt later.
|
||||
(void)Yap_undo_signal( YAP_FAIL_SIGNAL );
|
||||
return FALSE;
|
||||
}
|
||||
if (!Yap_has_a_signal()) {
|
||||
/* no need to look into GC */
|
||||
CalculateStackGap( PASS_REGS1 );
|
||||
}
|
||||
// fail even if there are more signals, they will have to be dealt later.
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -622,8 +621,7 @@ static int
|
||||
stack_overflow( CELL *env, yamop *cp USES_REGS )
|
||||
{
|
||||
if ((Int)(Unsigned(YREG) - Unsigned(HR)) < StackGap( PASS_REGS1 ) ||
|
||||
LOCAL_ActiveSignals & YAP_STOVF_SIGNAL) {
|
||||
LOCAL_ActiveSignals &= ~YAP_STOVF_SIGNAL;
|
||||
Yap_undo_signal( YAP_STOVF_SIGNAL )) {
|
||||
if (!Yap_gc(((PredEntry *)(S))->ArityOfPE, env, cp)) {
|
||||
Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage);
|
||||
return 0;
|
||||
@@ -636,10 +634,9 @@ stack_overflow( CELL *env, yamop *cp USES_REGS )
|
||||
static int
|
||||
code_overflow( CELL *yenv USES_REGS )
|
||||
{
|
||||
if (LOCAL_ActiveSignals & YAP_CDOVF_SIGNAL) {
|
||||
if (Yap_undo_signal( YAP_CDOVF_SIGNAL )) {
|
||||
CELL cut_b = LCL0-(CELL *)(S[E_CB]);
|
||||
|
||||
LOCAL_ActiveSignals &= ~YAP_CDOVF_SIGNAL;
|
||||
/* do a garbage collection first to check if we can recover memory */
|
||||
if (!Yap_growheap(FALSE, 0, NULL)) {
|
||||
Yap_NilError(OUT_OF_HEAP_ERROR, "YAP failed to grow heap: %s", LOCAL_ErrorMessage);
|
||||
@@ -709,12 +706,9 @@ interrupt_handler( USES_REGS1 )
|
||||
ARG1 = (Term) AbsPair(HR);
|
||||
|
||||
HR += 2;
|
||||
LOCK(LOCAL_SignalLock);
|
||||
#ifdef COROUTINING
|
||||
if (LOCAL_ActiveSignals & YAP_WAKEUP_SIGNAL) {
|
||||
if (Yap_undo_signal( YAP_WAKEUP_SIGNAL )) {
|
||||
CalculateStackGap( PASS_REGS1 );
|
||||
LOCAL_ActiveSignals &= ~YAP_WAKEUP_SIGNAL;
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
ARG2 = Yap_ListOfWokenGoals();
|
||||
pe = WakeUpCode;
|
||||
/* no more goals to wake up */
|
||||
@@ -724,7 +718,6 @@ interrupt_handler( USES_REGS1 )
|
||||
{
|
||||
CalculateStackGap( PASS_REGS1 );
|
||||
pe = CreepCode;
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
}
|
||||
P = pe->CodeOfPred;
|
||||
#ifdef LOW_LEVEL_TRACER
|
||||
@@ -797,23 +790,23 @@ interrupt_handler_either( USES_REGS1 )
|
||||
//#define DEBUG_INTERRUPTS 1
|
||||
|
||||
#ifdef DEBUG_INTERRUPTS
|
||||
static int trace_interrupts;
|
||||
static int trace_interrupts = TRUE;
|
||||
#endif
|
||||
|
||||
static int
|
||||
interrupt_fail( USES_REGS1 )
|
||||
{
|
||||
#ifdef DEBUG_INTERRUPTS
|
||||
if (trace_interrupts) fprintf(stderr,"[%d] %s:%d: INTERRUPT %lx (YENV=%p ENV=%p ASP=%p)\n", (int)pthread_self(), \
|
||||
__FUNCTION__, __LINE__,LOCAL_ActiveSignals,YENV,ENV,ASP);
|
||||
if (trace_interrupts) fprintf(stderr,"[%d] %lu--%lu %s:%d: (YENV=%p ENV=%p ASP=%p)\n", worker_id, LOCAL_FirstActiveSignal, LOCAL_LastActiveSignal, \
|
||||
__FUNCTION__, __LINE__,YENV,ENV,ASP);
|
||||
#endif
|
||||
check_alarm_fail_int( FALSE PASS_REGS );
|
||||
/* don't do debugging and stack expansion here: space will
|
||||
be recovered. automatically by fail, so
|
||||
better wait.
|
||||
*/
|
||||
if (!LOCAL_ActiveSignals ||
|
||||
(LOCAL_ActiveSignals & (YAP_CDOVF_SIGNAL|YAP_CREEP_SIGNAL))) {
|
||||
if (!Yap_has_a_signal() ||
|
||||
Yap_has_signals( YAP_CDOVF_SIGNAL, YAP_CREEP_SIGNAL )) {
|
||||
return FALSE;
|
||||
}
|
||||
S = (CELL *)RepPredProp(Yap_GetPredPropByAtom(AtomFail,0));
|
||||
@@ -829,13 +822,13 @@ interrupt_execute( USES_REGS1 )
|
||||
int v;
|
||||
|
||||
#ifdef DEBUG_INTERRUPTS
|
||||
if (trace_interrupts) fprintf(stderr,"[%d] %s:%d: INTERRUPT %lx (YENV=%p ENV=%p ASP=%p)\n", (int)pthread_self(), \
|
||||
__FUNCTION__, __LINE__,LOCAL_ActiveSignals,YENV,ENV,ASP);
|
||||
if (trace_interrupts) fprintf(stderr,"[%d] %lu--%lu %s:%d: (YENV=%p ENV=%p ASP=%p)\n", worker_id, LOCAL_FirstActiveSignal, LOCAL_LastActiveSignal, \
|
||||
__FUNCTION__, __LINE__,YENV,ENV,ASP);
|
||||
#endif
|
||||
if ((v = check_alarm_fail_int( TRUE PASS_REGS )) >= 0)
|
||||
return v;
|
||||
PP = P->u.pp.p0;
|
||||
if ((PP->ExtraPredFlags & NoDebugPredFlag) && (LOCAL_ActiveSignals == YAP_CREEP_SIGNAL))
|
||||
if ((PP->ExtraPredFlags & (NoDebugPredFlag|HiddenPredFlag)) && Yap_only_has_signal(YAP_CREEP_SIGNAL))
|
||||
return 2;
|
||||
S = (CELL *) P->u.pp.p;
|
||||
SET_ASP(YENV, E_CB*sizeof(CELL));
|
||||
@@ -850,14 +843,14 @@ interrupt_call( USES_REGS1 )
|
||||
int v;
|
||||
|
||||
#ifdef DEBUG_INTERRUPTS
|
||||
if (trace_interrupts) fprintf(stderr,"[%d] %s:%d: INTERRUPT %lx (YENV=%p ENV=%p ASP=%p)\n", (int)pthread_self(), \
|
||||
__FUNCTION__, __LINE__,LOCAL_ActiveSignals,YENV,ENV,ASP);
|
||||
if (trace_interrupts) fprintf(stderr,"[%d] %lu--%lu %s:%d: (YENV=%p ENV=%p ASP=%p)\n", worker_id, LOCAL_FirstActiveSignal, LOCAL_LastActiveSignal, \
|
||||
__FUNCTION__, __LINE__,YENV,ENV,ASP);
|
||||
#endif
|
||||
if ((v = check_alarm_fail_int( TRUE PASS_REGS )) >= 0)
|
||||
return v;
|
||||
// printf("%lx %p %p %lx\n", LOCAL_ActiveSignals, P->u.Osbpp.p, P->u.Osbpp.p0, P->u.Osbpp.p0->ExtraPredFlags);
|
||||
PP = P->u.Osbpp.p0;
|
||||
if ((PP->ExtraPredFlags & NoDebugPredFlag) && (LOCAL_ActiveSignals == YAP_CREEP_SIGNAL))
|
||||
if (Yap_only_has_signal(YAP_CREEP_SIGNAL) &&
|
||||
PP->ExtraPredFlags & (NoDebugPredFlag|HiddenPredFlag) )
|
||||
return 2;
|
||||
S = (CELL *) P->u.Osbpp.p;
|
||||
SET_ASP(YENV, P->u.Osbpp.s);
|
||||
@@ -872,13 +865,13 @@ interrupt_pexecute( PredEntry *pen USES_REGS )
|
||||
int v;
|
||||
|
||||
#ifdef DEBUG_INTERRUPTS
|
||||
if (trace_interrupts) fprintf(stderr,"[%d] %s:%d: INTERRUPT %lx (YENV=%p ENV=%p ASP=%p)\n", (int)pthread_self(), \
|
||||
__FUNCTION__, __LINE__,LOCAL_ActiveSignals,YENV,ENV,ASP);
|
||||
if (trace_interrupts) fprintf(stderr,"[%d] %lu--%lu %s:%d: (YENV=%p ENV=%p ASP=%p)\n", worker_id, LOCAL_FirstActiveSignal, LOCAL_LastActiveSignal, \
|
||||
__FUNCTION__, __LINE__,YENV,ENV,ASP);
|
||||
#endif
|
||||
if ((v = check_alarm_fail_int( 2 PASS_REGS )) >= 0)
|
||||
return v;
|
||||
PP = NULL;
|
||||
if (LOCAL_ActiveSignals == YAP_CREEP_SIGNAL)
|
||||
if (Yap_only_has_signal(YAP_CREEP_SIGNAL))
|
||||
return 2; /* keep on creeping */
|
||||
S = (CELL *) pen;
|
||||
ASP = YENV;
|
||||
@@ -902,15 +895,15 @@ interrupt_deallocate( USES_REGS1 )
|
||||
int v;
|
||||
|
||||
#ifdef DEBUG_INTERRUPTS
|
||||
if (trace_interrupts) fprintf(stderr,"[%d] %s:%d: INTERRUPT %lx (YENV=%p ENV=%p ASP=%p)\n", (int)pthread_self(), \
|
||||
__FUNCTION__, __LINE__,LOCAL_ActiveSignals,YENV,ENV,ASP);
|
||||
if (trace_interrupts) fprintf(stderr,"[%d] %lu--%lu %s:%d (YENV=%p ENV=%p ASP=%p)\n", worker_id, LOCAL_FirstActiveSignal, LOCAL_LastActiveSignal, \
|
||||
__FUNCTION__, __LINE__,YENV,ENV,ASP);
|
||||
#endif
|
||||
if ((v = check_alarm_fail_int( TRUE PASS_REGS )) >= 0)
|
||||
return v;
|
||||
/*
|
||||
don't do a creep here; also, if our instruction is followed by
|
||||
a execute_c, just wait a bit more */
|
||||
if ( (LOCAL_ActiveSignals == YAP_CREEP_SIGNAL) ||
|
||||
if ( Yap_only_has_signal( YAP_CREEP_SIGNAL ) ||
|
||||
/* keep on going if there is something else */
|
||||
(P->opc != Yap_opcode(_procceed) &&
|
||||
P->opc != Yap_opcode(_cut_e))) {
|
||||
@@ -927,7 +920,7 @@ interrupt_deallocate( USES_REGS1 )
|
||||
if (ASP > (CELL *)PROTECT_FROZEN_B(B))
|
||||
ASP = (CELL *)PROTECT_FROZEN_B(B);
|
||||
if ((v = code_overflow(YENV PASS_REGS)) >= 0) return v;
|
||||
if (LOCAL_ActiveSignals) {
|
||||
if (Yap_has_a_signal()) {
|
||||
if (Yap_op_from_opcode(P->opc) == _cut_e) {
|
||||
/* followed by a cut */
|
||||
ARG1 = MkIntegerTerm(LCL0-(CELL *)S[E_CB]);
|
||||
@@ -951,12 +944,13 @@ interrupt_cut( USES_REGS1 )
|
||||
{
|
||||
int v;
|
||||
#ifdef DEBUG_INTERRUPTS
|
||||
if (trace_interrupts) fprintf(stderr,"[%d] %s:%d: INTERRUPT %lx (YENV=%p ENV=%p ASP=%p)\n", (int)pthread_self(), \
|
||||
__FUNCTION__, __LINE__,LOCAL_ActiveSignals,YENV,ENV,ASP);
|
||||
if (trace_interrupts) fprintf(stderr,"[%d] %lu--%lu %s:%d (YENV=%p ENV=%p ASP=%p)\n", worker_id, LOCAL_FirstActiveSignal, LOCAL_LastActiveSignal, \
|
||||
__FUNCTION__, __LINE__,YENV,ENV,ASP);
|
||||
#endif
|
||||
if ((v = check_alarm_fail_int( 2 PASS_REGS )) >= 0)
|
||||
return v;
|
||||
if (!LOCAL_ActiveSignals || (LOCAL_ActiveSignals & (YAP_CDOVF_SIGNAL|YAP_CREEP_SIGNAL)) == LOCAL_ActiveSignals) {
|
||||
if (!Yap_has_a_signal()
|
||||
|| Yap_only_has_signals(YAP_CDOVF_SIGNAL , YAP_CREEP_SIGNAL )) {
|
||||
return 2;
|
||||
}
|
||||
/* find something to fool S */
|
||||
@@ -971,12 +965,13 @@ interrupt_cut_t( USES_REGS1 )
|
||||
{
|
||||
int v;
|
||||
#ifdef DEBUG_INTERRUPTS
|
||||
if (trace_interrupts) fprintf(stderr,"[%d] %s:%d: INTERRUPT %lx (YENV=%p ENV=%p ASP=%p)\n", (int)pthread_self(), \
|
||||
__FUNCTION__, __LINE__,LOCAL_ActiveSignals,YENV,ENV,ASP);
|
||||
if (trace_interrupts) fprintf(stderr,"[%d] %lu--%lu %s:%d: (YENV=%p ENV=%p ASP=%p)\n", worker_id, LOCAL_FirstActiveSignal, LOCAL_LastActiveSignal, \
|
||||
__FUNCTION__, __LINE__,YENV,ENV,ASP);
|
||||
#endif
|
||||
if ((v = check_alarm_fail_int( 2 PASS_REGS )) >= 0)
|
||||
return v;
|
||||
if (!LOCAL_ActiveSignals || (LOCAL_ActiveSignals & (YAP_CDOVF_SIGNAL|YAP_CREEP_SIGNAL)) == LOCAL_ActiveSignals) {
|
||||
if (!Yap_has_a_signal()
|
||||
|| Yap_only_has_signals(YAP_CDOVF_SIGNAL , YAP_CREEP_SIGNAL )) {
|
||||
return 2;
|
||||
}
|
||||
/* find something to fool S */
|
||||
@@ -991,11 +986,15 @@ interrupt_commit_y( USES_REGS1 )
|
||||
{
|
||||
int v;
|
||||
#ifdef DEBUG_INTERRUPTS
|
||||
if (trace_interrupts) fprintf(stderr,"[%d] %s:%d: INTERRUPT %lx (YENV=%p ENV=%p ASP=%p)\n", (int)pthread_self(), \
|
||||
__FUNCTION__, __LINE__,LOCAL_ActiveSignals,YENV,ENV,ASP);
|
||||
if (trace_interrupts) fprintf(stderr,"[%d] %lu--%lu %s:%d: (YENV=%p ENV=%p ASP=%p)\n", worker_id, LOCAL_FirstActiveSignal, LOCAL_LastActiveSignal, \
|
||||
__FUNCTION__, __LINE__,YENV,ENV,ASP);
|
||||
#endif
|
||||
if ((v = check_alarm_fail_int( 2 PASS_REGS )) >= 0)
|
||||
return v;
|
||||
if (!Yap_has_a_signal()
|
||||
|| Yap_only_has_signals(YAP_CDOVF_SIGNAL , YAP_CREEP_SIGNAL )) {
|
||||
return 2;
|
||||
}
|
||||
/* find something to fool S */
|
||||
S = (CELL *)PredRestoreRegs;
|
||||
XREGS[0] = YENV[P->u.yps.y];
|
||||
@@ -1008,12 +1007,13 @@ interrupt_commit_x( USES_REGS1 )
|
||||
{
|
||||
int v;
|
||||
#ifdef DEBUG_INTERRUPTS
|
||||
if (trace_interrupts) fprintf(stderr,"[%d] %s:%d: INTERRUPT %lx (YENV=%p ENV=%p ASP=%p)\n", (int)pthread_self(), \
|
||||
__FUNCTION__, __LINE__,LOCAL_ActiveSignals,YENV,ENV,ASP);
|
||||
if (trace_interrupts) fprintf(stderr,"[%d] %lu--%lu %s:%d (YENV=%p ENV=%p ASP=%p)\n", worker_id, LOCAL_FirstActiveSignal, LOCAL_LastActiveSignal, \
|
||||
__FUNCTION__, __LINE__,YENV,ENV,ASP);
|
||||
#endif
|
||||
if ((v = check_alarm_fail_int( 2 PASS_REGS )) >= 0)
|
||||
return v;
|
||||
if (!LOCAL_ActiveSignals || (LOCAL_ActiveSignals & (YAP_CDOVF_SIGNAL|YAP_CREEP_SIGNAL)) == LOCAL_ActiveSignals) {
|
||||
if (!Yap_has_a_signal()
|
||||
|| Yap_only_has_signals(YAP_CDOVF_SIGNAL , YAP_CREEP_SIGNAL )) {
|
||||
return 2;
|
||||
}
|
||||
PP = P->u.xps.p0;
|
||||
@@ -1040,12 +1040,12 @@ interrupt_either( USES_REGS1 )
|
||||
int v;
|
||||
|
||||
#ifdef DEBUG_INTERRUPTS
|
||||
if (trace_interrupts) fprintf(stderr,"[%d] %s:%d: INTERRUPT %lx (YENV=%p ENV=%p ASP=%p)\n", (int)pthread_self(), \
|
||||
__FUNCTION__, __LINE__,LOCAL_ActiveSignals,YENV,ENV,ASP);
|
||||
if (trace_interrupts) fprintf(stderr,"[%d] %lu--%lu %s:%d: (YENV=%p ENV=%p ASP=%p)\n", worker_id, LOCAL_FirstActiveSignal, LOCAL_LastActiveSignal, \
|
||||
__FUNCTION__, __LINE__,YENV,ENV,ASP);
|
||||
#endif
|
||||
if ((v = check_alarm_fail_int( 2 PASS_REGS )) >= 0)
|
||||
return v;
|
||||
if (LOCAL_ActiveSignals == YAP_CREEP_SIGNAL)
|
||||
if (Yap_only_has_signal(YAP_CREEP_SIGNAL))
|
||||
return 2;
|
||||
PP = P->u.Osblp.p0;
|
||||
/* find something to fool S */
|
||||
@@ -1064,12 +1064,12 @@ interrupt_dexecute( USES_REGS1 )
|
||||
int v;
|
||||
|
||||
#ifdef DEBUG_INTERRUPTS
|
||||
if (trace_interrupts) fprintf(stderr,"[%d] %s:%d: INTERRUPT %lx (YENV=%p ENV=%p ASP=%p)\n", (int)pthread_self(), \
|
||||
__FUNCTION__, __LINE__,LOCAL_ActiveSignals,YENV,ENV,ASP);
|
||||
if (trace_interrupts) fprintf(stderr,"[%d] %lu--%lu %s/%d (YENV=%p ENV=%p ASP=%p)\n", worker_id, LOCAL_FirstActiveSignal, LOCAL_LastActiveSignal, \
|
||||
__FUNCTION__, __LINE__,YENV,ENV,ASP);
|
||||
#endif
|
||||
PP = P->u.pp.p0;
|
||||
if ((LOCAL_ActiveSignals & YAP_CREEP_SIGNAL) &&
|
||||
(PP->ExtraPredFlags & NoDebugPredFlag)) {
|
||||
if (Yap_has_signal(YAP_CREEP_SIGNAL) &&
|
||||
(PP->ExtraPredFlags & (NoDebugPredFlag|HiddenPredFlag))) {
|
||||
return 2;
|
||||
}
|
||||
/* set S for next instructions */
|
||||
@@ -7400,7 +7400,7 @@ Yap_absmi(int inp)
|
||||
BOp(call_cpred, Osbpp);
|
||||
check_trail(TR);
|
||||
if (!(PREG->u.Osbpp.p->PredFlags & (SafePredFlag)) &&
|
||||
!(PREG->u.Osbpp.p0->ExtraPredFlags & (NoDebugPredFlag))) {
|
||||
!(PREG->u.Osbpp.p0->ExtraPredFlags & (NoDebugPredFlag|HiddenPredFlag))) {
|
||||
CACHE_Y_AS_ENV(YREG);
|
||||
check_stack(NoStackCCall, HR);
|
||||
ENDCACHE_Y_AS_ENV();
|
||||
@@ -8016,7 +8016,6 @@ Yap_absmi(int inp)
|
||||
FAIL();
|
||||
}
|
||||
d0 = pe->ArityOfPE;
|
||||
UNLOCKPE(19,pe);
|
||||
if (d0 == 0) {
|
||||
HR[1] = MkAtomTerm((Atom)(pe->FunctorOfPred));
|
||||
}
|
||||
|
10
C/agc.c
Normal file → Executable file
10
C/agc.c
Normal file → Executable file
@@ -481,9 +481,9 @@ atom_gc(USES_REGS1)
|
||||
GLOBAL_agc_collected = 0;
|
||||
|
||||
if (gc_trace) {
|
||||
fprintf(GLOBAL_stderr, "%% agc:\n");
|
||||
fprintf(stderr, "%% agc:\n");
|
||||
} else if (gc_verbose) {
|
||||
fprintf(GLOBAL_stderr, "%% Start of atom garbage collection %d:\n", GLOBAL_agc_calls);
|
||||
fprintf(stderr, "%% Start of atom garbage collection %d:\n", GLOBAL_agc_calls);
|
||||
}
|
||||
time_start = Yap_cputime();
|
||||
/* get the number of active registers */
|
||||
@@ -499,11 +499,11 @@ atom_gc(USES_REGS1)
|
||||
GLOBAL_tot_agc_recovered += GLOBAL_agc_collected;
|
||||
if (gc_verbose) {
|
||||
#ifdef _WIN32
|
||||
fprintf(GLOBAL_stderr, "%% Collected %I64d bytes.\n", GLOBAL_agc_collected);
|
||||
fprintf(stderr, "%% Collected %I64d bytes.\n", GLOBAL_agc_collected);
|
||||
#else
|
||||
fprintf(GLOBAL_stderr, "%% Collected %lld bytes.\n", GLOBAL_agc_collected);
|
||||
fprintf(stderr, "%% Collected %lld bytes.\n", GLOBAL_agc_collected);
|
||||
#endif
|
||||
fprintf(GLOBAL_stderr, "%% GC %d took %g sec, total of %g sec doing GC so far.\n", GLOBAL_agc_calls, (double)agc_time/1000, (double)GLOBAL_tot_agc_time/1000);
|
||||
fprintf(stderr, "%% GC %d took %g sec, total of %g sec doing GC so far.\n", GLOBAL_agc_calls, (double)agc_time/1000, (double)GLOBAL_tot_agc_time/1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
8
C/c_interface.c
Normal file → Executable file
8
C/c_interface.c
Normal file → Executable file
@@ -893,7 +893,7 @@ YAP_LookupAtom(char *c)
|
||||
|
||||
while (TRUE) {
|
||||
a = Yap_LookupAtom(c);
|
||||
if (a == NIL || (LOCAL_ActiveSignals & YAP_CDOVF_SIGNAL)) {
|
||||
if (a == NIL || Yap_has_signal(YAP_CDOVF_SIGNAL)) {
|
||||
if (!Yap_growheap(FALSE, 0, NULL)) {
|
||||
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap: %s", LOCAL_ErrorMessage);
|
||||
}
|
||||
@@ -911,7 +911,7 @@ YAP_LookupWideAtom(wchar_t *c)
|
||||
|
||||
while (TRUE) {
|
||||
a = Yap_LookupWideAtom(c);
|
||||
if (a == NIL || (LOCAL_ActiveSignals & YAP_CDOVF_SIGNAL)) {
|
||||
if (a == NIL || Yap_has_signal(YAP_CDOVF_SIGNAL)) {
|
||||
if (!Yap_growheap(FALSE, 0, NULL)) {
|
||||
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap: %s", LOCAL_ErrorMessage);
|
||||
}
|
||||
@@ -929,7 +929,7 @@ YAP_FullLookupAtom(char *c)
|
||||
|
||||
while (TRUE) {
|
||||
at = Yap_FullLookupAtom(c);
|
||||
if (at == NIL || (LOCAL_ActiveSignals & YAP_CDOVF_SIGNAL)) {
|
||||
if (at == NIL || Yap_has_signal(YAP_CDOVF_SIGNAL)) {
|
||||
if (!Yap_growheap(FALSE, 0, NULL)) {
|
||||
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap: %s", LOCAL_ErrorMessage);
|
||||
}
|
||||
@@ -2949,7 +2949,7 @@ YAP_CompileClause(Term t)
|
||||
}
|
||||
YAPLeaveCriticalSection();
|
||||
|
||||
if (LOCAL_ActiveSignals & YAP_CDOVF_SIGNAL) {
|
||||
if (Yap_has_signal( YAP_CDOVF_SIGNAL ) ) {
|
||||
if (!Yap_growheap(FALSE, 0, NULL)) {
|
||||
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap: %s", LOCAL_ErrorMessage);
|
||||
}
|
||||
|
@@ -2515,7 +2515,7 @@ GetDBTerm(DBTerm *DBSP, int src USES_REGS)
|
||||
if (HR+NOf > ASP-EventFlag/sizeof(CELL)) {
|
||||
if (LOCAL_PrologMode & InErrorMode) {
|
||||
if (HR+NOf > ASP)
|
||||
fprintf(GLOBAL_stderr, "\n\n [ FATAL ERROR: No Stack for Error Handling ]\n");
|
||||
fprintf(stderr, "\n\n [ FATAL ERROR: No Stack for Error Handling ]\n");
|
||||
Yap_exit( 1);
|
||||
} else {
|
||||
LOCAL_Error_TYPE = OUT_OF_STACK_ERROR;
|
||||
@@ -4093,7 +4093,7 @@ MyEraseClause(DynamicClause *clau USES_REGS)
|
||||
Yap_FreeCodeSpace((char *)clau);
|
||||
#ifdef DEBUG
|
||||
if (ref->NOfRefsTo)
|
||||
fprintf(GLOBAL_stderr, "Error: references to dynamic clause\n");
|
||||
fprintf(stderr, "Error: references to dynamic clause\n");
|
||||
#endif
|
||||
RemoveDBEntry(ref PASS_REGS);
|
||||
}
|
||||
|
4
C/errors.c
Normal file → Executable file
4
C/errors.c
Normal file → Executable file
@@ -166,7 +166,7 @@ legal_env (CELL *ep USES_REGS)
|
||||
static int
|
||||
YapPutc(int sno, wchar_t ch)
|
||||
{
|
||||
return (putc(ch, GLOBAL_stderr));
|
||||
return (putc(ch, stderr));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1976,7 +1976,7 @@ E);
|
||||
}
|
||||
if (serious) {
|
||||
/* disable active signals at this point */
|
||||
LOCAL_ActiveSignals = 0;
|
||||
LOCAL_FirstActiveSignal = LOCAL_LastActiveSignal = 0;
|
||||
CalculateStackGap( PASS_REGS1 );
|
||||
LOCAL_PrologMode &= ~InErrorMode;
|
||||
LOCK(LOCAL_SignalLock);
|
||||
|
67
C/exec.c
Normal file → Executable file
67
C/exec.c
Normal file → Executable file
@@ -159,15 +159,15 @@ do_execute(Term t, Term mod USES_REGS)
|
||||
/* first do predicate expansion, even before you process signals.
|
||||
This way you don't get to spy goal_expansion(). */
|
||||
if (PRED_GOAL_EXPANSION_ALL) {
|
||||
LOCK(LOCAL_SignalLock);
|
||||
/* disable creeping when we do goal expansion */
|
||||
if (LOCAL_ActiveSignals & (YAP_CREEP_SIGNAL) && !LOCAL_InterruptsDisabled) {
|
||||
LOCAL_ActiveSignals &= ~(YAP_CREEP_SIGNAL);
|
||||
if (!LOCAL_InterruptsDisabled &&
|
||||
Yap_undo_signal( YAP_CREEP_SIGNAL ) ) {
|
||||
CalculateStackGap( PASS_REGS1 );
|
||||
}
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return CallMetaCall(ARG1, mod PASS_REGS);
|
||||
} else if (LOCAL_ActiveSignals && !LOCAL_InterruptsDisabled &&
|
||||
} else if (Yap_has_a_signal() &&
|
||||
!LOCAL_InterruptsDisabled &&
|
||||
!(LOCAL_PrologMode & (AbortMode|InterruptMode|SystemMode))) {
|
||||
return EnterCreepMode(t, mod PASS_REGS);
|
||||
}
|
||||
@@ -332,16 +332,16 @@ do_execute_n(Term t, Term mod, unsigned int n USES_REGS)
|
||||
return CallError(TYPE_ERROR_CALLABLE, t0, mod PASS_REGS);
|
||||
}
|
||||
if (PRED_GOAL_EXPANSION_ALL) {
|
||||
LOCK(LOCAL_SignalLock);
|
||||
/* disable creeping when we do goal expansion */
|
||||
if (LOCAL_ActiveSignals & (YAP_CREEP_SIGNAL) && !LOCAL_InterruptsDisabled) {
|
||||
LOCAL_ActiveSignals &= ~(YAP_CREEP_SIGNAL);
|
||||
if (Yap_has_signal( YAP_CREEP_SIGNAL ) &&
|
||||
!LOCAL_InterruptsDisabled) {
|
||||
Yap_undo_signal( YAP_CREEP_SIGNAL );
|
||||
CalculateStackGap( PASS_REGS1 );
|
||||
}
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
t = copy_execn_to_heap(f, pt, n, arity, mod PASS_REGS);
|
||||
return CallMetaCall(t, mod PASS_REGS);
|
||||
} else if (LOCAL_ActiveSignals && !LOCAL_InterruptsDisabled) {
|
||||
} else if (Yap_has_a_signal() &&
|
||||
!LOCAL_InterruptsDisabled) {
|
||||
return EnterCreepMode(copy_execn_to_heap(f, pt, n, arity, CurrentModule PASS_REGS), mod PASS_REGS);
|
||||
}
|
||||
if (arity > MaxTemps) {
|
||||
@@ -379,12 +379,12 @@ static Int
|
||||
EnterCreepMode(Term t, Term mod USES_REGS) {
|
||||
PredEntry *PredCreep;
|
||||
|
||||
if (LOCAL_ActiveSignals & YAP_CDOVF_SIGNAL) {
|
||||
if (Yap_has_signal( YAP_CDOVF_SIGNAL ) ) {
|
||||
ARG1 = t;
|
||||
if (!Yap_growheap(FALSE, 0, NULL)) {
|
||||
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap at meta-call");
|
||||
}
|
||||
if (!LOCAL_ActiveSignals) {
|
||||
if (!Yap_has_a_signal()) {
|
||||
return do_execute(ARG1, mod PASS_REGS);
|
||||
}
|
||||
}
|
||||
@@ -636,8 +636,7 @@ p_execute_clause( USES_REGS1 )
|
||||
} else {
|
||||
code = Yap_ClauseFromTerm(clt)->ClCode;
|
||||
}
|
||||
if (LOCAL_ActiveSignals & (YAP_CREEP_SIGNAL)) {
|
||||
LOCAL_ActiveSignals &= ~(YAP_CREEP_SIGNAL);
|
||||
if (Yap_undo_signal(YAP_CREEP_SIGNAL)) {
|
||||
Yap_signal(YAP_CREEP_SIGNAL);
|
||||
}
|
||||
return CallPredicate(RepPredProp(pe), cut_cp, code PASS_REGS);
|
||||
@@ -652,18 +651,14 @@ p_execute_in_mod( USES_REGS1 )
|
||||
static Int
|
||||
p_do_goal_expansion( USES_REGS1 )
|
||||
{
|
||||
Int creeping = LOCAL_ActiveSignals & (YAP_CREEP_SIGNAL);
|
||||
Int creeping = Yap_has_signal(YAP_CREEP_SIGNAL);
|
||||
Int out = FALSE;
|
||||
PredEntry *pe;
|
||||
Term cmod = Deref(ARG2);
|
||||
|
||||
ARG2 = ARG3;
|
||||
/* disable creeping */
|
||||
LOCK(LOCAL_SignalLock);
|
||||
LOCAL_ActiveSignals &= ~(YAP_CREEP_SIGNAL);
|
||||
if (!LOCAL_ActiveSignals)
|
||||
CalculateStackGap( PASS_REGS1 );
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
if (creeping)
|
||||
Yap_undo_signal(YAP_CREEP_SIGNAL);
|
||||
|
||||
/* CurMod:goal_expansion(A,B) */
|
||||
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorGoalExpansion2, cmod) ) ) &&
|
||||
@@ -704,28 +699,23 @@ p_do_goal_expansion( USES_REGS1 )
|
||||
out = TRUE;
|
||||
}
|
||||
complete:
|
||||
LOCK(LOCAL_SignalLock);
|
||||
if (creeping) {
|
||||
LOCAL_ActiveSignals |= YAP_CREEP_SIGNAL;
|
||||
Yap_signal( YAP_CREEP_SIGNAL );
|
||||
}
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return out;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_do_term_expansion( USES_REGS1 )
|
||||
{
|
||||
Int creeping = LOCAL_ActiveSignals & (YAP_CREEP_SIGNAL);
|
||||
Int creeping = Yap_has_signal(YAP_CREEP_SIGNAL);
|
||||
Int out = FALSE;
|
||||
PredEntry *pe;
|
||||
Term cmod = CurrentModule;
|
||||
|
||||
/* disable creeping */
|
||||
LOCK(LOCAL_SignalLock);
|
||||
LOCAL_ActiveSignals &= ~(YAP_CREEP_SIGNAL);
|
||||
if (!LOCAL_ActiveSignals)
|
||||
CalculateStackGap( PASS_REGS1 );
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
if (creeping)
|
||||
Yap_undo_signal(YAP_CREEP_SIGNAL);
|
||||
|
||||
/* CurMod:term_expansion(A,B) */
|
||||
if ( (pe = RepPredProp(Yap_GetPredPropByFunc(FunctorTermExpansion, cmod) ) ) &&
|
||||
@@ -752,11 +742,9 @@ p_do_term_expansion( USES_REGS1 )
|
||||
out = TRUE;
|
||||
}
|
||||
complete:
|
||||
LOCK(LOCAL_SignalLock);
|
||||
if (creeping) {
|
||||
LOCAL_ActiveSignals |= YAP_CREEP_SIGNAL;
|
||||
Yap_signal(YAP_CREEP_SIGNAL);
|
||||
}
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -768,7 +756,8 @@ p_execute0( USES_REGS1 )
|
||||
unsigned int arity;
|
||||
Prop pe;
|
||||
|
||||
if (LOCAL_ActiveSignals && !LOCAL_InterruptsDisabled) {
|
||||
if (Yap_has_a_signal() &&
|
||||
!LOCAL_InterruptsDisabled) {
|
||||
return EnterCreepMode(t, mod PASS_REGS);
|
||||
}
|
||||
restart_exec:
|
||||
@@ -898,8 +887,8 @@ p_execute_nonstop( USES_REGS1 )
|
||||
/* N = arity; */
|
||||
/* call may not define new system predicates!! */
|
||||
if (RepPredProp(pe)->PredFlags & SpiedPredFlag) {
|
||||
if (LOCAL_ActiveSignals & (YAP_CREEP_SIGNAL) && !LOCAL_InterruptsDisabled) {
|
||||
LOCAL_ActiveSignals &= ~(YAP_CREEP_SIGNAL);
|
||||
if (!LOCAL_InterruptsDisabled &&
|
||||
Yap_undo_signal(YAP_CREEP_SIGNAL)) {
|
||||
Yap_signal(YAP_CREEP_SIGNAL);
|
||||
}
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
@@ -909,7 +898,7 @@ p_execute_nonstop( USES_REGS1 )
|
||||
}
|
||||
#endif
|
||||
return CallPredicate(RepPredProp(pe), B, RepPredProp(pe)->cs.p_code.TrueCodeOfPred PASS_REGS);
|
||||
} else { if (LOCAL_ActiveSignals & YAP_CREEP_SIGNAL &&
|
||||
} else { if (Yap_has_signal( YAP_CREEP_SIGNAL ) &&
|
||||
!LOCAL_InterruptsDisabled &&
|
||||
(!(RepPredProp(pe)->PredFlags & (AsmPredFlag|CPredFlag)) ||
|
||||
RepPredProp(pe)->OpcodeOfPred == Yap_opcode(_call_bfunc_xx))) {
|
||||
@@ -1087,7 +1076,7 @@ exec_absmi(int top USES_REGS)
|
||||
ASP = (CELL *)PROTECT_FROZEN_B(B);
|
||||
LOCK(LOCAL_SignalLock);
|
||||
/* forget any signals active, we're reborne */
|
||||
LOCAL_ActiveSignals = 0;
|
||||
LOCAL_FirstActiveSignal = LOCAL_LastActiveSignal;
|
||||
CalculateStackGap( PASS_REGS1 );
|
||||
LOCAL_PrologMode = UserMode;
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
@@ -1120,8 +1109,8 @@ exec_absmi(int top USES_REGS)
|
||||
YENV[E_CB] = Unsigned (B);
|
||||
out = Yap_absmi(0);
|
||||
/* make sure we don't leave a FAIL signal hanging around */
|
||||
LOCAL_ActiveSignals &= ~YAP_FAIL_SIGNAL;
|
||||
if (!LOCAL_ActiveSignals)
|
||||
Yap_undo_signal( YAP_FAIL_SIGNAL );
|
||||
if (!Yap_has_a_signal())
|
||||
CalculateStackGap( PASS_REGS1 );
|
||||
return out;
|
||||
}
|
||||
|
138
C/grow.c
138
C/grow.c
@@ -92,7 +92,7 @@ static void
|
||||
SetHeapRegs(int copying_threads USES_REGS)
|
||||
{
|
||||
#ifdef undf7
|
||||
fprintf(GLOBAL_stderr,"HeapBase = %x\tHeapTop=%x\nGlobalBase=%x\tGlobalTop=%x\nLocalBase=%x\tLocatTop=%x\n", Yap_HeapBase, HeapTop, LOCAL_GlobalBase, H, LCL0, ASP);
|
||||
Sfprintf(GLOBAL_stderr,"HeapBase = %x\tHeapTop=%x\nGlobalBase=%x\tGlobalTop=%x\nLocalBase=%x\tLocatTop=%x\n", Yap_HeapBase, HeapTop, LOCAL_GlobalBase, H, LCL0, ASP);
|
||||
#endif
|
||||
/* The old stack pointers */
|
||||
LOCAL_OldLCL0 = LCL0;
|
||||
@@ -355,7 +355,7 @@ AdjustAppl(register CELL t0 USES_REGS)
|
||||
#ifdef DEBUG
|
||||
else {
|
||||
/* strange cell */
|
||||
/* fprintf(GLOBAL_stderr,"% garbage appl %lx found in stacks by stack shifter\n", t0);*/
|
||||
/* Sfprintf(GLOBAL_stderr,"% garbage appl %lx found in stacks by stack shifter\n", t0);*/
|
||||
}
|
||||
#endif
|
||||
return(t0);
|
||||
@@ -373,7 +373,7 @@ AdjustPair(register CELL t0 USES_REGS)
|
||||
else if (IsHeapP(t))
|
||||
return (AbsPair(CellPtoHeapAdjust(t)));
|
||||
#ifdef DEBUG
|
||||
/* fprintf(GLOBAL_stderr,"% garbage pair %lx found in stacks by stack shifter\n", t0);*/
|
||||
/* Sfprintf(GLOBAL_stderr,"% garbage pair %lx found in stacks by stack shifter\n", t0);*/
|
||||
#endif
|
||||
return(t0);
|
||||
}
|
||||
@@ -812,13 +812,13 @@ static_growheap(long size, int fix_code, struct intermediates *cip, tr_fr_ptr *o
|
||||
LOCAL_heap_overflows++;
|
||||
if (gc_verbose) {
|
||||
#if defined(YAPOR_THREADS)
|
||||
fprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
|
||||
Sfprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
|
||||
#endif
|
||||
fprintf(GLOBAL_stderr, "%% Database Overflow %d\n", LOCAL_heap_overflows);
|
||||
fprintf(GLOBAL_stderr, "%% growing the heap %ld bytes\n", size);
|
||||
Sfprintf(GLOBAL_stderr, "%% Database Overflow %d\n", LOCAL_heap_overflows);
|
||||
Sfprintf(GLOBAL_stderr, "%% growing the heap %ld bytes\n", size);
|
||||
}
|
||||
/* CreepFlag is set to force heap expansion */
|
||||
if (LOCAL_ActiveSignals == YAP_CDOVF_SIGNAL) {
|
||||
if ( Yap_only_has_signal( YAP_CDOVF_SIGNAL) ) {
|
||||
LOCK(LOCAL_SignalLock);
|
||||
CalculateStackGap( PASS_REGS1 );
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
@@ -858,8 +858,8 @@ static_growheap(long size, int fix_code, struct intermediates *cip, tr_fr_ptr *o
|
||||
growth_time = Yap_cputime()-start_growth_time;
|
||||
LOCAL_total_heap_overflow_time += growth_time;
|
||||
if (gc_verbose) {
|
||||
fprintf(GLOBAL_stderr, "%% took %g sec\n", (double)growth_time/1000);
|
||||
fprintf(GLOBAL_stderr, "%% Total of %g sec expanding Database\n", (double)LOCAL_total_heap_overflow_time/1000);
|
||||
Sfprintf(GLOBAL_stderr, "%% took %g sec\n", (double)growth_time/1000);
|
||||
Sfprintf(GLOBAL_stderr, "%% Total of %g sec expanding Database\n", (double)LOCAL_total_heap_overflow_time/1000);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
@@ -958,10 +958,10 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit USES_REGS)
|
||||
vb_msg2 = "Delay";
|
||||
}
|
||||
#if defined(YAPOR_THREADS)
|
||||
fprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
|
||||
Sfprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
|
||||
#endif
|
||||
fprintf(GLOBAL_stderr, "%% %cO %s Overflow %d\n", vb_msg1, vb_msg2, LOCAL_delay_overflows);
|
||||
fprintf(GLOBAL_stderr, "%% %cO growing the stacks %ld bytes\n", vb_msg1, size);
|
||||
Sfprintf(GLOBAL_stderr, "%% %cO %s Overflow %d\n", vb_msg1, vb_msg2, LOCAL_delay_overflows);
|
||||
Sfprintf(GLOBAL_stderr, "%% %cO growing the stacks %ld bytes\n", vb_msg1, size);
|
||||
}
|
||||
ASP -= 256;
|
||||
YAPEnterCriticalSection();
|
||||
@@ -1042,8 +1042,8 @@ static_growglobal(long request, CELL **ptr, CELL *hsplit USES_REGS)
|
||||
growth_time = Yap_cputime()-start_growth_time;
|
||||
LOCAL_total_delay_overflow_time += growth_time;
|
||||
if (gc_verbose) {
|
||||
fprintf(GLOBAL_stderr, "%% %cO took %g sec\n", vb_msg1, (double)growth_time/1000);
|
||||
fprintf(GLOBAL_stderr, "%% %cO Total of %g sec expanding stacks \n", vb_msg1, (double)LOCAL_total_delay_overflow_time/1000);
|
||||
Sfprintf(GLOBAL_stderr, "%% %cO took %g sec\n", vb_msg1, (double)growth_time/1000);
|
||||
Sfprintf(GLOBAL_stderr, "%% %cO Total of %g sec expanding stacks \n", vb_msg1, (double)LOCAL_total_delay_overflow_time/1000);
|
||||
}
|
||||
LeaveGrowMode(GrowStackMode);
|
||||
if (hsplit) {
|
||||
@@ -1318,11 +1318,7 @@ do_growheap(int fix_code, UInt in_size, struct intermediates *cip, tr_fr_ptr *ol
|
||||
fix_tabling_info( PASS_REGS1 );
|
||||
#endif /* TABLING */
|
||||
if (sz >= sizeof(CELL) * K16) {
|
||||
LOCK(LOCAL_SignalLock);
|
||||
LOCAL_ActiveSignals &= ~YAP_CDOVF_SIGNAL;
|
||||
if (!LOCAL_ActiveSignals)
|
||||
CalculateStackGap( PASS_REGS1 );
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
Yap_undo_signal( YAP_CDOVF_SIGNAL );
|
||||
return TRUE;
|
||||
}
|
||||
/* failed */
|
||||
@@ -1375,12 +1371,7 @@ growatomtable( USES_REGS1 )
|
||||
if (nsize -AtomHashTableSize > 4*1024*1024)
|
||||
nsize = AtomHashTableSize+4*1024*1024+7919;
|
||||
|
||||
LOCK(LOCAL_SignalLock);
|
||||
if (LOCAL_ActiveSignals == YAP_CDOVF_SIGNAL) {
|
||||
CalculateStackGap( PASS_REGS1 );
|
||||
}
|
||||
LOCAL_ActiveSignals &= ~YAP_CDOVF_SIGNAL;
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
Yap_undo_signal( YAP_CDOVF_SIGNAL );
|
||||
while ((ntb = (AtomHashEntry *)Yap_AllocCodeSpace(nsize*sizeof(AtomHashEntry))) == NULL) {
|
||||
/* leave for next time */
|
||||
#if !USE_SYSTEM_MALLOC
|
||||
@@ -1391,10 +1382,10 @@ growatomtable( USES_REGS1 )
|
||||
LOCAL_atom_table_overflows ++;
|
||||
if (gc_verbose) {
|
||||
#if defined(YAPOR_THREADS)
|
||||
fprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
|
||||
Sfprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
|
||||
#endif
|
||||
fprintf(GLOBAL_stderr, "%% Atom Table Overflow %d\n", LOCAL_atom_table_overflows );
|
||||
fprintf(GLOBAL_stderr, "%% growing the atom table to %ld entries\n", (long int)(nsize));
|
||||
Sfprintf(GLOBAL_stderr, "%% Atom Table Overflow %d\n", LOCAL_atom_table_overflows );
|
||||
Sfprintf(GLOBAL_stderr, "%% growing the atom table to %ld entries\n", (long int)(nsize));
|
||||
}
|
||||
YAPEnterCriticalSection();
|
||||
init_new_table(ntb, nsize);
|
||||
@@ -1406,8 +1397,8 @@ growatomtable( USES_REGS1 )
|
||||
growth_time = Yap_cputime()-start_growth_time;
|
||||
LOCAL_total_atom_table_overflow_time += growth_time;
|
||||
if (gc_verbose) {
|
||||
fprintf(GLOBAL_stderr, "%% took %g sec\n", (double)growth_time/1000);
|
||||
fprintf(GLOBAL_stderr, "%% Total of %g sec expanding atom table \n", (double)LOCAL_total_atom_table_overflow_time/1000);
|
||||
Sfprintf(GLOBAL_stderr, "%% took %g sec\n", (double)growth_time/1000);
|
||||
Sfprintf(GLOBAL_stderr, "%% Total of %g sec expanding atom table \n", (double)LOCAL_total_atom_table_overflow_time/1000);
|
||||
}
|
||||
#if USE_SYSTEM_MALLOC
|
||||
return TRUE;
|
||||
@@ -1435,14 +1426,9 @@ Yap_growheap(int fix_code, size_t in_size, void *cip)
|
||||
#if (THREADS) || YAPOR
|
||||
res = FALSE;
|
||||
if (NOfAtoms > 2*AtomHashTableSize || blob_overflow) {
|
||||
LOCK(LOCAL_SignalLock);
|
||||
if (LOCAL_ActiveSignals == YAP_CDOVF_SIGNAL) {
|
||||
CalculateStackGap( PASS_REGS1 );
|
||||
}
|
||||
LOCAL_ActiveSignals &= ~YAP_CDOVF_SIGNAL;
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return TRUE;
|
||||
}
|
||||
Yap_undo_signal( YAP_CDOVF_SIGNAL );
|
||||
return TRUE;
|
||||
}
|
||||
#else
|
||||
if (NOfAtoms > 2*AtomHashTableSize || blob_overflow) {
|
||||
UInt n = NOfAtoms;
|
||||
@@ -1455,12 +1441,7 @@ Yap_growheap(int fix_code, size_t in_size, void *cip)
|
||||
NOfAtoms+1 > 2*AtomHashTableSize)) {
|
||||
res = growatomtable( PASS_REGS1 );
|
||||
} else {
|
||||
LOCK(LOCAL_SignalLock);
|
||||
if (LOCAL_ActiveSignals == YAP_CDOVF_SIGNAL) {
|
||||
CalculateStackGap( PASS_REGS1 );
|
||||
}
|
||||
LOCAL_ActiveSignals &= ~YAP_CDOVF_SIGNAL;
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
Yap_undo_signal( YAP_CDOVF_SIGNAL );
|
||||
return TRUE;
|
||||
}
|
||||
LeaveGrowMode(GrowHeapMode);
|
||||
@@ -1660,22 +1641,22 @@ growstack(size_t size USES_REGS)
|
||||
LOCAL_stack_overflows++;
|
||||
if (gc_verbose) {
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
fprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
|
||||
Sfprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
|
||||
#endif
|
||||
fprintf(GLOBAL_stderr, "%% Stack Overflow %d\n", LOCAL_stack_overflows);
|
||||
fprintf(GLOBAL_stderr, "%% Global: %8ld cells (%p-%p)\n", (unsigned long int)(HR-(CELL *)LOCAL_GlobalBase),LOCAL_GlobalBase,HR);
|
||||
fprintf(GLOBAL_stderr, "%% Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
|
||||
fprintf(GLOBAL_stderr, "%% Trail:%8ld cells (%p-%p)\n",
|
||||
Sfprintf(GLOBAL_stderr, "%% Stack Overflow %d\n", LOCAL_stack_overflows);
|
||||
Sfprintf(GLOBAL_stderr, "%% Global: %8ld cells (%p-%p)\n", (unsigned long int)(HR-(CELL *)LOCAL_GlobalBase),LOCAL_GlobalBase,HR);
|
||||
Sfprintf(GLOBAL_stderr, "%% Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
|
||||
Sfprintf(GLOBAL_stderr, "%% Trail:%8ld cells (%p-%p)\n",
|
||||
(unsigned long int)(TR-(tr_fr_ptr)LOCAL_TrailBase),LOCAL_TrailBase,TR);
|
||||
fprintf(GLOBAL_stderr, "%% Growing the stacks " UInt_FORMAT " bytes\n", (UInt) size);
|
||||
Sfprintf(GLOBAL_stderr, "%% Growing the stacks " UInt_FORMAT " bytes\n", (UInt) size);
|
||||
}
|
||||
if (!execute_growstack(size, FALSE, FALSE, NULL, NULL, NULL PASS_REGS))
|
||||
return FALSE;
|
||||
growth_time = Yap_cputime()-start_growth_time;
|
||||
LOCAL_total_stack_overflow_time += growth_time;
|
||||
if (gc_verbose) {
|
||||
fprintf(GLOBAL_stderr, "%% took %g sec\n", (double)growth_time/1000);
|
||||
fprintf(GLOBAL_stderr, "%% Total of %g sec expanding stacks \n", (double)LOCAL_total_stack_overflow_time/1000);
|
||||
Sfprintf(GLOBAL_stderr, "%% took %g sec\n", (double)growth_time/1000);
|
||||
Sfprintf(GLOBAL_stderr, "%% Total of %g sec expanding stacks \n", (double)LOCAL_total_stack_overflow_time/1000);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1698,14 +1679,14 @@ Yap_growstack_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
||||
LOCAL_stack_overflows++;
|
||||
if (gc_verbose) {
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
fprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
|
||||
Sfprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
|
||||
#endif
|
||||
fprintf(GLOBAL_stderr, "%% Stack Overflow %d\n", LOCAL_stack_overflows);
|
||||
fprintf(GLOBAL_stderr, "%% Global: %8ld cells (%p-%p)\n", (unsigned long int)(HR-(CELL *)LOCAL_GlobalBase),LOCAL_GlobalBase,HR);
|
||||
fprintf(GLOBAL_stderr, "%% Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
|
||||
fprintf(GLOBAL_stderr, "%% Trail:%8ld cells (%p-%p)\n",
|
||||
Sfprintf(GLOBAL_stderr, "%% Stack Overflow %d\n", LOCAL_stack_overflows);
|
||||
Sfprintf(GLOBAL_stderr, "%% Global: %8ld cells (%p-%p)\n", (unsigned long int)(HR-(CELL *)LOCAL_GlobalBase),LOCAL_GlobalBase,HR);
|
||||
Sfprintf(GLOBAL_stderr, "%% Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
|
||||
Sfprintf(GLOBAL_stderr, "%% Trail:%8ld cells (%p-%p)\n",
|
||||
(unsigned long int)(TR-(tr_fr_ptr)LOCAL_TrailBase),LOCAL_TrailBase,TR);
|
||||
fprintf(GLOBAL_stderr, "%% Growing the stacks %ld bytes\n", (unsigned long int)size);
|
||||
Sfprintf(GLOBAL_stderr, "%% Growing the stacks %ld bytes\n", (unsigned long int)size);
|
||||
}
|
||||
if (!execute_growstack(size, FALSE, TRUE, old_trp, tksp, vep PASS_REGS)) {
|
||||
LeaveGrowMode(GrowStackMode);
|
||||
@@ -1714,8 +1695,8 @@ Yap_growstack_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
|
||||
growth_time = Yap_cputime()-start_growth_time;
|
||||
LOCAL_total_stack_overflow_time += growth_time;
|
||||
if (gc_verbose) {
|
||||
fprintf(GLOBAL_stderr, "%% took %g sec\n", (double)growth_time/1000);
|
||||
fprintf(GLOBAL_stderr, "%% Total of %g sec expanding stacks \n", (double)LOCAL_total_stack_overflow_time/1000);
|
||||
Sfprintf(GLOBAL_stderr, "%% took %g sec\n", (double)growth_time/1000);
|
||||
Sfprintf(GLOBAL_stderr, "%% Total of %g sec expanding stacks \n", (double)LOCAL_total_stack_overflow_time/1000);
|
||||
}
|
||||
LeaveGrowMode(GrowStackMode);
|
||||
return TRUE;
|
||||
@@ -1746,16 +1727,16 @@ static int do_growtrail(long size, int contiguous_only, int in_parser, tr_fr_ptr
|
||||
LOCAL_trail_overflows++;
|
||||
if (gc_verbose) {
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
fprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
|
||||
Sfprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
|
||||
#endif
|
||||
fprintf(GLOBAL_stderr, "%% Trail Overflow %d\n", LOCAL_trail_overflows);
|
||||
Sfprintf(GLOBAL_stderr, "%% Trail Overflow %d\n", LOCAL_trail_overflows);
|
||||
#if USE_SYSTEM_MALLOC
|
||||
fprintf(GLOBAL_stderr, "%% Heap: %8ld cells (%p-%p)\n", (unsigned long int)(HR-(CELL *)LOCAL_GlobalBase),(CELL *)LOCAL_GlobalBase,HR);
|
||||
fprintf(GLOBAL_stderr, "%% Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
|
||||
fprintf(GLOBAL_stderr, "%% Trail:%8ld cells (%p-%p)\n",
|
||||
Sfprintf(GLOBAL_stderr, "%% Heap: %8ld cells (%p-%p)\n", (unsigned long int)(HR-(CELL *)LOCAL_GlobalBase),(CELL *)LOCAL_GlobalBase,HR);
|
||||
Sfprintf(GLOBAL_stderr, "%% Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
|
||||
Sfprintf(GLOBAL_stderr, "%% Trail:%8ld cells (%p-%p)\n",
|
||||
(unsigned long int)(TR-(tr_fr_ptr)LOCAL_TrailBase),LOCAL_TrailBase,TR);
|
||||
#endif
|
||||
fprintf(GLOBAL_stderr, "%% growing the trail %ld bytes\n", size);
|
||||
Sfprintf(GLOBAL_stderr, "%% growing the trail %ld bytes\n", size);
|
||||
}
|
||||
LOCAL_ErrorMessage = NULL;
|
||||
if (!GLOBAL_AllowTrailExpansion) {
|
||||
@@ -1788,15 +1769,10 @@ static int do_growtrail(long size, int contiguous_only, int in_parser, tr_fr_ptr
|
||||
growth_time = Yap_cputime()-start_growth_time;
|
||||
LOCAL_total_trail_overflow_time += growth_time;
|
||||
if (gc_verbose) {
|
||||
fprintf(GLOBAL_stderr, "%% took %g sec\n", (double)growth_time/1000);
|
||||
fprintf(GLOBAL_stderr, "%% Total of %g sec expanding trail \n", (double)LOCAL_total_trail_overflow_time/1000);
|
||||
Sfprintf(GLOBAL_stderr, "%% took %g sec\n", (double)growth_time/1000);
|
||||
Sfprintf(GLOBAL_stderr, "%% Total of %g sec expanding trail \n", (double)LOCAL_total_trail_overflow_time/1000);
|
||||
}
|
||||
LOCK(LOCAL_SignalLock);
|
||||
if (LOCAL_ActiveSignals == YAP_TROVF_SIGNAL) {
|
||||
CalculateStackGap( PASS_REGS1 );
|
||||
}
|
||||
LOCAL_ActiveSignals &= ~YAP_TROVF_SIGNAL;
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
Yap_undo_signal( YAP_TROVF_SIGNAL );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1923,13 +1899,13 @@ Yap_CopyThreadStacks(int worker_q, int worker_p, int incremental)
|
||||
LOCAL_stack_overflows++;
|
||||
if (gc_verbose) {
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
fprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
|
||||
Sfprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
|
||||
#endif
|
||||
fprintf(GLOBAL_stderr, "%% Stack Overflow %d\n", LOCAL_stack_overflows);
|
||||
fprintf(GLOBAL_stderr, "%% Stack: %8ld cells (%p-%p)\n", (unsigned long int)(LCL0-(CELL *)LOCAL_GlobalBase),LOCAL_GlobalBase,LCL0);
|
||||
fprintf(GLOBAL_stderr, "%% Trail:%8ld cells (%p-%p)\n",
|
||||
Sfprintf(GLOBAL_stderr, "%% Stack Overflow %d\n", LOCAL_stack_overflows);
|
||||
Sfprintf(GLOBAL_stderr, "%% Stack: %8ld cells (%p-%p)\n", (unsigned long int)(LCL0-(CELL *)LOCAL_GlobalBase),LOCAL_GlobalBase,LCL0);
|
||||
Sfprintf(GLOBAL_stderr, "%% Trail:%8ld cells (%p-%p)\n",
|
||||
(unsigned long int)(TR-(tr_fr_ptr)LOCAL_TrailBase),LOCAL_TrailBase,TR);
|
||||
fprintf(GLOBAL_stderr, "%% Growing the stacks %ld bytes\n", diff);
|
||||
Sfprintf(GLOBAL_stderr, "%% Growing the stacks %ld bytes\n", diff);
|
||||
}
|
||||
LOCAL_GDiff = LOCAL_GDiff0 = LOCAL_DelayDiff = LOCAL_BaseDiff = (newq-oldq);
|
||||
LOCAL_TrDiff = LOCAL_LDiff = diff + LOCAL_GDiff;
|
||||
@@ -1955,8 +1931,8 @@ Yap_CopyThreadStacks(int worker_q, int worker_p, int incremental)
|
||||
growth_time = Yap_cputime()-start_growth_time;
|
||||
LOCAL_total_stack_overflow_time += growth_time;
|
||||
if (gc_verbose) {
|
||||
fprintf(GLOBAL_stderr, "%% took %g sec\n", (double)growth_time/1000);
|
||||
fprintf(GLOBAL_stderr, "%% Total of %g sec expanding stacks \n", (double)LOCAL_total_stack_overflow_time/1000);
|
||||
Sfprintf(GLOBAL_stderr, "%% took %g sec\n", (double)growth_time/1000);
|
||||
Sfprintf(GLOBAL_stderr, "%% Total of %g sec expanding stacks \n", (double)LOCAL_total_stack_overflow_time/1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
108
C/heapgc.c
Normal file → Executable file
108
C/heapgc.c
Normal file → Executable file
@@ -1021,17 +1021,17 @@ inc_vars_of_type(CELL *curr,gc_types val) {
|
||||
static void
|
||||
put_type_info(unsigned long total)
|
||||
{
|
||||
fprintf(GLOBAL_stderr,"%% type info for %lu cells\n", total);
|
||||
fprintf(GLOBAL_stderr,"%% %lu vars\n", vars[gc_var]);
|
||||
fprintf(GLOBAL_stderr,"%% %lu refs\n", vars[gc_ref]);
|
||||
fprintf(GLOBAL_stderr,"%% %lu references from env\n", env_vars);
|
||||
fprintf(GLOBAL_stderr,"%% %lu atoms\n", vars[gc_atom]);
|
||||
fprintf(GLOBAL_stderr,"%% %lu small ints\n", vars[gc_int]);
|
||||
fprintf(GLOBAL_stderr,"%% %lu other numbers\n", vars[gc_num]);
|
||||
fprintf(GLOBAL_stderr,"%% %lu lists\n", vars[gc_list]);
|
||||
fprintf(GLOBAL_stderr,"%% %lu compound terms\n", vars[gc_appl]);
|
||||
fprintf(GLOBAL_stderr,"%% %lu functors\n", vars[gc_func]);
|
||||
fprintf(GLOBAL_stderr,"%% %lu suspensions\n", vars[gc_susp]);
|
||||
fprintf(stderr,"%% type info for %lu cells\n", total);
|
||||
fprintf(stderr,"%% %lu vars\n", vars[gc_var]);
|
||||
fprintf(stderr,"%% %lu refs\n", vars[gc_ref]);
|
||||
fprintf(stderr,"%% %lu references from env\n", env_vars);
|
||||
fprintf(stderr,"%% %lu atoms\n", vars[gc_atom]);
|
||||
fprintf(stderr,"%% %lu small ints\n", vars[gc_int]);
|
||||
fprintf(stderr,"%% %lu other numbers\n", vars[gc_num]);
|
||||
fprintf(stderr,"%% %lu lists\n", vars[gc_list]);
|
||||
fprintf(stderr,"%% %lu compound terms\n", vars[gc_appl]);
|
||||
fprintf(stderr,"%% %lu functors\n", vars[gc_func]);
|
||||
fprintf(stderr,"%% %lu suspensions\n", vars[gc_susp]);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1269,7 +1269,7 @@ mark_variable(CELL_PTR current USES_REGS)
|
||||
goto begin;
|
||||
#ifdef DEBUG
|
||||
} else if (next < (CELL *)LOCAL_GlobalBase || next > (CELL *)LOCAL_TrailTop) {
|
||||
fprintf(GLOBAL_stderr, "OOPS in GC: marking, current=%p, *current=" UInt_FORMAT " next=%p\n", current, ccur, next);
|
||||
fprintf(stderr, "OOPS in GC: marking, current=%p, *current=" UInt_FORMAT " next=%p\n", current, ccur, next);
|
||||
#endif
|
||||
} else {
|
||||
#ifdef COROUTING
|
||||
@@ -1576,7 +1576,7 @@ mark_environments(CELL_PTR gc_ENV, OPREG size, CELL *pvbmap USES_REGS)
|
||||
// printf("MARK %p--%p\n", gc_ENV, gc_ENV-size);
|
||||
#ifdef DEBUG
|
||||
if (size < 0 || size > 512)
|
||||
fprintf(GLOBAL_stderr,"OOPS in GC: env size for %p is " UInt_FORMAT "\n", gc_ENV, (CELL)size);
|
||||
fprintf(stderr,"OOPS in GC: env size for %p is " UInt_FORMAT "\n", gc_ENV, (CELL)size);
|
||||
#endif
|
||||
mark_db_fixed((CELL *)gc_ENV[E_CP] PASS_REGS);
|
||||
/* for each saved variable */
|
||||
@@ -1654,14 +1654,14 @@ mark_environments(CELL_PTR gc_ENV, OPREG size, CELL *pvbmap USES_REGS)
|
||||
PredEntry *pe = EnvPreg(gc_ENV[E_CP]);
|
||||
op_numbers op = Yap_op_from_opcode(ENV_ToOp(gc_ENV[E_CP]));
|
||||
#if defined(ANALYST) || defined(DEBUG)
|
||||
fprintf(GLOBAL_stderr,"ENV %p-%p(%d) %s\n", gc_ENV, pvbmap, size-EnvSizeInCells, Yap_op_names[op]);
|
||||
fprintf(stderr,"ENV %p-%p(%d) %s\n", gc_ENV, pvbmap, size-EnvSizeInCells, Yap_op_names[op]);
|
||||
#else
|
||||
fprintf(GLOBAL_stderr,"ENV %p-%p(%d) %d\n", gc_ENV, pvbmap, size-EnvSizeInCells, (int)op);
|
||||
fprintf(stderr,"ENV %p-%p(%d) %d\n", gc_ENV, pvbmap, size-EnvSizeInCells, (int)op);
|
||||
#endif
|
||||
if (pe->ArityOfPE)
|
||||
fprintf(GLOBAL_stderr," %s/%d\n", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE);
|
||||
fprintf(stderr," %s/%d\n", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE);
|
||||
else
|
||||
fprintf(GLOBAL_stderr," %s\n", RepAtom((Atom)(pe->FunctorOfPred))->StrOfAE);
|
||||
fprintf(stderr," %s\n", RepAtom((Atom)(pe->FunctorOfPred))->StrOfAE);
|
||||
}
|
||||
#endif
|
||||
gc_ENV = (CELL_PTR) gc_ENV[E_E]; /* link to prev
|
||||
@@ -1791,7 +1791,7 @@ mark_trail(tr_fr_ptr trail_ptr, tr_fr_ptr trail_base, CELL *gc_H, choiceptr gc_B
|
||||
}
|
||||
#ifdef DEBUG
|
||||
else
|
||||
fprintf(GLOBAL_stderr,"OOPS in GC: weird trail entry at %p:" UInt_FORMAT "\n", &TrailTerm(trail_base), (CELL)cptr);
|
||||
fprintf(stderr,"OOPS in GC: weird trail entry at %p:" UInt_FORMAT "\n", &TrailTerm(trail_base), (CELL)cptr);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -2031,19 +2031,19 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
|
||||
PredEntry *pe = Yap_PredForChoicePt(gc_B);
|
||||
#if defined(ANALYST) || DEBUG
|
||||
if (pe == NULL) {
|
||||
fprintf(GLOBAL_stderr,"%% marked " UInt_FORMAT " (%s)\n", LOCAL_total_marked, Yap_op_names[opnum]);
|
||||
fprintf(stderr,"%% marked " UInt_FORMAT " (%s)\n", LOCAL_total_marked, Yap_op_names[opnum]);
|
||||
} else if (pe->ArityOfPE) {
|
||||
fprintf(GLOBAL_stderr,"%% %s/" UInt_FORMAT " marked " UInt_FORMAT " (%s)\n", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE, LOCAL_total_marked, Yap_op_names[opnum]);
|
||||
fprintf(stderr,"%% %s/" UInt_FORMAT " marked " UInt_FORMAT " (%s)\n", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE, LOCAL_total_marked, Yap_op_names[opnum]);
|
||||
} else {
|
||||
fprintf(GLOBAL_stderr,"%% %s marked " UInt_FORMAT " (%s)\n", RepAtom((Atom)(pe->FunctorOfPred))->StrOfAE, LOCAL_total_marked, Yap_op_names[opnum]);
|
||||
fprintf(stderr,"%% %s marked " UInt_FORMAT " (%s)\n", RepAtom((Atom)(pe->FunctorOfPred))->StrOfAE, LOCAL_total_marked, Yap_op_names[opnum]);
|
||||
}
|
||||
#else
|
||||
if (pe == NULL) {
|
||||
fprintf(GLOBAL_stderr,"%% marked " Int_FORMAT " (%u)\n", LOCAL_total_marked, (unsigned int)opnum);
|
||||
fprintf(stderr,"%% marked " Int_FORMAT " (%u)\n", LOCAL_total_marked, (unsigned int)opnum);
|
||||
} else if (pe->ArityOfPE) {
|
||||
fprintf(GLOBAL_stderr,"%% %s/%lu marked " Int_FORMAT " (%u)\n", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, (unsigned long int)pe->ArityOfPE, LOCAL_total_marked, (unsigned int)opnum);
|
||||
fprintf(stderr,"%% %s/%lu marked " Int_FORMAT " (%u)\n", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, (unsigned long int)pe->ArityOfPE, LOCAL_total_marked, (unsigned int)opnum);
|
||||
} else {
|
||||
fprintf(GLOBAL_stderr,"%% %s marked " Int_FORMAT " (%u)\n", RepAtom((Atom)(pe->FunctorOfPred))->StrOfAE, LOCAL_total_marked, (unsigned int)opnum);
|
||||
fprintf(stderr,"%% %s marked " Int_FORMAT " (%u)\n", RepAtom((Atom)(pe->FunctorOfPred))->StrOfAE, LOCAL_total_marked, (unsigned int)opnum);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -2378,7 +2378,7 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
|
||||
nargs = rtp->u.Otapl.s;
|
||||
break;
|
||||
default:
|
||||
fprintf(GLOBAL_stderr, "OOPS in GC: Unexpected opcode: %d\n", opnum);
|
||||
fprintf(stderr, "OOPS in GC: Unexpected opcode: %d\n", opnum);
|
||||
nargs = 0;
|
||||
#else
|
||||
default:
|
||||
@@ -2842,27 +2842,27 @@ sweep_trail(choiceptr gc_B, tr_fr_ptr old_TR USES_REGS)
|
||||
LOCAL_new_TR = dest;
|
||||
if (is_gc_verbose()) {
|
||||
if (old_TR != (tr_fr_ptr)LOCAL_TrailBase)
|
||||
fprintf(GLOBAL_stderr,
|
||||
fprintf(stderr,
|
||||
"%% Trail: discarded %d (%ld%%) cells out of %ld\n",
|
||||
LOCAL_discard_trail_entries,
|
||||
(unsigned long int)(LOCAL_discard_trail_entries*100/(old_TR-(tr_fr_ptr)LOCAL_TrailBase)),
|
||||
(unsigned long int)(old_TR-(tr_fr_ptr)LOCAL_TrailBase));
|
||||
#ifdef DEBUG
|
||||
if (hp_entrs > 0)
|
||||
fprintf(GLOBAL_stderr,
|
||||
fprintf(stderr,
|
||||
"%% Trail: unmarked %ld dbentries (%ld%%) out of %ld\n",
|
||||
(long int)hp_not_in_use,
|
||||
(long int)(hp_not_in_use*100/hp_entrs),
|
||||
(long int)hp_entrs);
|
||||
if (hp_in_use_erased > 0 && hp_erased > 0)
|
||||
fprintf(GLOBAL_stderr,
|
||||
fprintf(stderr,
|
||||
"%% Trail: deleted %ld dbentries (%ld%%) out of %ld\n",
|
||||
(long int)hp_erased,
|
||||
(long int)(hp_erased*100/(hp_erased+hp_in_use_erased)),
|
||||
(long int)(hp_erased+hp_in_use_erased));
|
||||
#endif
|
||||
if (OldHeapUsed) {
|
||||
fprintf(GLOBAL_stderr,
|
||||
fprintf(stderr,
|
||||
"%% Heap: recovered %ld bytes (%ld%%) out of %ld\n",
|
||||
(unsigned long int)(OldHeapUsed-HeapUsed),
|
||||
(unsigned long int)((OldHeapUsed-HeapUsed)/(OldHeapUsed/100)),
|
||||
@@ -3030,7 +3030,7 @@ sweep_choicepoints(choiceptr gc_B USES_REGS)
|
||||
|
||||
restart_cp:
|
||||
/*
|
||||
* fprintf(GLOBAL_stderr,"sweeping cps: %x, %x, %x\n",
|
||||
* fprintf(stderr,"sweeping cps: %x, %x, %x\n",
|
||||
* *gc_B,CP_Extra(gc_B),CP_Nargs(gc_B));
|
||||
*/
|
||||
/* any choice point */
|
||||
@@ -3521,12 +3521,12 @@ compact_heap( USES_REGS1 )
|
||||
|
||||
#ifdef DEBUG
|
||||
if (dest != start_from-1)
|
||||
fprintf(GLOBAL_stderr,"%% Bad Dest (%lu): %p should be %p\n",
|
||||
fprintf(stderr,"%% Bad Dest (%lu): %p should be %p\n",
|
||||
(unsigned long int)LOCAL_GcCalls,
|
||||
dest,
|
||||
start_from-1);
|
||||
if (LOCAL_total_marked != found_marked)
|
||||
fprintf(GLOBAL_stderr,"%% Upward (%lu): %lu total against %lu found\n",
|
||||
fprintf(stderr,"%% Upward (%lu): %lu total against %lu found\n",
|
||||
(unsigned long int)LOCAL_GcCalls,
|
||||
(unsigned long int)LOCAL_total_marked,
|
||||
(unsigned long int)found_marked);
|
||||
@@ -3595,7 +3595,7 @@ compact_heap( USES_REGS1 )
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (LOCAL_total_marked != found_marked)
|
||||
fprintf(GLOBAL_stderr,"%% Downward (%lu): %lu total against %lu found\n",
|
||||
fprintf(stderr,"%% Downward (%lu): %lu total against %lu found\n",
|
||||
(unsigned long int)LOCAL_GcCalls,
|
||||
(unsigned long int)LOCAL_total_marked,
|
||||
(unsigned long int)found_marked);
|
||||
@@ -3704,12 +3704,12 @@ icompact_heap( USES_REGS1 )
|
||||
|
||||
#ifdef DEBUG
|
||||
if (dest != H0-1)
|
||||
fprintf(GLOBAL_stderr,"%% Bad Dest (%lu): %p should be %p\n",
|
||||
fprintf(stderr,"%% Bad Dest (%lu): %p should be %p\n",
|
||||
(unsigned long int)LOCAL_GcCalls,
|
||||
dest,
|
||||
H0-1);
|
||||
if (LOCAL_total_marked != found_marked)
|
||||
fprintf(GLOBAL_stderr,"%% Upward (%lu): %lu total against %lu found\n",
|
||||
fprintf(stderr,"%% Upward (%lu): %lu total against %lu found\n",
|
||||
(unsigned long int)LOCAL_GcCalls,
|
||||
(unsigned long int)LOCAL_total_marked,
|
||||
(unsigned long int)found_marked);
|
||||
@@ -3767,12 +3767,12 @@ icompact_heap( USES_REGS1 )
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (H0+LOCAL_total_marked != dest)
|
||||
fprintf(GLOBAL_stderr,"%% Downward (%lu): %p total against %p found\n",
|
||||
fprintf(stderr,"%% Downward (%lu): %p total against %p found\n",
|
||||
(unsigned long int)LOCAL_GcCalls,
|
||||
H0+LOCAL_total_marked,
|
||||
dest);
|
||||
if (LOCAL_total_marked != found_marked)
|
||||
fprintf(GLOBAL_stderr,"%% Downward (%lu): %lu total against %lu found\n",
|
||||
fprintf(stderr,"%% Downward (%lu): %lu total against %lu found\n",
|
||||
(unsigned long int)LOCAL_GcCalls,
|
||||
(unsigned long int)LOCAL_total_marked,
|
||||
(unsigned long int)found_marked);
|
||||
@@ -3895,12 +3895,12 @@ compaction_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp USES_REGS)
|
||||
-LOCAL_total_smarked
|
||||
#endif
|
||||
!= LOCAL_iptop-(CELL_PTR *)H && LOCAL_iptop < (CELL_PTR *)ASP -1024)
|
||||
fprintf(GLOBAL_stderr,"%% Oops on LOCAL_iptop-H (%ld) vs %ld\n", (unsigned long int)(LOCAL_iptop-(CELL_PTR *)HR), LOCAL_total_marked);
|
||||
fprintf(stderr,"%% Oops on LOCAL_iptop-H (%ld) vs %ld\n", (unsigned long int)(LOCAL_iptop-(CELL_PTR *)HR), LOCAL_total_marked);
|
||||
*/
|
||||
#endif
|
||||
#if DEBUGX
|
||||
int effectiveness = (((H-H0)-LOCAL_total_marked)*100)/(H-H0);
|
||||
fprintf(GLOBAL_stderr,"%% using pointers (%d)\n", effectiveness);
|
||||
fprintf(stderr,"%% using pointers (%d)\n", effectiveness);
|
||||
#endif
|
||||
if (CurrentH0) {
|
||||
H0 = CurrentH0;
|
||||
@@ -3978,15 +3978,15 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop USES_REGS)
|
||||
if (Yap_GetValue(AtomGcTrace) != TermNil)
|
||||
gc_trace = 1;
|
||||
if (gc_trace) {
|
||||
fprintf(GLOBAL_stderr, "%% gc\n");
|
||||
fprintf(stderr, "%% gc\n");
|
||||
} else if (gc_verbose) {
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
fprintf(GLOBAL_stderr, "%% Worker Id %d:\n", worker_id);
|
||||
fprintf(stderr, "%% Worker Id %d:\n", worker_id);
|
||||
#endif
|
||||
fprintf(GLOBAL_stderr, "%% Start of garbage collection %lu:\n", (unsigned long int)LOCAL_GcCalls);
|
||||
fprintf(GLOBAL_stderr, "%% Global: %8ld cells (%p-%p)\n", (long int)heap_cells,H0,HR);
|
||||
fprintf(GLOBAL_stderr, "%% Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
|
||||
fprintf(GLOBAL_stderr, "%% Trail:%8ld cells (%p-%p)\n",
|
||||
fprintf(stderr, "%% Start of garbage collection %lu:\n", (unsigned long int)LOCAL_GcCalls);
|
||||
fprintf(stderr, "%% Global: %8ld cells (%p-%p)\n", (long int)heap_cells,H0,HR);
|
||||
fprintf(stderr, "%% Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
|
||||
fprintf(stderr, "%% Trail:%8ld cells (%p-%p)\n",
|
||||
(unsigned long int)(TR-(tr_fr_ptr)LOCAL_TrailBase),LOCAL_TrailBase,TR);
|
||||
}
|
||||
#if !USE_SYSTEM_MALLOC
|
||||
@@ -4105,21 +4105,21 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop USES_REGS)
|
||||
} else
|
||||
effectiveness = 0;
|
||||
if (gc_verbose) {
|
||||
fprintf(GLOBAL_stderr, "%% Mark: Marked %ld cells of %ld (efficiency: %ld%%) in %g sec\n",
|
||||
fprintf(stderr, "%% Mark: Marked %ld cells of %ld (efficiency: %ld%%) in %g sec\n",
|
||||
(long int)tot, (long int)heap_cells, (long int)effectiveness, (double)(m_time-time_start)/1000);
|
||||
if (LOCAL_HGEN-H0)
|
||||
fprintf(GLOBAL_stderr,"%% previous generation has size " UInt_FORMAT ", with " UInt_FORMAT " (" UInt_FORMAT "%%) unmarked\n", (UInt)(LOCAL_HGEN-H0), (UInt)((LOCAL_HGEN-H0)-LOCAL_total_oldies), (UInt)(100*((LOCAL_HGEN-H0)-LOCAL_total_oldies)/(LOCAL_HGEN-H0)));
|
||||
fprintf(stderr,"%% previous generation has size " UInt_FORMAT ", with " UInt_FORMAT " (" UInt_FORMAT "%%) unmarked\n", (UInt)(LOCAL_HGEN-H0), (UInt)((LOCAL_HGEN-H0)-LOCAL_total_oldies), (UInt)(100*((LOCAL_HGEN-H0)-LOCAL_total_oldies)/(LOCAL_HGEN-H0)));
|
||||
#ifdef INSTRUMENT_GC
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<16; i++) {
|
||||
if (chain[i]) {
|
||||
fprintf(GLOBAL_stderr, "%% chain[%d]=%lu\n", i, chain[i]);
|
||||
fprintf(stderr, "%% chain[%d]=%lu\n", i, chain[i]);
|
||||
}
|
||||
}
|
||||
put_type_info((unsigned long int)tot);
|
||||
fprintf(GLOBAL_stderr,"%% %lu/%ld before and %lu/%ld after\n", old_vars, (unsigned long int)(B->cp_h-H0), new_vars, (unsigned long int)(H-B->cp_h));
|
||||
fprintf(GLOBAL_stderr,"%% %ld choicepoints\n", num_bs);
|
||||
fprintf(stderr,"%% %lu/%ld before and %lu/%ld after\n", old_vars, (unsigned long int)(B->cp_h-H0), new_vars, (unsigned long int)(H-B->cp_h));
|
||||
fprintf(stderr,"%% %ld choicepoints\n", num_bs);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -4128,7 +4128,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop USES_REGS)
|
||||
TR = old_TR;
|
||||
pop_registers(predarity, nextop PASS_REGS);
|
||||
TR = LOCAL_new_TR;
|
||||
/* fprintf(GLOBAL_stderr,"NEW LOCAL_HGEN %ld (%ld)\n", H-H0, LOCAL_HGEN-H0);*/
|
||||
/* fprintf(stderr,"NEW LOCAL_HGEN %ld (%ld)\n", H-H0, LOCAL_HGEN-H0);*/
|
||||
{
|
||||
Term t = MkVarTerm();
|
||||
Yap_UpdateTimedVar(LOCAL_GcGeneration, t);
|
||||
@@ -4136,14 +4136,14 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop USES_REGS)
|
||||
Yap_UpdateTimedVar(LOCAL_GcPhase, MkIntegerTerm(LOCAL_GcCurrentPhase));
|
||||
c_time = Yap_cputime();
|
||||
if (gc_verbose) {
|
||||
fprintf(GLOBAL_stderr, "%% Compress: took %g sec\n", (double)(c_time-time_start)/1000);
|
||||
fprintf(stderr, "%% Compress: took %g sec\n", (double)(c_time-time_start)/1000);
|
||||
}
|
||||
gc_time += (c_time-time_start);
|
||||
LOCAL_TotGcTime += gc_time;
|
||||
LOCAL_TotGcRecovered += heap_cells-tot;
|
||||
if (gc_verbose) {
|
||||
fprintf(GLOBAL_stderr, "%% GC %lu took %g sec, total of %g sec doing GC so far.\n", (unsigned long int)LOCAL_GcCalls, (double)gc_time/1000, (double)LOCAL_TotGcTime/1000);
|
||||
fprintf(GLOBAL_stderr, "%% Left %ld cells free in stacks.\n",
|
||||
fprintf(stderr, "%% GC %lu took %g sec, total of %g sec doing GC so far.\n", (unsigned long int)LOCAL_GcCalls, (double)gc_time/1000, (double)LOCAL_TotGcTime/1000);
|
||||
fprintf(stderr, "%% Left %ld cells free in stacks.\n",
|
||||
(unsigned long int)(ASP-HR));
|
||||
}
|
||||
check_global();
|
||||
|
@@ -195,8 +195,8 @@ int
|
||||
Yap_DebugPutc(int sno, wchar_t ch)
|
||||
{
|
||||
if (GLOBAL_Option['l' - 96])
|
||||
(void) putc(ch, GLOBAL_logfile);
|
||||
return (putc(ch, GLOBAL_stderr));
|
||||
(void) Sputc(ch, GLOBAL_logfile);
|
||||
return (Sputc(ch, GLOBAL_stderr));
|
||||
}
|
||||
|
||||
void
|
||||
|
2
C/parser.c
Normal file → Executable file
2
C/parser.c
Normal file → Executable file
@@ -128,7 +128,7 @@ Yap_LookupVar(char *var) /* lookup variable in variables table */
|
||||
|
||||
#if DEBUG
|
||||
if (GLOBAL_Option[4])
|
||||
fprintf(GLOBAL_stderr,"[LookupVar %s]", var);
|
||||
fprintf(stderr,"[LookupVar %s]", var);
|
||||
#endif
|
||||
if (var[0] != '_' || var[1] != '\0') {
|
||||
VarEntry **op = &LOCAL_VarTable;
|
||||
|
28
C/pl-yap.c
28
C/pl-yap.c
@@ -1173,7 +1173,7 @@ PL_w32thread_raise(DWORD id, int sig)
|
||||
handling in the Win32 platform.
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
static int thread_highest_id = 1;
|
||||
static int thread_highest_id = 0;
|
||||
|
||||
X_API int
|
||||
PL_w32thread_raise(DWORD id, int sig)
|
||||
@@ -1182,18 +1182,20 @@ PL_w32thread_raise(DWORD id, int sig)
|
||||
if ( sig < 0 || sig > MAXSIGNAL )
|
||||
return FALSE; /* illegal signal */
|
||||
|
||||
LOCK();
|
||||
for(i = 1; i <= thread_highest_id; i++)
|
||||
{ PL_thread_info_t *info = GD->thread.threads[i];
|
||||
LOCK();
|
||||
for(i = 0; i <= thread_highest_id; i++)
|
||||
{ PL_thread_info_t *info = GD->thread.threads[i];
|
||||
|
||||
if ( info && info->w32id == id && info->thread_data )
|
||||
{ Yap_signal(sig); //raiseSignal(info->thread_data, sig);
|
||||
if ( info->w32id )
|
||||
PostThreadMessage(info->w32id, WM_SIGNALLED, 0, 0L);
|
||||
UNLOCK();
|
||||
DEBUG(1, Sdprintf("Signalled %d to thread %d\n", sig, i));
|
||||
return TRUE;
|
||||
}
|
||||
if ( info && info->w32id == id && info->thread_data )
|
||||
{
|
||||
Sfprintf(GLOBAL_stderr, "post %d %d\n\n\n",i, sig);
|
||||
Yap_external_signal(i, sig); //raiseSignal(info->thread_data, sig);
|
||||
if ( info->w32id )
|
||||
PostThreadMessage(info->w32id, WM_SIGNALLED, 0, 0L);
|
||||
UNLOCK();
|
||||
DEBUG(1, Sdprintf("Signalled %d to thread %d\n", sig, i));
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
UNLOCK();
|
||||
|
||||
@@ -1514,7 +1516,7 @@ PL_thread_info_t *
|
||||
SWI_thread_info(int tid, PL_thread_info_t *info)
|
||||
{
|
||||
if (info)
|
||||
REMOTE_PL_local_data_p(tid)->thread.info = info;
|
||||
GD->thread.threads[tid] = REMOTE_PL_local_data_p(tid)->thread.info = info;
|
||||
return REMOTE_PL_local_data_p(tid)->thread.info;
|
||||
}
|
||||
|
||||
|
4
C/scanner.c
Normal file → Executable file
4
C/scanner.c
Normal file → Executable file
@@ -1452,12 +1452,12 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
|
||||
|
||||
default:
|
||||
#if DEBUG
|
||||
fprintf(GLOBAL_stderr, "\n++++ token: wrong char type %c %d\n", ch, chtype(ch));
|
||||
fprintf(stderr, "\n++++ token: wrong char type %c %d\n", ch, chtype(ch));
|
||||
#endif
|
||||
t->Tok = Ord(kind = eot_tok);
|
||||
}
|
||||
#if DEBUG
|
||||
if(GLOBAL_Option[2]) fprintf(GLOBAL_stderr,"[Token %d %ld]",Ord(kind),(unsigned long int)t->TokInfo);
|
||||
if(GLOBAL_Option[2]) fprintf(stderr,"[Token %d %ld]",Ord(kind),(unsigned long int)t->TokInfo);
|
||||
#endif
|
||||
if (LOCAL_ErrorMessage) {
|
||||
/* insert an error token to inform the system of what happened */
|
||||
|
401
C/signals.c
Normal file → Executable file
401
C/signals.c
Normal file → Executable file
@@ -38,27 +38,67 @@ static char SccsId[] = "%W% %G%";
|
||||
#include <wchar.h>
|
||||
|
||||
inline static void
|
||||
do_signal(yap_signals sig USES_REGS)
|
||||
do_signal(int wid, yap_signals sig USES_REGS)
|
||||
{
|
||||
LOCK(LOCAL_SignalLock);
|
||||
if (!LOCAL_InterruptsDisabled) {
|
||||
CreepFlag = Unsigned(LCL0);
|
||||
LOCK(REMOTE_SignalLock(wid));
|
||||
if (!REMOTE_InterruptsDisabled(wid)) {
|
||||
REMOTE_ThreadHandle(wid).current_yaam_regs->CreepFlag_ =
|
||||
Unsigned(REMOTE_ThreadHandle(wid).current_yaam_regs->LCL0_);
|
||||
if (sig != YAP_CREEP_SIGNAL)
|
||||
EventFlag = Unsigned(LCL0);
|
||||
REMOTE_ThreadHandle(wid).current_yaam_regs->EventFlag_ =
|
||||
Unsigned(REMOTE_ThreadHandle(wid).current_yaam_regs->LCL0_);
|
||||
}
|
||||
LOCAL_ActiveSignals |= sig;
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
UInt i = LOCAL_FirstActiveSignal;
|
||||
if (LOCAL_FirstActiveSignal != LOCAL_LastActiveSignal) {
|
||||
do {
|
||||
if (sig == LOCAL_ActiveSignals[i]) {
|
||||
UNLOCK(REMOTE_SignalLock(wid));
|
||||
return;
|
||||
}
|
||||
i++;
|
||||
if (i == LOCAL_MaxActiveSignals)
|
||||
i = 0;
|
||||
} while (i != LOCAL_LastActiveSignal);
|
||||
}
|
||||
LOCAL_ActiveSignals[i] = sig;
|
||||
LOCAL_LastActiveSignal++;
|
||||
if (LOCAL_LastActiveSignal == LOCAL_MaxActiveSignals)
|
||||
LOCAL_LastActiveSignal = 0;
|
||||
UNLOCK(REMOTE_SignalLock(wid));
|
||||
|
||||
}
|
||||
|
||||
inline static void
|
||||
inline static int
|
||||
undo_signal(yap_signals sig USES_REGS)
|
||||
{
|
||||
LOCK(LOCAL_SignalLock);
|
||||
if ((LOCAL_ActiveSignals & ~(YAP_CREEP_SIGNAL)) == sig) {
|
||||
UInt i = LOCAL_FirstActiveSignal;
|
||||
if (LOCAL_FirstActiveSignal != LOCAL_LastActiveSignal) {
|
||||
do {
|
||||
if (sig == LOCAL_ActiveSignals[i])
|
||||
break;
|
||||
i++;
|
||||
if (i == LOCAL_MaxActiveSignals)
|
||||
i = 0;
|
||||
} while (i != LOCAL_LastActiveSignal);
|
||||
}
|
||||
if (i == LOCAL_LastActiveSignal) {
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return FALSE;
|
||||
}
|
||||
while ((i+1) % LOCAL_MaxActiveSignals != LOCAL_LastActiveSignal) {
|
||||
LOCAL_ActiveSignals[i] = LOCAL_ActiveSignals[(i+1) % LOCAL_MaxActiveSignals];
|
||||
i++;
|
||||
}
|
||||
if (LOCAL_LastActiveSignal == 0)
|
||||
LOCAL_LastActiveSignal = LOCAL_MaxActiveSignals-1;
|
||||
else
|
||||
LOCAL_LastActiveSignal--;
|
||||
if (LOCAL_FirstActiveSignal != LOCAL_LastActiveSignal) {
|
||||
CalculateStackGap( PASS_REGS1 );
|
||||
}
|
||||
LOCAL_ActiveSignals &= ~sig;
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Int
|
||||
@@ -70,7 +110,7 @@ p_creep( USES_REGS1 )
|
||||
at = AtomCreep;
|
||||
pred = RepPredProp(PredPropByFunc(Yap_MkFunctor(at, 1),0));
|
||||
CreepCode = pred;
|
||||
do_signal(YAP_CREEP_SIGNAL PASS_REGS);
|
||||
do_signal(worker_id, YAP_CREEP_SIGNAL PASS_REGS);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -83,19 +123,14 @@ p_creep_fail( USES_REGS1 )
|
||||
at = AtomCreep;
|
||||
pred = RepPredProp(PredPropByFunc(Yap_MkFunctor(at, 1),0));
|
||||
CreepCode = pred;
|
||||
do_signal(YAP_CREEP_SIGNAL PASS_REGS);
|
||||
do_signal(worker_id, YAP_CREEP_SIGNAL PASS_REGS);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static Int
|
||||
p_stop_creeping( USES_REGS1 )
|
||||
{
|
||||
LOCK(LOCAL_SignalLock);
|
||||
LOCAL_ActiveSignals &= ~(YAP_CREEP_SIGNAL);
|
||||
if (!LOCAL_ActiveSignals) {
|
||||
CalculateStackGap( PASS_REGS1 );
|
||||
}
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
undo_signal( YAP_CREEP_SIGNAL PASS_REGS );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -103,10 +138,10 @@ static Int
|
||||
p_creep_allowed( USES_REGS1 )
|
||||
{
|
||||
if (PP != NULL) {
|
||||
undo_signal(YAP_CREEP_SIGNAL PASS_REGS);
|
||||
LOCK(LOCAL_SignalLock);
|
||||
if (LOCAL_ActiveSignals & YAP_CREEP_SIGNAL && !LOCAL_InterruptsDisabled) {
|
||||
LOCAL_ActiveSignals &= ~YAP_CREEP_SIGNAL;
|
||||
if (!LOCAL_ActiveSignals)
|
||||
if (!LOCAL_InterruptsDisabled) {
|
||||
if (LOCAL_FirstActiveSignal == LOCAL_LastActiveSignal)
|
||||
CalculateStackGap( PASS_REGS1 );
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
} else {
|
||||
@@ -114,6 +149,7 @@ p_creep_allowed( USES_REGS1 )
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -121,14 +157,109 @@ void
|
||||
Yap_signal(yap_signals sig)
|
||||
{
|
||||
CACHE_REGS
|
||||
do_signal(sig PASS_REGS);
|
||||
do_signal(worker_id, sig PASS_REGS);
|
||||
}
|
||||
|
||||
void
|
||||
Yap_undo_signal(yap_signals sig)
|
||||
Yap_external_signal(int wid, yap_signals sig)
|
||||
{
|
||||
CACHE_REGS
|
||||
undo_signal(sig PASS_REGS);
|
||||
REGSTORE *regcache = REMOTE_ThreadHandle(wid).current_yaam_regs;
|
||||
do_signal(wid, sig PASS_REGS);
|
||||
}
|
||||
|
||||
int
|
||||
Yap_undo_signal__(yap_signals sig USES_REGS)
|
||||
{
|
||||
return undo_signal(sig PASS_REGS);
|
||||
}
|
||||
|
||||
int
|
||||
Yap_has_signal__(yap_signals sig USES_REGS)
|
||||
{
|
||||
LOCK(LOCAL_SignalLock);
|
||||
UInt i = LOCAL_FirstActiveSignal;
|
||||
if (LOCAL_FirstActiveSignal != LOCAL_LastActiveSignal) {
|
||||
do {
|
||||
if (sig == LOCAL_ActiveSignals[i]) {
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return TRUE;
|
||||
}
|
||||
i++;
|
||||
if (i == LOCAL_MaxActiveSignals)
|
||||
i = 0;
|
||||
} while (i != LOCAL_LastActiveSignal);
|
||||
}
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
Yap_has_signals__(yap_signals sig1, yap_signals sig2 USES_REGS)
|
||||
{
|
||||
LOCK(LOCAL_SignalLock);
|
||||
UInt i = LOCAL_FirstActiveSignal;
|
||||
if (LOCAL_FirstActiveSignal != LOCAL_LastActiveSignal) {
|
||||
do {
|
||||
if (sig1 == LOCAL_ActiveSignals[i] ||
|
||||
sig2 == LOCAL_ActiveSignals[i]) {
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return TRUE;
|
||||
}
|
||||
i++;
|
||||
if (i == LOCAL_MaxActiveSignals)
|
||||
i = 0;
|
||||
} while (i != LOCAL_LastActiveSignal);
|
||||
}
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
Yap_only_has_signal__(yap_signals sig USES_REGS)
|
||||
{
|
||||
LOCK(LOCAL_SignalLock);
|
||||
UInt i = LOCAL_FirstActiveSignal;
|
||||
if (LOCAL_FirstActiveSignal != LOCAL_LastActiveSignal) {
|
||||
do {
|
||||
if (sig != LOCAL_ActiveSignals[i]) {
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return FALSE;
|
||||
}
|
||||
i++;
|
||||
if (i == LOCAL_MaxActiveSignals)
|
||||
i = 0;
|
||||
} while (i != LOCAL_LastActiveSignal);
|
||||
} else {
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return FALSE;
|
||||
}
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
Yap_only_has_signals__(yap_signals sig1, yap_signals sig2 USES_REGS)
|
||||
{
|
||||
LOCK(LOCAL_SignalLock);
|
||||
UInt i = LOCAL_FirstActiveSignal;
|
||||
if (LOCAL_FirstActiveSignal != LOCAL_LastActiveSignal) {
|
||||
do {
|
||||
if (sig1 != LOCAL_ActiveSignals[i] &&
|
||||
sig2 != LOCAL_ActiveSignals[i]) {
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return FALSE;
|
||||
}
|
||||
i++;
|
||||
if (i == LOCAL_MaxActiveSignals)
|
||||
i = 0;
|
||||
} while (i != LOCAL_LastActiveSignal);
|
||||
} else {
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return FALSE;
|
||||
}
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -146,155 +277,100 @@ p_debug( USES_REGS1 )
|
||||
static Int
|
||||
p_first_signal( USES_REGS1 )
|
||||
{
|
||||
Atom at;
|
||||
yap_signals sig;
|
||||
|
||||
LOCK(LOCAL_SignalLock);
|
||||
MUTEX_LOCK(&(LOCAL_ThreadHandle.tlock));
|
||||
/* always do wakeups first, because you don't want to keep the
|
||||
non-backtrackable variable bad */
|
||||
if (LOCAL_ActiveSignals & YAP_WAKEUP_SIGNAL) {
|
||||
LOCAL_ActiveSignals &= ~YAP_WAKEUP_SIGNAL;
|
||||
if (LOCAL_FirstActiveSignal != LOCAL_LastActiveSignal) {
|
||||
sig = LOCAL_ActiveSignals[LOCAL_FirstActiveSignal];
|
||||
LOCAL_FirstActiveSignal++;
|
||||
if (LOCAL_FirstActiveSignal == LOCAL_MaxActiveSignals)
|
||||
LOCAL_FirstActiveSignal = 0;
|
||||
} else {
|
||||
sig = YAP_NO_SIGNAL;
|
||||
}
|
||||
switch (sig) {
|
||||
case YAP_INT_SIGNAL:
|
||||
at = AtomSigInt;
|
||||
break;
|
||||
case YAP_CREEP_SIGNAL:
|
||||
at = AtomSigCreep;
|
||||
break;
|
||||
case YAP_TRACE_SIGNAL:
|
||||
at = AtomSigTrace;
|
||||
break;
|
||||
case YAP_DEBUG_SIGNAL:
|
||||
at = AtomSigDebug;
|
||||
break;
|
||||
case YAP_BREAK_SIGNAL:
|
||||
at = AtomSigBreak;
|
||||
break;
|
||||
case YAP_FAIL_SIGNAL:
|
||||
at = AtomFail;
|
||||
break;
|
||||
case YAP_STACK_DUMP_SIGNAL:
|
||||
at = AtomSigStackDump;
|
||||
break;
|
||||
case YAP_STATISTICS_SIGNAL:
|
||||
at = AtomSigStatistics;
|
||||
break;
|
||||
#ifdef SIGALRM
|
||||
case YAP_ALARM_SIGNAL:
|
||||
#endif
|
||||
case YAP_WINTIMER_SIGNAL:
|
||||
at = AtomSigAlarm;
|
||||
break;
|
||||
#ifdef SIGVTALRM
|
||||
case YAP_VTALARM_SIGNAL:
|
||||
at = AtomSigVTAlarm;
|
||||
break;
|
||||
#endif
|
||||
case YAP_WAKEUP_SIGNAL:
|
||||
at = AtomSigWakeUp;
|
||||
break;
|
||||
case YAP_ITI_SIGNAL:
|
||||
at = AtomSigIti;
|
||||
break;
|
||||
#ifdef SIGPIPE
|
||||
case YAP_PIPE_SIGNAL:
|
||||
at = AtomSigPipe;
|
||||
break;
|
||||
#endif
|
||||
#ifdef SIGHUP
|
||||
case YAP_HUP_SIGNAL:
|
||||
at = AtomSigHup;
|
||||
break;
|
||||
#endif
|
||||
#ifdef SIGUSR1
|
||||
case YAP_USR1_SIGNAL:
|
||||
at = AtomSigUsr1;
|
||||
break;
|
||||
#endif
|
||||
#ifdef SIGUSR2
|
||||
case YAP_USR2_SIGNAL:
|
||||
at = AtomSigUsr2;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
MUTEX_UNLOCK(&(LOCAL_ThreadHandle.tlock));
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return Yap_unify(ARG1, MkAtomTerm(AtomSigWakeUp));
|
||||
return FALSE;
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_ITI_SIGNAL) {
|
||||
LOCAL_ActiveSignals &= ~YAP_ITI_SIGNAL;
|
||||
MUTEX_UNLOCK(&(LOCAL_ThreadHandle.tlock));
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return Yap_unify(ARG1, MkAtomTerm(AtomSigIti));
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_INT_SIGNAL) {
|
||||
LOCAL_ActiveSignals &= ~YAP_INT_SIGNAL;
|
||||
MUTEX_UNLOCK(&(LOCAL_ThreadHandle.tlock));
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return Yap_unify(ARG1, MkAtomTerm(AtomSigInt));
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_USR2_SIGNAL) {
|
||||
LOCAL_ActiveSignals &= ~YAP_USR2_SIGNAL;
|
||||
MUTEX_UNLOCK(&(LOCAL_ThreadHandle.tlock));
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return Yap_unify(ARG1, MkAtomTerm(AtomSigUsr2));
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_USR1_SIGNAL) {
|
||||
LOCAL_ActiveSignals &= ~YAP_USR1_SIGNAL;
|
||||
MUTEX_UNLOCK(&(LOCAL_ThreadHandle.tlock));
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return Yap_unify(ARG1, MkAtomTerm(AtomSigUsr1));
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_PIPE_SIGNAL) {
|
||||
LOCAL_ActiveSignals &= ~YAP_PIPE_SIGNAL;
|
||||
#ifdef THREADS
|
||||
MUTEX_UNLOCK(&(LOCAL_ThreadHandle.tlock));
|
||||
#endif
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return Yap_unify(ARG1, MkAtomTerm(AtomSigPipe));
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_HUP_SIGNAL) {
|
||||
LOCAL_ActiveSignals &= ~YAP_HUP_SIGNAL;
|
||||
#ifdef THREADS
|
||||
MUTEX_UNLOCK(&(LOCAL_ThreadHandle.tlock));
|
||||
#endif
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return Yap_unify(ARG1, MkAtomTerm(AtomSigHup));
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_ALARM_SIGNAL) {
|
||||
LOCAL_ActiveSignals &= ~YAP_ALARM_SIGNAL;
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return Yap_unify(ARG1, MkAtomTerm(AtomSigAlarm));
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_VTALARM_SIGNAL) {
|
||||
LOCAL_ActiveSignals &= ~YAP_VTALARM_SIGNAL;
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return Yap_unify(ARG1, MkAtomTerm(AtomSigVTAlarm));
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_CREEP_SIGNAL) {
|
||||
LOCAL_ActiveSignals &= ~YAP_CREEP_SIGNAL;
|
||||
MUTEX_UNLOCK(&(LOCAL_ThreadHandle.tlock));
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return Yap_unify(ARG1, MkAtomTerm(AtomSigCreep));
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_TRACE_SIGNAL) {
|
||||
LOCAL_ActiveSignals &= ~YAP_TRACE_SIGNAL;
|
||||
MUTEX_UNLOCK(&(LOCAL_ThreadHandle.tlock));
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return Yap_unify(ARG1, MkAtomTerm(AtomSigTrace));
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_DEBUG_SIGNAL) {
|
||||
LOCAL_ActiveSignals &= ~YAP_DEBUG_SIGNAL;
|
||||
MUTEX_UNLOCK(&(LOCAL_ThreadHandle.tlock));
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return Yap_unify(ARG1, MkAtomTerm(AtomSigDebug));
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_BREAK_SIGNAL) {
|
||||
LOCAL_ActiveSignals &= ~YAP_BREAK_SIGNAL;
|
||||
MUTEX_UNLOCK(&(LOCAL_ThreadHandle.tlock));
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return Yap_unify(ARG1, MkAtomTerm(AtomSigBreak));
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_STACK_DUMP_SIGNAL) {
|
||||
LOCAL_ActiveSignals &= ~YAP_STACK_DUMP_SIGNAL;
|
||||
MUTEX_UNLOCK(&(LOCAL_ThreadHandle.tlock));
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return Yap_unify(ARG1, MkAtomTerm(AtomSigStackDump));
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_STATISTICS_SIGNAL) {
|
||||
LOCAL_ActiveSignals &= ~YAP_STATISTICS_SIGNAL;
|
||||
MUTEX_UNLOCK(&(LOCAL_ThreadHandle.tlock));
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return Yap_unify(ARG1, MkAtomTerm(AtomSigStatistics));
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_FAIL_SIGNAL) {
|
||||
LOCAL_ActiveSignals &= ~YAP_FAIL_SIGNAL;
|
||||
MUTEX_UNLOCK(&(LOCAL_ThreadHandle.tlock));
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return Yap_unify(ARG1, MkAtomTerm(AtomFail));
|
||||
}
|
||||
MUTEX_UNLOCK(&(LOCAL_ThreadHandle.tlock));
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
return FALSE;
|
||||
return Yap_unify(ARG1, MkAtomTerm(at));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_continue_signals( USES_REGS1 )
|
||||
{
|
||||
yap_signals sig;
|
||||
/* hack to force the signal anew */
|
||||
if (LOCAL_ActiveSignals & YAP_ITI_SIGNAL) {
|
||||
Yap_signal(YAP_ITI_SIGNAL);
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_INT_SIGNAL) {
|
||||
Yap_signal(YAP_INT_SIGNAL);
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_USR2_SIGNAL) {
|
||||
Yap_signal(YAP_USR2_SIGNAL);
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_USR1_SIGNAL) {
|
||||
Yap_signal(YAP_USR1_SIGNAL);
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_HUP_SIGNAL) {
|
||||
Yap_signal(YAP_HUP_SIGNAL);
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_ALARM_SIGNAL) {
|
||||
Yap_signal(YAP_ALARM_SIGNAL);
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_VTALARM_SIGNAL) {
|
||||
Yap_signal(YAP_VTALARM_SIGNAL);
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_CREEP_SIGNAL) {
|
||||
Yap_signal(YAP_CREEP_SIGNAL);
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_DEBUG_SIGNAL) {
|
||||
Yap_signal(YAP_DEBUG_SIGNAL);
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_BREAK_SIGNAL) {
|
||||
Yap_signal(YAP_BREAK_SIGNAL);
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_STACK_DUMP_SIGNAL) {
|
||||
Yap_signal(YAP_STACK_DUMP_SIGNAL);
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_STATISTICS_SIGNAL) {
|
||||
Yap_signal(YAP_STATISTICS_SIGNAL);
|
||||
}
|
||||
if (LOCAL_ActiveSignals & YAP_FAIL_SIGNAL) {
|
||||
Yap_signal(YAP_FAIL_SIGNAL);
|
||||
if (LOCAL_FirstActiveSignal != LOCAL_LastActiveSignal) {
|
||||
sig = LOCAL_ActiveSignals[LOCAL_FirstActiveSignal];
|
||||
Yap_signal(sig);
|
||||
}
|
||||
MUTEX_UNLOCK(&(LOCAL_ThreadHandle.tlock));
|
||||
return TRUE;
|
||||
@@ -314,3 +390,8 @@ Yap_InitSignalCPreds(void)
|
||||
Yap_InitCPred("$debug", 1, p_debug, SafePredFlag|SyncPredFlag);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Yap_InitSignals(int wid)
|
||||
{
|
||||
REMOTE_ActiveSignals(wid) = (UInt *)malloc(sizeof(UInt)*REMOTE_MaxActiveSignals(wid));
|
||||
}
|
||||
|
12
C/stdpreds.c
Normal file → Executable file
12
C/stdpreds.c
Normal file → Executable file
@@ -1298,21 +1298,21 @@ Yap_show_statistics(void)
|
||||
#endif
|
||||
frag = (100.0*(heap_space_taken-HeapUsed))/heap_space_taken;
|
||||
|
||||
fprintf(GLOBAL_stderr, "Code Space: %ld (%ld bytes needed, %ld bytes used, fragmentation %.3f%%).\n",
|
||||
Sfprintf(GLOBAL_stderr, "Code Space: %ld (%ld bytes needed, %ld bytes used, fragmentation %.3f%%).\n",
|
||||
(unsigned long int)(Unsigned (H0) - Unsigned (Yap_HeapBase)),
|
||||
(unsigned long int)(Unsigned(HeapTop)-Unsigned(Yap_HeapBase)),
|
||||
(unsigned long int)(HeapUsed),
|
||||
frag);
|
||||
fprintf(GLOBAL_stderr, "Stack Space: %ld (%ld for Global, %ld for local).\n",
|
||||
Sfprintf(GLOBAL_stderr, "Stack Space: %ld (%ld for Global, %ld for local).\n",
|
||||
(unsigned long int)(sizeof(CELL)*(LCL0-H0)),
|
||||
(unsigned long int)(sizeof(CELL)*(HR-H0)),
|
||||
(unsigned long int)(sizeof(CELL)*(LCL0-ASP)));
|
||||
fprintf(GLOBAL_stderr, "Trail Space: %ld (%ld used).\n",
|
||||
Sfprintf(GLOBAL_stderr, "Trail Space: %ld (%ld used).\n",
|
||||
(unsigned long int)(sizeof(tr_fr_ptr)*(Unsigned(LOCAL_TrailTop)-Unsigned(LOCAL_TrailBase))),
|
||||
(unsigned long int)(sizeof(tr_fr_ptr)*(Unsigned(TR)-Unsigned(LOCAL_TrailBase))));
|
||||
fprintf(GLOBAL_stderr, "Runtime: %lds.\n", (unsigned long int)(runtime ( PASS_REGS1 )));
|
||||
fprintf(GLOBAL_stderr, "Cputime: %lds.\n", (unsigned long int)(Yap_cputime ()));
|
||||
fprintf(GLOBAL_stderr, "Walltime: %lds.\n", (unsigned long int)(Yap_walltime ()));
|
||||
Sfprintf(GLOBAL_stderr, "Runtime: %lds.\n", (unsigned long int)(runtime ( PASS_REGS1 )));
|
||||
Sfprintf(GLOBAL_stderr, "Cputime: %lds.\n", (unsigned long int)(Yap_cputime ()));
|
||||
Sfprintf(GLOBAL_stderr, "Walltime: %lds.\n", (unsigned long int)(Yap_walltime ()));
|
||||
}
|
||||
|
||||
static Int
|
||||
|
17
C/sysbits.c
17
C/sysbits.c
@@ -2303,7 +2303,18 @@ static Int
|
||||
p_shell ( USES_REGS1 )
|
||||
{ /* '$shell'(+SystCommand) */
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
Yap_Error(SYSTEM_ERROR,TermNil,"shell not available in this configuration");
|
||||
/** shell(+Command:text, -Status:integer) is det.
|
||||
|
||||
Run an external command and wait for its completion.
|
||||
*/
|
||||
char *cmd;
|
||||
term_t A1 = Yap_InitSlot(ARG1 PASS_REGS);
|
||||
if ( PL_get_chars(A1, &cmd, CVT_ALL|REP_FN|CVT_EXCEPTION) )
|
||||
{ int rval = System(cmd);
|
||||
|
||||
return rval == 0;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
#else
|
||||
#if HAVE_SYSTEM
|
||||
@@ -2945,7 +2956,7 @@ p_enable_interrupts( USES_REGS1 )
|
||||
LOCAL_InterruptsDisabled--;
|
||||
if (LOCAL_ActiveSignals && !LOCAL_InterruptsDisabled) {
|
||||
CreepFlag = Unsigned(LCL0);
|
||||
if ( LOCAL_ActiveSignals != YAP_CREEP_SIGNAL )
|
||||
if ( !Yap_only_has_signal( YAP_CREEP_SIGNAL ) )
|
||||
EventFlag = Unsigned( LCL0 );
|
||||
}
|
||||
UNLOCK(LOCAL_SignalLock);
|
||||
@@ -3188,7 +3199,7 @@ Yap_InitSysPreds(void)
|
||||
InitLastWtime();
|
||||
Yap_InitCPred ("srandom", 1, p_srandom, SafePredFlag);
|
||||
Yap_InitCPred ("sh", 0, p_sh, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("$shell", 1, p_shell, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("$shell", 1, p_shell, SafePredFlag|SyncPredFlag|UserCPredFlag);
|
||||
Yap_InitCPred ("system", 1, p_system, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("rename", 2, p_mv, SafePredFlag|SyncPredFlag);
|
||||
Yap_InitCPred ("$yap_home", 1, p_yap_home, SafePredFlag);
|
||||
|
34
C/threads.c
34
C/threads.c
@@ -73,6 +73,23 @@ set_system_thread_id(int wid, PL_thread_info_t *info)
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
Yap_ThreadID( void )
|
||||
{
|
||||
int new_worker_id = 0;
|
||||
pthread_t self = pthread_self();
|
||||
while(new_worker_id < MAX_THREADS &&
|
||||
Yap_local[new_worker_id] &&
|
||||
(REMOTE_ThreadHandle(new_worker_id).in_use == TRUE ||
|
||||
REMOTE_ThreadHandle(new_worker_id).zombie == TRUE) ) {
|
||||
if (pthread_equal(self , REMOTE_ThreadHandle(new_worker_id).pthread_handle) ) {
|
||||
return new_worker_id;
|
||||
}
|
||||
new_worker_id++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
allocate_new_tid(void)
|
||||
{
|
||||
@@ -87,6 +104,7 @@ allocate_new_tid(void)
|
||||
new_worker_id = -1;
|
||||
} else if (!Yap_local[new_worker_id]) {
|
||||
if (!Yap_InitThread(new_worker_id)) {
|
||||
UNLOCK(GLOBAL_ThreadHandlesLock);
|
||||
return -1;
|
||||
}
|
||||
MUTEX_LOCK(&(REMOTE_ThreadHandle(new_worker_id).tlock));
|
||||
@@ -451,9 +469,7 @@ p_thread_zombie_self( USES_REGS1 )
|
||||
/* make sure the lock is available */
|
||||
if (pthread_getspecific(Yap_yaamregs_key) == NULL)
|
||||
return Yap_unify(MkIntegerTerm(-1), ARG1);
|
||||
MUTEX_LOCK(&(LOCAL_ThreadHandle.tlock));
|
||||
if (LOCAL_ActiveSignals &= YAP_ITI_SIGNAL) {
|
||||
MUTEX_UNLOCK(&(LOCAL_ThreadHandle.tlock));
|
||||
if (Yap_has_signal( YAP_ITI_SIGNAL )) {
|
||||
return FALSE;
|
||||
}
|
||||
// fprintf(stderr," -- %d\n", worker_id);
|
||||
@@ -752,8 +768,12 @@ p_lock_mutex( USES_REGS1 )
|
||||
{
|
||||
SWIMutex *mut = (SWIMutex*)IntegerOfTerm(Deref(ARG1));
|
||||
|
||||
#if DEBUG_LOCKS
|
||||
MUTEX_LOCK(&mut->m);
|
||||
#else
|
||||
if (MUTEX_LOCK(&mut->m) < 0)
|
||||
return FALSE;
|
||||
#endif
|
||||
mut->owners++;
|
||||
mut->tid_own = worker_id;
|
||||
return TRUE;
|
||||
@@ -915,13 +935,7 @@ p_thread_signal( USES_REGS1 )
|
||||
MUTEX_UNLOCK(&(REMOTE_ThreadHandle(wid).tlock));
|
||||
return TRUE;
|
||||
}
|
||||
LOCK(REMOTE_SignalLock(wid));
|
||||
REMOTE_ThreadHandle(wid).current_yaam_regs->CreepFlag_ =
|
||||
REMOTE_ThreadHandle(wid).current_yaam_regs->EventFlag_ =
|
||||
Unsigned(REMOTE_ThreadHandle(wid).current_yaam_regs->LCL0_);
|
||||
REMOTE_ActiveSignals(wid) |= YAP_ITI_SIGNAL;
|
||||
UNLOCK(REMOTE_SignalLock(wid));
|
||||
MUTEX_UNLOCK(&(REMOTE_ThreadHandle(wid).tlock));
|
||||
Yap_external_signal( wid, YAP_ITI_SIGNAL );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
36
C/tracer.c
Normal file → Executable file
36
C/tracer.c
Normal file → Executable file
@@ -25,6 +25,7 @@
|
||||
#include "yapio.h"
|
||||
#include "clause.h"
|
||||
#include "tracer.h"
|
||||
#include "SWI-Stream.h"
|
||||
|
||||
static void send_tracer_message(char *, char *, Int, char *, CELL *);
|
||||
|
||||
@@ -33,32 +34,32 @@ send_tracer_message(char *start, char *name, Int arity, char *mname, CELL *args)
|
||||
{
|
||||
if (name == NULL) {
|
||||
#ifdef YAPOR
|
||||
fprintf(GLOBAL_stderr, "(%d)%s", worker_id, start);
|
||||
Sfprintf(GLOBAL_stderr, "(%d)%s", worker_id, start);
|
||||
#else
|
||||
fprintf(GLOBAL_stderr, "%s", start);
|
||||
Sfprintf(GLOBAL_stderr, "%s", start);
|
||||
#endif
|
||||
} else {
|
||||
int i;
|
||||
|
||||
if (arity) {
|
||||
if (args)
|
||||
fprintf(GLOBAL_stderr, "%s %s:%s(", start, mname, name);
|
||||
Sfprintf(GLOBAL_stderr, "%s %s:%s(", start, mname, name);
|
||||
else
|
||||
fprintf(GLOBAL_stderr, "%s %s:%s/%lu", start, mname, name, (unsigned long int)arity);
|
||||
Sfprintf(GLOBAL_stderr, "%s %s:%s/%lu", start, mname, name, (unsigned long int)arity);
|
||||
} else {
|
||||
fprintf(GLOBAL_stderr, "%s %s:%s", start, mname, name);
|
||||
Sfprintf(GLOBAL_stderr, "%s %s:%s", start, mname, name);
|
||||
}
|
||||
if (args) {
|
||||
for (i= 0; i < arity; i++) {
|
||||
if (i > 0) fprintf(GLOBAL_stderr, ",");
|
||||
Yap_plwrite(args[i], NULL, 15, Handle_vars_f|AttVar_Portray_f, 1200);
|
||||
if (i > 0) Sfprintf(GLOBAL_stderr, ",");
|
||||
Yap_plwrite(args[i], GLOBAL_stderr, 15, Handle_vars_f|AttVar_Portray_f, 1200);
|
||||
}
|
||||
if (arity) {
|
||||
fprintf(GLOBAL_stderr, ")");
|
||||
Sfprintf(GLOBAL_stderr, ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
fprintf(GLOBAL_stderr, "\n");
|
||||
Sfprintf(GLOBAL_stderr, "\n");
|
||||
}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
@@ -120,7 +121,7 @@ check_area(void)
|
||||
first = i;
|
||||
found = TRUE;
|
||||
}
|
||||
fprintf(stderr,"%lld changed %d\n",vsc_count,i);
|
||||
Sfprintf(stderr,"%lld changed %d\n",vsc_count,i);
|
||||
}
|
||||
array[i] = ((CELL *)0x187a800)[i];
|
||||
}
|
||||
@@ -146,12 +147,12 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
LOCK(Yap_heap_regs->low_level_trace_lock);
|
||||
sc = Yap_heap_regs;
|
||||
//if (vsc_count == 54) jmp_deb(1);
|
||||
// fprintf(stderr,"B=%p ", B);
|
||||
// Sfprintf(stderr,"B=%p ", B);
|
||||
#ifdef THREADS
|
||||
LOCAL_ThreadHandle.thread_inst_count++;
|
||||
#endif
|
||||
#ifdef COMMENTED
|
||||
fprintf(stderr,"in %p\n");
|
||||
Sfprintf(stderr,"in %p\n");
|
||||
CELL * gc_ENV = ENV;
|
||||
while (gc_ENV != NULL) { /* no more environments */
|
||||
fprintf(stderr,"%ld\n", LCL0-gc_ENV);
|
||||
@@ -180,7 +181,7 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
if (vsc_count % 1LL == 0) {
|
||||
UInt sz = Yap_regp->H0_[17];
|
||||
UInt end = sizeof(MP_INT)/sizeof(CELL)+sz+1;
|
||||
fprintf(stderr,"VAL %lld %d %x/%x\n",vsc_count,sz,H0[16],H0[16+end]);
|
||||
Sfprintf(GLOBAL_stderr,"VAL %lld %d %x/%x\n",vsc_count,sz,H0[16],H0[16+end]);
|
||||
}
|
||||
} else
|
||||
return;
|
||||
@@ -292,9 +293,9 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
fprintf(GLOBAL_stderr,"%lld ",vsc_count);
|
||||
Sfprintf(GLOBAL_stderr,"%lld ",vsc_count);
|
||||
#if defined(THREADS) || defined(YAPOR)
|
||||
fprintf(GLOBAL_stderr,"(%d)", worker_id);
|
||||
Sfprintf(GLOBAL_stderr,"(%d)", worker_id);
|
||||
#endif
|
||||
/* check_trail_consistency(); */
|
||||
if (pred == NULL) {
|
||||
@@ -377,6 +378,7 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
}
|
||||
break;
|
||||
}
|
||||
Sflush(GLOBAL_stderr);
|
||||
fflush(NULL);
|
||||
UNLOCK(Yap_heap_regs->low_level_trace_lock);
|
||||
}
|
||||
@@ -389,6 +391,7 @@ toggle_low_level_trace(void)
|
||||
|
||||
static Int p_start_low_level_trace( USES_REGS1 )
|
||||
{
|
||||
GLOBAL_stderr = Sopen_file("LOG", "w");
|
||||
Yap_do_low_level_trace = TRUE;
|
||||
return(TRUE);
|
||||
}
|
||||
@@ -406,7 +409,7 @@ static Int p_reset_total_choicepoints( USES_REGS1 )
|
||||
|
||||
static Int p_show_low_level_trace( USES_REGS1 )
|
||||
{
|
||||
fprintf(stderr,"Call counter=%lld\n",vsc_count);
|
||||
Sfprintf(GLOBAL_stderr,"Call counter=%lld\n",vsc_count);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
@@ -425,6 +428,7 @@ static Int p_stop_low_level_trace( USES_REGS1 )
|
||||
{
|
||||
Yap_do_low_level_trace = FALSE;
|
||||
LOCAL_do_trace_primitives = TRUE;
|
||||
debug_locks = TRUE;
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user