5 typedef void (*c_to_factor_func_type)(cell quot);
6 typedef void (*unwind_native_frames_func_type)(cell quot, cell to);
7 typedef cell (*get_fpu_state_func_type)();
8 typedef void (*set_fpu_state_func_type)(cell state);
10 struct growable_array;
16 // THESE FIELDS ARE ACCESSED DIRECTLY FROM FACTOR. See:
18 // basis/compiler/constants/constants.factor
23 /* Spare context -- for callbacks */
26 /* New objects are allocated here, use the data->nursery reference
27 instead from c++ code. */
28 bump_allocator nursery;
30 /* Add this to a shifted address to compute write barrier offsets */
34 /* cdecl signal handler address, used by signal handler subprimitives */
35 cell signal_handler_addr;
37 /* are we handling a memory error? used to detect double faults */
40 /* Various special objects, accessed by special-object and
41 set-special-object primitives */
42 cell special_objects[special_object_count];
44 // THESE FIELDS ARE ACCESSED DIRECTLY FROM FACTOR.
48 /* Handle to the main thread we run in */
51 /* Data stack and retain stack sizes */
52 cell datastack_size, retainstack_size, callstack_size;
54 /* Stack of callback IDs */
55 std::vector<int> callback_ids;
57 /* Next callback ID */
60 /* List of callback function descriptors for PPC */
61 std::list<void**> function_descriptors;
63 /* Pooling unused contexts to make context allocation cheaper */
64 std::list<context*> unused_contexts;
66 /* Active contexts, for tracing by the GC */
67 std::set<context*> active_contexts;
69 /* Canonical truth value. In Factor, 't' */
72 /* External entry points */
73 c_to_factor_func_type c_to_factor_func;
75 /* Is profiling enabled? */
76 volatile cell sampling_profiler_p;
77 fixnum samples_per_second;
79 /* Global variables used to pass fault handler state from signal handler
81 bool signal_resumable;
83 cell signal_fault_addr;
85 unsigned int signal_fpu_status;
87 /* Pipe used to notify Factor multiplexer of signals */
88 int signal_pipe_input, signal_pipe_output;
90 /* State kept by the sampling profiler */
91 std::vector<profiling_sample> samples;
92 std::vector<cell> sample_callstacks;
94 /* GC is off during heap walking */
103 /* Pinned callback stubs */
104 callback_heap* callbacks;
106 /* Only set if we're performing a GC */
107 gc_state* current_gc;
108 volatile cell current_gc_p;
110 /* Set if we're in the jit */
111 volatile fixnum current_jit_count;
114 std::vector<cell> mark_stack;
116 /* If not NULL, we push GC events here */
117 std::vector<gc_event>* gc_events;
119 /* If a runtime function needs to call another function which potentially
120 allocates memory, it must wrap any references to the data and code
121 heaps with data_root and code_root smart pointers, which register
122 themselves here. See data_roots.hpp and code_roots.hpp */
124 std::vector<cell*> data_roots;
125 std::vector<code_root*> code_roots;
129 bool fep_help_was_shown;
133 /* Canonical bignums */
138 /* Method dispatch statistics */
139 dispatch_statistics dispatch_stats;
141 /* Number of entries in a polymorphic inline cache */
144 /* Incrementing object counter for identity hashing */
147 /* Sanity check to ensure that monotonic counter doesn't decrease */
148 uint64_t last_nano_count;
150 /* Stack for signal handlers, only used on Unix */
151 segment* signal_callstack_seg;
153 /* Are we already handling a fault? Used to catch double memory faults */
154 static bool fatal_erroring_p;
156 /* Safepoint state */
157 volatile safepoint_state safepoint;
160 context* new_context();
161 void init_context(context* ctx);
162 void delete_context();
163 void init_contexts(cell datastack_size_, cell retainstack_size_,
164 cell callstack_size_);
165 void delete_contexts();
166 cell begin_callback(cell quot);
168 void primitive_current_callback();
169 void primitive_context_object();
170 void primitive_context_object_for();
171 void primitive_set_context_object();
172 cell stack_to_array(cell bottom, cell top, vm_error_type error);
173 cell datastack_to_array(context* ctx);
174 void primitive_datastack_for();
175 cell retainstack_to_array(context* ctx);
176 void primitive_retainstack_for();
177 cell array_to_stack(array* array, cell bottom);
178 void set_datastack(context* ctx, array* array);
179 void primitive_set_datastack();
180 void set_retainstack(context* ctx, array* array);
181 void primitive_set_retainstack();
182 void primitive_check_datastack();
183 void primitive_load_locals();
186 void primitive_exit();
187 void primitive_nano_count();
188 void primitive_sleep();
189 void primitive_set_slot();
192 void primitive_special_object();
193 void primitive_set_special_object();
194 void primitive_identity_hashcode();
195 void compute_identity_hashcode(object* obj);
196 void primitive_compute_identity_hashcode();
197 cell object_size(cell tagged);
198 cell clone_object(cell obj_);
199 void primitive_clone();
200 void primitive_become();
203 void clear_samples();
204 void record_sample(bool prolog_p);
205 void record_callstack_sample(cell* begin, cell* end, bool prolog_p);
206 void start_sampling_profiler(fixnum rate);
207 void end_sampling_profiler();
208 void set_sampling_profiler(fixnum rate);
209 void primitive_sampling_profiler();
210 void primitive_get_samples();
211 void primitive_clear_samples();
214 void general_error(vm_error_type error, cell arg1, cell arg2);
215 void type_error(cell type, cell tagged);
216 void not_implemented_error();
217 void verify_memory_protection_error(cell addr);
218 void divide_by_zero_error();
219 void primitive_unimplemented();
220 void memory_signal_handler_impl();
221 void synchronous_signal_handler_impl();
222 void fp_signal_handler_impl();
225 int bignum_equal_p(bignum* x, bignum* y);
226 enum bignum_comparison bignum_compare(bignum* x, bignum* y);
227 bignum* bignum_add(bignum* x, bignum* y);
228 bignum* bignum_subtract(bignum* x, bignum* y);
229 bignum* bignum_square(bignum* x_);
230 bignum* bignum_multiply(bignum* x, bignum* y);
231 void bignum_divide(bignum* numerator, bignum* denominator, bignum** quotient,
233 bignum* bignum_quotient(bignum* numerator, bignum* denominator);
234 bignum* bignum_remainder(bignum* numerator, bignum* denominator);
235 fixnum bignum_to_fixnum_strict(bignum* bn);
236 bignum* double_to_bignum(double x);
237 int bignum_equal_p_unsigned(bignum* x, bignum* y);
238 enum bignum_comparison bignum_compare_unsigned(bignum* x, bignum* y);
239 bignum* bignum_add_unsigned(bignum* x_, bignum* y_, int negative_p);
240 bignum* bignum_subtract_unsigned(bignum* x_, bignum* y_);
241 bignum* bignum_multiply_unsigned(bignum* x_, bignum* y_, int negative_p);
242 bignum* bignum_multiply_unsigned_small_factor(bignum* x, bignum_digit_type y,
244 void bignum_destructive_add(bignum* bn, bignum_digit_type n);
245 void bignum_destructive_scale_up(bignum* bn, bignum_digit_type factor);
246 void bignum_divide_unsigned_large_denominator(
247 bignum* numerator_, bignum* denominator_, bignum** quotient,
248 bignum** remainder, int q_negative_p, int r_negative_p);
249 void bignum_divide_unsigned_normalized(bignum* u, bignum* v, bignum* q);
250 bignum_digit_type bignum_divide_subtract(bignum_digit_type* v_start,
251 bignum_digit_type* v_end,
252 bignum_digit_type guess,
253 bignum_digit_type* u_start);
254 void bignum_divide_unsigned_medium_denominator(
255 bignum* numerator_, bignum_digit_type denominator, bignum** quotient,
256 bignum** remainder, int q_negative_p, int r_negative_p);
257 void bignum_destructive_normalization(bignum* source, bignum* target,
259 void bignum_destructive_unnormalization(bignum* bn, int shift_right);
260 bignum_digit_type bignum_digit_divide(
261 bignum_digit_type uh, bignum_digit_type ul, bignum_digit_type v,
262 bignum_digit_type* q) /* return value */;
263 bignum_digit_type bignum_digit_divide_subtract(bignum_digit_type v1,
264 bignum_digit_type v2,
265 bignum_digit_type guess,
266 bignum_digit_type* u);
267 void bignum_divide_unsigned_small_denominator(
268 bignum* numerator_, bignum_digit_type denominator, bignum** quotient,
269 bignum** remainder, int q_negative_p, int r_negative_p);
270 bignum_digit_type bignum_destructive_scale_down(
271 bignum* bn, bignum_digit_type denominator);
272 bignum* bignum_remainder_unsigned_small_denominator(bignum* n,
275 bignum* bignum_digit_to_bignum(bignum_digit_type digit, int negative_p);
276 bignum* allot_bignum(bignum_length_type length, int negative_p);
277 bignum* allot_bignum_zeroed(bignum_length_type length, int negative_p);
278 bignum* bignum_shorten_length(bignum* bn, bignum_length_type length);
279 bignum* bignum_trim(bignum* bn);
280 bignum* bignum_new_sign(bignum* x_, int negative_p);
281 bignum* bignum_maybe_new_sign(bignum* x_, int negative_p);
282 void bignum_destructive_copy(bignum* source, bignum* target);
283 bignum* bignum_bitwise_not(bignum* x_);
284 bignum* bignum_arithmetic_shift(bignum* arg1, fixnum n);
285 bignum* bignum_bitwise_and(bignum* arg1, bignum* arg2);
286 bignum* bignum_bitwise_ior(bignum* arg1, bignum* arg2);
287 bignum* bignum_bitwise_xor(bignum* arg1, bignum* arg2);
288 bignum* bignum_magnitude_ash(bignum* arg1_, fixnum n);
289 bignum* bignum_pospos_bitwise_op(int op, bignum* arg1_, bignum* arg2_);
290 bignum* bignum_posneg_bitwise_op(int op, bignum* arg1_, bignum* arg2_);
291 bignum* bignum_negneg_bitwise_op(int op, bignum* arg1_, bignum* arg2_);
292 void bignum_negate_magnitude(bignum* arg);
293 bignum* bignum_integer_length(bignum* x_);
294 int bignum_logbitp(int shift, bignum* arg);
295 int bignum_unsigned_logbitp(int shift, bignum* bn);
296 bignum* bignum_gcd(bignum* a_, bignum* b_);
299 void init_card_decks();
300 void set_data_heap(data_heap* data_);
301 void init_data_heap(cell young_size, cell aging_size, cell tenured_size);
302 void primitive_size();
303 data_heap_room data_room();
304 void primitive_data_room();
307 cell instances(cell type);
308 void primitive_all_instances();
310 template <typename Generation, typename Iterator>
311 inline void each_object(Generation* gen, Iterator& iterator) {
312 cell obj = gen->first_object();
314 iterator((object*)obj);
315 obj = gen->next_object_after(obj);
319 template <typename Iterator> inline void each_object(Iterator& iterator) {
321 /* The nursery can't be iterated because there may be gaps between
322 the objects (see factor_vm::reallot_array) so we require it to
324 FACTOR_ASSERT(data->nursery->occupied_space() == 0);
327 each_object(data->tenured, iterator);
328 each_object(data->aging, iterator);
332 template <typename Iterator>
333 inline void each_object_each_slot(Iterator& iterator) {
334 auto each_object_func = [&](object* obj) {
335 auto each_slot_func = [&](cell* slot) {
338 obj->each_slot(each_slot_func);
340 each_object(each_object_func);
343 /* the write barrier must be called any time we are potentially storing a
344 pointer from an older generation to a younger one */
345 inline void write_barrier(cell* slot_ptr) {
346 *(char*)(cards_offset + ((cell)slot_ptr >> card_bits)) = card_mark_mask;
347 *(char*)(decks_offset + ((cell)slot_ptr >> deck_bits)) = card_mark_mask;
350 inline void write_barrier(object* obj, cell size) {
351 cell start = (cell)obj & (~card_size + 1);
352 cell end = ((cell)obj + size + card_size - 1) & (~card_size + 1);
354 for (cell offset = start; offset < end; offset += card_size)
355 write_barrier((cell*)offset);
359 void check_data_heap();
363 void set_current_gc_op(gc_op op);
364 void start_gc_again();
365 void collect_nursery();
366 void collect_aging();
367 void collect_to_tenured();
368 void update_code_roots_for_sweep();
369 void update_code_roots_for_compaction();
370 void collect_mark_impl();
371 void collect_sweep_impl();
373 void collect_compact_impl();
374 void collect_compact();
375 void collect_growing_heap(cell requested_size);
376 void gc(gc_op op, cell requested_size);
377 void primitive_minor_gc();
378 void primitive_full_gc();
379 void primitive_compact_gc();
380 void primitive_enable_gc_events();
381 void primitive_disable_gc_events();
382 object* allot_object(cell type, cell size);
383 object* allot_large_object(cell type, cell size);
385 /* Allocates memory */
386 template <typename Type> Type* allot(cell size) {
387 return (Type*)allot_object(Type::type_number, size);
391 template <typename Array> Array* allot_uninitialized_array(cell capacity);
392 template <typename Array>
393 bool reallot_array_in_place_p(Array* array, cell capacity);
394 template <typename Array> Array* reallot_array(Array* array_, cell capacity);
397 void print_chars(ostream& out, string* str);
398 void print_word(ostream& out, word* word, cell nesting);
399 void print_factor_string(ostream& out, string* str);
400 void print_array(ostream& out, array* array, cell nesting);
401 void print_byte_array(ostream& out, byte_array* array, cell nesting);
402 void print_tuple(ostream& out, tuple* tuple, cell nesting);
403 void print_alien(ostream& out, alien* alien, cell nesting);
404 void print_nested_obj(ostream& out, cell obj, fixnum nesting);
405 void print_obj(ostream& out, cell obj);
406 void print_objects(ostream& out, cell* start, cell* end);
407 void print_datastack(ostream& out);
408 void print_retainstack(ostream& out);
409 void print_callstack(ostream& out);
410 void print_callstack_object(ostream& out, callstack* obj);
411 void dump_cell(ostream& out, cell x);
412 void dump_memory(ostream& out, cell from, cell to);
413 void dump_memory_layout(ostream& out);
414 void dump_objects(ostream& out, cell type);
415 void dump_edges(ostream& out);
416 void find_data_references(ostream& out, cell look_for_);
417 void dump_code_heap(ostream& out);
418 void factorbug_usage(bool advanced_p);
420 void primitive_die();
423 inline void set_array_nth(array* array, cell slot, cell value);
424 array* allot_array(cell capacity, cell fill_);
425 void primitive_array();
426 cell allot_array_4(cell v1_, cell v2_, cell v3_, cell v4_);
427 void primitive_resize_array();
428 cell std_vector_to_array(std::vector<cell>& elements);
431 string* allot_string_internal(cell capacity);
432 void fill_string(string* str_, cell start, cell capacity, cell fill);
433 string* allot_string(cell capacity, cell fill);
434 void primitive_string();
435 bool reallot_string_in_place_p(string* str, cell capacity);
436 string* reallot_string(string* str_, cell capacity);
437 void primitive_resize_string();
438 void primitive_set_string_nth_fast();
441 cell tag_boolean(cell untagged) {
442 return (untagged ? true_object : false_object);
446 byte_array* allot_byte_array(cell size);
447 void primitive_byte_array();
448 void primitive_uninitialized_byte_array();
449 void primitive_resize_byte_array();
451 template <typename Type> byte_array* byte_array_from_value(Type* value);
454 void primitive_tuple();
455 void primitive_tuple_boa();
458 word* allot_word(cell name_, cell vocab_, cell hashcode_);
459 void primitive_word();
460 void primitive_word_code();
461 void primitive_word_optimized_p();
462 void primitive_wrapper();
463 void jit_compile_word(cell word_, cell def_, bool relocating);
464 cell find_all_words();
465 void compile_all_words();
468 void primitive_bignum_to_fixnum();
469 void primitive_bignum_to_fixnum_strict();
470 void primitive_float_to_fixnum();
471 void primitive_fixnum_divint();
472 void primitive_fixnum_divmod();
473 bignum* fixnum_to_bignum(fixnum);
474 bignum* cell_to_bignum(cell);
475 bignum* long_long_to_bignum(int64_t n);
476 bignum* ulong_long_to_bignum(uint64_t n);
477 inline fixnum sign_mask(fixnum x);
478 inline fixnum branchless_max(fixnum x, fixnum y);
479 inline fixnum branchless_abs(fixnum x);
480 void primitive_fixnum_shift();
481 void primitive_fixnum_to_bignum();
482 void primitive_float_to_bignum();
483 void primitive_bignum_eq();
484 void primitive_bignum_add();
485 void primitive_bignum_subtract();
486 void primitive_bignum_multiply();
487 void primitive_bignum_divint();
488 void primitive_bignum_divmod();
489 void primitive_bignum_mod();
490 void primitive_bignum_gcd();
491 void primitive_bignum_and();
492 void primitive_bignum_or();
493 void primitive_bignum_xor();
494 void primitive_bignum_shift();
495 void primitive_bignum_less();
496 void primitive_bignum_lesseq();
497 void primitive_bignum_greater();
498 void primitive_bignum_greatereq();
499 void primitive_bignum_not();
500 void primitive_bignum_bitp();
501 void primitive_bignum_log2();
502 inline cell unbox_array_size();
503 void primitive_fixnum_to_float();
504 void primitive_format_float();
505 void primitive_float_eq();
506 void primitive_float_add();
507 void primitive_float_subtract();
508 void primitive_float_multiply();
509 void primitive_float_divfloat();
510 void primitive_float_less();
511 void primitive_float_lesseq();
512 void primitive_float_greater();
513 void primitive_float_greatereq();
514 void primitive_float_bits();
515 void primitive_bits_float();
516 void primitive_double_bits();
517 void primitive_bits_double();
518 fixnum to_fixnum(cell tagged);
519 fixnum to_fixnum_strict(cell tagged);
520 cell to_cell(cell tagged);
521 cell from_signed_8(int64_t n);
522 int64_t to_signed_8(cell obj);
523 cell from_unsigned_8(uint64_t n);
524 uint64_t to_unsigned_8(cell obj);
525 float to_float(cell value);
526 double to_double(cell value);
527 inline void overflow_fixnum_add(fixnum x, fixnum y);
528 inline void overflow_fixnum_subtract(fixnum x, fixnum y);
529 inline void overflow_fixnum_multiply(fixnum x, fixnum y);
530 inline cell from_signed_cell(fixnum x);
531 inline cell from_unsigned_cell(cell x);
532 inline cell allot_float(double n);
533 inline bignum* float_to_bignum(cell tagged);
534 inline double untag_float(cell tagged);
535 inline double untag_float_check(cell tagged);
536 inline fixnum float_to_fixnum(cell tagged);
537 inline double fixnum_to_float(cell tagged);
540 template <typename Type> void check_tagged(tagged<Type> t) {
542 type_error(Type::type_number, t.value());
545 template <typename Type> Type* untag_check(cell value) {
546 tagged<Type> t(value);
553 void io_error_if_not_EINTR();
554 FILE* safe_fopen(char* filename, const char* mode);
555 int safe_fgetc(FILE* stream);
556 size_t safe_fread(void* ptr, size_t size, size_t nitems, FILE* stream);
557 void safe_fputc(int c, FILE* stream);
558 size_t safe_fwrite(void* ptr, size_t size, size_t nitems, FILE* stream);
559 int safe_ftell(FILE* stream);
560 void safe_fseek(FILE* stream, off_t offset, int whence);
561 void safe_fflush(FILE* stream);
562 void primitive_fopen();
563 FILE* pop_file_handle();
564 FILE* peek_file_handle();
565 void primitive_fgetc();
566 void primitive_fread();
567 void primitive_fputc();
568 void primitive_fwrite();
569 void primitive_ftell();
570 void primitive_fseek();
571 void primitive_fflush();
572 void primitive_fclose();
575 cell compute_entry_point_address(cell obj);
576 cell compute_entry_point_pic_address(word* w, cell tagged_quot);
577 cell compute_entry_point_pic_address(cell w_);
578 cell compute_entry_point_pic_tail_address(cell w_);
579 cell compute_external_address(instruction_operand op);
581 cell code_block_owner(code_block* compiled);
582 void update_word_references(code_block* compiled, bool reset_inline_caches);
583 void undefined_symbol();
584 cell compute_dlsym_address(array* literals, cell index, bool toc);
585 cell compute_vm_address(cell arg);
586 cell lookup_external_address(relocation_type rel_type,
587 code_block* compiled,
590 cell compute_here_address(cell arg, cell offset, code_block* compiled);
591 void initialize_code_block(code_block* compiled, cell literals);
592 void initialize_code_block(code_block* compiled);
593 void fixup_labels(array* labels, code_block* compiled);
594 code_block* allot_code_block(cell size, code_block_type type);
595 code_block* add_code_block(code_block_type type, cell code_, cell labels_,
596 cell owner_, cell relocation_, cell parameters_,
597 cell literals_, cell frame_size_untagged);
600 template <typename Iterator> void each_code_block(Iterator& iter) {
601 code->allocator->iterate(iter);
604 void update_code_heap_words(bool reset_inline_caches);
605 void initialize_code_blocks();
606 void primitive_modify_code_heap();
607 void primitive_code_room();
608 void primitive_strip_stack_traces();
610 void primitive_code_blocks();
613 void init_callbacks(cell size);
614 void primitive_free_callback();
615 void primitive_callback();
616 void primitive_callback_room();
619 void init_objects(image_header* h);
620 void load_data_heap(FILE* file, image_header* h, vm_parameters* p);
621 void load_code_heap(FILE* file, image_header* h, vm_parameters* p);
622 bool save_image(const vm_char* saving_filename, const vm_char* filename);
623 void primitive_save_image();
624 void fixup_data(cell data_offset, cell code_offset);
625 void fixup_code(cell data_offset, cell code_offset);
626 FILE* open_image(vm_parameters* p);
627 void load_image(vm_parameters* p);
628 bool read_embedded_image_footer(FILE* file, embedded_image_footer* footer);
629 bool embedded_image_p();
631 template <typename Iterator, typename Fixup>
632 void iterate_callstack_object(callstack* stack_, Iterator& iterator,
634 template <typename Iterator>
635 void iterate_callstack_object(callstack* stack_, Iterator& iterator);
637 callstack* allot_callstack(cell size);
638 cell second_from_top_stack_frame(context* ctx);
639 cell capture_callstack(context* ctx);
640 void primitive_callstack_for();
641 void primitive_callstack_to_array();
642 void primitive_innermost_stack_frame_executing();
643 void primitive_innermost_stack_frame_scan();
644 void primitive_set_innermost_stack_frame_quotation();
645 void primitive_callstack_bounds();
647 template <typename Iterator, typename Fixup>
648 void iterate_callstack(context* ctx, Iterator& iterator, Fixup& fixup);
649 template <typename Iterator>
650 void iterate_callstack(context* ctx, Iterator& iterator);
653 void dispatch_signal_handler(cell* sp, cell* pc, cell newpc);
654 #if defined(FACTOR_X86) || defined(FACTOR_64)
655 void dispatch_non_resumable_signal(cell* sp, cell* pc,
658 void dispatch_resumable_signal(cell* sp, cell* pc, cell handler);
662 char* pinned_alien_offset(cell obj);
663 cell allot_alien(cell delegate_, cell displacement);
664 cell allot_alien(cell address);
665 void primitive_displaced_alien();
666 void primitive_alien_address();
667 void* alien_pointer();
668 void primitive_dlopen();
669 void primitive_dlsym();
670 void primitive_dlsym_raw();
671 void primitive_dlclose();
672 void primitive_dll_validp();
673 char* alien_offset(cell obj);
676 void primitive_jit_compile();
677 cell lazy_jit_compile_entry_point();
678 void primitive_array_to_quotation();
679 void primitive_quotation_code();
680 code_block* jit_compile_quotation(cell owner_, cell quot_, bool relocating);
681 void jit_compile_quotation(cell quot_, bool relocating);
682 fixnum quot_code_offset_to_scan(cell quot_, cell offset);
683 cell lazy_jit_compile(cell quot);
684 bool quotation_compiled_p(quotation* quot);
685 void primitive_quotation_compiled_p();
686 void initialize_all_quotations();
689 cell search_lookup_alist(cell table, cell klass);
690 cell search_lookup_hash(cell table, cell klass, cell hashcode);
691 cell nth_superclass(tuple_layout* layout, fixnum echelon);
692 cell nth_hashcode(tuple_layout* layout, fixnum echelon);
693 cell lookup_tuple_method(cell obj, cell methods);
694 cell lookup_method(cell obj, cell methods);
695 void primitive_lookup_method();
696 cell object_class(cell obj);
697 cell method_cache_hashcode(cell klass, array* array);
698 void update_method_cache(cell cache, cell klass, cell method);
699 void primitive_mega_cache_miss();
700 void primitive_reset_dispatch_stats();
701 void primitive_dispatch_stats();
704 void init_inline_caching(int max_size);
705 void deallocate_inline_cache(cell return_address);
706 cell determine_inline_cache_type(array* cache_entries);
707 void update_pic_count(cell type);
708 code_block* compile_inline_cache(fixnum index, cell generic_word_,
709 cell methods_, cell cache_entries_,
711 cell inline_cache_size(cell cache_entries);
712 cell add_inline_cache_entry(cell cache_entries_, cell klass_, cell method_);
713 void update_pic_transitions(cell pic_size);
714 cell inline_cache_miss(cell return_address);
717 void c_to_factor(cell quot);
718 void unwind_native_frames(cell quot, cell to);
719 cell get_fpu_state();
720 void set_fpu_state(cell state);
723 void default_parameters(vm_parameters* p);
724 bool factor_arg(const vm_char* str, const vm_char* arg, cell* value);
725 void init_parameters_from_args(vm_parameters* p, int argc, vm_char** argv);
726 void prepare_boot_image();
727 void init_factor(vm_parameters* p);
728 void pass_args_to_factor(int argc, vm_char** argv);
729 void start_factor(vm_parameters* p);
731 void start_embedded_factor(vm_parameters* p);
732 void start_standalone_factor(int argc, vm_char** argv);
733 char* factor_eval_string(char* string);
734 void factor_eval_free(char* result);
736 void factor_sleep(long us);
739 void primitive_existsp();
741 void ffi_dlopen(dll* dll);
742 cell ffi_dlsym(dll* dll, symbol_char* symbol);
743 cell ffi_dlsym_raw(dll* dll, symbol_char* symbol);
744 void ffi_dlclose(dll* dll);
745 void c_to_factor_toplevel(cell quot);
747 void start_sampling_profiler_timer();
748 void end_sampling_profiler_timer();
752 HANDLE sampler_thread;
753 void sampler_thread_loop();
755 const vm_char* vm_executable_path();
756 const vm_char* default_image_path();
757 BOOL windows_stat(vm_char* path);
759 LONG exception_handler(PEXCEPTION_RECORD e, void* frame, PCONTEXT c,
763 void dispatch_signal(void* uap, void(handler)());
764 void unix_init_signals();
768 void call_fault_handler(exception_type_t exception,
769 exception_data_type_t code,
770 MACH_EXC_STATE_TYPE* exc_state,
771 MACH_THREAD_STATE_TYPE* thread_state,
772 MACH_FLOAT_STATE_TYPE* float_state);
775 factor_vm(THREADHANDLE thread_id);