From d6bc190f5196b983e2344de0ecab11bbf65aa528 Mon Sep 17 00:00:00 2001 From: Erik Charlebois Date: Sat, 11 May 2013 21:58:23 -0400 Subject: [PATCH] VM: Refactor entry_points to Factor style --- vm/entry_points.cpp | 71 ++++++++++++++++++++------------------------- vm/entry_points.hpp | 11 ++++--- 2 files changed, 37 insertions(+), 45 deletions(-) diff --git a/vm/entry_points.cpp b/vm/entry_points.cpp index a3cbcd1317..d4051025f4 100644 --- a/vm/entry_points.cpp +++ b/vm/entry_points.cpp @@ -1,53 +1,46 @@ #include "master.hpp" -namespace factor -{ +namespace factor { -void factor_vm::c_to_factor(cell quot) -{ - /* First time this is called, wrap the c-to-factor sub-primitive inside - of a callback stub, which saves and restores non-volatile registers - per platform ABI conventions, so that the Factor compiler can treat - all registers as volatile */ - if(!c_to_factor_func) - { - tagged c_to_factor_word(special_objects[C_TO_FACTOR_WORD]); - code_block *c_to_factor_block = callbacks->add(c_to_factor_word.value(),0); - void* func = c_to_factor_block->entry_point(); - CODE_TO_FUNCTION_POINTER_CALLBACK(this, func); - c_to_factor_func = (c_to_factor_func_type)func; - } - c_to_factor_func(quot); +void factor_vm::c_to_factor(cell quot) { + /* First time this is called, wrap the c-to-factor sub-primitive inside + of a callback stub, which saves and restores non-volatile registers + per platform ABI conventions, so that the Factor compiler can treat + all registers as volatile */ + if (!c_to_factor_func) { + tagged c_to_factor_word(special_objects[C_TO_FACTOR_WORD]); + code_block* c_to_factor_block = callbacks->add(c_to_factor_word.value(), 0); + void* func = c_to_factor_block->entry_point(); + CODE_TO_FUNCTION_POINTER_CALLBACK(this, func); + c_to_factor_func = (c_to_factor_func_type) func; + } + c_to_factor_func(quot); } -template Func factor_vm::get_entry_point(cell n) -{ - tagged entry_point_word(special_objects[n]); - return (Func)entry_point_word->entry_point; +template Func factor_vm::get_entry_point(cell n) { + tagged entry_point_word(special_objects[n]); + return (Func) entry_point_word->entry_point; } -void factor_vm::unwind_native_frames(cell quot, void *to) -{ - tagged entry_point_word(special_objects[UNWIND_NATIVE_FRAMES_WORD]); - void *func = entry_point_word->entry_point; - CODE_TO_FUNCTION_POINTER(func); - ((unwind_native_frames_func_type)func)(quot,to); +void factor_vm::unwind_native_frames(cell quot, void* to) { + tagged entry_point_word(special_objects[UNWIND_NATIVE_FRAMES_WORD]); + void* func = entry_point_word->entry_point; + CODE_TO_FUNCTION_POINTER(func); + ((unwind_native_frames_func_type) func)(quot, to); } -cell factor_vm::get_fpu_state() -{ - tagged entry_point_word(special_objects[GET_FPU_STATE_WORD]); - void *func = entry_point_word->entry_point; - CODE_TO_FUNCTION_POINTER(func); - return ((get_fpu_state_func_type)func)(); +cell factor_vm::get_fpu_state() { + tagged entry_point_word(special_objects[GET_FPU_STATE_WORD]); + void* func = entry_point_word->entry_point; + CODE_TO_FUNCTION_POINTER(func); + return ((get_fpu_state_func_type) func)(); } -void factor_vm::set_fpu_state(cell state) -{ - tagged entry_point_word(special_objects[SET_FPU_STATE_WORD]); - void *func = entry_point_word->entry_point; - CODE_TO_FUNCTION_POINTER(func); - ((set_fpu_state_func_type)func)(state); +void factor_vm::set_fpu_state(cell state) { + tagged entry_point_word(special_objects[SET_FPU_STATE_WORD]); + void* func = entry_point_word->entry_point; + CODE_TO_FUNCTION_POINTER(func); + ((set_fpu_state_func_type) func)(state); } } diff --git a/vm/entry_points.hpp b/vm/entry_points.hpp index fc3ae2e400..12501493c7 100644 --- a/vm/entry_points.hpp +++ b/vm/entry_points.hpp @@ -1,9 +1,8 @@ -namespace factor -{ +namespace factor { -typedef void (* c_to_factor_func_type)(cell quot); -typedef void (* unwind_native_frames_func_type)(cell quot, void *to); -typedef cell (* get_fpu_state_func_type)(); -typedef void (* set_fpu_state_func_type)(cell state); +typedef void (*c_to_factor_func_type)(cell quot); +typedef void (*unwind_native_frames_func_type)(cell quot, void* to); +typedef cell (*get_fpu_state_func_type)(); +typedef void (*set_fpu_state_func_type)(cell state); } -- 2.34.1