[netcore] Implement missing Bmi1/Bmi2 intrinsics (#16919)
[mono-project.git] / mono / mini / exceptions-arm64.c
blob0c1778aea0be658d4adccf1e15edd9f5c2077ac7
1 /**
2 * \file
3 * exception support for ARM64
5 * Copyright 2013 Xamarin Inc
7 * Based on exceptions-arm.c:
9 * Authors:
10 * Dietmar Maurer (dietmar@ximian.com)
11 * Paolo Molaro (lupus@ximian.com)
13 * (C) 2001 Ximian, Inc.
14 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
17 #include "mini.h"
18 #include "mini-runtime.h"
19 #include "aot-runtime.h"
21 #include <mono/arch/arm64/arm64-codegen.h>
22 #include <mono/metadata/abi-details.h>
24 #ifndef DISABLE_JIT
26 gpointer
27 mono_arch_get_restore_context (MonoTrampInfo **info, gboolean aot)
29 guint8 *start, *code;
30 MonoJumpInfo *ji = NULL;
31 GSList *unwind_ops = NULL;
32 int i, ctx_reg, size;
33 guint8 *labels [16];
35 size = 256;
36 code = start = mono_global_codeman_reserve (size);
38 arm_movx (code, ARMREG_IP0, ARMREG_R0);
39 ctx_reg = ARMREG_IP0;
41 /* Restore fregs */
42 arm_ldrx (code, ARMREG_IP1, ctx_reg, MONO_STRUCT_OFFSET (MonoContext, has_fregs));
43 labels [0] = code;
44 arm_cbzx (code, ARMREG_IP1, 0);
45 for (i = 0; i < 32; ++i)
46 arm_ldrfpx (code, i, ctx_reg, MONO_STRUCT_OFFSET (MonoContext, fregs) + (i * sizeof (MonoContextSimdReg)));
47 mono_arm_patch (labels [0], code, MONO_R_ARM64_CBZ);
48 /* Restore gregs */
49 // FIXME: Restore less registers
50 // FIXME: fp should be restored later
51 code = mono_arm_emit_load_regarray (code, 0xffffffff & ~(1 << ctx_reg) & ~(1 << ARMREG_SP), ctx_reg, MONO_STRUCT_OFFSET (MonoContext, regs));
52 /* ip0/ip1 doesn't need to be restored */
53 /* ip1 = pc */
54 arm_ldrx (code, ARMREG_IP1, ctx_reg, MONO_STRUCT_OFFSET (MonoContext, pc));
55 /* ip0 = sp */
56 arm_ldrx (code, ARMREG_IP0, ctx_reg, MONO_STRUCT_OFFSET (MonoContext, regs) + (ARMREG_SP * 8));
57 /* Restore sp, ctx is no longer valid */
58 arm_movspx (code, ARMREG_SP, ARMREG_IP0);
59 /* Branch to pc */
60 arm_brx (code, ARMREG_IP1);
61 /* Not reached */
62 arm_brk (code, 0);
64 g_assert ((code - start) < size);
65 mono_arch_flush_icache (start, code - start);
66 MONO_PROFILER_RAISE (jit_code_buffer, (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL));
68 if (info)
69 *info = mono_tramp_info_create ("restore_context", start, code - start, ji, unwind_ops);
71 return start;
74 gpointer
75 mono_arch_get_call_filter (MonoTrampInfo **info, gboolean aot)
77 guint8 *code;
78 guint8* start;
79 int i, size, offset, gregs_offset, fregs_offset, ctx_offset, num_fregs, frame_size;
80 MonoJumpInfo *ji = NULL;
81 GSList *unwind_ops = NULL;
82 guint8 *labels [16];
84 size = 512;
85 start = code = mono_global_codeman_reserve (size);
87 /* Compute stack frame size and offsets */
88 offset = 0;
89 /* frame block */
90 offset += 2 * 8;
91 /* gregs */
92 gregs_offset = offset;
93 offset += 32 * 8;
94 /* fregs */
95 num_fregs = 8;
96 fregs_offset = offset;
97 offset += num_fregs * 8;
98 ctx_offset = offset;
99 offset += 8;
100 frame_size = ALIGN_TO (offset, MONO_ARCH_FRAME_ALIGNMENT);
103 * We are being called from C code, ctx is in r0, the address to call is in r1.
104 * We need to save state, restore ctx, make the call, then restore the previous state,
105 * returning the value returned by the call.
108 /* Setup a frame */
109 arm_stpx_pre (code, ARMREG_FP, ARMREG_LR, ARMREG_SP, -frame_size);
110 arm_movspx (code, ARMREG_FP, ARMREG_SP);
112 /* Save ctx */
113 arm_strx (code, ARMREG_R0, ARMREG_FP, ctx_offset);
114 /* Save gregs */
115 code = mono_arm_emit_store_regarray (code, MONO_ARCH_CALLEE_SAVED_REGS | (1 << ARMREG_FP), ARMREG_FP, gregs_offset);
116 /* Save fregs */
117 for (i = 0; i < num_fregs; ++i)
118 arm_strfpx (code, ARMREG_D8 + i, ARMREG_FP, fregs_offset + (i * 8));
120 /* Load regs from ctx */
121 code = mono_arm_emit_load_regarray (code, MONO_ARCH_CALLEE_SAVED_REGS, ARMREG_R0, MONO_STRUCT_OFFSET (MonoContext, regs));
122 /* Load fregs */
123 arm_ldrx (code, ARMREG_IP0, ARMREG_R0, MONO_STRUCT_OFFSET (MonoContext, has_fregs));
124 labels [0] = code;
125 arm_cbzx (code, ARMREG_IP0, 0);
126 for (i = 0; i < num_fregs; ++i)
127 arm_ldrfpx (code, ARMREG_D8 + i, ARMREG_R0, MONO_STRUCT_OFFSET (MonoContext, fregs) + ((i + 8) * sizeof (MonoContextSimdReg)));
128 mono_arm_patch (labels [0], code, MONO_R_ARM64_CBZ);
129 /* Load fp */
130 arm_ldrx (code, ARMREG_FP, ARMREG_R0, MONO_STRUCT_OFFSET (MonoContext, regs) + (ARMREG_FP * 8));
132 /* Make the call */
133 arm_blrx (code, ARMREG_R1);
134 /* For filters, the result is in R0 */
136 /* Restore fp */
137 arm_ldrx (code, ARMREG_FP, ARMREG_SP, gregs_offset + (ARMREG_FP * 8));
138 /* Load ctx */
139 arm_ldrx (code, ARMREG_IP0, ARMREG_FP, ctx_offset);
140 /* Save registers back to ctx */
141 /* This isn't strictly neccessary since we don't allocate variables used in eh clauses to registers */
142 code = mono_arm_emit_store_regarray (code, MONO_ARCH_CALLEE_SAVED_REGS, ARMREG_IP0, MONO_STRUCT_OFFSET (MonoContext, regs));
144 /* Restore regs */
145 code = mono_arm_emit_load_regarray (code, MONO_ARCH_CALLEE_SAVED_REGS, ARMREG_FP, gregs_offset);
146 /* Restore fregs */
147 for (i = 0; i < num_fregs; ++i)
148 arm_ldrfpx (code, ARMREG_D8 + i, ARMREG_FP, fregs_offset + (i * 8));
149 /* Destroy frame */
150 code = mono_arm_emit_destroy_frame (code, frame_size, (1 << ARMREG_IP0));
151 arm_retx (code, ARMREG_LR);
153 g_assert ((code - start) < size);
154 mono_arch_flush_icache (start, code - start);
155 MONO_PROFILER_RAISE (jit_code_buffer, (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL));
157 if (info)
158 *info = mono_tramp_info_create ("call_filter", start, code - start, ji, unwind_ops);
160 return start;
163 static gpointer
164 get_throw_trampoline (int size, gboolean corlib, gboolean rethrow, gboolean llvm, gboolean resume_unwind, const char *tramp_name, MonoTrampInfo **info, gboolean aot, gboolean preserve_ips)
166 guint8 *start, *code;
167 MonoJumpInfo *ji = NULL;
168 GSList *unwind_ops = NULL;
169 int i, offset, gregs_offset, fregs_offset, frame_size, num_fregs;
171 code = start = mono_global_codeman_reserve (size);
173 /* We are being called by JITted code, the exception object/type token is in R0 */
175 /* Compute stack frame size and offsets */
176 offset = 0;
177 /* frame block */
178 offset += 2 * 8;
179 /* gregs */
180 gregs_offset = offset;
181 offset += 32 * 8;
182 /* fregs */
183 num_fregs = 8;
184 fregs_offset = offset;
185 offset += num_fregs * 8;
186 frame_size = ALIGN_TO (offset, MONO_ARCH_FRAME_ALIGNMENT);
188 /* Setup a frame */
189 arm_stpx_pre (code, ARMREG_FP, ARMREG_LR, ARMREG_SP, -frame_size);
190 arm_movspx (code, ARMREG_FP, ARMREG_SP);
192 /* Save gregs */
193 code = mono_arm_emit_store_regarray (code, 0xffffffff, ARMREG_FP, gregs_offset);
194 if (corlib && !llvm)
195 /* The real LR is in R1 */
196 arm_strx (code, ARMREG_R1, ARMREG_FP, gregs_offset + (ARMREG_LR * 8));
197 /* Save fp/sp */
198 arm_ldrx (code, ARMREG_IP0, ARMREG_FP, 0);
199 arm_strx (code, ARMREG_IP0, ARMREG_FP, gregs_offset + (ARMREG_FP * 8));
200 arm_addx_imm (code, ARMREG_IP0, ARMREG_FP, frame_size);
201 arm_strx (code, ARMREG_IP0, ARMREG_FP, gregs_offset + (ARMREG_SP * 8));
202 /* Save fregs */
203 for (i = 0; i < num_fregs; ++i)
204 arm_strfpx (code, ARMREG_D8 + i, ARMREG_FP, fregs_offset + (i * 8));
206 /* Call the C trampoline function */
207 /* Arg1 = exception object/type token */
208 arm_movx (code, ARMREG_R0, ARMREG_R0);
209 /* Arg2 = caller ip */
210 if (corlib) {
211 if (llvm)
212 arm_ldrx (code, ARMREG_R1, ARMREG_FP, gregs_offset + (ARMREG_LR * 8));
213 else
214 arm_movx (code, ARMREG_R1, ARMREG_R1);
215 } else {
216 arm_ldrx (code, ARMREG_R1, ARMREG_FP, 8);
218 /* Arg 3 = gregs */
219 arm_addx_imm (code, ARMREG_R2, ARMREG_FP, gregs_offset);
220 /* Arg 4 = fregs */
221 arm_addx_imm (code, ARMREG_R3, ARMREG_FP, fregs_offset);
222 /* Arg 5 = corlib */
223 arm_movzx (code, ARMREG_R4, corlib ? 1 : 0, 0);
224 /* Arg 6 = rethrow */
225 arm_movzx (code, ARMREG_R5, rethrow ? 1 : 0, 0);
226 if (!resume_unwind) {
227 /* Arg 7 = preserve_ips */
228 arm_movzx (code, ARMREG_R6, preserve_ips ? 1 : 0, 0);
231 /* Call the function */
232 if (aot) {
233 MonoJitICallId icall_id;
235 if (resume_unwind)
236 icall_id = MONO_JIT_ICALL_mono_arm_resume_unwind;
237 else
238 icall_id = MONO_JIT_ICALL_mono_arm_throw_exception;
240 code = mono_arm_emit_aotconst (&ji, code, start, ARMREG_LR, MONO_PATCH_INFO_JIT_ICALL_ADDR, GUINT_TO_POINTER (icall_id));
241 } else {
242 gpointer icall_func;
244 if (resume_unwind)
245 icall_func = (gpointer)mono_arm_resume_unwind;
246 else
247 icall_func = (gpointer)mono_arm_throw_exception;
249 code = mono_arm_emit_imm64 (code, ARMREG_LR, (guint64)icall_func);
251 arm_blrx (code, ARMREG_LR);
252 /* This shouldn't return */
253 arm_brk (code, 0x0);
255 g_assert ((code - start) < size);
256 mono_arch_flush_icache (start, code - start);
257 MONO_PROFILER_RAISE (jit_code_buffer, (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL));
259 if (info)
260 *info = mono_tramp_info_create (tramp_name, start, code - start, ji, unwind_ops);
262 return start;
265 gpointer
266 mono_arch_get_throw_exception (MonoTrampInfo **info, gboolean aot)
268 return get_throw_trampoline (256, FALSE, FALSE, FALSE, FALSE, "throw_exception", info, aot, FALSE);
271 gpointer
272 mono_arch_get_rethrow_exception (MonoTrampInfo **info, gboolean aot)
274 return get_throw_trampoline (256, FALSE, TRUE, FALSE, FALSE, "rethrow_exception", info, aot, FALSE);
277 gpointer
278 mono_arch_get_rethrow_preserve_exception (MonoTrampInfo **info, gboolean aot)
280 return get_throw_trampoline (256, FALSE, TRUE, FALSE, FALSE, "rethrow_preserve_exception", info, aot, TRUE);
283 gpointer
284 mono_arch_get_throw_corlib_exception (MonoTrampInfo **info, gboolean aot)
286 return get_throw_trampoline (256, TRUE, FALSE, FALSE, FALSE, "throw_corlib_exception", info, aot, FALSE);
289 GSList*
290 mono_arm_get_exception_trampolines (gboolean aot)
292 MonoTrampInfo *info;
293 GSList *tramps = NULL;
295 // FIXME Macroize.
297 /* LLVM uses the normal trampolines, but with a different name */
298 get_throw_trampoline (256, TRUE, FALSE, FALSE, FALSE, "llvm_throw_corlib_exception_trampoline", &info, aot, FALSE);
299 info->jit_icall_info = &mono_get_jit_icall_info ()->mono_llvm_throw_corlib_exception_trampoline;
300 tramps = g_slist_prepend (tramps, info);
302 get_throw_trampoline (256, TRUE, FALSE, TRUE, FALSE, "llvm_throw_corlib_exception_abs_trampoline", &info, aot, FALSE);
303 info->jit_icall_info = &mono_get_jit_icall_info ()->mono_llvm_throw_corlib_exception_abs_trampoline;
304 tramps = g_slist_prepend (tramps, info);
306 get_throw_trampoline (256, FALSE, FALSE, FALSE, TRUE, "llvm_resume_unwind_trampoline", &info, aot, FALSE);
307 info->jit_icall_info = &mono_get_jit_icall_info ()->mono_llvm_resume_unwind_trampoline;
308 tramps = g_slist_prepend (tramps, info);
310 return tramps;
313 #else
315 GSList*
316 mono_arm_get_exception_trampolines (gboolean aot)
318 g_assert_not_reached ();
319 return NULL;
322 #endif /* DISABLE_JIT */
324 void
325 mono_arch_exceptions_init (void)
327 gpointer tramp;
328 GSList *tramps, *l;
330 if (mono_aot_only) {
332 // FIXME Macroize.
334 tramp = mono_aot_get_trampoline ("llvm_throw_corlib_exception_trampoline");
335 mono_register_jit_icall_info (&mono_get_jit_icall_info ()->mono_llvm_throw_corlib_exception_trampoline, tramp, "llvm_throw_corlib_exception_trampoline", NULL, TRUE, NULL);
337 tramp = mono_aot_get_trampoline ("llvm_throw_corlib_exception_abs_trampoline");
338 mono_register_jit_icall_info (&mono_get_jit_icall_info ()->mono_llvm_throw_corlib_exception_abs_trampoline, tramp, "llvm_throw_corlib_exception_abs_trampoline", NULL, TRUE, NULL);
340 tramp = mono_aot_get_trampoline ("llvm_resume_unwind_trampoline");
341 mono_register_jit_icall_info (&mono_get_jit_icall_info ()->mono_llvm_resume_unwind_trampoline, tramp, "llvm_resume_unwind_trampoline", NULL, TRUE, NULL);
343 } else {
344 tramps = mono_arm_get_exception_trampolines (FALSE);
345 for (l = tramps; l; l = l->next) {
346 MonoTrampInfo *info = (MonoTrampInfo*)l->data;
347 mono_register_jit_icall_info (info->jit_icall_info, info->code, g_strdup (info->name), NULL, TRUE, NULL);
348 mono_tramp_info_register (info, NULL);
350 g_slist_free (tramps);
355 * mono_arm_throw_exception:
357 * This function is called by the exception trampolines.
358 * FP_REGS points to the 8 callee saved fp regs.
360 void
361 mono_arm_throw_exception (gpointer arg, host_mgreg_t pc, host_mgreg_t *int_regs, gdouble *fp_regs, gboolean corlib, gboolean rethrow, gboolean preserve_ips)
363 ERROR_DECL (error);
364 MonoContext ctx;
365 MonoObject *exc = NULL;
366 guint32 ex_token_index, ex_token;
368 if (!corlib)
369 exc = (MonoObject*)arg;
370 else {
371 ex_token_index = (guint64)arg;
372 ex_token = MONO_TOKEN_TYPE_DEF | ex_token_index;
373 exc = (MonoObject*)mono_exception_from_token (mono_defaults.corlib, ex_token);
376 /* Adjust pc so it points into the call instruction */
377 pc -= 4;
379 /* Initialize a ctx based on the arguments */
380 memset (&ctx, 0, sizeof (MonoContext));
381 memcpy (&(ctx.regs [0]), int_regs, sizeof (host_mgreg_t) * 32);
382 for (int i = 0; i < 8; i++)
383 *((gdouble*)&ctx.fregs [ARMREG_D8 + i]) = fp_regs [i];
384 ctx.has_fregs = 1;
385 ctx.pc = pc;
387 if (mono_object_isinst_checked (exc, mono_defaults.exception_class, error)) {
388 MonoException *mono_ex = (MonoException*)exc;
389 if (!rethrow) {
390 mono_ex->stack_trace = NULL;
391 mono_ex->trace_ips = NULL;
392 } else if (preserve_ips) {
393 mono_ex->caught_in_unmanaged = TRUE;
396 mono_error_assert_ok (error);
398 mono_handle_exception (&ctx, exc);
400 mono_restore_context (&ctx);
403 void
404 mono_arm_resume_unwind (gpointer arg, host_mgreg_t pc, host_mgreg_t *int_regs, gdouble *fp_regs, gboolean corlib, gboolean rethrow)
406 MonoContext ctx;
408 /* Adjust pc so it points into the call instruction */
409 pc -= 4;
411 /* Initialize a ctx based on the arguments */
412 memset (&ctx, 0, sizeof (MonoContext));
413 memcpy (&(ctx.regs [0]), int_regs, sizeof (host_mgreg_t) * 32);
414 for (int i = 0; i < 8; i++)
415 *((gdouble*)&ctx.fregs [ARMREG_D8 + i]) = fp_regs [i];
416 ctx.has_fregs = 1;
417 ctx.pc = pc;
419 mono_resume_unwind (&ctx);
423 * mono_arch_unwind_frame:
425 * See exceptions-amd64.c for docs;
427 gboolean
428 mono_arch_unwind_frame (MonoDomain *domain, MonoJitTlsData *jit_tls,
429 MonoJitInfo *ji, MonoContext *ctx,
430 MonoContext *new_ctx, MonoLMF **lmf,
431 host_mgreg_t **save_locations,
432 StackFrameInfo *frame)
434 gpointer ip = MONO_CONTEXT_GET_IP (ctx);
436 memset (frame, 0, sizeof (StackFrameInfo));
437 frame->ji = ji;
439 *new_ctx = *ctx;
441 if (ji != NULL) {
442 host_mgreg_t regs [MONO_MAX_IREGS + 8 + 1];
443 guint8 *cfa;
444 guint32 unwind_info_len;
445 guint8 *unwind_info;
448 if (ji->is_trampoline)
449 frame->type = FRAME_TYPE_TRAMPOLINE;
450 else
451 frame->type = FRAME_TYPE_MANAGED;
453 unwind_info = mono_jinfo_get_unwind_info (ji, &unwind_info_len);
455 memcpy (regs, &new_ctx->regs, sizeof (host_mgreg_t) * 32);
456 /* v8..v15 are callee saved */
457 for (int i = 0; i < 8; i++)
458 (regs + MONO_MAX_IREGS) [i] = *((host_mgreg_t*)&new_ctx->fregs [8 + i]);
460 gboolean success = mono_unwind_frame (unwind_info, unwind_info_len, (guint8*)ji->code_start,
461 (guint8*)ji->code_start + ji->code_size,
462 (guint8*)ip, NULL, regs, MONO_MAX_IREGS + 8,
463 save_locations, MONO_MAX_IREGS, (guint8**)&cfa);
465 if (!success)
466 return FALSE;
468 memcpy (&new_ctx->regs, regs, sizeof (host_mgreg_t) * 32);
469 for (int i = 0; i < 8; i++)
470 *((host_mgreg_t*)&new_ctx->fregs [8 + i]) = (regs + MONO_MAX_IREGS) [i];
472 new_ctx->pc = regs [ARMREG_LR];
473 new_ctx->regs [ARMREG_SP] = (host_mgreg_t)(gsize)cfa;
475 if (*lmf && (*lmf)->gregs [MONO_ARCH_LMF_REG_SP] && (MONO_CONTEXT_GET_SP (ctx) >= (gpointer)(*lmf)->gregs [MONO_ARCH_LMF_REG_SP])) {
476 /* remove any unused lmf */
477 *lmf = (MonoLMF*)(((gsize)(*lmf)->previous_lmf) & ~3);
480 /* we substract 1, so that the IP points into the call instruction */
481 new_ctx->pc--;
483 return TRUE;
484 } else if (*lmf) {
485 g_assert ((((guint64)(*lmf)->previous_lmf) & 2) == 0);
487 frame->type = FRAME_TYPE_MANAGED_TO_NATIVE;
489 ji = mini_jit_info_table_find (domain, (gpointer)(*lmf)->pc, NULL);
490 if (!ji)
491 return FALSE;
493 g_assert (MONO_ARCH_LMF_REGS == ((0x3ff << 19) | (1 << ARMREG_FP) | (1 << ARMREG_SP)));
494 memcpy (&new_ctx->regs [ARMREG_R19], &(*lmf)->gregs [0], sizeof (host_mgreg_t) * 10);
495 new_ctx->regs [ARMREG_FP] = (*lmf)->gregs [MONO_ARCH_LMF_REG_FP];
496 new_ctx->regs [ARMREG_SP] = (*lmf)->gregs [MONO_ARCH_LMF_REG_SP];
497 new_ctx->pc = (*lmf)->pc;
499 /* we substract 1, so that the IP points into the call instruction */
500 new_ctx->pc--;
502 *lmf = (MonoLMF*)(((gsize)(*lmf)->previous_lmf) & ~3);
504 return TRUE;
507 return FALSE;
511 * handle_exception:
513 * Called by resuming from a signal handler.
515 static void
516 handle_signal_exception (gpointer obj)
518 MonoJitTlsData *jit_tls = mono_tls_get_jit_tls ();
519 MonoContext ctx;
521 memcpy (&ctx, &jit_tls->ex_ctx, sizeof (MonoContext));
523 mono_handle_exception (&ctx, (MonoObject*)obj);
525 mono_restore_context (&ctx);
529 * This is the function called from the signal handler
531 gboolean
532 mono_arch_handle_exception (void *ctx, gpointer obj)
534 #if defined(MONO_CROSS_COMPILE)
535 g_assert_not_reached ();
536 #else
537 MonoJitTlsData *jit_tls;
538 void *sigctx = ctx;
541 * Resume into the normal stack and handle the exception there.
543 jit_tls = mono_tls_get_jit_tls ();
545 /* Pass the ctx parameter in TLS */
546 mono_sigctx_to_monoctx (sigctx, &jit_tls->ex_ctx);
547 /* The others in registers */
548 UCONTEXT_REG_R0 (sigctx) = (gsize)obj;
550 UCONTEXT_REG_PC (sigctx) = (gsize)handle_signal_exception;
551 UCONTEXT_REG_SP (sigctx) = UCONTEXT_REG_SP (sigctx) - MONO_ARCH_REDZONE_SIZE;
552 #endif
554 return TRUE;
557 gpointer
558 mono_arch_ip_from_context (void *sigctx)
560 #ifdef MONO_CROSS_COMPILE
561 g_assert_not_reached ();
562 return NULL;
563 #else
564 return (gpointer)UCONTEXT_REG_PC (sigctx);
565 #endif
568 void
569 mono_arch_setup_async_callback (MonoContext *ctx, void (*async_cb)(void *fun), gpointer user_data)
571 host_mgreg_t sp = (host_mgreg_t)MONO_CONTEXT_GET_SP (ctx);
573 // FIXME:
574 g_assert (!user_data);
576 /* Allocate a stack frame */
577 sp -= 32;
578 MONO_CONTEXT_SET_SP (ctx, sp);
580 mono_arch_setup_resume_sighandler_ctx (ctx, (gpointer)async_cb);
584 * mono_arch_setup_resume_sighandler_ctx:
586 * Setup CTX so execution continues at FUNC.
588 void
589 mono_arch_setup_resume_sighandler_ctx (MonoContext *ctx, gpointer func)
591 MONO_CONTEXT_SET_IP (ctx,func);
594 void
595 mono_arch_undo_ip_adjustment (MonoContext *ctx)
597 ctx->pc++;
600 void
601 mono_arch_do_ip_adjustment (MonoContext *ctx)
603 ctx->pc--;