From -1711397944791097535
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,a69618ea97f65037
X-Google-Attributes: gidf78e5,public
From: "Paul D. DeRocco" <pderocco@ix.netcom.com>
Subject: Re: nested functions
Date: 1998/04/28
Message-ID: <354563EA.C5F51A1F@ix.netcom.com>#1/1
X-Deja-AN: 348335284
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
Content-Transfer-Encoding: 7bit
References: <6hac23$8lb$1@news2.isdnet.net> <m3wwck8vtb.fsf@gabi-soft.fr> <353F904F.2EFDC21D@ix.netcom.com> <6hpf3p$9ci$1@toralf.uib.no>
X-Original-Date: Tue, 28 Apr 1998 01:06:50 -0400
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Organization: Vast Right-Wing Conspiracy
X-NETCOM-Date: Tue Apr 28 12:08:27 AM CDT 1998
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUANUV17uEDnX0m9pzZAQHhrAF+MNkkz1VQBFZ1hcjOw4mhKNgOcjY6FPQ6 vJiUXmAKgFt7eYaLqGX5eU/z3gOgi/np =Zxhl
Newsgroups: comp.std.c++


Igor Boukanov wrote:
> 
> GCC uses on fly code generation to make possible free mixture of
> pointers
> to non-nested and nested functions that result in no overhead for
> ordinary
> pointers. Basically it constructs a code that that would restore
> necessary
> context and then call the nested function itself.

In other words, GCC generates a thunk at runtime that passes the context
into the function, perhaps by loading it into a register? This is what
Win16 used to do for callbacks, although it was loading the DS register
with the instance's data segment. The problem is, where do you put these
thunks? The obvious place is on the stack, like any other temporary, but
many architectures don't let you execute code out of pages that are used
for data. This means the compiler has to allocate the thunk somewhere
else, and include the necessary exception handling code to guarantee
that the thunk is deallocated when the stack is unwound. Certainly
doable, but slightly messy. It's probably worth it, though.

-- 

Ciao,
Paul
---
[ 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              ]



