From -5849950589312935959
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,fb1a92fa405c930c
X-Google-Attributes: gidf78e5,public
From: fjh@cs.mu.OZ.AU (Fergus Henderson)
Subject: Re: nested functions
Date: 1999/06/18
Message-ID: <7kcjai$l9u$1@mulga.cs.mu.OZ.AU>#1/1
X-Deja-AN: 490948322
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <37659D89.565ACF7D@technologist.com> <7k5ncv$n8u$1@nnrp1.deja.com> <376690B6.6231FB13@technologist.com> <376761DB.603FE6F1@physik.tu-muenchen.de> <37681965.87E5D3D0@technologist.com> <7kap79$6te$1@mulga.cs.mu.OZ.AU> <170619991219470383%lisa_lippincott@advisories.com>
X-Original-Date: 18 Jun 1999 04:52:33 GMT
X-Complaints-To: news@news.unimelb.edu.au
X-Trace: izvestia.its.unimelb.edu.au 929682868 24294 128.250.29.17 (18 Jun 1999 05:14:28 GMT)
Organization: Computer Science, The University of Melbourne
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUAN2nVmeEDnX0m9pzZAQFIbgGAjNG0N61YukzOiqgo7bA46qRkfuLT3KkF WD3CBOtvdjQ7xgq8SX5r09CbGa/nQzUZ =tIEE
NNTP-Posting-Date: 18 Jun 1999 05:14:28 GMT
Newsgroups: comp.std.c++

Lisa Lippincott <lisa_lippincott@advisories.com> writes:

>Fergus Henderson <fjh@cs.mu.OZ.AU> wrote:
>
>> It's not necessary to create trampolines "on the fly".  You can
>> allocate a stack of trampolines statically (at link time, for example),
>> and allocate trampolines from this stack as needed.  They can be
>> deallocated when the containing scope is exited.
>> 
>> You don't need to be able to write to code space, because
>> you can keep the data parts and the code parts of the trampoline
>> stack in separate parallel arrays.
>
>I don't see how the number of trampolines needed can be bounded
>at link time.  Consider a recursive function:

The number of trampolines can't be bounded at link time, in general,
but neither can the normal call stack usage.  Many many C implementations
have had a fixed-size stack.  So the situation here is no worse.
In both cases, the implementation can easily provide some method for the
programmer to select what size stack they need.

Of course, for the vast majority of implementations it's possible to
create code at run-time.  The growing importance of JIT compilers and
dynamic linking suggest that this is likely to remain true in the future.
So most implementations won't need to use fixed-size stacks.

In addition, on implementations with appropriate virtual memory support,
you can create an unbounded size trampoline stack without creating any
new code at runtime, by mapping the same code page into multiple places
in the address space.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3        |     -- the last words of T. S. Garp.
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



