moved profiling fns into vm

db4
Phil Dawes 2009-08-17 21:37:04 +01:00
parent 110f925245
commit aa01f6b748
2 changed files with 30 additions and 4 deletions

28
vm/profiler.cpp Normal file → Executable file
View File

@ -5,13 +5,18 @@ namespace factor
bool profiling_p; bool profiling_p;
void init_profiler() void factorvm::init_profiler()
{ {
profiling_p = false; profiling_p = false;
} }
void init_profiler()
{
return vm->init_profiler();
}
/* Allocates memory */ /* Allocates memory */
code_block *compile_profiling_stub(cell word_) code_block *factorvm::compile_profiling_stub(cell word_)
{ {
gc_root<word> word(word_); gc_root<word> word(word_);
@ -21,8 +26,13 @@ code_block *compile_profiling_stub(cell word_)
return jit.to_code_block(); return jit.to_code_block();
} }
code_block *compile_profiling_stub(cell word_)
{
return vm->compile_profiling_stub(word_);
}
/* Allocates memory */ /* Allocates memory */
static void set_profiling(bool profiling) void factorvm::set_profiling(bool profiling)
{ {
if(profiling == profiling_p) if(profiling == profiling_p)
return; return;
@ -49,9 +59,19 @@ static void set_profiling(bool profiling)
iterate_code_heap(relocate_code_block); iterate_code_heap(relocate_code_block);
} }
PRIMITIVE(profiling) void set_profiling(bool profiling)
{
return vm->set_profiling(profiling);
}
inline void factorvm::vmprim_profiling()
{ {
set_profiling(to_boolean(dpop())); set_profiling(to_boolean(dpop()));
} }
PRIMITIVE(profiling)
{
PRIMITIVE_GETVM()->vmprim_profiling();
}
} }

View File

@ -31,6 +31,12 @@ struct factorvm {
inline void vmprim_load_locals(); inline void vmprim_load_locals();
cell clone_object(cell obj_); cell clone_object(cell obj_);
inline void vmprim_clone(); inline void vmprim_clone();
// profiler
void init_profiler();
code_block *compile_profiling_stub(cell word_);
void set_profiling(bool profiling);
inline void vmprim_profiling();
// next method here: // next method here:
}; };