/home/travis/build/MoarVM/MoarVM/src/moar.h
Line | Count | Source (jump to first uncovered line) |
1 | | #include <stdlib.h> |
2 | | #include <stdarg.h> |
3 | | #include <stdio.h> |
4 | | #include <setjmp.h> |
5 | | #include <stddef.h> |
6 | | |
7 | | /* Configuration. */ |
8 | | #include "gen/config.h" |
9 | | |
10 | | /* Standard integer types. */ |
11 | | #include <platform/inttypes.h> |
12 | | |
13 | | /* platform-specific setjmp override */ |
14 | | #include <platform/setjmp.h> |
15 | | |
16 | | /* libuv |
17 | | * must precede atomic_ops.h so we get the ordering of Winapi headers right |
18 | | */ |
19 | | #include <uv.h> |
20 | | |
21 | | /* libatomic_ops */ |
22 | | #define AO_REQUIRE_CAS |
23 | | #include <atomic_ops.h> |
24 | | |
25 | | /* libffi or dynload/dyncall/dyncallback */ |
26 | | #ifdef HAVE_LIBFFI |
27 | | #include <ffi.h> |
28 | | #else |
29 | | #include <dynload.h> |
30 | | #include <dyncall.h> |
31 | | #include <dyncall_callback.h> |
32 | | #endif |
33 | | |
34 | | /* forward declarations */ |
35 | | #include "types.h" |
36 | | |
37 | | /* Sized types. */ |
38 | | typedef int8_t MVMint8; |
39 | | typedef uint8_t MVMuint8; |
40 | | typedef int16_t MVMint16; |
41 | | typedef uint16_t MVMuint16; |
42 | | typedef int32_t MVMint32; |
43 | | typedef uint32_t MVMuint32; |
44 | | typedef int64_t MVMint64; |
45 | | typedef uint64_t MVMuint64; |
46 | | typedef float MVMnum32; |
47 | | typedef double MVMnum64; |
48 | | |
49 | | /* Alignment. */ |
50 | | #if HAVE_ALIGNOF |
51 | | /* A GCC extension. */ |
52 | | #define ALIGNOF(t) __alignof__(t) |
53 | | #elif defined _MSC_VER |
54 | | /* MSVC extension. */ |
55 | | #define ALIGNOF(t) __alignof(t) |
56 | | #else |
57 | | /* Alignment by measuring structure padding. */ |
58 | 48.7k | #define ALIGNOF(t) ((char *)(&((struct { char c; t _h; } *)0)->_h) - (char *)0) |
59 | | #endif |
60 | | |
61 | 43.4k | #define MVM_ALIGN_SECTION_MASK ((MVMuint32)ALIGNOF(MVMint64) - 1) |
62 | 21.7k | #define MVM_ALIGN_SECTION(offset) (((offset) + (MVM_ALIGN_SECTION_MASK)) & ~(MVM_ALIGN_SECTION_MASK)) |
63 | | |
64 | | #if defined MVM_BUILD_SHARED |
65 | | # define MVM_PUBLIC MVM_DLL_EXPORT |
66 | | # define MVM_PRIVATE MVM_DLL_LOCAL |
67 | | #elif defined MVM_SHARED |
68 | | # define MVM_PUBLIC MVM_DLL_IMPORT |
69 | | # define MVM_PRIVATE MVM_DLL_LOCAL |
70 | | #else |
71 | | # define MVM_PUBLIC |
72 | | # define MVM_PRIVATE |
73 | | #endif |
74 | | |
75 | | #if MVM_PTR_SIZE < 8 |
76 | | # define MVM_USE_OVERFLOW_SERIALIZATION_INDEX |
77 | | #endif |
78 | | |
79 | | #if defined _MSC_VER |
80 | | # define MVM_USED_BY_JIT __pragma(optimize( "g", off )) |
81 | | #else |
82 | | # define MVM_USED_BY_JIT |
83 | | #endif |
84 | | |
85 | | /* stuff for uthash */ |
86 | 0 | #define uthash_fatal(msg) MVM_exception_throw_adhoc(tc, "internal hash error: " msg) |
87 | | typedef uint32_t MVMhashv; |
88 | | |
89 | | #include "strings/uthash_types.h" |
90 | | |
91 | | MVM_PUBLIC const MVMint32 MVM_jit_support(void); |
92 | | |
93 | | /* Headers for various other data structures and APIs. */ |
94 | | #include "6model/6model.h" |
95 | | #include "gc/collect.h" |
96 | | #include "gc/debug.h" |
97 | | #include "gc/wb.h" |
98 | | #include "core/vector.h" |
99 | | #include "core/threadcontext.h" |
100 | | #include "core/instance.h" |
101 | | #include "strings/uthash.h" |
102 | | #include "core/interp.h" |
103 | | #include "core/callsite.h" |
104 | | #include "core/args.h" |
105 | | #include "core/exceptions.h" |
106 | | #include "core/alloc.h" |
107 | | #include "core/frame.h" |
108 | | #include "core/callstack.h" |
109 | | #include "core/validation.h" |
110 | | #include "core/bytecode.h" |
111 | | #include "core/bytecodedump.h" |
112 | | #include "core/ops.h" |
113 | | #include "core/threads.h" |
114 | | #include "core/hll.h" |
115 | | #include "core/loadbytecode.h" |
116 | | #include "core/bitmap.h" |
117 | | #include "math/num.h" |
118 | | #include "core/coerce.h" |
119 | | #include "core/ext.h" |
120 | | #ifdef HAVE_LIBFFI |
121 | | #include "core/nativecall_libffi.h" |
122 | | #else |
123 | | #include "core/nativecall_dyncall.h" |
124 | | #endif |
125 | | #include "core/nativecall.h" |
126 | | #include "core/dll.h" |
127 | | #include "core/continuation.h" |
128 | | #include "debug/debugserver.h" |
129 | | #include "6model/reprs.h" |
130 | | #include "6model/reprconv.h" |
131 | | #include "6model/bootstrap.h" |
132 | | #include "6model/containers.h" |
133 | | #include "6model/sc.h" |
134 | | #include "6model/serialization.h" |
135 | | #include "6model/parametric.h" |
136 | | #include "core/compunit.h" |
137 | | #include "gc/gen2.h" |
138 | | #include "gc/allocation.h" |
139 | | #include "gc/worklist.h" |
140 | | #include "gc/orchestrate.h" |
141 | | #include "gc/roots.h" |
142 | | #include "gc/objectid.h" |
143 | | #include "gc/finalize.h" |
144 | | #include "core/regionalloc.h" |
145 | | #include "spesh/dump.h" |
146 | | #include "spesh/debug.h" |
147 | | #include "spesh/graph.h" |
148 | | #include "spesh/codegen.h" |
149 | | #include "spesh/candidate.h" |
150 | | #include "spesh/manipulate.h" |
151 | | #include "spesh/args.h" |
152 | | #include "spesh/facts.h" |
153 | | #include "spesh/optimize.h" |
154 | | #include "spesh/dead_bb_elimination.h" |
155 | | #include "spesh/deopt.h" |
156 | | #include "spesh/log.h" |
157 | | #include "spesh/threshold.h" |
158 | | #include "spesh/inline.h" |
159 | | #include "spesh/osr.h" |
160 | | #include "spesh/iterator.h" |
161 | | #include "spesh/lookup.h" |
162 | | #include "spesh/worker.h" |
163 | | #include "spesh/stats.h" |
164 | | #include "spesh/plan.h" |
165 | | #include "spesh/arg_guard.h" |
166 | | #include "spesh/plugin.h" |
167 | | #include "strings/nfg.h" |
168 | | #include "strings/normalize.h" |
169 | | #include "strings/decode_stream.h" |
170 | | #include "strings/ascii.h" |
171 | | #include "strings/parse_num.h" |
172 | | #include "strings/utf8.h" |
173 | | #include "strings/utf8_c8.h" |
174 | | #include "strings/utf16.h" |
175 | | #include "strings/iter.h" |
176 | | #include "strings/ops.h" |
177 | | #include "strings/unicode_gen.h" |
178 | | #include "strings/unicode.h" |
179 | | #include "strings/latin1.h" |
180 | | #include "strings/windows1252.h" |
181 | | #include "strings/shiftjis.h" |
182 | | #include "strings/unicode_ops.h" |
183 | | #include "io/io.h" |
184 | | #include "io/eventloop.h" |
185 | | #include "io/syncfile.h" |
186 | | #include "io/syncsocket.h" |
187 | | #include "io/fileops.h" |
188 | | #include "io/dirops.h" |
189 | | #include "io/procops.h" |
190 | | #include "io/timers.h" |
191 | | #include "io/filewatchers.h" |
192 | | #include "io/signals.h" |
193 | | #include "io/asyncsocket.h" |
194 | | #include "io/asyncsocketudp.h" |
195 | | #include "math/bigintops.h" |
196 | | #include "mast/driver.h" |
197 | | #include "core/intcache.h" |
198 | | #include "core/fixedsizealloc.h" |
199 | | #include "jit/graph.h" |
200 | | #include "jit/label.h" |
201 | | #include "jit/expr.h" |
202 | | #include "jit/register.h" |
203 | | #include "jit/tile.h" |
204 | | #include "jit/compile.h" |
205 | | #include "jit/log.h" |
206 | | #include "jit/interface.h" |
207 | | #include "profiler/instrument.h" |
208 | | #include "profiler/log.h" |
209 | | #include "profiler/profile.h" |
210 | | #include "profiler/heapsnapshot.h" |
211 | | #include "profiler/telemeh.h" |
212 | | #include "instrument/crossthreadwrite.h" |
213 | | #include "instrument/line_coverage.h" |
214 | | |
215 | | MVMObject *MVM_backend_config(MVMThreadContext *tc); |
216 | | |
217 | | /* Top level VM API functions. */ |
218 | | MVM_PUBLIC MVMInstance * MVM_vm_create_instance(void); |
219 | | MVM_PUBLIC void MVM_vm_run_file(MVMInstance *instance, const char *filename); |
220 | | MVM_PUBLIC void MVM_vm_dump_file(MVMInstance *instance, const char *filename); |
221 | | MVM_PUBLIC MVM_NO_RETURN void MVM_vm_exit(MVMInstance *instance) MVM_NO_RETURN_ATTRIBUTE; |
222 | | MVM_PUBLIC void MVM_vm_destroy_instance(MVMInstance *instance); |
223 | | MVM_PUBLIC void MVM_vm_set_clargs(MVMInstance *instance, int argc, char **argv); |
224 | | MVM_PUBLIC void MVM_vm_set_exec_name(MVMInstance *instance, const char *exec_name); |
225 | | MVM_PUBLIC void MVM_vm_set_prog_name(MVMInstance *instance, const char *prog_name); |
226 | | MVM_PUBLIC void MVM_vm_set_lib_path(MVMInstance *instance, int count, const char **lib_path); |
227 | | |
228 | | #if defined(__s390__) |
229 | | AO_t AO_fetch_compare_and_swap_emulation(volatile AO_t *addr, AO_t old_val, AO_t new_val); |
230 | | # define AO_fetch_compare_and_swap_full(addr, old, newval) \ |
231 | | AO_fetch_compare_and_swap_emulation(addr, old, newval) |
232 | | #endif |
233 | | |
234 | | /* Returns original. Use only on AO_t-sized values (including pointers). */ |
235 | 1.52M | #define MVM_incr(addr) AO_fetch_and_add1_full((volatile AO_t *)(addr)) |
236 | 1.82M | #define MVM_decr(addr) AO_fetch_and_sub1_full((volatile AO_t *)(addr)) |
237 | 33.4k | #define MVM_add(addr, add) AO_fetch_and_add_full((volatile AO_t *)(addr), (AO_t)(add)) |
238 | | |
239 | | /* Returns non-zero for success. Use for both AO_t numbers and pointers. */ |
240 | 4.27M | #define MVM_trycas(addr, old, new) AO_compare_and_swap_full((volatile AO_t *)(addr), (AO_t)(old), (AO_t)(new)) |
241 | | |
242 | | /* Returns the old value dereferenced at addr. */ |
243 | 663k | #define MVM_cas(addr, old, new) AO_fetch_compare_and_swap_full((addr), (old), (new)) |
244 | | |
245 | | /* Returns the old pointer value dereferenced at addr. Provided for a tiny bit of type safety. */ |
246 | 474 | #define MVM_casptr(addr, old, new) ((void *)MVM_cas((AO_t *)(addr), (AO_t)(old), (AO_t)(new))) |
247 | | |
248 | | /* Full memory barrier. */ |
249 | 3.61M | #define MVM_barrier() AO_nop_full() |
250 | | |
251 | | /* Need to use these to assign to or read from any memory locations on |
252 | | * which the other atomic operation macros are used... */ |
253 | 891k | #define MVM_store(addr, new) AO_store_full((volatile AO_t *)(addr), (AO_t)(new)) |
254 | 3.64M | #define MVM_load(addr) AO_load_full((volatile AO_t *)(addr)) |