6 void factor_vm::init_profiler()
8 counting_profiler_p = false;
11 /* Allocates memory */
12 code_block *factor_vm::compile_profiling_stub(cell word_)
14 data_root<word> word(word_,this);
16 jit jit(code_block_profiling,word.value(),this);
17 jit.emit_with_literal(special_objects[JIT_PROFILING],word.value());
19 return jit.to_code_block();
22 /* Allocates memory */
23 void factor_vm::set_profiling(bool profiling)
25 if(profiling == counting_profiler_p)
28 /* Push everything to tenured space so that we can heap scan
29 and allocate profiling blocks if necessary */
32 data_root<array> words(find_all_words(),this);
34 counting_profiler_p = profiling;
36 cell length = array_capacity(words.untagged());
37 for(cell i = 0; i < length; i++)
39 tagged<word> word(array_nth(words.untagged(),i));
41 /* Note: can't do w->profiling = ... since LHS evaluates
42 before RHS, and if RHS does a GC, we will have an
43 invalid pointer on the LHS */
48 code_block *profiling_block = compile_profiling_stub(word.value());
49 word->profiling = profiling_block;
52 word->counter = tag_fixnum(0);
55 update_word_entry_point(word.untagged());
58 update_code_heap_words(false);
61 void factor_vm::primitive_profiling()
63 set_profiling(to_boolean(ctx->pop()));