growheap was not checking some compiler instructions

source was getting confused in reconsult


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1118 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2004-08-20 16:16:23 +00:00
parent 0018e82503
commit 64b01a75c1
2 changed files with 109 additions and 15 deletions

View File

@ -11,8 +11,11 @@
* File: amasm.c * * File: amasm.c *
* comments: abstract machine assembler * * comments: abstract machine assembler *
* * * *
* Last rev: $Date: 2004-04-29 03:45:50 $ * * Last rev: $Date: 2004-08-20 16:16:23 $ *
* $Log: not supported by cvs2svn $ * $Log: not supported by cvs2svn $
* Revision 1.61 2004/04/29 03:45:50 vsc
* fix garbage collection in execute_tail
*
* Revision 1.60 2004/04/22 20:07:04 vsc * Revision 1.60 2004/04/22 20:07:04 vsc
* more fixes for USE_SYSTEM_MEMORY * more fixes for USE_SYSTEM_MEMORY
* *
@ -2815,13 +2818,12 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
H = (CELL *)cip->freep; H = (CELL *)cip->freep;
while ((x = Yap_StoreTermInDBPlusExtraSpace(t, size)) == NULL) { while ((x = Yap_StoreTermInDBPlusExtraSpace(t, size)) == NULL) {
H = h0; *H++ = (CELL)h0;
if (!Yap_growheap(TRUE, size, cip)) { if (!Yap_growheap(TRUE, size, cip)) {
Yap_Error_TYPE = SYSTEM_ERROR; Yap_Error_TYPE = SYSTEM_ERROR;
return NULL; return NULL;
} }
h0 = H; h0 = (CELL *)*--H;
H = (CELL *)cip->freep;
} }
H = h0; H = h0;
cl = (LogUpdClause *)((CODEADDR)x-(UInt)size); cl = (LogUpdClause *)((CODEADDR)x-(UInt)size);
@ -2829,14 +2831,13 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
cip->code_addr = (yamop *)cl; cip->code_addr = (yamop *)cl;
} else if (mode == ASSEMBLING_CLAUSE && } else if (mode == ASSEMBLING_CLAUSE &&
(ap->PredFlags & SourcePredFlag || (ap->PredFlags & SourcePredFlag ||
(!ap->cs.p_code.NOfClauses && yap_flags[SOURCE_MODE_FLAG])) && yap_flags[SOURCE_MODE_FLAG]) &&
!is_fact) { !is_fact) {
DBTerm *x; DBTerm *x;
StaticClause *cl; StaticClause *cl;
CELL *h0 = H;
H = (CELL *)cip->freep;
while ((x = Yap_StoreTermInDBPlusExtraSpace(t, size)) == NULL) { while ((x = Yap_StoreTermInDBPlusExtraSpace(t, size)) == NULL) {
switch (Yap_Error_TYPE) { switch (Yap_Error_TYPE) {
case OUT_OF_STACK_ERROR: case OUT_OF_STACK_ERROR:
Yap_Error_Size = 256+((char *)cip->freep - (char *)H); Yap_Error_Size = 256+((char *)cip->freep - (char *)H);
@ -2844,33 +2845,26 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
longjmp(cip->CompilerBotch,3); longjmp(cip->CompilerBotch,3);
case OUT_OF_TRAIL_ERROR: case OUT_OF_TRAIL_ERROR:
/* don't just return NULL */ /* don't just return NULL */
H = h0;
ARG1 = t; ARG1 = t;
if (!Yap_growtrail(64 * 1024L)) { if (!Yap_growtrail(64 * 1024L)) {
return NULL; return NULL;
} }
Yap_Error_TYPE = YAP_NO_ERROR; Yap_Error_TYPE = YAP_NO_ERROR;
t = ARG1; t = ARG1;
h0 = H;
H = (CELL *)cip->freep;
break; break;
case OUT_OF_HEAP_ERROR: case OUT_OF_HEAP_ERROR:
/* don't just return NULL */ /* don't just return NULL */
H = h0;
ARG1 = t; ARG1 = t;
if (!Yap_growheap(TRUE, size, cip)) { if (!Yap_growheap(TRUE, size, cip)) {
return NULL; return NULL;
} }
Yap_Error_TYPE = YAP_NO_ERROR; Yap_Error_TYPE = YAP_NO_ERROR;
t = ARG1; t = ARG1;
h0 = H;
H = (CELL *)cip->freep;
break; break;
default: default:
return NULL; return NULL;
} }
} }
H = h0;
cl = (StaticClause *)((CODEADDR)x-(UInt)size); cl = (StaticClause *)((CODEADDR)x-(UInt)size);
cip->code_addr = (yamop *)cl; cip->code_addr = (yamop *)cl;
code_p = do_pass(1, &entry_code, mode, &clause_has_blobs, cip, size); code_p = do_pass(1, &entry_code, mode, &clause_has_blobs, cip, size);
@ -2880,6 +2874,7 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates
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) {
if (!Yap_growheap(TRUE, size, cip)) { if (!Yap_growheap(TRUE, size, cip)) {
Yap_Error_TYPE = SYSTEM_ERROR; Yap_Error_TYPE = SYSTEM_ERROR;
return NULL; return NULL;

101
C/grow.c
View File

@ -625,11 +625,16 @@ fix_compiler_instructions(PInstr *pcpc)
case unify_var_op: case unify_var_op:
case unify_last_var_op: case unify_last_var_op:
case unify_val_op: case unify_val_op:
case unify_local_op:
case unify_last_val_op: case unify_last_val_op:
case unify_last_local_op:
case put_var_op: case put_var_op:
case put_val_op: case put_val_op:
case put_unsafe_op:
case write_unsafe_op:
case write_var_op: case write_var_op:
case write_val_op: case write_val_op:
case write_local_op:
case f_var_op: case f_var_op:
case f_val_op: case f_val_op:
case fetch_args_for_bccall: case fetch_args_for_bccall:
@ -638,10 +643,104 @@ fix_compiler_instructions(PInstr *pcpc)
case save_appl_op: case save_appl_op:
case save_b_op: case save_b_op:
case commit_b_op: case commit_b_op:
case fetch_args_cv_op:
case fetch_args_vc_op:
case fetch_args_vv_op:
pcpc->rnd1 = GlobalAdjust(pcpc->rnd1); pcpc->rnd1 = GlobalAdjust(pcpc->rnd1);
break; break;
default:
/* hopefully nothing to do */ /* hopefully nothing to do */
case nop_op:
case get_atom_op:
case put_atom_op:
case get_num_op:
case put_num_op:
case get_float_op:
case put_float_op:
case align_float_op:
case get_longint_op:
case put_longint_op:
case get_bigint_op:
case put_bigint_op:
case get_list_op:
case put_list_op:
case get_struct_op:
case put_struct_op:
case unify_atom_op:
case unify_last_atom_op:
case write_atom_op:
case unify_num_op:
case unify_last_num_op:
case write_num_op:
case unify_float_op:
case unify_last_float_op:
case write_float_op:
case unify_longint_op:
case unify_last_longint_op:
case write_longint_op:
case unify_bigint_op:
case unify_last_bigint_op:
case write_bigint_op:
case unify_list_op:
case write_list_op:
case unify_struct_op:
case write_struct_op:
case fail_op:
case cut_op:
case cutexit_op:
case allocate_op:
case deallocate_op:
case tryme_op:
case jump_op:
case jumpi_op:
case procceed_op:
case call_op:
case execute_op:
case safe_call_op:
case label_op:
case name_op:
case pop_op:
case retryme_op:
case trustme_op:
case either_op:
case orelse_op:
case orlast_op:
case push_or_op:
case pushpop_or_op:
case pop_or_op:
case patch_b_op:
case try_op:
case retry_op:
case trust_op:
case try_in_op:
case jump_v_op:
case jump_nv_op:
case cache_arg_op:
case cache_sub_arg_op:
case switch_on_type_op:
case switch_c_op:
case if_c_op:
case switch_f_op:
case if_f_op:
case if_not_op:
case index_dbref_op:
case index_blob_op:
case if_nonvar_op:
case commit_opt_op:
case unify_last_list_op:
case write_last_list_op:
case unify_last_struct_op:
case write_last_struct_op:
case mark_initialised_pvars_op:
case mark_live_regs_op:
case enter_profiling_op:
case retry_profiled_op:
case count_call_op:
case count_retry_op:
case restore_tmps_op:
case restore_tmps_and_skip_op:
case enter_lu_op:
case empty_call_op:
case blob_op:
break; break;
} }
if (ncpc != NULL) { if (ncpc != NULL) {