Fix a code GC race condition

slava 2006-11-20 02:14:11 +00:00
parent 4af212d4a1
commit 4759883733
3 changed files with 16 additions and 6 deletions

View File

@ -252,7 +252,9 @@ void primitive_add_compiled_block(void)
here += words_length;
/* push the XT of the new word on the stack */
box_unsigned_cell(start + sizeof(F_COMPILED));
F_WORD *word = allot_word(F,F);
word->xt = start + sizeof(F_COMPILED);
dpush(tag_word(word));
}
#undef FROB
@ -270,7 +272,7 @@ void primitive_finalize_compile(void)
{
F_ARRAY *pair = untag_array(get(AREF(array,i)));
F_WORD *word = untag_word(get(AREF(pair,0)));
CELL xt = to_cell(get(AREF(pair,1)));
CELL xt = untag_word(get(AREF(pair,1)))->xt;
F_BLOCK *block = xt_to_block(xt);
if(block->status != B_ALLOCATED)
critical_error("bad XT",xt);

View File

@ -379,17 +379,24 @@ void update_xt(F_WORD* word)
}
/* <word> ( name vocabulary -- word ) */
void primitive_word(void)
F_WORD *allot_word(CELL vocab, CELL name)
{
F_WORD *word = allot_object(WORD_TYPE,sizeof(F_WORD));
word->hashcode = tag_fixnum(rand());
word->vocabulary = dpop();
word->name = dpop();
word->vocabulary = vocab;
word->name = name;
word->primitive = tag_fixnum(0);
word->def = F;
word->props = F;
update_xt(word);
dpush(tag_word(word));
return word;
}
void primitive_word(void)
{
CELL vocab = dpop();
CELL name = dpop();
dpush(tag_word(allot_word(vocab,name)));
}
void primitive_update_xt(void)

View File

@ -183,6 +183,7 @@ INLINE CELL tag_word(F_WORD *word)
}
void update_xt(F_WORD* word);
F_WORD *allot_word(CELL vocab, CELL name);
void primitive_word(void);
void primitive_update_xt(void);
void primitive_word_xt(void);