]> gitweb.factorcode.org Git - factor.git/blob - vm/entry_points.cpp
vm: strip out call-counting profiler
[factor.git] / vm / entry_points.cpp
1 #include "master.hpp"
2
3 namespace factor
4 {
5
6 void factor_vm::c_to_factor(cell quot)
7 {
8         /* First time this is called, wrap the c-to-factor sub-primitive inside
9         of a callback stub, which saves and restores non-volatile registers
10         per platform ABI conventions, so that the Factor compiler can treat
11         all registers as volatile */
12         if(!c_to_factor_func)
13         {
14                 tagged<word> c_to_factor_word(special_objects[C_TO_FACTOR_WORD]);
15                 code_block *c_to_factor_block = callbacks->add(c_to_factor_word.value(),0);
16                 void* func = c_to_factor_block->entry_point();
17                 CODE_TO_FUNCTION_POINTER_CALLBACK(this, func);
18                 c_to_factor_func = (c_to_factor_func_type)func;
19         }
20         c_to_factor_func(quot);
21 }
22
23 template<typename Func> Func factor_vm::get_entry_point(cell n)
24 {
25         tagged<word> entry_point_word(special_objects[n]);
26         return (Func)entry_point_word->entry_point;
27 }
28
29 void factor_vm::unwind_native_frames(cell quot, stack_frame *to)
30 {
31         tagged<word> entry_point_word(special_objects[UNWIND_NATIVE_FRAMES_WORD]);
32         void *func = entry_point_word->entry_point;
33         CODE_TO_FUNCTION_POINTER(func);
34         ((unwind_native_frames_func_type)func)(quot,to);
35 }
36
37 cell factor_vm::get_fpu_state()
38 {
39         tagged<word> entry_point_word(special_objects[GET_FPU_STATE_WORD]);
40         void *func = entry_point_word->entry_point;
41         CODE_TO_FUNCTION_POINTER(func);
42         return ((get_fpu_state_func_type)func)();
43 }
44
45 void factor_vm::set_fpu_state(cell state)
46 {
47         tagged<word> entry_point_word(special_objects[SET_FPU_STATE_WORD]);
48         void *func = entry_point_word->entry_point;
49         CODE_TO_FUNCTION_POINTER(func);
50         ((set_fpu_state_func_type)func)(state);
51 }
52
53 }