Re: Implementing Exception Handling in a VM

"Mark Andrews \(The Other One\)" <first.last@orcon.net.nz>
18 Aug 2006 01:14:31 -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: "Mark Andrews \(The Other One\)" <first.last@orcon.net.nz>
Newsgroups: comp.compilers
Date: 18 Aug 2006 01:14:31 -0400
Organization: Compilers Central
References: 06-08-076 06-08-088
Keywords: VM
Posted-Date: 18 Aug 2006 01:14:31 EDT

Barry Kelly wrote:
> I'm presuming your VM is of the very simple, "while not Terminated do /
> case op of / opAdd: ... end" etc.


Correct.


> That depends on whether or not you've implemented procedure calls in
> your VM as Delphi procedure calls or as an explicit call stack.


I have an explicit call stack.


> To get an interpreter working using Delphi itself for exceptions, it
> would probably be easiest to recurse into the interpreter for the
> 'try..finally' and 'try..except' protected parts of your language.


This sounds interesting. I hadn't even thought of doing it this way.


> Doing it manually in the interpreter loop: the way you do it depends on
> what you want, but it basically involves walking up the call stack. [...]


Given the way the VM is currently written this may be the way to go.


> This means that your call stack needs to have a stack of exception
> information (i.e. handlers) associated with it somehow. You could put
> the exception info inside the call stack, in whatever structure you use
> for activation records (i.e. stack frames). Your 'try' statements need
> to compile into an instruction(s) which push handler info onto this
> stack, and you need to pop off that info for both the normal,
> no-exception route and the unwinding code.


Great--I understand what you're saying. The proof will be me coding it :-)


Thanks for taking the time to answer so fully, I really appreciate it.
I've managed to find plenty of literature on lexers, parsers, codegen,
and VMs, but very little on exception handling. Thanks again.


Cheers,
Mark.


Post a followup to this message

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