Skip to content

Instantly share code, notes, and snippets.

@kubo39
Last active April 20, 2017 17:35
Show Gist options
  • Select an option

  • Save kubo39/2449b33056c2b707113a48946bd3f7da to your computer and use it in GitHub Desktop.

Select an option

Save kubo39/2449b33056c2b707113a48946bd3f7da to your computer and use it in GitHub Desktop.
  • DMD
$ dmd --version
DMD64 D Compiler v2.074.0
Copyright (c) 1999-2017 by Digital Mars written by Walter Bright
$ dmd -O -c hoge.d
$ objdump -Mintel -d hoge.o
...
   b:   49 89 fd                mov    r13,rdi
   e:   49 89 f6                mov    r14,rsi
  11:   45 31 e4                xor    r12d,r12d
  14:   31 db                   xor    ebx,ebx
  16:   49 63 c4                movsxd rax,r12d
  19:   49 03 06                add    rax,QWORD PTR [r14]
  1c:   41 89 c4                mov    r12d,eax
  1f:   49 ff d5                rex.WB call r13
  22:   ff c3                   inc    ebx
  24:   83 fb 64                cmp    ebx,0x64
  27:   72 ed                   jb     16 <_D4hoge3fooFKmPFNaZiZm+0x16>
  29:   49 63 c4                movsxd rax,r12d
...
  • LDC
$ ldc2 -version| head -1
LDC - the LLVM D compiler (1.0.0):
$ ldc2 -O -c -ofldc.o hoge.d
$ objdump -M intel -d ldc.o
...
   7:   49 89 f6                mov    r14,rsi
   a:   49 89 ff                mov    r15,rdi
   d:   bd 64 00 00 00          mov    ebp,0x64
  12:   31 db                   xor    ebx,ebx
  14:   66 66 66 2e 0f 1f 84    data16 data16 nop WORD PTR cs:[rax+rax*1+0x0]
  1b:   00 00 00 00 00 
  20:   41 03 1e                add    ebx,DWORD PTR [r14]
  23:   41 ff d7                call   r15
  26:   48 63 db                movsxd rbx,ebx
  29:   ff cd                   dec    ebp
  2b:   75 f3                   jne    20 <_D4hoge3fooFKmPFNaZiZm+0x20>
  2d:   48 89 d8                mov    rax,rbx
  30:   48 83 c4 08             add    rsp,0x8
ulong foo(ref ulong v, int function() pure callback)
{
auto sum = 0;
foreach (_; 0 .. 100)
{
sum += v;
callback();
}
return sum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment