Use Doug Lea's malloc as an alternative to YAP's standard malloc
don't use TR directly in scanner/parser, this avoids trouble with ^C while consulting large files. pass gcc -mno-cygwin to library compilation in cygwin environment (cygwin should compile out of the box now). git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1168 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
f267e74737
commit
2dfdca263d
73
C/alloc.c
73
C/alloc.c
@ -12,7 +12,7 @@
|
||||
* Last rev: *
|
||||
* mods: *
|
||||
* comments: allocating space *
|
||||
* version:$Id: alloc.c,v 1.62 2004-10-27 15:56:32 vsc Exp $ *
|
||||
* version:$Id: alloc.c,v 1.63 2004-10-28 20:12:20 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
#ifdef SCCS
|
||||
static char SccsId[] = "%W% %G%";
|
||||
@ -30,6 +30,9 @@ static char SccsId[] = "%W% %G%";
|
||||
#if HAVE_MALLOC_H
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#if USE_DL_MALLOC
|
||||
#include "dlmalloc.h"
|
||||
#endif
|
||||
#if HAVE_MEMORY_H
|
||||
#include <memory.h>
|
||||
#endif
|
||||
@ -54,7 +57,13 @@ static char SccsId[] = "%W% %G%";
|
||||
/************************************************************************/
|
||||
/* Yap workspace management */
|
||||
|
||||
#if USE_SYSTEM_MALLOC
|
||||
#if USE_SYSTEM_MALLOC||USE_DL_MALLOC
|
||||
|
||||
#if USE_DL_MALLOC
|
||||
#define malloc Yap_dlmalloc
|
||||
#define free Yap_dlfree
|
||||
#define realloc Yap_dlrealloc
|
||||
#endif
|
||||
|
||||
char *
|
||||
Yap_AllocCodeSpace(unsigned int size)
|
||||
@ -112,13 +121,24 @@ Yap_ExpandPreAllocCodeSpace(UInt sz0)
|
||||
ScratchPad.sz =
|
||||
sz = sz + sz0;
|
||||
|
||||
if (!(ptr = realloc(ScratchPad.ptr, sz)))
|
||||
while (!(ptr = realloc(ScratchPad.ptr, sz))) {
|
||||
#if USE_DL_MALLOC
|
||||
if (!Yap_growheap(FALSE, sz, NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
ScratchPad.ptr = ptr;
|
||||
AuxSp = (CELL *)(AuxTop = ptr+sz);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if USE_SYSTEM_MALLOC
|
||||
|
||||
struct various_codes *heap_regs;
|
||||
|
||||
static void
|
||||
@ -236,16 +256,18 @@ Yap_AllocHole(UInt actual_request, UInt total_size)
|
||||
#define snprintf5(A,B,C,D,E) sprintf(A,C,D,E)
|
||||
#endif
|
||||
|
||||
#ifdef LIGHT
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#if !USE_DL_MALLOC
|
||||
|
||||
STATIC_PROTO(void FreeBlock, (BlockHeader *));
|
||||
STATIC_PROTO(BlockHeader *GetBlock, (unsigned int));
|
||||
STATIC_PROTO(char *AllocHeap, (unsigned int));
|
||||
STATIC_PROTO(void RemoveFromFreeList, (BlockHeader *));
|
||||
STATIC_PROTO(void AddToFreeList, (BlockHeader *));
|
||||
|
||||
#ifdef LIGHT
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#define MinHGap 256*K
|
||||
|
||||
static void
|
||||
@ -494,6 +516,15 @@ FreeCodeSpace(char *p)
|
||||
FreeBlock(((BlockHeader *) (p - sizeof(YAP_SEG_SIZE))));
|
||||
}
|
||||
|
||||
static char *
|
||||
AllocCodeSpace(unsigned int size)
|
||||
{
|
||||
if (size < SmallSize + 2 * OpCodeSize + 3 * CellSize)
|
||||
return (AllocHeap(SmallSize + 2 * OpCodeSize + 3 * CellSize));
|
||||
return (AllocHeap(size));
|
||||
}
|
||||
|
||||
|
||||
#if DEBUG_ALLOC
|
||||
int vsc_mem_trace;
|
||||
#endif
|
||||
@ -530,14 +561,6 @@ Yap_FreeAtomSpace(char *p)
|
||||
FreeCodeSpace(p);
|
||||
}
|
||||
|
||||
static char *
|
||||
AllocCodeSpace(unsigned int size)
|
||||
{
|
||||
if (size < SmallSize + 2 * OpCodeSize + 3 * CellSize)
|
||||
return (AllocHeap(SmallSize + 2 * OpCodeSize + 3 * CellSize));
|
||||
return (AllocHeap(size));
|
||||
}
|
||||
|
||||
char *
|
||||
Yap_AllocCodeSpace(unsigned int size)
|
||||
{
|
||||
@ -557,6 +580,7 @@ Yap_ExpandPreAllocCodeSpace(UInt sz)
|
||||
}
|
||||
return Addr(HeapTop) + sizeof(CELL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
@ -1229,13 +1253,15 @@ InitHeap(void *heap_addr)
|
||||
/* reserve space for specially allocated functors and atoms so that
|
||||
their values can be known statically */
|
||||
HeapTop = Yap_HeapBase + AdjustSize(sizeof(all_heap_codes));
|
||||
#if USE_DL_MALLOC
|
||||
Yap_initdlmalloc();
|
||||
#else
|
||||
HeapMax = HeapUsed = HeapTop-Yap_HeapBase;
|
||||
|
||||
|
||||
/* notice that this forces odd addresses */
|
||||
*((YAP_SEG_SIZE *) HeapTop) = InUseFlag;
|
||||
HeapTop = HeapTop + sizeof(YAP_SEG_SIZE);
|
||||
*((YAP_SEG_SIZE *) HeapTop) = InUseFlag;
|
||||
#endif
|
||||
|
||||
FreeBlocks = NIL;
|
||||
|
||||
@ -1302,7 +1328,9 @@ Yap_InitMemory(int Trail, int Heap, int Stack)
|
||||
HeapLim = Yap_GlobalBase; /* avoid confusions while
|
||||
* * restoring */
|
||||
|
||||
#if !USE_DL_MALLOC
|
||||
AuxTop = (ADDR)(AuxSp = (CELL *)Yap_GlobalBase);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#if SIZEOF_INT_P!=SIZEOF_INT
|
||||
@ -1330,6 +1358,11 @@ Yap_InitMemory(int Trail, int Heap, int Stack)
|
||||
void
|
||||
Yap_InitExStacks(int Trail, int Stack)
|
||||
{
|
||||
#if USE_DL_MALLOC
|
||||
ScratchPad.ptr = NULL;
|
||||
ScratchPad.sz = ScratchPad.msz = SCRATCH_START_SIZE;
|
||||
AuxSp = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
@ -1359,6 +1392,10 @@ Yap_ExtendWorkSpaceThroughHole(UInt s)
|
||||
/* progress 1 MB */
|
||||
WorkSpaceTop += 512*1024;
|
||||
if (ExtendWorkSpace(s, MAP_FIXED)) {
|
||||
#if USE_DL_MALLOC
|
||||
Yap_hole_start = (ADDR)WorkSpaceTop0;
|
||||
Yap_hole_end = (ADDR)WorkSpaceTop-s;
|
||||
#endif
|
||||
return WorkSpaceTop-WorkSpaceTop0;
|
||||
}
|
||||
#if defined(_WIN32)
|
||||
@ -1381,7 +1418,7 @@ Yap_ExtendWorkSpaceThroughHole(UInt s)
|
||||
void
|
||||
Yap_AllocHole(UInt actual_request, UInt total_size)
|
||||
{
|
||||
#if USE_MMAP || defined(_WIN32)
|
||||
#if (USE_MMAP || defined(_WIN32)) && !USE_DL_MALLOC
|
||||
/* where we were when the hole was created,
|
||||
also where is the hole store */
|
||||
ADDR WorkSpaceTop0 = WorkSpaceTop-total_size;
|
||||
|
@ -10,8 +10,13 @@
|
||||
* File: c_interface.c *
|
||||
* comments: c_interface primitives definition *
|
||||
* *
|
||||
* Last rev: $Date: 2004-10-06 16:55:46 $,$Author: vsc $ *
|
||||
* Last rev: $Date: 2004-10-28 20:12:20 $,$Author: vsc $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.54 2004/10/06 16:55:46 vsc
|
||||
* change configure to support big mem configs
|
||||
* get rid of extra globals
|
||||
* fix trouble with multifile preds
|
||||
*
|
||||
* Revision 1.53 2004/08/11 16:14:51 vsc
|
||||
* whole lot of fixes:
|
||||
* - memory leak in indexing
|
||||
@ -912,14 +917,12 @@ X_API Term
|
||||
YAP_Read(int (*mygetc)(void))
|
||||
{
|
||||
Term t;
|
||||
tr_fr_ptr old_TR;
|
||||
int sno;
|
||||
TokEntry *tokstart;
|
||||
|
||||
BACKUP_MACHINE_REGS();
|
||||
|
||||
do_getf = mygetc;
|
||||
old_TR = TR;
|
||||
sno = Yap_GetFreeStreamD();
|
||||
if (sno < 0) {
|
||||
Yap_Error(SYSTEM_ERROR,TermNil, "new stream not available for YAP_Read");
|
||||
@ -930,13 +933,11 @@ YAP_Read(int (*mygetc)(void))
|
||||
Stream[sno].status = Free_Stream_f;
|
||||
if (Yap_ErrorMessage)
|
||||
{
|
||||
TR = old_TR;
|
||||
save_machine_regs();
|
||||
return(0);
|
||||
}
|
||||
t = Yap_Parse();
|
||||
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
|
||||
TR = old_TR;
|
||||
|
||||
RECOVER_MACHINE_REGS();
|
||||
return t;
|
||||
|
@ -11,8 +11,11 @@
|
||||
* File: cdmgr.c *
|
||||
* comments: Code manager *
|
||||
* *
|
||||
* Last rev: $Date: 2004-10-26 20:15:51 $,$Author: vsc $ *
|
||||
* Last rev: $Date: 2004-10-28 20:12:21 $,$Author: vsc $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.138 2004/10/26 20:15:51 vsc
|
||||
* More bug fixes for overflow handling
|
||||
*
|
||||
* Revision 1.137 2004/10/22 16:53:19 vsc
|
||||
* bug fixes
|
||||
*
|
||||
@ -2716,7 +2719,7 @@ search_for_static_predicate_in_use(PredEntry *p, int check_everything)
|
||||
if (b_ptr)
|
||||
pe = PredForChoicePt(b_ptr->cp_ap);
|
||||
else
|
||||
return NULL;
|
||||
return FALSE;
|
||||
if (pe == p) {
|
||||
if (check_everything)
|
||||
return TRUE;
|
||||
@ -2789,7 +2792,7 @@ do_toggle_static_predicates_in_use(int mask)
|
||||
}
|
||||
/* now mark the choicepoint */
|
||||
if ((b_ptr)) {
|
||||
if (pe = PredForChoicePt(b_ptr->cp_ap)) {
|
||||
if ((pe = PredForChoicePt(b_ptr->cp_ap))) {
|
||||
mark_pred(mask, pe);
|
||||
}
|
||||
}
|
||||
|
3176
C/dlmalloc.c
Executable file
3176
C/dlmalloc.c
Executable file
File diff suppressed because it is too large
Load Diff
4
C/grow.c
4
C/grow.c
@ -120,7 +120,7 @@ SetHeapRegs(void)
|
||||
Yap_TrailTop = TrailAddrAdjust(Yap_TrailTop);
|
||||
Yap_GlobalBase = DelayAddrAdjust(Yap_GlobalBase);
|
||||
Yap_LocalBase = LocalAddrAdjust(Yap_LocalBase);
|
||||
#if !USE_SYSTEM_MALLOC
|
||||
#if !USE_SYSTEM_MALLOC && !USE_DL_MALLOC
|
||||
AuxSp = PtoDelayAdjust(AuxSp);
|
||||
AuxTop = (ADDR)PtoDelayAdjust((CELL *)AuxTop);
|
||||
#endif
|
||||
@ -1272,7 +1272,7 @@ Yap_growtrail(long size)
|
||||
CELL **
|
||||
Yap_shift_visit(CELL **to_visit, CELL ***to_visit_maxp)
|
||||
{
|
||||
#if USE_SYSTEM_MALLOC
|
||||
#if USE_SYSTEM_MALLOC || USE_DL_MALLOC
|
||||
CELL **to_visit_max = *to_visit_maxp;
|
||||
Int sz1 = (CELL)to_visit_max-(CELL)to_visit;
|
||||
Int sz0 = AuxTop - (ADDR)to_visit_maxp, sz, dsz;
|
||||
|
@ -94,7 +94,7 @@ static cont *cont_top0;
|
||||
#endif
|
||||
static cont *cont_top;
|
||||
|
||||
static int
|
||||
static void
|
||||
gc_growtrail(int committed)
|
||||
{
|
||||
#if USE_SYSTEM_MALLOC
|
||||
@ -112,6 +112,7 @@ gc_growtrail(int committed)
|
||||
#endif
|
||||
longjmp(Yap_gc_restore, 1);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
inline static void
|
||||
|
23
C/iopreds.c
23
C/iopreds.c
@ -2957,13 +2957,11 @@ do_read(int inp_stream)
|
||||
#if EMACS
|
||||
int emacs_cares = FALSE;
|
||||
#endif
|
||||
tr_fr_ptr old_TR, TR_before_parse;
|
||||
|
||||
if (Stream[inp_stream].status & Binary_Stream_f) {
|
||||
Yap_Error(PERMISSION_ERROR_INPUT_BINARY_STREAM, MkAtomTerm(Stream[inp_stream].u.file.name), "read_term/2");
|
||||
return(FALSE);
|
||||
}
|
||||
old_TR = TR;
|
||||
while (TRUE) {
|
||||
CELL *old_H;
|
||||
|
||||
@ -2981,7 +2979,6 @@ do_read(int inp_stream)
|
||||
if (tokstart != NIL && tokstart->Tok != Ord (eot_tok)) {
|
||||
/* we got the end of file from an abort */
|
||||
if (Yap_ErrorMessage == "Abort") {
|
||||
TR = old_TR;
|
||||
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
|
||||
return FALSE;
|
||||
}
|
||||
@ -2989,8 +2986,6 @@ do_read(int inp_stream)
|
||||
Stream[inp_stream].status |= Push_Eof_Stream_f;
|
||||
Yap_ErrorMessage = "end of file found before end of term";
|
||||
} else {
|
||||
/* restore TR */
|
||||
TR = old_TR;
|
||||
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
|
||||
|
||||
return (Yap_unify(MkIntegerTerm(StartLine = Stream[inp_stream].linecount),ARG4) &&
|
||||
@ -2999,27 +2994,29 @@ do_read(int inp_stream)
|
||||
}
|
||||
}
|
||||
repeat_cycle:
|
||||
TR_before_parse = TR;
|
||||
if (Yap_ErrorMessage || (t = Yap_Parse ()) == 0) {
|
||||
if (Yap_ErrorMessage || (t = Yap_Parse()) == 0) {
|
||||
if (Yap_ErrorMessage && (strcmp(Yap_ErrorMessage,"Stack Overflow") == 0)) {
|
||||
/* ignore term we just built */
|
||||
TR = TR_before_parse;
|
||||
H = old_H;
|
||||
tr_fr_ptr old_TR = TR;
|
||||
TR = (tr_fr_ptr)ScannerStack;
|
||||
if (Yap_growstack_in_parser(&old_TR, &tokstart, &Yap_VarTable)) {
|
||||
ScannerStack = (char *)TR;
|
||||
TR = old_TR;
|
||||
old_H = H;
|
||||
Yap_tokptr = Yap_toktide = tokstart;
|
||||
Yap_ErrorMessage = NULL;
|
||||
goto repeat_cycle;
|
||||
}
|
||||
ScannerStack = (char *)TR;
|
||||
TR = old_TR;
|
||||
}
|
||||
TR = old_TR;
|
||||
if (ParserErrorStyle == QUIET_ON_PARSER_ERROR) {
|
||||
/* just fail */
|
||||
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
|
||||
return FALSE;
|
||||
} else if (ParserErrorStyle == CONTINUE_ON_PARSER_ERROR) {
|
||||
Yap_ErrorMessage = NULL;
|
||||
TR = TR_before_parse;
|
||||
/* try again */
|
||||
goto repeat_cycle;
|
||||
} else {
|
||||
@ -3055,14 +3052,17 @@ do_read(int inp_stream)
|
||||
|
||||
if (setjmp(Yap_IOBotch) == 0) {
|
||||
v = Yap_VarNames(Yap_VarTable, TermNil);
|
||||
TR = old_TR;
|
||||
break;
|
||||
} else {
|
||||
tr_fr_ptr old_TR = TR;
|
||||
/* don't need to recheck tokens */
|
||||
tokstart = NULL;
|
||||
/* restart global */
|
||||
H = old_H;
|
||||
TR = (tr_fr_ptr)ScannerStack;
|
||||
Yap_growstack_in_parser(&old_TR, &tokstart, &Yap_VarTable);
|
||||
ScannerStack = (char *)TR;
|
||||
TR = old_TR;
|
||||
old_H = H;
|
||||
}
|
||||
}
|
||||
@ -3070,7 +3070,6 @@ do_read(int inp_stream)
|
||||
return(Yap_unify(t, ARG2) && Yap_unify (v, ARG3) &&
|
||||
Yap_unify(MkIntTerm(StartLine = tokstart->TokPos),ARG4));
|
||||
} else {
|
||||
TR = old_TR;
|
||||
Yap_clean_tokenizer(tokstart, Yap_VarTable, Yap_AnonVarTable);
|
||||
return(Yap_unify(t, ARG2) && Yap_unify(MkIntTerm(StartLine = tokstart->TokPos),ARG4));
|
||||
}
|
||||
|
@ -306,8 +306,12 @@ ParseArgs(Atom a, JMPBUFF *FailBuff)
|
||||
p = (Term *) ParserAuxSp;
|
||||
while (1) {
|
||||
Term *tp = (Term *)ParserAuxSp;
|
||||
if (ParserAuxSp+1 > Yap_TrailTop) {
|
||||
Yap_ErrorMessage = "Trail Overflow";
|
||||
FAIL;
|
||||
}
|
||||
*tp++ = Unsigned(ParseTerm(999, FailBuff));
|
||||
ParserAuxSp = (tr_fr_ptr)tp;
|
||||
ParserAuxSp = tp;
|
||||
++nargs;
|
||||
if (Yap_tokptr->Tok != Ord(Ponctuation_tok))
|
||||
break;
|
||||
@ -315,7 +319,7 @@ ParseArgs(Atom a, JMPBUFF *FailBuff)
|
||||
break;
|
||||
NextToken;
|
||||
}
|
||||
ParserAuxSp = (tr_fr_ptr)p;
|
||||
ParserAuxSp = (char *)p;
|
||||
/*
|
||||
* Needed because the arguments for the functor are placed in reverse
|
||||
* order
|
||||
|
8
C/save.c
8
C/save.c
@ -402,6 +402,8 @@ save_regs(int mode)
|
||||
putout(Unsigned(HeapUsed));
|
||||
/* Then the start of the free code */
|
||||
putcellptr(CellPtr(FreeBlocks));
|
||||
putcellptr(AuxSp);
|
||||
putcellptr(CellPtr(AuxTop));
|
||||
if (mode == DO_EVERYTHING) {
|
||||
/* put the old trail base, just in case it moves again */
|
||||
putout(ARG1);
|
||||
@ -680,6 +682,8 @@ get_heap_info(void)
|
||||
OldHeapTop = (ADDR) get_cellptr();
|
||||
OldHeapUsed = (Int) get_cell();
|
||||
FreeBlocks = (BlockHeader *) get_cellptr();
|
||||
AuxSp = get_cellptr();
|
||||
AuxTop = (ADDR)get_cellptr();
|
||||
HDiff = Unsigned(Yap_HeapBase) - Unsigned(OldHeapBase);
|
||||
}
|
||||
|
||||
@ -1065,6 +1069,10 @@ RestoreFreeSpace(void)
|
||||
if (FreeBlocks != NULL)
|
||||
FreeBlocks = BlockAdjust(FreeBlocks);
|
||||
bpt = FreeBlocks;
|
||||
if (AuxSp != NULL)
|
||||
AuxSp = CellPtoHeapAdjust(AuxSp);
|
||||
if (AuxTop != NULL)
|
||||
AuxTop = AddrAdjust(AuxTop);
|
||||
while (bpt != NULL) {
|
||||
if (bpt->b_next != NULL) {
|
||||
bsz = bpt->b_next = BlockAdjust(bpt->b_next);
|
||||
|
15
C/scanner.c
15
C/scanner.c
@ -130,23 +130,22 @@ AllocScannerMemory(unsigned int size)
|
||||
#else
|
||||
char *AuxSpScan;
|
||||
|
||||
AuxSpScan = (char *)TR;
|
||||
AuxSpScan = ScannerStack;
|
||||
size = AdjustSize(size);
|
||||
TR = (tr_fr_ptr)(AuxSpScan+size);
|
||||
#if !OS_HANDLES_TR_OVERFLOW
|
||||
if (Unsigned(Yap_TrailTop) == Unsigned(TR)) {
|
||||
ScannerStack = AuxSpScan+size;
|
||||
if (Yap_TrailTop <= ScannerStack) {
|
||||
if(!Yap_growtrail (sizeof(CELL) * 16 * 1024L)) {
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return (AuxSpScan);
|
||||
return AuxSpScan;
|
||||
#endif
|
||||
}
|
||||
|
||||
char *
|
||||
Yap_AllocScannerMemory(unsigned int size)
|
||||
{
|
||||
/* I assume memory has been initialised */
|
||||
return AllocScannerMemory(size);
|
||||
}
|
||||
|
||||
@ -380,7 +379,7 @@ read_quoted_char(int *scan_nextp, int inp_stream, int (*QuotedNxtch)(int))
|
||||
static Term
|
||||
get_num(int *chp, int *chbuffp, int inp_stream, int (*Nxtch) (int), int (*QuotedNxtch) (int))
|
||||
{
|
||||
char *s = (char *)TR, *sp = s;
|
||||
char *s = (char *)ScannerStack, *sp = s;
|
||||
int ch = *chp;
|
||||
Int val = 0, base = ch - '0';
|
||||
int might_be_float = TRUE, has_overflow = FALSE;
|
||||
@ -549,6 +548,7 @@ Yap_scan_num(int (*Nxtch) (int))
|
||||
int ch, cherr;
|
||||
|
||||
Yap_ErrorMessage = NULL;
|
||||
ScannerStack = (char *)TR;
|
||||
ch = Nxtch(-1);
|
||||
if (ch == '-') {
|
||||
sign = -1;
|
||||
@ -586,6 +586,7 @@ Yap_tokenizer(int inp_stream)
|
||||
Yap_VarTable = NULL;
|
||||
Yap_AnonVarTable = NULL;
|
||||
Yap_eot_before_eof = FALSE;
|
||||
ScannerStack = (char *)TR;
|
||||
l = NIL;
|
||||
p = NIL; /* Just to make lint happy */
|
||||
ch = Nxtch(inp_stream);
|
||||
|
12
H/Heap.h
12
H/Heap.h
@ -10,7 +10,7 @@
|
||||
* File: Heap.h *
|
||||
* mods: *
|
||||
* comments: Heap Init Structure *
|
||||
* version: $Id: Heap.h,v 1.69 2004-10-27 15:56:34 vsc Exp $ *
|
||||
* version: $Id: Heap.h,v 1.70 2004-10-28 20:12:22 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
/* information that can be stored in Code Space */
|
||||
@ -95,11 +95,14 @@ typedef int (*Agc_hook)(Atom);
|
||||
|
||||
typedef struct various_codes {
|
||||
special_functors funcs;
|
||||
struct malloc_state *av_;
|
||||
ADDR hole_start, hole_end;
|
||||
Int heap_used;
|
||||
Int heap_max;
|
||||
ADDR heap_top;
|
||||
ADDR heap_lim;
|
||||
struct FREEB *free_blocks;
|
||||
char *scanner_stack;
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
lockvar bgl; /* protect long critical regions */
|
||||
lockvar free_blocks_lock; /* protect the list of free blocks */
|
||||
@ -425,10 +428,14 @@ struct various_codes *heap_regs;
|
||||
#define heap_regs ((all_heap_codes *)HEAP_INIT_BASE)
|
||||
#endif
|
||||
|
||||
#define Yap_av heap_regs->av_
|
||||
#define Yap_hole_start heap_regs->hole_start
|
||||
#define Yap_hole_end heap_regs->hole_end
|
||||
#define HeapUsed heap_regs->heap_used
|
||||
#define HeapMax heap_regs->heap_max
|
||||
#define HeapTop heap_regs->heap_top
|
||||
#define HeapLim heap_regs->heap_lim
|
||||
#define ScannerStack heap_regs->scanner_stack
|
||||
#ifdef YAPOR
|
||||
#define SEQUENTIAL_IS_DEFAULT heap_regs->seq_def
|
||||
#define GETWORK (&(heap_regs->getworkcode ))
|
||||
@ -753,10 +760,11 @@ struct various_codes *heap_regs;
|
||||
#define ReadlinePos heap_regs->readline_pos
|
||||
#endif
|
||||
|
||||
#define USE_DL_MALLOC 1
|
||||
|
||||
ADDR STD_PROTO(Yap_ExpandPreAllocCodeSpace, (UInt));
|
||||
#define Yap_ReleasePreAllocCodeSpace(x)
|
||||
#if USE_SYSTEM_MALLOC
|
||||
#if USE_SYSTEM_MALLOC||USE_DL_MALLOC
|
||||
ADDR STD_PROTO(Yap_InitPreAllocCodeSpace, (void));
|
||||
EXTERN inline ADDR
|
||||
Yap_PreAllocCodeSpace(void)
|
||||
|
@ -77,8 +77,8 @@ static char SccsId[] = "%W% %G%";
|
||||
* Use bp as PREG for X86 machines *
|
||||
***************************************************************/
|
||||
#if IN_ABSMI_C
|
||||
register void* P1REG asm ("bp"); /* can't use yamop before Yap.h */
|
||||
#define PREG ((yamop *)P1REG)
|
||||
register struct yami* P1REG asm ("bp"); /* can't use yamop before Yap.h */
|
||||
#define PREG P1REG
|
||||
#endif
|
||||
#define NEEDS_TO_SET_PC 1
|
||||
#endif /* BP_FREE */
|
||||
|
@ -369,7 +369,9 @@ Unification Routines
|
||||
|
||||
EXTERN Int STD_PROTO(Yap_unify,(Term,Term));
|
||||
|
||||
EXTERN inline void
|
||||
inline EXTERN void STD_PROTO(reset_trail,(tr_fr_ptr));
|
||||
|
||||
inline EXTERN void
|
||||
reset_trail(tr_fr_ptr TR0) {
|
||||
while(TR != TR0) {
|
||||
CELL d1;
|
||||
|
1169
H/dlmalloc.h
Executable file
1169
H/dlmalloc.h
Executable file
File diff suppressed because it is too large
Load Diff
@ -247,7 +247,7 @@ typedef struct AliasDescS {
|
||||
extern char *Yap_chtype;
|
||||
|
||||
/* parser stack, used to be AuxSp, now is ASP */
|
||||
#define ParserAuxSp (TR)
|
||||
#define ParserAuxSp ScannerStack
|
||||
|
||||
/* routines in parser.c */
|
||||
VarEntry STD_PROTO(*Yap_LookupVar,(char *));
|
||||
|
11
Makefile.in
11
Makefile.in
@ -108,7 +108,8 @@ HEADERS = \
|
||||
$(srcdir)/H/amidefs.h $(srcdir)/H/amiops.h $(srcdir)/H/arrays.h \
|
||||
$(srcdir)/H/arith2.h $(srcdir)/H/attvar.h \
|
||||
$(srcdir)/H/clause.h $(srcdir)/H/compile.h \
|
||||
$(srcdir)/H/corout.h $(srcdir)/H/eval.h $(srcdir)/H/heapgc.h \
|
||||
$(srcdir)/H/corout.h $(srcdir)/H/dlmalloc.h \
|
||||
$(srcdir)/H/eval.h $(srcdir)/H/heapgc.h \
|
||||
$(srcdir)/H/index.h $(srcdir)/H/iopreds.h \
|
||||
$(srcdir)/H/rheap.h \
|
||||
$(srcdir)/H/tracer.h \
|
||||
@ -134,7 +135,8 @@ C_SOURCES= \
|
||||
$(srcdir)/C/bignum.c \
|
||||
$(srcdir)/C/c_interface.c $(srcdir)/C/cdmgr.c $(srcdir)/C/cmppreds.c \
|
||||
$(srcdir)/C/compiler.c $(srcdir)/C/computils.c \
|
||||
$(srcdir)/C/corout.c $(srcdir)/C/dbase.c $(srcdir)/C/errors.c \
|
||||
$(srcdir)/C/corout.c $(srcdir)/C/dbase.c $(srcdir)/C/dlmalloc.c \
|
||||
$(srcdir)/C/errors.c \
|
||||
$(srcdir)/C/eval.c $(srcdir)/C/exec.c $(srcdir)/C/grow.c \
|
||||
$(srcdir)/C/heapgc.c $(srcdir)/C/index.c \
|
||||
$(srcdir)/C/init.c $(srcdir)/C/inlines.c \
|
||||
@ -184,7 +186,7 @@ ENGINE_OBJECTS = \
|
||||
agc.o absmi.o adtdefs.o alloc.o amasm.o analyst.o arrays.o \
|
||||
arith0.o arith1.o arith2.o attvar.o bb.o \
|
||||
cdmgr.o cmppreds.o compiler.o computils.o \
|
||||
corout.o dbase.o errors.o eval.o bignum.o \
|
||||
corout.o dbase.o dlmalloc.o errors.o eval.o bignum.o \
|
||||
exec.o grow.o heapgc.o index.o init.o inlines.o \
|
||||
iopreds.o depth_bound.o mavar.o modules.o other.o \
|
||||
parser.o save.o scanner.o sort.o stdpreds.o sysbits.o threads.o \
|
||||
@ -316,6 +318,9 @@ corout.o: $(srcdir)/C/corout.c
|
||||
dbase.o: $(srcdir)/C/dbase.c
|
||||
$(CC) -c $(CFLAGS) $(srcdir)/C/dbase.c -o $@
|
||||
|
||||
dlmalloc.o: $(srcdir)/C/dlmalloc.c
|
||||
$(CC) -c $(CFLAGS) $(srcdir)/C/dlmalloc.c -o $@
|
||||
|
||||
errors.o: $(srcdir)/C/errors.c
|
||||
$(CC) -c $(CFLAGS) $(srcdir)/C/errors.c -o $@
|
||||
|
||||
|
@ -238,6 +238,7 @@
|
||||
|
||||
#define MSHIFTOFFS 1
|
||||
|
||||
#undef USE_DL_MALLOC
|
||||
#undef USE_MALLOC
|
||||
#define USE_MMAP (HAVE_MMAP & !USE_MALLOC)
|
||||
#define USE_SHM (HAVE_SHMAT & !HAVE_MMAP & !USE_MALLOC)
|
||||
|
48
configure
vendored
48
configure
vendored
@ -3081,7 +3081,7 @@ fi
|
||||
# and -fomit-frame-point -DBP_FREE
|
||||
YAPLIB="libWYap.a"
|
||||
SHLIB_CFLAGS=""
|
||||
SHLIB_LD="gcc -shared ../../yap.dll"
|
||||
SHLIB_LD="\$(CC) -shared ../../yap.dll"
|
||||
SHLIB_SUFFIX=".dll"
|
||||
C_PARSER_FLAGS="$C_INTERF_FLAGS"
|
||||
EXEC_SUFFIX=".exe"
|
||||
@ -4142,12 +4142,12 @@ else
|
||||
#line 4143 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
main()
|
||||
{
|
||||
FILE *f=fopen("conftestval", "w");
|
||||
if (!f) return(1);
|
||||
if (!f) exit(1);
|
||||
fprintf(f, "%d\n", sizeof(int *));
|
||||
return(0);
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
if { (eval echo configure:4154: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
@ -4181,12 +4181,12 @@ else
|
||||
#line 4182 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
main()
|
||||
{
|
||||
FILE *f=fopen("conftestval", "w");
|
||||
if (!f) return(1);
|
||||
if (!f) exit(1);
|
||||
fprintf(f, "%d\n", sizeof(short int));
|
||||
return(0);
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
if { (eval echo configure:4193: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
@ -4220,12 +4220,12 @@ else
|
||||
#line 4221 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
main()
|
||||
{
|
||||
FILE *f=fopen("conftestval", "w");
|
||||
if (!f) return(1);
|
||||
if (!f) exit(1);
|
||||
fprintf(f, "%d\n", sizeof(int));
|
||||
return(0);
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
if { (eval echo configure:4232: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
@ -4259,12 +4259,12 @@ else
|
||||
#line 4260 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
main()
|
||||
{
|
||||
FILE *f=fopen("conftestval", "w");
|
||||
if (!f) return(1);
|
||||
if (!f) exit(1);
|
||||
fprintf(f, "%d\n", sizeof(long int));
|
||||
return(0);
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
if { (eval echo configure:4271: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
@ -4298,12 +4298,12 @@ else
|
||||
#line 4299 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
main()
|
||||
{
|
||||
FILE *f=fopen("conftestval", "w");
|
||||
if (!f) return(1);
|
||||
if (!f) exit(1);
|
||||
fprintf(f, "%d\n", sizeof(long long int));
|
||||
return(0);
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
if { (eval echo configure:4310: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
@ -4337,12 +4337,12 @@ else
|
||||
#line 4338 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
main()
|
||||
{
|
||||
FILE *f=fopen("conftestval", "w");
|
||||
if (!f) return(1);
|
||||
if (!f) exit(1);
|
||||
fprintf(f, "%d\n", sizeof(float));
|
||||
return(0);
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
if { (eval echo configure:4349: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
@ -4376,12 +4376,12 @@ else
|
||||
#line 4377 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
main()
|
||||
{
|
||||
FILE *f=fopen("conftestval", "w");
|
||||
if (!f) return(1);
|
||||
if (!f) exit(1);
|
||||
fprintf(f, "%d\n", sizeof(double));
|
||||
return(0);
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
if { (eval echo configure:4388: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
@ -5887,6 +5887,10 @@ cat >> confdefs.h <<\EOF
|
||||
#define GC_NO_TAGS 1
|
||||
EOF
|
||||
|
||||
cat >> confdefs.h <<\EOF
|
||||
#define USE_DL_MALLOC 1
|
||||
EOF
|
||||
|
||||
fi
|
||||
|
||||
mkdir -p library/mpi
|
||||
|
@ -632,7 +632,7 @@ dnl Linux has both elf and a.out, in this case we found elf
|
||||
# and -fomit-frame-point -DBP_FREE
|
||||
YAPLIB="libWYap.a"
|
||||
SHLIB_CFLAGS=""
|
||||
SHLIB_LD="gcc -shared ../../yap.dll"
|
||||
SHLIB_LD="\$(CC) -shared ../../yap.dll"
|
||||
SHLIB_SUFFIX=".dll"
|
||||
C_PARSER_FLAGS="$C_INTERF_FLAGS"
|
||||
EXEC_SUFFIX=".exe"
|
||||
@ -1068,10 +1068,11 @@ AC_DEFINE(USE_MALLOC,1)
|
||||
AC_DEFINE(GC_NO_TAGS,1)
|
||||
fi
|
||||
|
||||
dnl disable smart memory management
|
||||
dnl large memory configuration, don't trust Yap allocation routines
|
||||
if test "$maxmemory" = yes
|
||||
then
|
||||
AC_DEFINE(GC_NO_TAGS,1)
|
||||
AC_DEFINE(USE_DL_MALLOC,1)
|
||||
fi
|
||||
|
||||
mkdir -p library/mpi
|
||||
|
Reference in New Issue
Block a user