more fixes for indexing code

stable stuff


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@867 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2003-09-15 01:25:29 +00:00
parent 17ecf0dc14
commit 98578b16dc
19 changed files with 980 additions and 99 deletions

View File

@ -1070,11 +1070,29 @@ Yap_absmi(int inp)
*****************************************************************/
/* enter logical pred */
BOp(try_logical_pred, l);
BOp(stale_lu_index, Ill);
saveregs();
{
/* update ASP before calling IPred */
ASP = YREG+E_CB;
if (ASP > (CELL *) B) {
ASP = (CELL *) B;
}
PREG = Yap_CleanUpIndex(PREG->u.Ill.I);
/* restart index */
setregs();
CACHED_A1() = ARG1;
JMPNext();
}
ENDBOp();
/* enter logical pred */
BOp(enter_lu_pred, Ill);
/* mark the indexing code */
{
LogUpdIndex *cl = (LogUpdIndex *)PREG->u.l.l;
PREG = NEXTOP(PREG, l);
LogUpdIndex *cl = PREG->u.Ill.I;
PREG = PREG->u.Ill.l1;
LOCK(cl->ClLock);
/* indicate the indexing code is being used */
#if defined(YAPOR) || defined(THREADS)
@ -1508,7 +1526,9 @@ Yap_absmi(int inp)
case _retry_and_mark:
case _profiled_retry_and_mark:
case _retry:
case _retry_killed:
case _trust:
case _trust_killed:
low_level_trace(retry_pred, PREG->u.ld.p, B->cp_args);
break;
default:
@ -6281,11 +6301,10 @@ Yap_absmi(int inp)
if (ASP > (CELL *) B) {
ASP = (CELL *) B;
}
Yap_ExpandIndex(pe);
PREG = Yap_ExpandIndex(pe);
/* restart index */
setregs();
CACHED_A1() = ARG1;
PREG = pe->CodeOfPred;
JMPNext();
}
ENDBOp();
@ -6479,7 +6498,12 @@ Yap_absmi(int inp)
JMPNext();
ENDBOp();
BOp(retry_killed, ld);
goto retry_label;
ENDBOp();
BOp(retry, ld);
retry_label:
CACHE_Y(B);
restore_yaam_regs(NEXTOP(PREG, ld));
restore_at_least_one_arg(PREG->u.ld.s);
@ -6495,7 +6519,12 @@ Yap_absmi(int inp)
JMPNext();
ENDBOp();
BOp(trust_killed, ld);
goto trust_label;
ENDBOp();
BOp(trust, ld);
trust_label:
CACHE_Y(B);
#ifdef YAPOR
if (SCH_top_shared_cp(B)) {

View File

@ -343,6 +343,19 @@ a_cl(op_numbers opcode)
GONEXT(l);
}
static void
a_lucl(op_numbers opcode)
{
if (pass_no) {
code_p->opc = emit_op(opcode);
code_p->u.Ill.I = (LogUpdIndex *)code_addr;
code_p->u.Ill.l1 = emit_ilabel(cpc->rnd1);
code_p->u.Ill.l2 = emit_ilabel(cpc->rnd2);
code_p->u.Ill.s = cpc->rnd3;
}
GONEXT(Ill);
}
static void
a_cle(op_numbers opcode)
{
@ -2317,9 +2330,6 @@ do_pass(void)
a_deallocate();
break;
case tryme_op:
if (log_update && assembling == ASSEMBLING_INDEX) {
a_cl(_try_logical_pred);
}
TRYCODE(_try_me, _try_me0);
break;
case retryme_op:
@ -2331,10 +2341,10 @@ do_pass(void)
}
TRYCODE(_trust_me, _trust_me0);
break;
case enter_lu_op:
a_lucl(_enter_lu_pred);
break;
case try_op:
if (log_update) {
a_cl(_try_logical_pred);
}
a_gl(_try_clause);
break;
case retry_op:

View File

