diff --git a/extra/tools/profiler/profiler-tests.factor b/extra/tools/profiler/profiler-tests.factor old mode 100644 new mode 100755 index e76e5759b9..c346d9763c --- a/extra/tools/profiler/profiler-tests.factor +++ b/extra/tools/profiler/profiler-tests.factor @@ -1,6 +1,12 @@ IN: temporary USING: tools.profiler tools.test kernel memory math threads -alien tools.profiler.private ; +alien tools.profiler.private sequences ; + +[ t ] [ + \ length profile-counter + 10 [ { } length drop ] times + \ length profile-counter = +] unit-test [ ] [ [ 10 [ data-gc ] times ] profile ] unit-test @@ -26,3 +32,13 @@ alien tools.profiler.private ; ] profile [ 1 ] [ \ foobar profile-counter ] unit-test + +: fooblah { } [ ] each ; + +: foobaz fooblah fooblah ; + +[ foobaz ] profile + +[ 1 ] [ \ foobaz profile-counter ] unit-test + +[ 2 ] [ \ fooblah profile-counter ] unit-test diff --git a/vm/code_heap.c b/vm/code_heap.c index a472431879..ffa5839ab2 100755 --- a/vm/code_heap.c +++ b/vm/code_heap.c @@ -36,7 +36,7 @@ void *get_rel_symbol(F_REL *rel, CELL literals_start) return undefined_symbol; } -static CELL xt_offset; +bool profiling_p_; /* Compute an address to store at a relocation */ INLINE CELL compute_code_rel(F_REL *rel, @@ -56,10 +56,9 @@ INLINE CELL compute_code_rel(F_REL *rel, return CREF(words_start,REL_ARGUMENT(rel)); case RT_XT: word = untag_word(get(CREF(words_start,REL_ARGUMENT(rel)))); - if(word->compiledp == F) - return (CELL)word->code + sizeof(F_COMPILED); - else - return (CELL)word->code + sizeof(F_COMPILED) + xt_offset; + return (CELL)word->code + + sizeof(F_COMPILED) + + (profiling_p_ ? 0 : word->code->profiler_prologue); case RT_XT_PROFILING: word = untag_word(get(CREF(words_start,REL_ARGUMENT(rel)))); return (CELL)word->code + sizeof(F_COMPILED); @@ -140,7 +139,7 @@ void relocate_code_block(F_COMPILED *relocating, CELL code_start, { if(reloc_start != literals_start) { - xt_offset = (profiling_p() ? 0 : relocating->profiler_prologue); + profiling_p_ = profiling_p(); F_REL *rel = (F_REL *)reloc_start; F_REL *rel_end = (F_REL *)literals_start; diff --git a/vm/profiler.c b/vm/profiler.c index 79b271dc44..c42c6925a9 100755 --- a/vm/profiler.c +++ b/vm/profiler.c @@ -8,13 +8,13 @@ bool profiling_p(void) void profiling_word(F_WORD *word) { /* If we just enabled the profiler, reset call count */ - // if(profiling_p()) - // word->counter = tag_fixnum(0); - // - // if(word->compiledp == F) - // default_word_xt(word); - // else - // set_word_xt(word,word->code); + if(profiling_p()) + word->counter = tag_fixnum(0); + + if(word->compiledp == F) + default_word_xt(word); + else + set_word_xt(word,word->code); } void set_profiling(bool profiling)