[interp] Fix interp logging (#17636)
[mono-project.git] / mono / mini / exceptions-riscv.c
blob23f2f4499ca81c2cba29624f130db6f580cc7b54
1 /*
2 * Licensed to the .NET Foundation under one or more agreements.
3 * The .NET Foundation licenses this file to you under the MIT license.
4 * See the LICENSE file in the project root for more information.
5 */
7 #include "mini-runtime.h"
9 #include <mono/metadata/abi-details.h>
10 #include <mono/utils/mono-sigcontext.h>
11 #include "mono/utils/mono-tls-inline.h"
13 #ifndef DISABLE_JIT
15 static gpointer
16 nop_stub (void)
18 guint8 *code, *start;
20 start = code = mono_global_codeman_reserve (0x50);
22 /* nop */
23 riscv_addi (code, RISCV_X0, RISCV_X0, 0);
25 mono_arch_flush_icache (start, code - start);
27 return start;
30 gpointer
31 mono_arch_get_restore_context (MonoTrampInfo **info, gboolean aot)
33 *info = NULL;
34 return nop_stub ();
37 gpointer
38 mono_arch_get_call_filter (MonoTrampInfo **info, gboolean aot)
40 *info = NULL;
41 return nop_stub ();
44 gpointer
45 mono_arch_get_throw_exception (MonoTrampInfo **info, gboolean aot)
47 *info = NULL;
48 return nop_stub ();
51 gpointer
52 mono_arch_get_rethrow_exception (MonoTrampInfo **info, gboolean aot)
54 *info = NULL;
55 return nop_stub ();
58 gpointer
59 mono_arch_get_rethrow_preserve_exception (MonoTrampInfo **info, gboolean aot)
61 *info = NULL;
62 return nop_stub ();
65 gpointer
66 mono_arch_get_throw_corlib_exception (MonoTrampInfo **info, gboolean aot)
68 *info = NULL;
69 return nop_stub ();
72 #else
74 gpointer
75 mono_arch_get_restore_context (MonoTrampInfo **info, gboolean aot)
77 g_assert_not_reached ();
78 return NULL;
81 gpointer
82 mono_arch_get_call_filter (MonoTrampInfo **info, gboolean aot)
84 g_assert_not_reached ();
85 return NULL;
88 gpointer
89 mono_arch_get_call_filter (MonoTrampInfo **info, gboolean aot)
91 g_assert_not_reached ();
92 return NULL;
95 gpointer
96 mono_arch_get_throw_exception (MonoTrampInfo **info, gboolean aot)
98 g_assert_not_reached ();
99 return NULL;
102 gpointer
103 mono_arch_get_rethrow_exception (MonoTrampInfo **info, gboolean aot)
105 g_assert_not_reached ();
106 return NULL;
109 gpointer
110 mono_arch_get_throw_corlib_exception (MonoTrampInfo **info, gboolean aot)
112 g_assert_not_reached ();
113 return NULL;
116 #endif
118 void
119 mono_arch_exceptions_init (void)
121 // NOT_IMPLEMENTED;
124 gboolean
125 mono_arch_unwind_frame (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoJitInfo *ji,
126 MonoContext *ctx, MonoContext *new_ctx, MonoLMF **lmf,
127 host_mgreg_t **save_locations, StackFrameInfo *frame)
129 NOT_IMPLEMENTED;
130 return FALSE;
133 static void
134 handle_signal_exception (gpointer obj)
136 MonoJitTlsData *jit_tls = mono_tls_get_jit_tls ();
137 MonoContext ctx = jit_tls->ex_ctx;
139 mono_handle_exception (&ctx, obj);
140 mono_restore_context (&ctx);
143 gboolean
144 mono_arch_handle_exception (void *ctx, gpointer obj)
146 MonoJitTlsData *jit_tls = mono_tls_get_jit_tls ();
148 mono_sigctx_to_monoctx (ctx, &jit_tls->ex_ctx);
150 // Call handle_signal_exception () on the normal stack.
151 UCONTEXT_GREGS (ctx) [RISCV_A0] = (long) obj;
152 UCONTEXT_REG_PC (ctx) = (long) handle_signal_exception;
154 return TRUE;
157 gpointer
158 mono_arch_ip_from_context (void *sigctx)
160 return (gpointer) UCONTEXT_REG_PC (sigctx);
163 void
164 mono_arch_setup_async_callback (MonoContext *ctx, void (*async_cb)(void *fun), gpointer user_data)
166 // Allocate a stack frame and redirect PC.
167 MONO_CONTEXT_SET_SP (ctx, (host_mgreg_t) MONO_CONTEXT_GET_SP (ctx) - 32);
169 mono_arch_setup_resume_sighandler_ctx (ctx, async_cb);
172 void
173 mono_arch_setup_resume_sighandler_ctx (MonoContext *ctx, gpointer func)
175 MONO_CONTEXT_SET_IP (ctx, func);
178 void
179 mono_arch_undo_ip_adjustment (MonoContext *context)
181 NOT_IMPLEMENTED;
184 void
185 mono_arch_do_ip_adjustment (MonoContext *context)
187 g_assert_not_reached ();