memory
This commit is contained in:
45
CXX/yapi.cpp
45
CXX/yapi.cpp
@@ -477,7 +477,9 @@ const char *YAPAtom::getName(void) { return Yap_AtomToUTF8Text(a); }
|
||||
|
||||
void YAPQuery::openQuery() {
|
||||
CACHE_REGS
|
||||
if (ap == NULL || ap->OpcodeOfPred == UNDEF_OPCODE) {
|
||||
lvl = AllocLevel();
|
||||
|
||||
if (ap == NULL || ap->OpcodeOfPred == UNDEF_OPCODE) {
|
||||
ap = rewriteUndefQuery();
|
||||
}
|
||||
setNext();
|
||||
@@ -492,13 +494,13 @@ bool YAPEngine::call(YAPPredicate ap, YAPTerm ts[]) {
|
||||
bool result;
|
||||
YAP_dogoalinfo q;
|
||||
|
||||
for (arity_t i = 0; i < arity; i++)
|
||||
XREGS[i + 1] = ts[i].term();
|
||||
|
||||
q.CurSlot = Yap_StartSlots();
|
||||
q.p = P;
|
||||
|
||||
q.cp = CP;
|
||||
for (arity_t i = 0; i < arity; i++)
|
||||
XREGS[i + 1] = ts[i].term();
|
||||
|
||||
// allow Prolog style exceotion handling
|
||||
// don't forget, on success these bindings will still be there);
|
||||
result = YAP_LeaveGoal(true, &q);
|
||||
@@ -506,6 +508,7 @@ bool YAPEngine::call(YAPPredicate ap, YAPTerm ts[]) {
|
||||
YAPCatchError();
|
||||
|
||||
Yap_CloseHandles(q.CurSlot);
|
||||
pop_text_stack(q.lvl+1);
|
||||
RECOVER_MACHINE_REGS();
|
||||
return result;
|
||||
}
|
||||
@@ -519,6 +522,9 @@ bool YAPEngine::mgoal(Term t, Term tmod, bool release) {
|
||||
CACHE_REGS
|
||||
BACKUP_MACHINE_REGS();
|
||||
Term *ts = nullptr;
|
||||
q.CurSlot = Yap_StartSlots();
|
||||
q.p = P;
|
||||
q.cp = CP;
|
||||
try {
|
||||
if (IsStringTerm(tmod))
|
||||
tmod = MkAtomTerm(Yap_LookupAtom(StringOfTerm(tmod)));
|
||||
@@ -540,9 +546,6 @@ bool YAPEngine::mgoal(Term t, Term tmod, bool release) {
|
||||
}
|
||||
ts = nullptr;
|
||||
bool result;
|
||||
q.CurSlot = Yap_StartSlots();
|
||||
q.p = P;
|
||||
q.cp = CP;
|
||||
// allow Prolog style exception handling
|
||||
// don't forget, on success these guys may create slots
|
||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "exec ");
|
||||
@@ -1041,21 +1044,19 @@ std::stringstream s;
|
||||
void YAPEngine::reSet() {
|
||||
/* ignore flags for now */
|
||||
BACKUP_MACHINE_REGS();
|
||||
Yap_RebootHandles(worker_id);
|
||||
while (B && B->cp_b)
|
||||
B = B->cp_b;
|
||||
if (B) {
|
||||
P = FAILCODE;
|
||||
Yap_exec_absmi(true, YAP_EXEC_ABSMI);
|
||||
/* recover stack space */
|
||||
HR = B->cp_h;
|
||||
TR = B->cp_tr;
|
||||
#ifdef DEPTH_LIMIT
|
||||
DEPTH = B->cp_depth;
|
||||
#endif /* DEPTH_LIMIT */
|
||||
YENV = ENV = B->cp_env;
|
||||
}
|
||||
RECOVER_MACHINE_REGS();
|
||||
|
||||
choiceptr b = (choiceptr)(LCL0-q.b);
|
||||
if (b > B) B = b;
|
||||
P = FAILCODE;
|
||||
Yap_exec_absmi(true, YAP_EXEC_ABSMI);
|
||||
/* recover stack space */
|
||||
LOCAL_ActiveError->errorNo = YAP_NO_ERROR;
|
||||
if (H0+q.h < HR)
|
||||
HR = H0+q.h;
|
||||
if (LCL0+q.tr < (CELL*)TR)
|
||||
TR = (tr_fr_ptr)(LCL0+q.tr);
|
||||
Yap_CloseHandles( q.CurSlot );
|
||||
RECOVER_MACHINE_REGS();
|
||||
}
|
||||
|
||||
Term YAPEngine::top_level(std::string s) {
|
||||
|
@@ -45,7 +45,8 @@ class X_API YAPQuery : public YAPPredicate {
|
||||
YAPPairTerm names;
|
||||
YAPTerm goal;
|
||||
// temporaries
|
||||
YAPError *e;
|
||||
int lvl;
|
||||
YAPError *e;
|
||||
|
||||
inline void setNext() { // oq = LOCAL_execution;
|
||||
// LOCAL_execution = this;
|
||||
@@ -291,7 +292,7 @@ private:
|
||||
YAPError yerror;
|
||||
void doInit(YAP_file_type_t BootMode, YAPEngineArgs *cargs);
|
||||
YAP_dogoalinfo q;
|
||||
YAPError e;
|
||||
YAPError e;
|
||||
PredEntry *rewriteUndefEngineQuery(PredEntry *ap, Term &t, Term tmod);
|
||||
|
||||
public:
|
||||
@@ -338,7 +339,7 @@ public:
|
||||
/// current directory for the engine
|
||||
bool call(YAPPredicate ap, YAPTerm ts[]);
|
||||
/// current directory for the engine
|
||||
bool goal(YAPTerm Yt, YAPModule module) { return mgoal(Yt.term(),module.term()); };
|
||||
bool goal(YAPTerm Yt, YAPModule module, bool release=false) { return mgoal(Yt.term(),module.term(), release); };
|
||||
/// ru1n a goal in a module.
|
||||
///
|
||||
/// By default, memory will only be fully
|
||||
|
Reference in New Issue
Block a user