February 12, 2022
On Saturday, 12 February 2022 at 06:29:37 UTC, rempas wrote:
>
> I haven't wrote almost anything ...
> ...

umm..reasoning that involves negation is extremely difficult.

Walter will not be happy.



February 11, 2022
On 2/11/2022 8:40 AM, Dennis wrote:
> In fact, only recently was the ability to output asm added for debugging purposes:
> https://dlang.org/blog/2022/01/24/the-binary-language-of-moisture-vaporators/

I use that dumb feature most every day. It's the most productivity enhancing feature I've added in a long time.

For example, I formerly wrote:

    import core.stdio;
    int main() {
       printf("%d\n", expression);
       return 0;
    }

    dmd test
    ./test

every time I wanted to see what `expression` evaluated to. Now I just do:

   int test() { return expression; }

   dmd -c test -vasm

Shazzam! Mucho less typitty-tippity-tip-typing!
February 11, 2022
On 2/11/2022 6:52 AM, max haughton wrote:
> The object emission code in the backend is quite inefficient,

It's faster than any other compiler.

> it needs to be rewritten (it's horrible old code anyway)

I suppose that depends on what you're used to. The basic design is pretty simple - there's a code gen function for each expression node type. The optimizer uses standard data flow analysis math. There's a separate pass for register allocation, and one for scheduling.

The design was originally written for the 8086. It survived extension to 32 bits, then 64 bits, then SIMD.

The complexity comes from the complexity of the x86 instruction set and the choice of instructions is very dependent on the shape of the expression trees.

The only thing it has really failed at is the x87, which everyone wants to leave behind anyway.

February 11, 2022
On 2/10/2022 10:36 PM, max haughton wrote:
> The dmd backend gets a 6/10 for me when it comes to performance. The algorithms are very simple, it should really be faster than it is. The parts that actually emit the object code are particularly slow.

Much of that comes from supporting 4 very different object file formats.
February 12, 2022
On Saturday, 12 February 2022 at 07:06:21 UTC, forkit wrote:
>
> umm..reasoning that involves negation is extremely difficult.

Of course I was saying that to justify my idea about software been bloated which there will be something that does 80% of it with just 10% of the code-base. Also I'm just gonna try my first (and hopefully last) book about Compiler Design and if it succeeds and I'm able to make a fully compiler (including a linker) then I may even offer to make a backend for D in case someone wants to work in the backend. Or maybe Walter and the other folks will want to adopt it and make it the official backend of DMD. In any case, I would be glad to offer my help if that means improving D!

>
> Walter will not be happy.

Given the fact that Walter has to actually do real work and at the same time he's here answering every single crap that we are asking (I post the most crap, not gonna lie), makes me really impressed on his ability to stay calm. Makes me appreciate him more!
February 12, 2022
On Saturday, 12 February 2022 at 07:08:17 UTC, Walter Bright wrote:
>
> I use that dumb feature most every day. It's the most productivity enhancing feature I've added in a long time.
>
> For example, I formerly wrote:
>
>     import core.stdio;
>     int main() {
>        printf("%d\n", expression);
>        return 0;
>     }
>
>     dmd test
>     ./test
>
> every time I wanted to see what `expression` evaluated to. Now I just do:
>
>    int test() { return expression; }
>
>    dmd -c test -vasm
>
> Shazzam! Mucho less typitty-tippity-tip-typing!

THANK YOU!!! Every compiler needs that even if they can output binary formats directly (TCC I'm talking to you!) because it is easier to see the assembly rather than imagine the instructions in your head as humans are know to make mistakes. Thank you for adding this Walter!
February 12, 2022
On Saturday, 12 February 2022 at 07:13:15 UTC, Walter Bright wrote:
> On 2/11/2022 6:52 AM, max haughton wrote:
>> The object emission code in the backend is quite inefficient,
>
> It's faster than any other compiler.
>

It sure is!

That's the primary reason I became interested in D - the speed of compilation, using dmd.

When I use C#, I still prefer VS2010, because it has super fast compilation speed, compared to all later versions of VS (including VS2022) - at least in my experience.

I don't care how great a programming language is, slow compilation is a real turn off!

Hooray for dmd!!
February 12, 2022
On Saturday, 12 February 2022 at 07:13:15 UTC, Walter Bright wrote:
>
> The complexity comes from the complexity of the x86 instruction set and the choice of instructions is very dependent on the shape of the expression trees.

You could email the creator of Vox and ask him about the general structure of Vox and about tricks with X86_X64 specif stuff as this is what Vox targets so he may be specialized in this ISA and know stuff that you don't (which may also improve the runtime performance of programs compiled with DMD). Of course in case you didn't checked, the source of Vox is written in D and it is 36K LoC (at least that's what the README.md says) so you could also have a look (I did and it even looks readable to a n00b like me).

If I knew assembly and machine language (and in general about compiler design), I would do it myself to save you some time and then directly email you but unfortunately I'm not able to do that now.

But tbh, DMD is very fast as it is now given the fact that it does optimizations (Vox and TCC doesn't do any if I'm not mistaken). And my post was to make discussion and see what others think about this topic and not to say that DMD is slow cause that would be a lie ;)

> The only thing it has really failed at is the x87, which everyone wants to leave behind anyway.

Why, what was bad about it? Can I get a little of background on this one?

February 12, 2022
On Saturday, 12 February 2022 at 07:51:38 UTC, forkit wrote:
>
> I don't care how great a programming language is, slow compilation is a real turn off!
>
> Hooray for dmd!!

Thank you! That's the reason I don't use Rust at all and for anything (even if it is so popular and has so much support). That's also the reason I am OBSESSED with TCC and was inspired to learn about compilers and make my own.

Funny enough there are people that don't care about compilation speed and are willing to have their project compile even twice as fast for 5% runtime performance. The same people of course don't have any problem using Python in other cases...
February 12, 2022
On Friday, 11 February 2022 at 20:19:16 UTC, rempas wrote:
> On Friday, 11 February 2022 at 18:02:21 UTC, max haughton wrote:
>> On Friday, 11 February 2022 at 17:44:45 UTC, Stanislav Blinov wrote:
>>> On Friday, 11 February 2022 at 17:36:37 UTC, H. S. Teoh wrote:
>>>
>>>> I pulled just this week, and running `wc` on *.d *.c *.h says...
>>>
>>> https://github.com/AlDanial/cloc would yield a more practical metric, at least as far as "practical metric" in terms of LoC goes.
>>
>> ```
>> ---------------------------------------------------------------------------------------
>> Language                             files          blank        comment           code
>> ---------------------------------------------------------------------------------------
>> D                                     3867          75824          88426         431299
>> HTML                                   114          11405            967          61083
>> C/C++ Header                            57           2729            992          23332
>> C                                       93            830            797           3346
>> C++                                     19            532            139           2249
>> ```
>> this includes the test suite and other stuff that isn't technically the compiler-proper.
>
> Interesting! We could remove the "test-suit" directory and we could tell it to only parse "D" language files which will give us more "clean" results.

This is the number I gave yesterday. D-Scanner counts sloc more cleverly than the other tools mentionned. The report in detail:

dmd/src/build.d:	740
dmd/src/dmd/access.d:	181
dmd/src/dmd/aggregate.d:	362
dmd/src/dmd/aliasthis.d:	93
dmd/src/dmd/apply.d:	58
dmd/src/dmd/argtypes_aarch64.d:	96
dmd/src/dmd/argtypes_sysv_x64.d:	199
dmd/src/dmd/argtypes_x86.d:	190
dmd/src/dmd/arrayop.d:	176
dmd/src/dmd/arraytypes.d:	43
dmd/src/dmd/astbase.d:	2640
dmd/src/dmd/astcodegen.d:	83
dmd/src/dmd/astenums.d:	55
dmd/src/dmd/ast_node.d:	4
dmd/src/dmd/asttypename.d:	73
dmd/src/dmd/attrib.d:	484
dmd/src/dmd/backend/aarray.d:	244
dmd/src/dmd/backend/backconfig.d:	335
dmd/src/dmd/backend/backend.d:	7
dmd/src/dmd/backend/barray.d:	72
dmd/src/dmd/backend/bcomplex.d:	127
dmd/src/dmd/backend/blockopt.d:	1367
dmd/src/dmd/backend/cc.d:	534
dmd/src/dmd/backend/cdef.d:	223
dmd/src/dmd/backend/cg87.d:	2521
dmd/src/dmd/backend/cgcod.d:	1743
dmd/src/dmd/backend/cgcs.d:	445
dmd/src/dmd/backend/cgcse.d:	78
dmd/src/dmd/backend/cgcv.d:	58
dmd/src/dmd/backend/cg.d:	162
dmd/src/dmd/backend/cgelem.d:	3342
dmd/src/dmd/backend/cgen.d:	232
dmd/src/dmd/backend/cgobj.d:	1827
dmd/src/dmd/backend/cgreg.d:	539
dmd/src/dmd/backend/cgsched.d:	1595
dmd/src/dmd/backend/cgxmm.d:	1352
dmd/src/dmd/backend/cod1.d:	3447
dmd/src/dmd/backend/cod2.d:	3650
dmd/src/dmd/backend/cod3.d:	4719
dmd/src/dmd/backend/cod4.d:	3039
dmd/src/dmd/backend/cod5.d:	102
dmd/src/dmd/backend/codebuilder.d:	167
dmd/src/dmd/backend/code.d:	434
dmd/src/dmd/backend/code_x86.d:	114
dmd/src/dmd/backend/compress.d:	63
dmd/src/dmd/backend/cv4.d:	2
dmd/src/dmd/backend/cv8.d:	638
dmd/src/dmd/backend/dcgcv.d:	2196
dmd/src/dmd/backend/dcode.d:	52
dmd/src/dmd/backend/debugprint.d:	279
dmd/src/dmd/backend/disasm86.d:	3316
dmd/src/dmd/backend/divcoeff.d:	129
dmd/src/dmd/backend/dlist.d:	197
dmd/src/dmd/backend/drtlsym.d:	468
dmd/src/dmd/backend/dt.d:	316
dmd/src/dmd/backend/dtype.d:	892
dmd/src/dmd/backend/dvarstats.d:	230
dmd/src/dmd/backend/dvec.d:	287
dmd/src/dmd/backend/dwarf2.d:	1
dmd/src/dmd/backend/dwarf.d:	20
dmd/src/dmd/backend/dwarfdbginf.d:	1721
dmd/src/dmd/backend/dwarfeh.d:	308
dmd/src/dmd/backend/ee.d:	59
dmd/src/dmd/backend/el.d:	112
dmd/src/dmd/backend/elem.d:	1649
dmd/src/dmd/backend/elfobj.d:	1699
dmd/src/dmd/backend/elpicpie.d:	483
dmd/src/dmd/backend/errors.di:	2
dmd/src/dmd/backend/evalu8.d:	1628
dmd/src/dmd/backend/exh.d:	28
dmd/src/dmd/backend/filespec.d:	158
dmd/src/dmd/backend/fp.d:	11
dmd/src/dmd/backend/gdag.d:	527
dmd/src/dmd/backend/gflow.d:	1034
dmd/src/dmd/backend/global.d:	343
dmd/src/dmd/backend/glocal.d:	419
dmd/src/dmd/backend/gloop.d:	2129
dmd/src/dmd/backend/go.d:	247
dmd/src/dmd/backend/goh.d:	58
dmd/src/dmd/backend/gother.d:	1136
dmd/src/dmd/backend/gsroa.d:	330
dmd/src/dmd/backend/iasm.d:	80
dmd/src/dmd/backend/mach.d:	137
dmd/src/dmd/backend/machobj.d:	1361
dmd/src/dmd/backend/md5.d:	152
dmd/src/dmd/backend/md5.di:	9
dmd/src/dmd/backend/melf.d:	317
dmd/src/dmd/backend/mem.d:	19
dmd/src/dmd/backend/mscoff.d:	82
dmd/src/dmd/backend/mscoffobj.d:	1002
dmd/src/dmd/backend/newman.d:	1065
dmd/src/dmd/backend/nteh.d:	445
dmd/src/dmd/backend/obj.d:	299
dmd/src/dmd/backend/oper.d:	444
dmd/src/dmd/backend/os.d:	409
dmd/src/dmd/backend/out.d:	989
dmd/src/dmd/backend/pdata.d:	112
dmd/src/dmd/backend/ph2.d:	63
dmd/src/dmd/backend/ptrntab.d:	986
dmd/src/dmd/backend/rtlsym.d:	4
dmd/src/dmd/backend/symbol.d:	1259
dmd/src/dmd/backend/symtab.d:	50
dmd/src/dmd/backend/ty.d:	50
dmd/src/dmd/backend/type.d:	94
dmd/src/dmd/backend/util2.d:	162
dmd/src/dmd/backend/var.d:	395
dmd/src/dmd/backend/xmm.d:	1
dmd/src/dmd/blockexit.d:	229
dmd/src/dmd/builtin.d:	263
dmd/src/dmd/canthrow.d:	141
dmd/src/dmd/chkformat.d:	801
dmd/src/dmd/cli.d:	94
dmd/src/dmd/clone.d:	858
dmd/src/dmd/common/file.d:	239
dmd/src/dmd/common/int128.d:	325
dmd/src/dmd/common/outbuffer.d:	358
dmd/src/dmd/common/string.d:	72
dmd/src/dmd/compiler.d:	195
dmd/src/dmd/cond.d:	427
dmd/src/dmd/console.d:	68
dmd/src/dmd/constfold.d:	1254
dmd/src/dmd/cparse.d:	2374
dmd/src/dmd/cppmangle.d:	1264
dmd/src/dmd/cppmanglewin.d:	850
dmd/src/dmd/ctfeexpr.d:	1203
dmd/src/dmd/ctorflow.d:	82
dmd/src/dmd/dcast.d:	2122
dmd/src/dmd/dclass.d:	515
dmd/src/dmd/declaration.d:	956
dmd/src/dmd/delegatize.d:	111
dmd/src/dmd/denum.d:	116
dmd/src/dmd/dimport.d:	174
dmd/src/dmd/dinifile.d:	194
dmd/src/dmd/dinterpret.d:	4214
dmd/src/dmd/dmacro.d:	238
dmd/src/dmd/dmangle.d:	634
dmd/src/dmd/dmdparams.d:	12
dmd/src/dmd/dmodule.d:	721
dmd/src/dmd/dmsc.d:	86
dmd/src/dmd/doc.d:	2928
dmd/src/dmd/dscope.d:	388
dmd/src/dmd/dstruct.d:	281
dmd/src/dmd/dsymbol.d:	1015
dmd/src/dmd/dsymbolsem.d:	3557
dmd/src/dmd/dtemplate.d:	4167
dmd/src/dmd/dtoh.d:	1708
dmd/src/dmd/dversion.d:	83
dmd/src/dmd/e2ir.d:	3795
dmd/src/dmd/eh.d:	189
dmd/src/dmd/entity.d:	38
dmd/src/dmd/errors.d:	358
dmd/src/dmd/escape.d:	986
dmd/src/dmd/expression.d:	2608
dmd/src/dmd/expressionsem.d:	7109
dmd/src/dmd/file_manager.d:	140
dmd/src/dmd/foreachvar.d:	193
dmd/src/dmd/frontend.d:	215
dmd/src/dmd/func.d:	1650
dmd/src/dmd/globals.d:	262
dmd/src/dmd/glue.d:	941
dmd/src/dmd/gluelayer.d:	32
dmd/src/dmd/hdrgen.d:	2231
dmd/src/dmd/iasm.d:	20
dmd/src/dmd/iasmdmd.d:	2625
dmd/src/dmd/iasmgcc.d:	231
dmd/src/dmd/id.d:	20
dmd/src/dmd/identifier.d:	125
dmd/src/dmd/impcnvtab.d:	230
dmd/src/dmd/imphint.d:	9
dmd/src/dmd/importc.d:	115
dmd/src/dmd/init.d:	125
dmd/src/dmd/initsem.d:	772
dmd/src/dmd/inlinecost.d:	202
dmd/src/dmd/inline.d:	1067
dmd/src/dmd/intrange.d:	444
dmd/src/dmd/json.d:	621
dmd/src/dmd/lambdacomp.d:	239
dmd/src/dmd/lexer.d:	2303
dmd/src/dmd/lib.d:	54
dmd/src/dmd/libelf.d:	319
dmd/src/dmd/libmach.d:	318
dmd/src/dmd/libmscoff.d:	418
dmd/src/dmd/libomf.d:	311
dmd/src/dmd/link.d:	543
dmd/src/dmd/mars.d:	1759
dmd/src/dmd/mtype.d:	3396
dmd/src/dmd/nogc.d:	127
dmd/src/dmd/nspace.d:	60
dmd/src/dmd/ob.d:	1345
dmd/src/dmd/objc.d:	293
dmd/src/dmd/objc_glue.d:	629
dmd/src/dmd/opover.d:	1066
dmd/src/dmd/optimize.d:	757
dmd/src/dmd/parse.d:	5760
dmd/src/dmd/parsetimevisitor.d:	226
dmd/src/dmd/permissivevisitor.d:	3
dmd/src/dmd/printast.d:	87
dmd/src/dmd/root/aav.d:	145
dmd/src/dmd/root/array.d:	499
dmd/src/dmd/root/bitarray.d:	89
dmd/src/dmd/root/complex.d:	35
dmd/src/dmd/root/ctfloat.d:	113
dmd/src/dmd/root/env.d:	29
dmd/src/dmd/root/file.d:	108
dmd/src/dmd/root/filename.d:	462
dmd/src/dmd/root/hash.d:	38
dmd/src/dmd/root/longdouble.d:	460
dmd/src/dmd/root/man.d:	48
dmd/src/dmd/root/optional.d:	27
dmd/src/dmd/root/port.d:	84
dmd/src/dmd/root/region.d:	56
dmd/src/dmd/root/response.d:	188
dmd/src/dmd/root/rmem.d:	134
dmd/src/dmd/root/rootobject.d:	9
dmd/src/dmd/root/speller.d:	132
dmd/src/dmd/root/string.d:	113
dmd/src/dmd/root/stringtable.d:	182
dmd/src/dmd/root/strtold.d:	284
dmd/src/dmd/root/utf.d:	136
dmd/src/dmd/s2ir.d:	878
dmd/src/dmd/safe.d:	91
dmd/src/dmd/sapply.d:	54
dmd/src/dmd/scanelf.d:	173
dmd/src/dmd/scanmach.d:	195
dmd/src/dmd/scanmscoff.d:	164
dmd/src/dmd/scanomf.d:	265
dmd/src/dmd/semantic2.d:	396
dmd/src/dmd/semantic3.d:	888
dmd/src/dmd/sideeffect.d:	178
dmd/src/dmd/statement.d:	660
dmd/src/dmd/statement_rewrite_walker.d:	71
dmd/src/dmd/statementsem.d:	2645
dmd/src/dmd/staticassert.d:	20
dmd/src/dmd/staticcond.d:	254
dmd/src/dmd/stmtstate.d:	73
dmd/src/dmd/strictvisitor.d:	222
dmd/src/dmd/target.d:	815
dmd/src/dmd/templateparamsem.d:	88
dmd/src/dmd/tocsym.d:	407
dmd/src/dmd/toctype.d:	141
dmd/src/dmd/tocvdebug.d:	689
dmd/src/dmd/todt.d:	842
dmd/src/dmd/toir.d:	529
dmd/src/dmd/tokens.d:	198
dmd/src/dmd/toobj.d:	747
dmd/src/dmd/traits.d:	1219
dmd/src/dmd/transitivevisitor.d:	481
dmd/src/dmd/typesem.d:	2798
dmd/src/dmd/typinf.d:	123
dmd/src/dmd/utils.d:	132
dmd/src/dmd/visitor.d:	117
dmd/src/dmd/vsoptions.d:	384
dmd/src/vcbuild/msvc-lib.d:	26
total:	174122