make --enable-threads work on CVS release.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@645 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2002-10-21 22:14:29 +00:00
parent f7f3da7704
commit 0351b9f0ab
15 changed files with 3505 additions and 10058 deletions

View File

@ -12,7 +12,7 @@
* Last rev: *
* mods: *
* comments: allocating space *
* version:$Id: alloc.c,v 1.24 2002-10-17 01:37:46 vsc Exp $ *
* version:$Id: alloc.c,v 1.25 2002-10-21 22:14:28 vsc Exp $ *
*************************************************************************/
#ifdef SCCS
static char SccsId[] = "%W% %G%";
@ -165,7 +165,6 @@ FreeBlock(BlockHeader *b)
}
b->b_size &= ~InUseFlag;
LOCK(FreeBlocksLock);
LOCK(GLOBAL_LOCKS_alloc_block);
/* check if we can collapse with other blocsks */
/* check previous */
sp = &(b->b_size) - 1;
@ -199,7 +198,6 @@ FreeBlock(BlockHeader *b)
if (!HEAPTOP_OWNER(worker_id)) {
UNLOCK(HeapTopLock);
}
UNLOCK(GLOBAL_LOCKS_alloc_block);
UNLOCK(FreeBlocksLock);
}
@ -244,7 +242,6 @@ AllocHeap(unsigned int size)
if (size < 6)
size = 6;
LOCK(FreeBlocksLock);
LOCK(GLOBAL_LOCKS_alloc_block);
if ((b = GetBlock(size))) {
if (b->b_size >= size + 6 + 1) {
n = (BlockHeader *) (((YAP_SEG_SIZE *) b) + size + 1);
@ -255,7 +252,6 @@ AllocHeap(unsigned int size)
sp = &(b->b_size) + b->b_size;
*sp = b->b_size | InUseFlag;
b->b_size |= InUseFlag;
UNLOCK(GLOBAL_LOCKS_alloc_block);
UNLOCK(FreeBlocksLock);
return (Addr(b) + sizeof(YAP_SEG_SIZE));
}
@ -311,7 +307,6 @@ AllocHeap(unsigned int size)
if (HeapUsed > HeapMax)
HeapMax = HeapUsed;
HeapPlus = HeapTop + MinHGap / CellSize;
UNLOCK(GLOBAL_LOCKS_alloc_block);
UNLOCK(HeapUsedLock);
b->b_size = size | InUseFlag;
sp = &(b->b_size) + size;

View File

@ -1762,7 +1762,7 @@ p_compile_mode(void)
return (TRUE);
}
#if !defined(YAPOR) && !defined(THREADS)
#if !defined(YAPOR)
static yamop *next_clause(PredEntry *pe, CODEADDR codeptr)
{
CODEADDR clcode, cl;
@ -2008,12 +2008,6 @@ all_calls(void)
return(MkApplTerm(f,3,ts));
}
static Int
p_current_stack(void)
{
return(unify(ARG1,all_calls()));
}
static void
mark_pred(int mark, PredEntry *pe)
{
@ -2089,6 +2083,16 @@ do_toggle_static_predicates_in_use(int mask)
#endif
static Int
p_current_stack(void)
{
#ifdef YAPOR
return(FALSE);
#else
return(unify(ARG1,all_calls()));
#endif
}
/* This predicate is to be used by reconsult to mark all predicates
currently in use as being executed.

View File

@ -1229,12 +1229,10 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
INIT_LOCK(pp->lock);
INIT_DBREF_COUNT(pp);
return(pp);
} else if (IsAtomOrIntTerm(Tm)) {
Register DBRef pp;
SMALLUNSGN flag;
tt = Tm;
flag = DBAtomic;
if (IsAtomOrIntTerm(tt))
@ -1274,8 +1272,10 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
ntp = MkDBTerm(VarOfTerm(Tm), VarOfTerm(Tm), ntp0, ntp0+1, ntp0-1,
&attachments,
&vars_found);
if (ntp == NULL)
return(NULL);
if (ntp == NULL) {
ReleasePreAllocCodeSpace((ADDR)pp0);
return(NULL);
}
} else
#endif
if (IsPairTerm(Tm)) {
@ -1287,6 +1287,7 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
#endif
&vars_found);
if (ntp == NULL) {
ReleasePreAllocCodeSpace((ADDR)pp0);
return(NULL);
}
}
@ -1340,6 +1341,7 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
pp->Code = NULL;
INIT_LOCK(pp->lock);
INIT_DBREF_COUNT(pp);
ReleasePreAllocCodeSpace((ADDR)pp0);
return(pp);
}
#ifdef USE_GMP
@ -1375,13 +1377,17 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
&attachments,
#endif
&vars_found);
if (ntp == NULL)
if (ntp == NULL) {
ReleasePreAllocCodeSpace((ADDR)pp0);
return(NULL);
}
}
}
CodeAbs = (CELL *)((CELL)ntp-(CELL)ntp0);
if (DBErrorFlag)
if (DBErrorFlag) {
ReleasePreAllocCodeSpace((ADDR)pp0);
return (NULL); /* Error Situation */
}
NOfCells = ntp - ntp0; /* End Of Code Info */
#ifdef IDB_LINK_TABLE
*lr++ = 0;
@ -1398,13 +1404,16 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
CodeAbs += CellPtr(lr) - CellPtr(LinkAr);
if ((CELL *)((char *)ntp0+(CELL)CodeAbs) > AuxSp) {
DBErrorFlag = OVF_ERROR_IN_DB;
ReleasePreAllocCodeSpace((ADDR)pp0);
return(NULL);
}
/* restore lr to NULL in case there is a TR overflow */
lr = NULL;
#endif
if ((InFlag & MkIfNot) && (found_one = check_if_wvars(p->First, NOfCells, ntp0)))
if ((InFlag & MkIfNot) && (found_one = check_if_wvars(p->First, NOfCells, ntp0))) {
ReleasePreAllocCodeSpace((ADDR)pp0);
return (found_one);
}
} else {
#ifdef IDB_LINK_TABLE
/* make sure lr ends in 0 for check_if_nvars */
@ -1412,13 +1421,16 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
lr = NULL;
#endif
flag = DBNoVars;
if ((InFlag & MkIfNot) && (found_one = check_if_nvars(p->First, NOfCells, ntp0)))
if ((InFlag & MkIfNot) && (found_one = check_if_nvars(p->First, NOfCells, ntp0))) {
ReleasePreAllocCodeSpace((ADDR)pp0);
return (found_one);
}
}
if (tofref != TmpRefBase) {
CodeAbs += TmpRefBase - tofref + 1;
if ((CELL *)((char *)ntp0+(CELL)CodeAbs) > AuxSp) {
DBErrorFlag = OVF_ERROR_IN_DB;
ReleasePreAllocCodeSpace((ADDR)pp0);
return(NULL);
}
flag |= DBWithRefs;
@ -1430,6 +1442,7 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
DBErrorNumber = SYSTEM_ERROR;
DBErrorTerm = TermNil;
DBErrorMsg = "trying to store term larger than 256KB";
ReleasePreAllocCodeSpace((ADDR)pp0);
return(NULL);
}
#endif
@ -1440,6 +1453,7 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
DBErrorNumber = SYSTEM_ERROR;
DBErrorTerm = TermNil;
DBErrorMsg = "heap crashed against stacks";
ReleasePreAllocCodeSpace((ADDR)pp0);
return(NULL);
}
pp->id = FunctorDBRef;

