Merge branch 'master' of ssh://git.code.sf.net/p/yap/yap-6.3

This commit is contained in:
Vítor Santos Costa 2013-12-16 21:47:53 +00:00
commit 993a9272d1
7 changed files with 52 additions and 35 deletions

View File

@ -593,7 +593,7 @@ static int
check_alarm_fail_int(int CONT USES_REGS)
{
#if defined(_MSC_VER) || defined(__MINGW32__)
/* I need this for Windows and other systems where SIGINT
/* I need this for Windows and any system where SIGINT
is not proceesed by same thread as absmi */
LOCK(LOCAL_SignalLock);
if (LOCAL_PrologMode & (AbortMode|InterruptMode))
@ -605,15 +605,19 @@ 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) {
Yap_Error(PURE_ABORT, TermNil, "abort from console");
}
LOCAL_ActiveSignals &= ~(YAP_FAIL_SIGNAL|YAP_INT_SIGNAL);
if (!LOCAL_ActiveSignals)
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.
return FALSE;
}
return TRUE;
return -1;
}
static int
@ -621,6 +625,7 @@ stack_overflow( CELL *env, yamop *cp USES_REGS )
{
if ((Int)(Unsigned(YREG) - Unsigned(H)) < StackGap( PASS_REGS1 ) ||
LOCAL_ActiveSignals & YAP_STOVF_SIGNAL) {
LOCAL_ActiveSignals &= ~YAP_STOVF_SIGNAL;
if (!Yap_gc(((PredEntry *)(S))->ArityOfPE, env, cp)) {
Yap_NilError(OUT_OF_STACK_ERROR,LOCAL_ErrorMessage);
return 0;
@ -654,12 +659,9 @@ code_overflow( CELL *yenv USES_REGS )
static int
interrupt_handler( USES_REGS1 )
{
int v;
PredEntry *pe = (PredEntry *)S;
// printf("D %lx %p\n", LOCAL_ActiveSignals, P);
if ((v = check_alarm_fail_int( FALSE PASS_REGS )) != 1)
return v;
/* tell whether we can creep or not, this is hard because we will
lose the info RSN
*/
@ -832,7 +834,8 @@ interrupt_execute( USES_REGS1 )
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);
#endif
check_alarm_fail_int( TRUE PASS_REGS );
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))
return 2;
@ -852,7 +855,8 @@ interrupt_call( USES_REGS1 )
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);
#endif
check_alarm_fail_int( TRUE PASS_REGS );
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))
@ -873,7 +877,8 @@ interrupt_pexecute( PredEntry *pen USES_REGS )
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);
#endif
check_alarm_fail_int( 2 PASS_REGS );
if ((v = check_alarm_fail_int( 2 PASS_REGS )) >= 0)
return v;
PP = NULL;
if (LOCAL_ActiveSignals == YAP_CREEP_SIGNAL)
return 2; /* keep on creeping */
@ -902,7 +907,8 @@ interrupt_deallocate( USES_REGS1 )
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);
#endif
check_alarm_fail_int( TRUE PASS_REGS );
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 */
@ -945,11 +951,13 @@ interrupt_deallocate( USES_REGS1 )
static int
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);
#endif
check_alarm_fail_int( 2 PASS_REGS );
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) {
return 2;
}
@ -963,11 +971,13 @@ interrupt_cut( USES_REGS1 )
static int
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);
#endif
check_alarm_fail_int( 2 PASS_REGS );
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) {
return 2;
}
@ -981,13 +991,13 @@ interrupt_cut_t( USES_REGS1 )
static int
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);
#endif
if (!LOCAL_ActiveSignals || (LOCAL_ActiveSignals & (YAP_CDOVF_SIGNAL|YAP_CREEP_SIGNAL)) == LOCAL_ActiveSignals) {
return 2;
}
if ((v = check_alarm_fail_int( 2 PASS_REGS )) >= 0)
return v;
/* find something to fool S */
S = (CELL *)PredRestoreRegs;
XREGS[0] = YENV[P->u.yps.y];
@ -998,11 +1008,13 @@ interrupt_commit_y( USES_REGS1 )
static int
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);
#endif
check_alarm_fail_int( 2 PASS_REGS );
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) {
return 2;
}
@ -1033,7 +1045,8 @@ interrupt_either( USES_REGS1 )
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);
#endif
check_alarm_fail_int( 2 PASS_REGS );
if ((v = check_alarm_fail_int( 2 PASS_REGS )) >= 0)
return v;
if (LOCAL_ActiveSignals == YAP_CREEP_SIGNAL)
return 2;
PP = P->u.Osblp.p0;
@ -1056,7 +1069,6 @@ interrupt_dexecute( USES_REGS1 )
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);
#endif
check_alarm_fail_int( 2 PASS_REGS );
PP = P->u.pp.p0;
if (LOCAL_ActiveSignals & YAP_CREEP_SIGNAL &&
PP->ExtraPredFlags & NoDebugPredFlag) {
@ -3084,11 +3096,9 @@ Yap_absmi(int inp)
/* cut */
Op(cut, s);
#ifdef COROUTINING
if (FALSE) {
CACHE_Y_AS_ENV(YREG);
check_stack(NoStackCut, H);
ENDCACHE_Y_AS_ENV();
}
CACHE_Y_AS_ENV(YREG);
check_stack(NoStackCut, H);
ENDCACHE_Y_AS_ENV();
do_cut:
#endif
SET_ASP(YREG, PREG->u.s.s);
@ -3110,11 +3120,9 @@ Yap_absmi(int inp)
/* cut_t does the same as cut */
Op(cut_t, s);
#ifdef COROUTINING
if (FALSE) {
CACHE_Y_AS_ENV(YREG);
check_stack(NoStackCutT, H);
ENDCACHE_Y_AS_ENV();
}
CACHE_Y_AS_ENV(YREG);
check_stack(NoStackCutT, H);
ENDCACHE_Y_AS_ENV();
do_cut_t:
#endif
SET_ASP(YREG, PREG->u.s.s);
@ -3135,11 +3143,9 @@ Yap_absmi(int inp)
/* cut_e */
Op(cut_e, s);
#ifdef COROUTINING
if (FALSE) {
CACHE_Y_AS_ENV(YREG);
check_stack(NoStackCutE, H);
ENDCACHE_Y_AS_ENV();
}
CACHE_Y_AS_ENV(YREG);
check_stack(NoStackCutE, H);
ENDCACHE_Y_AS_ENV();
do_cut_e:
#endif
SET_ASP(YREG, PREG->u.s.s);

View File

@ -1815,6 +1815,9 @@ Yap_InitYaamRegs( int myworker_id )
DepFr_cons_cp(REMOTE_top_dep_fr(myworker_id)) = NORM_CP(B);
#endif
UNLOCK(REMOTE_SignalLock(myworker_id));
// make sure we have slots in case we don go through the top-level */
Yap_StartSlots( PASS_REGS1 );
}
static Int

