/home/travis/build/MoarVM/MoarVM/src/core/exceptions.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* Exception handler actions. */ |
2 | 420k | #define MVM_EX_ACTION_GOTO 0 |
3 | 273k | #define MVM_EX_ACTION_GOTO_WITH_PAYLOAD 1 |
4 | 153k | #define MVM_EX_ACTION_INVOKE 2 |
5 | | |
6 | | /* Exception categories. */ |
7 | 270 | #define MVM_EX_CAT_CATCH 1 |
8 | 739k | #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.10M | #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 | | /* Ways to throw an exception. */ |
24 | 282k | #define MVM_EX_THROW_DYN 0 |
25 | 2.15M | #define MVM_EX_THROW_LEX 1 |
26 | 12 | #define MVM_EX_THROW_LEXOTIC 2 |
27 | 0 | #define MVM_EX_THROW_LEX_CALLER 3 |
28 | | |
29 | | /* Information associated with an exception handler. */ |
30 | | struct MVMFrameHandler { |
31 | | /* Start offset into the frame's bytecode for the handler, inclusive. */ |
32 | | MVMuint32 start_offset; |
33 | | |
34 | | /* End offset into the frame's bytecode for the handler, exclusive. */ |
35 | | MVMuint32 end_offset; |
36 | | |
37 | | /* Category mask. */ |
38 | | MVMuint32 category_mask; |
39 | | |
40 | | /* The kind of handler it is. */ |
41 | | MVMuint16 action; |
42 | | |
43 | | /* Register containing block to invoke, for invokey handlers. */ |
44 | | MVMuint16 block_reg; |
45 | | |
46 | | /* Offset into the frame's bytecode of the handler, for goto handlers. */ |
47 | | MVMuint32 goto_offset; |
48 | | |
49 | | /* Register containing a label in case we have a labeled loop. We need to |
50 | | * be able to check for its identity when handling e.g. `next LABEL`. */ |
51 | | MVMuint16 label_reg; |
52 | | |
53 | | /* Is this handler actually a clone of a caller's handler performed during |
54 | | * inlining of something, and is that something not lexically enclosed in |
55 | | * the thing it was inlined into? If yes,this flag will be set. We need to |
56 | | * ignore such handlers when searching for matching lexical handlers only. */ |
57 | | MVMuint16 inlined_and_not_lexical; |
58 | | }; |
59 | | |
60 | | /* An active (currently executing) exception handler. */ |
61 | | struct MVMActiveHandler { |
62 | | /* The frame the handler was found in. */ |
63 | | MVMFrame *frame; |
64 | | |
65 | | /* The handler information itself. */ |
66 | | MVMFrameHandler *handler; |
67 | | |
68 | | /* Handler information for a JITted handler */ |
69 | | MVMJitHandler *jit_handler; |
70 | | |
71 | | /* The exception object. */ |
72 | | MVMObject *ex_obj; |
73 | | |
74 | | /* The next active handler in the chain. */ |
75 | | MVMActiveHandler *next_handler; |
76 | | }; |
77 | | |
78 | | /* Exception related functions. */ |
79 | | MVMObject * MVM_exception_backtrace(MVMThreadContext *tc, MVMObject *ex_obj); |
80 | | MVMObject * MVM_exception_backtrace_strings(MVMThreadContext *tc, MVMObject *exObj); |
81 | | void MVM_dump_backtrace(MVMThreadContext *tc); |
82 | | void MVM_exception_throwcat(MVMThreadContext *tc, MVMuint8 mode, MVMuint32 cat, MVMRegister *resume_result); |
83 | | void MVM_exception_die(MVMThreadContext *tc, MVMString *str, MVMRegister *rr); |
84 | | void MVM_exception_throwobj(MVMThreadContext *tc, MVMuint8 mode, MVMObject *exObj, MVMRegister *resume_result); |
85 | | void MVM_exception_throwpayload(MVMThreadContext *tc, MVMuint8 mode, MVMuint32 cat, MVMObject *payload, MVMRegister *resume_result); |
86 | | void MVM_exception_resume(MVMThreadContext *tc, MVMObject *exObj); |
87 | | MVMObject * MVM_exception_newlexotic(MVMThreadContext *tc, MVMuint32 offset); |
88 | | MVMObject * MVM_exception_newlexotic_from_jit(MVMThreadContext *tc, MVMint32 label); |
89 | | void MVM_exception_gotolexotic(MVMThreadContext *tc, MVMint32 handler_idx, MVMStaticFrame *sf); |
90 | | MVM_PUBLIC MVM_NO_RETURN void MVM_panic_allocation_failed(size_t len) MVM_NO_RETURN_GCC; |
91 | | MVM_PUBLIC MVM_NO_RETURN void MVM_panic(MVMint32 exitCode, const char *messageFormat, ...) MVM_NO_RETURN_GCC MVM_FORMAT(printf, 2, 3); |
92 | | MVM_PUBLIC MVM_NO_RETURN void MVM_oops(MVMThreadContext *tc, const char *messageFormat, ...) MVM_NO_RETURN_GCC MVM_FORMAT(printf, 2, 3); |
93 | | MVM_PUBLIC MVM_NO_RETURN void MVM_exception_throw_adhoc(MVMThreadContext *tc, const char *messageFormat, ...) MVM_NO_RETURN_GCC 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_GCC; |
95 | | MVM_PUBLIC MVM_NO_RETURN void MVM_exception_throw_adhoc_free(MVMThreadContext *tc, char **waste, const char *messageFormat, ...) MVM_NO_RETURN_GCC 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_GCC; |
97 | | MVM_PUBLIC void MVM_crash_on_error(void); |
98 | | char * MVM_exception_backtrace_line(MVMThreadContext *tc, MVMFrame *cur_frame, MVMuint16 not_top); |
99 | | |
100 | | |
101 | | /* Exit codes for panic. */ |
102 | 0 | #define MVM_exitcode_NYI 12 |
103 | 0 | #define MVM_exitcode_compunit 13 |
104 | | #define MVM_exitcode_invalidopcode 14 |
105 | 0 | #define MVM_exitcode_gcalloc 15 |
106 | 0 | #define MVM_exitcode_gcroots 16 |
107 | 0 | #define MVM_exitcode_gcnursery 17 |
108 | 0 | #define MVM_exitcode_threads 18 |
109 | 0 | #define MVM_exitcode_gcorch 19 |