October 29, 2008 Re: D calling convention | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright Wrote:
> EAX always gets the last argument evaluated, because evaluating an expression often naturally winds up in EAX.
Ah, right. I didn't think of that.
Do I understand correctly that in order to get the 'context as the first arg' behavior, we'd have to drop either EAX or left-to-right passing? Maybe it's not worth it then.
| |||
October 29, 2008 Re: D calling convention | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Christian Kamm | Christian Kamm wrote:
> Do I understand correctly that in order to get the 'context as the
> first arg' behavior, we'd have to drop either EAX or left-to-right
> passing? Maybe it's not worth it then.
I don't think it's worth it. Passing it in EAX is a big performance win.
| |||
October 29, 2008 Re: D calling convention | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Christian Kamm | "Christian Kamm" <kamm-incasoftware@removethis.de> wrote in message news:ge9044$1l0d$1@digitalmars.com... >> Is it possible to solve this problem and also solve the problem mentioned >> in the thread "implicitly convert function pointers to delegates"? Or are >> these two mutually exclusive? > > The two things are separate. Delegates are functions that have the context > argument bound. This is about the passing order of arguments. > But it matters how delegates pass the context pointer. In order to call functions using a delegate, the functions should silently ignore the context pointer. Which means they should never expect any argument to be passed in that register, or accept an argument on the stack that can be ignore (last one?).. I don't know the details, but I think these two issue are very closely related. L. | |||
October 29, 2008 Re: D calling convention | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Lionello Lunesu | Lionello Lunesu wrote:
>
> "Christian Kamm" <kamm-incasoftware@removethis.de> wrote in message news:ge9044$1l0d$1@digitalmars.com...
>>> Is it possible to solve this problem and also solve the problem mentioned
>>> in the thread "implicitly convert function pointers to delegates"? Or are
>>> these two mutually exclusive?
>>
>> The two things are separate. Delegates are functions that have the context
>> argument bound. This is about the passing order of arguments.
>>
>
> But it matters how delegates pass the context pointer. In order to call functions using a delegate, the functions should silently ignore the context pointer. Which means they should never expect any argument to be passed in that register, or accept an argument on the stack that can be ignore (last one?).. I don't know the details, but I think these two issue are very closely related.
>
> L.
As I see it there are really 3 different scenarios we'd (do we?) like to support:
1) converting a function pointer to a delegate
2) converting a member function pointer to a function pointer
3) converting a delegate to a function pointer
1) seems to be easiest by having the compiler generate a small wrapper that takes care of the differences in number of arguments.
2) would be easy to solve given the stuff mentioned in this thread
3) isn't really hard to solve either, at least in terms of LDC (thus LLVM), you'd just generate a trampoline.
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply