New Flags code

This commit is contained in:
Vítor Santos Costa 2015-06-18 07:55:07 +01:00
parent 8fc4dc2219
commit 60861649a0
5 changed files with 25 additions and 19 deletions

View File

@ -795,6 +795,7 @@ ExpandPredHash(void)
Prop Prop
Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod) Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod)
{ {
CACHE_REGS
PredEntry *p = (PredEntry *) Yap_AllocAtomSpace(sizeof(*p)); PredEntry *p = (PredEntry *) Yap_AllocAtomSpace(sizeof(*p));
if (p == NULL) { if (p == NULL) {

View File

@ -649,7 +649,7 @@ static Term getYapFlagInModule( Term tflag, Term mod )
return 0L; return 0L;
} }
static Int cont_yap_flag(USES_REGS1) { static Int cont_yap_flag( USES_REGS1) {
int i = IntOfTerm (EXTRA_CBACK_ARG (2, 1)); int i = IntOfTerm (EXTRA_CBACK_ARG (2, 1));
int gmax = GLOBAL_flagCount; int gmax = GLOBAL_flagCount;
int lmax = LOCAL_flagCount; int lmax = LOCAL_flagCount;
@ -704,7 +704,7 @@ static Int yap_flag(USES_REGS1) {
tflag = Yap_StripModule( tflag, &modt ); tflag = Yap_StripModule( tflag, &modt );
if (IsVarTerm(tflag)) { if (IsVarTerm(tflag)) {
EXTRA_CBACK_ARG (2, 1) = MkIntTerm (0); EXTRA_CBACK_ARG (2, 1) = MkIntTerm (0);
return cont_yap_flag(); return cont_yap_flag( PASS_REGS1 );
} }
do_cut( 0 ); do_cut( 0 );
@ -787,7 +787,7 @@ yap_flag/2 with the second argument unbound, and unifying the
returned second argument with _Value_. returned second argument with _Value_.
*/ */
static Int current_prolog_flag( PASS_REGS1 ) { static Int current_prolog_flag( USES_REGS1 ) {
Term tflag = Deref(ARG1); Term tflag = Deref(ARG1);
Term tout = 0; Term tout = 0;
FlagEntry *fv; FlagEntry *fv;
@ -854,6 +854,7 @@ bool setYapFlag( Term tflag, Term t2 )
if (!fv) { if (!fv) {
Term fl = GLOBAL_Flags[USER_FLAGS_FLAG].at; Term fl = GLOBAL_Flags[USER_FLAGS_FLAG].at;
if (fl == TermSilent) { if (fl == TermSilent) {
CACHE_REGS
Term t2 = Deref(ARG2); Term t2 = Deref(ARG2);
newFlag( tflag, t2); newFlag( tflag, t2);
} else if (fl == TermWarning) { } else if (fl == TermWarning) {
@ -976,7 +977,7 @@ according to _N_.
*/ */
static Int static Int
source_mode( USE_ARGS1 ) source_mode( USES_REGS1 )
{ {
Term targ; Term targ;
bool current = trueGlobalPrologFlag(SOURCE_FLAG); bool current = trueGlobalPrologFlag(SOURCE_FLAG);
@ -1071,6 +1072,7 @@ setInitialValue( bool bootstrap, flag_func f, const char *s,flag_term *tarr )
} else { } else {
Term t0; Term t0;
if (bootstrap) { return false; } if (bootstrap) { return false; }
CACHE_REGS
t0 = Yap_StringToTerm(s, strlen(s)+1, LOCAL_encoding, 1200, NULL); t0 = Yap_StringToTerm(s, strlen(s)+1, LOCAL_encoding, 1200, NULL);
if (!t0) if (!t0)
return false; return false;
@ -1137,27 +1139,27 @@ do_prolog_flag_property (Term tflag, Term opts USES_REGS)
case PROLOG_FLAG_PROPERTY_ACCESS: case PROLOG_FLAG_PROPERTY_ACCESS:
if (fv->rw) if (fv->rw)
rc = rc && rc = rc &&
Yap_unify(TermReadWrite, args[PROLOG_FLAG_PROPERTY_ACCESS].tvalue PASS_REGS); Yap_unify(TermReadWrite, args[PROLOG_FLAG_PROPERTY_ACCESS].tvalue);
else else
rc = rc && rc = rc &&
Yap_unify(TermReadOnly, args[PROLOG_FLAG_PROPERTY_ACCESS].tvalue PASS_REGS); Yap_unify(TermReadOnly, args[PROLOG_FLAG_PROPERTY_ACCESS].tvalue);
break; break;
case PROLOG_FLAG_PROPERTY_TYPE: case PROLOG_FLAG_PROPERTY_TYPE:
if (fv->type == boolean) if (fv->type == boolean)
rc = rc && rc = rc &&
Yap_unify(TermBoolean, args[PROLOG_FLAG_PROPERTY_TYPE].tvalue PASS_REGS); Yap_unify(TermBoolean, args[PROLOG_FLAG_PROPERTY_TYPE].tvalue);
else if (fv->type == isatom) else if (fv->type == isatom)
rc = rc && rc = rc &&
Yap_unify(TermAtom, args[PROLOG_FLAG_PROPERTY_TYPE].tvalue PASS_REGS); Yap_unify(TermAtom, args[PROLOG_FLAG_PROPERTY_TYPE].tvalue);
else if (fv->type == nat) else if (fv->type == nat)
rc = rc && rc = rc &&
Yap_unify(TermInteger, args[PROLOG_FLAG_PROPERTY_TYPE].tvalue PASS_REGS); Yap_unify(TermInteger, args[PROLOG_FLAG_PROPERTY_TYPE].tvalue);
else if (fv->type == isfloat) else if (fv->type == isfloat)
rc = rc && rc = rc &&
Yap_unify(TermFloat, args[PROLOG_FLAG_PROPERTY_TYPE].tvalue PASS_REGS); Yap_unify(TermFloat, args[PROLOG_FLAG_PROPERTY_TYPE].tvalue);
else else
rc = rc && rc = rc &&
Yap_unify(TermTerm, args[PROLOG_FLAG_PROPERTY_TYPE].tvalue PASS_REGS); Yap_unify(TermTerm, args[PROLOG_FLAG_PROPERTY_TYPE].tvalue);
break; break;
case PROLOG_FLAG_PROPERTY_KEEP: case PROLOG_FLAG_PROPERTY_KEEP:
rc = rc && false; rc = rc && false;
@ -1167,12 +1169,12 @@ do_prolog_flag_property (Term tflag, Term opts USES_REGS)
if (fv->FlagOfVE == UNKNOWN_FLAG || if (fv->FlagOfVE == UNKNOWN_FLAG ||
fv->FlagOfVE == CHARACTER_ESCAPES_FLAG || fv->FlagOfVE == CHARACTER_ESCAPES_FLAG ||
fv->FlagOfVE == BACKQUOTED_STRING_FLAG) fv->FlagOfVE == BACKQUOTED_STRING_FLAG)
Yap_unify(TermModule, args[PROLOG_FLAG_PROPERTY_SCOPE].tvalue PASS_REGS); Yap_unify(TermModule, args[PROLOG_FLAG_PROPERTY_SCOPE].tvalue);
rc = rc && rc = rc &&
Yap_unify(TermGlobal, args[PROLOG_FLAG_PROPERTY_SCOPE].tvalue PASS_REGS); Yap_unify(TermGlobal, args[PROLOG_FLAG_PROPERTY_SCOPE].tvalue);
} else } else
rc = rc && rc = rc &&
Yap_unify(TermThread, args[PROLOG_FLAG_PROPERTY_SCOPE].tvalue PASS_REGS); Yap_unify(TermThread, args[PROLOG_FLAG_PROPERTY_SCOPE].tvalue);
break; break;
case PROLOG_FLAG_PROPERTY_END: case PROLOG_FLAG_PROPERTY_END:
/* break; */ /* break; */
@ -1180,7 +1182,7 @@ do_prolog_flag_property (Term tflag, Term opts USES_REGS)
} }
} }
} }
UNLOCK(GLOBAL_Prolog_Flag[sno].prolog_flaglock); // UNLOCK(GLOBAL_Prolog_Flag[sno].prolog_flaglock);
return rc; return rc;
} }
@ -1329,7 +1331,7 @@ do_create_prolog_flag( USES_REGS1 )
} }
} }
} }
UNLOCK(GLOBAL_Prolog_Flag[sno].prolog_flaglock); //UNLOCK(GLOBAL_Prolog_Flag[sno].prolog_flaglock);
return true; return true;
} }

2
C/x.c
View File

@ -1827,7 +1827,7 @@ static void InitSignals(void);
#define SIG_ATOM_GC (SIG_PROLOG_OFFSET+1) #define SIG_ATOM_GC (SIG_PROLOG_OFFSET+1)
#endif #endif
#define SIG_GC (SIG_PROLOG_OFFSET+2) #define SIG_GC (SIG_PROLOG_OFFSET+2)
#ifdef O_PLMT #ifdef THREADS
#define SIG_THREAD_SIGNAL (SIG_PROLOG_OFFSET+3) #define SIG_THREAD_SIGNAL (SIG_PROLOG_OFFSET+3)
#endif #endif
#define SIG_FREECLAUSES (SIG_PROLOG_OFFSET+4) #define SIG_FREECLAUSES (SIG_PROLOG_OFFSET+4)

View File

@ -331,3 +331,6 @@ check_function_exists( wordexp HAVE_WORDEXP )
check_function_exists( _bool HAVE__BOOL ) check_function_exists( _bool HAVE__BOOL )
check_function_exists( _chsize_s HAVE__CHSIZE_S ) check_function_exists( _chsize_s HAVE__CHSIZE_S )
check_function_exists( _NSGetEnviron HAVE__NSGETENVIRON ) check_function_exists( _NSGetEnviron HAVE__NSGETENVIRON )
check_symbol_exists( __NR_gettid "sys/syscall.h;unistd.h" HAVE_GETTID_SYSCALL )
check_symbol_exists( gettid "sys/syscall.h;unistd.h" HAVE_GETTID_MACRO )

View File

@ -1873,11 +1873,11 @@ static void InitSignals(void);
#define SIG_PROLOG_OFFSET 32 /* Start of Prolog signals */ #define SIG_PROLOG_OFFSET 32 /* Start of Prolog signals */
#define SIG_EXCEPTION (SIG_PROLOG_OFFSET+0) #define SIG_EXCEPTION (SIG_PROLOG_OFFSET+0)
#ifdef O_ATOMGC #ifdef ATOMGC
#define SIG_ATOM_GC (SIG_PROLOG_OFFSET+1) #define SIG_ATOM_GC (SIG_PROLOG_OFFSET+1)
#endif #endif
#define SIG_GC (SIG_PROLOG_OFFSET+2) #define SIG_GC (SIG_PROLOG_OFFSET+2)
#ifdef O_PLMT #ifdef THREADS
#define SIG_THREAD_SIGNAL (SIG_PROLOG_OFFSET+3) #define SIG_THREAD_SIGNAL (SIG_PROLOG_OFFSET+3)
#endif #endif
#define SIG_FREECLAUSES (SIG_PROLOG_OFFSET+4) #define SIG_FREECLAUSES (SIG_PROLOG_OFFSET+4)