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-20 00:34:44 +00:00
commit 7589b57e4b
9 changed files with 115 additions and 43 deletions

View File

@ -3172,7 +3172,11 @@ YAP_Init(YAP_init_args *yap_init)
#endif /* YAPOR || TABLING */
#ifdef YAPOR
Yap_init_yapor_workers();
#if YAPOR_THREADS
if (Yap_thread_self() != 0) {
#else
if (worker_id != 0) {
#endif
#if defined(YAPOR_COPY) || defined(YAPOR_SBA)
/*
In the SBA we cannot just happily inherit registers
@ -3390,6 +3394,9 @@ YAP_Reset(void)
/* the first real choice-point will also have AP=FAIL */
/* always have an empty slots for people to use */
P = CP = YESCODE;
// ensure that we have slots where we need them
LOCAL_CurSlot = 0;
Yap_StartSlots( PASS_REGS1 );
RECOVER_MACHINE_REGS();
return res;
}

View File

@ -147,6 +147,16 @@ SetHeapRegs(int copying_threads USES_REGS)
LOCAL_OpenArray = PtoGloAdjust(LOCAL_OpenArray);
if (B)
B = ChoicePtrAdjust(B);
#ifdef YAPOR_THREADS
{
choiceptr cpt;
cpt = Get_LOCAL_top_cp();
if (cpt) {
// cpt = ChoicePtrAdjust( cpt );
Set_LOCAL_top_cp( cpt );
}
}
#endif
#ifdef TABLING
if (B_FZ)
B_FZ = ChoicePtrAdjust(B_FZ);
@ -1899,11 +1909,59 @@ Yap_CopyThreadStacks(int worker_q, int worker_p, int incremental)
/* make sure both stacks have same size */
Int p_size = REMOTE_ThreadHandle(worker_p).ssize+REMOTE_ThreadHandle(worker_p).tsize;
Int q_size = REMOTE_ThreadHandle(worker_q).ssize+REMOTE_ThreadHandle(worker_q).tsize;
if (p_size != q_size) {
if (!(REMOTE_ThreadHandle(worker_q).stack_address = realloc(REMOTE_ThreadHandle(worker_q).stack_address,p_size*K1))) {
exit(1);
if (p_size != q_size) {
UInt start_growth_time, growth_time;
int gc_verbose;
size_t ssiz = REMOTE_ThreadHandle(worker_q).ssize*K1;
size_t tsiz = REMOTE_ThreadHandle(worker_q).tsize*K1;
size_t diff = (REMOTE_ThreadHandle(worker_p).ssize-REMOTE_ThreadHandle(worker_q).ssize)*K1;
char *oldq = (char *)REMOTE_ThreadHandle(worker_q).stack_address, *newq;
if (!(newq = REMOTE_ThreadHandle(worker_q).stack_address = realloc(REMOTE_ThreadHandle(worker_q).stack_address,p_size*K1))) {
Yap_Error(OUT_OF_STACK_ERROR,TermNil,"cannot expand slave thread to match master thread");
}
start_growth_time = Yap_cputime();
gc_verbose = Yap_is_gc_verbose();
LOCAL_stack_overflows++;
if (gc_verbose) {
#if defined(YAPOR) || defined(THREADS)
fprintf(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",
(unsigned long int)(TR-(tr_fr_ptr)LOCAL_TrailBase),LOCAL_TrailBase,TR);
fprintf(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;
LOCAL_XDiff = LOCAL_HDiff = 0;
LOCAL_GSplit = NULL;
YAPEnterCriticalSection();
SetHeapRegs(FALSE PASS_REGS);
{
choiceptr imageB;
LOCAL_OldLCL0 = LCL0;
LCL0 = REMOTE_ThreadHandle(0).current_yaam_regs->LCL0_;
imageB = Get_GLOBAL_root_cp();
/* we know B */
B->cp_tr = TR =
(tr_fr_ptr)((CELL)(imageB->cp_tr)+((CELL)LOCAL_OldLCL0-(CELL)LCL0));
LCL0 = LOCAL_OldLCL0;
B->cp_h = H0;
B->cp_ap = GETWORK;
B->cp_or_fr = GLOBAL_root_or_fr;
}
YAPLeaveCriticalSection();
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);
}
}
REMOTE_ThreadHandle(worker_q).ssize = REMOTE_ThreadHandle(worker_p).ssize;
REMOTE_ThreadHandle(worker_q).tsize = REMOTE_ThreadHandle(worker_p).tsize;
/* compute offset indicators */

View File

@ -83,7 +83,9 @@ p_load_foreign( USES_REGS1 )
/* call the OS specific function for dynamic loading */
if(Yap_LoadForeign(ofiles,libs,InitProcName,&InitProc)==LOAD_SUCCEEDED) {
Int CurSlot = Yap_StartSlots( PASS_REGS1 );
(*InitProc)();
LOCAL_CurSlot = CurSlot;
returncode = TRUE;
}

View File

@ -1666,15 +1666,15 @@ p_access_yap_flags( USES_REGS1 )
tout = TermNil;
if (IsMode_LocalTrie(yap_flags[flag]))
tout = MkPairTerm(MkAtomTerm(AtomLocalTrie), tout);
else // if (IsMode_GlobalTrie(yap_flags[flag]))
else if (IsMode_GlobalTrie(yap_flags[flag]))
tout = MkPairTerm(MkAtomTerm(AtomGlobalTrie), tout);
if (IsMode_LoadAnswers(yap_flags[flag]))
tout = MkPairTerm(MkAtomTerm(AtomLoadAnswers), tout);
else // if (IsMode_ExecAnswers(yap_flags[flag]))
else if (IsMode_ExecAnswers(yap_flags[flag]))
tout = MkPairTerm(MkAtomTerm(AtomExecAnswers), tout);
if (IsMode_Local(yap_flags[flag]))
tout = MkPairTerm(MkAtomTerm(AtomLocal), tout);
else // if (IsMode_Batched(yap_flags[flag]))
else if (IsMode_Batched(yap_flags[flag]))
tout = MkPairTerm(MkAtomTerm(AtomBatched), tout);
#else
tout = MkAtomTerm(AtomFalse);

View File

@ -463,14 +463,14 @@ read_Text( void *buf, seq_tv_t *inp, encoding_t *enc, int *minimal, size_t *leng
#endif
case YAP_STRING_CHARS:
*enc = YAP_CHAR;
if (inp->sz)
if (inp->type & YAP_STRING_NCHARS)
*lengp = inp->sz;
else
*lengp = strlen(inp->val.c);
return (void *)inp->val.c;
case YAP_STRING_WCHARS:
*enc = YAP_WCHAR;
if (inp->sz)
if (inp->type & YAP_STRING_NCHARS)
*lengp = inp->sz;
else
*lengp = wcslen(inp->val.w);

View File

@ -127,7 +127,7 @@ store_specs(int new_worker_id, UInt ssize, UInt tsize, UInt sysize, Term *tpgoal
REMOTE_c_output_stream(new_worker_id) = REMOTE_c_output_stream(0);
REMOTE_c_error_stream(new_worker_id) = REMOTE_c_error_stream(0);
}
pm = (ssize + tsize)*1024;
pm = (ssize + tsize)*K1;
if (!(REMOTE_ThreadHandle(new_worker_id).stack_address = malloc(pm))) {
return FALSE;
}

View File

@ -294,6 +294,7 @@ Yap_CharsToAtom( const char *s USES_REGS )
seq_tv_t inp, out;
inp.val.c = s;
inp.sz = 0;
inp.type = YAP_STRING_CHARS;
out.type = YAP_STRING_ATOM;
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
@ -307,6 +308,7 @@ Yap_CharsToListOfAtoms( const char *s USES_REGS )
seq_tv_t inp, out;
inp.val.c = s;
inp.sz = 0;
inp.type = YAP_STRING_CHARS;
out.type = YAP_STRING_ATOMS;
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
@ -320,6 +322,7 @@ Yap_CharsToListOfCodes( const char *s USES_REGS )
seq_tv_t inp, out;
inp.val.c = s;
inp.sz = 0;
inp.type = YAP_STRING_CHARS;
out.type = YAP_STRING_CODES;
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
@ -333,6 +336,7 @@ Yap_CharsToString( const char *s USES_REGS )
seq_tv_t inp, out;
inp.val.c = s;
inp.sz = 0;
inp.type = YAP_STRING_CHARS;
out.type = YAP_STRING_STRING;
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
@ -346,6 +350,7 @@ Yap_CharsToTDQ( const char *s, Term mod USES_REGS )
seq_tv_t inp, out;
inp.val.c = s;
inp.sz = 0;
inp.type = YAP_STRING_CHARS;
inp.mod = mod;
out.type = mod_to_type(mod PASS_REGS);
@ -689,7 +694,7 @@ static inline Atom
Yap_StringToAtom(Term t0 USES_REGS)
{
seq_tv_t inp, out;
inp.sz = -1;
inp.sz = 0;
inp.val.t = t0;
inp.type = YAP_STRING_STRING;
out.type = YAP_STRING_ATOM;
@ -702,7 +707,7 @@ static inline Atom
Yap_StringSWIToAtom(Term t0 USES_REGS)
{
seq_tv_t inp, out;
inp.sz = -1;
inp.sz = 0;
inp.val.t = t0;
inp.type = YAP_STRING_STRING|YAP_STRING_ATOM|YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_ATOMS_CODES|YAP_STRING_TERM;
out.type = YAP_STRING_ATOM;
@ -715,7 +720,7 @@ static inline size_t
Yap_StringToAtomic(Term t0 USES_REGS)
{
seq_tv_t inp, out;
inp.sz = -1;
inp.sz = 0;
inp.val.t = t0;
inp.type = YAP_STRING_STRING;
out.type = YAP_STRING_ATOM|YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM;
@ -728,7 +733,7 @@ static inline size_t
Yap_StringToLength(Term t0 USES_REGS)
{
seq_tv_t inp, out;
inp.sz = -1;
inp.sz = 0;
inp.val.t = t0;
inp.type = YAP_STRING_STRING;
out.type = YAP_STRING_LENGTH;
@ -741,7 +746,7 @@ static inline size_t
Yap_StringToListOfAtoms(Term t0 USES_REGS)
{
seq_tv_t inp, out;
inp.sz = -1;
inp.sz = 0;
inp.val.t = t0;
inp.type = YAP_STRING_STRING;
out.type = YAP_STRING_ATOMS;
@ -754,7 +759,7 @@ static inline size_t
Yap_StringSWIToListOfAtoms(Term t0 USES_REGS)
{
seq_tv_t inp, out;
inp.sz = -1;
inp.sz = 0;
inp.val.t = t0;
inp.type = YAP_STRING_STRING|YAP_STRING_ATOM|YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_ATOMS_CODES|YAP_STRING_TERM;
out.type = YAP_STRING_ATOMS;
@ -768,7 +773,7 @@ Yap_StringToListOfCodes(Term t0 USES_REGS)
{
seq_tv_t inp, out;
inp.val.t = t0;
inp.sz = -1;
inp.sz = 0;
inp.type = YAP_STRING_STRING;
out.type = YAP_STRING_CODES;
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
@ -793,7 +798,7 @@ Yap_StringToNumber(Term t0 USES_REGS)
{
seq_tv_t inp, out;
inp.val.t = t0;
inp.sz = -1;
inp.sz = 0;
inp.type = YAP_STRING_STRING;
out.type = YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM;
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
@ -806,7 +811,7 @@ Yap_WCharsToListOfCodes(const wchar_t *s USES_REGS)
{
seq_tv_t inp, out;
inp.val.w = s;
inp.sz = -1;
inp.sz = 0;
inp.type = YAP_STRING_WCHARS;
out.type = YAP_STRING_CODES;
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
@ -821,7 +826,7 @@ Yap_WCharsToTDQ( wchar_t *s, Term mod USES_REGS )
inp.val.w = s;
inp.type = YAP_STRING_WCHARS;
inp.sz = -1;
inp.sz = 0;
inp.mod = mod;
out.type = mod_to_type(mod PASS_REGS);
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
@ -834,7 +839,7 @@ Yap_WCharsToString(const wchar_t *s USES_REGS)
{
seq_tv_t inp, out;
inp.val.w = s;
inp.sz = -1;
inp.sz = 0;
inp.type = YAP_STRING_WCHARS;
out.type = YAP_STRING_STRING;
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
@ -848,10 +853,10 @@ Yap_ConcatAtoms(Term t1, Term t2 USES_REGS)
seq_tv_t inpv[2], out;
inpv[0].val.t = t1;
inpv[0].type = YAP_STRING_ATOM;
inpv[0].sz = -1;
inpv[0].sz = 0;
inpv[1].val.t = t2;
inpv[1].type = YAP_STRING_ATOM;
inpv[1].sz = -1;
inpv[1].sz = 0;
out.type = YAP_STRING_ATOM;
if (!Yap_Concat_Text(2, inpv, &out PASS_REGS))
return NULL;
@ -864,10 +869,10 @@ Yap_ConcatAtomics(Term t1, Term t2 USES_REGS)
seq_tv_t inpv[2], out;
inpv[0].val.t = t1;
inpv[0].type = YAP_STRING_STRING|YAP_STRING_ATOM|YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM;
inpv[0].sz = -1;
inpv[0].sz = 0;
inpv[1].val.t = t2;
inpv[1].type = YAP_STRING_STRING|YAP_STRING_ATOM|YAP_STRING_INT|YAP_STRING_FLOAT|YAP_STRING_BIG|YAP_STRING_TERM;
inpv[1].sz = -1;
inpv[1].sz = 0;
out.type = YAP_STRING_ATOM;
if (!Yap_Concat_Text(2, inpv, &out PASS_REGS))
return NULL;
@ -880,10 +885,10 @@ Yap_ConcatStrings(Term t1, Term t2 USES_REGS)
seq_tv_t inpv[2], out;
inpv[0].val.t = t1;
inpv[0].type = YAP_STRING_STRING;
inpv[0].sz = -1;
inpv[0].sz = 0;
inpv[1].val.t = t2;
inpv[1].type = YAP_STRING_STRING;
inpv[1].sz = -1;
inpv[1].sz = 0;
out.type = YAP_STRING_STRING;
if (!Yap_Concat_Text(2, inpv, &out PASS_REGS))
return 0L;
@ -900,11 +905,11 @@ Yap_SpliceAtom(Term t1, Atom ats[], size_t cut, size_t max USES_REGS)
cuts[1] = max;
inp.type = YAP_STRING_ATOM;
inp.val.t = t1;
inp.sz = -1;
inp.sz = 0;
outv[0].type = YAP_STRING_ATOM;
outv[0].sz = -1;
outv[0].sz = 0;
outv[1].type = YAP_STRING_ATOM;
outv[1].sz = -1;
outv[1].sz = 0;
if (!Yap_Splice_Text(2, cuts, &inp, NULL, outv PASS_REGS))
return NULL;
ats[0] = outv[0].val.a;
@ -918,13 +923,13 @@ Yap_SubtractHeadAtom(Term t1, Term th USES_REGS)
seq_tv_t outv[2], inp;
inp.type = YAP_STRING_ATOM;
inp.val.t = t1;
inp.sz = -1;
inp.sz = 0;
outv[0].type = YAP_STRING_ATOM;
outv[0].val.t = th;
outv[0].sz = -1;
outv[0].sz = 0;
outv[1].type = YAP_STRING_ATOM;
outv[1].val.t = 0;
outv[1].sz = -1;
outv[1].sz = 0;
if (!Yap_Splice_Text(2, NULL, &inp, NULL, outv PASS_REGS))
return NULL;
return outv[1].val.a;
@ -937,10 +942,10 @@ Yap_SubtractTailAtom(Term t1, Term th USES_REGS)
seq_tv_t outv[2], inp;
inp.type = YAP_STRING_ATOM;
inp.val.t = t1;
inp.sz = -1;
inp.sz = 0;
outv[0].type = YAP_STRING_ATOM;
outv[0].val.t = 0;
outv[0].sz = -1;
outv[0].sz = 0;
outv[1].type = YAP_STRING_ATOM;
outv[1].val.t = th;
if (!Yap_Splice_Text(2, NULL, &inp, NULL, outv PASS_REGS))
@ -955,10 +960,10 @@ Yap_SpliceString(Term t1, Term ts[], size_t cut, size_t max USES_REGS)
size_t cuts[2];
inp.type = YAP_STRING_STRING;
inp.val.t = t1;
inp.sz = -1;
inp.sz = 0;
outv[0].type = YAP_STRING_STRING;
outv[1].type = YAP_STRING_STRING;
outv[1].sz = -1;
outv[1].sz = 0;
cuts[0] = cut;
cuts[1] = max;
if (!Yap_Splice_Text(2, cuts, &inp, NULL, outv PASS_REGS))
@ -974,13 +979,13 @@ Yap_SubtractHeadString(Term t1, Term th USES_REGS)
seq_tv_t outv[2], inp;
inp.type = YAP_STRING_STRING;
inp.val.t = t1;
inp.sz = -1;
inp.sz = 0;
outv[0].type = YAP_STRING_STRING;
outv[0].val.t = th;
outv[0].sz = -1;
outv[0].sz = 0;
outv[1].type = YAP_STRING_STRING;
outv[1].val.t = 0;
outv[1].sz = -1;
outv[1].sz = 0;
if (!Yap_Splice_Text(2, NULL, &inp, NULL, outv PASS_REGS))
return 0L;
return outv[1].val.t;
@ -992,10 +997,10 @@ Yap_SubtractTailString(Term t1, Term th USES_REGS)
seq_tv_t outv[2], inp;
inp.type = YAP_STRING_STRING;
inp.val.t = t1;
inp.sz = -1;
inp.sz = 0;
outv[0].type = YAP_STRING_STRING;
outv[0].val.t = 0;
outv[0].sz = -1;
outv[0].sz = 0;
outv[1].type = YAP_STRING_STRING;
outv[1].val.t = th;
if (!Yap_Splice_Text(2, NULL, &inp, NULL, outv PASS_REGS))

@ -1 +1 @@
Subproject commit a383bfd51144172fdea8463bd56e9308742e5de2
Subproject commit 5a72fe49e5a5c651a890a388eb967b83da8e2c52

View File

@ -224,7 +224,7 @@ absolute_file_name(File,Opts,TrueFileName) :-
(Type == directory ->
exists_directory(F0)
;
\+ exists_directory(F0) % if it has a type cannot be a directory.
\+ exists_directory(F0) % if it has a type cannot be a directory.
).
'$add_extensions'([Ext|_],File,F) :-