diff --git a/extra/tools/profiler/profiler-tests.factor b/extra/tools/profiler/profiler-tests.factor index d78e6fcbea..75ca5ede8c 100755 --- a/extra/tools/profiler/profiler-tests.factor +++ b/extra/tools/profiler/profiler-tests.factor @@ -1,6 +1,6 @@ IN: tools.profiler.tests USING: accessors tools.profiler tools.test kernel memory math -threads alien tools.profiler.private sequences ; +threads alien tools.profiler.private sequences compiler.units ; [ t ] [ \ length counter>> @@ -42,3 +42,15 @@ threads alien tools.profiler.private sequences ; [ 1 ] [ \ foobaz counter>> ] unit-test [ 2 ] [ \ fooblah counter>> ] unit-test + +: recompile-while-profiling-test ( -- ) ; + +[ ] [ + [ + 333 [ recompile-while-profiling-test ] times + { recompile-while-profiling-test } compile + 333 [ recompile-while-profiling-test ] times + ] profile +] unit-test + +[ 666 ] [ \ recompile-while-profiling-test counter>> ] unit-test diff --git a/vm/profiler.c b/vm/profiler.c index 58a4aa035e..27e903178b 100755 --- a/vm/profiler.c +++ b/vm/profiler.c @@ -35,8 +35,6 @@ void update_word_xt(F_WORD *word) /* If we just enabled the profiler, reset call count */ if(profiling_p) { - word->counter = tag_fixnum(0); - if(!word->profiling) { REGISTER_UNTAGGED(word); @@ -71,6 +69,8 @@ void set_profiling(bool profiling) for(i = 0; i < length; i++) { F_WORD *word = untag_word(array_nth(untag_array(words),i)); + if(profiling) + word->counter = tag_fixnum(0); update_word_xt(word); }