summaryrefslogtreecommitdiff
path: root/asmrun
diff options
context:
space:
mode:
Diffstat (limited to 'asmrun')
-rw-r--r--asmrun/.depend6
-rw-r--r--asmrun/arm.S11
-rw-r--r--asmrun/backtrace.c2
-rw-r--r--asmrun/i386.S14
-rw-r--r--asmrun/roots.c8
-rw-r--r--asmrun/signals_asm.c2
-rw-r--r--asmrun/signals_osdep.h134
7 files changed, 71 insertions, 106 deletions
diff --git a/asmrun/.depend b/asmrun/.depend
index b9e29856f6..2e7c20d1c4 100644
--- a/asmrun/.depend
+++ b/asmrun/.depend
@@ -138,7 +138,7 @@ minor_gc.o: minor_gc.c ../byterun/config.h ../byterun/fail.h \
../byterun/minor_gc.h ../byterun/gc.h ../byterun/gc_ctrl.h \
../byterun/major_gc.h ../byterun/memory.h ../byterun/minor_gc.h \
../byterun/misc.h ../byterun/mlvalues.h ../byterun/roots.h \
- ../byterun/signals.h
+ ../byterun/signals.h ../byterun/weak.h
misc.o: misc.c ../byterun/config.h ../byterun/misc.h ../byterun/config.h \
../byterun/memory.h ../byterun/gc.h ../byterun/mlvalues.h \
../byterun/misc.h ../byterun/major_gc.h ../byterun/freelist.h \
@@ -340,7 +340,7 @@ minor_gc.d.o: minor_gc.c ../byterun/config.h ../byterun/fail.h \
../byterun/minor_gc.h ../byterun/gc.h ../byterun/gc_ctrl.h \
../byterun/major_gc.h ../byterun/memory.h ../byterun/minor_gc.h \
../byterun/misc.h ../byterun/mlvalues.h ../byterun/roots.h \
- ../byterun/signals.h
+ ../byterun/signals.h ../byterun/weak.h
misc.d.o: misc.c ../byterun/config.h ../byterun/misc.h ../byterun/config.h \
../byterun/memory.h ../byterun/gc.h ../byterun/mlvalues.h \
../byterun/misc.h ../byterun/major_gc.h ../byterun/freelist.h \
@@ -542,7 +542,7 @@ minor_gc.p.o: minor_gc.c ../byterun/config.h ../byterun/fail.h \
../byterun/minor_gc.h ../byterun/gc.h ../byterun/gc_ctrl.h \
../byterun/major_gc.h ../byterun/memory.h ../byterun/minor_gc.h \
../byterun/misc.h ../byterun/mlvalues.h ../byterun/roots.h \
- ../byterun/signals.h
+ ../byterun/signals.h ../byterun/weak.h
misc.p.o: misc.c ../byterun/config.h ../byterun/misc.h ../byterun/config.h \
../byterun/memory.h ../byterun/gc.h ../byterun/mlvalues.h \
../byterun/misc.h ../byterun/major_gc.h ../byterun/freelist.h \
diff --git a/asmrun/arm.S b/asmrun/arm.S
index c32b4b6674..98fdfcfe32 100644
--- a/asmrun/arm.S
+++ b/asmrun/arm.S
@@ -91,11 +91,13 @@ caml_allocN:
/* Record return address and desired size */
ldr alloc_limit, .Lcaml_last_return_address
str lr, [alloc_limit, #0]
- str r10, .Lcaml_requested_size
+ ldr alloc_limit, .LLcaml_requested_size
+ str r10, [alloc_limit, #0]
/* Invoke GC */
bl .Linvoke_gc
/* Try again */
- ldr r10, .Lcaml_requested_size
+ ldr r10, .LLcaml_requested_size
+ ldr r10, [r10, #0]
b caml_allocN
/* Shared code to invoke the GC */
@@ -323,9 +325,12 @@ caml_ml_array_bound_error:
.LLtrap_handler: .word .Ltrap_handler
.Lcaml_apply2: .word caml_apply2
.Lcaml_apply3: .word caml_apply3
-.Lcaml_requested_size: .word 0
+.LLcaml_requested_size: .word .Lcaml_requested_size
.Lcaml_array_bound_error: .word caml_array_bound_error
+.data
+.Lcaml_requested_size: .word 0
+
/* GC roots for callback */
.data
diff --git a/asmrun/backtrace.c b/asmrun/backtrace.c
index 50af17bb73..0d918b142e 100644
--- a/asmrun/backtrace.c
+++ b/asmrun/backtrace.c
@@ -59,8 +59,8 @@ void caml_stash_backtrace(value exn, uintnat pc, char * sp, char * trapsp)
h = Hash_retaddr(pc);
while(1) {
d = caml_frame_descriptors[h];
+ if (d == 0) return; /* can happen if some code not compiled with -g */
if (d->retaddr == pc) break;
- if (d->retaddr == 0) return; /* should not happen */
h = (h+1) & caml_frame_descriptors_mask;
}
/* Skip to next frame */
diff --git a/asmrun/i386.S b/asmrun/i386.S
index 9d45f6e974..ce05744a79 100644
--- a/asmrun/i386.S
+++ b/asmrun/i386.S
@@ -384,9 +384,17 @@ G(caml_ml_array_bound_error):
ffree %st(5)
ffree %st(6)
ffree %st(7)
- /* Branch to [caml_array_bound_error] */
- movl $ G(caml_array_bound_error), %eax
- jmp G(caml_c_call)
+ /* Record lowest stack address and return address */
+ movl (%esp), %edx
+ movl %edx, G(caml_last_return_address)
+ leal 4(%esp), %edx
+ movl %edx, G(caml_bottom_of_stack)
+ /* For MacOS X: re-align the stack */
+#ifdef SYS_macosx
+ andl $-16, %esp
+#endif
+ /* Branch to [caml_array_bound_error] (never returns) */
+ call G(caml_array_bound_error)
.data
.globl G(caml_system__frametable)
diff --git a/asmrun/roots.c b/asmrun/roots.c
index f5ff1591e8..c1d3db003a 100644
--- a/asmrun/roots.c
+++ b/asmrun/roots.c
@@ -100,7 +100,11 @@ void caml_oldify_local_roots (void)
frame_descr * d;
uintnat h;
int i, j, n, ofs;
+#ifdef Stack_grows_upwards
+ short * p; /* PR#4339: stack offsets are negative in this case */
+#else
unsigned short * p;
+#endif
value glob;
value * root;
struct global_root * gr;
@@ -229,7 +233,11 @@ void caml_do_local_roots(scanning_action f, char * bottom_of_stack,
frame_descr * d;
uintnat h;
int i, j, n, ofs;
+#ifdef Stack_grows_upwards
+ short * p; /* PR#4339: stack offsets are negative in this case */
+#else
unsigned short * p;
+#endif
value * root;
struct caml__roots_block *lr;
diff --git a/asmrun/signals_asm.c b/asmrun/signals_asm.c
index f333540513..b55561265f 100644
--- a/asmrun/signals_asm.c
+++ b/asmrun/signals_asm.c
@@ -238,7 +238,7 @@ void caml_init_signals(void)
/* Stack overflow handling */
#ifdef HAS_STACK_OVERFLOW_DETECTION
{
- struct sigaltstack stk;
+ stack_t stk;
struct sigaction act;
stk.ss_sp = sig_alt_stack;
stk.ss_size = SIGSTKSZ;
diff --git a/asmrun/signals_osdep.h b/asmrun/signals_osdep.h
index f34863b39b..ceefc7161f 100644
--- a/asmrun/signals_osdep.h
+++ b/asmrun/signals_osdep.h
@@ -87,9 +87,16 @@
sigact.sa_flags = SA_SIGINFO
#include <sys/ucontext.h>
+ #include <AvailabilityMacros.h>
- #define CONTEXT_STATE (((struct ucontext *)context)->uc_mcontext->ss)
- #define CONTEXT_PC (CONTEXT_STATE.eip)
+#if !defined(MAC_OS_X_VERSION_10_5) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
+ #define CONTEXT_REG(r) r
+ #else
+ #define CONTEXT_REG(r) __##r
+ #endif
+
+ #define CONTEXT_STATE (((ucontext_t *)context)->uc_mcontext->CONTEXT_REG(ss))
+ #define CONTEXT_PC (CONTEXT_STATE.CONTEXT_REG(eip))
#define CONTEXT_FAULTING_ADDRESS ((char *) info->si_addr)
/****************** MIPS, all OS */
@@ -113,106 +120,43 @@
#elif defined(TARGET_power) && defined(SYS_rhapsody)
-#ifdef __ppc64__
-
#define DECLARE_SIGNAL_HANDLER(name) \
static void name(int sig, siginfo_t * info, void * context)
- #define SET_SIGACT(sigact,name) \
- sigact.sa_sigaction = (name); \
- sigact.sa_flags = SA_SIGINFO | SA_64REGSET
-
- typedef unsigned long long context_reg;
-
#include <sys/ucontext.h>
-
- #define CONTEXT_STATE (((struct ucontext64 *)context)->uc_mcontext64->ss)
-
- #define CONTEXT_PC (CONTEXT_STATE.srr0)
- #define CONTEXT_EXCEPTION_POINTER (CONTEXT_STATE.r29)
- #define CONTEXT_YOUNG_LIMIT (CONTEXT_STATE.r30)
- #define CONTEXT_YOUNG_PTR (CONTEXT_STATE.r31)
- #define CONTEXT_FAULTING_ADDRESS ((char *) info->si_addr)
- #define CONTEXT_SP (CONTEXT_STATE.r1)
-
-#else
-
- #include <sys/utsname.h>
-
- #define DECLARE_SIGNAL_HANDLER(name) \
- static void name(int sig, siginfo_t * info, void * context)
-
- #define SET_SIGACT(sigact,name) \
- sigact.sa_handler = (void (*)(int)) (name); \
- sigact.sa_flags = SA_SIGINFO
-
- typedef unsigned long context_reg;
-
- #define CONTEXT_PC (*context_gpr_p(context, -2))
- #define CONTEXT_EXCEPTION_POINTER (*context_gpr_p(context, 29))
- #define CONTEXT_YOUNG_LIMIT (*context_gpr_p(context, 30))
- #define CONTEXT_YOUNG_PTR (*context_gpr_p(context, 31))
- #define CONTEXT_FAULTING_ADDRESS ((char *) info->si_addr)
- #define CONTEXT_SP (*context_gpr_p(context, 1))
-
- static int ctx_version = 0;
- static void init_ctx (void)
- {
- struct utsname name;
- if (uname (&name) == 0){
- if (name.release[1] == '.' && name.release[0] <= '5'){
- ctx_version = 1;
- }else{
- ctx_version = 2;
- }
- }else{
- caml_fatal_error ("cannot determine SIGCONTEXT format");
- }
- }
-
- #ifdef DARWIN_VERSION_6
- #include <sys/ucontext.h>
- static unsigned long *context_gpr_p (void *ctx, int regno)
- {
- unsigned long *regs;
- if (ctx_version == 0) init_ctx ();
- if (ctx_version == 1){
- /* old-style context (10.0 and 10.1) */
- regs = (unsigned long *)(((struct sigcontext *)ctx)->sc_regs);
- }else{
- Assert (ctx_version == 2);
- /* new-style context (10.2) */
- regs = (unsigned long *)&(((struct ucontext *)ctx)->uc_mcontext->ss);
- }
- return &(regs[2 + regno]);
- }
+ #include <AvailabilityMacros.h>
+
+ #ifdef __LP64__
+ #define SET_SIGACT(sigact,name) \
+ sigact.sa_sigaction = (name); \
+ sigact.sa_flags = SA_SIGINFO | SA_64REGSET
+
+ typedef unsigned long long context_reg;
+
+ #define CONTEXT_MCONTEXT (((ucontext64_t *)context)->uc_mcontext64)
#else
- #define SA_SIGINFO 0x0040
- struct ucontext {
- int uc_onstack;
- sigset_t uc_sigmask;
- struct sigaltstack uc_stack;
- struct ucontext *uc_link;
- size_t uc_mcsize;
- unsigned long *uc_mcontext;
- };
- static unsigned long *context_gpr_p (void *ctx, int regno)
- {
- unsigned long *regs;
- if (ctx_version == 0) init_ctx ();
- if (ctx_version == 1){
- /* old-style context (10.0 and 10.1) */
- regs = (unsigned long *)(((struct sigcontext *)ctx)->sc_regs);
- }else{
- Assert (ctx_version == 2);
- /* new-style context (10.2) */
- regs = (unsigned long *)((struct ucontext *)ctx)->uc_mcontext + 8;
- }
- return &(regs[2 + regno]);
- }
+ #define SET_SIGACT(sigact,name) \
+ sigact.sa_sigaction = (name); \
+ sigact.sa_flags = SA_SIGINFO
+
+ typedef unsigned long context_reg;
+
+ #define CONTEXT_MCONTEXT (((ucontext_t *)context)->uc_mcontext)
+ #endif
+
+#if !defined(MAC_OS_X_VERSION_10_5) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
+ #define CONTEXT_REG(r) r
+ #else
+ #define CONTEXT_REG(r) __##r
#endif
-#endif
+ #define CONTEXT_STATE (CONTEXT_MCONTEXT->CONTEXT_REG(ss))
+ #define CONTEXT_PC (CONTEXT_STATE.CONTEXT_REG(srr0))
+ #define CONTEXT_EXCEPTION_POINTER (CONTEXT_STATE.CONTEXT_REG(r29))
+ #define CONTEXT_YOUNG_LIMIT (CONTEXT_STATE.CONTEXT_REG(r30))
+ #define CONTEXT_YOUNG_PTR (CONTEXT_STATE.CONTEXT_REG(r31))
+ #define CONTEXT_SP (CONTEXT_STATE.CONTEXT_REG(r1))
+ #define CONTEXT_FAULTING_ADDRESS ((char *) info->si_addr)
/****************** PowerPC, ELF (Linux) */