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