Re: Implementing Exception Handling in a VM

Hans-Peter Diettrich <DrDiettrich1@aol.com>
15 Aug 2006 18:52:14 -0400

          From comp.compilers

Related articles
Implementing Exception Handling in a VM first.last@orcon.net.nz (Mark Andrews \(The Other One\)) (2006-08-14)
Re: Implementing Exception Handling in a VM barry.j.kelly@gmail.com (Barry Kelly) (2006-08-15)
Re: Implementing Exception Handling in a VM DrDiettrich1@aol.com (Hans-Peter Diettrich) (2006-08-15)
Re: Implementing Exception Handling in a VM DrDiettrich1@aol.com (Hans-Peter Diettrich) (2006-08-18)
Re: Implementing Exception Handling in a VM first.last@orcon.net.nz (Mark Andrews \(The Other One\)) (2006-08-18)
Re: Implementing Exception Handling in a VM first.last@orcon.net.nz (Mark Andrews \(The Other One\)) (2006-08-18)
Re: Implementing Exception Handling in a VM barry.j.kelly@gmail.com (Barry Kelly) (2006-08-19)
Re: Implementing Exception Handling in a VM DrDiettrich1@aol.com (Hans-Peter Diettrich) (2006-08-19)
| List of all articles for this month |
From: Hans-Peter Diettrich <DrDiettrich1@aol.com>
Newsgroups: comp.compilers
Date: 15 Aug 2006 18:52:14 -0400
Organization: Compilers Central
References: 06-08-076
Keywords: VM
Posted-Date: 15 Aug 2006 18:52:14 EDT

Mark Andrews (The Other One) wrote:


> Some time ago I wrote a simple Pascal-like language that ran on an
> equally simple VM--all implemented in Delphi. I'd like to update the
> language to use exception handling constructs such as try-except-end and
> try-finally-end.
>
> Given that the implementing language (Delphi, in this case) has SEH, can
> I leverage this fact to add exception support in my Pascal-like
> language? If so, where might I learn how to do this?


We discussed SEH both in general and also in Delphi, some time ago, in
c.l.p.d.misc. You'll find interface techniques to the Windows SEH in
System.pas and SysUtils.pas, from which you can build your own routines.
If you want your VM to be more platform independent, have a look at the
equivalent units in FreePascal.


If you don't allow for access to external code, which may rise
exceptions out of your control, you can implement any other exception
handling system in your VM. Then the good ole Basic OnError handling
might be a base to start from. Or you have a look at SEH in .NET.


In most cases your compiler(s) will have to produce appropriate code and
tables for the "H"andling part of SEH, the VM alone can not provide full
support for the asynchronous jumps into or around the except and finally
parts. This is why I mentioned the Basic OnError before, which in VB is
based on tables with the kind and range of the try, except and finally
parts, attached to every subroutine. These tables can be used to unwind
the stack after an exception occured, and to jump to the exception and
finally handlers, under full control of the VM, without further special
instructions or instruction sequences in the code itself. Apart from
this aspect the OnError and SEH models are quite incompatible, a VB
compiler for .NET has to produce very much code and lenghty tables, in
order to make OnError work in a SEH environment.




I'm willing to discuss details of SEH in this group, if John agrees, or
by e-mail, to some extent. The general part may be of wider interest, in
contrast to the Windows implementation details.


DoDi



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.