Debugging compile time memory usage
Stefan Koch
uplink.coder at googlemail.com
Sun Jun 24 15:47:00 UTC 2018
On Sunday, 24 June 2018 at 14:16:26 UTC, Kamil Koczurek wrote:
> I recently wrote a brainfuck compiler in D, which loads the BF
> source at compile time, performs some (simple) optimizations,
> translates everything to D and puts it into the source code
> with a mixin.
>
> I did manage to get some pretty good performance, but for some
> programs in brainfuck I have to use LDC instead of DMD because
> the latter runs out of memory. Is there a way for me to
> optimize my code in such a way that DMD will be able to compile
> it?
>
> D code: https://pastebin.com/fg1bqwnd
> BF program that works:
> https://github.com/erikdubbelboer/brainfuck-jit/blob/master/mandelbrot.bf
> BF program that makes DMD crash:
> https://github.com/fabianishere/brainfuck/blob/master/examples/hanoi.bf
>
> After putting BF code in code.bf and D in main.d, I compile it
> with the following command: dmd main.d -J./
>
> Error msg: unable to fork: Cannot allocate memory
> DMD version: DMD64 D Compiler v2.080.0-dirty
Check out https://github.com/UplinkCoder/bf-ctfe.
It uses all tricks which I know to use the least amount of memory.
(Which admittedly still is a lot)
Other then that. you'll have to wait for newCTFE to be stable
enough for me to give green light for merging.
More information about the Digitalmars-d-learn
mailing list