exo-compilation fixes for threads.

This commit is contained in:
Vítor Santos Costa 2013-04-16 21:49:37 -05:00
parent ea3f25c378
commit 210dacfe5a
4 changed files with 35 additions and 39 deletions

View File

@ -1143,7 +1143,7 @@ Yap_absmi(int inp)
{ {
struct index_t *it = (struct index_t *)(PREG->u.lp.l); struct index_t *it = (struct index_t *)(PREG->u.lp.l);
saveregs(); saveregs();
d0 = ((CRetryExoIndex)it->udi_next)(it); d0 = ((CRetryExoIndex)it->udi_next)(it PASS_REGS);
setregs(); setregs();
#ifdef SHADOW_S #ifdef SHADOW_S
SREG = S; SREG = S;

View File

@ -382,7 +382,7 @@ Yap_ExoLookup(PredEntry *ap USES_REGS)
if (count) { if (count) {
yamop *code = LOOKUP(i, arity, j0, LOCAL_ibnds); yamop *code = LOOKUP(i, arity, j0, LOCAL_ibnds);
if (i->is_udi) if (i->is_udi)
return ((CEnterExoIndex)i->udi_first)(i); return ((CEnterExoIndex)i->udi_first)(i PASS_REGS);
else return code; else return code;
} else } else
return i->code; return i->code;

View File

@ -41,6 +41,7 @@
static int static int
compar(const void *ip0, const void *jp0) { compar(const void *ip0, const void *jp0) {
CACHE_REGS
BITS32 *ip = (BITS32 *)ip0, *jp = (BITS32 *)jp0; BITS32 *ip = (BITS32 *)ip0, *jp = (BITS32 *)jp0;
BITS32 *bs = LOCAL_exo_base; BITS32 *bs = LOCAL_exo_base;
Int i = bs[LOCAL_exo_arity*(*ip)+LOCAL_exo_arg]; Int i = bs[LOCAL_exo_arity*(*ip)+LOCAL_exo_arg];
@ -49,7 +50,7 @@ compar(const void *ip0, const void *jp0) {
} }
static int static int
compare(const BITS32 *ip, Int j) { compare(const BITS32 *ip, Int j USES_REGS) {
BITS32 *bs = LOCAL_exo_base; BITS32 *bs = LOCAL_exo_base;
Int i = bs[LOCAL_exo_arity*(*ip)+LOCAL_exo_arg]; Int i = bs[LOCAL_exo_arity*(*ip)+LOCAL_exo_arg];
/* fprintf(stderr, "%ld-%ld\n", IntOfTerm(i), j); */ /* fprintf(stderr, "%ld-%ld\n", IntOfTerm(i), j); */
@ -58,7 +59,7 @@ compare(const BITS32 *ip, Int j) {
static void static void
RangeUDIRefitIndex(struct index_t **ip, UInt b[]) RangeUDIRefitIndex(struct index_t **ip, UInt b[] USES_REGS)
{ {
size_t sz; size_t sz;
struct index_t *it = *ip; struct index_t *it = *ip;
@ -112,7 +113,7 @@ RangeUDIRefitIndex(struct index_t **ip, UInt b[])
} }
static yamop * static yamop *
Min(struct index_t *it, BITS32 off) Min(struct index_t *it, BITS32 off USES_REGS)
{ {
if (it->links[off]) { if (it->links[off]) {
BITS32 *c = (BITS32 *)it->udi_data; BITS32 *c = (BITS32 *)it->udi_data;
@ -123,7 +124,7 @@ Min(struct index_t *it, BITS32 off)
} }
static yamop * static yamop *
Max(struct index_t *it, BITS32 off) Max(struct index_t *it, BITS32 off USES_REGS)
{ {
if (it->links[off]) { if (it->links[off]) {
BITS32 *c = (BITS32 *)it->udi_data; BITS32 *c = (BITS32 *)it->udi_data;
@ -135,7 +136,7 @@ Max(struct index_t *it, BITS32 off)
} }
static yamop * static yamop *
Gt(struct index_t *it, Int x, BITS32 off) Gt(struct index_t *it, Int x, BITS32 off USES_REGS)
{ {
if (it->links[off]) { if (it->links[off]) {
BITS32 *c = (BITS32 *)it->udi_data; BITS32 *c = (BITS32 *)it->udi_data;
@ -149,7 +150,7 @@ Gt(struct index_t *it, Int x, BITS32 off)
if (n > 8 && FALSE) { if (n > 8 && FALSE) {
// start = binary_search(start,end, x, it); // start = binary_search(start,end, x, it);
} else { } else {
while ( pt < end && compare(pt, x) <= 0 ) { while ( pt < end && compare(pt, x PASS_REGS) <= 0 ) {
pt++; pt++;
} }
} }
@ -168,7 +169,7 @@ Gt(struct index_t *it, Int x, BITS32 off)
} }
static yamop * static yamop *
Lt(struct index_t *it, Int x, BITS32 off) Lt(struct index_t *it, Int x, BITS32 off USES_REGS)
{ {
if (it->links[off]) { if (it->links[off]) {
BITS32 *c = (BITS32 *)it->udi_data; BITS32 *c = (BITS32 *)it->udi_data;
@ -182,9 +183,9 @@ Lt(struct index_t *it, Int x, BITS32 off)
if (n > 8 && FALSE) { if (n > 8 && FALSE) {
// start = binary_search(start,end, x, it); // start = binary_search(start,end, x, it);
} else { } else {
if (compare(start, x) >= 0) if (compare(start, x PASS_REGS) >= 0)
return FAILCODE; return FAILCODE;
while ( pt < end && compare(pt, x) < 0 ) { while ( pt < end && compare(pt, x PASS_REGS) < 0 ) {
pt++; pt++;
} }
} }
@ -201,7 +202,7 @@ Lt(struct index_t *it, Int x, BITS32 off)
} }
static yamop * static yamop *
Eq(struct index_t *it, Int x, BITS32 off) Eq(struct index_t *it, Int x, BITS32 off USES_REGS)
{ {
if (it->links[off]) { if (it->links[off]) {
BITS32 *c = (BITS32 *)it->udi_data; BITS32 *c = (BITS32 *)it->udi_data;
@ -215,15 +216,15 @@ Eq(struct index_t *it, Int x, BITS32 off)
if (n > 8 && FALSE) { if (n > 8 && FALSE) {
// start = binary_search(start,end, x, it); // start = binary_search(start,end, x, it);
} else { } else {
Int c; Int c = 0;
while ( pt < end && (c = compare(pt, x)) < 0 ) { while ( pt < end && (c = compare(pt, x PASS_REGS)) < 0 ) {
pt++; pt++;
} }
if (pt == end || c) if (pt == end || c)
return FAILCODE; return FAILCODE;
start = pt; start = pt;
pt ++; pt ++;
while ( pt < end && (c = compare(pt, x)) == 0 ) { while ( pt < end && (c = compare(pt, x PASS_REGS)) == 0 ) {
pt++; pt++;
} }
} }
@ -240,7 +241,7 @@ Eq(struct index_t *it, Int x, BITS32 off)
} }
static yamop * static yamop *
All(struct index_t *it, BITS32 off) All(struct index_t *it, BITS32 off USES_REGS)
{ {
if (it->links[off]) { if (it->links[off]) {
BITS32 *c = (BITS32 *)it->udi_data; BITS32 *c = (BITS32 *)it->udi_data;
@ -263,7 +264,7 @@ All(struct index_t *it, BITS32 off)
} }
static yamop * static yamop *
RangeEnterUDIIndex(struct index_t *it) RangeEnterUDIIndex(struct index_t *it USES_REGS)
{ {
Int i = arg_of_interest(); Int i = arg_of_interest();
Term t = XREGS[i+1], a1; Term t = XREGS[i+1], a1;
@ -286,44 +287,44 @@ RangeEnterUDIIndex(struct index_t *it)
at = NameOfFunctor(f); at = NameOfFunctor(f);
} }
if (at == AtomMax) { if (at == AtomMax) {
return Max(it, off); return Max(it, off PASS_REGS);
} else if (at == AtomMin) { } else if (at == AtomMin) {
return Min(it, off); return Min(it, off PASS_REGS);
} else if (at == AtomGT) { } else if (at == AtomGT) {
Term arg = ArgOfTerm(1, a1); Term arg = ArgOfTerm(1, a1);
if (IsVarTerm(arg)) if (IsVarTerm(arg))
return All(it, off); return All(it, off PASS_REGS);
else if (!IsIntTerm(arg)) { else if (!IsIntTerm(arg)) {
Yap_Error(TYPE_ERROR_INTEGER, arg, "data-base constraint"); Yap_Error(TYPE_ERROR_INTEGER, arg, "data-base constraint");
return FAILCODE; return FAILCODE;
} }
return Gt(it, IntOfTerm(arg), off); return Gt(it, IntOfTerm(arg), off PASS_REGS);
} else if (at == AtomLT) { } else if (at == AtomLT) {
Term arg = ArgOfTerm(1, a1); Term arg = ArgOfTerm(1, a1);
if (IsVarTerm(arg)) if (IsVarTerm(arg))
return All(it, off); return All(it, off PASS_REGS);
else if (!IsIntTerm(arg)) { else if (!IsIntTerm(arg)) {
Yap_Error(TYPE_ERROR_INTEGER, t, "data-base constraint"); Yap_Error(TYPE_ERROR_INTEGER, t, "data-base constraint");
return FAILCODE; return FAILCODE;
} }
return Lt(it, IntOfTerm(arg), off); return Lt(it, IntOfTerm(arg), off PASS_REGS);
} else if (at == AtomEQ) { } else if (at == AtomEQ) {
Term arg = ArgOfTerm(1, a1); Term arg = ArgOfTerm(1, a1);
if (IsVarTerm(arg)) if (IsVarTerm(arg))
return All(it, off); return All(it, off PASS_REGS);
else if (!IsIntTerm(arg)) { else if (!IsIntTerm(arg)) {
Yap_Error(TYPE_ERROR_INTEGER, t, "data-base constraint"); Yap_Error(TYPE_ERROR_INTEGER, t, "data-base constraint");
return FAILCODE; return FAILCODE;
} }
return Eq(it, IntOfTerm(arg), off); return Eq(it, IntOfTerm(arg), off PASS_REGS);
} }
return FAILCODE; return FAILCODE;
} }
static int static int
RangeRetryUDIIndex(struct index_t *it) RangeRetryUDIIndex(struct index_t *it USES_REGS)
{ {
CELL *w = (CELL*)(B+1); CELL *w = (CELL*)(B+1);
BITS32 *end = (BITS32 *) w[it->arity+2], BITS32 *end = (BITS32 *) w[it->arity+2],
@ -341,7 +342,7 @@ static struct udi_control_block RangeCB;
typedef struct exo_udi_access_t { typedef struct exo_udi_access_t {
CRefitExoIndex refit; CRefitExoIndex refit;
}; } exo_udi_encaps_t;
static struct exo_udi_access_t ExoCB; static struct exo_udi_access_t ExoCB;
@ -355,20 +356,15 @@ static void *
RangeUdiInsert (void *control, RangeUdiInsert (void *control,
Term term, int arg, void *data) Term term, int arg, void *data)
{ {
CACHE_REGS
struct index_t **ip = (struct index_t **)term; struct index_t **ip = (struct index_t **)term;
(ExoCB.refit)(ip, LOCAL_ibnds); (ExoCB.refit)(ip, LOCAL_ibnds PASS_REGS);
(*ip)->udi_first = (void *)RangeEnterUDIIndex; (*ip)->udi_first = (void *)RangeEnterUDIIndex;
(*ip)->udi_next = (void *)RangeRetryUDIIndex; (*ip)->udi_next = (void *)RangeRetryUDIIndex;
return control; return control;
} }
static void *
RangeUdiSearch (void *control,
int arg, Yap_UdiCallback callback, void *args)
{
return NULL;
}
static int RangeUdiDestroy(void *control) static int RangeUdiDestroy(void *control)
{ {
return TRUE; return TRUE;
@ -386,7 +382,7 @@ void Yap_udi_range_init(void) {
cb->init= RangeUdiInit; cb->init= RangeUdiInit;
cb->insert=RangeUdiInsert; cb->insert=RangeUdiInsert;
cb->search=RangeUdiSearch; cb->search=NULL;
cb->destroy=RangeUdiDestroy; cb->destroy=RangeUdiDestroy;
Yap_UdiRegister(cb); Yap_UdiRegister(cb);

View File

@ -213,9 +213,9 @@ LINK_TO_ADDRESS(struct index_t *it, BITS32 off)
return it->links+off; return it->links+off;
} }
typedef void (*CRefitExoIndex)(struct index_t **ip, UInt b[]); typedef void (*CRefitExoIndex)(struct index_t **ip, UInt b[] USES_REGS);
typedef yamop * (*CEnterExoIndex)(struct index_t *it); typedef yamop * (*CEnterExoIndex)(struct index_t *it USES_REGS);
typedef int (*CRetryExoIndex)(struct index_t *it); typedef int (*CRetryExoIndex)(struct index_t *it USES_REGS);
typedef struct dbterm_list { typedef struct dbterm_list {
/* a list of dbterms associated with a clause */ /* a list of dbterms associated with a clause */