Skip to content

Instantly share code, notes, and snippets.

@Tarrasch
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tarrasch/8965562 to your computer and use it in GitHub Desktop.
Save Tarrasch/8965562 to your computer and use it in GitHub Desktop.
I got this file by running:
❯ "inplace/bin/ghc-stage1" -optc-Wall -optc-Wextra -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Winline -optc-Waggregate-return -optc-Wpointer-arith -optc-Wmissing-noreturn -optc-Wnested-externs -optc-Wredundant-decls -optc-Iincludes -optc-Iincludes/dist -optc-Iincludes/dist-derivedconstants/header -optc-Iincludes/dist-ghcconstants/header -optc-Irts -optc-Irts/dist/build -optc-DCOMPILING_RTS -optc-DDEBUG -optc-fno-strict-aliasing -optc-fno-common -optc-DUSE_DWARF -optc-O2 -optc-fomit-frame-pointer -optc-DRtsWay=\"rts_v\" -static -O -H64m -Iincludes -Iincludes/dist -Iincludes/dist-derivedconstants/header -Iincludes/dist-ghcconstants/header -Irts -Irts/dist/build -DCOMPILING_RTS -package-name rts -dcmm-lint -i -irts -irts/dist/build -irts/dist/build/autogen -Irts/dist/build -Irts/dist/build/autogen -O2 -g -c rts/sm/Scav.c -o rts/dist/build/sm/Scav.o
and then I ran:
objdump --source rts/dist/build/sm/Scav.o | less
And manually pasted out these excerpts which are *exactly identical*
0000000000000970 <use_function>:
970: 41 56 push %r14
972: 85 f6 test %esi,%esi
974: 41 89 f6 mov %esi,%r14d
977: 41 55 push %r13
979: 49 89 fd mov %rdi,%r13
97c: 41 54 push %r12
97e: 55 push %rbp
97f: 53 push %rbx
980: 74 3c je 9be <use_function+0x4e>
982: 48 89 d3 mov %rdx,%rbx
985: 89 f5 mov %esi,%ebp
987: 49 89 fc mov %rdi,%r12
98a: eb 10 jmp 99c <use_function+0x2c>
98c: 0f 1f 40 00 nopl 0x0(%rax)
990: 49 83 c4 08 add $0x8,%r12
994: 48 d1 eb shr %rbx
997: 83 ed 01 sub $0x1,%ebp
99a: 74 19 je 9b5 <use_function+0x45>
99c: f6 c3 01 test $0x1,%bl
99f: 75 ef jne 990 <use_function+0x20>
9a1: 4c 89 e7 mov %r12,%rdi
9a4: 48 d1 eb shr %rbx
9a7: 49 83 c4 08 add $0x8,%r12
9ab: e8 00 00 00 00 callq 9b0 <use_function+0x40>
9b0: 83 ed 01 sub $0x1,%ebp
9b3: 75 e7 jne 99c <use_function+0x2c>
9b5: 41 83 ee 01 sub $0x1,%r14d
9b9: 4f 8d 6c f5 08 lea 0x8(%r13,%r14,8),%r13
9be: 5b pop %rbx
9bf: 5d pop %rbp
9c0: 41 5c pop %r12
9c2: 4c 89 e8 mov %r13,%rax
9c5: 41 5d pop %r13
9c7: 41 5e pop %r14
9c9: c3 retq
9ca: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
00000000000009d0 <explicit_inline>:
9d0: 41 56 push %r14
9d2: 85 f6 test %esi,%esi
9d4: 41 89 f6 mov %esi,%r14d
9d7: 41 55 push %r13
9d9: 49 89 fd mov %rdi,%r13
9dc: 41 54 push %r12
9de: 55 push %rbp
9df: 53 push %rbx
9e0: 74 3c je a1e <explicit_inline+0x4e>
9e2: 48 89 d3 mov %rdx,%rbx
9e5: 89 f5 mov %esi,%ebp
9e7: 49 89 fc mov %rdi,%r12
9ea: eb 10 jmp 9fc <explicit_inline+0x2c>
9ec: 0f 1f 40 00 nopl 0x0(%rax)
9f0: 49 83 c4 08 add $0x8,%r12
9f4: 48 d1 eb shr %rbx
9f7: 83 ed 01 sub $0x1,%ebp
9fa: 74 19 je a15 <explicit_inline+0x45>
9fc: f6 c3 01 test $0x1,%bl
9ff: 75 ef jne 9f0 <explicit_inline+0x20>
a01: 4c 89 e7 mov %r12,%rdi
a04: 48 d1 eb shr %rbx
a07: 49 83 c4 08 add $0x8,%r12
a0b: e8 00 00 00 00 callq a10 <explicit_inline+0x40>
a10: 83 ed 01 sub $0x1,%ebp
a13: 75 e7 jne 9fc <explicit_inline+0x2c>
a15: 41 83 ee 01 sub $0x1,%r14d
a19: 4f 8d 6c f5 08 lea 0x8(%r13,%r14,8),%r13
a1e: 5b pop %rbx
a1f: 5d pop %rbp
a20: 41 5c pop %r12
a22: 4c 89 e8 mov %r13,%rax
a25: 41 5d pop %r13
a27: 41 5e pop %r14
a29: c3 retq
a2a: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
// This is parts of Scav.c
STATIC_INLINE StgPtr
scavenge_small_bitmap (StgPtr p, nat size, StgWord bitmap)
{
while (size > 0) {
if ((bitmap & 1) == 0) {
evacuate((StgClosure **)p);
}
p++;
bitmap = bitmap >> 1;
size--;
}
return p;
}
#if !(defined(THREADED_RTS) && !defined(PARALLEL_GC))
StgPtr
use_function (StgPtr p, nat size, StgWord bitmap);
StgPtr
use_function (StgPtr p, nat size, StgWord bitmap)
{
p = scavenge_small_bitmap(p, size, bitmap);
return p;
}
StgPtr
explicit_inline (StgPtr p, nat size, StgWord bitmap);
StgPtr
explicit_inline (StgPtr p, nat size, StgWord bitmap)
{
while (size > 0) {
if ((bitmap & 1) == 0) {
evacuate((StgClosure **)p);
}
p++;
bitmap = bitmap >> 1;
size--;
}
return p;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment