Skip to content

Instantly share code, notes, and snippets.

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 gnachman/f827f205e8b99fe35c9b5fbd2235aa28 to your computer and use it in GitHub Desktop.
Save gnachman/f827f205e8b99fe35c9b5fbd2235aa28 to your computer and use it in GitHub Desktop.
rdi=self
rsi=selector
rdx=array of events
dx 1st arg
cx 2nd arg
r8 3rd arg
r9 4th arg
local vars:
NSFastEnumerationState *-f0; (extends to -b0)
id -b0[16];
AppKit`-[NSView interpretKeyEvents:]:
0x7fff944c53e3 <+0>: pushq %rbp ; stack = [original bp]
0x7fff944c53e4 <+1>: movq %rsp, %rbp ; bp = sp at original bp
0x7fff944c53e7 <+4>: pushq %r15
0x7fff944c53e9 <+6>: pushq %r14
0x7fff944c53eb <+8>: pushq %r13
0x7fff944c53ed <+10>: pushq %r12
0x7fff944c53ef <+12>: pushq %rbx ; stack = [original values of: bx; r12; r13; r14; r15; bp]
0x7fff944c53f0 <+13>: subq $0xd8, %rsp ; stack = [216 bytes for local vars; original values of: bx; r12; r13; r14; r15; bp]
0x7fff944c53f7 <+20>: movq %rdx, %r15 ; rdi=self, rsi=@selector(interpretKeyEvents:), rdx=@[ event ], r15=@[ event ]
0x7fff944c53fa <+23>: movq %rdi, %rbx ; rdi=self, rsi=@selector(interpretKeyEvents:), rdx=@[ event ], r15=@[ event ]; rbx=self
0x7fff944c53fd <+26>: movq -0x20865a4c(%rip), %rax ; rdi=self, rsi=@selector(interpretKeyEvents:), rdx=@[ event ], r15=@[ event ]; rbx=self, rax=__stack_chk_guard
0x7fff944c5404 <+33>: movq (%rax), %rax
0x7fff944c5407 <+36>: movq %rax, -0x30(%rbp)
0x7fff944c540b <+40>: movq -0x20615eea(%rip), %rsi ; rdi=self, rsi=@selector(inputContext), rdx=@[ event ], r15=@[ event ]; rbx=self, rax=__stack_chk_guard
0x7fff944c5412 <+47>: callq *-0x208644c8(%rip) ; rax <- [self inputContext]
0x7fff944c5418 <+53>: movq %rax, %r12 ; rdi=self, rsi=@selector(inputContext), rdx=@[ event ], r15=@[ event ]; rbx=self, rax=__stack_chk_guard; r12=self.inputContext
0x7fff944c541b <+56>: testq %r12, %r12
0x7fff944c541e <+59>: je 0x7fff944c54e5 ; if self.inputContext == nil goto <+258>
0x7fff944c5424 <+65>: xorps %xmm0, %xmm0 ; xmm0=0
0x7fff944c5427 <+68>: movaps %xmm0, -0xc0(%rbp)
0x7fff944c542e <+75>: movaps %xmm0, -0xd0(%rbp)
0x7fff944c5435 <+82>: movaps %xmm0, -0xe0(%rbp)
0x7fff944c543c <+89>: movaps %xmm0, -0xf0(%rbp) ; -c0 = -d0 = -e0 = -f0 = 0
0x7fff944c5443 <+96>: movq -0x206185fa(%rip), %rsi ; rsi <- “countByEnumeratingWithState:objects:count:"
0x7fff944c544a <+103>: leaq -0xf0(%rbp), %rdx ; rdx <- &-f0
0x7fff944c5451 <+110>: leaq -0xb0(%rbp), %rcx ; dcx <- &-b0
0x7fff944c5458 <+117>: movl $0x10, %r8d ; r8d <- 16
0x7fff944c545e <+123>: movq %r15, %rdi ; rdi <- @[ event ]
; rdi=@[ event ], rsi=@selector(countByEnumeratingWithState:objects:count:), rdx=&-f0, r15=@[ event ]; rbx=self, rax=self.inputContext; r12=self.inputContext
0x7fff944c5461 <+126>: callq *-0x20864517(%rip) ; rax <- [@[event] countByEnumeratingWithState:&-f0 objects:&-b0 count:16]
0x7fff944c5467 <+132>: movq %rax, %rbx ; rdi=@[ event ], rsi=@selector(countByEnumeratingWithState:objects:count:), rdx=&-f0, r15=@[ event ]; rbx=events.count, rax=events.count; r12=self.inputContext
0x7fff944c546a <+135>: testq %rbx, %rbx
0x7fff944c546d <+138>: je 0x7fff944c5510 ; if !events.count goto <+301>
0x7fff944c5473 <+144>: movq -0xe0(%rbp), %rax ; rax <- fastEnumerationState.mutationsPtr
0x7fff944c547a <+151>: movq (%rax), %r13 ; r13 = *fastEnumerationState.mutationsPtr (equals 1)
<+154>:
0x7fff944c547d <+154>: xorl %r14d, %r14d ; r14d <- 0
<+157>:
0x7fff944c5480 <+157>: movq -0xe0(%rbp), %rax ; rax <- fastEnumerationState.mutationsPtr
0x7fff944c5487 <+164>: cmpq %r13, (%rax)
0x7fff944c548a <+167>: je 0x7fff944c5494 ; if r13==rax goto <+177>
0x7fff944c548c <+169>: movq %r15, %rdi ; rid <- @[event]
0x7fff944c548f <+172>: callq 0x7fff94c2ef0c ; symbol stub for: objc_enumerationMutation
<+177>
0x7fff944c5494 <+177>: movq -0xe8(%rbp), %rax ; rax <- fastEnumerationState.itemsPtr
0x7fff944c549b <+184>: movq (%rax,%r14,8), %rdx ; rdx <- fastEnumerationState[r14 * 8]
0x7fff944c549f <+188>: movq %r12, %rdi ; rdi <- r12 (self.inputContext)
0x7fff944c54a2 <+191>: movq -0x205fd7c1(%rip), %rsi ; rsi <- ”handleEvent:"
0x7fff944c54a9 <+198>: callq *-0x2086455f(%rip) ; rax<-[self.inputContext handleEvent:itemsPtr[r14]]
0x7fff944c54af <+204>: incq %r14 ; ++r14
0x7fff944c54b2 <+207>: cmpq %rbx, %r14
0x7fff944c54b5 <+210>: jb 0x7fff944c5480 ; if r14 < rbx goto <+157> // r14 is counter, rbx is the count
0x7fff944c54b7 <+212>: movl $0x10, %r8d ; r8d <- 16
0x7fff944c54bd <+218>: movq %r15, %rdi ; rdi <- @[event]
0x7fff944c54c0 <+221>: movq -0x20618677(%rip), %rsi ;
0x7fff944c54c7 <+228>: leaq -0xf0(%rbp), %rdx ; rdx <- &-f0
0x7fff944c54ce <+235>: leaq -0xb0(%rbp), %rcx ; rcx <- &-b0
0x7fff944c54d5 <+242>: callq *-0x2086458b(%rip) ; rax <- [@[event] countByEnumeratingWithState:&-f0 objects:&-b0 count:16];
0x7fff944c54db <+248>: movq %rax, %rbx ; bx <- ax (number of events left)
0x7fff944c54de <+251>: testq %rbx, %rbx
0x7fff944c54e1 <+254>: jne 0x7fff944c547d ; if number of events left != 0 goto <+154>
0x7fff944c54e3 <+256>: jmp 0x7fff944c5510 ; goto <+301>
<+258>: // nil input context
0x7fff944c54e5 <+258>: movq %rbx, -0x100(%rbp)
0x7fff944c54ec <+265>: movq -0x205e6393(%rip), %rax ; (void *)0x00007fff73efb878: NSView
0x7fff944c54f3 <+272>: movq %rax, -0xf8(%rbp)
0x7fff944c54fa <+279>: movq -0x2060ee09(%rip), %rsi ; "interpretKeyEvents:"
0x7fff944c5501 <+286>: leaq -0x100(%rbp), %rdi
0x7fff944c5508 <+293>: movq %r15, %rdx
0x7fff944c550b <+296>: callq 0x7fff94c2ef60 ; symbol stub for: objc_msgSendSuper2
<+301> // exit loop
0x7fff944c5510 <+301>: movq -0x20865b5f(%rip), %rax ; (void *)0x00007fff71d05070: __stack_chk_guard
0x7fff944c5517 <+308>: movq (%rax), %rax
0x7fff944c551a <+311>: cmpq -0x30(%rbp), %rax
0x7fff944c551e <+315>: jne 0x7fff944c5532 ; <+335>
0x7fff944c5520 <+317>: addq $0xd8, %rsp
0x7fff944c5527 <+324>: popq %rbx
0x7fff944c5528 <+325>: popq %r12
0x7fff944c552a <+327>: popq %r13
0x7fff944c552c <+329>: popq %r14
0x7fff944c552e <+331>: popq %r15
0x7fff944c5530 <+333>: popq %rbp
0x7fff944c5531 <+334>: retq
0x7fff944c5532 <+335>: callq 0x7fff94c2f0f2 ; symbol stub for: __stack_chk_fail
0x7fff944c5537 <+340>: nop
0x7fff944c5538 <+341>: nop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment