6 // First five fields accessed directly by assembler. See vm.factor
8 zone nursery; /* new objects are allocated here */
11 cell userenv[USER_ENV]; /* TAGGED user environment data; see getenv/setenv prims */
14 cell ds_size, rs_size;
15 context *unused_contexts;
17 void reset_datastack();
18 void reset_retainstack();
21 context *alloc_context();
22 void dealloc_context(context *old_context);
25 void init_stacks(cell ds_size_, cell rs_size_);
26 bool stack_to_array(cell bottom, cell top);
27 cell array_to_stack(array *array, cell bottom);
28 void primitive_datastack();
29 void primitive_retainstack();
30 void primitive_set_datastack();
31 void primitive_set_retainstack();
32 void primitive_check_datastack();
35 cell T; /* Canonical T object. It's just a word */
37 void primitive_getenv();
38 void primitive_setenv();
39 void primitive_exit();
40 void primitive_micros();
41 void primitive_sleep();
42 void primitive_set_slot();
43 void primitive_load_locals();
44 cell clone_object(cell obj_);
45 void primitive_clone();
51 code_block *compile_profiling_stub(cell word_);
52 void set_profiling(bool profiling);
53 void primitive_profiling();
56 /* Global variables used to pass fault handler state from signal handler to
59 cell signal_fault_addr;
60 unsigned int signal_fpu_status;
61 stack_frame *signal_callstack_top;
64 void critical_error(const char* msg, cell tagged);
65 void throw_error(cell error, stack_frame *callstack_top);
66 void not_implemented_error();
67 bool in_page(cell fault, cell area, cell area_size, int offset);
68 void memory_protection_error(cell addr, stack_frame *native_stack);
69 void signal_error(int signal, stack_frame *native_stack);
70 void divide_by_zero_error();
71 void fp_trap_error(unsigned int fpu_status, stack_frame *signal_callstack_top);
72 void primitive_call_clear();
73 void primitive_unimplemented();
74 void memory_signal_handler_impl();
75 void misc_signal_handler_impl();
76 void fp_signal_handler_impl();
77 void type_error(cell type, cell tagged);
78 void general_error(vm_error_type error, cell arg1, cell arg2, stack_frame *native_stack);
81 int bignum_equal_p(bignum * x, bignum * y);
82 enum bignum_comparison bignum_compare(bignum * x, bignum * y);
83 bignum *bignum_add(bignum * x, bignum * y);
84 bignum *bignum_subtract(bignum * x, bignum * y);
85 bignum *bignum_multiply(bignum * x, bignum * y);
86 void bignum_divide(bignum * numerator, bignum * denominator, bignum * * quotient, bignum * * remainder);
87 bignum *bignum_quotient(bignum * numerator, bignum * denominator);
88 bignum *bignum_remainder(bignum * numerator, bignum * denominator);
89 cell bignum_to_cell(bignum * bignum);
90 fixnum bignum_to_fixnum(bignum * bignum);
91 s64 bignum_to_long_long(bignum * bignum);
92 u64 bignum_to_ulong_long(bignum * bignum);
93 double bignum_to_double(bignum * bignum);
94 bignum *double_to_bignum(double x);
95 int bignum_equal_p_unsigned(bignum * x, bignum * y);
96 enum bignum_comparison bignum_compare_unsigned(bignum * x, bignum * y);
97 bignum *bignum_add_unsigned(bignum * x, bignum * y, int negative_p);
98 bignum *bignum_subtract_unsigned(bignum * x, bignum * y);
99 bignum *bignum_multiply_unsigned(bignum * x, bignum * y, int negative_p);
100 bignum *bignum_multiply_unsigned_small_factor(bignum * x, bignum_digit_type y,int negative_p);
101 void bignum_destructive_add(bignum * bignum, bignum_digit_type n);
102 void bignum_destructive_scale_up(bignum * bignum, bignum_digit_type factor);
103 void bignum_divide_unsigned_large_denominator(bignum * numerator, bignum * denominator,
104 bignum * * quotient, bignum * * remainder, int q_negative_p, int r_negative_p);
105 void bignum_divide_unsigned_normalized(bignum * u, bignum * v, bignum * q);
106 bignum_digit_type bignum_divide_subtract(bignum_digit_type * v_start, bignum_digit_type * v_end,
107 bignum_digit_type guess, bignum_digit_type * u_start);
108 void bignum_divide_unsigned_medium_denominator(bignum * numerator,bignum_digit_type denominator,
109 bignum * * quotient, bignum * * remainder,int q_negative_p, int r_negative_p);
110 void bignum_destructive_normalization(bignum * source, bignum * target, int shift_left);
111 void bignum_destructive_unnormalization(bignum * bignum, int shift_right);
112 bignum_digit_type bignum_digit_divide(bignum_digit_type uh, bignum_digit_type ul,
113 bignum_digit_type v, bignum_digit_type * q) /* return value */;
114 bignum_digit_type bignum_digit_divide_subtract(bignum_digit_type v1, bignum_digit_type v2,
115 bignum_digit_type guess, bignum_digit_type * u);
116 void bignum_divide_unsigned_small_denominator(bignum * numerator, bignum_digit_type denominator,
117 bignum * * quotient, bignum * * remainder,int q_negative_p, int r_negative_p);
118 bignum_digit_type bignum_destructive_scale_down(bignum * bignum, bignum_digit_type denominator);
119 bignum * bignum_remainder_unsigned_small_denominator(bignum * n, bignum_digit_type d, int negative_p);
120 bignum *bignum_digit_to_bignum(bignum_digit_type digit, int negative_p);
121 bignum *allot_bignum(bignum_length_type length, int negative_p);
122 bignum * allot_bignum_zeroed(bignum_length_type length, int negative_p);
123 bignum *bignum_shorten_length(bignum * bignum, bignum_length_type length);
124 bignum *bignum_trim(bignum * bignum);
125 bignum *bignum_new_sign(bignum * x, int negative_p);
126 bignum *bignum_maybe_new_sign(bignum * x, int negative_p);
127 void bignum_destructive_copy(bignum * source, bignum * target);
128 bignum *bignum_bitwise_not(bignum * x);
129 bignum *bignum_arithmetic_shift(bignum * arg1, fixnum n);
130 bignum *bignum_bitwise_and(bignum * arg1, bignum * arg2);
131 bignum *bignum_bitwise_ior(bignum * arg1, bignum * arg2);
132 bignum *bignum_bitwise_xor(bignum * arg1, bignum * arg2);
133 bignum *bignum_magnitude_ash(bignum * arg1, fixnum n);
134 bignum *bignum_pospos_bitwise_op(int op, bignum * arg1, bignum * arg2);
135 bignum *bignum_posneg_bitwise_op(int op, bignum * arg1, bignum * arg2);
136 bignum *bignum_negneg_bitwise_op(int op, bignum * arg1, bignum * arg2);
137 void bignum_negate_magnitude(bignum * arg);
138 bignum *bignum_integer_length(bignum * x);
139 int bignum_logbitp(int shift, bignum * arg);
140 int bignum_unsigned_logbitp(int shift, bignum * bignum);
141 bignum *digit_stream_to_bignum(unsigned int n_digits, unsigned int (*producer)(unsigned int, factor_vm *), unsigned int radix, int negative_p);
144 bool secure_gc; /* Set by the -securegc command line argument */
145 bool gc_off; /* GC is off during heap walking */
147 /* A heap walk allows useful things to be done, like finding all
148 references to an object for debugging purposes. */
151 void init_card_decks();
152 data_heap *grow_data_heap(data_heap *data, cell requested_bytes);
153 void clear_cards(cell from, cell to);
154 void clear_decks(cell from, cell to);
155 void clear_allot_markers(cell from, cell to);
156 void reset_generation(cell i);
157 void reset_generations(cell from, cell to);
158 void set_data_heap(data_heap *data_);
159 void init_data_heap(cell gens,cell young_size,cell aging_size,cell tenured_size,bool secure_gc_);
160 cell untagged_object_size(object *pointer);
161 cell unaligned_object_size(object *pointer);
162 void primitive_size();
163 cell binary_payload_start(object *pointer);
164 void primitive_data_room();
167 void primitive_begin_scan();
169 void primitive_next_object();
170 void primitive_end_scan();
171 template<typename T> void each_object(T &functor);
172 cell find_all_words();
173 cell object_size(cell tagged);
177 cell allot_markers_offset;
179 inline card *addr_to_card(cell a);
180 inline cell card_to_addr(card *c);
181 inline cell card_offset(card *c);
182 inline card_deck *addr_to_deck(cell a);
183 inline cell deck_to_addr(card_deck *c);
184 inline card *deck_to_card(card_deck *d);
185 inline card *addr_to_allot_marker(object *a);
186 inline void write_barrier(object *obj);
187 inline void allot_barrier(object *address);
190 /* used during garbage collection only */
193 bool performing_compaction;
195 /* if true, we are collecting aging space for the second time, so if it is still
196 full, we go on to collect tenured */
197 bool collecting_aging_again;
198 /* in case a generation fills up in the middle of a gc, we jump back
199 up to try collecting the next generation. */
201 gc_stats stats[max_gen_count];
205 cell code_heap_scans;
206 /* What generation was being collected when copy_code_heap_roots() was last
207 called? Until the next call to add_code_block(), future
208 collections of younger generations don't have to touch the code
210 cell last_code_heap_scan;
211 /* sometimes we grow the heap */
212 bool growing_data_heap;
213 data_heap *old_data_heap;
216 object *copy_untagged_object_impl(object *pointer, cell size);
217 object *copy_object_impl(object *untagged);
218 bool should_copy_p(object *untagged);
219 object *resolve_forwarding(object *untagged);
220 template <typename T> T *copy_untagged_object(T *untagged);
221 cell copy_object(cell pointer);
222 void copy_handle(cell *handle);
223 void copy_card(card *ptr, cell gen, cell here);
224 void copy_card_deck(card_deck *deck, cell gen, card mask, card unmask);
225 void copy_gen_cards(cell gen);
227 void copy_stack_elements(segment *region, cell top);
228 void copy_registered_locals();
229 void copy_registered_bignums();
231 cell copy_next_from_nursery(cell scan);
232 cell copy_next_from_aging(cell scan);
233 cell copy_next_from_tenured(cell scan);
234 void copy_reachable_objects(cell scan, cell *end);
235 void begin_gc(cell requested_bytes);
236 void end_gc(cell gc_elapsed);
237 void garbage_collection(cell gen,bool growing_data_heap_,cell requested_bytes);
240 void primitive_gc_stats();
241 void clear_gc_stats();
242 void primitive_become();
243 void inline_gc(cell *gc_roots_base, cell gc_roots_size);
244 inline bool collecting_accumulation_gen_p();
245 inline object *allot_zone(zone *z, cell a);
246 inline object *allot_object(header header, cell size);
247 template <typename TYPE> TYPE *allot(cell size);
248 inline void check_data_pointer(object *pointer);
249 inline void check_tagged_pointer(cell tagged);
250 void primitive_clear_gc_stats();
253 /* If a runtime function needs to call another function which potentially
254 allocates memory, it must wrap any local variable references to Factor
255 objects in gc_root instances */
256 std::vector<cell> gc_locals;
257 std::vector<cell> gc_bignums;
260 template <typename T> T *allot_array_internal(cell capacity);
261 template <typename T> bool reallot_array_in_place_p(T *array, cell capacity);
262 template <typename TYPE> TYPE *reallot_array(TYPE *array_, cell capacity);
270 void print_chars(string* str);
271 void print_word(word* word, cell nesting);
272 void print_factor_string(string* str);
273 void print_array(array* array, cell nesting);
274 void print_tuple(tuple *tuple, cell nesting);
275 void print_nested_obj(cell obj, fixnum nesting);
276 void print_obj(cell obj);
277 void print_objects(cell *start, cell *end);
278 void print_datastack();
279 void print_retainstack();
280 void print_stack_frame(stack_frame *frame);
281 void print_callstack();
282 void dump_cell(cell x);
283 void dump_memory(cell from, cell to);
284 void dump_zone(zone *z);
285 void dump_generations();
286 void dump_objects(cell type);
287 void find_data_references_step(cell *scan);
288 void find_data_references(cell look_for_);
289 void dump_code_heap();
291 void primitive_die();
294 array *allot_array(cell capacity, cell fill_);
295 void primitive_array();
296 cell allot_array_1(cell obj_);
297 cell allot_array_2(cell v1_, cell v2_);
298 cell allot_array_4(cell v1_, cell v2_, cell v3_, cell v4_);
299 void primitive_resize_array();
300 inline void set_array_nth(array *array, cell slot, cell value);
303 cell string_nth(string* str, cell index);
304 void set_string_nth_fast(string *str, cell index, cell ch);
305 void set_string_nth_slow(string *str_, cell index, cell ch);
306 void set_string_nth(string *str, cell index, cell ch);
307 string *allot_string_internal(cell capacity);
308 void fill_string(string *str_, cell start, cell capacity, cell fill);
309 string *allot_string(cell capacity, cell fill);
310 void primitive_string();
311 bool reallot_string_in_place_p(string *str, cell capacity);
312 string* reallot_string(string *str_, cell capacity);
313 void primitive_resize_string();
314 void primitive_string_nth();
315 void primitive_set_string_nth_fast();
316 void primitive_set_string_nth_slow();
319 void box_boolean(bool value);
320 bool to_boolean(cell value);
321 inline cell tag_boolean(cell untagged);
324 byte_array *allot_byte_array(cell size);
325 void primitive_byte_array();
326 void primitive_uninitialized_byte_array();
327 void primitive_resize_byte_array();
330 tuple *allot_tuple(cell layout_);
331 void primitive_tuple();
332 void primitive_tuple_boa();
335 word *allot_word(cell name_, cell vocab_, cell hashcode_);
336 void primitive_word();
337 void primitive_word_xt();
338 void update_word_xt(cell w_);
339 void primitive_optimized_p();
340 void primitive_wrapper();
347 void primitive_bignum_to_fixnum();
348 void primitive_float_to_fixnum();
349 void primitive_fixnum_divint();
350 void primitive_fixnum_divmod();
351 bignum *fixnum_to_bignum(fixnum);
352 bignum *cell_to_bignum(cell);
353 bignum *long_long_to_bignum(s64 n);
354 bignum *ulong_long_to_bignum(u64 n);
355 inline fixnum sign_mask(fixnum x);
356 inline fixnum branchless_max(fixnum x, fixnum y);
357 inline fixnum branchless_abs(fixnum x);
358 void primitive_fixnum_shift();
359 void primitive_fixnum_to_bignum();
360 void primitive_float_to_bignum();
361 void primitive_bignum_eq();
362 void primitive_bignum_add();
363 void primitive_bignum_subtract();
364 void primitive_bignum_multiply();
365 void primitive_bignum_divint();
366 void primitive_bignum_divmod();
367 void primitive_bignum_mod();
368 void primitive_bignum_and();
369 void primitive_bignum_or();
370 void primitive_bignum_xor();
371 void primitive_bignum_shift();
372 void primitive_bignum_less();
373 void primitive_bignum_lesseq();
374 void primitive_bignum_greater();
375 void primitive_bignum_greatereq();
376 void primitive_bignum_not();
377 void primitive_bignum_bitp();
378 void primitive_bignum_log2();
379 unsigned int bignum_producer(unsigned int digit);
380 void primitive_byte_array_to_bignum();
381 cell unbox_array_size();
382 void primitive_fixnum_to_float();
383 void primitive_bignum_to_float();
384 void primitive_str_to_float();
385 void primitive_float_to_str();
386 void primitive_float_eq();
387 void primitive_float_add();
388 void primitive_float_subtract();
389 void primitive_float_multiply();
390 void primitive_float_divfloat();
391 void primitive_float_mod();
392 void primitive_float_less();
393 void primitive_float_lesseq();
394 void primitive_float_greater();
395 void primitive_float_greatereq();
396 void primitive_float_bits();
397 void primitive_bits_float();
398 void primitive_double_bits();
399 void primitive_bits_double();
400 fixnum to_fixnum(cell tagged);
401 cell to_cell(cell tagged);
402 void box_signed_1(s8 n);
403 void box_unsigned_1(u8 n);
404 void box_signed_2(s16 n);
405 void box_unsigned_2(u16 n);
406 void box_signed_4(s32 n);
407 void box_unsigned_4(u32 n);
408 void box_signed_cell(fixnum integer);
409 void box_unsigned_cell(cell cell);
410 void box_signed_8(s64 n);
411 s64 to_signed_8(cell obj);
412 void box_unsigned_8(u64 n);
413 u64 to_unsigned_8(cell obj);
414 void box_float(float flo);
415 float to_float(cell value);
416 void box_double(double flo);
417 double to_double(cell value);
418 inline void overflow_fixnum_add(fixnum x, fixnum y);
419 inline void overflow_fixnum_subtract(fixnum x, fixnum y);
420 inline void overflow_fixnum_multiply(fixnum x, fixnum y);
421 inline cell allot_integer(fixnum x);
422 inline cell allot_cell(cell x);
423 inline cell allot_float(double n);
424 inline bignum *float_to_bignum(cell tagged);
425 inline double bignum_to_float(cell tagged);
426 inline double untag_float(cell tagged);
427 inline double untag_float_check(cell tagged);
428 inline fixnum float_to_fixnum(cell tagged);
429 inline double fixnum_to_float(cell tagged);
430 template <typename T> T *untag_check(cell value);
431 template <typename T> T *untag(cell value);
436 void primitive_fopen();
437 void primitive_fgetc();
438 void primitive_fread();
439 void primitive_fputc();
440 void primitive_fwrite();
441 void primitive_fseek();
442 void primitive_fflush();
443 void primitive_fclose();
446 relocation_type relocation_type_of(relocation_entry r);
447 relocation_class relocation_class_of(relocation_entry r);
448 cell relocation_offset_of(relocation_entry r);
449 void flush_icache_for(code_block *block);
450 int number_of_parameters(relocation_type type);
451 void *object_xt(cell obj);
452 void *xt_pic(word *w, cell tagged_quot);
453 void *word_xt_pic(word *w);
454 void *word_xt_pic_tail(word *w);
455 void undefined_symbol();
456 void *get_rel_symbol(array *literals, cell index);
457 cell compute_relocation(relocation_entry rel, cell index, code_block *compiled);
458 void iterate_relocations(code_block *compiled, relocation_iterator iter);
459 void store_address_2_2(cell *ptr, cell value);
460 void store_address_masked(cell *ptr, fixnum value, cell mask, fixnum shift);
461 void store_address_in_code_block(cell klass, cell offset, fixnum absolute_value);
462 void update_literal_references_step(relocation_entry rel, cell index, code_block *compiled);
463 void update_literal_references(code_block *compiled);
464 void copy_literal_references(code_block *compiled);
465 void relocate_code_block_step(relocation_entry rel, cell index, code_block *compiled);
466 void update_word_references_step(relocation_entry rel, cell index, code_block *compiled);
467 void update_word_references(code_block *compiled);
468 void update_literal_and_word_references(code_block *compiled);
469 void check_code_address(cell address);
470 void mark_code_block(code_block *compiled);
471 void mark_stack_frame_step(stack_frame *frame);
472 void mark_active_blocks(context *stacks);
473 void mark_object_code_block(object *object);
474 void relocate_code_block(code_block *compiled);
475 void fixup_labels(array *labels, code_block *compiled);
476 code_block *allot_code_block(cell size);
477 code_block *add_code_block(cell type,cell code_,cell labels_,cell relocation_,cell literals_);
478 inline bool stack_traces_p()
480 return userenv[STACK_TRACES_ENV] != F;
485 unordered_map<heap_block *, char *> forwarding;
487 void init_code_heap(cell size);
488 bool in_code_heap_p(cell ptr);
489 void jit_compile_word(cell word_, cell def_, bool relocate);
490 void iterate_code_heap(code_heap_iterator iter);
491 void copy_code_heap_roots();
492 void update_code_heap_words();
493 void primitive_modify_code_heap();
494 void primitive_code_room();
495 code_block *forward_xt(code_block *compiled);
496 void forward_frame_xt(stack_frame *frame);
497 void forward_object_xts();
498 void fixup_object_xts();
499 void compact_code_heap();
500 inline void check_code_pointer(cell ptr);
503 cell code_relocation_base;
504 cell data_relocation_base;
506 void init_objects(image_header *h);
507 void load_data_heap(FILE *file, image_header *h, vm_parameters *p);
508 void load_code_heap(FILE *file, image_header *h, vm_parameters *p);
509 bool save_image(const vm_char *filename);
510 void primitive_save_image();
511 void primitive_save_image_and_exit();
512 void data_fixup(cell *cell);
513 template <typename T> void code_fixup(T **handle);
514 void fixup_word(word *word);
515 void fixup_quotation(quotation *quot);
516 void fixup_alien(alien *d);
517 void fixup_stack_frame(stack_frame *frame);
518 void fixup_callstack_object(callstack *stack);
519 void relocate_object(object *object);
520 void relocate_data();
521 void fixup_code_block(code_block *compiled);
522 void relocate_code();
523 void load_image(vm_parameters *p);
526 template<typename T> void iterate_callstack_object(callstack *stack_, T &iterator);
527 void check_frame(stack_frame *frame);
528 callstack *allot_callstack(cell size);
529 stack_frame *fix_callstack_top(stack_frame *top, stack_frame *bottom);
530 stack_frame *capture_start();
531 void primitive_callstack();
532 void primitive_set_callstack();
533 code_block *frame_code(stack_frame *frame);
534 cell frame_type(stack_frame *frame);
535 cell frame_executing(stack_frame *frame);
536 stack_frame *frame_successor(stack_frame *frame);
537 cell frame_scan(stack_frame *frame);
538 void primitive_callstack_to_array();
539 stack_frame *innermost_stack_frame(callstack *stack);
540 stack_frame *innermost_stack_frame_quot(callstack *callstack);
541 void primitive_innermost_stack_frame_executing();
542 void primitive_innermost_stack_frame_scan();
543 void primitive_set_innermost_stack_frame_quot();
544 void save_callstack_bottom(stack_frame *callstack_bottom);
545 template<typename T> void iterate_callstack(cell top, cell bottom, T &iterator);
546 inline void do_slots(cell obj, void (* iter)(cell *,factor_vm*));
549 char *pinned_alien_offset(cell obj);
550 cell allot_alien(cell delegate_, cell displacement);
551 void primitive_displaced_alien();
552 void primitive_alien_address();
553 void *alien_pointer();
554 void primitive_dlopen();
555 void primitive_dlsym();
556 void primitive_dlclose();
557 void primitive_dll_validp();
558 void primitive_vm_ptr();
559 char *alien_offset(cell obj);
561 void box_alien(void *ptr);
562 void to_value_struct(cell src, void *dest, cell size);
563 void box_value_struct(void *src, cell size);
564 void box_small_struct(cell x, cell y, cell size);
565 void box_medium_struct(cell x1, cell x2, cell x3, cell x4, cell size);
568 void primitive_jit_compile();
569 void primitive_array_to_quotation();
570 void primitive_quotation_xt();
571 void set_quot_xt(quotation *quot, code_block *code);
572 void jit_compile(cell quot_, bool relocating);
573 void compile_all_words();
574 fixnum quot_code_offset_to_scan(cell quot_, cell offset);
575 cell lazy_jit_compile_impl(cell quot_, stack_frame *stack);
576 void primitive_quot_compiled_p();
579 cell megamorphic_cache_hits;
580 cell megamorphic_cache_misses;
582 cell search_lookup_alist(cell table, cell klass);
583 cell search_lookup_hash(cell table, cell klass, cell hashcode);
584 cell nth_superclass(tuple_layout *layout, fixnum echelon);
585 cell nth_hashcode(tuple_layout *layout, fixnum echelon);
586 cell lookup_tuple_method(cell obj, cell methods);
587 cell lookup_hi_tag_method(cell obj, cell methods);
588 cell lookup_hairy_method(cell obj, cell methods);
589 cell lookup_method(cell obj, cell methods);
590 void primitive_lookup_method();
591 cell object_class(cell obj);
592 cell method_cache_hashcode(cell klass, array *array);
593 void update_method_cache(cell cache, cell klass, cell method);
594 void primitive_mega_cache_miss();
595 void primitive_reset_dispatch_stats();
596 void primitive_dispatch_stats();
600 cell cold_call_to_ic_transitions;
601 cell ic_to_pic_transitions;
602 cell pic_to_mega_transitions;
603 cell pic_counts[4]; /* PIC_TAG, PIC_HI_TAG, PIC_TUPLE, PIC_HI_TAG_TUPLE */
605 void init_inline_caching(int max_size);
606 void deallocate_inline_cache(cell return_address);
607 cell determine_inline_cache_type(array *cache_entries);
608 void update_pic_count(cell type);
609 code_block *compile_inline_cache(fixnum index,cell generic_word_,cell methods_,cell cache_entries_,bool tail_call_p);
610 void *megamorphic_call_stub(cell generic_word);
611 cell inline_cache_size(cell cache_entries);
612 cell add_inline_cache_entry(cell cache_entries_, cell klass_, cell method_);
613 void update_pic_transitions(cell pic_size);
614 void *inline_cache_miss(cell return_address);
615 void primitive_reset_inline_cache_stats();
616 void primitive_inline_cache_stats();
619 void default_parameters(vm_parameters *p);
620 bool factor_arg(const vm_char* str, const vm_char* arg, cell* value);
621 void init_parameters_from_args(vm_parameters *p, int argc, vm_char **argv);
622 void do_stage1_init();
623 void init_factor(vm_parameters *p);
624 void pass_args_to_factor(int argc, vm_char **argv);
625 void start_factor(vm_parameters *p);
626 void start_embedded_factor(vm_parameters *p);
627 void start_standalone_factor(int argc, vm_char **argv);
628 char *factor_eval_string(char *string);
629 void factor_eval_free(char *result);
631 void factor_sleep(long us);
634 void primitive_existsp();
636 void ffi_dlopen(dll *dll);
637 void *ffi_dlsym(dll *dll, symbol_char *symbol);
638 void ffi_dlclose(dll *dll);
639 void c_to_factor_toplevel(cell quot);
643 void sleep_micros(u64 usec);
644 const vm_char *vm_executable_path();
645 const vm_char *default_image_path();
646 void windows_image_path(vm_char *full_path, vm_char *temp_path, unsigned int length);
647 bool windows_stat(vm_char *path);
651 LONG exception_handler(PEXCEPTION_POINTERS pe);
655 void memory_signal_handler(int signal, siginfo_t *siginfo, void *uap);
656 void misc_signal_handler(int signal, siginfo_t *siginfo, void *uap);
657 void fpe_signal_handler(int signal, siginfo_t *siginfo, void *uap);
658 stack_frame *uap_stack_pointer(void *uap);
663 void call_fault_handler(exception_type_t exception, exception_data_type_t code, MACH_EXC_STATE_TYPE *exc_state, MACH_THREAD_STATE_TYPE *thread_state, MACH_FLOAT_STATE_TYPE *float_state);
667 : profiling_p(false),
670 performing_gc(false),
671 performing_compaction(false),
672 collecting_aging_again(false),
673 growing_data_heap(false),
678 memset(this,0,sizeof(this)); // just to make sure
683 #ifndef FACTOR_REENTRANT
684 #define FACTOR_SINGLE_THREADED_SINGLETON
687 #ifdef FACTOR_SINGLE_THREADED_SINGLETON
688 /* calls are dispatched using the singleton vm ptr */
689 extern factor_vm *vm;
690 #define PRIMITIVE_GETVM() vm
691 #define PRIMITIVE_OVERFLOW_GETVM() vm
694 #define SIGNAL_VM_PTR() vm
697 #ifdef FACTOR_SINGLE_THREADED_TESTING
698 /* calls are dispatched as per multithreaded, but checked against singleton */
699 extern factor_vm *vm;
700 #define ASSERTVM() assert(vm==myvm)
701 #define PRIMITIVE_GETVM() ((factor_vm*)myvm)
702 #define PRIMITIVE_OVERFLOW_GETVM() ASSERTVM(); myvm
704 #define SIGNAL_VM_PTR() tls_vm()
707 #ifdef FACTOR_REENTRANT_TLS
708 /* uses thread local storage to obtain vm ptr */
709 #define PRIMITIVE_GETVM() tls_vm()
710 #define PRIMITIVE_OVERFLOW_GETVM() tls_vm()
711 #define VM_PTR tls_vm()
713 #define SIGNAL_VM_PTR() tls_vm()
716 #ifdef FACTOR_REENTRANT
717 #define PRIMITIVE_GETVM() ((factor_vm*)myvm)
718 #define PRIMITIVE_OVERFLOW_GETVM() ((factor_vm*)myvm)
721 #define SIGNAL_VM_PTR() tls_vm()