One minute to twelve: last chance to fix D2 ABI?

Robert Jacques sandford at jhu.edu
Wed Mar 3 08:08:19 PST 2010


On Wed, 03 Mar 2010 10:34:48 -0500, Steve Teale  
<steve.teale at britseyeview.com> wrote:

> On Wed, 03 Mar 2010 01:38:58 -0500, Robert Jacques wrote:
>
>> On Wed, 03 Mar 2010 01:00:46 -0500, Steve Teale
>> <steve.teale at britseyeview.com> wrote:
>>>
>>>> * Binding a delegate to a function pointer will always need a
>>>> (dynamic) thunk, because the function will have been invoked without
>>>> any context pointer and it's the thunk's responsibility to assign the
>>>> correct context pointer.
>>>
>>> At present, D's way of handling delegates requires patching GCC for the
>>> GDC implementation. If an ABI change was made it would be nice if it
>>> fitted into the GCC trampoline model.
>>>
>>> Steve
>>
>> Um, how exactly? I just read the wikipedia page on GCC trampoline and it
>> a) targeted only at nested functions b) utilizes self-modifying code
>> which is disabled on any sensible platform c) would require dynamic
>> allocation and d) actually uses more memory than D's method. Some time
>> ago there was a link to an excellent article (by Walter? Don?) on
>> different ways to do this. I remember d's way coming out the best, but
>> I've seemed to have lost the link.
>
> I'm just quoting from something I noticed a couple of days ago. In David
> Friedman's make file for GDC there is:
>
> # Enables correct implementation of delegates. This requires patching  
> GCC.
> D_EXTRA_DEFINES += -DD_NO_TRAMPOLINES=1
>
> Steve

I think that's because GCC's internal nested function AST construct would  
normally use trampolines, but D defines them as delegates (IIRC). As this  
hack is around GCC's AST handling and not D's ABI, it would be required  
regardless. BTW nested function support is a language extension specific  
to GCC.



More information about the Digitalmars-d mailing list