diff: runtime/calls.h fixes
Fergus Henderson
fjh at cs.mu.oz.au
Tue May 27 06:38:55 AEST 1997
runtime/goto.h:
Define NEEDS_ASM_FIXUP_REGS iff ASM_FIXUP_REGS is non-empty
(for use by calls.h).
runtime/calls.h:
Use NEEDS_ASM_FIXUP_REGS and ASM_FIXUP_REGS (defined in goto.h)
to handle register restores on return from procedure calls,
rather than hard-coding it specifically for __alpha__.
This ensures that all the architecture-specific code for
handling non-local gotos is localized in the start of goto.h.
cvs diff: Diffing .
Index: calls.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/calls.h,v
retrieving revision 1.2
diff -u -r1.2 calls.h
--- calls.h 1997/02/12 02:15:07 1.2
+++ calls.h 1997/05/26 16:34:59
@@ -22,8 +22,13 @@
GOTO_LABEL(label); \
} while (0)
-#if defined(__alpha__) && defined(USE_ASM_LABELS)
-#define noprof_call(proc, succ_cont) \
+/*
+** On some systems [basically those using PIC (Position Independent Code)],
+** if we're using gcc non-local gotos to jump between functions then
+** we need to do ASM_FIXUP_REGS after each return from a procedure call.
+*/
+#if defined(USE_GCC_NONLOCAL_GOTOS) && defined(NEED_ASM_FIXUP_REGS)
+ #define noprof_call(proc, succ_cont) \
({ \
__label__ fixup_gp; \
debugcall((proc), (succ_cont)); \
@@ -31,14 +36,11 @@
set_prof_current_proc(proc); \
GOTO(proc); \
fixup_gp: \
- __asm__ __volatile__ ( \
- "ldgp $gp, 0($27)" \
- : : : "memory" \
- ); \
+ ASM_FIXUP_REGS \
GOTO(succ_cont); \
})
/* same as above, but with GOTO_LABEL rather than GOTO */
-#define noprof_call_localret(proc, succ_cont) \
+ #define noprof_call_localret(proc, succ_cont) \
({ \
__label__ fixup_gp; \
debugcall((proc), (succ_cont)); \
@@ -46,21 +48,18 @@
set_prof_current_proc(proc); \
GOTO(proc); \
fixup_gp: \
- __asm__ __volatile__ ( \
- "ldgp $gp, 0($27)" \
- : : : "memory" \
- ); \
+ ASM_FIXUP_REGS \
GOTO_LABEL(succ_cont); \
})
#else
-#define noprof_call(proc, succ_cont) \
+ #define noprof_call(proc, succ_cont) \
do { \
debugcall((proc), (succ_cont)); \
succip = (succ_cont); \
set_prof_current_proc(proc); \
GOTO(proc); \
} while (0)
-#define noprof_call_localret(proc, succ_cont) \
+ #define noprof_call_localret(proc, succ_cont) \
noprof_call((proc), LABEL(succ_cont))
#endif
Index: goto.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/goto.h,v
retrieving revision 1.28
diff -u -r1.28 goto.h
--- goto.h 1997/02/16 12:08:05 1.28
+++ goto.h 1997/05/26 16:31:28
@@ -266,9 +266,11 @@
__asm__ __volatile__( \
INLINE_ASM_FIXUP_REGS \
);
+#define NEED_ASM_FIXUP_REGS
#else
#define ASM_FIXUP_REGS
#define INLINE_ASM_FIXUP_REGS
+#undef NEED_ASM_FIXUP_REGS
#endif
/*
cvs diff: Diffing machdeps
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
More information about the developers
mailing list