more memory allocation fixes.
This commit is contained in:
parent
c4b12d5cbe
commit
052c20a29b
50
C/amasm.c
50
C/amasm.c
@ -3836,21 +3836,23 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
|
|||||||
int clause_has_dbterm = FALSE;
|
int clause_has_dbterm = FALSE;
|
||||||
|
|
||||||
#if USE_SYSTEM_MALLOC
|
#if USE_SYSTEM_MALLOC
|
||||||
if (!Yap_LabelFirstArray && max_label <= DEFAULT_NLABELS) {
|
if (!cip->label_offset) {
|
||||||
Yap_LabelFirstArray = (Int *)Yap_AllocCodeSpace(sizeof(Int)*DEFAULT_NLABELS);
|
if (!Yap_LabelFirstArray && max_label <= DEFAULT_NLABELS) {
|
||||||
Yap_LabelFirstArraySz = DEFAULT_NLABELS;
|
Yap_LabelFirstArray = (Int *)Yap_AllocCodeSpace(sizeof(Int)*DEFAULT_NLABELS);
|
||||||
if (!Yap_LabelFirstArray) {
|
Yap_LabelFirstArraySz = DEFAULT_NLABELS;
|
||||||
save_machine_regs();
|
if (!Yap_LabelFirstArray) {
|
||||||
longjmp(cip->CompilerBotch, OUT_OF_HEAP_BOTCH);
|
save_machine_regs();
|
||||||
|
longjmp(cip->CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (Yap_LabelFirstArray && max_label <= Yap_LabelFirstArraySz) {
|
||||||
if (Yap_LabelFirstArray && max_label <= Yap_LabelFirstArraySz) {
|
cip->label_offset = Yap_LabelFirstArray;
|
||||||
cip->label_offset = Yap_LabelFirstArray;
|
} else {
|
||||||
} else {
|
cip->label_offset = (Int *)Yap_AllocCodeSpace(sizeof(Int)*max_label);
|
||||||
cip->label_offset = (Int *)Yap_AllocCodeSpace(sizeof(Int)*max_label);
|
if (!cip->label_offset) {
|
||||||
if (!cip->label_offset) {
|
save_machine_regs();
|
||||||
save_machine_regs();
|
longjmp(cip->CompilerBotch, OUT_OF_HEAP_BOTCH);
|
||||||
longjmp(cip->CompilerBotch, OUT_OF_HEAP_BOTCH);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -3875,10 +3877,6 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
|
|||||||
UInt osize;
|
UInt osize;
|
||||||
|
|
||||||
if(!(x = fetch_clause_space(&t,size,cip,&osize))){
|
if(!(x = fetch_clause_space(&t,size,cip,&osize))){
|
||||||
#if USE_SYSTEM_MALLOC
|
|
||||||
if (cip->label_offset != Yap_LabelFirstArray)
|
|
||||||
Yap_FreeCodeSpace((ADDR)cip->label_offset);
|
|
||||||
#endif
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
cl = (LogUpdClause *)((CODEADDR)x-(UInt)size);
|
cl = (LogUpdClause *)((CODEADDR)x-(UInt)size);
|
||||||
@ -3893,10 +3891,6 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
|
|||||||
StaticClause *cl;
|
StaticClause *cl;
|
||||||
UInt osize;
|
UInt osize;
|
||||||
if(!(x = fetch_clause_space(&t,size,cip,&osize))) {
|
if(!(x = fetch_clause_space(&t,size,cip,&osize))) {
|
||||||
#if USE_SYSTEM_MALLOC
|
|
||||||
if (cip->label_offset != Yap_LabelFirstArray)
|
|
||||||
Yap_FreeCodeSpace((ADDR)cip->label_offset);
|
|
||||||
#endif
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
cl = (StaticClause *)((CODEADDR)x-(UInt)size);
|
cl = (StaticClause *)((CODEADDR)x-(UInt)size);
|
||||||
@ -3906,10 +3900,6 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
|
|||||||
cl->usc.ClSource = x;
|
cl->usc.ClSource = x;
|
||||||
cl->ClSize = osize;
|
cl->ClSize = osize;
|
||||||
ProfEnd=code_p;
|
ProfEnd=code_p;
|
||||||
#if USE_SYSTEM_MALLOC
|
|
||||||
if (cip->label_offset != Yap_LabelFirstArray)
|
|
||||||
Yap_FreeCodeSpace((ADDR)cip->label_offset);
|
|
||||||
#endif
|
|
||||||
return entry_code;
|
return entry_code;
|
||||||
} else {
|
} else {
|
||||||
while ((cip->code_addr = (yamop *) Yap_AllocCodeSpace(size)) == NULL) {
|
while ((cip->code_addr = (yamop *) Yap_AllocCodeSpace(size)) == NULL) {
|
||||||
@ -3917,10 +3907,6 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
|
|||||||
if (!Yap_growheap(TRUE, size, cip)) {
|
if (!Yap_growheap(TRUE, size, cip)) {
|
||||||
Yap_Error_TYPE = OUT_OF_HEAP_ERROR;
|
Yap_Error_TYPE = OUT_OF_HEAP_ERROR;
|
||||||
Yap_Error_Size = size;
|
Yap_Error_Size = size;
|
||||||
#if USE_SYSTEM_MALLOC
|
|
||||||
if (cip->label_offset != Yap_LabelFirstArray)
|
|
||||||
Yap_FreeCodeSpace((ADDR)cip->label_offset);
|
|
||||||
#endif
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3944,10 +3930,6 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
|
|||||||
Yap_inform_profiler_of_clause(entry_code, ProfEnd, ap, mode == ASSEMBLING_INDEX);
|
Yap_inform_profiler_of_clause(entry_code, ProfEnd, ap, mode == ASSEMBLING_INDEX);
|
||||||
}
|
}
|
||||||
#endif /* LOW_PROF */
|
#endif /* LOW_PROF */
|
||||||
#if USE_SYSTEM_MALLOC
|
|
||||||
if (cip->label_offset != Yap_LabelFirstArray)
|
|
||||||
Yap_FreeCodeSpace((ADDR)cip->label_offset);
|
|
||||||
#endif
|
|
||||||
return entry_code;
|
return entry_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3405,6 +3405,7 @@ Yap_cclause(volatile Term inp_clause, int NOfArgs, Term mod, volatile Term src)
|
|||||||
cglobs.cint.BlobsStart = cglobs.cint.icpc = NULL;
|
cglobs.cint.BlobsStart = cglobs.cint.icpc = NULL;
|
||||||
cglobs.cint.dbterml = NULL;
|
cglobs.cint.dbterml = NULL;
|
||||||
cglobs.cint.blks = NULL;
|
cglobs.cint.blks = NULL;
|
||||||
|
cglobs.cint.label_offset = NULL;
|
||||||
cglobs.cint.freep =
|
cglobs.cint.freep =
|
||||||
cglobs.cint.freep0 =
|
cglobs.cint.freep0 =
|
||||||
(char *) (H + maxvnum+(sizeof(Int)/sizeof(CELL))*MaxTemps+MaxTemps);
|
(char *) (H + maxvnum+(sizeof(Int)/sizeof(CELL))*MaxTemps+MaxTemps);
|
||||||
|
@ -170,7 +170,12 @@ Yap_ReleaseCMem (struct intermediates *cip)
|
|||||||
p = nextp;
|
p = nextp;
|
||||||
}
|
}
|
||||||
cip->blks = NULL;
|
cip->blks = NULL;
|
||||||
|
if (cip->label_offset &&
|
||||||
|
cip->label_offset != Yap_LabelFirstArray) {
|
||||||
|
Yap_FreeCodeSpace((ADDR)cip->label_offset);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
cip->label_offset = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
@ -3419,6 +3419,7 @@ Yap_PredIsIndexable(PredEntry *ap, UInt NSlots, yamop *next_pc)
|
|||||||
Yap_BuildMegaClause(ap);
|
Yap_BuildMegaClause(ap);
|
||||||
cint.CodeStart = cint.BlobsStart = cint.cpc = cint.icpc = NULL;
|
cint.CodeStart = cint.BlobsStart = cint.cpc = cint.icpc = NULL;
|
||||||
cint.expand_block = NULL;
|
cint.expand_block = NULL;
|
||||||
|
cint.label_offset = NULL;
|
||||||
Yap_ErrorMessage = NULL;
|
Yap_ErrorMessage = NULL;
|
||||||
if (compile_index(&cint) == (UInt)FAILCODE) {
|
if (compile_index(&cint) == (UInt)FAILCODE) {
|
||||||
Yap_ReleaseCMem(&cint);
|
Yap_ReleaseCMem(&cint);
|
||||||
@ -4499,6 +4500,7 @@ ExpandIndex(PredEntry *ap, int ExtraArgs, yamop *nextop) {
|
|||||||
cint.blks = NULL;
|
cint.blks = NULL;
|
||||||
cint.cls = NULL;
|
cint.cls = NULL;
|
||||||
cint.code_addr = NULL;
|
cint.code_addr = NULL;
|
||||||
|
cint.label_offset = NULL;
|
||||||
if ((cb = setjmp(cint.CompilerBotch)) == 3) {
|
if ((cb = setjmp(cint.CompilerBotch)) == 3) {
|
||||||
restore_machine_regs();
|
restore_machine_regs();
|
||||||
/* grow stack */
|
/* grow stack */
|
||||||
|
Reference in New Issue
Block a user