Machine-independent support for garbage collection, debugging, exception handling, and concurrency (draft)Report
For a compiler writer, generating good machine code for a variety of platforms is hard work. One might try to reuse a retargetable code generator from another compiler, but code generators are complex and difficult to use, and they limit one's choice of implementation language. One might try to use C as a portable assembly language, but C limits the compiler writer's flexibility and the performance of the resulting code. The wide use of C, despite these drawbacks, argues for a portable assembly language. <p> <tt>C--</tt> is a new language designed expressly as a portable assembly language. <tt>C--</tt> eliminates some of the performance problems associated with C, but in its originally-proposed form it does not provide adequate support for garbage collection, exception handling, and debugging. The problem is that neither the high-level compiler nor the <tt>C--</tt> compiler has all of the information needed to support these run-time features. This paper proposes a three-part solution: new language constructs for <tt>C--</tt>, run-time support for <tt>C--</tt>, and restrictions on optimization of <tt>C--</tt> programs. <p> The new <tt>C--</tt> language constructs enable a high-level compiler to associate initialized data with <em>spans</em> of <tt>C--</tt> source ranges and to specify ``alternate continuations'' for calls to procedures that might raise exceptions. The run-time support is an interface (specified in C) that the garbage collector, exception mechanism, and debugger can use to get access to both high-level and low-level information, provided that the <tt>C--</tt> program is suspended at a <em>safe point</em>. High- and low-level information is coordinated by means of the <tt>C--</tt> spans and a common numbering for variables. Finally, the <tt>C--</tt> optimizer operates under the constraints that the debugger or garbage collector can change the values of local variables while execution is suspended, and that a procedure call with alternate continuations can return to more than one location. <p> This three-part solution also provides adequate support for concurrency, so the paper illustrates the problem and the proposed solution with examples from garbage collection, exception handling, debugging, and threads. The paper also includes a model of the dataflow behavior of <tt>C--</tt> calls. <p> A number of open problems remain. The most serious have to do with apparent redundancies among spans and safe points, and with the interaction of debugging support with optimization. <p> <em>This paper is very much work in progress</em>. We are not yet satisfied with the solutions we've come up with. Perhaps you can help improve it.
All rights reserved (no additional license for public reuse)
Peyton, Jones, and Norman Ramsey. "Machine-independent support for garbage collection, debugging, exception handling, and concurrency (draft)." University of Virginia Dept. of Computer Science Tech Report (1998).
University of Virginia, Department of Computer Science