152 lines
6.8 KiB
C++
152 lines
6.8 KiB
C++
namespace factor
|
|
{
|
|
|
|
struct factorvm {
|
|
|
|
// contexts
|
|
void reset_datastack();
|
|
void reset_retainstack();
|
|
void fix_stacks();
|
|
void save_stacks();
|
|
context *alloc_context();
|
|
void dealloc_context(context *old_context);
|
|
void nest_stacks();
|
|
void unnest_stacks();
|
|
void init_stacks(cell ds_size_, cell rs_size_);
|
|
bool stack_to_array(cell bottom, cell top);
|
|
cell array_to_stack(array *array, cell bottom);
|
|
inline void vmprim_datastack();
|
|
inline void vmprim_retainstack();
|
|
inline void vmprim_set_datastack();
|
|
inline void vmprim_set_retainstack();
|
|
inline void vmprim_check_datastack();
|
|
|
|
// run
|
|
inline void vmprim_getenv();
|
|
inline void vmprim_setenv();
|
|
inline void vmprim_exit();
|
|
inline void vmprim_micros();
|
|
inline void vmprim_sleep();
|
|
inline void vmprim_set_slot();
|
|
inline void vmprim_load_locals();
|
|
cell clone_object(cell obj_);
|
|
inline void vmprim_clone();
|
|
|
|
// profiler
|
|
void init_profiler();
|
|
code_block *compile_profiling_stub(cell word_);
|
|
void set_profiling(bool profiling);
|
|
inline void vmprim_profiling();
|
|
|
|
// errors
|
|
void out_of_memory();
|
|
void fatal_error(const char* msg, cell tagged);
|
|
void critical_error(const char* msg, cell tagged);
|
|
void throw_error(cell error, stack_frame *callstack_top);
|
|
void not_implemented_error();
|
|
bool in_page(cell fault, cell area, cell area_size, int offset);
|
|
void memory_protection_error(cell addr, stack_frame *native_stack);
|
|
void signal_error(int signal, stack_frame *native_stack);
|
|
void divide_by_zero_error();
|
|
void fp_trap_error(stack_frame *signal_callstack_top);
|
|
inline void vmprim_call_clear();
|
|
inline void vmprim_unimplemented();
|
|
void memory_signal_handler_impl();
|
|
void misc_signal_handler_impl();
|
|
void fp_signal_handler_impl();
|
|
void type_error(cell type, cell tagged);
|
|
void general_error(vm_error_type error, cell arg1, cell arg2, stack_frame *callstack_top);
|
|
|
|
// bignum
|
|
int bignum_equal_p(bignum * x, bignum * y);
|
|
enum bignum_comparison bignum_compare(bignum * x, bignum * y);
|
|
bignum *bignum_add(bignum * x, bignum * y);
|
|
bignum *bignum_subtract(bignum * x, bignum * y);
|
|
bignum *bignum_multiply(bignum * x, bignum * y);
|
|
void bignum_divide(bignum * numerator, bignum * denominator, bignum * * quotient, bignum * * remainder);
|
|
bignum *bignum_quotient(bignum * numerator, bignum * denominator);
|
|
bignum *bignum_remainder(bignum * numerator, bignum * denominator);
|
|
double bignum_to_double(bignum * bignum);
|
|
bignum *double_to_bignum(double x);
|
|
int bignum_equal_p_unsigned(bignum * x, bignum * y);
|
|
enum bignum_comparison bignum_compare_unsigned(bignum * x, bignum * y);
|
|
bignum *bignum_add_unsigned(bignum * x, bignum * y, int negative_p);
|
|
bignum *bignum_subtract_unsigned(bignum * x, bignum * y);
|
|
bignum *bignum_multiply_unsigned(bignum * x, bignum * y, int negative_p);
|
|
bignum *bignum_multiply_unsigned_small_factor(bignum * x, bignum_digit_type y,int negative_p);
|
|
void bignum_destructive_add(bignum * bignum, bignum_digit_type n);
|
|
void bignum_destructive_scale_up(bignum * bignum, bignum_digit_type factor);
|
|
void bignum_divide_unsigned_large_denominator(bignum * numerator, bignum * denominator,
|
|
bignum * * quotient, bignum * * remainder, int q_negative_p, int r_negative_p);
|
|
void bignum_divide_unsigned_normalized(bignum * u, bignum * v, bignum * q);
|
|
bignum_digit_type bignum_divide_subtract(bignum_digit_type * v_start, bignum_digit_type * v_end,
|
|
bignum_digit_type guess, bignum_digit_type * u_start);
|
|
void bignum_divide_unsigned_medium_denominator(bignum * numerator,bignum_digit_type denominator,
|
|
bignum * * quotient, bignum * * remainder,int q_negative_p, int r_negative_p);
|
|
void bignum_destructive_normalization(bignum * source, bignum * target, int shift_left);
|
|
void bignum_destructive_unnormalization(bignum * bignum, int shift_right);
|
|
bignum_digit_type bignum_digit_divide(bignum_digit_type uh, bignum_digit_type ul,
|
|
bignum_digit_type v, bignum_digit_type * q) /* return value */;
|
|
bignum_digit_type bignum_digit_divide_subtract(bignum_digit_type v1, bignum_digit_type v2,
|
|
bignum_digit_type guess, bignum_digit_type * u);
|
|
void bignum_divide_unsigned_small_denominator(bignum * numerator, bignum_digit_type denominator,
|
|
bignum * * quotient, bignum * * remainder,int q_negative_p, int r_negative_p);
|
|
bignum_digit_type bignum_destructive_scale_down(bignum * bignum, bignum_digit_type denominator);
|
|
bignum * bignum_remainder_unsigned_small_denominator(bignum * n, bignum_digit_type d, int negative_p);
|
|
bignum *bignum_digit_to_bignum(bignum_digit_type digit, int negative_p);
|
|
bignum *allot_bignum(bignum_length_type length, int negative_p);
|
|
bignum * allot_bignum_zeroed(bignum_length_type length, int negative_p);
|
|
bignum *bignum_shorten_length(bignum * bignum, bignum_length_type length);
|
|
bignum *bignum_trim(bignum * bignum);
|
|
bignum *bignum_new_sign(bignum * x, int negative_p);
|
|
bignum *bignum_maybe_new_sign(bignum * x, int negative_p);
|
|
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 *digit_stream_to_bignum(unsigned int n_digits, unsigned int (*producer)(unsigned int), unsigned int radix, int negative_p);
|
|
|
|
//data_heap
|
|
cell init_zone(zone *z, cell size, cell start);
|
|
void init_card_decks();
|
|
data_heap *alloc_data_heap(cell gens, cell young_size,cell aging_size,cell tenured_size);
|
|
data_heap *grow_data_heap(data_heap *data, cell requested_bytes);
|
|
void dealloc_data_heap(data_heap *data);
|
|
void clear_cards(cell from, cell to);
|
|
void clear_decks(cell from, cell to);
|
|
void clear_allot_markers(cell from, cell to);
|
|
void reset_generation(cell i);
|
|
void reset_generations(cell from, cell to);
|
|
void set_data_heap(data_heap *data_);
|
|
void init_data_heap(cell gens,cell young_size,cell aging_size,cell tenured_size,bool secure_gc_);
|
|
cell untagged_object_size(object *pointer);
|
|
cell unaligned_object_size(object *pointer);
|
|
inline void vmprim_size();
|
|
cell binary_payload_start(object *pointer);
|
|
inline void vmprim_data_room();
|
|
void begin_scan();
|
|
void end_scan();
|
|
inline void vmprim_begin_scan();
|
|
cell next_object();
|
|
inline void vmprim_next_object();
|
|
inline void vmprim_end_scan();
|
|
template<typename T> void each_object(T &functor);
|
|
cell find_all_words();
|
|
// next method here:
|
|
|
|
};
|
|
|
|
extern factorvm *vm;
|
|
|
|
}
|