Inter-compiler portability of asm between gdc and ldc2 (and dmd)

Stefan Koch uplink.coder at googlemail.com
Wed Jul 15 07:34:08 UTC 2020


On Wednesday, 15 July 2020 at 00:26:13 UTC, Cecil Ward wrote:
>
> Has anyone for example done something using templates or 
> mixin-ful goodness generating code on-the fly?
>
> Alternatively I could just give up and be forced to maintain 
> two parallel implementations of certain modules forever more, 
> provided there is zero runtime overhead, no cost in terms of 
> speed or bloat.

There is a workaround which I used and that involves runtime 
overhead on startup.
You just write the bytes that make up your function into an 
executable page of memory.
Set a function pointer to there, and you are done ;)



More information about the Digitalmars-d mailing list