System programming in D (Was: The God Language)

Sean Kelly sean at invisibleduck.org
Thu Jan 5 13:53:54 PST 2012


On Jan 5, 2012, at 1:42 PM, Manu wrote:

> Most C compilers also don't allow program optimisation/rescheduling around inline asm blocks, this makes them useless, and I'll bet GDC suffers the same problem right now(…?)

Not sure about GDC.  At one time, I pushed for keeping "volatile" alive so asm blocks could be labeled to tell the compiler not to optimize across them.  I recall Walter rejecting the idea because compilers shouldn't optimize across asm blocks.  This should probably be revisited at some point.


> >   * __restrict - Not a deal breaker, but console game dev industry uses this all the time. There are countless articles on the topic (many are private or on console vendor forums). If this is not standardised in the language, GDC will still expose it I'm sure, fragmenting the language.
> >
> >   * __forceinline - I'd rather have a proper keyword than using tricks like mixins and stuff as have been discussed. The reason for this is debugging. Code is not-inlined in debug builds, looks&feels like normal code, can still evaluate, and step like regular code... and guarantee that it inlines properly when optimised. This just saves time; no frills debugging.
> 
> I'd say these are QOI issues, as above.
> 
> Yup, so just standardise the names for these attributes and pass the info through to GCC's back end... done :) ... Although I'm sure __forceinline isn't so simple.

I'm sure it isn't.  Though as long as compilers aren't required to support it, it's just a matter of making it work, right: ;-)

 
> >   * multiple return values - This is a purely idealistic feature request, but would lead to some really nice optimisations while retaining very tidy code if implemented properly. Other languages support this, it's a nice modern feature... why not have it in D?
> 
> I can see the ABI rules for this getting really complicated, much like how parameter passing rules on x64 are insanely complex compared to x32.  But I agree that it would be a nice feature to have.
> 
> How so? Parameters are passed in a sequence of regs of the appropriate type, to a point, at which stage they get put on the stack... is x64 somehow more complicated than that?
> Multiple return values would use the exact same regs in reverse. There should be no side effects, the calling function has already (or has the caoability to) stored off any save regs in order to pass args in the first place.

No, that's exactly how x64 works.  But compared to x32 where everything is simply pushed onto the stack…  That's all I was saying.


> Fair call, but I don't have time to get involved in that level right now, not by a long shot.
> I'm just a potential customer trying to give it a fair go at this point... ;)

Then please be as specific as you can :-)  Don might have some experience in this area, but I suspect Walter does not.


More information about the Digitalmars-d mailing list