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)
|
static void expand_consult(void)
|
||||||
{
|
{
|
||||||
consult_obj *new_cl, *new_cb, *new_cs, *old_top;
|
consult_obj *new_cl, *new_cb, *new_cs;
|
||||||
UInt old_sz = ConsultCapacity-1, i;
|
UInt OldConsultCapacity = ConsultCapacity;
|
||||||
Int diff;
|
|
||||||
|
|
||||||
|
|
||||||
old_top = ConsultBase+ConsultCapacity;
|
/* now double consult capacity */
|
||||||
/* now increment consult capacity */
|
|
||||||
ConsultCapacity += InitialConsultCapacity;
|
ConsultCapacity += InitialConsultCapacity;
|
||||||
/* I assume it always works ;-) */
|
/* I assume it always works ;-) */
|
||||||
new_cl = (consult_obj *)AllocCodeSpace(sizeof(consult_obj)*ConsultCapacity);
|
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");
|
Error(SYSTEM_ERROR,TermNil,"Could not expand consult space: Heap crashed against Stacks");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new_cb = new_cl + (ConsultSp-ConsultBase);
|
|
||||||
new_cs = new_cl + (InitialConsultCapacity+1);
|
new_cs = new_cl + (InitialConsultCapacity+1);
|
||||||
|
new_cb = new_cs + (ConsultBase-ConsultSp);
|
||||||
/* start copying */
|
/* 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 */
|
/* copying done, release old space */
|
||||||
FreeCodeSpace((char *)ConsultLow);
|
FreeCodeSpace((char *)ConsultLow);
|
||||||
/* next, set up pointers correctly */
|
/* next, set up pointers correctly */
|
||||||
diff = (char *)new_cb-(char *)ConsultBase;
|
|
||||||
ConsultSp = new_cs;
|
ConsultSp = new_cs;
|
||||||
ConsultBase = new_cb;
|
ConsultBase = new_cb;
|
||||||
ConsultLow = new_cl;
|
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 */
|
/* p was already locked */
|
||||||
@ -1127,7 +1119,7 @@ init_consult(int mode, char *file)
|
|||||||
ConsultSp--;
|
ConsultSp--;
|
||||||
ConsultSp->mode = mode;
|
ConsultSp->mode = mode;
|
||||||
ConsultSp--;
|
ConsultSp--;
|
||||||
ConsultSp->c = ConsultBase;
|
ConsultSp->c = (ConsultBase-ConsultSp);
|
||||||
ConsultBase = ConsultSp;
|
ConsultBase = ConsultSp;
|
||||||
#if !defined(YAPOR) && !defined(SBA)
|
#if !defined(YAPOR) && !defined(SBA)
|
||||||
if (consult_level == 0)
|
if (consult_level == 0)
|
||||||
@ -1178,7 +1170,8 @@ end_consult(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
ConsultSp = ConsultBase;
|
ConsultSp = ConsultBase;
|
||||||
ConsultBase = ConsultSp->c;
|
printf("ConsultBase is %p\n",ConsultBase);
|
||||||
|
ConsultBase = ConsultSp+ConsultSp->c;
|
||||||
ConsultSp += 3;
|
ConsultSp += 3;
|
||||||
consult_level--;
|
consult_level--;
|
||||||
#if !defined(YAPOR) && !defined(SBA)
|
#if !defined(YAPOR) && !defined(SBA)
|
||||||
|
@ -572,7 +572,7 @@ init_dbtable(tr_fr_ptr trail_ptr) {
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
||||||
#define INSTRUMENT_GC 1
|
#define INSTRUMENT_GC 1
|
||||||
/* #define CHECK_CHOICEPOINTS 1 */
|
#define CHECK_CHOICEPOINTS 1
|
||||||
|
|
||||||
#ifdef INSTRUMENT_GC
|
#ifdef INSTRUMENT_GC
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
10
H/Heap.h
10
H/Heap.h
@ -10,7 +10,7 @@
|
|||||||
* File: Heap.h *
|
* File: Heap.h *
|
||||||
* mods: *
|
* mods: *
|
||||||
* comments: Heap Init Structure *
|
* 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 */
|
/* information that can be stored in Code Space */
|
||||||
@ -80,10 +80,10 @@ typedef struct various_codes {
|
|||||||
CODEADDR clause;
|
CODEADDR clause;
|
||||||
Functor func;
|
Functor func;
|
||||||
} clausecode;
|
} clausecode;
|
||||||
consult_obj *consultsp;
|
union CONSULT_OBJ *consultsp;
|
||||||
consult_obj *consultbase;
|
union CONSULT_OBJ *consultbase;
|
||||||
consult_obj *consultlow;
|
union CONSULT_OBJ *consultlow;
|
||||||
Int consultcapacity;
|
UInt consultcapacity;
|
||||||
#if HAVE_LIBREADLINE
|
#if HAVE_LIBREADLINE
|
||||||
char *readline_buf, *readline_pos;
|
char *readline_buf, *readline_pos;
|
||||||
#endif
|
#endif
|
||||||
|
@ -18,6 +18,15 @@
|
|||||||
#include "Yatom.h"
|
#include "Yatom.h"
|
||||||
#include "Heap.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 */
|
/* Either we are assembling clauses or indexing code */
|
||||||
|
|
||||||
#define ASSEMBLING_CLAUSE 0
|
#define ASSEMBLING_CLAUSE 0
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
* *
|
* *
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
|
/* consult stack management */
|
||||||
|
|
||||||
/* virtual machine instruction op-codes */
|
/* virtual machine instruction op-codes */
|
||||||
typedef enum compiler_op {
|
typedef enum compiler_op {
|
||||||
nop_op,
|
nop_op,
|
||||||
|
11
m4/Yap.h.m4
11
m4/Yap.h.m4
@ -10,7 +10,7 @@
|
|||||||
* File: Yap.h.m4 *
|
* File: Yap.h.m4 *
|
||||||
* mods: *
|
* mods: *
|
||||||
* comments: main header file for YAP *
|
* 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"
|
#include "config.h"
|
||||||
@ -733,15 +733,6 @@ extern int emacs_mode;
|
|||||||
/************ variable concerned with version number *****************/
|
/************ variable concerned with version number *****************/
|
||||||
extern char 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*************************/
|
/********* common instructions codes*************************/
|
||||||
|
|
||||||
#define MAX_PROMPT 256
|
#define MAX_PROMPT 256
|
||||||
|
@ -77,7 +77,7 @@ Inline(BlobTermAdjust, Term, Term, t, (t-HDiff) )
|
|||||||
Inline(BlobTermAdjust, Term, Term, t, (t+HDiff) )
|
Inline(BlobTermAdjust, Term, Term, t, (t+HDiff) )
|
||||||
#endif
|
#endif
|
||||||
Inline(AtomEntryAdjust, AtomEntry *, AtomEntry *, at, (AtomEntry *)(CharP(at)+HDiff) )
|
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(DBRefAdjust, DBRef, DBRef, dbr, (DBRef)(CharP(dbr)+HDiff) )
|
||||||
Inline(CodeAdjust, Term, Term, dbr, ((Term)(dbr)+HDiff) )
|
Inline(CodeAdjust, Term, Term, dbr, ((Term)(dbr)+HDiff) )
|
||||||
Inline(AddrAdjust, ADDR, ADDR, addr, (ADDR)(CharP(addr)+HDiff) )
|
Inline(AddrAdjust, ADDR, ADDR, addr, (ADDR)(CharP(addr)+HDiff) )
|
||||||
|
Reference in New Issue
Block a user