fix the consult overflow right!
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@245 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
4ae64918e0
commit
1217ecee1f
23
C/cdmgr.c
23
C/cdmgr.c
@ -709,13 +709,10 @@ assertz_dynam_clause(PredEntry *p, CODEADDR cp)
|
||||
|
||||
static void expand_consult(void)
|
||||
{
|
||||
consult_obj *new_cl, *new_cb, *new_cs, *old_top;
|
||||
UInt old_sz = ConsultCapacity-1, i;
|
||||
Int diff;
|
||||
|
||||
consult_obj *new_cl, *new_cb, *new_cs;
|
||||
UInt OldConsultCapacity = ConsultCapacity;
|
||||
|
||||
old_top = ConsultBase+ConsultCapacity;
|
||||
/* now increment consult capacity */
|
||||
/* now double consult capacity */
|
||||
ConsultCapacity += InitialConsultCapacity;
|
||||
/* I assume it always works ;-) */
|
||||
new_cl = (consult_obj *)AllocCodeSpace(sizeof(consult_obj)*ConsultCapacity);
|
||||
@ -723,21 +720,16 @@ static void expand_consult(void)
|
||||
Error(SYSTEM_ERROR,TermNil,"Could not expand consult space: Heap crashed against Stacks");
|
||||
return;
|
||||
}
|
||||
new_cb = new_cl + (ConsultSp-ConsultBase);
|
||||
new_cs = new_cl + (InitialConsultCapacity+1);
|
||||
new_cb = new_cs + (ConsultBase-ConsultSp);
|
||||
/* start copying */
|
||||
memcpy((void *)(new_cs), (void *)(ConsultSp), (ConsultCapacity-(InitialConsultCapacity+1))*sizeof(consult_obj));
|
||||
memcpy((void *)(new_cs), (void *)(ConsultSp), OldConsultCapacity*sizeof(consult_obj));
|
||||
/* copying done, release old space */
|
||||
FreeCodeSpace((char *)ConsultLow);
|
||||
/* next, set up pointers correctly */
|
||||
diff = (char *)new_cb-(char *)ConsultBase;
|
||||
ConsultSp = new_cs;
|
||||
ConsultBase = new_cb;
|
||||
ConsultLow = new_cl;
|
||||
/* adjust consultbase pointers */
|
||||
for (i = 0; i < old_sz; i++) {
|
||||
new_cs->c = (consult_obj *)((void *)(new_cs->c)+diff);
|
||||
}
|
||||
}
|
||||
|
||||
/* p was already locked */
|
||||
@ -1127,7 +1119,7 @@ init_consult(int mode, char *file)
|
||||
ConsultSp--;
|
||||
ConsultSp->mode = mode;
|
||||
ConsultSp--;
|
||||
ConsultSp->c = ConsultBase;
|
||||
ConsultSp->c = (ConsultBase-ConsultSp);
|
||||
ConsultBase = ConsultSp;
|
||||
#if !defined(YAPOR) && !defined(SBA)
|
||||
if (consult_level == 0)
|
||||
@ -1178,7 +1170,8 @@ end_consult(void)
|
||||
}
|
||||
#endif
|
||||
ConsultSp = ConsultBase;
|
||||
ConsultBase = ConsultSp->c;
|
||||
printf("ConsultBase is %p\n",ConsultBase);
|
||||
ConsultBase = ConsultSp+ConsultSp->c;
|
||||
ConsultSp += 3;
|
||||
consult_level--;
|
||||
#if !defined(YAPOR) && !defined(SBA)
|
||||
|
@ -572,7 +572,7 @@ init_dbtable(tr_fr_ptr trail_ptr) {
|
||||
#ifdef DEBUG
|
||||
|
||||
#define INSTRUMENT_GC 1
|
||||
/* #define CHECK_CHOICEPOINTS 1 */
|
||||
#define CHECK_CHOICEPOINTS 1
|
||||
|
||||
#ifdef INSTRUMENT_GC
|
||||
typedef enum {
|
||||
|
10
H/Heap.h
10
H/Heap.h
@ -10,7 +10,7 @@
|
||||
* File: Heap.h *
|
||||
* mods: *
|
||||
* comments: Heap Init Structure *
|
||||
* version: $Id: Heap.h,v 1.15 2001-12-17 18:31:10 vsc Exp $ *
|
||||
* version: $Id: Heap.h,v 1.16 2002-01-01 05:26:25 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
/* information that can be stored in Code Space */
|
||||
@ -80,10 +80,10 @@ typedef struct various_codes {
|
||||
CODEADDR clause;
|
||||
Functor func;
|
||||
} clausecode;
|
||||
consult_obj *consultsp;
|
||||
consult_obj *consultbase;
|
||||
consult_obj *consultlow;
|
||||
Int consultcapacity;
|
||||
union CONSULT_OBJ *consultsp;
|
||||
union CONSULT_OBJ *consultbase;
|
||||
union CONSULT_OBJ *consultlow;
|
||||
UInt consultcapacity;
|
||||
#if HAVE_LIBREADLINE
|
||||
char *readline_buf, *readline_pos;
|
||||
#endif
|
||||
|
@ -18,6 +18,15 @@
|
||||
#include "Yatom.h"
|
||||
#include "Heap.h"
|
||||
|
||||
/* consulting files */
|
||||
|
||||
typedef union CONSULT_OBJ {
|
||||
char *filename;
|
||||
int mode;
|
||||
Prop p;
|
||||
UInt c;
|
||||
} consult_obj;
|
||||
|
||||
/* Either we are assembling clauses or indexing code */
|
||||
|
||||
#define ASSEMBLING_CLAUSE 0
|
||||
|
@ -15,6 +15,8 @@
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/* consult stack management */
|
||||
|
||||
/* virtual machine instruction op-codes */
|
||||
typedef enum compiler_op {
|
||||
nop_op,
|
||||
|
11
m4/Yap.h.m4
11
m4/Yap.h.m4
@ -10,7 +10,7 @@
|
||||
* File: Yap.h.m4 *
|
||||
* mods: *
|
||||
* comments: main header file for YAP *
|
||||
* version: $Id: Yap.h.m4,v 1.15 2001-12-20 17:19:43 vsc Exp $ *
|
||||
* version: $Id: Yap.h.m4,v 1.16 2002-01-01 05:26:25 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
@ -733,15 +733,6 @@ extern int emacs_mode;
|
||||
/************ variable concerned with version number *****************/
|
||||
extern char version_number[];
|
||||
|
||||
/* consult stack management */
|
||||
|
||||
typedef union CONSULT_OBJ {
|
||||
char *filename;
|
||||
int mode;
|
||||
Prop p;
|
||||
union CONSULT_OBJ *c;
|
||||
} consult_obj;
|
||||
|
||||
/********* common instructions codes*************************/
|
||||
|
||||
#define MAX_PROMPT 256
|
||||
|
@ -77,7 +77,7 @@ Inline(BlobTermAdjust, Term, Term, t, (t-HDiff) )
|
||||
Inline(BlobTermAdjust, Term, Term, t, (t+HDiff) )
|
||||
#endif
|
||||
Inline(AtomEntryAdjust, AtomEntry *, AtomEntry *, at, (AtomEntry *)(CharP(at)+HDiff) )
|
||||
Inline(ConsultObjAdjust, consult_obj *, consult_obj *, co, (consult_obj *)(CharP(co)+HDiff) )
|
||||
Inline(ConsultObjAdjust, union CONSULT_OBJ *, union CONSULT_OBJ *, co, (union CONSULT_OBJ *)(CharP(co)+HDiff) )
|
||||
Inline(DBRefAdjust, DBRef, DBRef, dbr, (DBRef)(CharP(dbr)+HDiff) )
|
||||
Inline(CodeAdjust, Term, Term, dbr, ((Term)(dbr)+HDiff) )
|
||||
Inline(AddrAdjust, ADDR, ADDR, addr, (ADDR)(CharP(addr)+HDiff) )
|
||||
|
Reference in New Issue
Block a user