View File

@ -450,6 +450,7 @@ read_Text( void *buf, seq_tv_t *inp, encoding_t *enc, int *minimal, size_t *leng
*lengp = strlen(s);
*enc = YAP_CHAR;
return s;
#if USE_GMP
case YAP_STRING_BIG:
if (buf) s = buf;
else s = Yap_PreAllocCodeSpace();
@ -459,6 +460,7 @@ read_Text( void *buf, seq_tv_t *inp, encoding_t *enc, int *minimal, size_t *leng
*enc = YAP_CHAR;
*lengp = strlen(s);
return s;
#endif
case YAP_STRING_CHARS:
*enc = YAP_CHAR;
if (inp->sz)
@ -551,6 +553,7 @@ read_Text( void *buf, seq_tv_t *inp, encoding_t *enc, int *minimal, size_t *leng
LOCAL_Error_TYPE = gen_type_error( inp->type );
LOCAL_Error_Term = t;
}
#if USE_GMP
} else if (IsBigIntTerm(t)) {
if (inp->type & (YAP_STRING_BIG)) {
inp->type &= (YAP_STRING_BIG);
@ -560,6 +563,7 @@ read_Text( void *buf, seq_tv_t *inp, encoding_t *enc, int *minimal, size_t *leng
LOCAL_Error_TYPE = gen_type_error( inp->type );
LOCAL_Error_Term = t;
}
#endif
} else {
if (!Yap_IsGroundTerm(t)) {
LOCAL_Error_TYPE = INSTANTIATION_ERROR;

View File

@ -417,7 +417,7 @@ extern int Yap_page_size;
}
#endif /***********************************************************************************/
#ifdef THREADS
#if defined(THREADS) && defined(TABLING)
#define ALLOC_STRUCT(STR, STR_TYPE, _PG_ENT) \
GET_FREE_STRUCT(STR, STR_TYPE, LOCAL##_PG_ENT, GLOBAL##_PG_ENT)
#define FREE_STRUCT(STR, STR_TYPE, _PG_ENT) \

View File

@ -159,7 +159,7 @@ struct page_statistics {
#endif /* USE_PAGES_MALLOC */
#ifdef THREADS
#if defined(THREADS) && defined(TABLING)
#define GET_ALL_PAGE_STATS(STATS, STR_TYPE, _PAGES) \
LOCK(GLOBAL_ThreadHandlesLock); \
CHECK_PAGE_FREE_STRUCTS(STR_TYPE, GLOBAL##_PAGES); \

View File

@ -199,4 +199,5 @@ read_sig.
:- '$set_no_trace'(true, prolog).
:- '$set_no_trace'('$call'(_,_,_,_), prolog).
:- '$set_no_trace'('$execute_nonstop'(_,_), prolog).
:- '$set_no_trace'('$restore_regs'(_,_), prolog).

View File

@ -130,6 +130,9 @@ table(Pred) :-
'$set_table'(Mod,PredFunctor,PredModeList) :-
'$undefined'(PredFunctor,Mod), !,
'$c_table'(Mod,PredFunctor,PredModeList).
'$set_table'(Mod,PredFunctor,PredModeList) :-
'$flags'(PredFunctor,Mod,Flags,Flags),
Flags /\ 0x00000040 =:= 0x00000040, !.
'$set_table'(Mod,PredFunctor,PredModeList) :-
'$flags'(PredFunctor,Mod,Flags,Flags),
Flags /\ 0x1991F8C0 =:= 0,