Coverage Report

Created: 2018-07-03 15:31

/home/travis/build/MoarVM/MoarVM/src/core/exceptions.h
Line
Count
Source (jump to first uncovered line)
1
/* Exception handler actions. */
2
496k
#define MVM_EX_ACTION_GOTO                0
3
330k
#define MVM_EX_ACTION_GOTO_WITH_PAYLOAD   1
4
313k
#define MVM_EX_ACTION_INVOKE              2
5
6
/* Exception categories. */
7
31.1k
#define MVM_EX_CAT_CATCH         1
8
655k
#define MVM_EX_CAT_CONTROL       2
9
0
#define MVM_EX_CAT_NEXT          4
10
0
#define MVM_EX_CAT_REDO          8
11
0
#define MVM_EX_CAT_LAST          16
12
0
#define MVM_EX_CAT_RETURN        32
13
#define MVM_EX_CAT_UNWIND        64
14
0
#define MVM_EX_CAT_TAKE          128
15
0
#define MVM_EX_CAT_WARN          256
16
0
#define MVM_EX_CAT_SUCCEED       512
17
0
#define MVM_EX_CAT_PROCEED       1024
18
2.08M
#define MVM_EX_CAT_LABELED       4096
19
#define MVM_EX_CAT_AWAIT         8192
20
#define MVM_EX_CAT_EMIT          16384
21
#define MVM_EX_CAT_DONE          32768
22
23
/* Not a real category, but marks an inline boundary. */
24
474k
#define MVM_EX_INLINE_BOUNDARY   2147483648
25
26
/* Ways to throw an exception. */
27
265k
#define MVM_EX_THROW_DYN         0
28
601k
#define MVM_EX_THROW_LEX         1
29
9
#define MVM_EX_THROW_LEXOTIC     2
30
6
#define MVM_EX_THROW_LEX_CALLER  3
31
32
/* Information associated with an exception handler. */
33
struct MVMFrameHandler {
34
    /* Start offset into the frame's bytecode for the handler, inclusive. */
35
    MVMuint32 start_offset;
36
37
    /* End offset into the frame's bytecode for the handler, exclusive. */
38
    MVMuint32 end_offset;
39
40
    /* Category mask or inline boundary indicator. */
41
    MVMuint32 category_mask;
42
43
    /* The kind of handler it is. */
44
    MVMuint16 action;
45
46
    /* Register containing block to invoke, for invokey handlers. */
47
    MVMuint16 block_reg;
48
49
    /* Offset into the frame's bytecode of the handler, for goto handlers. */
50
    MVMuint32 goto_offset;
51
52
    /* Register containing a label in case we have a labeled loop. We need to
53
     * be able to check for its identity when handling e.g. `next LABEL`. */
54
    MVMuint16 label_reg;
55
56
    /* The inlinee that this handler is associated with. Set to -1 for the
57
     * top-level handlers of a frame. Used both to skip non-top-level
58
     * handlers, but also to indicate, for a inline boundary indicator
59
     * entry in the table, the inline whose handlers end at this point. */
60
    MVMint16 inlinee;
61
};
62
63
/* An active (currently executing) exception handler. */
64
struct MVMActiveHandler {
65
    /* The frame the handler was found in. */
66
    MVMFrame *frame;
67
68
    /* The handler information itself. */
69
    MVMFrameHandler *handler;
70
71
    /* Handler information for a JITted handler */
72
    MVMJitHandler *jit_handler;
73
74
    /* The exception object. */
75
    MVMObject *ex_obj;
76
77
    /* The next active handler in the chain. */
78
    MVMActiveHandler *next_handler;
79
};
80
81
/* Exception related functions. */
82
MVMObject * MVM_exception_backtrace(MVMThreadContext *tc, MVMObject *ex_obj);
83
MVMObject * MVM_exception_backtrace_strings(MVMThreadContext *tc, MVMObject *exObj);
84
void MVM_dump_backtrace(MVMThreadContext *tc);
85
void MVM_exception_throwcat(MVMThreadContext *tc, MVMuint8 mode, MVMuint32 cat, MVMRegister *resume_result);
86
void MVM_exception_die(MVMThreadContext *tc, MVMString *str, MVMRegister *rr);
87
void MVM_exception_throwobj(MVMThreadContext *tc, MVMuint8 mode, MVMObject *exObj, MVMRegister *resume_result);
88
void MVM_exception_throwpayload(MVMThreadContext *tc, MVMuint8 mode, MVMuint32 cat, MVMObject *payload, MVMRegister *resume_result);
89
void MVM_exception_resume(MVMThreadContext *tc, MVMObject *exObj);
90
MVM_PUBLIC MVM_NO_RETURN void MVM_panic_allocation_failed(size_t len) MVM_NO_RETURN_ATTRIBUTE;
91
MVM_PUBLIC MVM_NO_RETURN void MVM_panic(MVMint32 exitCode, const char *messageFormat, ...) MVM_NO_RETURN_ATTRIBUTE MVM_FORMAT(printf, 2, 3);
92
MVM_PUBLIC MVM_NO_RETURN void MVM_oops(MVMThreadContext *tc, const char *messageFormat, ...) MVM_NO_RETURN_ATTRIBUTE MVM_FORMAT(printf, 2, 3);
93
MVM_PUBLIC MVM_NO_RETURN void MVM_exception_throw_adhoc(MVMThreadContext *tc, const char *messageFormat, ...) MVM_NO_RETURN_ATTRIBUTE MVM_FORMAT(printf, 2, 3);
94
MVM_NO_RETURN void MVM_exception_throw_adhoc_va(MVMThreadContext *tc, const char *messageFormat, va_list args) MVM_NO_RETURN_ATTRIBUTE;
95
MVM_PUBLIC MVM_NO_RETURN void MVM_exception_throw_adhoc_free(MVMThreadContext *tc, char **waste, const char *messageFormat, ...) MVM_NO_RETURN_ATTRIBUTE MVM_FORMAT(printf, 3, 4);
96
MVM_NO_RETURN void MVM_exception_throw_adhoc_free_va(MVMThreadContext *tc, char **waste, const char *messageFormat, va_list args) MVM_NO_RETURN_ATTRIBUTE;
97
MVM_PUBLIC void MVM_crash_on_error(void);
98
char * MVM_exception_backtrace_line(MVMThreadContext *tc, MVMFrame *cur_frame, MVMuint16 not_top, MVMuint8 *throw_address);
99
MVMint32 MVM_get_exception_category(MVMThreadContext *tc, MVMObject *ex);
100
MVMObject * MVM_get_exception_payload(MVMThreadContext *tc, MVMObject *ex);
101
void MVM_bind_exception_payload(MVMThreadContext *tc, MVMObject *ex, MVMObject *payload);
102
void MVM_bind_exception_category(MVMThreadContext *tc, MVMObject *ex, MVMint32 category);
103
void MVM_exception_returnafterunwind(MVMThreadContext *tc, MVMObject *ex);
104
105
/* Exit codes for panic. */
106
0
#define MVM_exitcode_NYI            12
107
0
#define MVM_exitcode_compunit       13
108
#define MVM_exitcode_invalidopcode  14
109
0
#define MVM_exitcode_gcalloc        15
110
0
#define MVM_exitcode_gcroots        16
111
0
#define MVM_exitcode_gcnursery      17
112
0
#define MVM_exitcode_threads        18
113
0
#define MVM_exitcode_gcorch         19