View File

@ -834,6 +834,7 @@ InitCodes(void)
INIT_LOCK(heap_regs->heap_used_lock);
INIT_LOCK(heap_regs->heap_top_lock);
INIT_LOCK(heap_regs->dead_clauses_lock);
heap_regs->heap_top_owner = -1;
#endif /* YAPOR */
heap_regs->clausecode.arity = 0;
heap_regs->clausecode.clause = NIL;
@ -1194,6 +1195,9 @@ InitStacks(int Heap,
register array, but for now they exist */
#endif /* PUSH_REGS */
#ifdef THREADS
regp->worker_id_ = 0;
#endif
/* Init signal handling and time */
/* also init memory page size, required by later functions */
InitSysbits ();

View File

@ -2231,3 +2231,92 @@ int WINAPI win_yap(HANDLE hinst, DWORD reason, LPVOID reserved)
}
#endif
#if defined(YAPOR) || defined(THREADS)
#ifdef sparc
void STD_PROTO(rw_lock_voodoo,(void));
void
rw_lock_voodoo(void) {
/* code taken from the Linux kernel, it handles shifting between locks */
/* Read/writer locks, as usual this is overly clever to make it as fast as possible. */
/* caches... */
__asm__ __volatile__(
"___rw_read_enter_spin_on_wlock:\n"
" orcc %g2, 0x0, %g0\n"
" be,a ___rw_read_enter\n"
" ldstub [%g1 + 3], %g2\n"
" b ___rw_read_enter_spin_on_wlock\n"
" ldub [%g1 + 3], %g2\n"
"___rw_read_exit_spin_on_wlock:\n"
" orcc %g2, 0x0, %g0\n"
" be,a ___rw_read_exit\n"
" ldstub [%g1 + 3], %g2\n"
" b ___rw_read_exit_spin_on_wlock\n"
" ldub [%g1 + 3], %g2\n"
"___rw_write_enter_spin_on_wlock:\n"
" orcc %g2, 0x0, %g0\n"
" be,a ___rw_write_enter\n"
" ldstub [%g1 + 3], %g2\n"
" b ___rw_write_enter_spin_on_wlock\n"
" ld [%g1], %g2\n"
"\n"
" .globl ___rw_read_enter\n"
"___rw_read_enter:\n"
" orcc %g2, 0x0, %g0\n"
" bne,a ___rw_read_enter_spin_on_wlock\n"
" ldub [%g1 + 3], %g2\n"
" ld [%g1], %g2\n"
" add %g2, 1, %g2\n"
" st %g2, [%g1]\n"
" retl\n"
" mov %g4, %o7\n"
" .globl ___rw_read_exit\n"
"___rw_read_exit:\n"
" orcc %g2, 0x0, %g0\n"
" bne,a ___rw_read_exit_spin_on_wlock\n"
" ldub [%g1 + 3], %g2\n"
" ld [%g1], %g2\n"
" sub %g2, 0x1ff, %g2\n"
" st %g2, [%g1]\n"
" retl\n"
" mov %g4, %o7\n"
" .globl ___rw_write_enter\n"
"___rw_write_enter:\n"
" orcc %g2, 0x0, %g0\n"
" bne ___rw_write_enter_spin_on_wlock\n"
" ld [%g1], %g2\n"
" andncc %g2, 0xff, %g0\n"
" bne,a ___rw_write_enter_spin_on_wlock\n"
" stb %g0, [%g1 + 3]\n"
" retl\n"
" mov %g4, %o7\n"
);
}
#endif /* sparc */
#ifdef i386
asm(
".align 4\n"
".globl __write_lock_failed\n"
"__write_lock_failed:\n"
" lock; addl $" RW_LOCK_BIAS_STR ",(%eax)\n"
"1: cmpl $" RW_LOCK_BIAS_STR ",(%eax)\n"
" jne 1b\n"
" lock; subl $" RW_LOCK_BIAS_STR ",(%eax)\n"
" jnz __write_lock_failed\n"
" ret\n"
".align 4\n"
".globl __read_lock_failed\n"
"__read_lock_failed:\n"
" lock ; incl (%eax)\n"
"1: cmpl $1,(%eax)\n"
" js 1b\n"
" lock ; decl (%eax)\n"
" js __read_lock_failed\n"
" ret\n"
);
#endif /* i386 */
#endif /* YAPOR || THREADS */

