ovfl
This commit is contained in:
parent
402e6cab55
commit
0036e3632e
57
C/globals.c
57
C/globals.c
@ -266,9 +266,10 @@ static void adjust_cps(UInt size USES_REGS) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Term GrowArena(Term arena, CELL *pt, size_t old_size, size_t size,
|
static Term GrowArena(Term arena, size_t size,
|
||||||
UInt arity, cell_space_t *cspace USES_REGS) {
|
UInt arity, cell_space_t *cspace USES_REGS) {
|
||||||
size_t sz;
|
CELL *pt = ArenaLimit(arena);
|
||||||
|
size_t old_size = ArenaSz(arena);
|
||||||
LOCAL_ArenaOverflows++;
|
LOCAL_ArenaOverflows++;
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
if (old_size < 128 * 1024) {
|
if (old_size < 128 * 1024) {
|
||||||
@ -291,20 +292,17 @@ static Term GrowArena(Term arena, CELL *pt, size_t old_size, size_t size,
|
|||||||
adjust_cps(size PASS_REGS);
|
adjust_cps(size PASS_REGS);
|
||||||
}
|
}
|
||||||
pt = ArenaLimit(arena);
|
pt = ArenaLimit(arena);
|
||||||
sz = old_size + size;
|
if (pt == HR) {
|
||||||
if (pt == HR) {
|
|
||||||
HR += size;
|
HR += size;
|
||||||
HR[ - 1] = EndSpecials;
|
|
||||||
} else {
|
} else {
|
||||||
if ((sz = Yap_InsertInGlobal(pt, size * sizeof(CELL))) == 0) {
|
XREGS[arity + 1] = arena;
|
||||||
return FALSE;
|
if ((size = Yap_InsertInGlobal(pt, size * sizeof(CELL))/sizeof(CELL)) == 0) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
pt[size-1] = EndSpecials;
|
arena = XREGS[arity + 1];
|
||||||
}
|
}
|
||||||
arena = XREGS[arity + 1];
|
CreateNewArena(RepAppl(arena), size+old_size);
|
||||||
MP_INT *dst = (MP_INT *)(RepAppl(arena) + 2);
|
return size+old_size;
|
||||||
dst->_mp_alloc+= size;
|
|
||||||
return sz;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CELL *Yap_GetFromArena(Term *arenap, UInt cells, UInt arity) {
|
CELL *Yap_GetFromArena(Term *arenap, UInt cells, UInt arity) {
|
||||||
@ -375,8 +373,7 @@ static int copy_complex_term(register CELL *pt0, register CELL *pt0_end,
|
|||||||
struct cp_frame *to_visit0, *to_visit = Malloc(1024*sizeof(struct cp_frame));
|
struct cp_frame *to_visit0, *to_visit = Malloc(1024*sizeof(struct cp_frame));
|
||||||
struct cp_frame *to_visit_max;
|
struct cp_frame *to_visit_max;
|
||||||
|
|
||||||
CELL *HB0 = HB;
|
tr_fr_ptr TR0 = TR;
|
||||||
tr_fr_ptr TR0 = TR;
|
|
||||||
int ground = TRUE;
|
int ground = TRUE;
|
||||||
|
|
||||||
HB = HLow;
|
HB = HLow;
|
||||||
@ -650,13 +647,14 @@ trail_overflow:
|
|||||||
static Term CopyTermToArena(Term t, Term arena, bool share, bool copy_att_vars,
|
static Term CopyTermToArena(Term t, Term arena, bool share, bool copy_att_vars,
|
||||||
UInt arity, Term *newarena,
|
UInt arity, Term *newarena,
|
||||||
size_t min_grow USES_REGS) {
|
size_t min_grow USES_REGS) {
|
||||||
size_t old_size = ArenaSz(arena);
|
size_t old_size;
|
||||||
cell_space_t cspace;
|
cell_space_t cspace;
|
||||||
int res = 0;
|
int res = 0, restarts = 0;
|
||||||
Term tn;
|
Term tn;
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
enter_cell_space(&cspace);
|
enter_cell_space(&cspace);
|
||||||
|
old_size = ArenaSz(arena);
|
||||||
t = Deref(t);
|
t = Deref(t);
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
ASP = ArenaLimit(arena);
|
ASP = ArenaLimit(arena);
|
||||||
@ -793,7 +791,6 @@ static Term CopyTermToArena(Term t, Term arena, bool share, bool copy_att_vars,
|
|||||||
error_handler:
|
error_handler:
|
||||||
XREGS[arity + 1] = t;
|
XREGS[arity + 1] = t;
|
||||||
XREGS[arity + 2] = arena;
|
XREGS[arity + 2] = arena;
|
||||||
}
|
|
||||||
exit_cell_space(&cspace);
|
exit_cell_space(&cspace);
|
||||||
switch (res) {
|
switch (res) {
|
||||||
case -1:
|
case -1:
|
||||||
@ -801,8 +798,9 @@ static Term CopyTermToArena(Term t, Term arena, bool share, bool copy_att_vars,
|
|||||||
LOCAL_GlobalArenaOverflows++;
|
LOCAL_GlobalArenaOverflows++;
|
||||||
restarts++;
|
restarts++;
|
||||||
min_grow += (restarts < 16 ? 16*1024*restarts*restarts : 128*1024*1024);
|
min_grow += (restarts < 16 ? 16*1024*restarts*restarts : 128*1024*1024);
|
||||||
if ((arena=GrowArena(arena, min_grow, arity + 2, &cspace PASS_REGS))==0) {
|
CreateNewArena (RepAppl(arena),old_size);
|
||||||
Yap_Error(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage);
|
if((arena=GrowArena(arena, min_grow, arity + 2, &cspace PASS_REGS))==0) {
|
||||||
|
Yap_ThrowError(RESOURCE_ERROR_STACK, TermNil, LOCAL_ErrorMessage);
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -810,7 +808,6 @@ static Term CopyTermToArena(Term t, Term arena, bool share, bool copy_att_vars,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
enter_cell_space(&cspace);
|
enter_cell_space(&cspace);
|
||||||
arena = Deref(XREGS[arity + 2]);
|
arena = Deref(XREGS[arity + 2]);
|
||||||
t = XREGS[arity + 1];
|
t = XREGS[arity + 1];
|
||||||
@ -822,12 +819,13 @@ static Term CreateTermInArena(Term arena, Atom Na, UInt Nar, UInt arity,
|
|||||||
cell_space_t cells;
|
cell_space_t cells;
|
||||||
Term tf;
|
Term tf;
|
||||||
CELL *HB0;
|
CELL *HB0;
|
||||||
|
size_t old_size = ArenaSz(arena);
|
||||||
Functor f = Yap_MkFunctor(Na, Nar);
|
Functor f = Yap_MkFunctor(Na, Nar);
|
||||||
UInt i;
|
UInt i;
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
enter_cell_space(&cells);
|
enter_cell_space(&cells);
|
||||||
HR = HB = ArenaPt(arena);
|
HB0 = HR = HB = ArenaPt(arena);
|
||||||
ASP = ArenaLimit(arena);
|
ASP = ArenaLimit(arena);
|
||||||
tf = AbsAppl(HR);
|
tf = AbsAppl(HR);
|
||||||
HR[0] = (CELL)f;
|
HR[0] = (CELL)f;
|
||||||
@ -837,10 +835,11 @@ restart:
|
|||||||
HR = HB;
|
HR = HB;
|
||||||
XREGS[arity + 1] = arena;
|
XREGS[arity + 1] = arena;
|
||||||
{
|
{
|
||||||
// CELL *old_top = ArenaLimit(*newarena);
|
// CELL *old_top = ArenaLimit(*nsizeof(CELL)ewarena);
|
||||||
if (arena == LOCAL_GlobalArena)
|
if (arena == LOCAL_GlobalArena)
|
||||||
LOCAL_GlobalArenaOverflows++;
|
LOCAL_GlobalArenaOverflows++;
|
||||||
if ((arena=GrowArena(arena, Nar * sizeof(CELL),
|
CreateNewArena (RepAppl(arena),old_size);
|
||||||
|
if ((arena=GrowArena(arena, Nar * sizeof(CELL),
|
||||||
arity + 1, &cells PASS_REGS))==0) {
|
arity + 1, &cells PASS_REGS))==0) {
|
||||||
Yap_Error(RESOURCE_ERROR_STACK, TermNil,
|
Yap_Error(RESOURCE_ERROR_STACK, TermNil,
|
||||||
"while creating large global term");
|
"while creating large global term");
|
||||||
@ -859,7 +858,7 @@ restart:
|
|||||||
HB0[i] = init;
|
HB0[i] = init;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CloseArena(&cells, newarena, old_size PASS_REGS);
|
CloseArena(&cells, newarena, ArenaSz(arena) PASS_REGS);
|
||||||
return tf;
|
return tf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1990,7 +1989,8 @@ restart:
|
|||||||
gsiz = 1024;
|
gsiz = 1024;
|
||||||
}
|
}
|
||||||
ARG3 = to;
|
ARG3 = to;
|
||||||
if ((arena=GrowArena(arena, ArenaLimit(arena), old_sz, gsiz, 3, &cspace PASS_REGS))==0) {
|
CreateNewArena (RepAppl(arena),old_sz);
|
||||||
|
if ((arena=GrowArena(arena, gsiz, 3, &cspace PASS_REGS))==0) {
|
||||||
Yap_Error(RESOURCE_ERROR_STACK, arena, LOCAL_ErrorMessage);
|
Yap_Error(RESOURCE_ERROR_STACK, arena, LOCAL_ErrorMessage);
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
@ -2349,7 +2349,8 @@ cell_space_t cspace;
|
|||||||
}
|
}
|
||||||
ARG3 = to;
|
ARG3 = to;
|
||||||
/* fprintf(stderr,"growing %ld cells\n",(unsigned long int)gsiz);*/
|
/* fprintf(stderr,"growing %ld cells\n",(unsigned long int)gsiz);*/
|
||||||
if (!GrowArena(arena, ArenaLimit(arena), old_sz, gsiz, 3, &cspace PASS_REGS)) {
|
CreateNewArena (RepAppl(arena),old_sz);
|
||||||
|
if (!GrowArena(arena, gsiz, 3, &cspace PASS_REGS)) {
|
||||||
Yap_Error(RESOURCE_ERROR_STACK, arena, LOCAL_ErrorMessage);
|
Yap_Error(RESOURCE_ERROR_STACK, arena, LOCAL_ErrorMessage);
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
|
10
C/grow.c
10
C/grow.c
@ -908,6 +908,7 @@ static_growglobal(size_t request, CELL **ptr, CELL *hsplit USES_REGS)
|
|||||||
hsplit > HR)
|
hsplit > HR)
|
||||||
return false;
|
return false;
|
||||||
if (hsplit == HR && Unsigned(HR)+request < Unsigned(ASP)-StackGap( PASS_REGS1 )) {
|
if (hsplit == HR && Unsigned(HR)+request < Unsigned(ASP)-StackGap( PASS_REGS1 )) {
|
||||||
|
HR += request/sizeof(CELL);
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -916,12 +917,10 @@ static_growglobal(size_t request, CELL **ptr, CELL *hsplit USES_REGS)
|
|||||||
do_grow = false;
|
do_grow = false;
|
||||||
}
|
}
|
||||||
if (do_grow) {
|
if (do_grow) {
|
||||||
if (request < YAP_ALLOC_SIZE)
|
if (request < YAP_ALLOC_SIZE)
|
||||||
request = YAP_ALLOC_SIZE;
|
request = YAP_ALLOC_SIZE;
|
||||||
request = AdjustPageSize(request);
|
request = AdjustPageSize(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("grow=%d\n", do_grow);
|
|
||||||
/* adjust to a multiple of 256) */
|
/* adjust to a multiple of 256) */
|
||||||
LOCAL_ErrorMessage = NULL;
|
LOCAL_ErrorMessage = NULL;
|
||||||
LOCAL_PrologMode |= GrowStackMode;
|
LOCAL_PrologMode |= GrowStackMode;
|
||||||
@ -1024,7 +1023,6 @@ static_growglobal(size_t request, CELL **ptr, CELL *hsplit USES_REGS)
|
|||||||
}
|
}
|
||||||
if (hsplit) {
|
if (hsplit) {
|
||||||
MoveHalfGlobal(hsplit, request PASS_REGS);
|
MoveHalfGlobal(hsplit, request PASS_REGS);
|
||||||
printf("done\n");
|
|
||||||
}
|
}
|
||||||
YAPLeaveCriticalSection();
|
YAPLeaveCriticalSection();
|
||||||
ASP += 256;
|
ASP += 256;
|
||||||
|
Reference in New Issue
Block a user