save/restore exo
This commit is contained in:
parent
a913523d6a
commit
e9d04ef9f5
2
C/exo.c
2
C/exo.c
@ -421,7 +421,7 @@ p_exodb_get_space( USES_REGS1 )
|
|||||||
Yap_ClauseSpace += required;
|
Yap_ClauseSpace += required;
|
||||||
/* cool, it's our turn to do the conversion */
|
/* cool, it's our turn to do the conversion */
|
||||||
mcl->ClFlags = MegaMask|ExoMask;
|
mcl->ClFlags = MegaMask|ExoMask;
|
||||||
mcl->ClSize = required-sizeof(MegaClause);
|
mcl->ClSize = required;
|
||||||
mcl->ClPred = ap;
|
mcl->ClPred = ap;
|
||||||
mcl->ClItemSize = arity*sizeof(CELL);
|
mcl->ClItemSize = arity*sizeof(CELL);
|
||||||
mcl->ClNext = NULL;
|
mcl->ClNext = NULL;
|
||||||
|
11
C/qlyr.c
11
C/qlyr.c
@ -849,6 +849,7 @@ read_clauses(IOSTREAM *stream, PredEntry *pp, UInt nclauses, UInt flags) {
|
|||||||
} else if (pp->PredFlags & MegaClausePredFlag) {
|
} else if (pp->PredFlags & MegaClausePredFlag) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
char *base = (void *)read_uint(stream);
|
char *base = (void *)read_uint(stream);
|
||||||
|
UInt mask = read_uint(stream);
|
||||||
UInt size = read_uint(stream);
|
UInt size = read_uint(stream);
|
||||||
MegaClause *cl = (MegaClause *)Yap_AlwaysAllocCodeSpace(size);
|
MegaClause *cl = (MegaClause *)Yap_AlwaysAllocCodeSpace(size);
|
||||||
|
|
||||||
@ -857,12 +858,20 @@ read_clauses(IOSTREAM *stream, PredEntry *pp, UInt nclauses, UInt flags) {
|
|||||||
}
|
}
|
||||||
LOCAL_HDiff = (char *)cl-base;
|
LOCAL_HDiff = (char *)cl-base;
|
||||||
read_bytes(stream, cl, size);
|
read_bytes(stream, cl, size);
|
||||||
|
cl->ClFlags = mask;
|
||||||
pp->cs.p_code.FirstClause =
|
pp->cs.p_code.FirstClause =
|
||||||
pp->cs.p_code.LastClause =
|
pp->cs.p_code.LastClause =
|
||||||
cl->ClCode;
|
cl->ClCode;
|
||||||
pp->PredFlags |= MegaClausePredFlag;
|
pp->PredFlags |= MegaClausePredFlag;
|
||||||
/* enter index mode */
|
/* enter index mode */
|
||||||
pp->OpcodeOfPred = INDEX_OPCODE;
|
if (mask & ExoMask) {
|
||||||
|
struct index_t **icl = (struct index_t **)(cl->ClCode);
|
||||||
|
pp->OpcodeOfPred = Yap_opcode(_enter_exo);
|
||||||
|
icl[0] = NULL;
|
||||||
|
icl[1] = NULL;
|
||||||
|
} else {
|
||||||
|
pp->OpcodeOfPred = INDEX_OPCODE;
|
||||||
|
}
|
||||||
pp->CodeOfPred = pp->cs.p_code.TrueCodeOfPred = (yamop *)(&(pp->OpcodeOfPred));
|
pp->CodeOfPred = pp->cs.p_code.TrueCodeOfPred = (yamop *)(&(pp->OpcodeOfPred));
|
||||||
/* This must be set for restoremegaclause */
|
/* This must be set for restoremegaclause */
|
||||||
pp->cs.p_code.NOfClauses = nclauses;
|
pp->cs.p_code.NOfClauses = nclauses;
|
||||||
|
1
C/qlyw.c
1
C/qlyw.c
@ -649,6 +649,7 @@ save_clauses(IOSTREAM *stream, PredEntry *pp) {
|
|||||||
UInt size = cl->ClSize;
|
UInt size = cl->ClSize;
|
||||||
|
|
||||||
CHECK(save_uint(stream, (UInt)cl));
|
CHECK(save_uint(stream, (UInt)cl));
|
||||||
|
CHECK(save_uint(stream, (UInt)(cl->ClFlags)));
|
||||||
CHECK(save_uint(stream, size));
|
CHECK(save_uint(stream, size));
|
||||||
CHECK(save_bytes(stream, cl, size));
|
CHECK(save_bytes(stream, cl, size));
|
||||||
} else if (pp->PredFlags & DynamicPredFlag) {
|
} else if (pp->PredFlags & DynamicPredFlag) {
|
||||||
|
19
H/rheap.h
19
H/rheap.h
@ -588,10 +588,21 @@ RestoreMegaClause(MegaClause *cl USES_REGS)
|
|||||||
}
|
}
|
||||||
max = (yamop *)((CODEADDR)cl+cl->ClSize);
|
max = (yamop *)((CODEADDR)cl+cl->ClSize);
|
||||||
|
|
||||||
for (ptr = cl->ClCode; ptr < max; ) {
|
if (cl->ClFlags & ExoMask) {
|
||||||
nextptr = (yamop *)((char *)ptr + cl->ClItemSize);
|
CELL *base = (CELL *)((ADDR)cl->ClCode+2*sizeof(struct index_t *));
|
||||||
restore_opcodes(ptr, nextptr PASS_REGS);
|
CELL *end = (CELL*)max, *ptr;
|
||||||
ptr = nextptr;
|
|
||||||
|
for (ptr = base; ptr < end; ptr++) {
|
||||||
|
Term t = *ptr;
|
||||||
|
if (IsAtomTerm(t)) *ptr = AtomTermAdjust(t);
|
||||||
|
/* don't handle other complex terms just yet, ints are ok */
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (ptr = cl->ClCode; ptr < max; ) {
|
||||||
|
nextptr = (yamop *)((char *)ptr + cl->ClItemSize);
|
||||||
|
restore_opcodes(ptr, nextptr PASS_REGS);
|
||||||
|
ptr = nextptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user