View File

@ -10,7 +10,7 @@
* File: Regs.h *
* mods: *
* comments: YAP abstract machine registers *
* version: $Id: Regs.h,v 1.15 2002-05-14 18:24:33 vsc Exp $ *
* version: $Id: Regs.h,v 1.16 2002-10-21 22:14:28 vsc Exp $ *
*************************************************************************/
@ -101,7 +101,8 @@ typedef struct
choiceptr B_FZ_;
tr_fr_ptr TR_FZ_;
#endif
#ifdef YAPOR
#if defined(YAPOR) || defined(THREADS)
unsigned int worker_id_;
#ifdef SBA
choiceptr BSEG_;
struct or_frame *frame_head_, *frame_tail_;
@ -110,7 +111,7 @@ typedef struct
int sba_end_;
int sba_size_;
#endif /* SBA */
#endif /* YAPOR */
#endif /* YAPOR || THREADS */
#if PUSH_REGS
/* On a X86 machine, the best solution is to keep the
X registers on a global variable, whose address is known between
@ -634,7 +635,8 @@ EXTERN inline void restore_B(void) {
#define B_FZ REGS.B_FZ_
#define TR_FZ REGS.TR_FZ_
#endif
#ifdef YAPOR
#if defined(YAPOR) || defined(THREADS)
#define worker_id (REGS.worker_id_)
#ifdef SBA
#define BSEG REGS.BSEG_
#define binding_array REGS.binding_array_

View File

@ -10,7 +10,7 @@
* File: Yap.proto *
* mods: *
* comments: Function declarations for YAP *
* version: $Id: Yapproto.h,v 1.24 2002-10-17 00:05:29 vsc Exp $ *
* version: $Id: Yapproto.h,v 1.25 2002-10-21 22:14:28 vsc Exp $ *
*************************************************************************/
/* prototype file for Yap */
@ -50,6 +50,7 @@ Term STD_PROTO(StringToList,(char *));
Term STD_PROTO(StringToListOfAtoms,(char *));
long STD_PROTO(_YAP_InitSlot,(Term));
long STD_PROTO(_YAP_NewSlots,(int));
Term STD_PROTO(_YAP_GetFromSlot,(long));
void STD_PROTO(_YAP_RecoverSlots,(int));
Term STD_PROTO(_YAP_GetFromSlot,(long));

