[m-dev.] pragma c code joy!

Thomas Charles CONWAY conway at cs.mu.OZ.AU
Thu Jun 25 09:03:00 AEST 1998


Fergus Henderson, you write:
> 
> See the comments in pragma_c_gen.m:
> 
> % (2)   The call to save_registers() is needed so that if the
> %       C code calls Mercury code, we can call restore_registers()
> %       on entry to the Mercury code (see export.m) to get the
> %       right values of `sp', `hp', `curfr' and `maxfr' for the
> %       recursive invocation of Mercury.
> %
> % (3)   The call to restore_registers() is needed in case the
> %       C code calls Mercury code which allocates some data
> %       on the heap, and this data is returned from Mercury
> %       through C back to Mercury.  In that case, we need to
> %       keep the value of `hp' that was set by the recursive
> %       invocation of Mercury.  The Mercury calling convention
> %       guarantees that when calling det or semidet code, the values
> %       of `sp', `curfr', and `maxfr' will be preserved, so if we're
> %       using conservative gc, there is nothing that needs restoring.

Yes, I grokked the information from the comments eventually. :-)

Thomas
-- 
Thomas Conway <conway at cs.mu.oz.au>
Nail here [] for new monitor.  )O+



More information about the developers mailing list