Index: src/runtime/lookup-asm/lookup-asm-amd64-macho.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-amd64-macho.S +++ src/runtime/lookup-asm/lookup-asm-amd64-macho.S @@ -46,11 +46,11 @@ jz $1 ret .endmacro -.macro generate_lookup_super: +.macro generate_lookup_super $0: movq (%rdi), %rax testq %rax, %rax jz ret_nil ADDED src/runtime/lookup-asm/lookup-asm-ppc-macho.S Index: src/runtime/lookup-asm/lookup-asm-ppc-macho.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-ppc-macho.S +++ src/runtime/lookup-asm/lookup-asm-ppc-macho.S @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#include "config.h" + +.globl _objc_msg_lookup +.globl _objc_msg_lookup_stret +.globl _objc_msg_lookup_super +.globl _objc_msg_lookup_super_stret + +.section __TEXT, __text, regular, pure_instructions +.macro generate_lookup +$0: + cmpwi r3, 0 + beq- ret_nil + + lwz r5, 0(r3) + lwz r5, 32(r5) + +Lmain_$0: +#ifdef OF_SELUID24 + lbz r6, 1(r4) +#endif + lbz r7, 2(r4) + lbz r8, 3(r4) + +#ifdef OF_SELUID24 + slwi r6, r6, 2 +#endif + slwi r7, r7, 2 + slwi r8, r8, 2 + +#ifdef OF_SELUID24 + lwzx r5, r5, r6 +#endif + lwzx r5, r5, r7 + lwzx r5, r5, r8 + + cmpwi r5, 0 + beq- 0f + + mr r3, r5 + blr + +0: + b $1 +.endmacro + +.macro generate_lookup_super +$0: + lwz r5, 0(r3) + cmpwi r5, 0 + beq- ret_nil + + lwz r5, 4(r3) + lwz r5, 32(r5) + + b Lmain_$1 +.endmacro + +generate_lookup _objc_msg_lookup, _objc_method_not_found +generate_lookup _objc_msg_lookup_stret, _objc_method_not_found_stret +generate_lookup_super _objc_msg_lookup_super, _objc_msg_lookup +generate_lookup_super _objc_msg_lookup_super_stret, _objc_msg_lookup_stret + +ret_nil: + mflr r0 + bl get_pc + mtlr r0 +0: + addi r3, r3, lo16(nil_method-0b) + blr + +nil_method: + li r3, 0 + blr + +get_pc: + mflr r3 + blr Index: src/runtime/lookup-asm/lookup-asm.S ================================================================== --- src/runtime/lookup-asm/lookup-asm.S +++ src/runtime/lookup-asm/lookup-asm.S @@ -28,11 +28,15 @@ # elif (defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32) || \ (defined(__mips_eabi) && _MIPS_SZPTR == 32) # include "lookup-asm-mips-elf.S" # endif #elif defined(__MACH__) -# if defined(__amd64__) || defined(__x86_64__) +# if defined(__x86_64__) # include "lookup-asm-amd64-macho.S" +# elif defined(__ppc__) +# include "lookup-asm-ppc-macho.S" # endif -#elif defined(_WIN32) && defined(__i386__) -# include "lookup-asm-x86-win32.S" +#elif defined(_WIN32) +# if defined(__i386__) +# include "lookup-asm-x86-win32.S" +# endif #endif Index: src/runtime/runtime-private.h ================================================================== --- src/runtime/runtime-private.h +++ src/runtime/runtime-private.h @@ -184,19 +184,21 @@ # if (defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32) || \ (defined(__mips_eabi) && _MIPS_SZPTR == 32) # define OF_ASM_LOOKUP # endif #elif defined(__MACH__) -# if defined(__amd64__) || defined(__x86_64__) +# if defined(__x86_64__) || defined(__ppc__) # define OF_ASM_LOOKUP # endif -#elif defined(_WIN32) && defined(__i386__) -# define OF_ASM_LOOKUP +#elif defined(_WIN32) +# if defined(__i386__) +# define OF_ASM_LOOKUP +# endif #endif #define OBJC_ERROR(...) \ { \ fprintf(stderr, "[objc @ " __FILE__ ":%d] ", __LINE__); \ fprintf(stderr, __VA_ARGS__); \ fputs("\n", stderr); \ abort(); \ }