@ -264,12 +264,19 @@ static void
decrease_log_indices(LogUpdIndex *c, yamop *suspend_code)
{
/* decrease all reference counters */
yamop *beg = c->ClCode,
*end = (yamop *)((CODEADDR)c+Yap_SizeOfBlock((CODEADDR)c)),
*ipc;
yamop *beg = c->ClCode, *end, *ipc;
op_numbers op;
if (c->ClFlags & SwitchTableMask) {
return;
}
op = Yap_op_from_opcode(beg->opc);
if ((op == _enter_lu_pred ||
op == _stale_lu_index) &&
beg->u.Ill.l1 != beg->u.Ill.l2) {
end = beg->u.Ill.l2;
} else {
end = (yamop *)((CODEADDR)c+Yap_SizeOfBlock((CODEADDR)c));
}
ipc = beg;
while (ipc < end) {
op_numbers op = Yap_op_from_opcode(ipc->opc);
@ -286,9 +293,11 @@ decrease_log_indices(LogUpdIndex *c, yamop *suspend_code)
ipc = NEXTOP(ipc,xxp);
break;
case _retry:
case _retry_killed:
case _retry_profiled:
case _count_retry:
case _trust:
case _trust_killed:
decrease_ref_counter(ipc->u.ld.d, beg, end, suspend_code);
ipc = NEXTOP(ipc,ld);
break;
@ -312,8 +321,11 @@ decrease_log_indices(LogUpdIndex *c, yamop *suspend_code)
case _trust_me4:
ipc = NEXTOP(ipc,ld);
break;
case _enter_lu_pred:
case _stale_lu_index:
ipc = ipc->u.Ill.l1;
break;
case _try_in:
case _try_logical_pred:
case _trust_logical_pred:
case _jump:
case _jump_if_var:

View File

@ -616,6 +616,7 @@ static char *opformat[] =
"count_retry_op\t\t%g",
"restore_temps\t\t%l",
"restore_temps_and_skip\t\t%l",
"enter_lu",
"empty_call\t\t%l,%d",
#ifdef TABLING
"table_new_answer",

View File

@ -1570,8 +1570,10 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat)
linkblk(LinkAr, CellPtr(ppt->Contents-1), (CELL)ppt-(CELL)ppt0);
#endif
ppt->Entry = AdjustIDBPtr(tt,(CELL)ppt-(CELL)ppt0);
#ifdef COROUTINING
if (ppt->attachments)
ppt->attachments = AdjustIDBPtr(ppt->attachments,(CELL)ppt-(CELL)ppt0);
#endif
} else {
ppt->Entry = tt;
}

View File

@ -1616,7 +1616,7 @@ Yap_InitExecFs(void)
Yap_InitCPred("$call_with_args", 11, p_execute_9, 0);
Yap_InitCPred("$call_with_args", 12, p_execute_10, 0);
#ifdef DEPTH_LIMIT
Yap_InitCPred("depth_bound_call", 2, p_execute_depth_limit, 0);
Yap_InitCPred("$execute_under_depth_limit", 2, p_execute_depth_limit, 0);
#endif
Yap_InitCPred("$execute0", 2, p_execute0, 0);
Yap_InitCPred("$save_current_choice_point", 1, p_save_cp, 0);

View File

@ -1710,7 +1710,9 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose)
case _retry_me4:
case _trust_me4:
case _retry:
case _retry_killed:
case _trust:
case _trust_killed:
nargs = rtp->u.ld.s;
break;
case _jump:

930
C/index.c

File diff suppressed because it is too large Load Diff

View File

