VM: Refactor vm.cpp/hpp to Factor style
parent
8522265169
commit
5614985c3d
25
vm/vm.cpp
25
vm/vm.cpp
|
@ -1,10 +1,9 @@
|
||||||
#include "master.hpp"
|
#include "master.hpp"
|
||||||
|
|
||||||
namespace factor
|
namespace factor {
|
||||||
{
|
|
||||||
|
|
||||||
factor_vm::factor_vm(THREADHANDLE thread) :
|
factor_vm::factor_vm(THREADHANDLE thread)
|
||||||
nursery(0,0),
|
: nursery(0, 0),
|
||||||
faulting_p(false),
|
faulting_p(false),
|
||||||
thread(thread),
|
thread(thread),
|
||||||
callback_id(0),
|
callback_id(0),
|
||||||
|
@ -23,24 +22,20 @@ factor_vm::factor_vm(THREADHANDLE thread) :
|
||||||
full_output(false),
|
full_output(false),
|
||||||
last_nano_count(0),
|
last_nano_count(0),
|
||||||
signal_callstack_seg(NULL),
|
signal_callstack_seg(NULL),
|
||||||
safepoint()
|
safepoint() {
|
||||||
{
|
|
||||||
primitive_reset_dispatch_stats();
|
primitive_reset_dispatch_stats();
|
||||||
}
|
}
|
||||||
|
|
||||||
factor_vm::~factor_vm()
|
factor_vm::~factor_vm() {
|
||||||
{
|
|
||||||
delete_contexts();
|
delete_contexts();
|
||||||
if(signal_callstack_seg)
|
if (signal_callstack_seg) {
|
||||||
{
|
|
||||||
delete signal_callstack_seg;
|
delete signal_callstack_seg;
|
||||||
signal_callstack_seg = NULL;
|
signal_callstack_seg = NULL;
|
||||||
}
|
}
|
||||||
std::list<void **>::const_iterator iter = function_descriptors.begin();
|
std::list<void**>::const_iterator iter = function_descriptors.begin();
|
||||||
std::list<void **>::const_iterator end = function_descriptors.end();
|
std::list<void**>::const_iterator end = function_descriptors.end();
|
||||||
while(iter != end)
|
while (iter != end) {
|
||||||
{
|
delete[] * iter;
|
||||||
delete [] *iter;
|
|
||||||
iter++;
|
iter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
519
vm/vm.hpp
519
vm/vm.hpp
|
@ -1,11 +1,9 @@
|
||||||
namespace factor
|
namespace factor {
|
||||||
{
|
|
||||||
|
|
||||||
struct growable_array;
|
struct growable_array;
|
||||||
struct code_root;
|
struct code_root;
|
||||||
|
|
||||||
struct factor_vm
|
struct factor_vm {
|
||||||
{
|
|
||||||
//
|
//
|
||||||
// vvvvvv
|
// vvvvvv
|
||||||
// THESE FIELDS ARE ACCESSED DIRECTLY FROM FACTOR. See:
|
// THESE FIELDS ARE ACCESSED DIRECTLY FROM FACTOR. See:
|
||||||
|
@ -13,10 +11,10 @@ struct factor_vm
|
||||||
// basis/compiler/constants/constants.factor
|
// basis/compiler/constants/constants.factor
|
||||||
|
|
||||||
/* Current context */
|
/* Current context */
|
||||||
context *ctx;
|
context* ctx;
|
||||||
|
|
||||||
/* Spare context -- for callbacks */
|
/* Spare context -- for callbacks */
|
||||||
context *spare_ctx;
|
context* spare_ctx;
|
||||||
|
|
||||||
/* New objects are allocated here */
|
/* New objects are allocated here */
|
||||||
nursery_space nursery;
|
nursery_space nursery;
|
||||||
|
@ -52,13 +50,13 @@ struct factor_vm
|
||||||
int callback_id;
|
int callback_id;
|
||||||
|
|
||||||
/* List of callback function descriptors for PPC */
|
/* List of callback function descriptors for PPC */
|
||||||
std::list<void **> function_descriptors;
|
std::list<void**> function_descriptors;
|
||||||
|
|
||||||
/* Pooling unused contexts to make context allocation cheaper */
|
/* Pooling unused contexts to make context allocation cheaper */
|
||||||
std::list<context *> unused_contexts;
|
std::list<context*> unused_contexts;
|
||||||
|
|
||||||
/* Active contexts, for tracing by the GC */
|
/* Active contexts, for tracing by the GC */
|
||||||
std::set<context *> active_contexts;
|
std::set<context*> active_contexts;
|
||||||
|
|
||||||
/* Canonical truth value. In Factor, 't' */
|
/* Canonical truth value. In Factor, 't' */
|
||||||
cell true_object;
|
cell true_object;
|
||||||
|
@ -89,16 +87,16 @@ struct factor_vm
|
||||||
bool gc_off;
|
bool gc_off;
|
||||||
|
|
||||||
/* Data heap */
|
/* Data heap */
|
||||||
data_heap *data;
|
data_heap* data;
|
||||||
|
|
||||||
/* Code heap */
|
/* Code heap */
|
||||||
code_heap *code;
|
code_heap* code;
|
||||||
|
|
||||||
/* Pinned callback stubs */
|
/* Pinned callback stubs */
|
||||||
callback_heap *callbacks;
|
callback_heap* callbacks;
|
||||||
|
|
||||||
/* Only set if we're performing a GC */
|
/* Only set if we're performing a GC */
|
||||||
gc_state *current_gc;
|
gc_state* current_gc;
|
||||||
volatile cell current_gc_p;
|
volatile cell current_gc_p;
|
||||||
|
|
||||||
/* Set if we're in the jit */
|
/* Set if we're in the jit */
|
||||||
|
@ -108,7 +106,7 @@ struct factor_vm
|
||||||
std::vector<cell> mark_stack;
|
std::vector<cell> mark_stack;
|
||||||
|
|
||||||
/* If not NULL, we push GC events here */
|
/* If not NULL, we push GC events here */
|
||||||
std::vector<gc_event> *gc_events;
|
std::vector<gc_event>* gc_events;
|
||||||
|
|
||||||
/* If a runtime function needs to call another function which potentially
|
/* If a runtime function needs to call another function which potentially
|
||||||
allocates memory, it must wrap any references to the data and code
|
allocates memory, it must wrap any references to the data and code
|
||||||
|
@ -116,7 +114,7 @@ struct factor_vm
|
||||||
themselves here. See data_roots.hpp and code_roots.hpp */
|
themselves here. See data_roots.hpp and code_roots.hpp */
|
||||||
std::vector<data_root_range> data_roots;
|
std::vector<data_root_range> data_roots;
|
||||||
std::vector<cell> bignum_roots;
|
std::vector<cell> bignum_roots;
|
||||||
std::vector<code_root *> code_roots;
|
std::vector<code_root*> code_roots;
|
||||||
|
|
||||||
/* Debugger */
|
/* Debugger */
|
||||||
bool fep_p;
|
bool fep_p;
|
||||||
|
@ -138,12 +136,11 @@ struct factor_vm
|
||||||
/* Incrementing object counter for identity hashing */
|
/* Incrementing object counter for identity hashing */
|
||||||
cell object_counter;
|
cell object_counter;
|
||||||
|
|
||||||
/* Sanity check to ensure that monotonic counter doesn't
|
/* Sanity check to ensure that monotonic counter doesn't decrease */
|
||||||
decrease */
|
|
||||||
u64 last_nano_count;
|
u64 last_nano_count;
|
||||||
|
|
||||||
/* Stack for signal handlers, only used on Unix */
|
/* Stack for signal handlers, only used on Unix */
|
||||||
segment *signal_callstack_seg;
|
segment* signal_callstack_seg;
|
||||||
|
|
||||||
/* Are we already handling a fault? Used to catch double memory faults */
|
/* Are we already handling a fault? Used to catch double memory faults */
|
||||||
static bool fatal_erroring_p;
|
static bool fatal_erroring_p;
|
||||||
|
@ -152,10 +149,11 @@ struct factor_vm
|
||||||
volatile safepoint_state safepoint;
|
volatile safepoint_state safepoint;
|
||||||
|
|
||||||
// contexts
|
// contexts
|
||||||
context *new_context();
|
context* new_context();
|
||||||
void init_context(context *ctx);
|
void init_context(context* ctx);
|
||||||
void delete_context(context *old_context);
|
void delete_context(context* old_context);
|
||||||
void init_contexts(cell datastack_size_, cell retainstack_size_, cell callstack_size_);
|
void init_contexts(cell datastack_size_, cell retainstack_size_,
|
||||||
|
cell callstack_size_);
|
||||||
void delete_contexts();
|
void delete_contexts();
|
||||||
cell begin_callback(cell quot);
|
cell begin_callback(cell quot);
|
||||||
void end_callback();
|
void end_callback();
|
||||||
|
@ -164,28 +162,26 @@ struct factor_vm
|
||||||
void primitive_context_object_for();
|
void primitive_context_object_for();
|
||||||
void primitive_set_context_object();
|
void primitive_set_context_object();
|
||||||
cell stack_to_array(cell bottom, cell top);
|
cell stack_to_array(cell bottom, cell top);
|
||||||
cell datastack_to_array(context *ctx);
|
cell datastack_to_array(context* ctx);
|
||||||
void primitive_datastack();
|
void primitive_datastack();
|
||||||
void primitive_datastack_for();
|
void primitive_datastack_for();
|
||||||
cell retainstack_to_array(context *ctx);
|
cell retainstack_to_array(context* ctx);
|
||||||
void primitive_retainstack();
|
void primitive_retainstack();
|
||||||
void primitive_retainstack_for();
|
void primitive_retainstack_for();
|
||||||
cell array_to_stack(array *array, cell bottom);
|
cell array_to_stack(array* array, cell bottom);
|
||||||
void set_datastack(context *ctx, array *array);
|
void set_datastack(context* ctx, array* array);
|
||||||
void primitive_set_datastack();
|
void primitive_set_datastack();
|
||||||
void set_retainstack(context *ctx, array *array);
|
void set_retainstack(context* ctx, array* array);
|
||||||
void primitive_set_retainstack();
|
void primitive_set_retainstack();
|
||||||
void primitive_check_datastack();
|
void primitive_check_datastack();
|
||||||
void primitive_load_locals();
|
void primitive_load_locals();
|
||||||
|
|
||||||
template<typename Iterator, typename Fixup>
|
template <typename Iterator, typename Fixup>
|
||||||
void iterate_active_callstacks(Iterator &iter, Fixup &fixup)
|
void iterate_active_callstacks(Iterator& iter, Fixup& fixup) {
|
||||||
{
|
std::set<context*>::const_iterator begin = active_contexts.begin();
|
||||||
std::set<context *>::const_iterator begin = active_contexts.begin();
|
std::set<context*>::const_iterator end = active_contexts.end();
|
||||||
std::set<context *>::const_iterator end = active_contexts.end();
|
while (begin != end) {
|
||||||
while(begin != end)
|
iterate_callstack(*begin++, iter, fixup);
|
||||||
{
|
|
||||||
iterate_callstack(*begin++,iter,fixup);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +195,7 @@ struct factor_vm
|
||||||
void primitive_special_object();
|
void primitive_special_object();
|
||||||
void primitive_set_special_object();
|
void primitive_set_special_object();
|
||||||
void primitive_identity_hashcode();
|
void primitive_identity_hashcode();
|
||||||
void compute_identity_hashcode(object *obj);
|
void compute_identity_hashcode(object* obj);
|
||||||
void primitive_compute_identity_hashcode();
|
void primitive_compute_identity_hashcode();
|
||||||
cell object_size(cell tagged);
|
cell object_size(cell tagged);
|
||||||
cell clone_object(cell obj_);
|
cell clone_object(cell obj_);
|
||||||
|
@ -209,7 +205,7 @@ struct factor_vm
|
||||||
// sampling_profiler
|
// sampling_profiler
|
||||||
void clear_samples();
|
void clear_samples();
|
||||||
void record_sample(bool prolog_p);
|
void record_sample(bool prolog_p);
|
||||||
void record_callstack_sample(cell *begin, cell *end, bool prolog_p);
|
void record_callstack_sample(cell* begin, cell* end, bool prolog_p);
|
||||||
void start_sampling_profiler(fixnum rate);
|
void start_sampling_profiler(fixnum rate);
|
||||||
void end_sampling_profiler();
|
void end_sampling_profiler();
|
||||||
void set_sampling_profiler(fixnum rate);
|
void set_sampling_profiler(fixnum rate);
|
||||||
|
@ -232,70 +228,84 @@ struct factor_vm
|
||||||
void fp_signal_handler_impl();
|
void fp_signal_handler_impl();
|
||||||
|
|
||||||
// bignum
|
// bignum
|
||||||
int bignum_equal_p(bignum * x, bignum * y);
|
int bignum_equal_p(bignum* x, bignum* y);
|
||||||
enum bignum_comparison bignum_compare(bignum * x, bignum * y);
|
enum bignum_comparison bignum_compare(bignum* x, bignum* y);
|
||||||
bignum *bignum_add(bignum * x, bignum * y);
|
bignum* bignum_add(bignum* x, bignum* y);
|
||||||
bignum *bignum_subtract(bignum * x, bignum * y);
|
bignum* bignum_subtract(bignum* x, bignum* y);
|
||||||
bignum *bignum_multiply(bignum * x, bignum * y);
|
bignum* bignum_multiply(bignum* x, bignum* y);
|
||||||
void bignum_divide(bignum * numerator, bignum * denominator, bignum * * quotient, bignum * * remainder);
|
void bignum_divide(bignum* numerator, bignum* denominator, bignum** quotient,
|
||||||
bignum *bignum_quotient(bignum * numerator, bignum * denominator);
|
bignum** remainder);
|
||||||
bignum *bignum_remainder(bignum * numerator, bignum * denominator);
|
bignum* bignum_quotient(bignum* numerator, bignum* denominator);
|
||||||
cell bignum_to_cell(bignum * bignum);
|
bignum* bignum_remainder(bignum* numerator, bignum* denominator);
|
||||||
fixnum bignum_to_fixnum(bignum * bignum);
|
cell bignum_to_cell(bignum* bignum);
|
||||||
s64 bignum_to_long_long(bignum * bignum);
|
fixnum bignum_to_fixnum(bignum* bignum);
|
||||||
u64 bignum_to_ulong_long(bignum * bignum);
|
s64 bignum_to_long_long(bignum* bignum);
|
||||||
bignum *double_to_bignum(double x);
|
u64 bignum_to_ulong_long(bignum* bignum);
|
||||||
int bignum_equal_p_unsigned(bignum * x, bignum * y);
|
bignum* double_to_bignum(double x);
|
||||||
enum bignum_comparison bignum_compare_unsigned(bignum * x, bignum * y);
|
int bignum_equal_p_unsigned(bignum* x, bignum* y);
|
||||||
bignum *bignum_add_unsigned(bignum * x, bignum * y, int negative_p);
|
enum bignum_comparison bignum_compare_unsigned(bignum* x, bignum* y);
|
||||||
bignum *bignum_subtract_unsigned(bignum * x, bignum * y);
|
bignum* bignum_add_unsigned(bignum* x, bignum* y, int negative_p);
|
||||||
bignum *bignum_multiply_unsigned(bignum * x, bignum * y, int negative_p);
|
bignum* bignum_subtract_unsigned(bignum* x, bignum* y);
|
||||||
bignum *bignum_multiply_unsigned_small_factor(bignum * x, bignum_digit_type y,int negative_p);
|
bignum* bignum_multiply_unsigned(bignum* x, bignum* y, int negative_p);
|
||||||
void bignum_destructive_add(bignum * bignum, bignum_digit_type n);
|
bignum* bignum_multiply_unsigned_small_factor(bignum* x, bignum_digit_type y,
|
||||||
void bignum_destructive_scale_up(bignum * bignum, bignum_digit_type factor);
|
int negative_p);
|
||||||
void bignum_divide_unsigned_large_denominator(bignum * numerator, bignum * denominator,
|
void bignum_destructive_add(bignum* bignum, bignum_digit_type n);
|
||||||
bignum * * quotient, bignum * * remainder, int q_negative_p, int r_negative_p);
|
void bignum_destructive_scale_up(bignum* bignum, bignum_digit_type factor);
|
||||||
void bignum_divide_unsigned_normalized(bignum * u, bignum * v, bignum * q);
|
void bignum_divide_unsigned_large_denominator(
|
||||||
bignum_digit_type bignum_divide_subtract(bignum_digit_type * v_start, bignum_digit_type * v_end,
|
bignum* numerator, bignum* denominator, bignum** quotient,
|
||||||
bignum_digit_type guess, bignum_digit_type * u_start);
|
bignum** remainder, int q_negative_p, int r_negative_p);
|
||||||
void bignum_divide_unsigned_medium_denominator(bignum * numerator,bignum_digit_type denominator,
|
void bignum_divide_unsigned_normalized(bignum* u, bignum* v, bignum* q);
|
||||||
bignum * * quotient, bignum * * remainder,int q_negative_p, int r_negative_p);
|
bignum_digit_type bignum_divide_subtract(bignum_digit_type* v_start,
|
||||||
void bignum_destructive_normalization(bignum * source, bignum * target, int shift_left);
|
bignum_digit_type* v_end,
|
||||||
void bignum_destructive_unnormalization(bignum * bignum, int shift_right);
|
bignum_digit_type guess,
|
||||||
bignum_digit_type bignum_digit_divide(bignum_digit_type uh, bignum_digit_type ul,
|
bignum_digit_type* u_start);
|
||||||
bignum_digit_type v, bignum_digit_type * q) /* return value */;
|
void bignum_divide_unsigned_medium_denominator(
|
||||||
bignum_digit_type bignum_digit_divide_subtract(bignum_digit_type v1, bignum_digit_type v2,
|
bignum* numerator, bignum_digit_type denominator, bignum** quotient,
|
||||||
bignum_digit_type guess, bignum_digit_type * u);
|
bignum** remainder, int q_negative_p, int r_negative_p);
|
||||||
void bignum_divide_unsigned_small_denominator(bignum * numerator, bignum_digit_type denominator,
|
void bignum_destructive_normalization(bignum* source, bignum* target,
|
||||||
bignum * * quotient, bignum * * remainder,int q_negative_p, int r_negative_p);
|
int shift_left);
|
||||||
bignum_digit_type bignum_destructive_scale_down(bignum * bignum, bignum_digit_type denominator);
|
void bignum_destructive_unnormalization(bignum* bignum, int shift_right);
|
||||||
bignum * bignum_remainder_unsigned_small_denominator(bignum * n, bignum_digit_type d, int negative_p);
|
bignum_digit_type bignum_digit_divide(
|
||||||
bignum *bignum_digit_to_bignum(bignum_digit_type digit, int negative_p);
|
bignum_digit_type uh, bignum_digit_type ul, bignum_digit_type v,
|
||||||
bignum *allot_bignum(bignum_length_type length, int negative_p);
|
bignum_digit_type* q) /* return value */;
|
||||||
bignum * allot_bignum_zeroed(bignum_length_type length, int negative_p);
|
bignum_digit_type bignum_digit_divide_subtract(bignum_digit_type v1,
|
||||||
bignum *bignum_shorten_length(bignum * bignum, bignum_length_type length);
|
bignum_digit_type v2,
|
||||||
bignum *bignum_trim(bignum * bignum);
|
bignum_digit_type guess,
|
||||||
bignum *bignum_new_sign(bignum * x, int negative_p);
|
bignum_digit_type* u);
|
||||||
bignum *bignum_maybe_new_sign(bignum * x, int negative_p);
|
void bignum_divide_unsigned_small_denominator(
|
||||||
void bignum_destructive_copy(bignum * source, bignum * target);
|
bignum* numerator, bignum_digit_type denominator, bignum** quotient,
|
||||||
bignum *bignum_bitwise_not(bignum * x);
|
bignum** remainder, int q_negative_p, int r_negative_p);
|
||||||
bignum *bignum_arithmetic_shift(bignum * arg1, fixnum n);
|
bignum_digit_type bignum_destructive_scale_down(
|
||||||
bignum *bignum_bitwise_and(bignum * arg1, bignum * arg2);
|
bignum* bignum, bignum_digit_type denominator);
|
||||||
bignum *bignum_bitwise_ior(bignum * arg1, bignum * arg2);
|
bignum* bignum_remainder_unsigned_small_denominator(bignum* n,
|
||||||
bignum *bignum_bitwise_xor(bignum * arg1, bignum * arg2);
|
bignum_digit_type d,
|
||||||
bignum *bignum_magnitude_ash(bignum * arg1, fixnum n);
|
int negative_p);
|
||||||
bignum *bignum_pospos_bitwise_op(int op, bignum * arg1, bignum * arg2);
|
bignum* bignum_digit_to_bignum(bignum_digit_type digit, int negative_p);
|
||||||
bignum *bignum_posneg_bitwise_op(int op, bignum * arg1, bignum * arg2);
|
bignum* allot_bignum(bignum_length_type length, int negative_p);
|
||||||
bignum *bignum_negneg_bitwise_op(int op, bignum * arg1, bignum * arg2);
|
bignum* allot_bignum_zeroed(bignum_length_type length, int negative_p);
|
||||||
void bignum_negate_magnitude(bignum * arg);
|
bignum* bignum_shorten_length(bignum* bignum, bignum_length_type length);
|
||||||
bignum *bignum_integer_length(bignum * x);
|
bignum* bignum_trim(bignum* bignum);
|
||||||
int bignum_logbitp(int shift, bignum * arg);
|
bignum* bignum_new_sign(bignum* x, int negative_p);
|
||||||
int bignum_unsigned_logbitp(int shift, bignum * bignum);
|
bignum* bignum_maybe_new_sign(bignum* x, int negative_p);
|
||||||
bignum *bignum_gcd(bignum * a, bignum * b);
|
void bignum_destructive_copy(bignum* source, bignum* target);
|
||||||
|
bignum* bignum_bitwise_not(bignum* x);
|
||||||
|
bignum* bignum_arithmetic_shift(bignum* arg1, fixnum n);
|
||||||
|
bignum* bignum_bitwise_and(bignum* arg1, bignum* arg2);
|
||||||
|
bignum* bignum_bitwise_ior(bignum* arg1, bignum* arg2);
|
||||||
|
bignum* bignum_bitwise_xor(bignum* arg1, bignum* arg2);
|
||||||
|
bignum* bignum_magnitude_ash(bignum* arg1, fixnum n);
|
||||||
|
bignum* bignum_pospos_bitwise_op(int op, bignum* arg1, bignum* arg2);
|
||||||
|
bignum* bignum_posneg_bitwise_op(int op, bignum* arg1, bignum* arg2);
|
||||||
|
bignum* bignum_negneg_bitwise_op(int op, bignum* arg1, bignum* arg2);
|
||||||
|
void bignum_negate_magnitude(bignum* arg);
|
||||||
|
bignum* bignum_integer_length(bignum* x);
|
||||||
|
int bignum_logbitp(int shift, bignum* arg);
|
||||||
|
int bignum_unsigned_logbitp(int shift, bignum* bignum);
|
||||||
|
bignum* bignum_gcd(bignum* a, bignum* b);
|
||||||
|
|
||||||
//data heap
|
//data heap
|
||||||
void init_card_decks();
|
void init_card_decks();
|
||||||
void set_data_heap(data_heap *data_);
|
void set_data_heap(data_heap* data_);
|
||||||
void init_data_heap(cell young_size, cell aging_size, cell tenured_size);
|
void init_data_heap(cell young_size, cell aging_size, cell tenured_size);
|
||||||
void primitive_size();
|
void primitive_size();
|
||||||
data_heap_room data_room();
|
data_heap_room data_room();
|
||||||
|
@ -305,43 +315,38 @@ struct factor_vm
|
||||||
cell instances(cell type);
|
cell instances(cell type);
|
||||||
void primitive_all_instances();
|
void primitive_all_instances();
|
||||||
|
|
||||||
template<typename Generation, typename Iterator>
|
template <typename Generation, typename Iterator>
|
||||||
inline void each_object(Generation *gen, Iterator &iterator)
|
inline void each_object(Generation* gen, Iterator& iterator) {
|
||||||
{
|
|
||||||
cell obj = gen->first_object();
|
cell obj = gen->first_object();
|
||||||
while(obj)
|
while (obj) {
|
||||||
{
|
iterator((object*)obj);
|
||||||
iterator((object *)obj);
|
|
||||||
obj = gen->next_object_after(obj);
|
obj = gen->next_object_after(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Iterator> inline void each_object(Iterator &iterator)
|
template <typename Iterator> inline void each_object(Iterator& iterator) {
|
||||||
{
|
|
||||||
gc_off = true;
|
gc_off = true;
|
||||||
|
|
||||||
each_object(data->tenured,iterator);
|
each_object(data->tenured, iterator);
|
||||||
each_object(data->aging,iterator);
|
each_object(data->aging, iterator);
|
||||||
each_object(data->nursery,iterator);
|
each_object(data->nursery, iterator);
|
||||||
|
|
||||||
gc_off = false;
|
gc_off = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the write barrier must be called any time we are potentially storing a
|
/* the write barrier must be called any time we are potentially storing a
|
||||||
pointer from an older generation to a younger one */
|
pointer from an older generation to a younger one */
|
||||||
inline void write_barrier(cell *slot_ptr)
|
inline void write_barrier(cell* slot_ptr) {
|
||||||
{
|
*(char*)(cards_offset + ((cell) slot_ptr >> card_bits)) = card_mark_mask;
|
||||||
*(char *)(cards_offset + ((cell)slot_ptr >> card_bits)) = card_mark_mask;
|
*(char*)(decks_offset + ((cell) slot_ptr >> deck_bits)) = card_mark_mask;
|
||||||
*(char *)(decks_offset + ((cell)slot_ptr >> deck_bits)) = card_mark_mask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void write_barrier(object *obj, cell size)
|
inline void write_barrier(object* obj, cell size) {
|
||||||
{
|
cell start = (cell) obj & (~card_size + 1);
|
||||||
cell start = (cell)obj & (~card_size + 1);
|
cell end = ((cell) obj + size + card_size - 1) & (~card_size + 1);
|
||||||
cell end = ((cell)obj + size + card_size - 1) & (~card_size + 1);
|
|
||||||
|
|
||||||
for(cell offset = start; offset < end; offset += card_size)
|
for (cell offset = start; offset < end; offset += card_size)
|
||||||
write_barrier((cell *)offset);
|
write_barrier((cell*)offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
// data heap checker
|
// data heap checker
|
||||||
|
@ -351,7 +356,7 @@ struct factor_vm
|
||||||
void end_gc();
|
void end_gc();
|
||||||
void set_current_gc_op(gc_op op);
|
void set_current_gc_op(gc_op op);
|
||||||
void start_gc_again();
|
void start_gc_again();
|
||||||
void update_code_heap_for_minor_gc(std::set<code_block *> *remembered_set);
|
void update_code_heap_for_minor_gc(std::set<code_block*>* remembered_set);
|
||||||
void collect_nursery();
|
void collect_nursery();
|
||||||
void collect_aging();
|
void collect_aging();
|
||||||
void collect_to_tenured();
|
void collect_to_tenured();
|
||||||
|
@ -365,53 +370,53 @@ struct factor_vm
|
||||||
void collect_compact(bool trace_contexts_p);
|
void collect_compact(bool trace_contexts_p);
|
||||||
void collect_growing_heap(cell requested_size, bool trace_contexts_p);
|
void collect_growing_heap(cell requested_size, bool trace_contexts_p);
|
||||||
void gc(gc_op op, cell requested_size, bool trace_contexts_p);
|
void gc(gc_op op, cell requested_size, bool trace_contexts_p);
|
||||||
void scrub_context(context *ctx);
|
void scrub_context(context* ctx);
|
||||||
void scrub_contexts();
|
void scrub_contexts();
|
||||||
void primitive_minor_gc();
|
void primitive_minor_gc();
|
||||||
void primitive_full_gc();
|
void primitive_full_gc();
|
||||||
void primitive_compact_gc();
|
void primitive_compact_gc();
|
||||||
void primitive_enable_gc_events();
|
void primitive_enable_gc_events();
|
||||||
void primitive_disable_gc_events();
|
void primitive_disable_gc_events();
|
||||||
object *allot_object(cell type, cell size);
|
object* allot_object(cell type, cell size);
|
||||||
object *allot_large_object(cell type, cell size);
|
object* allot_large_object(cell type, cell size);
|
||||||
|
|
||||||
/* Allocates memory */
|
/* Allocates memory */
|
||||||
template<typename Type> Type *allot(cell size)
|
template <typename Type> Type* allot(cell size) {
|
||||||
{
|
return (Type*)allot_object(Type::type_number, size);
|
||||||
return (Type *)allot_object(Type::type_number,size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void check_data_pointer(object *pointer)
|
inline void check_data_pointer(object* pointer) {
|
||||||
{
|
#ifdef FACTOR_DEBUG
|
||||||
#ifdef FACTOR_DEBUG
|
if (!(current_gc && current_gc->op == collect_growing_heap_op))
|
||||||
if(!(current_gc && current_gc->op == collect_growing_heap_op))
|
FACTOR_ASSERT(data->seg->in_segment_p((cell) pointer));
|
||||||
FACTOR_ASSERT(data->seg->in_segment_p((cell)pointer));
|
#endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// generic arrays
|
// generic arrays
|
||||||
template<typename Array> Array *allot_uninitialized_array(cell capacity);
|
template <typename Array> Array* allot_uninitialized_array(cell capacity);
|
||||||
template<typename Array> bool reallot_array_in_place_p(Array *array, cell capacity);
|
template <typename Array>
|
||||||
template<typename Array> Array *reallot_array(Array *array_, cell capacity);
|
bool reallot_array_in_place_p(Array* array, cell capacity);
|
||||||
|
template <typename Array> Array* reallot_array(Array* array_, cell capacity);
|
||||||
|
|
||||||
// debug
|
// debug
|
||||||
void print_chars(string* str);
|
void print_chars(string* str);
|
||||||
void print_word(word* word, cell nesting);
|
void print_word(word* word, cell nesting);
|
||||||
void print_factor_string(string* str);
|
void print_factor_string(string* str);
|
||||||
void print_array(array* array, cell nesting);
|
void print_array(array* array, cell nesting);
|
||||||
void print_byte_array(byte_array *array, cell nesting);
|
void print_byte_array(byte_array* array, cell nesting);
|
||||||
void print_tuple(tuple *tuple, cell nesting);
|
void print_tuple(tuple* tuple, cell nesting);
|
||||||
void print_alien(alien *alien, cell nesting);
|
void print_alien(alien* alien, cell nesting);
|
||||||
void print_nested_obj(cell obj, fixnum nesting);
|
void print_nested_obj(cell obj, fixnum nesting);
|
||||||
void print_obj(cell obj);
|
void print_obj(cell obj);
|
||||||
void print_objects(cell *start, cell *end);
|
void print_objects(cell* start, cell* end);
|
||||||
void print_datastack();
|
void print_datastack();
|
||||||
void print_retainstack();
|
void print_retainstack();
|
||||||
void print_callstack();
|
void print_callstack();
|
||||||
void print_callstack_object(callstack *obj);
|
void print_callstack_object(callstack* obj);
|
||||||
void dump_cell(cell x);
|
void dump_cell(cell x);
|
||||||
void dump_memory(cell from, cell to);
|
void dump_memory(cell from, cell to);
|
||||||
template<typename Generation> void dump_generation(const char *name, Generation *gen);
|
template <typename Generation>
|
||||||
|
void dump_generation(const char* name, Generation* gen);
|
||||||
void dump_generations();
|
void dump_generations();
|
||||||
void dump_objects(cell type);
|
void dump_objects(cell type);
|
||||||
void dump_edges();
|
void dump_edges();
|
||||||
|
@ -422,45 +427,44 @@ struct factor_vm
|
||||||
void primitive_die();
|
void primitive_die();
|
||||||
|
|
||||||
// arrays
|
// arrays
|
||||||
inline void set_array_nth(array *array, cell slot, cell value);
|
inline void set_array_nth(array* array, cell slot, cell value);
|
||||||
array *allot_array(cell capacity, cell fill_);
|
array* allot_array(cell capacity, cell fill_);
|
||||||
void primitive_array();
|
void primitive_array();
|
||||||
cell allot_array_1(cell obj_);
|
cell allot_array_1(cell obj_);
|
||||||
cell allot_array_2(cell v1_, cell v2_);
|
cell allot_array_2(cell v1_, cell v2_);
|
||||||
cell allot_array_4(cell v1_, cell v2_, cell v3_, cell v4_);
|
cell allot_array_4(cell v1_, cell v2_, cell v3_, cell v4_);
|
||||||
void primitive_resize_array();
|
void primitive_resize_array();
|
||||||
cell std_vector_to_array(std::vector<cell> &elements);
|
cell std_vector_to_array(std::vector<cell>& elements);
|
||||||
|
|
||||||
// strings
|
// strings
|
||||||
string *allot_string_internal(cell capacity);
|
string* allot_string_internal(cell capacity);
|
||||||
void fill_string(string *str_, cell start, cell capacity, cell fill);
|
void fill_string(string* str_, cell start, cell capacity, cell fill);
|
||||||
string *allot_string(cell capacity, cell fill);
|
string* allot_string(cell capacity, cell fill);
|
||||||
void primitive_string();
|
void primitive_string();
|
||||||
bool reallot_string_in_place_p(string *str, cell capacity);
|
bool reallot_string_in_place_p(string* str, cell capacity);
|
||||||
string* reallot_string(string *str_, cell capacity);
|
string* reallot_string(string* str_, cell capacity);
|
||||||
void primitive_resize_string();
|
void primitive_resize_string();
|
||||||
void primitive_set_string_nth_fast();
|
void primitive_set_string_nth_fast();
|
||||||
|
|
||||||
// booleans
|
// booleans
|
||||||
cell tag_boolean(cell untagged)
|
cell tag_boolean(cell untagged) {
|
||||||
{
|
|
||||||
return (untagged ? true_object : false_object);
|
return (untagged ? true_object : false_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
// byte arrays
|
// byte arrays
|
||||||
byte_array *allot_byte_array(cell size);
|
byte_array* allot_byte_array(cell size);
|
||||||
void primitive_byte_array();
|
void primitive_byte_array();
|
||||||
void primitive_uninitialized_byte_array();
|
void primitive_uninitialized_byte_array();
|
||||||
void primitive_resize_byte_array();
|
void primitive_resize_byte_array();
|
||||||
|
|
||||||
template<typename Type> byte_array *byte_array_from_value(Type *value);
|
template <typename Type> byte_array* byte_array_from_value(Type* value);
|
||||||
|
|
||||||
// tuples
|
// tuples
|
||||||
void primitive_tuple();
|
void primitive_tuple();
|
||||||
void primitive_tuple_boa();
|
void primitive_tuple_boa();
|
||||||
|
|
||||||
// words
|
// words
|
||||||
word *allot_word(cell name_, cell vocab_, cell hashcode_);
|
word* allot_word(cell name_, cell vocab_, cell hashcode_);
|
||||||
void primitive_word();
|
void primitive_word();
|
||||||
void primitive_word_code();
|
void primitive_word_code();
|
||||||
void primitive_optimized_p();
|
void primitive_optimized_p();
|
||||||
|
@ -474,10 +478,10 @@ struct factor_vm
|
||||||
void primitive_float_to_fixnum();
|
void primitive_float_to_fixnum();
|
||||||
void primitive_fixnum_divint();
|
void primitive_fixnum_divint();
|
||||||
void primitive_fixnum_divmod();
|
void primitive_fixnum_divmod();
|
||||||
bignum *fixnum_to_bignum(fixnum);
|
bignum* fixnum_to_bignum(fixnum);
|
||||||
bignum *cell_to_bignum(cell);
|
bignum* cell_to_bignum(cell);
|
||||||
bignum *long_long_to_bignum(s64 n);
|
bignum* long_long_to_bignum(s64 n);
|
||||||
bignum *ulong_long_to_bignum(u64 n);
|
bignum* ulong_long_to_bignum(u64 n);
|
||||||
inline fixnum sign_mask(fixnum x);
|
inline fixnum sign_mask(fixnum x);
|
||||||
inline fixnum branchless_max(fixnum x, fixnum y);
|
inline fixnum branchless_max(fixnum x, fixnum y);
|
||||||
inline fixnum branchless_abs(fixnum x);
|
inline fixnum branchless_abs(fixnum x);
|
||||||
|
@ -534,30 +538,30 @@ struct factor_vm
|
||||||
inline cell from_signed_cell(fixnum x);
|
inline cell from_signed_cell(fixnum x);
|
||||||
inline cell from_unsigned_cell(cell x);
|
inline cell from_unsigned_cell(cell x);
|
||||||
inline cell allot_float(double n);
|
inline cell allot_float(double n);
|
||||||
inline bignum *float_to_bignum(cell tagged);
|
inline bignum* float_to_bignum(cell tagged);
|
||||||
inline double untag_float(cell tagged);
|
inline double untag_float(cell tagged);
|
||||||
inline double untag_float_check(cell tagged);
|
inline double untag_float_check(cell tagged);
|
||||||
inline fixnum float_to_fixnum(cell tagged);
|
inline fixnum float_to_fixnum(cell tagged);
|
||||||
inline double fixnum_to_float(cell tagged);
|
inline double fixnum_to_float(cell tagged);
|
||||||
|
|
||||||
// tagged
|
// tagged
|
||||||
template<typename Type> Type *untag_check(cell value);
|
template <typename Type> Type* untag_check(cell value);
|
||||||
|
|
||||||
// io
|
// io
|
||||||
void init_c_io();
|
void init_c_io();
|
||||||
void io_error();
|
void io_error();
|
||||||
FILE* safe_fopen(char *filename, char *mode);
|
FILE* safe_fopen(char* filename, char* mode);
|
||||||
int safe_fgetc(FILE *stream);
|
int safe_fgetc(FILE* stream);
|
||||||
size_t safe_fread(void *ptr, size_t size, size_t nitems, FILE *stream);
|
size_t safe_fread(void* ptr, size_t size, size_t nitems, FILE* stream);
|
||||||
void safe_fputc(int c, FILE* stream);
|
void safe_fputc(int c, FILE* stream);
|
||||||
size_t safe_fwrite(void *ptr, size_t size, size_t nitems, FILE *stream);
|
size_t safe_fwrite(void* ptr, size_t size, size_t nitems, FILE* stream);
|
||||||
int safe_ftell(FILE *stream);
|
int safe_ftell(FILE* stream);
|
||||||
void safe_fseek(FILE *stream, off_t offset, int whence);
|
void safe_fseek(FILE* stream, off_t offset, int whence);
|
||||||
void safe_fflush(FILE *stream);
|
void safe_fflush(FILE* stream);
|
||||||
void safe_fclose(FILE *stream);
|
void safe_fclose(FILE* stream);
|
||||||
void primitive_fopen();
|
void primitive_fopen();
|
||||||
FILE *pop_file_handle();
|
FILE* pop_file_handle();
|
||||||
FILE *peek_file_handle();
|
FILE* peek_file_handle();
|
||||||
void primitive_fgetc();
|
void primitive_fgetc();
|
||||||
void primitive_fread();
|
void primitive_fread();
|
||||||
void primitive_fputc();
|
void primitive_fputc();
|
||||||
|
@ -569,32 +573,31 @@ struct factor_vm
|
||||||
|
|
||||||
// code_block
|
// code_block
|
||||||
cell compute_entry_point_address(cell obj);
|
cell compute_entry_point_address(cell obj);
|
||||||
cell compute_entry_point_pic_address(word *w, cell tagged_quot);
|
cell compute_entry_point_pic_address(word* w, cell tagged_quot);
|
||||||
cell compute_entry_point_pic_address(cell w_);
|
cell compute_entry_point_pic_address(cell w_);
|
||||||
cell compute_entry_point_pic_tail_address(cell w_);
|
cell compute_entry_point_pic_tail_address(cell w_);
|
||||||
cell code_block_owner(code_block *compiled);
|
cell code_block_owner(code_block* compiled);
|
||||||
void update_word_references(code_block *compiled, bool reset_inline_caches);
|
void update_word_references(code_block* compiled, bool reset_inline_caches);
|
||||||
void undefined_symbol();
|
void undefined_symbol();
|
||||||
cell compute_dlsym_address(array *literals, cell index);
|
cell compute_dlsym_address(array* literals, cell index);
|
||||||
#ifdef FACTOR_PPC
|
#ifdef FACTOR_PPC
|
||||||
cell compute_dlsym_toc_address(array *literals, cell index);
|
cell compute_dlsym_toc_address(array* literals, cell index);
|
||||||
#endif
|
#endif
|
||||||
cell compute_vm_address(cell arg);
|
cell compute_vm_address(cell arg);
|
||||||
void store_external_address(instruction_operand op);
|
void store_external_address(instruction_operand op);
|
||||||
cell compute_here_address(cell arg, cell offset, code_block *compiled);
|
cell compute_here_address(cell arg, cell offset, code_block* compiled);
|
||||||
void initialize_code_block(code_block *compiled, cell literals);
|
void initialize_code_block(code_block* compiled, cell literals);
|
||||||
void initialize_code_block(code_block *compiled);
|
void initialize_code_block(code_block* compiled);
|
||||||
void fixup_labels(array *labels, code_block *compiled);
|
void fixup_labels(array* labels, code_block* compiled);
|
||||||
code_block *allot_code_block(cell size, code_block_type type);
|
code_block* allot_code_block(cell size, code_block_type type);
|
||||||
code_block *add_code_block(code_block_type type, cell code_, cell labels_,
|
code_block* add_code_block(code_block_type type, cell code_, cell labels_,
|
||||||
cell owner_, cell relocation_, cell parameters_, cell literals_,
|
cell owner_, cell relocation_, cell parameters_,
|
||||||
cell frame_size_untagged);
|
cell literals_, cell frame_size_untagged);
|
||||||
|
|
||||||
//code heap
|
//code heap
|
||||||
inline void check_code_pointer(cell ptr) { }
|
inline void check_code_pointer(cell ptr) {}
|
||||||
|
|
||||||
template<typename Iterator> void each_code_block(Iterator &iter)
|
template <typename Iterator> void each_code_block(Iterator& iter) {
|
||||||
{
|
|
||||||
code->allocator->iterate(iter);
|
code->allocator->iterate(iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -613,69 +616,69 @@ struct factor_vm
|
||||||
void primitive_callback();
|
void primitive_callback();
|
||||||
|
|
||||||
// image
|
// image
|
||||||
void init_objects(image_header *h);
|
void init_objects(image_header* h);
|
||||||
void load_data_heap(FILE *file, image_header *h, vm_parameters *p);
|
void load_data_heap(FILE* file, image_header* h, vm_parameters* p);
|
||||||
void load_code_heap(FILE *file, image_header *h, vm_parameters *p);
|
void load_code_heap(FILE* file, image_header* h, vm_parameters* p);
|
||||||
bool save_image(const vm_char *saving_filename, const vm_char *filename);
|
bool save_image(const vm_char* saving_filename, const vm_char* filename);
|
||||||
void primitive_save_image();
|
void primitive_save_image();
|
||||||
void primitive_save_image_and_exit();
|
void primitive_save_image_and_exit();
|
||||||
void fixup_data(cell data_offset, cell code_offset);
|
void fixup_data(cell data_offset, cell code_offset);
|
||||||
void fixup_code(cell data_offset, cell code_offset);
|
void fixup_code(cell data_offset, cell code_offset);
|
||||||
FILE *open_image(vm_parameters *p);
|
FILE* open_image(vm_parameters* p);
|
||||||
void load_image(vm_parameters *p);
|
void load_image(vm_parameters* p);
|
||||||
bool read_embedded_image_footer(FILE *file, embedded_image_footer *footer);
|
bool read_embedded_image_footer(FILE* file, embedded_image_footer* footer);
|
||||||
bool embedded_image_p();
|
bool embedded_image_p();
|
||||||
|
|
||||||
template<typename Iterator, typename Fixup>
|
template <typename Iterator, typename Fixup>
|
||||||
void iterate_callstack_object(callstack *stack_, Iterator &iterator,
|
void iterate_callstack_object(callstack* stack_, Iterator& iterator,
|
||||||
Fixup &fixup);
|
Fixup& fixup);
|
||||||
template<typename Iterator>
|
template <typename Iterator>
|
||||||
void iterate_callstack_object(callstack *stack_, Iterator &iterator);
|
void iterate_callstack_object(callstack* stack_, Iterator& iterator);
|
||||||
|
|
||||||
callstack *allot_callstack(cell size);
|
callstack* allot_callstack(cell size);
|
||||||
void *second_from_top_stack_frame(context *ctx);
|
void* second_from_top_stack_frame(context* ctx);
|
||||||
cell capture_callstack(context *ctx);
|
cell capture_callstack(context* ctx);
|
||||||
void primitive_callstack();
|
void primitive_callstack();
|
||||||
void primitive_callstack_for();
|
void primitive_callstack_for();
|
||||||
void *frame_predecessor(void *frame);
|
void* frame_predecessor(void* frame);
|
||||||
void primitive_callstack_to_array();
|
void primitive_callstack_to_array();
|
||||||
void primitive_innermost_stack_frame_executing();
|
void primitive_innermost_stack_frame_executing();
|
||||||
void primitive_innermost_stack_frame_scan();
|
void primitive_innermost_stack_frame_scan();
|
||||||
void primitive_set_innermost_stack_frame_quot();
|
void primitive_set_innermost_stack_frame_quot();
|
||||||
void primitive_callstack_bounds();
|
void primitive_callstack_bounds();
|
||||||
|
|
||||||
template<typename Iterator, typename Fixup>
|
template <typename Iterator, typename Fixup>
|
||||||
void iterate_callstack(context *ctx, Iterator &iterator, Fixup &fixup);
|
void iterate_callstack(context* ctx, Iterator& iterator, Fixup& fixup);
|
||||||
template<typename Iterator>
|
template <typename Iterator>
|
||||||
void iterate_callstack(context *ctx, Iterator &iterator);
|
void iterate_callstack(context* ctx, Iterator& iterator);
|
||||||
|
|
||||||
// cpu-*
|
// cpu-*
|
||||||
void dispatch_signal_handler(cell *sp, cell *pc, cell newpc);
|
void dispatch_signal_handler(cell* sp, cell* pc, cell newpc);
|
||||||
|
|
||||||
// alien
|
// alien
|
||||||
char *pinned_alien_offset(cell obj);
|
char* pinned_alien_offset(cell obj);
|
||||||
cell allot_alien(cell delegate_, cell displacement);
|
cell allot_alien(cell delegate_, cell displacement);
|
||||||
cell allot_alien(void *address);
|
cell allot_alien(void* address);
|
||||||
void primitive_displaced_alien();
|
void primitive_displaced_alien();
|
||||||
void primitive_alien_address();
|
void primitive_alien_address();
|
||||||
void *alien_pointer();
|
void* alien_pointer();
|
||||||
void primitive_dlopen();
|
void primitive_dlopen();
|
||||||
void primitive_dlsym();
|
void primitive_dlsym();
|
||||||
void primitive_dlsym_raw();
|
void primitive_dlsym_raw();
|
||||||
void primitive_dlclose();
|
void primitive_dlclose();
|
||||||
void primitive_dll_validp();
|
void primitive_dll_validp();
|
||||||
char *alien_offset(cell obj);
|
char* alien_offset(cell obj);
|
||||||
|
|
||||||
// quotations
|
// quotations
|
||||||
void primitive_jit_compile();
|
void primitive_jit_compile();
|
||||||
void *lazy_jit_compile_entry_point();
|
void* lazy_jit_compile_entry_point();
|
||||||
void primitive_array_to_quotation();
|
void primitive_array_to_quotation();
|
||||||
void primitive_quotation_code();
|
void primitive_quotation_code();
|
||||||
code_block *jit_compile_quot(cell owner_, cell quot_, bool relocating);
|
code_block* jit_compile_quot(cell owner_, cell quot_, bool relocating);
|
||||||
void jit_compile_quot(cell quot_, bool relocating);
|
void jit_compile_quot(cell quot_, bool relocating);
|
||||||
fixnum quot_code_offset_to_scan(cell quot_, cell offset);
|
fixnum quot_code_offset_to_scan(cell quot_, cell offset);
|
||||||
cell lazy_jit_compile(cell quot);
|
cell lazy_jit_compile(cell quot);
|
||||||
bool quot_compiled_p(quotation *quot);
|
bool quot_compiled_p(quotation* quot);
|
||||||
void primitive_quot_compiled_p();
|
void primitive_quot_compiled_p();
|
||||||
cell find_all_quotations();
|
cell find_all_quotations();
|
||||||
void initialize_all_quotations();
|
void initialize_all_quotations();
|
||||||
|
@ -683,13 +686,13 @@ struct factor_vm
|
||||||
// dispatch
|
// dispatch
|
||||||
cell search_lookup_alist(cell table, cell klass);
|
cell search_lookup_alist(cell table, cell klass);
|
||||||
cell search_lookup_hash(cell table, cell klass, cell hashcode);
|
cell search_lookup_hash(cell table, cell klass, cell hashcode);
|
||||||
cell nth_superclass(tuple_layout *layout, fixnum echelon);
|
cell nth_superclass(tuple_layout* layout, fixnum echelon);
|
||||||
cell nth_hashcode(tuple_layout *layout, fixnum echelon);
|
cell nth_hashcode(tuple_layout* layout, fixnum echelon);
|
||||||
cell lookup_tuple_method(cell obj, cell methods);
|
cell lookup_tuple_method(cell obj, cell methods);
|
||||||
cell lookup_method(cell obj, cell methods);
|
cell lookup_method(cell obj, cell methods);
|
||||||
void primitive_lookup_method();
|
void primitive_lookup_method();
|
||||||
cell object_class(cell obj);
|
cell object_class(cell obj);
|
||||||
cell method_cache_hashcode(cell klass, array *array);
|
cell method_cache_hashcode(cell klass, array* array);
|
||||||
void update_method_cache(cell cache, cell klass, cell method);
|
void update_method_cache(cell cache, cell klass, cell method);
|
||||||
void primitive_mega_cache_miss();
|
void primitive_mega_cache_miss();
|
||||||
void primitive_reset_dispatch_stats();
|
void primitive_reset_dispatch_stats();
|
||||||
|
@ -698,49 +701,51 @@ struct factor_vm
|
||||||
// inline cache
|
// inline cache
|
||||||
void init_inline_caching(int max_size);
|
void init_inline_caching(int max_size);
|
||||||
void deallocate_inline_cache(cell return_address);
|
void deallocate_inline_cache(cell return_address);
|
||||||
cell determine_inline_cache_type(array *cache_entries);
|
cell determine_inline_cache_type(array* cache_entries);
|
||||||
void update_pic_count(cell type);
|
void update_pic_count(cell type);
|
||||||
code_block *compile_inline_cache(fixnum index,cell generic_word_,cell methods_,cell cache_entries_,bool tail_call_p);
|
code_block* compile_inline_cache(fixnum index, cell generic_word_,
|
||||||
void *megamorphic_call_stub(cell generic_word);
|
cell methods_, cell cache_entries_,
|
||||||
|
bool tail_call_p);
|
||||||
|
void* megamorphic_call_stub(cell generic_word);
|
||||||
cell inline_cache_size(cell cache_entries);
|
cell inline_cache_size(cell cache_entries);
|
||||||
cell add_inline_cache_entry(cell cache_entries_, cell klass_, cell method_);
|
cell add_inline_cache_entry(cell cache_entries_, cell klass_, cell method_);
|
||||||
void update_pic_transitions(cell pic_size);
|
void update_pic_transitions(cell pic_size);
|
||||||
void *inline_cache_miss(cell return_address);
|
void* inline_cache_miss(cell return_address);
|
||||||
|
|
||||||
// entry points
|
// entry points
|
||||||
void c_to_factor(cell quot);
|
void c_to_factor(cell quot);
|
||||||
template<typename Func> Func get_entry_point(cell n);
|
template <typename Func> Func get_entry_point(cell n);
|
||||||
void unwind_native_frames(cell quot, void *to);
|
void unwind_native_frames(cell quot, void* to);
|
||||||
cell get_fpu_state();
|
cell get_fpu_state();
|
||||||
void set_fpu_state(cell state);
|
void set_fpu_state(cell state);
|
||||||
|
|
||||||
// factor
|
// factor
|
||||||
void default_parameters(vm_parameters *p);
|
void default_parameters(vm_parameters* p);
|
||||||
bool factor_arg(const vm_char *str, const vm_char *arg, cell *value);
|
bool factor_arg(const vm_char* str, const vm_char* arg, cell* value);
|
||||||
void init_parameters_from_args(vm_parameters *p, int argc, vm_char **argv);
|
void init_parameters_from_args(vm_parameters* p, int argc, vm_char** argv);
|
||||||
void prepare_boot_image();
|
void prepare_boot_image();
|
||||||
void init_factor(vm_parameters *p);
|
void init_factor(vm_parameters* p);
|
||||||
void pass_args_to_factor(int argc, vm_char **argv);
|
void pass_args_to_factor(int argc, vm_char** argv);
|
||||||
void start_factor(vm_parameters *p);
|
void start_factor(vm_parameters* p);
|
||||||
void stop_factor();
|
void stop_factor();
|
||||||
void start_embedded_factor(vm_parameters *p);
|
void start_embedded_factor(vm_parameters* p);
|
||||||
void start_standalone_factor(int argc, vm_char **argv);
|
void start_standalone_factor(int argc, vm_char** argv);
|
||||||
char *factor_eval_string(char *string);
|
char* factor_eval_string(char* string);
|
||||||
void factor_eval_free(char *result);
|
void factor_eval_free(char* result);
|
||||||
void factor_yield();
|
void factor_yield();
|
||||||
void factor_sleep(long us);
|
void factor_sleep(long us);
|
||||||
|
|
||||||
// os-*
|
// os-*
|
||||||
void primitive_existsp();
|
void primitive_existsp();
|
||||||
void move_file(const vm_char *path1, const vm_char *path2);
|
void move_file(const vm_char* path1, const vm_char* path2);
|
||||||
void init_ffi();
|
void init_ffi();
|
||||||
void ffi_dlopen(dll *dll);
|
void ffi_dlopen(dll* dll);
|
||||||
void *ffi_dlsym(dll *dll, symbol_char *symbol);
|
void* ffi_dlsym(dll* dll, symbol_char* symbol);
|
||||||
void *ffi_dlsym_raw(dll *dll, symbol_char *symbol);
|
void* ffi_dlsym_raw(dll* dll, symbol_char* symbol);
|
||||||
#ifdef FACTOR_PPC
|
#ifdef FACTOR_PPC
|
||||||
void *ffi_dlsym_toc(dll *dll, symbol_char *symbol);
|
void* ffi_dlsym_toc(dll* dll, symbol_char* symbol);
|
||||||
#endif
|
#endif
|
||||||
void ffi_dlclose(dll *dll);
|
void ffi_dlclose(dll* dll);
|
||||||
void c_to_factor_toplevel(cell quot);
|
void c_to_factor_toplevel(cell quot);
|
||||||
void init_signals();
|
void init_signals();
|
||||||
void start_sampling_profiler_timer();
|
void start_sampling_profiler_timer();
|
||||||
|
@ -752,26 +757,32 @@ struct factor_vm
|
||||||
static void ignore_ctrl_c();
|
static void ignore_ctrl_c();
|
||||||
static void handle_ctrl_c();
|
static void handle_ctrl_c();
|
||||||
|
|
||||||
// os-windows
|
// os-windows
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
HANDLE sampler_thread;
|
HANDLE sampler_thread;
|
||||||
void sampler_thread_loop();
|
void sampler_thread_loop();
|
||||||
|
|
||||||
const vm_char *vm_executable_path();
|
const vm_char* vm_executable_path();
|
||||||
const vm_char *default_image_path();
|
const vm_char* default_image_path();
|
||||||
void windows_image_path(vm_char *full_path, vm_char *temp_path, unsigned int length);
|
void windows_image_path(vm_char* full_path, vm_char* temp_path,
|
||||||
BOOL windows_stat(vm_char *path);
|
unsigned int length);
|
||||||
|
BOOL windows_stat(vm_char* path);
|
||||||
|
|
||||||
LONG exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch);
|
LONG exception_handler(PEXCEPTION_RECORD e, void* frame, PCONTEXT c,
|
||||||
|
void* dispatch);
|
||||||
|
|
||||||
#else // UNIX
|
#else // UNIX
|
||||||
void dispatch_signal(void *uap, void (handler)());
|
void dispatch_signal(void* uap, void(handler)());
|
||||||
void unix_init_signals();
|
void unix_init_signals();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
void call_fault_handler(exception_type_t exception, exception_data_type_t code, MACH_EXC_STATE_TYPE *exc_state, MACH_THREAD_STATE_TYPE *thread_state, MACH_FLOAT_STATE_TYPE *float_state);
|
void call_fault_handler(exception_type_t exception,
|
||||||
#endif
|
exception_data_type_t code,
|
||||||
|
MACH_EXC_STATE_TYPE* exc_state,
|
||||||
|
MACH_THREAD_STATE_TYPE* thread_state,
|
||||||
|
MACH_FLOAT_STATE_TYPE* float_state);
|
||||||
|
#endif
|
||||||
|
|
||||||
factor_vm(THREADHANDLE thread_id);
|
factor_vm(THREADHANDLE thread_id);
|
||||||
~factor_vm();
|
~factor_vm();
|
||||||
|
|
Loading…
Reference in New Issue