Merge pull request #2826 from mattleibow/mono.options-update
[mono.git] / mono / mini / exceptions-arm64.c
1 /*
2  * exceptions-arm64.c: exception support for ARM64
3  *
4  * Copyright 2013 Xamarin Inc
5  *
6  * Based on exceptions-arm.c:
7  *
8  * Authors:
9  *   Dietmar Maurer (dietmar@ximian.com)
10  *   Paolo Molaro (lupus@ximian.com)
11  *
12  * (C) 2001 Ximian, Inc.
13  * Licensed under the MIT license. See LICENSE file in the project root for full license information.
14  */
15
16 #include "mini.h"
17
18 #include <mono/arch/arm64/arm64-codegen.h>
19 #include <mono/metadata/abi-details.h>
20
21 #define ALIGN_TO(val,align) ((((guint64)val) + ((align) - 1)) & ~((align) - 1))
22
23 #ifndef DISABLE_JIT
24
25 gpointer
26 mono_arch_get_restore_context (MonoTrampInfo **info, gboolean aot)
27 {
28         guint8 *start, *code;
29         MonoJumpInfo *ji = NULL;
30         GSList *unwind_ops = NULL;
31         int i, ctx_reg, size;
32
33         size = 256;
34         code = start = mono_global_codeman_reserve (size);
35
36         arm_movx (code, ARMREG_IP0, ARMREG_R0);
37         ctx_reg = ARMREG_IP0;
38         /* Restore fregs */
39         for (i = 0; i < 32; ++i)
40                 arm_ldrfpx (code, i, ctx_reg, MONO_STRUCT_OFFSET (MonoContext, fregs) + (i * 8));
41         /* Restore gregs */
42         // FIXME: Restore less registers
43         // FIXME: fp should be restored later
44         code = mono_arm_emit_load_regarray (code, 0xffffffff & ~(1 << ctx_reg) & ~(1 << ARMREG_SP), ctx_reg, MONO_STRUCT_OFFSET (MonoContext, regs));
45         /* ip0/ip1 doesn't need to be restored */
46         /* ip1 = pc */
47         arm_ldrx (code, ARMREG_IP1, ctx_reg, MONO_STRUCT_OFFSET (MonoContext, pc));
48         /* ip0 = sp */
49         arm_ldrx (code, ARMREG_IP0, ctx_reg, MONO_STRUCT_OFFSET (MonoContext, regs) + (ARMREG_SP * 8));
50         /* Restore sp, ctx is no longer valid */
51         arm_movspx (code, ARMREG_SP, ARMREG_IP0); 
52         /* Branch to pc */
53         arm_brx (code, ARMREG_IP1);
54         /* Not reached */
55         arm_brk (code, 0);
56
57         g_assert ((code - start) < size);
58         mono_arch_flush_icache (start, code - start);
59         mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL);
60
61         if (info)
62                 *info = mono_tramp_info_create ("restore_context", start, code - start, ji, unwind_ops);
63
64         return start;
65 }
66
67 gpointer
68 mono_arch_get_call_filter (MonoTrampInfo **info, gboolean aot)
69 {
70         guint8 *code;
71         guint8* start;
72         int size, offset, gregs_offset, fregs_offset, ctx_offset, num_fregs, frame_size;
73         MonoJumpInfo *ji = NULL;
74         GSList *unwind_ops = NULL;
75
76         size = 512;
77         start = code = mono_global_codeman_reserve (size);
78
79         /* Compute stack frame size and offsets */
80         offset = 0;
81         /* frame block */
82         offset += 2 * 8;
83         /* gregs */
84         gregs_offset = offset;
85         offset += 32 * 8;
86         /* fregs */
87         num_fregs = 8;
88         fregs_offset = offset;
89         offset += num_fregs * 8;
90         ctx_offset = offset;
91         ctx_offset += 8;
92         frame_size = ALIGN_TO (offset, MONO_ARCH_FRAME_ALIGNMENT);
93
94         /*
95          * We are being called from C code, ctx is in r0, the address to call is in r1.
96          * We need to save state, restore ctx, make the call, then restore the previous state,
97          * returning the value returned by the call.
98          */
99
100         /* Setup a frame */
101         arm_stpx_pre (code, ARMREG_FP, ARMREG_LR, ARMREG_SP, -frame_size);
102         arm_movspx (code, ARMREG_FP, ARMREG_SP);
103
104         /* Save ctx */
105         arm_strx (code, ARMREG_R0, ARMREG_FP, ctx_offset);
106         /* Save gregs */
107         code = mono_arm_emit_store_regarray (code, MONO_ARCH_CALLEE_SAVED_REGS | (1 << ARMREG_FP), ARMREG_FP, gregs_offset);
108         /* No need to save/restore fregs, since we don't currently use them */
109
110         /* Load regs from ctx */
111         code = mono_arm_emit_load_regarray (code, MONO_ARCH_CALLEE_SAVED_REGS, ARMREG_R0, MONO_STRUCT_OFFSET (MonoContext, regs));
112         /* Load fp */
113         arm_ldrx (code, ARMREG_FP, ARMREG_R0, MONO_STRUCT_OFFSET (MonoContext, regs) + (ARMREG_FP * 8));
114
115         /* Make the call */
116         arm_blrx (code, ARMREG_R1);
117         /* For filters, the result is in R0 */
118
119         /* Restore fp */
120         arm_ldrx (code, ARMREG_FP, ARMREG_SP, gregs_offset + (ARMREG_FP * 8));
121         /* Load ctx */
122         arm_ldrx (code, ARMREG_IP0, ARMREG_FP, ctx_offset);
123         /* Save registers back to ctx */
124         /* This isn't strictly neccessary since we don't allocate variables used in eh clauses to registers */
125         code = mono_arm_emit_store_regarray (code, MONO_ARCH_CALLEE_SAVED_REGS, ARMREG_IP0, MONO_STRUCT_OFFSET (MonoContext, regs));
126
127         /* Restore regs */
128         code = mono_arm_emit_load_regarray (code, MONO_ARCH_CALLEE_SAVED_REGS, ARMREG_FP, gregs_offset);
129         /* Destroy frame */
130         code = mono_arm_emit_destroy_frame (code, frame_size, (1 << ARMREG_IP0));
131         arm_retx (code, ARMREG_LR);
132
133         g_assert ((code - start) < size);
134         mono_arch_flush_icache (start, code - start);
135         mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL);
136
137         if (info)
138                 *info = mono_tramp_info_create ("call_filter", start, code - start, ji, unwind_ops);
139
140         return start;
141 }
142
143 static gpointer 
144 get_throw_trampoline (int size, gboolean corlib, gboolean rethrow, gboolean llvm, gboolean resume_unwind, const char *tramp_name, MonoTrampInfo **info, gboolean aot)
145 {
146         guint8 *start, *code;
147         MonoJumpInfo *ji = NULL;
148         GSList *unwind_ops = NULL;
149         int i, offset, gregs_offset, fregs_offset, frame_size, num_fregs;
150
151         code = start = mono_global_codeman_reserve (size);
152
153         /* We are being called by JITted code, the exception object/type token is in R0 */
154
155         /* Compute stack frame size and offsets */
156         offset = 0;
157         /* frame block */
158         offset += 2 * 8;
159         /* gregs */
160         gregs_offset = offset;
161         offset += 32 * 8;
162         /* fregs */
163         num_fregs = 8;
164         fregs_offset = offset;
165         offset += num_fregs * 8;
166         frame_size = ALIGN_TO (offset, MONO_ARCH_FRAME_ALIGNMENT);
167
168         /* Setup a frame */
169         arm_stpx_pre (code, ARMREG_FP, ARMREG_LR, ARMREG_SP, -frame_size);
170         arm_movspx (code, ARMREG_FP, ARMREG_SP);
171
172         /* Save gregs */
173         code = mono_arm_emit_store_regarray (code, 0xffffffff, ARMREG_FP, gregs_offset);
174         if (corlib && !llvm)
175                 /* The real LR is in R1 */
176                 arm_strx (code, ARMREG_R1, ARMREG_FP, gregs_offset + (ARMREG_LR * 8));
177         /* Save fp/sp */
178         arm_ldrx (code, ARMREG_IP0, ARMREG_FP, 0);
179         arm_strx (code, ARMREG_IP0, ARMREG_FP, gregs_offset + (ARMREG_FP * 8));
180         arm_addx_imm (code, ARMREG_IP0, ARMREG_FP, frame_size);
181         arm_strx (code, ARMREG_IP0, ARMREG_FP, gregs_offset + (ARMREG_SP * 8)); 
182         /* Save fregs */
183         for (i = 0; i < num_fregs; ++i)
184                 arm_strfpx (code, ARMREG_D8 + i, ARMREG_FP, fregs_offset + (i * 8));
185
186         /* Call the C trampoline function */
187         /* Arg1 =  exception object/type token */
188         arm_movx (code, ARMREG_R0, ARMREG_R0);
189         /* Arg2 = caller ip */
190         if (corlib) {
191                 if (llvm)
192                         arm_ldrx (code, ARMREG_R1, ARMREG_FP, gregs_offset + (ARMREG_LR * 8));
193                 else
194                         arm_movx (code, ARMREG_R1, ARMREG_R1);
195         } else {
196                 arm_ldrx (code, ARMREG_R1, ARMREG_FP, 8);
197         }
198         /* Arg 3 = gregs */
199         arm_addx_imm (code, ARMREG_R2, ARMREG_FP, gregs_offset);
200         /* Arg 4 = fregs */
201         arm_addx_imm (code, ARMREG_R3, ARMREG_FP, fregs_offset);
202         /* Arg 5 = corlib */
203         arm_movzx (code, ARMREG_R4, corlib ? 1 : 0, 0);
204         /* Arg 6 = rethrow */
205         arm_movzx (code, ARMREG_R5, rethrow ? 1 : 0, 0);
206         /* Call the function */
207         if (aot) {
208                 const char *icall_name;
209
210                 if (resume_unwind)
211                         icall_name = "mono_arm_resume_unwind";
212                 else
213                         icall_name = "mono_arm_throw_exception";
214
215                 code = mono_arm_emit_aotconst (&ji, code, start, ARMREG_LR, MONO_PATCH_INFO_JIT_ICALL_ADDR, icall_name);
216         } else {
217                 gpointer icall_func;
218
219                 if (resume_unwind)
220                         icall_func = mono_arm_resume_unwind;
221                 else
222                         icall_func = mono_arm_throw_exception;
223
224                 code = mono_arm_emit_imm64 (code, ARMREG_LR, (guint64)icall_func);
225         }
226         arm_blrx (code, ARMREG_LR);
227         /* This shouldn't return */
228         arm_brk (code, 0x0);
229
230         g_assert ((code - start) < size);
231         mono_arch_flush_icache (start, code - start);
232         mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL);
233
234         if (info)
235                 *info = mono_tramp_info_create (tramp_name, start, code - start, ji, unwind_ops);
236
237         return start;
238 }
239
240 gpointer 
241 mono_arch_get_throw_exception (MonoTrampInfo **info, gboolean aot)
242 {
243         return get_throw_trampoline (256, FALSE, FALSE, FALSE, FALSE, "throw_exception", info, aot);
244 }
245
246 gpointer
247 mono_arch_get_rethrow_exception (MonoTrampInfo **info, gboolean aot)
248 {
249         return get_throw_trampoline (256, FALSE, TRUE, FALSE, FALSE, "rethrow_exception", info, aot);
250 }
251
252 gpointer 
253 mono_arch_get_throw_corlib_exception (MonoTrampInfo **info, gboolean aot)
254 {
255         return get_throw_trampoline (256, TRUE, FALSE, FALSE, FALSE, "throw_corlib_exception", info, aot);
256 }
257
258 GSList*
259 mono_arm_get_exception_trampolines (gboolean aot)
260 {
261         MonoTrampInfo *info;
262         GSList *tramps = NULL;
263
264         /* LLVM uses the normal trampolines, but with a different name */
265         get_throw_trampoline (256, TRUE, FALSE, FALSE, FALSE, "llvm_throw_corlib_exception_trampoline", &info, aot);
266         tramps = g_slist_prepend (tramps, info);
267         
268         get_throw_trampoline (256, TRUE, FALSE, TRUE, FALSE, "llvm_throw_corlib_exception_abs_trampoline", &info, aot);
269         tramps = g_slist_prepend (tramps, info);
270
271         get_throw_trampoline (256, FALSE, FALSE, FALSE, TRUE, "llvm_resume_unwind_trampoline", &info, aot);
272         tramps = g_slist_prepend (tramps, info);
273
274         return tramps;
275 }
276
277 #else /* DISABLE_JIT */
278
279 gpointer
280 mono_arch_get_restore_context (MonoTrampInfo **info, gboolean aot)
281 {
282         g_assert_not_reached ();
283         return NULL;
284 }
285
286 gpointer
287 mono_arch_get_call_filter (MonoTrampInfo **info, gboolean aot)
288 {
289         g_assert_not_reached ();
290         return NULL;
291 }
292
293 gpointer 
294 mono_arch_get_throw_exception (MonoTrampInfo **info, gboolean aot)
295 {
296         g_assert_not_reached ();
297         return NULL;
298 }
299
300 gpointer
301 mono_arch_get_rethrow_exception (MonoTrampInfo **info, gboolean aot)
302 {
303         g_assert_not_reached ();
304         return NULL;
305 }
306
307 gpointer 
308 mono_arch_get_throw_corlib_exception (MonoTrampInfo **info, gboolean aot)
309 {
310         g_assert_not_reached ();
311         return NULL;
312 }       
313
314 GSList*
315 mono_arm_get_exception_trampolines (gboolean aot)
316 {
317         g_assert_not_reached ();
318         return NULL;
319 }
320
321 #endif /* !DISABLE_JIT */
322
323 void
324 mono_arch_exceptions_init (void)
325 {
326         guint8 *tramp;
327         GSList *tramps, *l;
328
329         if (mono_aot_only) {
330                 tramp = mono_aot_get_trampoline ("llvm_throw_corlib_exception_trampoline");
331                 mono_register_jit_icall (tramp, "llvm_throw_corlib_exception_trampoline", NULL, TRUE);
332                 tramp = mono_aot_get_trampoline ("llvm_throw_corlib_exception_abs_trampoline");
333                 mono_register_jit_icall (tramp, "llvm_throw_corlib_exception_abs_trampoline", NULL, TRUE);
334                 tramp = mono_aot_get_trampoline ("llvm_resume_unwind_trampoline");
335                 mono_register_jit_icall (tramp, "llvm_resume_unwind_trampoline", NULL, TRUE);
336         } else {
337                 tramps = mono_arm_get_exception_trampolines (FALSE);
338                 for (l = tramps; l; l = l->next) {
339                         MonoTrampInfo *info = l->data;
340
341                         mono_register_jit_icall (info->code, g_strdup (info->name), NULL, TRUE);
342                         mono_tramp_info_register (info, NULL);
343                 }
344                 g_slist_free (tramps);
345         }
346 }
347
348 /*
349  * mono_arm_throw_exception:
350  *
351  *   This function is called by the exception trampolines.
352  * FP_REGS points to the 8 callee saved fp regs.
353  */
354 void
355 mono_arm_throw_exception (gpointer arg, mgreg_t pc, mgreg_t *int_regs, gdouble *fp_regs, gboolean corlib, gboolean rethrow)
356 {
357         MonoError error;
358         MonoContext ctx;
359         MonoObject *exc = NULL;
360         guint32 ex_token_index, ex_token;
361
362         if (!corlib)
363                 exc = arg;
364         else {
365                 ex_token_index = (guint64)arg;
366                 ex_token = MONO_TOKEN_TYPE_DEF | ex_token_index;
367                 exc = (MonoObject*)mono_exception_from_token (mono_defaults.corlib, ex_token);
368         }
369
370         /* Adjust pc so it points into the call instruction */
371         pc -= 4;
372
373         /* Initialize a ctx based on the arguments */
374         memset (&ctx, 0, sizeof (MonoContext));
375         memcpy (&(ctx.regs [0]), int_regs, sizeof (mgreg_t) * 32);
376         memcpy (&(ctx.fregs [ARMREG_D8]), fp_regs, sizeof (double) * 8);
377         ctx.pc = pc;
378
379         if (mono_object_isinst_checked (exc, mono_defaults.exception_class, &error)) {
380                 MonoException *mono_ex = (MonoException*)exc;
381                 if (!rethrow)
382                         mono_ex->stack_trace = NULL;
383         }
384         mono_error_assert_ok (&error);
385
386         mono_handle_exception (&ctx, exc);
387
388         mono_restore_context (&ctx);
389 }
390
391 void
392 mono_arm_resume_unwind (gpointer arg, mgreg_t pc, mgreg_t *int_regs, gdouble *fp_regs, gboolean corlib, gboolean rethrow)
393 {
394         MonoContext ctx;
395
396         /* Adjust pc so it points into the call instruction */
397         pc -= 4;
398
399         /* Initialize a ctx based on the arguments */
400         memset (&ctx, 0, sizeof (MonoContext));
401         memcpy (&(ctx.regs [0]), int_regs, sizeof (mgreg_t) * 32);
402         memcpy (&(ctx.fregs [ARMREG_D8]), fp_regs, sizeof (double) * 8);
403         ctx.pc = pc;
404
405         mono_resume_unwind (&ctx);
406 }
407
408 /* 
409  * mono_arch_unwind_frame:
410  *
411  * See exceptions-amd64.c for docs;
412  */
413 gboolean
414 mono_arch_unwind_frame (MonoDomain *domain, MonoJitTlsData *jit_tls, 
415                                                          MonoJitInfo *ji, MonoContext *ctx, 
416                                                          MonoContext *new_ctx, MonoLMF **lmf,
417                                                          mgreg_t **save_locations,
418                                                          StackFrameInfo *frame)
419 {
420         gpointer ip = MONO_CONTEXT_GET_IP (ctx);
421
422         memset (frame, 0, sizeof (StackFrameInfo));
423         frame->ji = ji;
424
425         *new_ctx = *ctx;
426
427         if (ji != NULL) {
428                 mgreg_t regs [MONO_MAX_IREGS + 8 + 1];
429                 guint8 *cfa;
430                 guint32 unwind_info_len;
431                 guint8 *unwind_info;
432
433                 frame->type = FRAME_TYPE_MANAGED;
434
435                 unwind_info = mono_jinfo_get_unwind_info (ji, &unwind_info_len);
436
437                 memcpy (regs, &new_ctx->regs, sizeof (mgreg_t) * 32);
438                 /* v8..v15 are callee saved */
439                 memcpy (regs + MONO_MAX_IREGS, &(new_ctx->fregs [8]), sizeof (mgreg_t) * 8);
440
441                 mono_unwind_frame (unwind_info, unwind_info_len, ji->code_start, 
442                                                    (guint8*)ji->code_start + ji->code_size,
443                                                    ip, NULL, regs, MONO_MAX_IREGS + 8,
444                                                    save_locations, MONO_MAX_IREGS, &cfa);
445
446                 memcpy (&new_ctx->regs, regs, sizeof (mgreg_t) * 32);
447                 memcpy (&(new_ctx->fregs [8]), regs + MONO_MAX_IREGS, sizeof (mgreg_t) * 8);
448
449                 new_ctx->pc = regs [ARMREG_LR];
450                 new_ctx->regs [ARMREG_SP] = (mgreg_t)cfa;
451
452                 if (*lmf && (*lmf)->gregs [MONO_ARCH_LMF_REG_SP] && (MONO_CONTEXT_GET_SP (ctx) >= (gpointer)(*lmf)->gregs [MONO_ARCH_LMF_REG_SP])) {
453                         /* remove any unused lmf */
454                         *lmf = (gpointer)(((gsize)(*lmf)->previous_lmf) & ~3);
455                 }
456
457                 /* we substract 1, so that the IP points into the call instruction */
458                 new_ctx->pc--;
459
460                 return TRUE;
461         } else if (*lmf) {
462                 if (((gsize)(*lmf)->previous_lmf) & 2) {
463                         /* 
464                          * This LMF entry is created by the soft debug code to mark transitions to
465                          * managed code done during invokes.
466                          */
467                         MonoLMFExt *ext = (MonoLMFExt*)(*lmf);
468
469                         g_assert (ext->debugger_invoke);
470
471                         memcpy (new_ctx, &ext->ctx, sizeof (MonoContext));
472
473                         *lmf = (gpointer)(((gsize)(*lmf)->previous_lmf) & ~3);
474
475                         frame->type = FRAME_TYPE_DEBUGGER_INVOKE;
476
477                         return TRUE;
478                 }
479
480                 frame->type = FRAME_TYPE_MANAGED_TO_NATIVE;
481
482                 ji = mini_jit_info_table_find (domain, (gpointer)(*lmf)->pc, NULL);
483                 if (!ji)
484                         return FALSE;
485
486                 g_assert (MONO_ARCH_LMF_REGS == ((0x3ff << 19) | (1 << ARMREG_FP) | (1 << ARMREG_SP)));
487                 memcpy (&new_ctx->regs [ARMREG_R19], &(*lmf)->gregs [0], sizeof (mgreg_t) * 10);
488                 new_ctx->regs [ARMREG_FP] = (*lmf)->gregs [MONO_ARCH_LMF_REG_FP];
489                 new_ctx->regs [ARMREG_SP] = (*lmf)->gregs [MONO_ARCH_LMF_REG_SP];
490                 new_ctx->pc = (*lmf)->pc;
491
492                 /* we substract 1, so that the IP points into the call instruction */
493                 new_ctx->pc--;
494
495                 *lmf = (gpointer)(((gsize)(*lmf)->previous_lmf) & ~3);
496
497                 return TRUE;
498         }
499
500         return FALSE;
501 }
502
503 void
504 mono_arch_sigctx_to_monoctx (void *sigctx, MonoContext *mctx)
505 {
506         mono_sigctx_to_monoctx (sigctx, mctx);
507 }
508
509 void
510 mono_arch_monoctx_to_sigctx (MonoContext *mctx, void *sigctx)
511 {
512         mono_monoctx_to_sigctx (mctx, sigctx);
513 }
514
515 /*
516  * handle_exception:
517  *
518  *   Called by resuming from a signal handler.
519  */
520 static void
521 handle_signal_exception (gpointer obj)
522 {
523         MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
524         MonoContext ctx;
525
526         memcpy (&ctx, &jit_tls->ex_ctx, sizeof (MonoContext));
527
528         mono_handle_exception (&ctx, obj);
529
530         mono_restore_context (&ctx);
531 }
532
533 /*
534  * This is the function called from the signal handler
535  */
536 gboolean
537 mono_arch_handle_exception (void *ctx, gpointer obj)
538 {
539 #if defined(MONO_CROSS_COMPILE)
540         g_assert_not_reached ();
541 #else
542         MonoJitTlsData *jit_tls;
543         void *sigctx = ctx;
544
545         /*
546          * Resume into the normal stack and handle the exception there.
547          */
548         jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
549
550         /* Pass the ctx parameter in TLS */
551         mono_arch_sigctx_to_monoctx (sigctx, &jit_tls->ex_ctx);
552         /* The others in registers */
553         UCONTEXT_REG_R0 (sigctx) = (gsize)obj;
554
555         UCONTEXT_REG_PC (sigctx) = (gsize)handle_signal_exception;
556         UCONTEXT_REG_SP (sigctx) = UCONTEXT_REG_SP (sigctx) - MONO_ARCH_REDZONE_SIZE;
557 #endif
558
559         return TRUE;
560 }
561
562 gpointer
563 mono_arch_ip_from_context (void *sigctx)
564 {
565 #ifdef MONO_CROSS_COMPILE
566         g_assert_not_reached ();
567         return NULL;
568 #else
569         return (gpointer)UCONTEXT_REG_PC (sigctx);
570 #endif
571 }
572
573 void
574 mono_arch_setup_async_callback (MonoContext *ctx, void (*async_cb)(void *fun), gpointer user_data)
575 {
576         mgreg_t sp = (mgreg_t)MONO_CONTEXT_GET_SP (ctx);
577
578         // FIXME:
579         g_assert (!user_data);
580
581         /* Allocate a stack frame */
582         sp -= 32;
583         MONO_CONTEXT_SET_SP (ctx, sp);
584
585         mono_arch_setup_resume_sighandler_ctx (ctx, async_cb);
586 }
587
588 /*
589  * mono_arch_setup_resume_sighandler_ctx:
590  *
591  *   Setup CTX so execution continues at FUNC.
592  */
593 void
594 mono_arch_setup_resume_sighandler_ctx (MonoContext *ctx, gpointer func)
595 {
596         MONO_CONTEXT_SET_IP (ctx,func);
597 }