Fix profiler crash with large heap

db4
Slava Pestov 2008-04-05 08:27:07 -05:00
parent f94596af57
commit 2c76171c8a
4 changed files with 33 additions and 21 deletions

View File

@ -821,3 +821,24 @@ DEFINE_PRIMITIVE(become)
gc();
}
CELL find_all_words(void)
{
GROWABLE_ARRAY(words);
begin_scan();
CELL obj;
while((obj = next_object()) != F)
{
if(type_of(obj) == WORD_TYPE)
GROWABLE_ADD(words,obj);
}
/* End heap scan */
gc_off = false;
GROWABLE_TRIM(words);
return words;
}

View File

@ -365,3 +365,5 @@ DLLEXPORT void simple_gc(void);
DECLARE_PRIMITIVE(gc);
DECLARE_PRIMITIVE(gc_time);
DECLARE_PRIMITIVE(become);
CELL find_all_words(void);

View File

@ -38,21 +38,8 @@ void do_stage1_init(void)
fprintf(stderr,"*** Stage 2 early init... ");
fflush(stderr);
GROWABLE_ARRAY(words);
CELL words = find_all_words();
begin_scan();
CELL obj;
while((obj = next_object()) != F)
{
if(type_of(obj) == WORD_TYPE)
GROWABLE_ADD(words,obj);
}
/* End heap scan */
gc_off = false;
GROWABLE_TRIM(words);
REGISTER_ROOT(words);
CELL i;

View File

@ -61,17 +61,19 @@ void set_profiling(bool profiling)
and allocate profiling blocks if necessary */
gc();
/* Update word XTs and saved callstack objects */
begin_scan();
CELL words = find_all_words();
CELL obj;
while((obj = next_object()) != F)
REGISTER_ROOT(words);
CELL i;
CELL length = array_capacity(untag_object(words));
for(i = 0; i < length; i++)
{
if(type_of(obj) == WORD_TYPE)
update_word_xt(untag_object(obj));
F_WORD *word = untag_word(array_nth(untag_array(words),i));
update_word_xt(word);
}
gc_off = false; /* end heap scan */
UNREGISTER_ROOT(words);
/* Update XTs in code heap */
iterate_code_heap(relocate_code_block);