Created
January 19, 2012 16:06
-
-
Save dspezia/1640804 to your computer and use it in GitHub Desktop.
Annotated zslGetRank
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dump of assembler code for function zslGetRank: | |
; Function prolog: save registers on the stack | |
0x0000000000427fd0 <+0>: push %r14 | |
0x0000000000427fd2 <+2>: push %r13 | |
0x0000000000427fd4 <+4>: mov %rsi,%r13 | |
0x0000000000427fd7 <+7>: push %r12 | |
0x0000000000427fd9 <+9>: push %rbp | |
0x0000000000427fda <+10>: push %rbx | |
0x0000000000427fdb <+11>: sub $0x10,%rsp | |
; i = zsl->level-1 (r14) and x = zsl->header (rbx) | |
0x0000000000427fdf <+15>: mov 0x18(%rdi),%r14d | |
0x0000000000427fe3 <+19>: mov (%rdi),%rbx | |
0x0000000000427fe6 <+22>: sub $0x1,%r14d | |
; initial test of for loop | |
0x0000000000427fea <+26>: js 0x428076 <zslGetRank+166> | |
0x0000000000427ff0 <+32>: xor %r12d,%r12d | |
0x0000000000427ff3 <+35>: nopl 0x0(%rax,%rax,1) | |
; rbp will contain the offset to point to x->level[i] | |
; optimization of the compiler here: | |
; 3*8+(i*16) = 8 + 2*8 + 16*i = 8 + 16*(i+1) | |
; rax = x->level[i].forward | |
0x0000000000427ff8 <+40>: movslq %r14d,%rbp | |
0x0000000000427ffb <+43>: add $0x1,%rbp | |
0x0000000000427fff <+47>: shl $0x4,%rbp | |
0x0000000000428003 <+51>: mov 0x8(%rbx,%rbp,1),%rax | |
; Check x->level[i].forward is not nul | |
0x0000000000428008 <+56>: test %rax,%rax | |
0x000000000042800b <+59>: je 0x428052 <zslGetRank+130> | |
0x000000000042800d <+61>: nopl (%rax) | |
; Check score | |
0x0000000000428010 <+64>: movsd 0x8(%rax),%xmm1 | |
0x0000000000428015 <+69>: ucomisd %xmm1,%xmm0 | |
0x0000000000428019 <+73>: ja 0x42803c <zslGetRank+108> | |
0x000000000042801b <+75>: ucomisd %xmm0,%xmm1 | |
0x000000000042801f <+79>: jne 0x428052 <zslGetRank+130> | |
0x0000000000428021 <+81>: jp 0x428052 <zslGetRank+130> | |
; rdi = x->level[i].forward->obj, calling compareStringObjects | |
0x0000000000428023 <+83>: mov (%rax),%rdi | |
0x0000000000428026 <+86>: mov %r13,%rsi | |
0x0000000000428029 <+89>: movsd %xmm0,(%rsp) | |
0x000000000042802e <+94>: callq 0x41b840 <compareStringObjects> | |
0x0000000000428033 <+99>: test %eax,%eax | |
0x0000000000428035 <+101>: movsd (%rsp),%xmm0 | |
0x000000000042803a <+106>: jg 0x428052 <zslGetRank+130> | |
; eax = x->level[i].span | |
0x000000000042803c <+108>: mov 0x10(%rbp,%rbx,1),%eax | |
; x = x->level[i].forward (still in rbx) | |
0x0000000000428040 <+112>: mov 0x8(%rbx,%rbp,1),%rbx | |
; accumulate rank, eax being the low part of rax | |
0x0000000000428045 <+117>: add %rax,%r12 | |
; again rax = x->level[i].forward, test, and loop | |
0x0000000000428048 <+120>: mov 0x8(%rbx,%rbp,1),%rax | |
0x000000000042804d <+125>: test %rax,%rax | |
0x0000000000428050 <+128>: jne 0x428010 <zslGetRank+64> | |
; rbx still represents x, compare x->obj | |
0x0000000000428052 <+130>: mov (%rbx),%rdi | |
0x0000000000428055 <+133>: test %rdi,%rdi | |
0x0000000000428058 <+136>: je 0x428070 <zslGetRank+160> | |
; call equalStringObjects and compare results | |
0x000000000042805a <+138>: mov %r13,%rsi | |
0x000000000042805d <+141>: movsd %xmm0,(%rsp) | |
0x0000000000428062 <+146>: callq 0x41b910 <equalStringObjects> | |
0x0000000000428067 <+151>: test %eax,%eax | |
0x0000000000428069 <+153>: movsd (%rsp),%xmm0 | |
; return rank if test is true | |
0x000000000042806e <+158>: jne 0x428079 <zslGetRank+169> | |
; end of for loop, i is decremented | |
0x0000000000428070 <+160>: sub $0x1,%r14d | |
0x0000000000428074 <+164>: jns 0x427ff8 <zslGetRank+40> | |
; return 0, and function epilog | |
0x0000000000428076 <+166>: xor %r12d,%r12d | |
0x0000000000428079 <+169>: add $0x10,%rsp | |
0x000000000042807d <+173>: mov %r12,%rax | |
0x0000000000428080 <+176>: pop %rbx | |
0x0000000000428081 <+177>: pop %rbp | |
0x0000000000428082 <+178>: pop %r12 | |
0x0000000000428084 <+180>: pop %r13 | |
0x0000000000428086 <+182>: pop %r14 | |
0x0000000000428088 <+184>: retq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment