moved callstack.hpp inline functions to vm.hpp

db4
Phil Dawes 2009-08-17 21:37:12 +01:00
parent 9e23e41267
commit fb9f9ac3d3
5 changed files with 25 additions and 23 deletions

View File

@ -33,24 +33,5 @@ template<typename T> 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<typename T> void factorvm::iterate_callstack_object(callstack *stack_, T &iterator)
{
gc_root<callstack> 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<typename T> void iterate_callstack_object(callstack *stack_, T &iterator)
{
return vm->iterate_callstack_object(stack_,iterator);
}
}

View File

@ -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);

View File

@ -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();

View File

@ -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"

View File

@ -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<typename T> void factorvm::iterate_callstack_object(callstack *stack_, T &iterator)
{
gc_root<callstack> 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<typename T> void iterate_callstack_object(callstack *stack_, T &iterator)
{
return vm->iterate_callstack_object(stack_,iterator);
}
// next method here: