]> gitweb.factorcode.org Git - factor.git/blob - vm/vm-data.hpp
Moved PRIMITIVE and PRIMITIVE_FORWARDs to primitives.[ch]pp
[factor.git] / vm / vm-data.hpp
1 namespace factor
2 {
3
4 struct factor_vm_data {
5         // if you change this struct, also change vm.factor k--------
6         context *stack_chain; 
7         zone nursery; /* new objects are allocated here */
8         cell cards_offset;
9         cell decks_offset;
10         cell userenv[USER_ENV]; /* TAGGED user environment data; see getenv/setenv prims */
11
12         // -------------------------------
13
14         // contexts
15         cell ds_size, rs_size;
16         context *unused_contexts;
17
18         // run
19         cell T;  /* Canonical T object. It's just a word */
20
21         // profiler
22         bool profiling_p;
23
24         // errors
25         /* Global variables used to pass fault handler state from signal handler to
26            user-space */
27         cell signal_number;
28         cell signal_fault_addr;
29         unsigned int signal_fpu_status;
30         stack_frame *signal_callstack_top;
31
32         //data_heap
33         bool secure_gc;  /* Set by the -securegc command line argument */
34         bool gc_off; /* GC is off during heap walking */
35         data_heap *data;
36         /* A heap walk allows useful things to be done, like finding all
37            references to an object for debugging purposes. */
38         cell heap_scan_ptr;
39         //write barrier
40         cell allot_markers_offset;
41         //data_gc
42         /* used during garbage collection only */
43         zone *newspace;
44         bool performing_gc;
45         bool performing_compaction;
46         cell collecting_gen;
47         /* if true, we are collecting aging space for the second time, so if it is still
48            full, we go on to collect tenured */
49         bool collecting_aging_again;
50         /* in case a generation fills up in the middle of a gc, we jump back
51            up to try collecting the next generation. */
52         jmp_buf gc_jmp;
53         gc_stats stats[max_gen_count];
54         u64 cards_scanned;
55         u64 decks_scanned;
56         u64 card_scan_time;
57         cell code_heap_scans;
58         /* What generation was being collected when copy_code_heap_roots() was last
59            called? Until the next call to add_code_block(), future
60            collections of younger generations don't have to touch the code
61            heap. */
62         cell last_code_heap_scan;
63         /* sometimes we grow the heap */
64         bool growing_data_heap;
65         data_heap *old_data_heap;
66
67         // local roots
68         /* If a runtime function needs to call another function which potentially
69            allocates memory, it must wrap any local variable references to Factor
70            objects in gc_root instances */
71         std::vector<cell> gc_locals;
72         std::vector<cell> gc_bignums;
73
74         //debug
75         bool fep_disabled;
76         bool full_output;
77         cell look_for;
78         cell obj;
79
80         //math
81         cell bignum_zero;
82         cell bignum_pos_one;
83         cell bignum_neg_one;    
84
85         //code_heap
86         heap *code;
87         unordered_map<heap_block *, char *> forwarding;
88
89         //image
90         cell code_relocation_base;
91         cell data_relocation_base;
92
93         //dispatch
94         cell megamorphic_cache_hits;
95         cell megamorphic_cache_misses;
96
97         //inline cache
98         cell max_pic_size;
99         cell cold_call_to_ic_transitions;
100         cell ic_to_pic_transitions;
101         cell pic_to_mega_transitions;
102         cell pic_counts[4];  /* PIC_TAG, PIC_HI_TAG, PIC_TUPLE, PIC_HI_TAG_TUPLE */
103
104         factor_vm_data() 
105                 : profiling_p(false),
106                   secure_gc(false),
107                   gc_off(false),
108                   performing_gc(false),
109                   performing_compaction(false),
110                   collecting_aging_again(false),
111                   growing_data_heap(false),
112                   fep_disabled(false),
113                   full_output(false),
114                   max_pic_size(0)
115         {
116                 memset(this,0,sizeof(this)); // just to make sure
117         }
118
119 };
120
121 }