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

db4
Slava Pestov 2008-11-11 23:07:40 -06:00
parent de02724135
commit cdb94e4c62
3 changed files with 10 additions and 3 deletions

View File

@ -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

View File

@ -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)

View File

@ -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));
}