3 * exception support for ARM
6 * Dietmar Maurer (dietmar@ximian.com)
7 * Paolo Molaro (lupus@ximian.com)
9 * (C) 2001 Ximian, Inc.
17 #ifndef MONO_CROSS_COMPILE
19 #include <asm/sigcontext.h>
20 #endif /* def HOST_ANDROID */
23 #ifdef HAVE_UCONTEXT_H
25 #endif /* def HAVE_UCONTEXT_H */
27 #include <mono/arch/arm/arm-codegen.h>
28 #include <mono/arch/arm/arm-vfp-codegen.h>
29 #include <mono/metadata/abi-details.h>
30 #include <mono/metadata/appdomain.h>
31 #include <mono/metadata/tabledefs.h>
32 #include <mono/metadata/threads.h>
33 #include <mono/metadata/debug-helpers.h>
34 #include <mono/metadata/exception.h>
35 #include <mono/metadata/mono-debug.h>
39 #include "mini-runtime.h"
40 #include "aot-runtime.h"
41 #include "mono/utils/mono-sigcontext.h"
42 #include "mono/utils/mono-compiler.h"
47 * arch_get_restore_context:
49 * Returns a pointer to a method which restores a previously saved sigcontext.
50 * The first argument in r0 is the pointer to the context.
53 mono_arch_get_restore_context (MonoTrampInfo
**info
, gboolean aot
)
58 MonoJumpInfo
*ji
= NULL
;
59 GSList
*unwind_ops
= NULL
;
61 start
= code
= mono_global_codeman_reserve (128);
64 * Move things to their proper place so we can restore all the registers with
70 if (!mono_arch_is_soft_float ()) {
71 ARM_ADD_REG_IMM8 (code
, ARMREG_IP
, ctx_reg
, MONO_STRUCT_OFFSET (MonoContext
, fregs
));
72 ARM_FLDMD (code
, ARM_VFP_D0
, 16, ARMREG_IP
);
76 ARM_LDR_IMM (code
, ARMREG_IP
, ctx_reg
, MONO_STRUCT_OFFSET (MonoContext
, pc
));
77 ARM_STR_IMM (code
, ARMREG_IP
, ctx_reg
, MONO_STRUCT_OFFSET (MonoContext
, regs
) + (ARMREG_PC
* sizeof (mgreg_t
)));
79 /* restore everything */
80 ARM_ADD_REG_IMM8 (code
, ARMREG_IP
, ctx_reg
, MONO_STRUCT_OFFSET(MonoContext
, regs
));
81 ARM_LDM (code
, ARMREG_IP
, 0xffff);
86 g_assert ((code
- start
) < 128);
88 mono_arch_flush_icache (start
, code
- start
);
89 MONO_PROFILER_RAISE (jit_code_buffer
, (start
, code
- start
, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING
, NULL
));
92 *info
= mono_tramp_info_create ("restore_context", start
, code
- start
, ji
, unwind_ops
);
98 * arch_get_call_filter:
100 * Returns a pointer to a method which calls an exception filter. We
101 * also use this function to call finally handlers (we pass NULL as
102 * @exc object in this case).
105 mono_arch_get_call_filter (MonoTrampInfo
**info
, gboolean aot
)
110 MonoJumpInfo
*ji
= NULL
;
111 GSList
*unwind_ops
= NULL
;
113 /* call_filter (MonoContext *ctx, unsigned long eip, gpointer exc) */
114 start
= code
= mono_global_codeman_reserve (320);
116 /* save all the regs on the stack */
117 ARM_MOV_REG_REG (code
, ARMREG_IP
, ARMREG_SP
);
118 ARM_PUSH (code
, MONO_ARM_REGSAVE_MASK
);
120 ARM_SUB_REG_IMM8 (code
, ARMREG_SP
, ARMREG_SP
, 8);
122 /* restore all the regs from ctx (in r0), but not sp, the stack pointer */
124 ARM_LDR_IMM (code
, ARMREG_IP
, ctx_reg
, MONO_STRUCT_OFFSET (MonoContext
, pc
));
125 ARM_ADD_REG_IMM8 (code
, ARMREG_LR
, ctx_reg
, MONO_STRUCT_OFFSET(MonoContext
, regs
) + (MONO_ARM_FIRST_SAVED_REG
* sizeof (mgreg_t
)));
126 ARM_LDM (code
, ARMREG_LR
, MONO_ARM_REGSAVE_MASK
);
127 /* call handler at eip (r1) and set the first arg with the exception (r2) */
128 ARM_MOV_REG_REG (code
, ARMREG_R0
, ARMREG_R2
);
129 ARM_MOV_REG_REG (code
, ARMREG_LR
, ARMREG_PC
);
130 ARM_MOV_REG_REG (code
, ARMREG_PC
, ARMREG_R1
);
132 ARM_ADD_REG_IMM8 (code
, ARMREG_SP
, ARMREG_SP
, 8);
135 ARM_POP_NWB (code
, 0xff0 | ((1 << ARMREG_SP
) | (1 << ARMREG_PC
)));
137 g_assert ((code
- start
) < 320);
139 mono_arch_flush_icache (start
, code
- start
);
140 MONO_PROFILER_RAISE (jit_code_buffer
, (start
, code
- start
, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING
, NULL
));
143 *info
= mono_tramp_info_create ("call_filter", start
, code
- start
, ji
, unwind_ops
);
148 #endif /* DISABLE_JIT */
151 mono_arm_throw_exception (MonoObject
*exc
, host_mgreg_t pc
, host_mgreg_t sp
, host_mgreg_t
*int_regs
, gdouble
*fp_regs
, gboolean preserve_ips
)
155 gboolean rethrow
= sp
& 1;
157 sp
&= ~1; /* clear the optional rethrow bit */
158 pc
&= ~1; /* clear the thumb bit */
159 /* adjust eip so that it point into the call instruction */
162 /*printf ("stack in throw: %p\n", esp);*/
163 MONO_CONTEXT_SET_BP (&ctx
, int_regs
[ARMREG_FP
- 4]);
164 MONO_CONTEXT_SET_SP (&ctx
, sp
);
165 MONO_CONTEXT_SET_IP (&ctx
, pc
);
166 memcpy (((guint8
*)&ctx
.regs
) + (ARMREG_R4
* sizeof (host_mgreg_t
)), int_regs
, 8 * sizeof (host_mgreg_t
));
167 memcpy (&ctx
.fregs
, fp_regs
, sizeof (double) * 16);
169 if (mono_object_isinst_checked (exc
, mono_defaults
.exception_class
, error
)) {
170 MonoException
*mono_ex
= (MonoException
*)exc
;
172 mono_ex
->stack_trace
= NULL
;
173 mono_ex
->trace_ips
= NULL
;
174 } else if (preserve_ips
) {
175 mono_ex
->caught_in_unmanaged
= TRUE
;
178 mono_error_assert_ok (error
);
179 mono_handle_exception (&ctx
, exc
);
180 mono_restore_context (&ctx
);
181 g_assert_not_reached ();
185 mono_arm_throw_exception_by_token (guint32 ex_token_index
, host_mgreg_t pc
, host_mgreg_t sp
, host_mgreg_t
*int_regs
, gdouble
*fp_regs
)
187 guint32 ex_token
= MONO_TOKEN_TYPE_DEF
| ex_token_index
;
188 /* Clear thumb bit */
191 mono_arm_throw_exception ((MonoObject
*)mono_exception_from_token (mono_defaults
.corlib
, ex_token
), pc
, sp
, int_regs
, fp_regs
, FALSE
);
195 mono_arm_resume_unwind (guint32 dummy1
, host_mgreg_t pc
, host_mgreg_t sp
, host_mgreg_t
*int_regs
, gdouble
*fp_regs
)
199 pc
&= ~1; /* clear the optional rethrow bit */
200 /* adjust eip so that it point into the call instruction */
203 MONO_CONTEXT_SET_BP (&ctx
, int_regs
[ARMREG_FP
- 4]);
204 MONO_CONTEXT_SET_SP (&ctx
, sp
);
205 MONO_CONTEXT_SET_IP (&ctx
, pc
);
206 memcpy (((guint8
*)&ctx
.regs
) + (ARMREG_R4
* sizeof (host_mgreg_t
)), int_regs
, 8 * sizeof (host_mgreg_t
));
208 mono_resume_unwind (&ctx
);
214 * get_throw_trampoline:
216 * Returns a function pointer which can be used to raise
217 * exceptions. The returned function has the following
218 * signature: void (*func) (MonoException *exc); or
219 * void (*func) (guint32 ex_token, guint8* ip);
223 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
)
227 MonoJumpInfo
*ji
= NULL
;
228 GSList
*unwind_ops
= NULL
;
231 code
= start
= mono_global_codeman_reserve (size
);
233 mono_add_unwind_op_def_cfa (unwind_ops
, code
, start
, ARMREG_SP
, 0);
235 /* save all the regs on the stack */
236 ARM_MOV_REG_REG (code
, ARMREG_IP
, ARMREG_SP
);
237 ARM_PUSH (code
, MONO_ARM_REGSAVE_MASK
);
239 cfa_offset
= MONO_ARM_NUM_SAVED_REGS
* sizeof (mgreg_t
);
240 mono_add_unwind_op_def_cfa (unwind_ops
, code
, start
, ARMREG_SP
, cfa_offset
);
241 mono_add_unwind_op_offset (unwind_ops
, code
, start
, ARMREG_LR
, - sizeof (mgreg_t
));
244 if (!mono_arch_is_soft_float ()) {
245 ARM_SUB_REG_IMM8 (code
, ARMREG_SP
, ARMREG_SP
, sizeof (double) * 16);
246 cfa_offset
+= sizeof (double) * 16;
247 mono_add_unwind_op_def_cfa_offset (unwind_ops
, code
, start
, cfa_offset
);
248 ARM_FSTMD (code
, ARM_VFP_D0
, 16, ARMREG_SP
);
253 if (!resume_unwind
&& !corlib
)
254 param_size
+= 4; // Extra arg
255 ARM_SUB_REG_IMM8 (code
, ARMREG_SP
, ARMREG_SP
, param_size
);
256 cfa_offset
+= param_size
;
257 mono_add_unwind_op_def_cfa_offset (unwind_ops
, code
, start
, cfa_offset
);
259 /* call throw_exception (exc, ip, sp, int_regs, fp_regs) */
261 ARM_ADD_REG_IMM8 (code
, ARMREG_R2
, ARMREG_SP
, cfa_offset
);
262 /* we encode rethrow in sp */
264 g_assert (!resume_unwind
);
266 ARM_ORR_REG_IMM8 (code
, ARMREG_R2
, ARMREG_R2
, rethrow
);
268 /* exc is already in place in r0 */
270 /* The caller ip is already in R1 */
273 * The address passed by llvm might point to before the call,
274 * thus outside the eh range recorded by llvm. Use the return
276 * FIXME: Do this on more platforms.
278 ARM_MOV_REG_REG (code
, ARMREG_R1
, ARMREG_LR
); /* caller ip */
281 ARM_MOV_REG_REG (code
, ARMREG_R1
, ARMREG_LR
); /* caller ip */
284 ARM_ADD_REG_IMM8 (code
, ARMREG_R3
, ARMREG_SP
, (cfa_offset
- (MONO_ARM_NUM_SAVED_REGS
* sizeof (mgreg_t
))));
285 if (resume_unwind
|| corlib
) {
287 ARM_ADD_REG_IMM8 (code
, ARMREG_LR
, ARMREG_SP
, 8);
288 ARM_STR_IMM (code
, ARMREG_LR
, ARMREG_SP
, 0);
291 ARM_MOV_REG_IMM8 (code
, ARMREG_R5
, preserve_ips
);
292 ARM_STR_IMM (code
, ARMREG_R5
, ARMREG_SP
, 4);
295 ARM_ADD_REG_IMM8 (code
, ARMREG_LR
, ARMREG_SP
, 8);
296 ARM_STR_IMM (code
, ARMREG_LR
, ARMREG_SP
, 0);
300 const char *icall_name
;
303 icall_name
= "mono_arm_resume_unwind";
305 icall_name
= "mono_arm_throw_exception_by_token";
307 icall_name
= "mono_arm_throw_exception";
309 ji
= mono_patch_info_list_prepend (ji
, code
- start
, MONO_PATCH_INFO_JIT_ICALL_ADDR
, icall_name
);
310 ARM_LDR_IMM (code
, ARMREG_IP
, ARMREG_PC
, 0);
312 *(gpointer
*)(gpointer
)code
= NULL
;
314 ARM_LDR_REG_REG (code
, ARMREG_IP
, ARMREG_PC
, ARMREG_IP
);
316 code
= mono_arm_emit_load_imm (code
, ARMREG_IP
, GPOINTER_TO_UINT (resume_unwind
? (gpointer
)mono_arm_resume_unwind
: (corlib
? (gpointer
)mono_arm_throw_exception_by_token
: (gpointer
)mono_arm_throw_exception
)));
318 ARM_MOV_REG_REG (code
, ARMREG_LR
, ARMREG_PC
);
319 ARM_MOV_REG_REG (code
, ARMREG_PC
, ARMREG_IP
);
320 /* we should never reach this breakpoint */
322 g_assert ((code
- start
) < size
);
323 mono_arch_flush_icache (start
, code
- start
);
324 MONO_PROFILER_RAISE (jit_code_buffer
, (start
, code
- start
, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING
, NULL
));
327 *info
= mono_tramp_info_create (tramp_name
, start
, code
- start
, ji
, unwind_ops
);
333 * arch_get_throw_exception:
335 * Returns a function pointer which can be used to raise
336 * exceptions. The returned function has the following
337 * signature: void (*func) (MonoException *exc);
338 * For example to raise an arithmetic exception you can use:
340 * x86_push_imm (code, mono_get_exception_arithmetic ());
341 * x86_call_code (code, arch_get_throw_exception ());
345 mono_arch_get_throw_exception (MonoTrampInfo
**info
, gboolean aot
)
347 return get_throw_trampoline (132, FALSE
, FALSE
, FALSE
, FALSE
, "throw_exception", info
, aot
, FALSE
);
351 * mono_arch_get_rethrow_exception:
353 * Returns a function pointer which can be used to rethrow
354 * exceptions. The returned function has the following
355 * signature: void (*func) (MonoException *exc);
359 mono_arch_get_rethrow_exception (MonoTrampInfo
**info
, gboolean aot
)
361 return get_throw_trampoline (132, FALSE
, TRUE
, FALSE
, FALSE
, "rethrow_exception", info
, aot
, FALSE
);
365 mono_arch_get_rethrow_preserve_exception (MonoTrampInfo
**info
, gboolean aot
)
367 return get_throw_trampoline (132, FALSE
, TRUE
, FALSE
, FALSE
, "rethrow_preserve_exception", info
, aot
, TRUE
);
371 * mono_arch_get_throw_corlib_exception:
372 * \returns a function pointer which can be used to raise
373 * corlib exceptions. The returned function has the following
374 * signature: void (*func) (guint32 ex_token, guint32 offset);
375 * Here, \c offset is the offset which needs to be substracted from the caller IP
376 * to get the IP of the throw. Passing the offset has the advantage that it
377 * needs no relocations in the caller.
378 * On ARM, the ip is passed instead of an offset.
381 mono_arch_get_throw_corlib_exception (MonoTrampInfo
**info
, gboolean aot
)
383 return get_throw_trampoline (168, TRUE
, FALSE
, FALSE
, FALSE
, "throw_corlib_exception", info
, aot
, FALSE
);
387 mono_arm_get_exception_trampolines (gboolean aot
)
390 GSList
*tramps
= NULL
;
392 /* LLVM uses the normal trampolines, but with a different name */
393 get_throw_trampoline (168, TRUE
, FALSE
, FALSE
, FALSE
, "llvm_throw_corlib_exception_trampoline", &info
, aot
, FALSE
);
394 tramps
= g_slist_prepend (tramps
, info
);
396 get_throw_trampoline (168, TRUE
, FALSE
, TRUE
, FALSE
, "llvm_throw_corlib_exception_abs_trampoline", &info
, aot
, FALSE
);
397 tramps
= g_slist_prepend (tramps
, info
);
399 get_throw_trampoline (168, FALSE
, FALSE
, FALSE
, TRUE
, "llvm_resume_unwind_trampoline", &info
, aot
, FALSE
);
400 tramps
= g_slist_prepend (tramps
, info
);
408 mono_arm_get_exception_trampolines (gboolean aot
)
410 g_assert_not_reached ();
417 mono_arch_exceptions_init (void)
423 tramp
= mono_aot_get_trampoline ("llvm_throw_corlib_exception_trampoline");
424 mono_register_jit_icall (tramp
, "llvm_throw_corlib_exception_trampoline", NULL
, TRUE
);
425 tramp
= mono_aot_get_trampoline ("llvm_throw_corlib_exception_abs_trampoline");
426 mono_register_jit_icall (tramp
, "llvm_throw_corlib_exception_abs_trampoline", NULL
, TRUE
);
427 tramp
= mono_aot_get_trampoline ("llvm_resume_unwind_trampoline");
428 mono_register_jit_icall (tramp
, "llvm_resume_unwind_trampoline", NULL
, TRUE
);
430 tramps
= mono_arm_get_exception_trampolines (FALSE
);
431 for (l
= tramps
; l
; l
= l
->next
) {
432 MonoTrampInfo
*info
= (MonoTrampInfo
*)l
->data
;
434 mono_register_jit_icall (info
->code
, g_strdup (info
->name
), NULL
, TRUE
);
435 mono_tramp_info_register (info
, NULL
);
437 g_slist_free (tramps
);
442 * mono_arch_unwind_frame:
444 * See exceptions-amd64.c for docs;
447 mono_arch_unwind_frame (MonoDomain
*domain
, MonoJitTlsData
*jit_tls
,
448 MonoJitInfo
*ji
, MonoContext
*ctx
,
449 MonoContext
*new_ctx
, MonoLMF
**lmf
,
450 host_mgreg_t
**save_locations
,
451 StackFrameInfo
*frame
)
453 gpointer ip
= MONO_CONTEXT_GET_IP (ctx
);
455 memset (frame
, 0, sizeof (StackFrameInfo
));
462 mono_unwind_reg_t regs
[MONO_MAX_IREGS
+ 1 + 8];
464 guint32 unwind_info_len
;
467 if (ji
->is_trampoline
)
468 frame
->type
= FRAME_TYPE_TRAMPOLINE
;
470 frame
->type
= FRAME_TYPE_MANAGED
;
472 unwind_info
= mono_jinfo_get_unwind_info (ji
, &unwind_info_len
);
475 printf ("%s %p %p\n", ji->d.method->name, ji->code_start, ip);
476 mono_print_unwind_info (unwind_info, unwind_info_len);
479 for (i
= 0; i
< 16; ++i
)
480 regs
[i
] = new_ctx
->regs
[i
];
482 /* On IOS, d8..d15 are callee saved. They are mapped to 8..15 in unwind.c */
483 for (i
= 0; i
< 8; ++i
)
484 regs
[MONO_MAX_IREGS
+ i
] = *(guint64
*)&(new_ctx
->fregs
[8 + i
]);
487 mono_unwind_frame (unwind_info
, unwind_info_len
, (guint8
*)ji
->code_start
,
488 (guint8
*)ji
->code_start
+ ji
->code_size
,
489 (guint8
*)ip
, NULL
, regs
, MONO_MAX_IREGS
+ 8,
490 save_locations
, MONO_MAX_IREGS
, &cfa
);
492 for (i
= 0; i
< 16; ++i
)
493 new_ctx
->regs
[i
] = regs
[i
];
494 new_ctx
->pc
= regs
[ARMREG_LR
];
495 new_ctx
->regs
[ARMREG_SP
] = (gsize
)cfa
;
497 for (i
= 0; i
< 8; ++i
)
498 new_ctx
->fregs
[8 + i
] = *(double*)&(regs
[MONO_MAX_IREGS
+ i
]);
501 /* Clear thumb bit */
504 /* we substract 1, so that the IP points into the call instruction */
509 g_assert ((((guint64
)(*lmf
)->previous_lmf
) & 2) == 0);
511 frame
->type
= FRAME_TYPE_MANAGED_TO_NATIVE
;
513 if ((ji
= mini_jit_info_table_find (domain
, (gpointer
)(gsize
)(*lmf
)->ip
, NULL
))) {
518 frame
->method
= (*lmf
)->method
;
522 * The LMF is saved at the start of the method using:
523 * ARM_MOV_REG_REG (code, ARMREG_IP, ARMREG_SP)
524 * ARM_PUSH (code, 0x5ff0);
525 * So it stores the register state as it existed at the caller. We need to
526 * produce the register state which existed at the time of the call which
527 * transitioned to native call, so we save the sp/fp/ip in the LMF.
529 memcpy (&new_ctx
->regs
[0], &(*lmf
)->iregs
[0], sizeof (host_mgreg_t
) * 13);
530 new_ctx
->pc
= (*lmf
)->ip
;
531 new_ctx
->regs
[ARMREG_SP
] = (*lmf
)->sp
;
532 new_ctx
->regs
[ARMREG_FP
] = (*lmf
)->fp
;
534 /* Clear thumb bit */
537 /* we substract 1, so that the IP points into the call instruction */
540 *lmf
= (MonoLMF
*)(((gsize
)(*lmf
)->previous_lmf
) & ~3);
551 * Called by resuming from a signal handler.
554 handle_signal_exception (gpointer obj
)
556 MonoJitTlsData
*jit_tls
= mono_tls_get_jit_tls ();
559 memcpy (&ctx
, &jit_tls
->ex_ctx
, sizeof (MonoContext
));
561 mono_handle_exception (&ctx
, (MonoObject
*)obj
);
563 mono_restore_context (&ctx
);
567 * This works around a gcc 4.5 bug:
568 * https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/721531
570 static MONO_NEVER_INLINE gpointer
571 get_handle_signal_exception_addr (void)
573 return (gpointer
)handle_signal_exception
;
577 * This is the function called from the signal handler
580 mono_arch_handle_exception (void *ctx
, gpointer obj
)
582 #if defined(MONO_CROSS_COMPILE) || !defined(MONO_ARCH_HAVE_SIGCTX_TO_MONOCTX)
583 g_assert_not_reached ();
584 #elif defined(MONO_ARCH_USE_SIGACTION)
585 arm_ucontext
*sigctx
= (arm_ucontext
*)ctx
;
587 * Handling the exception in the signal handler is problematic, since the original
588 * signal is disabled, and we could run arbitrary code though the debugger. So
589 * resume into the normal stack and do most work there if possible.
591 MonoJitTlsData
*jit_tls
= mono_tls_get_jit_tls ();
592 guint64 sp
= UCONTEXT_REG_SP (sigctx
);
594 /* Pass the ctx parameter in TLS */
595 mono_sigctx_to_monoctx (sigctx
, &jit_tls
->ex_ctx
);
596 /* The others in registers */
597 UCONTEXT_REG_R0 (sigctx
) = (gsize
)obj
;
599 /* Allocate a stack frame */
601 UCONTEXT_REG_SP (sigctx
) = sp
;
603 UCONTEXT_REG_PC (sigctx
) = (gsize
)get_handle_signal_exception_addr ();
604 #ifdef UCONTEXT_REG_CPSR
605 if ((gsize
)UCONTEXT_REG_PC (sigctx
) & 1)
606 /* Transition to thumb */
607 UCONTEXT_REG_CPSR (sigctx
) |= (1 << 5);
609 /* Transition to ARM */
610 UCONTEXT_REG_CPSR (sigctx
) &= ~(1 << 5);
618 mono_sigctx_to_monoctx (ctx
, &mctx
);
620 result
= mono_handle_exception (&mctx
, obj
);
621 /* restore the context so that returning from the signal handler will invoke
624 mono_monoctx_to_sigctx (&mctx
, ctx
);
630 mono_arch_ip_from_context (void *sigctx
)
632 #ifdef MONO_CROSS_COMPILE
633 g_assert_not_reached ();
635 arm_ucontext
*my_uc
= (arm_ucontext
*)sigctx
;
636 return (void*) UCONTEXT_REG_PC (my_uc
);
641 mono_arch_setup_async_callback (MonoContext
*ctx
, void (*async_cb
)(void *fun
), gpointer user_data
)
643 host_mgreg_t sp
= (host_mgreg_t
)MONO_CONTEXT_GET_SP (ctx
);
646 g_assert (!user_data
);
648 /* Allocate a stack frame */
650 MONO_CONTEXT_SET_SP (ctx
, sp
);
652 mono_arch_setup_resume_sighandler_ctx (ctx
, (gpointer
)async_cb
);
656 * mono_arch_setup_resume_sighandler_ctx:
658 * Setup CTX so execution continues at FUNC.
661 mono_arch_setup_resume_sighandler_ctx (MonoContext
*ctx
, gpointer func
)
663 MONO_CONTEXT_SET_IP (ctx
,func
);
664 if ((host_mgreg_t
)MONO_CONTEXT_GET_IP (ctx
) & 1)
665 /* Transition to thumb */
666 ctx
->cpsr
|= (1 << 5);
668 /* Transition to ARM */
669 ctx
->cpsr
&= ~(1 << 5);
673 mono_arch_undo_ip_adjustment (MonoContext
*ctx
)
677 if (mono_arm_thumb_supported ())
682 mono_arch_do_ip_adjustment (MonoContext
*ctx
)
684 /* Clear thumb bit */