ClSize should be the block size in bytes, and not the amount of code. Check that for megaclauses.
This commit is contained in:
parent
0c940b2dce
commit
b331c4bed0
@ -838,7 +838,9 @@ Yap_BuildMegaClause(PredEntry *ap)
|
||||
required = sz*ap->cs.p_code.NOfClauses+sizeof(MegaClause)+(UInt)NEXTOP((yamop *)NULL,l);
|
||||
#ifdef DEBUG
|
||||
total_megaclause += required;
|
||||
total_released += ap->cs.p_code.NOfClauses*(sz+sizeof(StaticClause));
|
||||
cl =
|
||||
ClauseCodeToStaticClause(ap->cs.p_code.FirstClause);
|
||||
total_released += ap->cs.p_code.NOfClauses*cl->ClSize;
|
||||
nof_megaclauses++;
|
||||
#endif
|
||||
while (!(mcl = (MegaClause *)Yap_AllocCodeSpace(required))) {
|
||||
@ -850,7 +852,7 @@ Yap_BuildMegaClause(PredEntry *ap)
|
||||
Yap_ClauseSpace += required;
|
||||
/* cool, it's our turn to do the conversion */
|
||||
mcl->ClFlags = MegaMask | has_blobs;
|
||||
mcl->ClSize = sz*ap->cs.p_code.NOfClauses;
|
||||
mcl->ClSize = required;
|
||||
mcl->ClPred = ap;
|
||||
mcl->ClItemSize = sz;
|
||||
mcl->ClNext = NULL;
|
||||
|
@ -2671,7 +2671,8 @@ init_clauses(ClauseDef *cl, PredEntry *ap)
|
||||
{
|
||||
if (ap->PredFlags & MegaClausePredFlag) {
|
||||
MegaClause *mcl = ClauseCodeToMegaClause(ap->cs.p_code.FirstClause);
|
||||
yamop *end = (yamop *)((char *)mcl->ClCode+mcl->ClSize);
|
||||
UInt nclauses = mcl->ClPred->cs.p_code.NOfClauses;
|
||||
yamop *end = (yamop *)((char *)mcl->ClCode+nclauses*mcl->ClItemSize);
|
||||
yamop *cd = mcl->ClCode;
|
||||
while (cd < end) {
|
||||
cl->Code = cl->CurrentCode = cd;
|
||||
@ -2926,7 +2927,8 @@ install_clauses(ClauseDef *cls, PredEntry *ap, istack_entry *stack, yamop *beg,
|
||||
istack_entry *sp = stack;
|
||||
if (ap->PredFlags & MegaClausePredFlag) {
|
||||
MegaClause *mcl = ClauseCodeToMegaClause(beg);
|
||||
yamop *end = (yamop *)((char *)mcl->ClCode+mcl->ClSize);
|
||||
UInt nclauses = mcl->ClPred->cs.p_code.NOfClauses;
|
||||
yamop *end = (yamop *)((char *)mcl->ClCode+nclauses*mcl->ClItemSize);
|
||||
yamop *cd = mcl->ClCode;
|
||||
|
||||
if (stack[0].pos == 0) {
|
||||
@ -3211,7 +3213,7 @@ count_clauses_left(yamop *cl, PredEntry *ap)
|
||||
return i;
|
||||
} else if (ap->PredFlags & MegaClausePredFlag) {
|
||||
MegaClause *mcl = ClauseCodeToMegaClause(ap->cs.p_code.FirstClause);
|
||||
UInt ncls = mcl->ClSize/mcl->ClItemSize;
|
||||
UInt ncls = mcl->ClPred->cs.p_code.NOfClauses;
|
||||
|
||||
return (ncls-1)-((char *)cl-(char *)mcl->ClCode)/mcl->ClItemSize;
|
||||
} else {
|
||||
|
10
C/qlyr.c
10
C/qlyr.c
@ -828,10 +828,16 @@ read_clauses(IOSTREAM *stream, PredEntry *pp, UInt nclauses, UInt flags) {
|
||||
}
|
||||
LOCAL_HDiff = (char *)cl-base;
|
||||
read_bytes(stream, cl, size);
|
||||
RestoreMegaClause(cl PASS_REGS);
|
||||
pp->cs.p_code.FirstClause =
|
||||
pp->cs.p_code.LastClause =
|
||||
cl->ClCode;
|
||||
pp->PredFlags |= MegaClausePredFlag;
|
||||
/* enter index mode */
|
||||
pp->OpcodeOfPred = INDEX_OPCODE;
|
||||
pp->CodeOfPred = pp->cs.p_code.TrueCodeOfPred = (yamop *)(&(pp->OpcodeOfPred));
|
||||
/* This must be set for restoremegaclause */
|
||||
pp->cs.p_code.NOfClauses = nclauses;
|
||||
RestoreMegaClause(cl PASS_REGS);
|
||||
} else if (pp->PredFlags & DynamicPredFlag) {
|
||||
UInt i;
|
||||
|
||||
@ -923,7 +929,7 @@ read_pred(IOSTREAM *stream, Term mod) {
|
||||
ap->src.IndxId = read_uint(stream);
|
||||
} else {
|
||||
ap->src.OwnerFile = (Atom)read_uint(stream);
|
||||
if (ap->src.OwnerFile && !(flags & MultiFileFlag)) {
|
||||
if (ap->src.OwnerFile) {
|
||||
ap->src.OwnerFile = AtomAdjust(ap->src.OwnerFile);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user