View File

@ -109,97 +109,4 @@ void error_message(const char *mesg, ...) {
}
#endif /* YAPOR_ERRORS || TABLING_ERRORS */
#ifdef YAPOR
#ifdef sparc
void rw_lock_voodoo(void) {
/* code taken from the Linux kernel, it handles shifting between locks */
/* Read/writer locks, as usual this is overly clever to make it as fast as possible. */
/* caches... */
__asm__ __volatile__(
"___rw_read_enter_spin_on_wlock:"
" orcc %g2, 0x0, %g0"
" be,a ___rw_read_enter"
" ldstub [%g1 + 3], %g2"
" b ___rw_read_enter_spin_on_wlock"
" ldub [%g1 + 3], %g2"
"___rw_read_exit_spin_on_wlock:"
" orcc %g2, 0x0, %g0"
" be,a ___rw_read_exit"
" ldstub [%g1 + 3], %g2"
" b ___rw_read_exit_spin_on_wlock"
" ldub [%g1 + 3], %g2"
"___rw_write_enter_spin_on_wlock:"
" orcc %g2, 0x0, %g0"
" be,a ___rw_write_enter"
" ldstub [%g1 + 3], %g2"
" b ___rw_write_enter_spin_on_wlock"
" ld [%g1], %g2"
""
" .globl ___rw_read_enter"
"___rw_read_enter:"
" orcc %g2, 0x0, %g0"
" bne,a ___rw_read_enter_spin_on_wlock"
" ldub [%g1 + 3], %g2"
" ld [%g1], %g2"
" add %g2, 1, %g2"
" st %g2, [%g1]"
" retl"
" mov %g4, %o7"
" .globl ___rw_read_exit"
"___rw_read_exit:"
" orcc %g2, 0x0, %g0"
" bne,a ___rw_read_exit_spin_on_wlock"
" ldub [%g1 + 3], %g2"
" ld [%g1], %g2"
" sub %g2, 0x1ff, %g2"
" st %g2, [%g1]"
" retl"
" mov %g4, %o7"
" .globl ___rw_write_enter"
"___rw_write_enter:"
" orcc %g2, 0x0, %g0"
" bne ___rw_write_enter_spin_on_wlock"
" ld [%g1], %g2"
" andncc %g2, 0xff, %g0"
" bne,a ___rw_write_enter_spin_on_wlock"
" stb %g0, [%g1 + 3]"
" retl"
" mov %g4, %o7"
);
}
#endif /* sparc */
#ifdef i386
asm(
".align 4"
".globl __write_lock_failed"
"__write_lock_failed:"
" lock; addl $" RW_LOCK_BIAS_STR ",(%eax)"
"1: cmpl $" RW_LOCK_BIAS_STR ",(%eax)"
" jne 1b"
""
" lock; subl $" RW_LOCK_BIAS_STR ",(%eax)"
" jnz __write_lock_failed"
" ret"
""
""
".align 4"
".globl __read_lock_failed"
"__read_lock_failed:"
" lock ; incl (%eax)"
"1: cmpl $1,(%eax)"
" js 1b"
""
" lock ; decl (%eax)"
" js __read_lock_failed"
" ret"
);
#endif /* i386 */
#endif /* YAPOR */
#endif /* YAPOR || TABLING */

View File

@ -3,7 +3,6 @@
** ----------------- */
typedef double realtime;
typedef volatile int lockvar;
typedef unsigned long bitmap;
#define MAX_WORKERS (sizeof(bitmap) * 8 - 1)

View File

@ -3,12 +3,10 @@
** ----------------------- */
extern struct worker{
int worker_id;
void *worker_area[MAX_WORKERS];
long worker_offset[MAX_WORKERS];
} WORKER;
#define worker_id (WORKER.worker_id)
#define worker_area(W) (WORKER.worker_area[W])
#define worker_offset(W) (WORKER.worker_offset[W])

View File

