Coverage Report

Created: 2017-04-15 07:07

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