@ -211,7 +211,7 @@ unix_upd_stream_info (StreamDesc * s)
}
#if USE_SOCKET
if (Yap_sockets_io &&
(YP_fileno (s->u.file.file) == 0))
s->u.file.file == NULL)
{
s->status |= Socket_Stream_f;
s->u.socket.domain = af_inet;
@ -385,9 +385,15 @@ InitStdStream (int sno, SMALLUNSGN flags, YP_File file)
static void
InitStdStreams (void)
{
InitStdStream (StdInStream, Input_Stream_f, stdin);
InitStdStream (StdOutStream, Output_Stream_f, stdout);
InitStdStream (StdErrStream, Output_Stream_f, stderr);
if (Yap_sockets_io) {
InitStdStream (StdInStream, Input_Stream_f, NULL);
InitStdStream (StdOutStream, Output_Stream_f, NULL);
InitStdStream (StdErrStream, Output_Stream_f, NULL);
} else {
InitStdStream (StdInStream, Input_Stream_f, stdin);
InitStdStream (StdOutStream, Output_Stream_f, stdout);
InitStdStream (StdErrStream, Output_Stream_f, stderr);
}
Yap_c_input_stream = StdInStream;
Yap_c_output_stream = StdOutStream;
Yap_c_error_stream = StdErrStream;
@ -666,7 +672,13 @@ ConsoleSocketPutc (int sno, int ch)
#if _MSC_VER || defined(__MINGW32__)
send(s->u.socket.fd, &c, sizeof(c), 0);
#else
write(s->u.socket.fd, &c, sizeof(c));
if (write(s->u.socket.fd, &c, sizeof(c)) < 0) {
#if HAVE_STRERROR
Yap_Error(FATAL_ERROR, TermNil, "no access to console: %s", strerror(errno));
#else
Yap_Error(FATAL_ERROR, TermNil, "no access to console");
#endif
}
#endif
count_output_char(ch,s);
return ((int) ch);

View File

@ -113,6 +113,7 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
/* extern int gc_calls; */
vsc_count++;
return;
#ifdef COMMENTED
if (vsc_count < 5530257LL) {
return;

View File

@ -249,11 +249,14 @@
OPCODE(count_retry_me ,ld),
OPCODE(count_trust_me ,ld),
OPCODE(count_retry_and_mark ,ld),
OPCODE(try_logical_pred ,l),
OPCODE(enter_lu_pred ,Ill),
OPCODE(stale_lu_index ,Ill),
OPCODE(trust_logical_pred ,l),
OPCODE(alloc_for_logical_pred ,EC),
OPCODE(unify_idb_term ,e),
OPCODE(copy_idb_term ,e),
OPCODE(retry_killed ,ld),
OPCODE(trust_killed ,ld),
#ifdef SFUNC
OPCODE(get_s_f ,),
OPCODE(put_s_f ,),

View File

@ -165,6 +165,13 @@ typedef struct yami {
CODEADDR l2;
CELL next;
} fll;
struct {
struct logic_upd_index *I;
struct yami *l1;
struct yami *l2;
COUNT s;
CELL next;
} Ill;
struct {
struct yami *l;
CELL next;

View File

@ -180,6 +180,7 @@ Term STD_PROTO(Yap_cp_as_integer,(choiceptr));
/* index.c */
yamop *STD_PROTO(Yap_PredIsIndexable,(PredEntry *));
yamop *STD_PROTO(Yap_ExpandIndex,(PredEntry *));
yamop *STD_PROTO(Yap_CleanUpIndex,(struct logic_upd_index *));
void STD_PROTO(Yap_AddClauseToIndex,(PredEntry *,yamop *,int));
void STD_PROTO(Yap_RemoveClauseFromIndex,(PredEntry *,yamop *));
LogUpdClause *STD_PROTO(Yap_follow_lu_indexing_code,(PredEntry *,yamop *,Term,Term,Term, yamop *,yamop *));

View File

@ -130,6 +130,7 @@ typedef enum compiler_op {
count_retry_op,
restore_tmps_op,
restore_tmps_and_skip_op,
enter_lu_op,
empty_call_op,
#ifdef TABLING
table_new_answer_op,

View File

@ -114,3 +114,8 @@ typedef struct {
#define MAX_ISTACK_DEPTH 32
typedef enum {
REFRESH,
RECORDA,
RECORDZ
} expand_values;

View File

@ -639,7 +639,9 @@ RestoreClause(yamop *pc, PredEntry *pp, int mode)
case _retry_and_mark:
case _try_clause:
case _retry:
case _retry_killed:
case _trust:
case _trust_killed:
#ifdef YAPOR
case _getwork:
case _getwork_seq:
@ -657,12 +659,18 @@ RestoreClause(yamop *pc, PredEntry *pp, int mode)
pc->u.ld.d = PtoOpAdjust(pc->u.ld.d);
pc = NEXTOP(pc,ld);
break;
case _enter_lu_pred:
case _stale_lu_index:
pc->u.Ill.I = (LogUpdIndex *)PtoOpAdjust((yamop *)(pc->u.Ill.I));
pc->u.Ill.l1 = PtoOpAdjust(pc->u.Ill.l1);
pc->u.Ill.l2 = PtoOpAdjust(pc->u.Ill.l2);
pc = NEXTOP(pc,Ill);
break;
/* instructions type l */
case _enter_profiling:
case _count_call:
case _retry_profiled:
case _count_retry:
case _try_logical_pred:
case _trust_logical_pred:
case _execute:
case _dexecute:

View File

@ -281,11 +281,11 @@ parse_yap_arguments(int argc, char *argv[], YAP_init_args *iap)
host = *++argv;
argc--;
if (host != NULL && host[0] == '-')
if (host == NULL || host[0] == '-')
YAP_Error("sockets must receive host to connect to");
p1 = *++argv;
argc--;
if (p1[0] == '-')
if (p1 == NULL || p1[0] == '-')
YAP_Error("sockets must receive port to connect to");
port = strtol(p1, &ptr, 10);
if (ptr == NULL || ptr[0] != '\0')

View File

@ -17,6 +17,6 @@
%depth_bound_call(A,D) :-
%write(depth_bound_call(A,D)), nl, fail.
%depth_bound_call(A,D) :-
% '$execute_under_depth_limit'(A,D).
depth_bound_call(A,D) :-
'$execute_under_depth_limit'(A,D).

View File

@ -579,6 +579,7 @@ source_module(Mod) :-
consult(:),
current_predicate(:),
current_predicate(?,:),
depth_bound_call(:,+),
ensure_loaded(:),
findall(?,:,?),
findall(?,:,?,?),