Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.compilers > #1980
| From | Kaz Kylheku <217-679-0842@kylheku.com> |
|---|---|
| Newsgroups | comp.compilers |
| Subject | Re: Add nested-function support in a language the based on a stack-machine |
| Date | 2018-03-06 18:17 +0000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <18-03-028@comp.compilers> (permalink) |
| References | <18-02-009@comp.compilers> <18-03-002@comp.compilers> <18-03-012@comp.compilers> <18-03-020@comp.compilers> <18-03-024@comp.compilers> |
On 2018-03-06, John Levine <johnl@taugh.com> wrote: >>>>>This is because displays were found to be more costly for Algol-like >>>>>languages ... >>> >>>>> IIRC the additional cost is in updating the display on calls >>>>>and returns. > > I get the impression that displays describe two different things. > > One is a static array that has one entry for each level of lexical > scoping. In a routine declared N levels (zero based) down, its prolog > saves the Nth entry in the display and replaces it with a pointer to > the current stack frame, and the epilog restores it. It can assume > that higher level routines have correctly set entries 0:N-1. That > seems pretty efficient. Assuming the saved pointer is at a known > location in each stack frame you can do a longjmp and unwind stacks > without too much pain. > > The other is the same array, but with a copy of the current display in > each routine's stack frame. This is slower at call time but probably > faster to use on machines like S/360 without direct addressing > since the display on the stack is addressable from the frame pointer, > but static data needs to load a pointer from a constant pool. A > longjmp doesn't need anything special since stacked displays go away > when the stack frames go away. This is precisely what I happen to be working on at the moment: a virtual machine for a Lisp dialect in which I plan to have displays copied into the local stack frame. I expect it to be a performance advantage that there is nothing special to do when the stack frame goes away. If we had to take some unconditional action, we would have to set up a catch frame. That means doing a setjmp-like operation that saves a whole vector of stuff similar to a jmp_buf. Not just machine registers, but the signal mask (or a virtualized representation of it, for efficiency), and other stuff. This vector is larger than a display display containing a significant number of environment levels! If the scope binds dynamically scoped variables, those have to be undone. However, that requires no special action. The dynamic environment is a chain rooted at a global pointer called dyn_env. Long ago, I made the simplifying design decision to include this dyn_env pointer in the jmp_buf-like context that is saved at every catch frame, and so there is no need for a scope to set up a handler for the sake of restoring dynamically scoped bindings. The normal return case has to restore dyn_env, which is simple.
Back to comp.compilers | Previous | Next — Previous in thread | Next in thread | Find similar
Add nested-function support in a language the based on a stack-machine dror.openu@gmail.com - 2018-02-12 11:25 -0800
Re: Add nested-function support in a language the based on a stack-machine dror.openu@gmail.com - 2018-02-12 14:16 -0800
Re: Add nested-function support in a language the based on a stack-machine Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2018-02-13 12:10 +0100
Re: Add nested-function support in a language the based on a stack-machine Louis Krupp <lkrupp@nospam.pssw.com.invalid> - 2018-02-13 00:42 -0700
Re: Add nested-function support in a language the based on a stack-machine Kaz Kylheku <217-679-0842@kylheku.com> - 2018-02-14 00:59 +0000
Re: Add nested-function support in a language the based on a stack-machine George Neuner <gneuner2@comcast.net> - 2018-02-13 22:04 -0500
Re: Add nested-function support in a language the based on a stack-machine Kaz Kylheku <217-679-0842@kylheku.com> - 2018-02-14 18:06 +0000
Re: Add nested-function support in a language the based on a stack-machine George Neuner <gneuner2@comcast.net> - 2018-02-15 11:41 -0500
Re: Add nested-function support in a language the based on a stack-machine Kaz Kylheku <217-679-0842@kylheku.com> - 2018-02-17 16:13 +0000
Re: Add nested-function support in a language the based on a stack-machine anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2018-02-17 16:39 +0000
Re: Add nested-function support in a language the based on a stack-machine George Neuner <gneuner2@comcast.net> - 2018-03-01 13:48 -0500
Re: Add nested-function support in a language the based on a stack-machine Kaz Kylheku <217-679-0842@kylheku.com> - 2018-03-01 19:26 +0000
Re: Add nested-function support in a language the based on a stack-machine Kaz Kylheku <217-679-0842@kylheku.com> - 2018-03-02 00:38 +0000
Re: Add nested-function support in a language the based on a stack-machine George Neuner <gneuner2@comcast.net> - 2018-03-02 02:48 -0500
Re: Add nested-function support in a language the based on a stack-machine rpw3@rpw3.org (Rob Warnock) - 2018-03-03 16:00 +0000
Re: Add nested-function support in a language the based on a stack-machine anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2018-03-02 09:30 +0000
Re: Add nested-function support in a language the based on a stack-machine anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2018-03-05 15:01 +0000
Re: Add nested-function support in a language the based on a stack-machine George Neuner <gneuner2@comcast.net> - 2018-03-05 15:51 -0500
Re: Add nested-function support in a language the based on a stack-machine George Neuner <gneuner2@comcast.net> - 2018-03-05 14:39 -0500
Re: Add nested-function support in a language the based on a stack-machine John Levine <johnl@taugh.com> - 2018-03-06 04:31 +0000
Re: Add nested-function support in a language the based on a stack-machine Kaz Kylheku <217-679-0842@kylheku.com> - 2018-03-06 18:17 +0000
Re: Add nested-function support in a language the based on a stack-machine Kaz Kylheku <157-073-9834@kylheku.com> - 2018-03-11 03:19 +0000
Re: Add nested-function support in a language the based on a stack-machine Tomasz Kowaltowski <tk@ic.unicamp.br> - 2018-03-06 12:10 -0300
Re: Add nested-function support in a language the based on a stack-machine bartc <bc@freeuk.com> - 2018-03-06 19:02 +0000
Re: Add nested-function support in a language the based on a stack-machine antispam@math.uni.wroc.pl - 2018-04-29 16:29 +0000
Re: Add nested-function support in a language the based on a stack-machine George Neuner <gneuner2@comcast.net> - 2018-03-01 13:49 -0500
Re: Add nested-function support in a language the based on a stack-machine George Neuner <gneuner2@comcast.net> - 2018-02-13 22:37 -0500
Re: Add nested-function support in a language the based on a stack-machine George Neuner <gneuner2@comcast.net> - 2018-02-13 23:27 -0500
Re: Add nested-function support in a language the based on a stack-machine Shoefoot <shoefoot@gmail.com> - 2018-02-14 12:27 -0800
csiph-web