From cdb94e4c623d5e56ea8a124d50adcc46e167d811 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 11 Nov 2008 23:07:40 -0600 Subject: [PATCH] Word constructor was not invoking relocation on the profiled block, so words constructed while profiling was on could not be executed. This prevented profiling of PEGs --- basis/tools/profiler/profiler-tests.factor | 7 ++++++- vm/profiler.c | 1 - vm/types.c | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/basis/tools/profiler/profiler-tests.factor b/basis/tools/profiler/profiler-tests.factor index 75ca5ede8c..f0c71aa311 100644 --- a/basis/tools/profiler/profiler-tests.factor +++ b/basis/tools/profiler/profiler-tests.factor @@ -1,6 +1,7 @@ IN: tools.profiler.tests USING: accessors tools.profiler tools.test kernel memory math -threads alien tools.profiler.private sequences compiler.units ; +threads alien tools.profiler.private sequences compiler.units +words ; [ t ] [ \ length counter>> @@ -54,3 +55,7 @@ threads alien tools.profiler.private sequences compiler.units ; ] unit-test [ 666 ] [ \ recompile-while-profiling-test counter>> ] unit-test + +[ ] [ [ [ ] compile-call ] profile ] unit-test + +[ [ gensym execute ] profile ] [ T{ undefined } = ] must-fail-with diff --git a/vm/profiler.c b/vm/profiler.c index 27e903178b..250e5a996a 100755 --- a/vm/profiler.c +++ b/vm/profiler.c @@ -32,7 +32,6 @@ F_COMPILED *compile_profiling_stub(F_WORD *word) /* Allocates memory */ void update_word_xt(F_WORD *word) { - /* If we just enabled the profiler, reset call count */ if(profiling_p) { if(!word->profiling) diff --git a/vm/types.c b/vm/types.c index 5e2ed4bed9..38fe3460e7 100755 --- a/vm/types.c +++ b/vm/types.c @@ -61,6 +61,9 @@ F_WORD *allot_word(CELL vocab, CELL name) update_word_xt(word); UNREGISTER_UNTAGGED(word); + if(profiling_p) + iterate_code_heap_step(word->profiling,relocate_code_block); + return word; } @@ -76,7 +79,7 @@ DEFINE_PRIMITIVE(word) DEFINE_PRIMITIVE(word_xt) { F_WORD *word = untag_word(dpop()); - F_COMPILED *code = word->code; + F_COMPILED *code = (profiling_p ? word->profiling : word->code); dpush(allot_cell((CELL)code + sizeof(F_COMPILED))); dpush(allot_cell((CELL)code + sizeof(F_COMPILED) + code->code_length)); }