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 memory_protection_error(cell pc, cell addr);
219 void divide_by_zero_error();
220 void primitive_unimplemented();
221 void memory_signal_handler_impl();
222 void synchronous_signal_handler_impl();
223 void fp_signal_handler_impl();
226 int bignum_equal_p(bignum* x, bignum* y);
227 enum bignum_comparison bignum_compare(bignum* x, bignum* y);
228 bignum* bignum_add(bignum* x, bignum* y);
229 bignum* bignum_subtract(bignum* x, bignum* y);
230 bignum* bignum_square(bignum* x_);
231 bignum* bignum_multiply(bignum* x, bignum* y);
232 void bignum_divide(bignum* numerator, bignum* denominator, bignum** quotient,
234 bignum* bignum_quotient(bignum* numerator, bignum* denominator);
235 bignum* bignum_remainder(bignum* numerator, bignum* denominator);
236 fixnum bignum_to_fixnum_strict(bignum* bn);
237 bignum* double_to_bignum(double x);
238 int bignum_equal_p_unsigned(bignum* x, bignum* y);
239 enum bignum_comparison bignum_compare_unsigned(bignum* x, bignum* y);
240 bignum* bignum_add_unsigned(bignum* x_, bignum* y_, int negative_p);
241 bignum* bignum_subtract_unsigned(bignum* x_, bignum* y_);
242 bignum* bignum_multiply_unsigned(bignum* x_, bignum* y_, int negative_p);
243 bignum* bignum_multiply_unsigned_small_factor(bignum* x, bignum_digit_type y,
245 void bignum_destructive_add(bignum* bn, bignum_digit_type n);
246 void bignum_destructive_scale_up(bignum* bn, bignum_digit_type factor);
247 void bignum_divide_unsigned_large_denominator(
248 bignum* numerator_, bignum* denominator_, bignum** quotient,
249 bignum** remainder, int q_negative_p, int r_negative_p);
250 void bignum_divide_unsigned_normalized(bignum* u, bignum* v, bignum* q);
251 bignum_digit_type bignum_divide_subtract(bignum_digit_type* v_start,
252 bignum_digit_type* v_end,
253 bignum_digit_type guess,
254 bignum_digit_type* u_start);
255 void bignum_divide_unsigned_medium_denominator(
256 bignum* numerator_, bignum_digit_type denominator, bignum** quotient,
257 bignum** remainder, int q_negative_p, int r_negative_p);
258 void bignum_destructive_normalization(bignum* source, bignum* target,
260 void bignum_destructive_unnormalization(bignum* bn, int shift_right);
261 bignum_digit_type bignum_digit_divide(
262 bignum_digit_type uh, bignum_digit_type ul, bignum_digit_type v,
263 bignum_digit_type* q) /* return value */;
264 bignum_digit_type bignum_digit_divide_subtract(bignum_digit_type v1,
265 bignum_digit_type v2,
266 bignum_digit_type guess,
267 bignum_digit_type* u);
268 void bignum_divide_unsigned_small_denominator(
269 bignum* numerator_, bignum_digit_type denominator, bignum** quotient,
270 bignum** remainder, int q_negative_p, int r_negative_p);
271 bignum_digit_type bignum_destructive_scale_down(
272 bignum* bn, bignum_digit_type denominator);
273 bignum* bignum_remainder_unsigned_small_denominator(bignum* n,
276 bignum* bignum_digit_to_bignum(bignum_digit_type digit, int negative_p);
277 bignum* allot_bignum(bignum_length_type length, int negative_p);
278 bignum* allot_bignum_zeroed(bignum_length_type length, int negative_p);
279 bignum* bignum_shorten_length(bignum* bn, bignum_length_type length);
280 bignum* bignum_trim(bignum* bn);
281 bignum* bignum_new_sign(bignum* x_, int negative_p);
282 bignum* bignum_maybe_new_sign(bignum* x_, int negative_p);
283 void bignum_destructive_copy(bignum* source, bignum* target);
284 bignum* bignum_bitwise_not(bignum* x_);
285 bignum* bignum_arithmetic_shift(bignum* arg1, fixnum n);
286 bignum* bignum_bitwise_and(bignum* arg1, bignum* arg2);
287 bignum* bignum_bitwise_ior(bignum* arg1, bignum* arg2);
288 bignum* bignum_bitwise_xor(bignum* arg1, bignum* arg2);
289 bignum* bignum_magnitude_ash(bignum* arg1_, fixnum n);
290 bignum* bignum_pospos_bitwise_op(int op, bignum* arg1_, bignum* arg2_);
291 bignum* bignum_posneg_bitwise_op(int op, bignum* arg1_, bignum* arg2_);
292 bignum* bignum_negneg_bitwise_op(int op, bignum* arg1_, bignum* arg2_);
293 void bignum_negate_magnitude(bignum* arg);
294 bignum* bignum_integer_length(bignum* x_);
295 int bignum_logbitp(int shift, bignum* arg);
296 int bignum_unsigned_logbitp(int shift, bignum* bn);
297 bignum* bignum_gcd(bignum* a_, bignum* b_);
300 void init_card_decks();
301 void set_data_heap(data_heap* data_);
302 void init_data_heap(cell young_size, cell aging_size, cell tenured_size);
303 void primitive_size();
304 data_heap_room data_room();
305 void primitive_data_room();
308 cell instances(cell type);
309 void primitive_all_instances();
311 template <typename Generation, typename Iterator>
312 inline void each_object(Generation* gen, Iterator& iterator) {
313 cell obj = gen->first_object();
315 iterator((object*)obj);
316 obj = gen->next_object_after(obj);
320 template <typename Iterator> inline void each_object(Iterator& iterator) {
322 /* The nursery can't be iterated because there may be gaps between
323 the objects (see factor_vm::reallot_array) so we require it to
325 FACTOR_ASSERT(data->nursery->occupied_space() == 0);
328 each_object(data->tenured, iterator);
329 each_object(data->aging, iterator);
333 template <typename Iterator>
334 inline void each_object_each_slot(Iterator& iterator) {
335 auto each_object_func = [&](object* obj) {
336 auto each_slot_func = [&](cell* slot) {
339 obj->each_slot(each_slot_func);
341 each_object(each_object_func);
344 /* the write barrier must be called any time we are potentially storing a
345 pointer from an older generation to a younger one */
346 inline void write_barrier(cell* slot_ptr) {
347 *(char*)(cards_offset + ((cell)slot_ptr >> card_bits)) = card_mark_mask;
348 *(char*)(decks_offset + ((cell)slot_ptr >> deck_bits)) = card_mark_mask;
351 inline void write_barrier(object* obj, cell size) {
352 cell start = (cell)obj & (~card_size + 1);
353 cell end = ((cell)obj + size + card_size - 1) & (~card_size + 1);
355 for (cell offset = start; offset < end; offset += card_size)
356 write_barrier((cell*)offset);
360 void check_data_heap();
364 void set_current_gc_op(gc_op op);
365 void start_gc_again();
366 void collect_nursery();
367 void collect_aging();
368 void collect_to_tenured();
369 void update_code_roots_for_sweep();
370 void update_code_roots_for_compaction();
371 void collect_mark_impl();
372 void collect_sweep_impl();
374 void collect_compact_impl();
375 void collect_compact();
376 void collect_growing_heap(cell requested_size);
377 void gc(gc_op op, cell requested_size);
378 void primitive_minor_gc();
379 void primitive_full_gc();
380 void primitive_compact_gc();
381 void primitive_enable_gc_events();
382 void primitive_disable_gc_events();
383 object* allot_object(cell type, cell size);
384 object* allot_large_object(cell type, cell size);
386 /* Allocates memory */
387 template <typename Type> Type* allot(cell size) {
388 return (Type*)allot_object(Type::type_number, size);
392 template <typename Array> Array* allot_uninitialized_array(cell capacity);
393 template <typename Array>
394 bool reallot_array_in_place_p(Array* array, cell capacity);
395 template <typename Array> Array* reallot_array(Array* array_, cell capacity);
398 void print_chars(ostream& out, string* str);
399 void print_word(ostream& out, word* word, cell nesting);
400 void print_factor_string(ostream& out, string* str);
401 void print_array(ostream& out, array* array, cell nesting);
402 void print_byte_array(ostream& out, byte_array* array, cell nesting);
403 void print_tuple(ostream& out, tuple* tuple, cell nesting);
404 void print_alien(ostream& out, alien* alien, cell nesting);
405 void print_nested_obj(ostream& out, cell obj, fixnum nesting);
406 void print_obj(ostream& out, cell obj);
407 void print_objects(ostream& out, cell* start, cell* end);
408 void print_datastack(ostream& out);
409 void print_retainstack(ostream& out);
410 void print_callstack(ostream& out);
411 void print_callstack_object(ostream& out, callstack* obj);
412 void dump_cell(ostream& out, cell x);
413 void dump_memory(ostream& out, cell from, cell to);
414 template <typename Generation>
415 void dump_generation(ostream& out, const char* name, Generation* gen);
416 void dump_generations(ostream& out);
417 void dump_objects(ostream& out, cell type);
418 void dump_edges(ostream& out);
419 void find_data_references(ostream& out, cell look_for_);
420 void dump_code_heap(ostream& out);
421 void factorbug_usage(bool advanced_p);
423 void primitive_die();
426 inline void set_array_nth(array* array, cell slot, cell value);
427 array* allot_array(cell capacity, cell fill_);
428 void primitive_array();
429 cell allot_array_4(cell v1_, cell v2_, cell v3_, cell v4_);
430 void primitive_resize_array();
431 cell std_vector_to_array(std::vector<cell>& elements);
434 string* allot_string_internal(cell capacity);
435 void fill_string(string* str_, cell start, cell capacity, cell fill);
436 string* allot_string(cell capacity, cell fill);
437 void primitive_string();
438 bool reallot_string_in_place_p(string* str, cell capacity);
439 string* reallot_string(string* str_, cell capacity);
440 void primitive_resize_string();
441 void primitive_set_string_nth_fast();
444 cell tag_boolean(cell untagged) {
445 return (untagged ? true_object : false_object);
449 byte_array* allot_byte_array(cell size);
450 void primitive_byte_array();
451 void primitive_uninitialized_byte_array();
452 void primitive_resize_byte_array();
454 template <typename Type> byte_array* byte_array_from_value(Type* value);
457 void primitive_tuple();
458 void primitive_tuple_boa();
461 word* allot_word(cell name_, cell vocab_, cell hashcode_);
462 void primitive_word();
463 void primitive_word_code();
464 void primitive_word_optimized_p();
465 void primitive_wrapper();
466 void jit_compile_word(cell word_, cell def_, bool relocating);
467 cell find_all_words();
468 void compile_all_words();
471 void primitive_bignum_to_fixnum();
472 void primitive_bignum_to_fixnum_strict();
473 void primitive_float_to_fixnum();
474 void primitive_fixnum_divint();
475 void primitive_fixnum_divmod();
476 bignum* fixnum_to_bignum(fixnum);
477 bignum* cell_to_bignum(cell);
478 bignum* long_long_to_bignum(int64_t n);
479 bignum* ulong_long_to_bignum(uint64_t n);
480 inline fixnum sign_mask(fixnum x);
481 inline fixnum branchless_max(fixnum x, fixnum y);
482 inline fixnum branchless_abs(fixnum x);
483 void primitive_fixnum_shift();
484 void primitive_fixnum_to_bignum();
485 void primitive_float_to_bignum();
486 void primitive_bignum_eq();
487 void primitive_bignum_add();
488 void primitive_bignum_subtract();
489 void primitive_bignum_multiply();
490 void primitive_bignum_divint();
491 void primitive_bignum_divmod();
492 void primitive_bignum_mod();
493 void primitive_bignum_gcd();
494 void primitive_bignum_and();
495 void primitive_bignum_or();
496 void primitive_bignum_xor();
497 void primitive_bignum_shift();
498 void primitive_bignum_less();
499 void primitive_bignum_lesseq();
500 void primitive_bignum_greater();
501 void primitive_bignum_greatereq();
502 void primitive_bignum_not();
503 void primitive_bignum_bitp();
504 void primitive_bignum_log2();
505 inline cell unbox_array_size();
506 void primitive_fixnum_to_float();
507 void primitive_format_float();
508 void primitive_float_eq();
509 void primitive_float_add();
510 void primitive_float_subtract();
511 void primitive_float_multiply();
512 void primitive_float_divfloat();
513 void primitive_float_less();
514 void primitive_float_lesseq();
515 void primitive_float_greater();
516 void primitive_float_greatereq();
517 void primitive_float_bits();
518 void primitive_bits_float();
519 void primitive_double_bits();
520 void primitive_bits_double();
521 fixnum to_fixnum(cell tagged);
522 fixnum to_fixnum_strict(cell tagged);
523 cell to_cell(cell tagged);
524 cell from_signed_8(int64_t n);
525 int64_t to_signed_8(cell obj);
526 cell from_unsigned_8(uint64_t n);
527 uint64_t to_unsigned_8(cell obj);
528 float to_float(cell value);
529 double to_double(cell value);
530 inline void overflow_fixnum_add(fixnum x, fixnum y);
531 inline void overflow_fixnum_subtract(fixnum x, fixnum y);
532 inline void overflow_fixnum_multiply(fixnum x, fixnum y);
533 inline cell from_signed_cell(fixnum x);
534 inline cell from_unsigned_cell(cell x);
535 inline cell allot_float(double n);
536 inline bignum* float_to_bignum(cell tagged);
537 inline double untag_float(cell tagged);
538 inline double untag_float_check(cell tagged);
539 inline fixnum float_to_fixnum(cell tagged);
540 inline double fixnum_to_float(cell tagged);
543 template <typename Type> Type* untag_check(cell value);
547 void io_error_if_not_EINTR();
548 FILE* safe_fopen(char* filename, char* mode);
549 int safe_fgetc(FILE* stream);
550 size_t safe_fread(void* ptr, size_t size, size_t nitems, FILE* stream);
551 void safe_fputc(int c, FILE* stream);
552 size_t safe_fwrite(void* ptr, size_t size, size_t nitems, FILE* stream);
553 int safe_ftell(FILE* stream);
554 void safe_fseek(FILE* stream, off_t offset, int whence);
555 void safe_fflush(FILE* stream);
556 void safe_fclose(FILE* stream);
557 void primitive_fopen();
558 FILE* pop_file_handle();
559 FILE* peek_file_handle();
560 void primitive_fgetc();
561 void primitive_fread();
562 void primitive_fputc();
563 void primitive_fwrite();
564 void primitive_ftell();
565 void primitive_fseek();
566 void primitive_fflush();
567 void primitive_fclose();
570 cell compute_entry_point_address(cell obj);
571 cell compute_entry_point_pic_address(word* w, cell tagged_quot);
572 cell compute_entry_point_pic_address(cell w_);
573 cell compute_entry_point_pic_tail_address(cell w_);
574 cell compute_external_address(instruction_operand op);
576 cell code_block_owner(code_block* compiled);
577 void update_word_references(code_block* compiled, bool reset_inline_caches);
578 void undefined_symbol();
579 cell compute_dlsym_address(array* literals, cell index);
581 cell compute_dlsym_toc_address(array* literals, cell index);
583 cell compute_vm_address(cell arg);
584 cell lookup_external_address(relocation_type rel_type,
585 code_block* compiled,
588 cell compute_here_address(cell arg, cell offset, code_block* compiled);
589 void initialize_code_block(code_block* compiled, cell literals);
590 void initialize_code_block(code_block* compiled);
591 void fixup_labels(array* labels, code_block* compiled);
592 code_block* allot_code_block(cell size, code_block_type type);
593 code_block* add_code_block(code_block_type type, cell code_, cell labels_,
594 cell owner_, cell relocation_, cell parameters_,
595 cell literals_, cell frame_size_untagged);
598 template <typename Iterator> void each_code_block(Iterator& iter) {
599 code->allocator->iterate(iter);
602 void update_code_heap_words(bool reset_inline_caches);
603 void initialize_code_blocks();
604 void primitive_modify_code_heap();
605 void primitive_code_room();
606 void primitive_strip_stack_traces();
608 void primitive_code_blocks();
611 void init_callbacks(cell size);
612 void primitive_free_callback();
613 void primitive_callback();
614 void primitive_callback_room();
617 void init_objects(image_header* h);
618 void load_data_heap(FILE* file, image_header* h, vm_parameters* p);
619 void load_code_heap(FILE* file, image_header* h, vm_parameters* p);
620 bool save_image(const vm_char* saving_filename, const vm_char* filename);
621 void primitive_save_image();
622 void fixup_data(cell data_offset, cell code_offset);
623 void fixup_code(cell data_offset, cell code_offset);
624 FILE* open_image(vm_parameters* p);
625 void load_image(vm_parameters* p);
626 bool read_embedded_image_footer(FILE* file, embedded_image_footer* footer);
627 bool embedded_image_p();
629 template <typename Iterator, typename Fixup>
630 void iterate_callstack_object(callstack* stack_, Iterator& iterator,
632 template <typename Iterator>
633 void iterate_callstack_object(callstack* stack_, Iterator& iterator);
635 callstack* allot_callstack(cell size);
636 cell second_from_top_stack_frame(context* ctx);
637 cell capture_callstack(context* ctx);
638 void primitive_callstack_for();
639 void primitive_callstack_to_array();
640 void primitive_innermost_stack_frame_executing();
641 void primitive_innermost_stack_frame_scan();
642 void primitive_set_innermost_stack_frame_quotation();
643 void primitive_callstack_bounds();
645 template <typename Iterator, typename Fixup>
646 void iterate_callstack(context* ctx, Iterator& iterator, Fixup& fixup);
647 template <typename Iterator>
648 void iterate_callstack(context* ctx, Iterator& iterator);
651 void dispatch_signal_handler(cell* sp, cell* pc, cell newpc);
652 #if defined(FACTOR_X86) || defined(FACTOR_64)
653 void dispatch_non_resumable_signal(cell* sp, cell* pc,
656 void dispatch_resumable_signal(cell* sp, cell* pc, cell handler);
660 char* pinned_alien_offset(cell obj);
661 cell allot_alien(cell delegate_, cell displacement);
662 cell allot_alien(cell address);
663 void primitive_displaced_alien();
664 void primitive_alien_address();
665 void* alien_pointer();
666 void primitive_dlopen();
667 void primitive_dlsym();
668 void primitive_dlsym_raw();
669 void primitive_dlclose();
670 void primitive_dll_validp();
671 char* alien_offset(cell obj);
674 void primitive_jit_compile();
675 cell lazy_jit_compile_entry_point();
676 void primitive_array_to_quotation();
677 void primitive_quotation_code();
678 code_block* jit_compile_quotation(cell owner_, cell quot_, bool relocating);
679 void jit_compile_quotation(cell quot_, bool relocating);
680 fixnum quot_code_offset_to_scan(cell quot_, cell offset);
681 cell lazy_jit_compile(cell quot);
682 bool quotation_compiled_p(quotation* quot);
683 void primitive_quotation_compiled_p();
684 void initialize_all_quotations();
687 cell search_lookup_alist(cell table, cell klass);
688 cell search_lookup_hash(cell table, cell klass, cell hashcode);
689 cell nth_superclass(tuple_layout* layout, fixnum echelon);
690 cell nth_hashcode(tuple_layout* layout, fixnum echelon);
691 cell lookup_tuple_method(cell obj, cell methods);
692 cell lookup_method(cell obj, cell methods);
693 void primitive_lookup_method();
694 cell object_class(cell obj);
695 cell method_cache_hashcode(cell klass, array* array);
696 void update_method_cache(cell cache, cell klass, cell method);
697 void primitive_mega_cache_miss();
698 void primitive_reset_dispatch_stats();
699 void primitive_dispatch_stats();
702 void init_inline_caching(int max_size);
703 void deallocate_inline_cache(cell return_address);
704 cell determine_inline_cache_type(array* cache_entries);
705 void update_pic_count(cell type);
706 code_block* compile_inline_cache(fixnum index, cell generic_word_,
707 cell methods_, cell cache_entries_,
709 cell inline_cache_size(cell cache_entries);
710 cell add_inline_cache_entry(cell cache_entries_, cell klass_, cell method_);
711 void update_pic_transitions(cell pic_size);
712 cell inline_cache_miss(cell return_address);
715 void c_to_factor(cell quot);
716 void unwind_native_frames(cell quot, cell to);
717 cell get_fpu_state();
718 void set_fpu_state(cell state);
721 void default_parameters(vm_parameters* p);
722 bool factor_arg(const vm_char* str, const vm_char* arg, cell* value);
723 void init_parameters_from_args(vm_parameters* p, int argc, vm_char** argv);
724 void prepare_boot_image();
725 void init_factor(vm_parameters* p);
726 void pass_args_to_factor(int argc, vm_char** argv);
727 void start_factor(vm_parameters* p);
729 void start_embedded_factor(vm_parameters* p);
730 void start_standalone_factor(int argc, vm_char** argv);
731 char* factor_eval_string(char* string);
732 void factor_eval_free(char* result);
734 void factor_sleep(long us);
737 void primitive_existsp();
738 void move_file(const vm_char* path1, const vm_char* path2);
740 void ffi_dlopen(dll* dll);
741 cell ffi_dlsym(dll* dll, symbol_char* symbol);
742 cell ffi_dlsym_raw(dll* dll, symbol_char* symbol);
744 cell ffi_dlsym_toc(dll* dll, symbol_char* symbol);
746 void ffi_dlclose(dll* dll);
747 void c_to_factor_toplevel(cell quot);
749 void start_sampling_profiler_timer();
750 void end_sampling_profiler_timer();
754 HANDLE sampler_thread;
755 void sampler_thread_loop();
757 const vm_char* vm_executable_path();
758 const vm_char* default_image_path();
759 void windows_image_path(vm_char* full_path, vm_char* temp_path,
760 unsigned int length);
761 BOOL windows_stat(vm_char* path);
763 LONG exception_handler(PEXCEPTION_RECORD e, void* frame, PCONTEXT c,
767 void dispatch_signal(void* uap, void(handler)());
768 void unix_init_signals();
772 void call_fault_handler(exception_type_t exception,
773 exception_data_type_t code,
774 MACH_EXC_STATE_TYPE* exc_state,
775 MACH_THREAD_STATE_TYPE* thread_state,
776 MACH_FLOAT_STATE_TYPE* float_state);
779 factor_vm(THREADHANDLE thread_id);