bug fix
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1396 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
38b3140eab
commit
7d5dbe04cd
@ -27,7 +27,7 @@
|
|||||||
#include "eam.h"
|
#include "eam.h"
|
||||||
#include "eamamasm.h"
|
#include "eamamasm.h"
|
||||||
|
|
||||||
#define Debug 000
|
#define Debug 0
|
||||||
#define Debug_GC 0
|
#define Debug_GC 0
|
||||||
#define Debug_Dump_State 0 /* 0 =off || 1==only on Scheduling || 2== only on GC || 4=on every abs inst NOTE: DEBUG has to be enable to use 4*/
|
#define Debug_Dump_State 0 /* 0 =off || 1==only on Scheduling || 2== only on GC || 4=on every abs inst NOTE: DEBUG has to be enable to use 4*/
|
||||||
#define Debug_MEMORY 0
|
#define Debug_MEMORY 0
|
||||||
@ -114,7 +114,8 @@ void del_orbox_and_sons(struct OR_BOX *orbox);
|
|||||||
void waking_boxes_suspended_on_var(struct PERM_VAR *v);
|
void waking_boxes_suspended_on_var(struct PERM_VAR *v);
|
||||||
struct PERM_VAR *request_permVar(struct AND_BOX *a);
|
struct PERM_VAR *request_permVar(struct AND_BOX *a);
|
||||||
void free_permVar(struct PERM_VAR *v);
|
void free_permVar(struct PERM_VAR *v);
|
||||||
Cell *request_memory_locals(int nr, int set_vars);
|
Cell *request_memory_locals(int nr);
|
||||||
|
Cell *request_memory_locals_noinit(int nr);
|
||||||
void free_memory_locals(Cell *l);
|
void free_memory_locals(Cell *l);
|
||||||
void add_to_list_perms(struct PERM_VAR *var,struct AND_BOX *a);
|
void add_to_list_perms(struct PERM_VAR *var,struct AND_BOX *a);
|
||||||
void remove_list_perms(struct AND_BOX *a);
|
void remove_list_perms(struct AND_BOX *a);
|
||||||
@ -224,7 +225,7 @@ Cell *c;
|
|||||||
}
|
}
|
||||||
total=total+nr*i;
|
total=total+nr*i;
|
||||||
}
|
}
|
||||||
printf("Ultimo Pedido (bytes) =%d ¦ Ultimo bloco livre=%ld\n",size,ult*CELL_SIZE);
|
printf("Ultimo Pedido (bytes) =%d ¦ Ultimo bloco livre=%d\n",size,ult*CELL_SIZE);
|
||||||
printf("Memoria TOTAL (bytes) =%ld \n",((unsigned long) END_BOX)-((unsigned long) START_ADDR_BOXES));
|
printf("Memoria TOTAL (bytes) =%ld \n",((unsigned long) END_BOX)-((unsigned long) START_ADDR_BOXES));
|
||||||
printf("Memoria livre no Index_Free=%ld \n",total*CELL_SIZE);
|
printf("Memoria livre no Index_Free=%ld \n",total*CELL_SIZE);
|
||||||
printf("Memoria Total livre =%ld \n",total*CELL_SIZE+((unsigned long) END_BOX)-((unsigned long)Next_Free));
|
printf("Memoria Total livre =%ld \n",total*CELL_SIZE+((unsigned long) END_BOX)-((unsigned long)Next_Free));
|
||||||
@ -442,7 +443,7 @@ void free_memory(Cell *mem,int size) {
|
|||||||
#else
|
#else
|
||||||
INLINE void free_memory(Cell *mem,int size) /* size in bytes */
|
INLINE void free_memory(Cell *mem,int size) /* size in bytes */
|
||||||
{
|
{
|
||||||
register long size_cells;
|
register int size_cells;
|
||||||
|
|
||||||
if (size==0 || mem==NULL) return;
|
if (size==0 || mem==NULL) return;
|
||||||
|
|
||||||
@ -497,7 +498,7 @@ struct PERM_VAR *pv;
|
|||||||
else PERMS_REUSED+=PERM_VAR_SIZE;
|
else PERMS_REUSED+=PERM_VAR_SIZE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if Debug_MEMORY
|
#if Debug || Debug_MEMORY
|
||||||
printf("Requesting a permVar...\n");
|
printf("Requesting a permVar...\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -534,7 +535,7 @@ void free_permVar(struct PERM_VAR *v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
INLINE Cell *request_memory_locals(int nr, int set_vars)
|
INLINE Cell *request_memory_locals(int nr)
|
||||||
{
|
{
|
||||||
Cell *l;
|
Cell *l;
|
||||||
int i;
|
int i;
|
||||||
@ -554,7 +555,6 @@ int i;
|
|||||||
l[0]=nr;
|
l[0]=nr;
|
||||||
l++;
|
l++;
|
||||||
|
|
||||||
if (set_vars==0) return(l);
|
|
||||||
for(i=0;i<nr;i++) {
|
for(i=0;i<nr;i++) {
|
||||||
l[i]=(Cell) &l[i];
|
l[i]=(Cell) &l[i];
|
||||||
}
|
}
|
||||||
@ -566,6 +566,32 @@ int i;
|
|||||||
return(l);
|
return(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INLINE Cell *request_memory_locals_noinit(int nr)
|
||||||
|
{
|
||||||
|
Cell *l;
|
||||||
|
|
||||||
|
#if Memory_Stat
|
||||||
|
Cell *old;
|
||||||
|
old=Next_Free;
|
||||||
|
TOTAL_TEMPS+=CELL_SIZE*(nr+1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if Debug_MEMORY
|
||||||
|
printf("Requesting Memory for %d+1 locals (not initialized)...\n",nr);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
l=(Cell *)request_memory(CELL_SIZE*(nr+1));
|
||||||
|
l[0]=nr;
|
||||||
|
l++;
|
||||||
|
|
||||||
|
#if Memory_Stat
|
||||||
|
if (old==Next_Free) TEMPS_REUSED+=CELL_SIZE*(nr+1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return(l);
|
||||||
|
}
|
||||||
|
|
||||||
INLINE void free_memory_locals(Cell *l)
|
INLINE void free_memory_locals(Cell *l)
|
||||||
{
|
{
|
||||||
if (l==NULL || l[-1]==0) return;
|
if (l==NULL || l[-1]==0) return;
|
||||||
@ -2124,7 +2150,7 @@ break_debug();
|
|||||||
register int nr_locals;
|
register int nr_locals;
|
||||||
nr_locals=arg3;
|
nr_locals=arg3;
|
||||||
/* nr_locals=((struct Clauses *)arg1)->nr_vars; */
|
/* nr_locals=((struct Clauses *)arg1)->nr_vars; */
|
||||||
var_locals=request_memory_locals(nr_locals,1);
|
var_locals=request_memory_locals(nr_locals);
|
||||||
// add_to_list_locals(var_locals,ABX);
|
// add_to_list_locals(var_locals,ABX);
|
||||||
} else {
|
} else {
|
||||||
var_locals=NULL;
|
var_locals=NULL;
|
||||||
@ -2821,7 +2847,7 @@ break_debug();
|
|||||||
} else { /* write Mode */
|
} else { /* write Mode */
|
||||||
register Cell *_DR;
|
register Cell *_DR;
|
||||||
_DR=(Cell *) deref(var_locals[arg1]);
|
_DR=(Cell *) deref(var_locals[arg1]);
|
||||||
if (isvar((Cell) _DR)) {
|
if (isvar((Cell) _DR) && !is_perm_var((Cell *) _DR)) {
|
||||||
*_S=(Cell) request_permVar(ABX);
|
*_S=(Cell) request_permVar(ABX);
|
||||||
UnifyCells(_DR,_S);
|
UnifyCells(_DR,_S);
|
||||||
} else {
|
} else {
|
||||||
@ -2865,7 +2891,7 @@ break_debug();
|
|||||||
register Cell *_DR;
|
register Cell *_DR;
|
||||||
_DR=(Cell *) deref(_X[arg1]);
|
_DR=(Cell *) deref(_X[arg1]);
|
||||||
|
|
||||||
if (isvar((Cell) _DR)) {
|
if (isvar((Cell) _DR) && !is_perm_var((Cell *) _DR)) {
|
||||||
*_S=(Cell) request_permVar(ABX);
|
*_S=(Cell) request_permVar(ABX);
|
||||||
UnifyCells(_DR,_S);
|
UnifyCells(_DR,_S);
|
||||||
} else {
|
} else {
|
||||||
@ -3192,7 +3218,7 @@ break_debug();
|
|||||||
break_debug();
|
break_debug();
|
||||||
printf("put_var_P X%d,Y%d \n",(int) arg1,(int) arg2);
|
printf("put_var_P X%d,Y%d \n",(int) arg1,(int) arg2);
|
||||||
#endif
|
#endif
|
||||||
if (!is_perm_var((Cell *) var_locals[arg2]))
|
if (isvar(var_locals[arg2]) && !is_perm_var((Cell *) var_locals[arg2]))
|
||||||
var_locals[arg2]=(Cell) request_permVar(ABX);
|
var_locals[arg2]=(Cell) request_permVar(ABX);
|
||||||
_X[arg1]=var_locals[arg2];
|
_X[arg1]=var_locals[arg2];
|
||||||
pc+=3;
|
pc+=3;
|
||||||
@ -3302,7 +3328,7 @@ break_debug();
|
|||||||
break_debug();
|
break_debug();
|
||||||
printf("write_var_P Y%d \n",(int) arg1);
|
printf("write_var_P Y%d \n",(int) arg1);
|
||||||
#endif
|
#endif
|
||||||
if (!is_perm_var((Cell *) var_locals[arg1]))
|
if (isvar(var_locals[arg1]) && !is_perm_var((Cell *) var_locals[arg1]))
|
||||||
var_locals[arg1]=(Cell) request_permVar(ABX);
|
var_locals[arg1]=(Cell) request_permVar(ABX);
|
||||||
*(_S)=var_locals[arg1];
|
*(_S)=var_locals[arg1];
|
||||||
_S++;
|
_S++;
|
||||||
|
@ -336,7 +336,7 @@ struct EXTERNAL_VAR *old_externals,*externals;
|
|||||||
|
|
||||||
oldvars=calls->locals;
|
oldvars=calls->locals;
|
||||||
nr=oldvars[-1];
|
nr=oldvars[-1];
|
||||||
newvars=request_memory_locals(nr,1);
|
newvars=request_memory_locals(nr);
|
||||||
|
|
||||||
if (var_locals==oldvars) var_locals=newvars;
|
if (var_locals==oldvars) var_locals=newvars;
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ if (a==NULL) return;
|
|||||||
|
|
||||||
oldvars=calls->locals;
|
oldvars=calls->locals;
|
||||||
nr=oldvars[-1];
|
nr=oldvars[-1];
|
||||||
newvars=request_memory_locals(nr,0);
|
newvars=request_memory_locals_noinit(nr);
|
||||||
calls->locals=newvars;
|
calls->locals=newvars;
|
||||||
/* primeiro actualizo as variaveis */
|
/* primeiro actualizo as variaveis */
|
||||||
for(i=0;i<nr;i++) {
|
for(i=0;i<nr;i++) {
|
||||||
|
@ -229,6 +229,28 @@ void eam_pass(CInstr *ppc)
|
|||||||
emit_par(ArityOfFunctor((Functor )ppc->new4));
|
emit_par(ArityOfFunctor((Functor )ppc->new4));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case put_unsafe_op:
|
||||||
|
/*
|
||||||
|
printf("Got a put_unsafe...\n");
|
||||||
|
emit_inst(_put_unsafe_op);
|
||||||
|
emit_par(ppc->new1);
|
||||||
|
emit_par(Y_Var((Ventry *) ppc->new4));
|
||||||
|
break;
|
||||||
|
*/
|
||||||
|
case put_val_op:
|
||||||
|
/*
|
||||||
|
if (Is_X_Var((Ventry *) ppc->new4)) {
|
||||||
|
emit_inst(_put_val_X_op);
|
||||||
|
emit_par(ppc->new1);
|
||||||
|
emit_par(X_Var((Ventry *) ppc->new4));
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
emit_inst(_put_val_Y_op);
|
||||||
|
emit_par(ppc->new1);
|
||||||
|
emit_par(Y_Var((Ventry *) ppc->new4));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*/
|
||||||
case put_var_op:
|
case put_var_op:
|
||||||
if (Is_X_Var((Ventry *) ppc->new4)) {
|
if (Is_X_Var((Ventry *) ppc->new4)) {
|
||||||
emit_inst(_put_var_X_op);
|
emit_inst(_put_var_X_op);
|
||||||
@ -241,24 +263,6 @@ void eam_pass(CInstr *ppc)
|
|||||||
emit_par(Y_Var((Ventry *) ppc->new4));
|
emit_par(Y_Var((Ventry *) ppc->new4));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case put_val_op:
|
|
||||||
if (Is_X_Var((Ventry *) ppc->new4)) {
|
|
||||||
emit_inst(_put_val_X_op);
|
|
||||||
emit_par(ppc->new1);
|
|
||||||
emit_par(X_Var((Ventry *) ppc->new4));
|
|
||||||
break;
|
|
||||||
} else { /* else put_val_Y */
|
|
||||||
emit_inst(_put_val_Y_op);
|
|
||||||
emit_par(ppc->new1);
|
|
||||||
emit_par(Y_Var((Ventry *) ppc->new4));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case put_unsafe_op:
|
|
||||||
emit_inst(_put_unsafe_op);
|
|
||||||
emit_par(ppc->new1);
|
|
||||||
emit_par(Y_Var((Ventry *) ppc->new4));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case put_num_op:
|
case put_num_op:
|
||||||
case put_atom_op:
|
case put_atom_op:
|
||||||
@ -277,19 +281,6 @@ void eam_pass(CInstr *ppc)
|
|||||||
emit_par(ArityOfFunctor((Functor )ppc->new4));
|
emit_par(ArityOfFunctor((Functor )ppc->new4));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case write_var_op:
|
|
||||||
if (((Ventry *)(ppc->new4))->KindOfVE!=VoidVar) {
|
|
||||||
if (Is_X_Var((Ventry *) ppc->new4)) {
|
|
||||||
emit_inst(_write_var_X_op);
|
|
||||||
emit_par(X_Var((Ventry *) ppc->new4));
|
|
||||||
} else {
|
|
||||||
if (Is_P_Var((Ventry *) ppc->new4)) emit_inst(_write_var_P_op);
|
|
||||||
else emit_inst(_write_var_Y_op);
|
|
||||||
emit_par(Y_Var((Ventry *) ppc->new4));
|
|
||||||
}
|
|
||||||
} else emit_inst(_write_void);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case write_local_op:
|
case write_local_op:
|
||||||
if (Is_X_Var((Ventry *) ppc->new4)) {
|
if (Is_X_Var((Ventry *) ppc->new4)) {
|
||||||
emit_inst(_write_local_X_op);
|
emit_inst(_write_local_X_op);
|
||||||
@ -311,6 +302,21 @@ void eam_pass(CInstr *ppc)
|
|||||||
}
|
}
|
||||||
} else emit_inst(_write_void);
|
} else emit_inst(_write_void);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case write_var_op:
|
||||||
|
if (((Ventry *)(ppc->new4))->KindOfVE!=VoidVar) {
|
||||||
|
if (Is_X_Var((Ventry *) ppc->new4)) {
|
||||||
|
emit_inst(_write_var_X_op);
|
||||||
|
emit_par(X_Var((Ventry *) ppc->new4));
|
||||||
|
} else {
|
||||||
|
if (Is_P_Var((Ventry *) ppc->new4)) emit_inst(_write_var_P_op);
|
||||||
|
else emit_inst(_write_var_Y_op);
|
||||||
|
emit_par(Y_Var((Ventry *) ppc->new4));
|
||||||
|
}
|
||||||
|
} else emit_inst(_write_void);
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
case write_num_op:
|
case write_num_op:
|
||||||
case write_atom_op:
|
case write_atom_op:
|
||||||
emit_inst(_write_atom_op);
|
emit_inst(_write_atom_op);
|
||||||
|
Reference in New Issue
Block a user