[m-dev.] diff: runtime/engine.h

Fergus Henderson fjh at cs.mu.oz.au
Tue Jul 29 16:34:13 AEST 1997


Simon Taylor, you wrote:
> +	/* 
> +	** MR_setjmp and MR_longjmp are wrappers around setjmp and longjmp 
> +	** to ensure that
> +	**	 call C -> setjmp -> call Mercury -> call C -> longjmp 
> +	** works correctly. This is used by the exception handling code for
> +	** the ODBC interface.
> +	*/ 
> +
> +	/*
> +	** We don't save hp or r1, r2 etc. because the longjmping
> +	** code may want to return data on the heap or in registers.
> +	*/

I think not saving/restoring r1, r2, ... is potentially dangerous.  
The caller may be assuming that r1, r2, ... are still valid.

Also, you need to call save_registers() and restore_registers(),
not save/restore_transient_registers(), because longjmp() can
clobber all of them, not just the "transient" (register window) ones.

-- 
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