From fb9f9ac3d35acb073e8e1b818df589654109de27 Mon Sep 17 00:00:00 2001 From: Phil Dawes Date: Mon, 17 Aug 2009 21:37:12 +0100 Subject: [PATCH] moved callstack.hpp inline functions to vm.hpp --- vm/callstack.hpp | 19 ------------------- vm/code_gc.hpp | 2 +- vm/code_heap.hpp | 2 ++ vm/master.hpp | 2 +- vm/vm.hpp | 23 +++++++++++++++++++++-- 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/vm/callstack.hpp b/vm/callstack.hpp index 7e7e5cc20b..ee097b528c 100755 --- a/vm/callstack.hpp +++ b/vm/callstack.hpp @@ -33,24 +33,5 @@ template void iterate_callstack(cell top, cell bottom, T &iterator) } } -/* This is a little tricky. The iterator may allocate memory, so we -keep the callstack in a GC root and use relative offsets */ -template void factorvm::iterate_callstack_object(callstack *stack_, T &iterator) -{ - gc_root stack(stack_,vm); - fixnum frame_offset = untag_fixnum(stack->length) - sizeof(stack_frame); - - while(frame_offset >= 0) - { - stack_frame *frame = stack->frame_at(frame_offset); - frame_offset -= frame->size; - iterator(frame); - } -} - -template void iterate_callstack_object(callstack *stack_, T &iterator) -{ - return vm->iterate_callstack_object(stack_,iterator); -} } diff --git a/vm/code_gc.hpp b/vm/code_gc.hpp index ed59cc5919..1cfafb69c2 100755 --- a/vm/code_gc.hpp +++ b/vm/code_gc.hpp @@ -14,7 +14,7 @@ struct heap { heap_free_list free; }; -//typedef void (*heap_iterator)(heap_block *compiled); +typedef void (*heap_iterator)(heap_block *compiled); void new_heap(heap *h, cell size); void build_free_list(heap *h, cell size); diff --git a/vm/code_heap.hpp b/vm/code_heap.hpp index 20d2b974d3..6f139a4728 100755 --- a/vm/code_heap.hpp +++ b/vm/code_heap.hpp @@ -10,6 +10,8 @@ bool in_code_heap_p(cell ptr); void jit_compile_word(cell word, cell def, bool relocate); +typedef void (*code_heap_iterator)(code_block *compiled); + void iterate_code_heap(code_heap_iterator iter); void copy_code_heap_roots(); diff --git a/vm/master.hpp b/vm/master.hpp index 4adc163123..792e997f6f 100755 --- a/vm/master.hpp +++ b/vm/master.hpp @@ -60,13 +60,13 @@ #include "tuples.hpp" #include "words.hpp" #include "math.hpp" -#include "vm.hpp" #include "float_bits.hpp" #include "io.hpp" #include "code_gc.hpp" #include "code_heap.hpp" #include "image.hpp" #include "callstack.hpp" +#include "vm.hpp" #include "alien.hpp" #include "jit.hpp" #include "quotations.hpp" diff --git a/vm/vm.hpp b/vm/vm.hpp index fdfa48d1e7..1caa30040b 100644 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -11,8 +11,6 @@ struct image_header; typedef u8 card; typedef u8 card_deck; -typedef void (*heap_iterator)(heap_block *compiled); -typedef void (*code_heap_iterator)(code_block *compiled); struct factorvm { @@ -1001,6 +999,27 @@ inline double bignum_to_float(cell tagged) return vm->bignum_to_float(tagged); } +//callstack.hpp +/* This is a little tricky. The iterator may allocate memory, so we +keep the callstack in a GC root and use relative offsets */ +template void factorvm::iterate_callstack_object(callstack *stack_, T &iterator) +{ + gc_root stack(stack_,vm); + fixnum frame_offset = untag_fixnum(stack->length) - sizeof(stack_frame); + + while(frame_offset >= 0) + { + stack_frame *frame = stack->frame_at(frame_offset); + frame_offset -= frame->size; + iterator(frame); + } +} + +template void iterate_callstack_object(callstack *stack_, T &iterator) +{ + return vm->iterate_callstack_object(stack_,iterator); +} + // next method here: