vm/object_start_map.o \
vm/objects.o \
vm/primitives.o \
- vm/profiler.o \
+ vm/counting_profiler.o \
vm/quotations.o \
vm/run.o \
vm/strings.o \
vm/to_tenured_collector.o \
vm/tuples.o \
vm/utilities.o \
- vm/vm.o \
+ vm/vm.o \
vm/words.o
EXE_OBJS = $(PLAF_EXE_OBJS)
vm\object_start_map.obj \
vm\objects.obj \
vm\primitives.obj \
- vm\profiler.obj \
+ vm\counting_profiler.obj \
vm\quotations.obj \
vm\run.obj \
vm\strings.obj \
word *w = (word *)obj;
if(w->code)
w->code = visit_code_block(w->code);
- if(w->profiling)
- w->profiling = visit_code_block(w->profiling);
+ if(w->counting_profiler)
+ w->counting_profiler = visit_code_block(w->counting_profiler);
parent->update_word_entry_point(w);
break;
--- /dev/null
+#include "master.hpp"
+
+namespace factor
+{
+
+void factor_vm::init_counting_profiler()
+{
+ counting_profiler_p = false;
+}
+
+/* Allocates memory */
+code_block *factor_vm::compile_counting_profiler_stub(cell word_)
+{
+ data_root<word> word(word_,this);
+
+ jit jit(code_block_counting_profiler,word.value(),this);
+ jit.emit_with_literal(special_objects[JIT_PROFILING],word.value());
+
+ return jit.to_code_block();
+}
+
+/* Allocates memory */
+void factor_vm::set_counting_profiler(bool counting_profiler)
+{
+ if(counting_profiler == counting_profiler_p)
+ return;
+
+ /* Push everything to tenured space so that we can heap scan
+ and allocate counting_profiler blocks if necessary */
+ primitive_full_gc();
+
+ data_root<array> words(find_all_words(),this);
+
+ counting_profiler_p = counting_profiler;
+
+ cell length = array_capacity(words.untagged());
+ for(cell i = 0; i < length; i++)
+ {
+ tagged<word> word(array_nth(words.untagged(),i));
+
+ /* Note: can't do w->counting_profiler = ... since LHS evaluates
+ before RHS, and if RHS does a GC, we will have an
+ invalid pointer on the LHS */
+ if(counting_profiler)
+ {
+ if(!word->counting_profiler)
+ {
+ code_block *counting_profiler_block = compile_counting_profiler_stub(word.value());
+ word->counting_profiler = counting_profiler_block;
+ }
+
+ word->counter = tag_fixnum(0);
+ }
+
+ update_word_entry_point(word.untagged());
+ }
+
+ update_code_heap_words(false);
+}
+
+void factor_vm::primitive_counting_profiler()
+{
+ set_counting_profiler(to_boolean(ctx->pop()));
+}
+
+}
--- /dev/null
+namespace factor
+{
+
+}
template<typename Func> Func factor_vm::get_entry_point(cell n)
{
/* We return word->code->entry_point() and not word->entry_point,
- because if profiling is enabled, we don't want to go through the
- entry point's profiling stub. This clobbers registers, since entry
+ because if counting_profiler is enabled, we don't want to go through the
+ entry point's counting_profiler stub. This clobbers registers, since entry
points use the C ABI and not the Factor ABI. */
tagged<word> entry_point_word(special_objects[n]);
return (Func)entry_point_word->code->entry_point();
if(p->console)
open_console();
- init_profiler();
+ init_counting_profiler();
special_objects[OBJ_CPU] = allot_alien(false_object,(cell)FACTOR_CPU_STRING);
special_objects[OBJ_OS] = allot_alien(false_object,(cell)FACTOR_OS_STRING);
{
/* Simple code generator used by:
-- profiler (profiler.cpp),
+- counting_profiler (counting_profiler.cpp),
- quotation compiler (quotations.cpp),
- megamorphic caches (dispatch.cpp),
- polymorphic inline caches (inline_cache.cpp) */
{
code_block_unoptimized,
code_block_optimized,
- code_block_profiling,
+ code_block_counting_profiler,
code_block_pic
};
cell pic_def;
/* TAGGED alternative entry point for direct tail calls. Used for inline caching */
cell pic_tail_def;
- /* TAGGED call count for profiling */
+ /* TAGGED call count for counting_profiler */
cell counter;
/* TAGGED machine code for sub-primitive */
cell subprimitive;
void *entry_point;
/* UNTAGGED compiled code block */
code_block *code;
- /* UNTAGGED profiler stub */
- code_block *profiling;
+ /* UNTAGGED counting_profiler stub */
+ code_block *counting_profiler;
};
/* Assembly code makes assumptions about the layout of this struct */
#include "contexts.hpp"
#include "run.hpp"
#include "objects.hpp"
-#include "profiler.hpp"
+#include "counting_profiler.hpp"
#include "errors.hpp"
#include "bignumint.hpp"
#include "bignum.hpp"
_(modify_code_heap) \
_(nano_count) \
_(optimized_p) \
- _(profiling) \
+ _(counting_profiler) \
_(quot_compiled_p) \
_(quotation_code) \
_(reset_dispatch_stats) \
+++ /dev/null
-#include "master.hpp"
-
-namespace factor
-{
-
-void factor_vm::init_profiler()
-{
- counting_profiler_p = false;
-}
-
-/* Allocates memory */
-code_block *factor_vm::compile_profiling_stub(cell word_)
-{
- data_root<word> word(word_,this);
-
- jit jit(code_block_profiling,word.value(),this);
- jit.emit_with_literal(special_objects[JIT_PROFILING],word.value());
-
- return jit.to_code_block();
-}
-
-/* Allocates memory */
-void factor_vm::set_profiling(bool profiling)
-{
- if(profiling == counting_profiler_p)
- return;
-
- /* Push everything to tenured space so that we can heap scan
- and allocate profiling blocks if necessary */
- primitive_full_gc();
-
- data_root<array> words(find_all_words(),this);
-
- counting_profiler_p = profiling;
-
- cell length = array_capacity(words.untagged());
- for(cell i = 0; i < length; i++)
- {
- tagged<word> word(array_nth(words.untagged(),i));
-
- /* Note: can't do w->profiling = ... since LHS evaluates
- before RHS, and if RHS does a GC, we will have an
- invalid pointer on the LHS */
- if(profiling)
- {
- if(!word->profiling)
- {
- code_block *profiling_block = compile_profiling_stub(word.value());
- word->profiling = profiling_block;
- }
-
- word->counter = tag_fixnum(0);
- }
-
- update_word_entry_point(word.untagged());
- }
-
- update_code_heap_words(false);
-}
-
-void factor_vm::primitive_profiling()
-{
- set_profiling(to_boolean(ctx->pop()));
-}
-
-}
+++ /dev/null
-namespace factor
-{
-
-}
void primitive_clone();
void primitive_become();
- // profiler
- void init_profiler();
- code_block *compile_profiling_stub(cell word_);
- void set_profiling(bool profiling);
- void primitive_profiling();
+ // counting_profiler
+ void init_counting_profiler();
+ code_block *compile_counting_profiler_stub(cell word_);
+ void set_counting_profiler(bool counting_profiler);
+ void primitive_counting_profiler();
// errors
void general_error(vm_error_type error, cell arg1, cell arg2);
new_word->pic_def = false_object;
new_word->pic_tail_def = false_object;
new_word->subprimitive = false_object;
- new_word->profiling = NULL;
+ new_word->counting_profiler = NULL;
new_word->code = NULL;
jit_compile_word(new_word.value(),new_word->def,true);
if(counting_profiler_p)
{
- code_block *profiling_block = compile_profiling_stub(new_word.value());
- new_word->profiling = profiling_block;
- initialize_code_block(new_word->profiling);
+ code_block *counting_profiler_block = compile_counting_profiler_stub(new_word.value());
+ new_word->counting_profiler = counting_profiler_block;
+ initialize_code_block(new_word->counting_profiler);
}
update_word_entry_point(new_word.untagged());
if(counting_profiler_p)
{
- ctx->push(from_unsigned_cell((cell)w->profiling->entry_point()));
- ctx->push(from_unsigned_cell((cell)w->profiling + w->profiling->size()));
+ ctx->push(from_unsigned_cell((cell)w->counting_profiler->entry_point()));
+ ctx->push(from_unsigned_cell((cell)w->counting_profiler + w->counting_profiler->size()));
}
else
{
void factor_vm::update_word_entry_point(word *w)
{
- if(counting_profiler_p && w->profiling)
- w->entry_point = w->profiling->entry_point();
+ if(counting_profiler_p && w->counting_profiler)
+ w->entry_point = w->counting_profiler->entry_point();
else
w->entry_point = w->code->entry_point();
}