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 /* External entry points */
70 c_to_factor_func_type c_to_factor_func;
72 /* Is profiling enabled? */
73 volatile cell sampling_profiler_p;
74 fixnum samples_per_second;
76 /* Global variables used to pass fault handler state from signal handler
78 bool signal_resumable;
80 cell signal_fault_addr;
82 unsigned int signal_fpu_status;
84 /* Pipe used to notify Factor multiplexer of signals */
85 int signal_pipe_input, signal_pipe_output;
87 /* State kept by the sampling profiler */
88 std::vector<profiling_sample> samples;
89 std::vector<cell> sample_callstacks;
91 /* GC is off during heap walking */
100 /* Pinned callback stubs */
101 callback_heap* callbacks;
103 /* Only set if we're performing a GC */
104 gc_state* current_gc;
105 volatile cell current_gc_p;
107 /* Set if we're in the jit */
108 volatile fixnum current_jit_count;
110 /* Mark stack used for mark & sweep GC */
111 std::vector<cell> mark_stack;
113 /* If not NULL, we push GC events here */
114 std::vector<gc_event>* gc_events;
116 /* If a runtime function needs to call another function which potentially
117 allocates memory, it must wrap any references to the data and code
118 heaps with data_root and code_root smart pointers, which register
119 themselves here. See data_roots.hpp and code_roots.hpp */
121 std::vector<cell*> data_roots;
122 std::vector<code_root*> code_roots;
126 bool fep_help_was_shown;
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();
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, vm_error_type error);
165 cell datastack_to_array(context* ctx);
166 void primitive_datastack_for();
167 cell retainstack_to_array(context* ctx);
168 void primitive_retainstack_for();
169 cell array_to_stack(array* array, cell bottom);
170 void set_datastack(context* ctx, array* array);
171 void primitive_set_datastack();
172 void set_retainstack(context* ctx, array* array);
173 void primitive_set_retainstack();
174 void primitive_check_datastack();
175 void primitive_load_locals();
178 void primitive_exit();
179 void primitive_nano_count();
180 void primitive_sleep();
181 void primitive_set_slot();
184 void primitive_special_object();
185 void primitive_set_special_object();
186 void primitive_identity_hashcode();
187 void primitive_compute_identity_hashcode();
188 cell clone_object(cell obj_);
189 void primitive_clone();
190 void primitive_become();
193 void clear_samples();
194 void record_sample(bool prolog_p);
195 void record_callstack_sample(cell* begin, cell* end, bool prolog_p);
196 void start_sampling_profiler(fixnum rate);
197 void end_sampling_profiler();
198 void set_sampling_profiler(fixnum rate);
199 void primitive_sampling_profiler();
200 void primitive_get_samples();
203 void general_error(vm_error_type error, cell arg1, cell arg2);
204 void type_error(cell type, cell tagged);
205 void not_implemented_error();
206 void verify_memory_protection_error(cell addr);
207 void divide_by_zero_error();
208 void primitive_unimplemented();
209 void memory_signal_handler_impl();
210 void synchronous_signal_handler_impl();
211 void fp_signal_handler_impl();
214 int bignum_equal_p(bignum* x, bignum* y);
215 enum bignum_comparison bignum_compare(bignum* x, bignum* y);
216 bignum* bignum_add(bignum* x, bignum* y);
217 bignum* bignum_subtract(bignum* x, bignum* y);
218 bignum* bignum_square(bignum* x_);
219 bignum* bignum_multiply(bignum* x, bignum* y);
220 void bignum_divide(bignum* numerator, bignum* denominator, bignum** quotient,
222 bignum* bignum_quotient(bignum* numerator, bignum* denominator);
223 bignum* bignum_remainder(bignum* numerator, bignum* denominator);
224 fixnum bignum_to_fixnum_strict(bignum* bn);
225 bignum* double_to_bignum(double x);
226 int bignum_equal_p_unsigned(bignum* x, bignum* y);
227 enum bignum_comparison bignum_compare_unsigned(bignum* x, bignum* y);
228 bignum* bignum_add_unsigned(bignum* x_, bignum* y_, int negative_p);
229 bignum* bignum_subtract_unsigned(bignum* x_, bignum* y_);
230 bignum* bignum_multiply_unsigned(bignum* x_, bignum* y_, int negative_p);
231 bignum* bignum_multiply_unsigned_small_factor(bignum* x, bignum_digit_type y,
233 void bignum_destructive_add(bignum* bn, bignum_digit_type n);
234 void bignum_destructive_scale_up(bignum* bn, bignum_digit_type factor);
235 void bignum_divide_unsigned_large_denominator(
236 bignum* numerator_, bignum* denominator_, bignum** quotient,
237 bignum** remainder, int q_negative_p, int r_negative_p);
238 void bignum_divide_unsigned_normalized(bignum* u, bignum* v, bignum* q);
239 bignum_digit_type bignum_divide_subtract(bignum_digit_type* v_start,
240 bignum_digit_type* v_end,
241 bignum_digit_type guess,
242 bignum_digit_type* u_start);
243 void bignum_divide_unsigned_medium_denominator(
244 bignum* numerator_, bignum_digit_type denominator, bignum** quotient,
245 bignum** remainder, int q_negative_p, int r_negative_p);
246 void bignum_destructive_normalization(bignum* source, bignum* target,
248 void bignum_destructive_unnormalization(bignum* bn, int shift_right);
249 bignum_digit_type bignum_digit_divide(
250 bignum_digit_type uh, bignum_digit_type ul, bignum_digit_type v,
251 bignum_digit_type* q) /* return value */;
252 bignum_digit_type bignum_digit_divide_subtract(bignum_digit_type v1,
253 bignum_digit_type v2,
254 bignum_digit_type guess,
255 bignum_digit_type* u);
256 void bignum_divide_unsigned_small_denominator(
257 bignum* numerator_, bignum_digit_type denominator, bignum** quotient,
258 bignum** remainder, int q_negative_p, int r_negative_p);
259 bignum_digit_type bignum_destructive_scale_down(
260 bignum* bn, bignum_digit_type denominator);
261 bignum* bignum_remainder_unsigned_small_denominator(bignum* n,
264 bignum* bignum_digit_to_bignum(bignum_digit_type digit, int negative_p);
265 bignum* allot_bignum(bignum_length_type length, int negative_p);
266 bignum* allot_bignum_zeroed(bignum_length_type length, int negative_p);
267 bignum* bignum_shorten_length(bignum* bn, bignum_length_type length);
268 bignum* bignum_trim(bignum* bn);
269 bignum* bignum_new_sign(bignum* x_, int negative_p);
270 bignum* bignum_maybe_new_sign(bignum* x_, int negative_p);
271 void bignum_destructive_copy(bignum* source, bignum* target);
272 bignum* bignum_bitwise_not(bignum* x_);
273 bignum* bignum_arithmetic_shift(bignum* arg1, fixnum n);
274 bignum* bignum_bitwise_and(bignum* arg1, bignum* arg2);
275 bignum* bignum_bitwise_ior(bignum* arg1, bignum* arg2);
276 bignum* bignum_bitwise_xor(bignum* arg1, bignum* arg2);
277 bignum* bignum_magnitude_ash(bignum* arg1_, fixnum n);
278 bignum* bignum_pospos_bitwise_op(int op, bignum* arg1_, bignum* arg2_);
279 bignum* bignum_posneg_bitwise_op(int op, bignum* arg1_, bignum* arg2_);
280 bignum* bignum_negneg_bitwise_op(int op, bignum* arg1_, bignum* arg2_);
281 void bignum_negate_magnitude(bignum* arg);
282 bignum* bignum_integer_length(bignum* x_);
283 int bignum_logbitp(int shift, bignum* arg);
284 int bignum_unsigned_logbitp(int shift, bignum* bn);
285 bignum* bignum_gcd(bignum* a_, bignum* b_);
288 void set_data_heap(data_heap* data_);
289 void init_data_heap(cell young_size, cell aging_size, cell tenured_size);
290 void primitive_size();
291 data_heap_room data_room();
292 void primitive_data_room();
293 cell instances(cell type);
294 void primitive_all_instances();
296 template <typename Generation, typename Iterator>
297 inline void each_object(Generation* gen, Iterator& iterator) {
298 cell obj = gen->first_object();
300 iterator((object*)obj);
301 obj = gen->next_object_after(obj);
305 template <typename Iterator> inline void each_object(Iterator& iterator) {
307 /* The nursery can't be iterated because there may be gaps between
308 the objects (see factor_vm::reallot_array) so we require it to
310 FACTOR_ASSERT(data->nursery->occupied_space() == 0);
313 each_object(data->tenured, iterator);
314 each_object(data->aging, iterator);
318 template <typename Iterator>
319 inline void each_object_each_slot(Iterator& iterator) {
320 auto each_object_func = [&](object* obj) {
321 auto each_slot_func = [&](cell* slot) {
324 obj->each_slot(each_slot_func);
326 each_object(each_object_func);
329 /* the write barrier must be called any time we are potentially storing a
330 pointer from an older generation to a younger one */
331 inline void write_barrier(cell* slot_ptr) {
332 *(unsigned char*)(cards_offset + ((cell)slot_ptr >> card_bits)) = card_mark_mask;
333 *(unsigned char*)(decks_offset + ((cell)slot_ptr >> deck_bits)) = card_mark_mask;
336 inline void write_barrier(object* obj, cell size) {
337 cell start = (cell)obj & (~card_size + 1);
338 cell end = ((cell)obj + size + card_size - 1) & (~card_size + 1);
340 for (cell offset = start; offset < end; offset += card_size)
341 write_barrier((cell*)offset);
345 void check_data_heap();
349 void set_current_gc_op(gc_op op);
350 void start_gc_again();
351 void collect_nursery();
352 void collect_aging();
353 void collect_to_tenured();
354 void update_code_roots_for_sweep();
355 void update_code_roots_for_compaction();
356 void collect_mark_impl();
357 void collect_sweep_impl();
359 void collect_compact_impl();
360 void collect_compact();
361 void collect_growing_heap(cell requested_size);
362 void gc(gc_op op, cell requested_size);
363 void primitive_minor_gc();
364 void primitive_full_gc();
365 void primitive_compact_gc();
366 void primitive_enable_gc_events();
367 void primitive_disable_gc_events();
368 object* allot_object(cell type, cell size);
369 object* allot_large_object(cell type, cell size);
371 /* Allocates memory */
372 template <typename Type> Type* allot(cell size) {
373 return (Type*)allot_object(Type::type_number, size);
377 template <typename Array> Array* allot_uninitialized_array(cell capacity);
378 template <typename Array>
379 bool reallot_array_in_place_p(Array* array, cell capacity);
380 template <typename Array> Array* reallot_array(Array* array_, cell capacity);
383 void print_chars(ostream& out, string* str);
384 void print_word(ostream& out, word* word, cell nesting);
385 void print_factor_string(ostream& out, string* str);
386 void print_array(ostream& out, array* array, cell nesting);
387 void print_byte_array(ostream& out, byte_array* array, cell nesting);
388 void print_tuple(ostream& out, tuple* tuple, cell nesting);
389 void print_alien(ostream& out, alien* alien, cell nesting);
390 void print_nested_obj(ostream& out, cell obj, fixnum nesting);
391 void print_obj(ostream& out, cell obj);
392 void print_objects(ostream& out, cell* start, cell* end);
393 void print_datastack(ostream& out);
394 void print_retainstack(ostream& out);
395 void print_callstack(ostream& out);
396 void print_callstack_object(ostream& out, callstack* obj);
397 void dump_cell(ostream& out, cell x);
398 void dump_memory(ostream& out, cell from, cell to);
399 void dump_memory_layout(ostream& out);
400 void dump_objects(ostream& out, cell type);
401 void dump_edges(ostream& out);
402 void find_data_references(ostream& out, cell look_for_);
403 void dump_code_heap(ostream& out);
404 void factorbug_usage(bool advanced_p);
406 void primitive_die();
409 inline void set_array_nth(array* array, cell slot, cell value);
410 array* allot_array(cell capacity, cell fill_);
411 void primitive_array();
412 cell allot_array_4(cell v1_, cell v2_, cell v3_, cell v4_);
413 void primitive_resize_array();
414 cell std_vector_to_array(std::vector<cell>& elements);
417 string* allot_string_internal(cell capacity);
418 void fill_string(string* str_, cell start, cell capacity, cell fill);
419 string* allot_string(cell capacity, cell fill);
420 void primitive_string();
421 bool reallot_string_in_place_p(string* str, cell capacity);
422 string* reallot_string(string* str_, cell capacity);
423 void primitive_resize_string();
424 void primitive_set_string_nth_fast();
427 cell tag_boolean(cell untagged) {
428 return untagged ? special_objects[OBJ_CANONICAL_TRUE] : false_object;
432 byte_array* allot_byte_array(cell size);
433 void primitive_byte_array();
434 void primitive_uninitialized_byte_array();
435 void primitive_resize_byte_array();
437 template <typename Type> byte_array* byte_array_from_value(Type* value);
440 void primitive_tuple();
441 void primitive_tuple_boa();
444 word* allot_word(cell name_, cell vocab_, cell hashcode_);
445 void primitive_word();
446 void primitive_word_code();
447 void primitive_word_optimized_p();
448 void primitive_wrapper();
449 void jit_compile_word(cell word_, cell def_, bool relocating);
452 void primitive_bignum_to_fixnum();
453 void primitive_bignum_to_fixnum_strict();
454 void primitive_float_to_fixnum();
455 void primitive_fixnum_divint();
456 void primitive_fixnum_divmod();
457 bignum* fixnum_to_bignum(fixnum);
458 bignum* cell_to_bignum(cell);
459 bignum* long_long_to_bignum(int64_t n);
460 bignum* ulong_long_to_bignum(uint64_t n);
461 inline fixnum sign_mask(fixnum x);
462 inline fixnum branchless_max(fixnum x, fixnum y);
463 inline fixnum branchless_abs(fixnum x);
464 void primitive_fixnum_shift();
465 void primitive_fixnum_to_bignum();
466 void primitive_float_to_bignum();
467 void primitive_bignum_eq();
468 void primitive_bignum_add();
469 void primitive_bignum_subtract();
470 void primitive_bignum_multiply();
471 void primitive_bignum_divint();
472 void primitive_bignum_divmod();
473 void primitive_bignum_mod();
474 void primitive_bignum_gcd();
475 void primitive_bignum_and();
476 void primitive_bignum_or();
477 void primitive_bignum_xor();
478 void primitive_bignum_shift();
479 void primitive_bignum_less();
480 void primitive_bignum_lesseq();
481 void primitive_bignum_greater();
482 void primitive_bignum_greatereq();
483 void primitive_bignum_not();
484 void primitive_bignum_bitp();
485 void primitive_bignum_log2();
486 inline cell unbox_array_size();
487 void primitive_fixnum_to_float();
488 void primitive_format_float();
489 void primitive_float_eq();
490 void primitive_float_add();
491 void primitive_float_subtract();
492 void primitive_float_multiply();
493 void primitive_float_divfloat();
494 void primitive_float_less();
495 void primitive_float_lesseq();
496 void primitive_float_greater();
497 void primitive_float_greatereq();
498 void primitive_float_bits();
499 void primitive_bits_float();
500 void primitive_double_bits();
501 void primitive_bits_double();
502 fixnum to_fixnum(cell tagged);
503 fixnum to_fixnum_strict(cell tagged);
504 cell to_cell(cell tagged);
505 cell from_signed_8(int64_t n);
506 int64_t to_signed_8(cell obj);
507 cell from_unsigned_8(uint64_t n);
508 uint64_t to_unsigned_8(cell obj);
509 float to_float(cell value);
510 double to_double(cell value);
511 inline void overflow_fixnum_add(fixnum x, fixnum y);
512 inline void overflow_fixnum_subtract(fixnum x, fixnum y);
513 inline void overflow_fixnum_multiply(fixnum x, fixnum y);
514 inline cell from_signed_cell(fixnum x);
515 inline cell from_unsigned_cell(cell x);
516 inline cell allot_float(double n);
517 inline bignum* float_to_bignum(cell tagged);
518 inline double untag_float(cell tagged);
519 inline double untag_float_check(cell tagged);
520 inline fixnum float_to_fixnum(cell tagged);
521 inline double fixnum_to_float(cell tagged);
524 template <typename Type> void check_tagged(tagged<Type> t) {
526 type_error(Type::type_number, t.value_);
529 template <typename Type> Type* untag_check(cell value) {
530 tagged<Type> t(value);
537 void io_error_if_not_EINTR();
538 FILE* safe_fopen(char* filename, const char* mode);
539 int safe_fgetc(FILE* stream);
540 size_t safe_fread(void* ptr, size_t size, size_t nitems, FILE* stream);
541 void safe_fputc(int c, FILE* stream);
542 size_t safe_fwrite(void* ptr, size_t size, size_t nitems, FILE* stream);
543 int safe_ftell(FILE* stream);
544 void safe_fseek(FILE* stream, off_t offset, int whence);
545 void safe_fflush(FILE* stream);
546 void primitive_fopen();
547 FILE* pop_file_handle();
548 FILE* peek_file_handle();
549 void primitive_fgetc();
550 void primitive_fread();
551 void primitive_fputc();
552 void primitive_fwrite();
553 void primitive_ftell();
554 void primitive_fseek();
555 void primitive_fflush();
556 void primitive_fclose();
559 cell compute_entry_point_pic_address(word* w, cell tagged_quot);
560 cell compute_entry_point_pic_address(cell w_);
561 cell compute_entry_point_pic_tail_address(cell w_);
562 cell compute_external_address(instruction_operand op);
564 void update_word_references(code_block* compiled, bool reset_inline_caches);
565 void undefined_symbol();
566 cell compute_dlsym_address(array* literals, cell index, bool toc);
567 cell lookup_external_address(relocation_type rel_type,
568 code_block* compiled,
571 cell compute_here_address(cell arg, cell offset, code_block* compiled);
572 void initialize_code_block(code_block* compiled, cell literals);
573 void initialize_code_block(code_block* compiled);
574 void fixup_labels(array* labels, code_block* compiled);
575 code_block* allot_code_block(cell size, code_block_type type);
576 code_block* add_code_block(code_block_type type, cell code_, cell labels_,
577 cell owner_, cell relocation_, cell parameters_,
578 cell literals_, cell frame_size_untagged);
581 template <typename Iterator> void each_code_block(Iterator& iter) {
582 code->allocator->iterate(iter);
585 void update_code_heap_words(bool reset_inline_caches);
586 void initialize_code_blocks();
587 void primitive_modify_code_heap();
588 void primitive_code_room();
589 void primitive_strip_stack_traces();
590 void primitive_code_blocks();
593 void primitive_free_callback();
594 void primitive_callback();
595 void primitive_callback_room();
598 void load_data_heap(FILE* file, image_header* h, vm_parameters* p);
599 void load_code_heap(FILE* file, image_header* h, vm_parameters* p);
600 bool save_image(const vm_char* saving_filename, const vm_char* filename);
601 void primitive_save_image();
602 void fixup_heaps(cell data_offset, cell code_offset);
603 FILE* open_image(vm_parameters* p);
604 void load_image(vm_parameters* p);
605 bool read_embedded_image_footer(FILE* file, embedded_image_footer* footer);
606 bool embedded_image_p();
608 template <typename Iterator, typename Fixup>
609 void iterate_callstack_object(callstack* stack_, Iterator& iterator,
611 template <typename Iterator>
612 void iterate_callstack_object(callstack* stack_, Iterator& iterator);
614 callstack* allot_callstack(cell size);
615 cell second_from_top_stack_frame(context* ctx);
616 cell capture_callstack(context* ctx);
617 void primitive_callstack_for();
618 void primitive_callstack_to_array();
619 void primitive_innermost_stack_frame_executing();
620 void primitive_innermost_stack_frame_scan();
621 void primitive_set_innermost_stack_frame_quotation();
622 void primitive_callstack_bounds();
624 template <typename Iterator, typename Fixup>
625 void iterate_callstack(context* ctx, Iterator& iterator, Fixup& fixup);
626 template <typename Iterator>
627 void iterate_callstack(context* ctx, Iterator& iterator);
630 void dispatch_signal_handler(cell* sp, cell* pc, cell newpc);
631 #if defined(FACTOR_X86) || defined(FACTOR_64)
632 void dispatch_non_resumable_signal(cell* sp, cell* pc,
635 void dispatch_resumable_signal(cell* sp, cell* pc, cell handler);
639 char* pinned_alien_offset(cell obj);
640 cell allot_alien(cell delegate_, cell displacement);
641 cell allot_alien(cell address);
642 void primitive_displaced_alien();
643 void primitive_alien_address();
644 void* alien_pointer();
645 void primitive_dlopen();
646 void primitive_dlsym();
647 void primitive_dlsym_raw();
648 void primitive_dlclose();
649 void primitive_dll_validp();
650 char* alien_offset(cell obj);
653 void primitive_jit_compile();
654 cell lazy_jit_compile_entry_point();
655 void primitive_array_to_quotation();
656 void primitive_quotation_code();
657 code_block* jit_compile_quotation(cell owner_, cell quot_, bool relocating);
658 void jit_compile_quotation(cell quot_, bool relocating);
659 fixnum quot_code_offset_to_scan(cell quot_, cell offset);
660 cell lazy_jit_compile(cell quot);
661 bool quotation_compiled_p(quotation* quot);
662 void primitive_quotation_compiled_p();
665 cell search_lookup_alist(cell table, cell klass);
666 cell search_lookup_hash(cell table, cell klass, cell hashcode);
667 cell nth_superclass(tuple_layout* layout, fixnum echelon);
668 cell nth_hashcode(tuple_layout* layout, fixnum echelon);
669 cell lookup_tuple_method(cell obj, cell methods);
670 cell lookup_method(cell obj, cell methods);
671 void primitive_lookup_method();
672 cell object_class(cell obj);
673 cell method_cache_hashcode(cell klass, array* array);
674 void update_method_cache(cell cache, cell klass, cell method);
675 void primitive_mega_cache_miss();
676 void primitive_reset_dispatch_stats();
677 void primitive_dispatch_stats();
680 void init_inline_caching(int max_size);
681 void deallocate_inline_cache(cell return_address);
682 cell determine_inline_cache_type(array* cache_entries);
683 void update_pic_count(cell type);
684 code_block* compile_inline_cache(fixnum index, cell generic_word_,
685 cell methods_, cell cache_entries_,
687 cell inline_cache_size(cell cache_entries);
688 cell add_inline_cache_entry(cell cache_entries_, cell klass_, cell method_);
689 void update_pic_transitions(cell pic_size);
690 cell inline_cache_miss(cell return_address);
693 void c_to_factor(cell quot);
694 void unwind_native_frames(cell quot, cell to);
695 cell get_fpu_state();
696 void set_fpu_state(cell state);
699 void default_parameters(vm_parameters* p);
700 bool factor_arg(const vm_char* str, const vm_char* arg, cell* value);
701 void init_parameters_from_args(vm_parameters* p, int argc, vm_char** argv);
702 void prepare_boot_image();
703 void init_factor(vm_parameters* p);
704 void pass_args_to_factor(int argc, vm_char** argv);
706 void start_embedded_factor(vm_parameters* p);
707 void start_standalone_factor(int argc, vm_char** argv);
708 char* factor_eval_string(char* string);
709 void factor_eval_free(char* result);
711 void factor_sleep(long us);
714 void primitive_existsp();
716 void ffi_dlopen(dll* dll);
717 cell ffi_dlsym(dll* dll, symbol_char* symbol);
718 cell ffi_dlsym_raw(dll* dll, symbol_char* symbol);
719 void ffi_dlclose(dll* dll);
720 void c_to_factor_toplevel(cell quot);
722 void start_sampling_profiler_timer();
723 void end_sampling_profiler_timer();
727 HANDLE sampler_thread;
728 void sampler_thread_loop();
730 const vm_char* vm_executable_path();
731 const vm_char* default_image_path();
732 BOOL windows_stat(vm_char* path);
734 LONG exception_handler(PEXCEPTION_RECORD e, void* frame, PCONTEXT c,
738 void dispatch_signal(void* uap, void(handler)());
739 void unix_init_signals();
743 void call_fault_handler(exception_type_t exception,
744 exception_data_type_t code,
745 MACH_EXC_STATE_TYPE* exc_state,
746 MACH_THREAD_STATE_TYPE* thread_state,
747 MACH_FLOAT_STATE_TYPE* float_state);
750 factor_vm(THREADHANDLE thread_id);