Index: src/runtime/lookup-asm/lookup-asm-x86-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-x86-elf.S +++ src/runtime/lookup-asm/lookup-asm-x86-elf.S @@ -61,13 +61,15 @@ .endm .macro generate_lookup_super name lookup \name: movl 4(%esp), %edx - cmpl $0, (%edx) + movl (%edx), %eax + cmpl $0, %eax je ret_nil + movl %eax, 4(%esp) movl 4(%edx), %edx movl 32(%edx), %edx jmp .Lmain_\lookup .type \name, %function .size \name, .-\name Index: src/runtime/lookup-asm/lookup-asm-x86-win32.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-x86-win32.S +++ src/runtime/lookup-asm/lookup-asm-x86-win32.S @@ -56,13 +56,15 @@ .endm .macro generate_lookup_super name lookup \name: movl 4(%esp), %edx - cmpl $0, (%edx) + movl (%edx), %eax + cmpl $0, %eax je ret_nil + movl %eax, 4(%esp) movl 4(%edx), %edx movl 32(%edx), %edx jmp .Lmain_\lookup .endm Index: src/runtime/lookup-asm/lookup-asm-x86_64-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-x86_64-elf.S +++ src/runtime/lookup-asm/lookup-asm-x86_64-elf.S @@ -52,15 +52,16 @@ .size \name, .-\name .endm .macro generate_lookup_super name lookup \name: - movq (%rdi), %rax - testq %rax, %rax + movq %rdi, %r8 + movq (%rdi), %rdi + testq %rdi, %rdi jz ret_nil - movq 8(%rdi), %r8 + movq 8(%r8), %r8 movq 64(%r8), %r8 jmp .Lmain_\lookup .type \name, %function .size \name, .-\name .endm Index: src/runtime/lookup-asm/lookup-asm-x86_64-macho.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-x86_64-macho.S +++ src/runtime/lookup-asm/lookup-asm-x86_64-macho.S @@ -48,15 +48,16 @@ ret .endmacro .macro generate_lookup_super $0: - movq (%rdi), %rax - testq %rax, %rax + movq %rdi, %r8 + movq (%rdi), %rdi + testq %rdi, %rdi jz ret_nil - movq 8(%rdi), %r8 + movq 8(%r8), %r8 movq 64(%r8), %r8 jmp Lmain_$1 .endmacro generate_lookup _objc_msg_lookup, _objc_method_not_found Index: src/runtime/lookup-asm/lookup-asm-x86_64-win64.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-x86_64-win64.S +++ src/runtime/lookup-asm/lookup-asm-x86_64-win64.S @@ -56,15 +56,16 @@ jmp \not_found .endm .macro generate_lookup_super name lookup \name: - movq (%rcx), %rax - testq %rax, %rax + movq %rcx, %r8 + movq (%rcx), %rcx + testq %rcx, %rcx jz ret_nil - movq 8(%rcx), %r8 + movq 8(%r8), %r8 movq 56(%r8), %r8 jmp .Lmain_\lookup .endm generate_lookup objc_msg_lookup objc_method_not_found