Files
mercury/compiler/notes/gc_and_c_code.html
Bert Thompson dea497b338 Translated plain text docs to HTML. This obviously creates
Estimated hours taken: 4

Translated plain text docs to HTML. This obviously creates
a dual update problem. We should solve this by putting
the plain text docs in the attic and retaining the HTML.

Also added the HTML files to the Mmakefile so they are installed
on the web pages.

The other documents in compiler/notes will be HTMLized soon.

compiler/notes/
	Mmakefiles
	ALLOCATION.html
	AUTHORS.html
	CODING_STANDARDS.html
	COMPILER_DESIGN.html
	GC_AND_C_CODE.html
	GLOSSARY.html
	MODULE_SYSTEM.html
	RELEASE_CHECKLIST.html
	REVIEWS.html
	TODO.html
1997-04-03 05:17:54 +00:00

76 lines
1.6 KiB
HTML

<html>
<head>
<title>
Information On Garbage Collection And C Code
</title>
</head>
<body
bgcolor="#ffffff"
text="#000000"
>
<hr>
<!-------------------------->
When handwritten code is called from Mercury, the garbage collection
scheduler doesn't know anything about the code, so it cannot replace
the succip on the stack (if there is one) with the collector's address.
<p>
If the handwritten code calls no other code, then this is fine, the
scheduler knows it can replace the succip variable and when a
proceed() occurs execution will return to mercury code which it
knows about.
<p>
If handwritten code calls other handwritten code, we have a problem,
as succip will be saved on the stack and we don't know where on
the stack it is stored. So we use a global variable 'saved_succip' which
is succip is saved into. Care must be taken to save saved_succip on the
stack so it doesn't get clobbered. <br>
So
<pre>
detstackvar(1) = (int) succip;
</pre>
becomes
<pre>
detstackvar(1) = (int) saved_succip;
saved_succip = (int) succip;
</pre>
and, when restoring,
<pre>
succip = (int) detstackvar(1);
</pre>
becomes
<pre>
succip = saved_succip;
saved_succip = detstackvar(1);
</pre>
(With appropriate LVALUE_CASTs).
<p>
In this way, garbage collection always knows where the succip is stored
in handwritten code.
<p>
The garbage collection code must check that the current execution is not
still in a handwritten predicate - if it is, it must re-schedule (essentially
just the same as before).
<p>
<hr>
<!-------------------------->
Last update was $Date: 1997-04-03 05:17:37 $ by $Author: aet $@cs.mu.oz.au. <br>
</body>
</html>