@ -47,15 +47,15 @@ static __inline__ void _read_lock(rwlock_t *rw)
{
register rwlock_t *lp asm("g1");
lp = rw;
__asm__ __volatile__("
mov %%o7, %%g4
call ___rw_read_enter
ldstub [%%g1 + 3], %%g2
" : /* no outputs */
: "r" (lp)
asm __volatile__("mov %%o7, %%g4\n\t" \
"call ___rw_read_enter\n\t" \
"ldstub [%%g1 + 3], %%g2\n" \
: /* no outputs */ \
: "r" (lp) \
: "g2", "g4", "g7", "memory", "cc");
}
#define READ_LOCK(lock) \
do { _read_lock(&(lock)); \
} while(0)
@ -64,12 +64,12 @@ static __inline__ void _read_unlock(rwlock_t *rw)
{
register rwlock_t *lp asm("g1");
lp = rw;
__asm__ __volatile__("
mov %%o7, %%g4
call ___rw_read_exit
ldstub [%%g1 + 3], %%g2
" : /* no outputs */
: "r" (lp)
asm __volatile__( \
"mov %%o7, %%g4\n\t" \
"call ___rw_read_exit\n\t" \
"ldstub [%%g1 + 3], %%g2\n" \
: /* no outputs */ \
: "r" (lp) \
: "g2", "g4", "g7", "memory", "cc");
}
@ -81,12 +81,12 @@ static __inline__ void write_lock(rwlock_t *rw)
{
register rwlock_t *lp asm("g1");
lp = rw;
__asm__ __volatile__("
mov %%o7, %%g4
call ___rw_write_enter
ldstub [%%g1 + 3], %%g2
" : /* no outputs */
: "r" (lp)
asm __volatile__( \
"mov %%o7, %%g4\n\t"\
"call ___rw_write_enter\n\t" \
"ldstub [%%g1 + 3], %%g2\n\t" \
: /* no outputs */ \
: "r" (lp) \
: "g2", "g4", "g7", "memory", "cc");
}

View File

@ -16,9 +16,7 @@
#define INIT_LOCK(LOCK_VAR) ((LOCK_VAR) = 0)
#define LOCK(LOCK_VAR) do { \
if (TRY_LOCK(&(LOCK_VAR))) break; \
SIMICS_SERVICE(START_COUNTER, 11); \
while (IS_LOCKED(LOCK_VAR)) continue; \
SIMICS_SERVICE(STOP_COUNTER, 11); \
} while (1)
#define IS_LOCKED(LOCK_VAR) ((LOCK_VAR) != 0)
#define IS_UNLOCKED(LOCK_VAR) ((LOCK_VAR) == 0)

13253
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
dnl
Mdnl
dnl Process this file with autoconf to produce a configure script.
dnl
@ -36,6 +36,9 @@ AC_ARG_ENABLE(low-level-tracer,
AC_ARG_ENABLE(tabling,
[ --enable-tabling support tabling as: batched,local ],
tabling="$enableval", tabling=no)
AC_ARG_ENABLE(threads,
[ --enable-threads support system threads ],
threads="$enableval", threads=no)
AC_ARG_ENABLE(max-performance,
[ --enable-max-performance try using the best flags for specific architecture ],
maxperformance="$enableval", maxperformance=no)
@ -148,7 +151,7 @@ AC_ARG_WITH(trail-space,
fi,
[yap_cv_trail_space=0])
if test "$tabling" = yes -o "$orparallelism" = yes
if test "$tabling" = yes -o "$orparallelism" = yes -o "$threads" = yes
then
AC_DEFINE(MinHeapSpace, (400*SIZEOF_INT_P))
AC_DEFINE(MinStackSpace,(300*SIZEOF_INT_P))
@ -631,6 +634,11 @@ if test "$lowleveltracer" = "yes"
YAP_EXTRAS="$YAP_EXTRAS -DLOW_LEVEL_TRACER=1"
fi
if test "$threads" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DTHREADS=1"
fi
case "$orparallelism" in
sba)
YAP_EXTRAS="$YAP_EXTRAS -DSBA=1"

View File

@ -10,7 +10,7 @@
* File: Yap.h.m4 *
* mods: *
* comments: main header file for YAP *
* version: $Id: Yap.h.m4,v 1.33 2002-10-17 01:37:46 vsc Exp $ *
* version: $Id: Yap.h.m4,v 1.34 2002-10-21 22:14:29 vsc Exp $ *
*************************************************************************/
#include "config.h"
@ -327,6 +327,7 @@ typedef CELL Term;
#if !defined(YAPOR) && !defined(THREADS)
#include <nolocks.h>
#else
typedef volatile int lockvar;
#ifdef i386
#include <x86_locks.h>
#endif