11 // THESE FIELDS ARE ACCESSED DIRECTLY FROM FACTOR. See:
13 // basis/compiler/constants/constants.factor
18 /* Spare context -- for callbacks */
21 /* New objects are allocated here, use the data->nursery reference
22 instead from c++ code. */
23 bump_allocator nursery;
25 /* Add this to a shifted address to compute write barrier offsets */
29 /* cdecl signal handler address, used by signal handler subprimitives */
30 cell signal_handler_addr;
32 /* are we handling a memory error? used to detect double faults */
35 /* Various special objects, accessed by special-object and
36 set-special-object primitives */
37 cell special_objects[special_object_count];
39 // THESE FIELDS ARE ACCESSED DIRECTLY FROM FACTOR.
43 /* Handle to the main thread we run in */
46 /* Data stack and retain stack sizes */
47 cell datastack_size, retainstack_size, callstack_size;
49 /* Stack of callback IDs */
50 std::vector<int> callback_ids;
52 /* Next callback ID */
55 /* List of callback function descriptors for PPC */
56 std::list<void**> function_descriptors;
58 /* Pooling unused contexts to make context allocation cheaper */
59 std::list<context*> unused_contexts;
61 /* Active contexts, for tracing by the GC */
62 std::set<context*> active_contexts;
64 /* Canonical truth value. In Factor, 't' */
67 /* External entry points */
68 c_to_factor_func_type c_to_factor_func;
70 /* Is profiling enabled? */
71 volatile cell sampling_profiler_p;
72 fixnum samples_per_second;
74 /* Global variables used to pass fault handler state from signal handler
76 bool signal_resumable;
78 cell signal_fault_addr;
80 unsigned int signal_fpu_status;
82 /* Pipe used to notify Factor multiplexer of signals */
83 int signal_pipe_input, signal_pipe_output;
85 /* State kept by the sampling profiler */
86 std::vector<profiling_sample> samples;
87 std::vector<cell> sample_callstacks;
89 /* GC is off during heap walking */
98 /* Pinned callback stubs */
99 callback_heap* callbacks;
101 /* Only set if we're performing a GC */
102 gc_state* current_gc;
103 volatile cell current_gc_p;
105 /* Set if we're in the jit */
106 volatile fixnum current_jit_count;
109 std::vector<cell> mark_stack;
111 /* If not NULL, we push GC events here */
112 std::vector<gc_event>* gc_events;
114 /* If a runtime function needs to call another function which potentially
115 allocates memory, it must wrap any references to the data and code
116 heaps with data_root and code_root smart pointers, which register
117 themselves here. See data_roots.hpp and code_roots.hpp */
119 std::vector<cell*> data_roots;
120 std::vector<code_root*> code_roots;
124 bool fep_help_was_shown;
128 /* Canonical bignums */
133 /* Method dispatch statistics */
134 dispatch_statistics dispatch_stats;
136 /* Number of entries in a polymorphic inline cache */
139 /* Incrementing object counter for identity hashing */
142 /* Sanity check to ensure that monotonic counter doesn't decrease */
143 uint64_t last_nano_count;
145 /* Stack for signal handlers, only used on Unix */
146 segment* signal_callstack_seg;
148 /* Are we already handling a fault? Used to catch double memory faults */
149 static bool fatal_erroring_p;
151 /* Safepoint state */
152 volatile safepoint_state safepoint;
155 context* new_context();
156 void init_context(context* ctx);
157 void delete_context(context* old_context);
158 void init_contexts(cell datastack_size_, cell retainstack_size_,
159 cell callstack_size_);
160 void delete_contexts();
161 cell begin_callback(cell quot);
163 void primitive_current_callback();
164 void primitive_context_object();
165 void primitive_context_object_for();
166 void primitive_set_context_object();
167 cell stack_to_array(cell bottom, cell top);
168 cell datastack_to_array(context* ctx);
169 void primitive_datastack();
170 void primitive_datastack_for();
171 cell retainstack_to_array(context* ctx);
172 void primitive_retainstack();
173 void primitive_retainstack_for();
174 cell array_to_stack(array* array, cell bottom);
175 void set_datastack(context* ctx, array* array);
176 void primitive_set_datastack();
177 void set_retainstack(context* ctx, array* array);
178 void primitive_set_retainstack();
179 void primitive_check_datastack();
180 void primitive_load_locals();
183 void primitive_exit();
184 void primitive_nano_count();
185 void primitive_sleep();
186 void primitive_set_slot();
189 void primitive_special_object();
190 void primitive_set_special_object();
191 void primitive_identity_hashcode();
192 void compute_identity_hashcode(object* obj);
193 void primitive_compute_identity_hashcode();
194 cell object_size(cell tagged);
195 cell clone_object(cell obj_);
196 void primitive_clone();
197 void primitive_become();
200 void clear_samples();
201 void record_sample(bool prolog_p);
202 void record_callstack_sample(cell* begin, cell* end, bool prolog_p);
203 void start_sampling_profiler(fixnum rate);
204 void end_sampling_profiler();
205 void set_sampling_profiler(fixnum rate);
206 void primitive_sampling_profiler();
207 void primitive_get_samples();
208 void primitive_clear_samples();
211 void general_error(vm_error_type error, cell arg1, cell arg2);
212 void type_error(cell type, cell tagged);
213 void not_implemented_error();
214 void verify_memory_protection_error(cell addr);
215 void memory_protection_error(cell pc, cell addr);
216 void signal_error(cell signal);
217 void divide_by_zero_error();
218 void fp_trap_error(unsigned int fpu_status);
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 cell bignum_to_cell(bignum* bn);
236 fixnum bignum_to_fixnum_strict(bignum* bn);
237 fixnum bignum_to_fixnum(bignum* bn);
238 int64_t bignum_to_long_long(bignum* bn);
239 uint64_t bignum_to_ulong_long(bignum* bn);
240 bignum* double_to_bignum(double x);
241 int bignum_equal_p_unsigned(bignum* x, bignum* y);
242 enum bignum_comparison bignum_compare_unsigned(bignum* x, bignum* y);
243 bignum* bignum_add_unsigned(bignum* x_, bignum* y_, int negative_p);
244 bignum* bignum_subtract_unsigned(bignum* x_, bignum* y_);
245 bignum* bignum_multiply_unsigned(bignum* x_, bignum* y_, int negative_p);
246 bignum* bignum_multiply_unsigned_small_factor(bignum* x, bignum_digit_type y,
248 void bignum_destructive_add(bignum* bn, bignum_digit_type n);
249 void bignum_destructive_scale_up(bignum* bn, bignum_digit_type factor);
250 void bignum_divide_unsigned_large_denominator(
251 bignum* numerator_, bignum* denominator_, bignum** quotient,
252 bignum** remainder, int q_negative_p, int r_negative_p);
253 void bignum_divide_unsigned_normalized(bignum* u, bignum* v, bignum* q);
254 bignum_digit_type bignum_divide_subtract(bignum_digit_type* v_start,
255 bignum_digit_type* v_end,
256 bignum_digit_type guess,
257 bignum_digit_type* u_start);
258 void bignum_divide_unsigned_medium_denominator(
259 bignum* numerator_, bignum_digit_type denominator, bignum** quotient,
260 bignum** remainder, int q_negative_p, int r_negative_p);
261 void bignum_destructive_normalization(bignum* source, bignum* target,
263 void bignum_destructive_unnormalization(bignum* bn, int shift_right);
264 bignum_digit_type bignum_digit_divide(
265 bignum_digit_type uh, bignum_digit_type ul, bignum_digit_type v,
266 bignum_digit_type* q) /* return value */;
267 bignum_digit_type bignum_digit_divide_subtract(bignum_digit_type v1,
268 bignum_digit_type v2,
269 bignum_digit_type guess,
270 bignum_digit_type* u);
271 void bignum_divide_unsigned_small_denominator(
272 bignum* numerator_, bignum_digit_type denominator, bignum** quotient,
273 bignum** remainder, int q_negative_p, int r_negative_p);
274 bignum_digit_type bignum_destructive_scale_down(
275 bignum* bn, bignum_digit_type denominator);
276 bignum* bignum_remainder_unsigned_small_denominator(bignum* n,
279 bignum* bignum_digit_to_bignum(bignum_digit_type digit, int negative_p);
280 bignum* allot_bignum(bignum_length_type length, int negative_p);
281 bignum* allot_bignum_zeroed(bignum_length_type length, int negative_p);
282 bignum* bignum_shorten_length(bignum* bn, bignum_length_type length);
283 bignum* bignum_trim(bignum* bn);
284 bignum* bignum_new_sign(bignum* x_, int negative_p);
285 bignum* bignum_maybe_new_sign(bignum* x_, int negative_p);
286 void bignum_destructive_copy(bignum* source, bignum* target);
287 bignum* bignum_bitwise_not(bignum* x_);
288 bignum* bignum_arithmetic_shift(bignum* arg1, fixnum n);
289 bignum* bignum_bitwise_and(bignum* arg1, bignum* arg2);
290 bignum* bignum_bitwise_ior(bignum* arg1, bignum* arg2);
291 bignum* bignum_bitwise_xor(bignum* arg1, bignum* arg2);
292 bignum* bignum_magnitude_ash(bignum* arg1_, fixnum n);
293 bignum* bignum_pospos_bitwise_op(int op, bignum* arg1_, bignum* arg2_);
294 bignum* bignum_posneg_bitwise_op(int op, bignum* arg1_, bignum* arg2_);
295 bignum* bignum_negneg_bitwise_op(int op, bignum* arg1_, bignum* arg2_);
296 void bignum_negate_magnitude(bignum* arg);
297 bignum* bignum_integer_length(bignum* x_);
298 int bignum_logbitp(int shift, bignum* arg);
299 int bignum_unsigned_logbitp(int shift, bignum* bn);
300 bignum* bignum_gcd(bignum* a_, bignum* b_);
303 void init_card_decks();
304 void set_data_heap(data_heap* data_);
305 void init_data_heap(cell young_size, cell aging_size, cell tenured_size);
306 void primitive_size();
307 data_heap_room data_room();
308 void primitive_data_room();
311 cell instances(cell type);
312 void primitive_all_instances();
314 template <typename Generation, typename Iterator>
315 inline void each_object(Generation* gen, Iterator& iterator) {
316 cell obj = gen->first_object();
318 iterator((object*)obj);
319 obj = gen->next_object_after(obj);
323 template <typename Iterator> inline void each_object(Iterator& iterator) {
325 /* The nursery can't be iterated because there may be gaps between
326 the objects (see factor_vm::reallot_array) so we require it to
328 FACTOR_ASSERT(data->nursery->occupied_space() == 0);
331 each_object(data->tenured, iterator);
332 each_object(data->aging, iterator);
336 /* the write barrier must be called any time we are potentially storing a
337 pointer from an older generation to a younger one */
338 inline void write_barrier(cell* slot_ptr) {
339 *(char*)(cards_offset + ((cell)slot_ptr >> card_bits)) = card_mark_mask;
340 *(char*)(decks_offset + ((cell)slot_ptr >> deck_bits)) = card_mark_mask;
343 inline void write_barrier(object* obj, cell size) {
344 cell start = (cell)obj & (~card_size + 1);
345 cell end = ((cell)obj + size + card_size - 1) & (~card_size + 1);
347 for (cell offset = start; offset < end; offset += card_size)
348 write_barrier((cell*)offset);
352 void check_data_heap();
356 void set_current_gc_op(gc_op op);
357 void start_gc_again();
358 void update_code_heap_for_minor_gc(std::set<code_block*>* remembered_set);
359 void collect_nursery();
360 void collect_aging();
361 void collect_to_tenured();
362 void update_code_roots_for_sweep();
363 void update_code_roots_for_compaction();
364 void collect_mark_impl();
365 void collect_sweep_impl();
367 void collect_compact_impl();
368 void collect_compact_code_impl();
369 void collect_compact();
370 void collect_growing_heap(cell requested_size);
371 void gc(gc_op op, cell requested_size);
372 void scrub_context(context* ctx);
373 void scrub_contexts();
374 void primitive_minor_gc();
375 void primitive_full_gc();
376 void primitive_compact_gc();
377 void primitive_enable_gc_events();
378 void primitive_disable_gc_events();
379 object* allot_object(cell type, cell size);
380 object* allot_large_object(cell type, cell size);
382 /* Allocates memory */
383 template <typename Type> Type* allot(cell size) {
384 return (Type*)allot_object(Type::type_number, size);
388 template <typename Array> Array* allot_uninitialized_array(cell capacity);
389 template <typename Array>
390 bool reallot_array_in_place_p(Array* array, cell capacity);
391 template <typename Array> Array* reallot_array(Array* array_, cell capacity);
394 void print_chars(ostream& out, string* str);
395 void print_word(ostream& out, word* word, cell nesting);
396 void print_factor_string(ostream& out, string* str);
397 void print_array(ostream& out, array* array, cell nesting);
398 void print_byte_array(ostream& out, byte_array* array, cell nesting);
399 void print_tuple(ostream& out, tuple* tuple, cell nesting);
400 void print_alien(ostream& out, alien* alien, cell nesting);
401 void print_nested_obj(ostream& out, cell obj, fixnum nesting);
402 void print_obj(ostream& out, cell obj);
403 void print_objects(ostream& out, cell* start, cell* end);
404 void print_datastack(ostream& out);
405 void print_retainstack(ostream& out);
406 void print_callstack(ostream& out);
407 void print_callstack_object(ostream& out, callstack* obj);
408 void dump_cell(ostream& out, cell x);
409 void dump_memory(ostream& out, cell from, cell to);
410 template <typename Generation>
411 void dump_generation(ostream& out, const char* name, Generation* gen);
412 void dump_generations(ostream& out);
413 void dump_objects(ostream& out, cell type);
414 void dump_edges(ostream& out);
415 void find_data_references(ostream& out, cell look_for_);
416 void dump_code_heap(ostream& out);
417 void factorbug_usage(bool advanced_p);
419 void primitive_die();
422 inline void set_array_nth(array* array, cell slot, cell value);
423 array* allot_array(cell capacity, cell fill_);
424 void primitive_array();
425 cell allot_array_4(cell v1_, cell v2_, cell v3_, cell v4_);
426 void primitive_resize_array();
427 cell std_vector_to_array(std::vector<cell>& elements);
430 string* allot_string_internal(cell capacity);
431 void fill_string(string* str_, cell start, cell capacity, cell fill);
432 string* allot_string(cell capacity, cell fill);
433 void primitive_string();
434 bool reallot_string_in_place_p(string* str, cell capacity);
435 string* reallot_string(string* str_, cell capacity);
436 void primitive_resize_string();
437 void primitive_set_string_nth_fast();
440 cell tag_boolean(cell untagged) {
441 return (untagged ? true_object : false_object);
445 byte_array* allot_byte_array(cell size);
446 void primitive_byte_array();
447 void primitive_uninitialized_byte_array();
448 void primitive_resize_byte_array();
450 template <typename Type> byte_array* byte_array_from_value(Type* value);
453 void primitive_tuple();
454 void primitive_tuple_boa();
457 word* allot_word(cell name_, cell vocab_, cell hashcode_);
458 void primitive_word();
459 void primitive_word_code();
460 void primitive_optimized_p();
461 void primitive_wrapper();
462 void jit_compile_word(cell word_, cell def_, bool relocating);
463 cell find_all_words();
464 void compile_all_words();
467 void primitive_bignum_to_fixnum();
468 void primitive_bignum_to_fixnum_strict();
469 void primitive_float_to_fixnum();
470 void primitive_fixnum_divint();
471 void primitive_fixnum_divmod();
472 bignum* fixnum_to_bignum(fixnum);
473 bignum* cell_to_bignum(cell);
474 bignum* long_long_to_bignum(int64_t n);
475 bignum* ulong_long_to_bignum(uint64_t n);
476 inline fixnum sign_mask(fixnum x);
477 inline fixnum branchless_max(fixnum x, fixnum y);
478 inline fixnum branchless_abs(fixnum x);
479 void primitive_fixnum_shift();
480 void primitive_fixnum_to_bignum();
481 void primitive_float_to_bignum();
482 void primitive_bignum_eq();
483 void primitive_bignum_add();
484 void primitive_bignum_subtract();
485 void primitive_bignum_multiply();
486 void primitive_bignum_divint();
487 void primitive_bignum_divmod();
488 void primitive_bignum_mod();
489 void primitive_bignum_gcd();
490 void primitive_bignum_and();
491 void primitive_bignum_or();
492 void primitive_bignum_xor();
493 void primitive_bignum_shift();
494 void primitive_bignum_less();
495 void primitive_bignum_lesseq();
496 void primitive_bignum_greater();
497 void primitive_bignum_greatereq();
498 void primitive_bignum_not();
499 void primitive_bignum_bitp();
500 void primitive_bignum_log2();
501 inline cell unbox_array_size();
502 void primitive_fixnum_to_float();
503 void primitive_format_float();
504 void primitive_float_eq();
505 void primitive_float_add();
506 void primitive_float_subtract();
507 void primitive_float_multiply();
508 void primitive_float_divfloat();
509 void primitive_float_less();
510 void primitive_float_lesseq();
511 void primitive_float_greater();
512 void primitive_float_greatereq();
513 void primitive_float_bits();
514 void primitive_bits_float();
515 void primitive_double_bits();
516 void primitive_bits_double();
517 fixnum to_fixnum(cell tagged);
518 fixnum to_fixnum_strict(cell tagged);
519 cell to_cell(cell tagged);
520 cell from_signed_8(int64_t n);
521 int64_t to_signed_8(cell obj);
522 cell from_unsigned_8(uint64_t n);
523 uint64_t to_unsigned_8(cell obj);
524 float to_float(cell value);
525 double to_double(cell value);
526 inline void overflow_fixnum_add(fixnum x, fixnum y);
527 inline void overflow_fixnum_subtract(fixnum x, fixnum y);
528 inline void overflow_fixnum_multiply(fixnum x, fixnum y);
529 inline cell from_signed_cell(fixnum x);
530 inline cell from_unsigned_cell(cell x);
531 inline cell allot_float(double n);
532 inline bignum* float_to_bignum(cell tagged);
533 inline double untag_float(cell tagged);
534 inline double untag_float_check(cell tagged);
535 inline fixnum float_to_fixnum(cell tagged);
536 inline double fixnum_to_float(cell tagged);
539 template <typename Type> Type* untag_check(cell value);
544 FILE* safe_fopen(char* filename, char* mode);
545 int safe_fgetc(FILE* stream);
546 size_t safe_fread(void* ptr, size_t size, size_t nitems, FILE* stream);
547 void safe_fputc(int c, FILE* stream);
548 size_t safe_fwrite(void* ptr, size_t size, size_t nitems, FILE* stream);
549 int safe_ftell(FILE* stream);
550 void safe_fseek(FILE* stream, off_t offset, int whence);
551 void safe_fflush(FILE* stream);
552 void safe_fclose(FILE* stream);
553 void primitive_fopen();
554 FILE* pop_file_handle();
555 FILE* peek_file_handle();
556 void primitive_fgetc();
557 void primitive_fread();
558 void primitive_fputc();
559 void primitive_fwrite();
560 void primitive_ftell();
561 void primitive_fseek();
562 void primitive_fflush();
563 void primitive_fclose();
566 cell compute_entry_point_address(cell obj);
567 cell compute_entry_point_pic_address(word* w, cell tagged_quot);
568 cell compute_entry_point_pic_address(cell w_);
569 cell compute_entry_point_pic_tail_address(cell w_);
570 cell code_block_owner(code_block* compiled);
571 void update_word_references(code_block* compiled, bool reset_inline_caches);
572 void undefined_symbol();
573 cell compute_dlsym_address(array* literals, cell index);
575 cell compute_dlsym_toc_address(array* literals, cell index);
577 cell compute_vm_address(cell arg);
578 void store_external_address(instruction_operand op);
579 cell lookup_external_address(relocation_type rel_type,
580 code_block* compiled,
583 cell compute_here_address(cell arg, cell offset, code_block* compiled);
584 void initialize_code_block(code_block* compiled, cell literals);
585 void initialize_code_block(code_block* compiled);
586 void fixup_labels(array* labels, code_block* compiled);
587 code_block* allot_code_block(cell size, code_block_type type);
588 code_block* add_code_block(code_block_type type, cell code_, cell labels_,
589 cell owner_, cell relocation_, cell parameters_,
590 cell literals_, cell frame_size_untagged);
593 template <typename Iterator> void each_code_block(Iterator& iter) {
594 code->allocator->iterate(iter);
597 void init_code_heap(cell size);
598 void update_code_heap_words(bool reset_inline_caches);
599 void initialize_code_blocks();
600 void primitive_modify_code_heap();
601 void primitive_code_room();
602 void primitive_strip_stack_traces();
604 void primitive_code_blocks();
607 void init_callbacks(cell size);
608 void primitive_free_callback();
609 void primitive_callback();
610 void primitive_callback_room();
613 void init_objects(image_header* h);
614 void load_data_heap(FILE* file, image_header* h, vm_parameters* p);
615 void load_code_heap(FILE* file, image_header* h, vm_parameters* p);
616 bool save_image(const vm_char* saving_filename, const vm_char* filename);
617 void primitive_save_image();
618 void primitive_save_image_and_exit();
619 void fixup_data(cell data_offset, cell code_offset);
620 void fixup_code(cell data_offset, cell code_offset);
621 FILE* open_image(vm_parameters* p);
622 void load_image(vm_parameters* p);
623 bool read_embedded_image_footer(FILE* file, embedded_image_footer* footer);
624 bool embedded_image_p();
626 template <typename Iterator, typename Fixup>
627 void iterate_callstack_object(callstack* stack_, Iterator& iterator,
629 template <typename Iterator>
630 void iterate_callstack_object(callstack* stack_, Iterator& iterator);
632 callstack* allot_callstack(cell size);
633 cell second_from_top_stack_frame(context* ctx);
634 cell capture_callstack(context* ctx);
635 void primitive_callstack();
636 void primitive_callstack_for();
637 cell frame_predecessor(cell frame_top);
638 void primitive_callstack_to_array();
639 void primitive_innermost_stack_frame_executing();
640 void primitive_innermost_stack_frame_scan();
641 void primitive_set_innermost_stack_frame_quot();
642 void primitive_callstack_bounds();
644 template <typename Iterator, typename Fixup>
645 void iterate_callstack(context* ctx, Iterator& iterator, Fixup& fixup);
646 template <typename Iterator>
647 void iterate_callstack(context* ctx, Iterator& iterator);
650 void dispatch_signal_handler(cell* sp, cell* pc, cell newpc);
653 char* pinned_alien_offset(cell obj);
654 cell allot_alien(cell delegate_, cell displacement);
655 cell allot_alien(void* address);
656 void primitive_displaced_alien();
657 void primitive_alien_address();
658 void* alien_pointer();
659 void primitive_dlopen();
660 void primitive_dlsym();
661 void primitive_dlsym_raw();
662 void primitive_dlclose();
663 void primitive_dll_validp();
664 char* alien_offset(cell obj);
667 void primitive_jit_compile();
668 cell lazy_jit_compile_entry_point();
669 void primitive_array_to_quotation();
670 void primitive_quotation_code();
671 code_block* jit_compile_quot(cell owner_, cell quot_, bool relocating);
672 void jit_compile_quot(cell quot_, bool relocating);
673 fixnum quot_code_offset_to_scan(cell quot_, cell offset);
674 cell lazy_jit_compile(cell quot);
675 bool quot_compiled_p(quotation* quot);
676 void primitive_quot_compiled_p();
677 cell find_all_quotations();
678 void initialize_all_quotations();
681 cell search_lookup_alist(cell table, cell klass);
682 cell search_lookup_hash(cell table, cell klass, cell hashcode);
683 cell nth_superclass(tuple_layout* layout, fixnum echelon);
684 cell nth_hashcode(tuple_layout* layout, fixnum echelon);
685 cell lookup_tuple_method(cell obj, cell methods);
686 cell lookup_method(cell obj, cell methods);
687 void primitive_lookup_method();
688 cell object_class(cell obj);
689 cell method_cache_hashcode(cell klass, array* array);
690 void update_method_cache(cell cache, cell klass, cell method);
691 void primitive_mega_cache_miss();
692 void primitive_reset_dispatch_stats();
693 void primitive_dispatch_stats();
696 void init_inline_caching(int max_size);
697 void deallocate_inline_cache(cell return_address);
698 cell determine_inline_cache_type(array* cache_entries);
699 void update_pic_count(cell type);
700 code_block* compile_inline_cache(fixnum index, cell generic_word_,
701 cell methods_, cell cache_entries_,
703 cell inline_cache_size(cell cache_entries);
704 cell add_inline_cache_entry(cell cache_entries_, cell klass_, cell method_);
705 void update_pic_transitions(cell pic_size);
706 cell inline_cache_miss(cell return_address);
709 void c_to_factor(cell quot);
710 template <typename Func> Func get_entry_point(cell n);
711 void unwind_native_frames(cell quot, cell to);
712 cell get_fpu_state();
713 void set_fpu_state(cell state);
716 void default_parameters(vm_parameters* p);
717 bool factor_arg(const vm_char* str, const vm_char* arg, cell* value);
718 void init_parameters_from_args(vm_parameters* p, int argc, vm_char** argv);
719 void prepare_boot_image();
720 void init_factor(vm_parameters* p);
721 void pass_args_to_factor(int argc, vm_char** argv);
722 void start_factor(vm_parameters* p);
724 void start_embedded_factor(vm_parameters* p);
725 void start_standalone_factor(int argc, vm_char** argv);
726 char* factor_eval_string(char* string);
727 void factor_eval_free(char* result);
729 void factor_sleep(long us);
732 void primitive_existsp();
733 void move_file(const vm_char* path1, const vm_char* path2);
735 void ffi_dlopen(dll* dll);
736 void* ffi_dlsym(dll* dll, symbol_char* symbol);
737 void* ffi_dlsym_raw(dll* dll, symbol_char* symbol);
739 void* ffi_dlsym_toc(dll* dll, symbol_char* symbol);
741 void ffi_dlclose(dll* dll);
742 void c_to_factor_toplevel(cell quot);
744 void start_sampling_profiler_timer();
745 void end_sampling_profiler_timer();
746 static void open_console();
747 static void close_console();
748 static void lock_console();
749 static void unlock_console();
750 static void ignore_ctrl_c();
751 static void handle_ctrl_c();
755 HANDLE sampler_thread;
756 void sampler_thread_loop();
758 const vm_char* vm_executable_path();
759 const vm_char* default_image_path();
760 void windows_image_path(vm_char* full_path, vm_char* temp_path,
761 unsigned int length);
762 BOOL windows_stat(vm_char* path);
764 LONG exception_handler(PEXCEPTION_RECORD e, void* frame, PCONTEXT c,
768 void dispatch_signal(void* uap, void(handler)());
769 void unix_init_signals();
773 void call_fault_handler(exception_type_t exception,
774 exception_data_type_t code,
775 MACH_EXC_STATE_TYPE* exc_state,
776 MACH_THREAD_STATE_TYPE* thread_state,
777 MACH_FLOAT_STATE_TYPE* float_state);
780 factor_vm(THREADHANDLE thread_id);