9 // THESE FIELDS ARE ACCESSED DIRECTLY FROM FACTOR. See:
11 // basis/compiler/constants/constants.factor
16 /* Spare context -- for callbacks */
19 /* New objects are allocated here */
20 nursery_space nursery;
22 /* Add this to a shifted address to compute write barrier offsets */
26 /* cdecl signal handler address, used by signal handler subprimitives */
27 cell signal_handler_addr;
29 /* are we handling a memory error? used to detect double faults */
32 /* Various special objects, accessed by special-object and
33 set-special-object primitives */
34 cell special_objects[special_object_count];
36 // THESE FIELDS ARE ACCESSED DIRECTLY FROM FACTOR.
40 /* Handle to the main thread we run in */
43 /* Data stack and retain stack sizes */
44 cell datastack_size, retainstack_size, callstack_size;
46 /* Stack of callback IDs */
47 std::vector<int> callback_ids;
49 /* Next callback ID */
52 /* List of callback function descriptors for PPC */
53 std::list<void**> function_descriptors;
55 /* Pooling unused contexts to make context allocation cheaper */
56 std::list<context*> unused_contexts;
58 /* Active contexts, for tracing by the GC */
59 std::set<context*> active_contexts;
61 /* Canonical truth value. In Factor, 't' */
64 /* External entry points */
65 c_to_factor_func_type c_to_factor_func;
67 /* Is profiling enabled? */
68 volatile cell sampling_profiler_p;
69 fixnum samples_per_second;
71 /* Global variables used to pass fault handler state from signal handler
73 bool signal_resumable;
75 cell signal_fault_addr;
77 unsigned int signal_fpu_status;
79 /* Pipe used to notify Factor multiplexer of signals */
80 int signal_pipe_input, signal_pipe_output;
82 /* State kept by the sampling profiler */
83 std::vector<profiling_sample> samples;
84 std::vector<cell> sample_callstacks;
86 /* GC is off during heap walking */
95 /* Pinned callback stubs */
96 callback_heap* callbacks;
98 /* Only set if we're performing a GC */
100 volatile cell current_gc_p;
102 /* Set if we're in the jit */
103 volatile fixnum current_jit_count;
106 std::vector<cell> mark_stack;
108 /* If not NULL, we push GC events here */
109 std::vector<gc_event>* gc_events;
111 /* If a runtime function needs to call another function which potentially
112 allocates memory, it must wrap any references to the data and code
113 heaps with data_root and code_root smart pointers, which register
114 themselves here. See data_roots.hpp and code_roots.hpp */
115 std::vector<data_root_range> data_roots;
116 std::vector<cell> bignum_roots;
117 std::vector<code_root*> code_roots;
121 bool fep_help_was_shown;
125 /* Canonical bignums */
130 /* Method dispatch statistics */
131 dispatch_statistics dispatch_stats;
133 /* Number of entries in a polymorphic inline cache */
136 /* Incrementing object counter for identity hashing */
139 /* Sanity check to ensure that monotonic counter doesn't decrease */
140 uint64_t last_nano_count;
142 /* Stack for signal handlers, only used on Unix */
143 segment* signal_callstack_seg;
145 /* Are we already handling a fault? Used to catch double memory faults */
146 static bool fatal_erroring_p;
148 /* Safepoint state */
149 volatile safepoint_state safepoint;
152 context* new_context();
153 void init_context(context* ctx);
154 void delete_context(context* old_context);
155 void init_contexts(cell datastack_size_, cell retainstack_size_,
156 cell callstack_size_);
157 void delete_contexts();
158 cell begin_callback(cell quot);
160 void primitive_current_callback();
161 void primitive_context_object();
162 void primitive_context_object_for();
163 void primitive_set_context_object();
164 cell stack_to_array(cell bottom, cell top);
165 cell datastack_to_array(context* ctx);
166 void primitive_datastack();
167 void primitive_datastack_for();
168 cell retainstack_to_array(context* ctx);
169 void primitive_retainstack();
170 void primitive_retainstack_for();
171 cell array_to_stack(array* array, cell bottom);
172 void set_datastack(context* ctx, array* array);
173 void primitive_set_datastack();
174 void set_retainstack(context* ctx, array* array);
175 void primitive_set_retainstack();
176 void primitive_check_datastack();
177 void primitive_load_locals();
179 template <typename Iterator, typename Fixup>
180 void iterate_active_callstacks(Iterator& iter, Fixup& fixup) {
181 std::set<context*>::const_iterator begin = active_contexts.begin();
182 std::set<context*>::const_iterator end = active_contexts.end();
183 while (begin != end) {
184 iterate_callstack(*begin++, iter, fixup);
189 void primitive_exit();
190 void primitive_nano_count();
191 void primitive_sleep();
192 void primitive_set_slot();
195 void primitive_special_object();
196 void primitive_set_special_object();
197 void primitive_identity_hashcode();
198 void compute_identity_hashcode(object* obj);
199 void primitive_compute_identity_hashcode();
200 cell object_size(cell tagged);
201 cell clone_object(cell obj_);
202 void primitive_clone();
203 void primitive_become();
206 void clear_samples();
207 void record_sample(bool prolog_p);
208 void record_callstack_sample(cell* begin, cell* end, bool prolog_p);
209 void start_sampling_profiler(fixnum rate);
210 void end_sampling_profiler();
211 void set_sampling_profiler(fixnum rate);
212 void primitive_sampling_profiler();
213 void primitive_get_samples();
214 void primitive_clear_samples();
217 void general_error(vm_error_type error, cell arg1, cell arg2);
218 void type_error(cell type, cell tagged);
219 void not_implemented_error();
220 void verify_memory_protection_error(cell addr);
221 void memory_protection_error(cell pc, cell addr);
222 void signal_error(cell signal);
223 void divide_by_zero_error();
224 void fp_trap_error(unsigned int fpu_status);
225 void primitive_unimplemented();
226 void memory_signal_handler_impl();
227 void synchronous_signal_handler_impl();
228 void fp_signal_handler_impl();
231 int bignum_equal_p(bignum* x, bignum* y);
232 enum bignum_comparison bignum_compare(bignum* x, bignum* y);
233 bignum* bignum_add(bignum* x, bignum* y);
234 bignum* bignum_subtract(bignum* x, bignum* y);
235 bignum* bignum_square(bignum* x);
236 bignum* bignum_multiply(bignum* x, bignum* y);
237 void bignum_divide(bignum* numerator, bignum* denominator, bignum** quotient,
239 bignum* bignum_quotient(bignum* numerator, bignum* denominator);
240 bignum* bignum_remainder(bignum* numerator, bignum* denominator);
241 cell bignum_to_cell(bignum* bignum);
242 fixnum bignum_to_fixnum(bignum* bignum);
243 int64_t bignum_to_long_long(bignum* bignum);
244 uint64_t bignum_to_ulong_long(bignum* bignum);
245 bignum* double_to_bignum(double x);
246 int bignum_equal_p_unsigned(bignum* x, bignum* y);
247 enum bignum_comparison bignum_compare_unsigned(bignum* x, bignum* y);
248 bignum* bignum_add_unsigned(bignum* x, bignum* y, int negative_p);
249 bignum* bignum_subtract_unsigned(bignum* x, bignum* y);
250 bignum* bignum_multiply_unsigned(bignum* x, bignum* y, int negative_p);
251 bignum* bignum_multiply_unsigned_small_factor(bignum* x, bignum_digit_type y,
253 void bignum_destructive_add(bignum* bignum, bignum_digit_type n);
254 void bignum_destructive_scale_up(bignum* bignum, bignum_digit_type factor);
255 void bignum_divide_unsigned_large_denominator(
256 bignum* numerator, bignum* denominator, bignum** quotient,
257 bignum** remainder, int q_negative_p, int r_negative_p);
258 void bignum_divide_unsigned_normalized(bignum* u, bignum* v, bignum* q);
259 bignum_digit_type bignum_divide_subtract(bignum_digit_type* v_start,
260 bignum_digit_type* v_end,
261 bignum_digit_type guess,
262 bignum_digit_type* u_start);
263 void bignum_divide_unsigned_medium_denominator(
264 bignum* numerator, bignum_digit_type denominator, bignum** quotient,
265 bignum** remainder, int q_negative_p, int r_negative_p);
266 void bignum_destructive_normalization(bignum* source, bignum* target,
268 void bignum_destructive_unnormalization(bignum* bignum, int shift_right);
269 bignum_digit_type bignum_digit_divide(
270 bignum_digit_type uh, bignum_digit_type ul, bignum_digit_type v,
271 bignum_digit_type* q) /* return value */;
272 bignum_digit_type bignum_digit_divide_subtract(bignum_digit_type v1,
273 bignum_digit_type v2,
274 bignum_digit_type guess,
275 bignum_digit_type* u);
276 void bignum_divide_unsigned_small_denominator(
277 bignum* numerator, bignum_digit_type denominator, bignum** quotient,
278 bignum** remainder, int q_negative_p, int r_negative_p);
279 bignum_digit_type bignum_destructive_scale_down(
280 bignum* bignum, bignum_digit_type denominator);
281 bignum* bignum_remainder_unsigned_small_denominator(bignum* n,
284 bignum* bignum_digit_to_bignum(bignum_digit_type digit, int negative_p);
285 bignum* allot_bignum(bignum_length_type length, int negative_p);
286 bignum* allot_bignum_zeroed(bignum_length_type length, int negative_p);
287 bignum* bignum_shorten_length(bignum* bignum, bignum_length_type length);
288 bignum* bignum_trim(bignum* bignum);
289 bignum* bignum_new_sign(bignum* x, int negative_p);
290 bignum* bignum_maybe_new_sign(bignum* x, int negative_p);
291 void bignum_destructive_copy(bignum* source, bignum* target);
292 bignum* bignum_bitwise_not(bignum* x);
293 bignum* bignum_arithmetic_shift(bignum* arg1, fixnum n);
294 bignum* bignum_bitwise_and(bignum* arg1, bignum* arg2);
295 bignum* bignum_bitwise_ior(bignum* arg1, bignum* arg2);
296 bignum* bignum_bitwise_xor(bignum* arg1, bignum* arg2);
297 bignum* bignum_magnitude_ash(bignum* arg1, fixnum n);
298 bignum* bignum_pospos_bitwise_op(int op, bignum* arg1, bignum* arg2);
299 bignum* bignum_posneg_bitwise_op(int op, bignum* arg1, bignum* arg2);
300 bignum* bignum_negneg_bitwise_op(int op, bignum* arg1, bignum* arg2);
301 void bignum_negate_magnitude(bignum* arg);
302 bignum* bignum_integer_length(bignum* x);
303 int bignum_logbitp(int shift, bignum* arg);
304 int bignum_unsigned_logbitp(int shift, bignum* bignum);
305 bignum* bignum_gcd(bignum* a, bignum* b);
308 void init_card_decks();
309 void set_data_heap(data_heap* data_);
310 void init_data_heap(cell young_size, cell aging_size, cell tenured_size);
311 void primitive_size();
312 data_heap_room data_room();
313 void primitive_data_room();
316 cell instances(cell type);
317 void primitive_all_instances();
319 template <typename Generation, typename Iterator>
320 inline void each_object(Generation* gen, Iterator& iterator) {
321 cell obj = gen->first_object();
323 iterator((object*)obj);
324 obj = gen->next_object_after(obj);
328 template <typename Iterator> inline void each_object(Iterator& iterator) {
331 each_object(data->tenured, iterator);
332 each_object(data->aging, iterator);
333 each_object(data->nursery, iterator);
338 /* the write barrier must be called any time we are potentially storing a
339 pointer from an older generation to a younger one */
340 inline void write_barrier(cell* slot_ptr) {
341 *(char*)(cards_offset + ((cell)slot_ptr >> card_bits)) = card_mark_mask;
342 *(char*)(decks_offset + ((cell)slot_ptr >> deck_bits)) = card_mark_mask;
345 inline void write_barrier(object* obj, cell size) {
346 cell start = (cell)obj & (~card_size + 1);
347 cell end = ((cell)obj + size + card_size - 1) & (~card_size + 1);
349 for (cell offset = start; offset < end; offset += card_size)
350 write_barrier((cell*)offset);
354 void check_data_heap();
358 void set_current_gc_op(gc_op op);
359 void start_gc_again();
360 void update_code_heap_for_minor_gc(std::set<code_block*>* remembered_set);
361 void collect_nursery();
362 void collect_aging();
363 void collect_to_tenured();
364 void update_code_roots_for_sweep();
365 void update_code_roots_for_compaction();
366 void collect_mark_impl(bool trace_contexts_p);
367 void collect_sweep_impl();
368 void collect_full(bool trace_contexts_p);
369 void collect_compact_impl(bool trace_contexts_p);
370 void collect_compact_code_impl(bool trace_contexts_p);
371 void collect_compact(bool trace_contexts_p);
372 void collect_growing_heap(cell requested_size, bool trace_contexts_p);
373 void gc(gc_op op, cell requested_size, bool trace_contexts_p);
374 void scrub_context(context* ctx);
375 void scrub_contexts();
376 void primitive_minor_gc();
377 void primitive_full_gc();
378 void primitive_compact_gc();
379 void primitive_enable_gc_events();
380 void primitive_disable_gc_events();
381 object* allot_object(cell type, cell size);
382 object* allot_large_object(cell type, cell size);
384 /* Allocates memory */
385 template <typename Type> Type* allot(cell size) {
386 return (Type*)allot_object(Type::type_number, size);
389 inline void check_data_pointer(object* pointer) {
390 FACTOR_ASSERT((current_gc && current_gc->op == collect_growing_heap_op) ||
391 data->seg->in_segment_p((cell)pointer));
395 template <typename Array> Array* allot_uninitialized_array(cell capacity);
396 template <typename Array>
397 bool reallot_array_in_place_p(Array* array, cell capacity);
398 template <typename Array> Array* reallot_array(Array* array_, cell capacity);
401 void print_chars(string* str);
402 void print_word(word* word, cell nesting);
403 void print_factor_string(string* str);
404 void print_array(array* array, cell nesting);
405 void print_byte_array(byte_array* array, cell nesting);
406 void print_tuple(tuple* tuple, cell nesting);
407 void print_alien(alien* alien, cell nesting);
408 void print_nested_obj(cell obj, fixnum nesting);
409 void print_obj(cell obj);
410 void print_objects(cell* start, cell* end);
411 void print_datastack();
412 void print_retainstack();
413 void print_callstack();
414 void print_callstack_object(callstack* obj);
415 void dump_cell(cell x);
416 void dump_memory(cell from, cell to);
417 template <typename Generation>
418 void dump_generation(const char* name, Generation* gen);
419 void dump_generations();
420 void dump_objects(cell type);
422 void find_data_references(cell look_for_);
423 void dump_code_heap();
424 void factorbug_usage(bool advanced_p);
426 void primitive_die();
429 inline void set_array_nth(array* array, cell slot, cell value);
430 array* allot_array(cell capacity, cell fill_);
431 void primitive_array();
432 cell allot_array_4(cell v1_, cell v2_, cell v3_, cell v4_);
433 void primitive_resize_array();
434 cell std_vector_to_array(std::vector<cell>& elements);
437 string* allot_string_internal(cell capacity);
438 void fill_string(string* str_, cell start, cell capacity, cell fill);
439 string* allot_string(cell capacity, cell fill);
440 void primitive_string();
441 bool reallot_string_in_place_p(string* str, cell capacity);
442 string* reallot_string(string* str_, cell capacity);
443 void primitive_resize_string();
444 void primitive_set_string_nth_fast();
447 cell tag_boolean(cell untagged) {
448 return (untagged ? true_object : false_object);
452 byte_array* allot_byte_array(cell size);
453 void primitive_byte_array();
454 void primitive_uninitialized_byte_array();
455 void primitive_resize_byte_array();
457 template <typename Type> byte_array* byte_array_from_value(Type* value);
460 void primitive_tuple();
461 void primitive_tuple_boa();
464 word* allot_word(cell name_, cell vocab_, cell hashcode_);
465 void primitive_word();
466 void primitive_word_code();
467 void primitive_optimized_p();
468 void primitive_wrapper();
469 void jit_compile_word(cell word_, cell def_, bool relocating);
470 cell find_all_words();
471 void compile_all_words();
474 void primitive_bignum_to_fixnum();
475 void primitive_float_to_fixnum();
476 void primitive_fixnum_divint();
477 void primitive_fixnum_divmod();
478 bignum* fixnum_to_bignum(fixnum);
479 bignum* cell_to_bignum(cell);
480 bignum* long_long_to_bignum(int64_t n);
481 bignum* ulong_long_to_bignum(uint64_t n);
482 inline fixnum sign_mask(fixnum x);
483 inline fixnum branchless_max(fixnum x, fixnum y);
484 inline fixnum branchless_abs(fixnum x);
485 void primitive_fixnum_shift();
486 void primitive_fixnum_to_bignum();
487 void primitive_float_to_bignum();
488 void primitive_bignum_eq();
489 void primitive_bignum_add();
490 void primitive_bignum_subtract();
491 void primitive_bignum_multiply();
492 void primitive_bignum_divint();
493 void primitive_bignum_divmod();
494 void primitive_bignum_mod();
495 void primitive_bignum_gcd();
496 void primitive_bignum_and();
497 void primitive_bignum_or();
498 void primitive_bignum_xor();
499 void primitive_bignum_shift();
500 void primitive_bignum_less();
501 void primitive_bignum_lesseq();
502 void primitive_bignum_greater();
503 void primitive_bignum_greatereq();
504 void primitive_bignum_not();
505 void primitive_bignum_bitp();
506 void primitive_bignum_log2();
507 inline cell unbox_array_size();
508 cell unbox_array_size_slow();
509 void primitive_fixnum_to_float();
510 void primitive_format_float();
511 void primitive_float_eq();
512 void primitive_float_add();
513 void primitive_float_subtract();
514 void primitive_float_multiply();
515 void primitive_float_divfloat();
516 void primitive_float_less();
517 void primitive_float_lesseq();
518 void primitive_float_greater();
519 void primitive_float_greatereq();
520 void primitive_float_bits();
521 void primitive_bits_float();
522 void primitive_double_bits();
523 void primitive_bits_double();
524 fixnum to_fixnum(cell tagged);
525 cell to_cell(cell tagged);
526 cell from_signed_8(int64_t n);
527 int64_t to_signed_8(cell obj);
528 cell from_unsigned_8(uint64_t n);
529 uint64_t to_unsigned_8(cell obj);
530 float to_float(cell value);
531 double to_double(cell value);
532 inline void overflow_fixnum_add(fixnum x, fixnum y);
533 inline void overflow_fixnum_subtract(fixnum x, fixnum y);
534 inline void overflow_fixnum_multiply(fixnum x, fixnum y);
535 inline cell from_signed_cell(fixnum x);
536 inline cell from_unsigned_cell(cell x);
537 inline cell allot_float(double n);
538 inline bignum* float_to_bignum(cell tagged);
539 inline double untag_float(cell tagged);
540 inline double untag_float_check(cell tagged);
541 inline fixnum float_to_fixnum(cell tagged);
542 inline double fixnum_to_float(cell tagged);
545 template <typename Type> Type* untag_check(cell value);
550 FILE* safe_fopen(char* filename, char* mode);
551 int safe_fgetc(FILE* stream);
552 size_t safe_fread(void* ptr, size_t size, size_t nitems, FILE* stream);
553 void safe_fputc(int c, FILE* stream);
554 size_t safe_fwrite(void* ptr, size_t size, size_t nitems, FILE* stream);
555 int safe_ftell(FILE* stream);
556 void safe_fseek(FILE* stream, off_t offset, int whence);
557 void safe_fflush(FILE* stream);
558 void safe_fclose(FILE* stream);
559 void primitive_fopen();
560 FILE* pop_file_handle();
561 FILE* peek_file_handle();
562 void primitive_fgetc();
563 void primitive_fread();
564 void primitive_fputc();
565 void primitive_fwrite();
566 void primitive_ftell();
567 void primitive_fseek();
568 void primitive_fflush();
569 void primitive_fclose();
572 cell compute_entry_point_address(cell obj);
573 cell compute_entry_point_pic_address(word* w, cell tagged_quot);
574 cell compute_entry_point_pic_address(cell w_);
575 cell compute_entry_point_pic_tail_address(cell w_);
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 void store_external_address(instruction_operand op);
585 cell compute_here_address(cell arg, cell offset, code_block* compiled);
586 void initialize_code_block(code_block* compiled, cell literals);
587 void initialize_code_block(code_block* compiled);
588 void fixup_labels(array* labels, code_block* compiled);
589 code_block* allot_code_block(cell size, code_block_type type);
590 code_block* add_code_block(code_block_type type, cell code_, cell labels_,
591 cell owner_, cell relocation_, cell parameters_,
592 cell literals_, cell frame_size_untagged);
595 inline void check_code_pointer(cell ptr) {}
597 template <typename Iterator> void each_code_block(Iterator& iter) {
598 code->allocator->iterate(iter);
601 void init_code_heap(cell size);
602 void update_code_heap_words(bool reset_inline_caches);
603 void initialize_code_blocks();
604 void primitive_modify_code_heap();
605 code_heap_room code_room();
606 void primitive_code_room();
607 void primitive_strip_stack_traces();
609 void primitive_code_blocks();
612 void init_callbacks(cell size);
613 void primitive_callback();
616 void init_objects(image_header* h);
617 void load_data_heap(FILE* file, image_header* h, vm_parameters* p);
618 void load_code_heap(FILE* file, image_header* h, vm_parameters* p);
619 bool save_image(const vm_char* saving_filename, const vm_char* filename);
620 void primitive_save_image();
621 void primitive_save_image_and_exit();
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 void* second_from_top_stack_frame(context* ctx);
637 cell capture_callstack(context* ctx);
638 void primitive_callstack();
639 void primitive_callstack_for();
640 void* frame_predecessor(void* frame);
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_quot();
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);
656 char* pinned_alien_offset(cell obj);
657 cell allot_alien(cell delegate_, cell displacement);
658 cell allot_alien(void* address);
659 void primitive_displaced_alien();
660 void primitive_alien_address();
661 void* alien_pointer();
662 void primitive_dlopen();
663 void primitive_dlsym();
664 void primitive_dlsym_raw();
665 void primitive_dlclose();
666 void primitive_dll_validp();
667 char* alien_offset(cell obj);
670 void primitive_jit_compile();
671 void* lazy_jit_compile_entry_point();
672 void primitive_array_to_quotation();
673 void primitive_quotation_code();
674 code_block* jit_compile_quot(cell owner_, cell quot_, bool relocating);
675 void jit_compile_quot(cell quot_, bool relocating);
676 fixnum quot_code_offset_to_scan(cell quot_, cell offset);
677 cell lazy_jit_compile(cell quot);
678 bool quot_compiled_p(quotation* quot);
679 void primitive_quot_compiled_p();
680 cell find_all_quotations();
681 void initialize_all_quotations();
684 cell search_lookup_alist(cell table, cell klass);
685 cell search_lookup_hash(cell table, cell klass, cell hashcode);
686 cell nth_superclass(tuple_layout* layout, fixnum echelon);
687 cell nth_hashcode(tuple_layout* layout, fixnum echelon);
688 cell lookup_tuple_method(cell obj, cell methods);
689 cell lookup_method(cell obj, cell methods);
690 void primitive_lookup_method();
691 cell object_class(cell obj);
692 cell method_cache_hashcode(cell klass, array* array);
693 void update_method_cache(cell cache, cell klass, cell method);
694 void primitive_mega_cache_miss();
695 void primitive_reset_dispatch_stats();
696 void primitive_dispatch_stats();
699 void init_inline_caching(int max_size);
700 void deallocate_inline_cache(cell return_address);
701 cell determine_inline_cache_type(array* cache_entries);
702 void update_pic_count(cell type);
703 code_block* compile_inline_cache(fixnum index, cell generic_word_,
704 cell methods_, cell cache_entries_,
706 void* megamorphic_call_stub(cell generic_word);
707 cell inline_cache_size(cell cache_entries);
708 cell add_inline_cache_entry(cell cache_entries_, cell klass_, cell method_);
709 void update_pic_transitions(cell pic_size);
710 void* inline_cache_miss(cell return_address);
713 void c_to_factor(cell quot);
714 template <typename Func> Func get_entry_point(cell n);
715 void unwind_native_frames(cell quot, void* to);
716 cell get_fpu_state();
717 void set_fpu_state(cell state);
720 void default_parameters(vm_parameters* p);
721 bool factor_arg(const vm_char* str, const vm_char* arg, cell* value);
722 void init_parameters_from_args(vm_parameters* p, int argc, vm_char** argv);
723 void prepare_boot_image();
724 void init_factor(vm_parameters* p);
725 void pass_args_to_factor(int argc, vm_char** argv);
726 void start_factor(vm_parameters* p);
728 void start_embedded_factor(vm_parameters* p);
729 void start_standalone_factor(int argc, vm_char** argv);
730 char* factor_eval_string(char* string);
731 void factor_eval_free(char* result);
733 void factor_sleep(long us);
736 void primitive_existsp();
737 void move_file(const vm_char* path1, const vm_char* path2);
739 void ffi_dlopen(dll* dll);
740 void* ffi_dlsym(dll* dll, symbol_char* symbol);
741 void* ffi_dlsym_raw(dll* dll, symbol_char* symbol);
743 void* ffi_dlsym_toc(dll* dll, symbol_char* symbol);
745 void ffi_dlclose(dll* dll);
746 void c_to_factor_toplevel(cell quot);
748 void start_sampling_profiler_timer();
749 void end_sampling_profiler_timer();
750 static void open_console();
751 static void close_console();
752 static void lock_console();
753 static void unlock_console();
754 static void ignore_ctrl_c();
755 static void handle_ctrl_c();
759 HANDLE sampler_thread;
760 void sampler_thread_loop();
762 const vm_char* vm_executable_path();
763 const vm_char* default_image_path();
764 void windows_image_path(vm_char* full_path, vm_char* temp_path,
765 unsigned int length);
766 BOOL windows_stat(vm_char* path);
768 LONG exception_handler(PEXCEPTION_RECORD e, void* frame, PCONTEXT c,
772 void dispatch_signal(void* uap, void(handler)());
773 void unix_init_signals();
777 void call_fault_handler(exception_type_t exception,
778 exception_data_type_t code,
779 MACH_EXC_STATE_TYPE* exc_state,
780 MACH_THREAD_STATE_TYPE* thread_state,
781 MACH_FLOAT_STATE_TYPE* float_state);
784 factor_vm(THREADHANDLE thread_id);