Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -128,10 +128,12 @@ AC_SUBST(OBJFW_SHARED_LIB, "${LIB_PREFIX}objfw${LIB_SUFFIX}") AC_SUBST(EXCEPTIONS_LIB_A, "exceptions.lib.a") AC_SUBST(EXCEPTIONS_EXCEPTIONS_LIB_A, "exceptions/exceptions.lib.a") AC_SUBST(FORWARDING_LIB_A, "forwarding.lib.a") AC_SUBST(FORWARDING_FORWARDING_LIB_A, "forwarding/forwarding.lib.a") + AC_SUBST(LOOKUP_ASM_LIB_A, "lookup-asm.lib.a") + AC_SUBST(LOOKUP_ASM_LOOKUP_ASM_LIB_A, "lookup-asm/lookup-asm.lib.a") ], [ AC_SUBST(LIBOBJFW_DEP, "../src/libobjfw.a") ]) AC_ARG_ENABLE(static, AS_HELP_STRING([--enable-static], [build static library])) AS_IF([test x"$enable_static" = x"yes" -o x"$enable_shared" = x"no"], [ @@ -138,10 +140,12 @@ AC_SUBST(OBJFW_STATIC_LIB, "libobjfw.a") AC_SUBST(EXCEPTIONS_A, "exceptions.a") AC_SUBST(EXCEPTIONS_EXCEPTIONS_A, "exceptions/exceptions.a") AC_SUBST(FORWARDING_A, "forwarding.a") AC_SUBST(FORWARDING_FORWARDING_A, "forwarding/forwarding.a") + AC_SUBST(LOOKUP_ASM_A, "lookup-asm.a") + AC_SUBST(LOOKUP_ASM_LOOKUP_ASM_A, "lookup-asm/lookup-asm.a") ]) AC_DEFINE_UNQUOTED(PLUGIN_SUFFIX, "$PLUGIN_SUFFIX", [Suffix for plugins]) AS_IF([test x"$PLUGIN_SUFFIX" != x""], [ AC_SUBST(USE_SRCS_PLUGINS, '${SRCS_PLUGINS}') Index: extra.mk.in ================================================================== --- extra.mk.in +++ extra.mk.in @@ -22,10 +22,14 @@ FORWARDING_FORWARDING_LIB_A = @FORWARDING_FORWARDING_LIB_A@ FORWARDING_LIB_A = @FORWARDING_LIB_A@ FOUNDATION_COMPAT_M = @FOUNDATION_COMPAT_M@ INSTANCE_M = @INSTANCE_M@ LIBOBJFW_DEP = @LIBOBJFW_DEP@ +LOOKUP_ASM_A = @LOOKUP_ASM_A@ +LOOKUP_ASM_LIB_A = @LOOKUP_ASM_LIB_A@ +LOOKUP_ASM_LOOKUP_ASM_A = @LOOKUP_ASM_LOOKUP_ASM_A@ +LOOKUP_ASM_LOOKUP_ASM_LIB_A = @LOOKUP_ASM_LOOKUP_ASM_LIB_A@ MAP_LDFLAGS = @MAP_LDFLAGS@ OFBLOCKTESTS_M = @OFBLOCKTESTS_M@ OFHTTPCLIENTTESTS_M = @OFHTTPCLIENTTESTS_M@ OFPROCESS_M = @OFPROCESS_M@ OFSTREAMOBSERVER_KQUEUE_M = @OFSTREAMOBSERVER_KQUEUE_M@ Index: src/runtime/Makefile ================================================================== --- src/runtime/Makefile +++ src/runtime/Makefile @@ -1,6 +1,8 @@ include ../../extra.mk + +SUBDIRS = lookup-asm STATIC_PIC_LIB_NOINST = ${RUNTIME_LIB_A} STATIC_LIB_NOINST = ${RUNTIME_A} SRCS = arc.m \ @@ -8,11 +10,10 @@ class.m \ exception.m \ hashtable.m \ init.m \ lookup.m \ - lookup-asm.S \ property.m \ protocol.m \ selector.m \ sparsearray.m \ static-instances.m \ @@ -19,9 +20,14 @@ synchronized.m \ ${USE_SRCS_THREADS} SRCS_THREADS = threading.m INCLUDES = runtime.h +OBJS_EXTRA = ${LOOKUP_ASM_LOOKUP_ASM_A} +LIB_OBJS_EXTRA = ${LOOKUP_ASM_LOOKUP_ASM_LIB_A} + include ../../buildsys.mk CPPFLAGS += -I. -I.. -I../.. LD = ${OBJC} + +${LOOKUP_ASM_LOOKUP_ASM_A} ${LOOKUP_ASM_LOOKUP_ASM_LIB_A}: lookup-asm DELETED src/runtime/lookup-asm-amd64-elf.S Index: src/runtime/lookup-asm-amd64-elf.S ================================================================== --- src/runtime/lookup-asm-amd64-elf.S +++ src/runtime/lookup-asm-amd64-elf.S @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 - * 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 -.macro generate_lookup name not_found_handler -\name: - testq %rdi, %rdi - jz ret_nil - - movq (%rdi), %r8 - movq 64(%r8), %r8 - -.main_\name: - movq (%rsi), %rax - movzbl %ah, %ecx - movzbl %al, %edx -#ifdef OF_SELUID24 - shrl $16, %eax - - movq (%r8,%rax,8), %r8 -#endif - movq (%r8,%rcx,8), %r8 - movq (%r8,%rdx,8), %rax - - testq %rax, %rax - jz \not_found_handler@PLT - - ret -.type \name, %function -.size \name, .-\name -.endm - -.macro generate_lookup_super name lookup -\name: - movq (%rdi), %rax - testq %rax, %rax - jz ret_nil - - movq 8(%rdi), %r8 - movq 64(%r8), %r8 - movq %rdi, %rax - jmp .main_\lookup -.type \name, %function -.size \name, .-\name -.endm - -generate_lookup objc_msg_lookup objc_not_found_handler -generate_lookup objc_msg_lookup_stret objc_not_found_handler_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: - leaq nil_method(%rip), %rax - ret - -nil_method: - xorq %rax, %rax - ret - -#ifdef __linux__ -.section .note.GNU-stack, "", %progbits -#endif DELETED src/runtime/lookup-asm-amd64-macho.S Index: src/runtime/lookup-asm-amd64-macho.S ================================================================== --- src/runtime/lookup-asm-amd64-macho.S +++ src/runtime/lookup-asm-amd64-macho.S @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 - * 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: - testq %rdi, %rdi - jz ret_nil - - movq (%rdi), %r8 - movq 64(%r8), %r8 - -Lmain$0: - movq (%rsi), %rax - movzbl %ah, %ecx - movzbl %al, %edx -#ifdef OF_SELUID24 - shrl $16, %eax - - movq (%r8,%rax,8), %r8 -#endif - movq (%r8,%rcx,8), %r8 - movq (%r8,%rdx,8), %rax - - testq %rax, %rax - jz $1 - - ret -.endmacro - -.macro generate_lookup_super: -$0: - movq (%rdi), %rax - testq %rax, %rax - jz ret_nil - - movq 8(%rdi), %r8 - movq 64(%r8), %r8 - movq %rdi, %rax - jmp Lmain$1 -.endmacro - -generate_lookup _objc_msg_lookup, _objc_not_found_handler -generate_lookup _objc_msg_lookup_stret, _objc_not_found_handler_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: - leaq nil_method(%rip), %rax - ret - -nil_method: - movq %rdi, %rax - ret DELETED src/runtime/lookup-asm-arm-elf.S Index: src/runtime/lookup-asm-arm-elf.S ================================================================== --- src/runtime/lookup-asm-arm-elf.S +++ src/runtime/lookup-asm-arm-elf.S @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 - * 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 -.macro generate_lookup name not_found_handler -\name: - cmp r0, #0 - beq ret_nil - - ldr r2, [r0, #0] - ldr r2, [r2, #32] - -.main_\name: -#ifdef OF_SELUID24 - ldrb r3, [r1, #2] - ldr r2, [r2, r3, lsl #2] -#endif - ldrb r3, [r1, #1] - ldr r2, [r2, r3, lsl #2] - ldrb r3, [r1, #0] - ldr r2, [r2, r3, lsl #2] - - cmp r2, #0 - beq \not_found_handler(PLT) - - mov r0, r2 - bx lr -.type \name, %function -.size \name, .-\name -.endm - -.macro generate_lookup_super name lookup -\name: - ldr r2, [r0, #0] - cmp r0, #0 - beq ret_nil - - ldr r2, [r0, #4] - ldr r2, [r2, #32] - - b .main_\lookup -.type \name, %function -.size \name, .-\name -.endm - -generate_lookup objc_msg_lookup objc_not_found_handler -generate_lookup objc_msg_lookup_stret objc_not_found_handler_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: - adr r0, nil_method - bx lr - -nil_method: - mov r0, #0 - bx lr - -#ifdef __linux__ -.section .note.GNU-stack, "", %progbits -#endif DELETED src/runtime/lookup-asm-mips-elf.S Index: src/runtime/lookup-asm-mips-elf.S ================================================================== --- src/runtime/lookup-asm-mips-elf.S +++ src/runtime/lookup-asm-mips-elf.S @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 - * 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 -.macro generate_lookup name not_found_handler -\name: - beqz $a0, .ret_nil_\name - - lw $t0, 0($a0) - lw $t0, 32($t0) - -.main_\name: -#if defined(_MIPSEL) -# ifdef OF_SELUID24 - lbu $t1, 2($a1) -# endif - lbu $t2, 1($a1) - lbu $t3, 0($a1) -#elif defined(_MIPSEB) -# ifdef OF_SELUID24 - lbu $t1, 1($a1) -# endif - lbu $t2, 2($a1) - lbu $t3, 3($a1) -#else -# error Neither _MIPSEL nor _MIPSEB defined! -#endif - -#ifdef OF_SELUID24 - sll $t1, $t1, 2 -#endif - sll $t2, $t2, 2 - sll $t3, $t3, 2 - -#ifdef OF_SELUID24 - addu $t0, $t0, $t1 - lw $t0, 0($t0) -#endif - addu $t0, $t0, $t2 - lw $t0, 0($t0) - addu $t0, $t0, $t3 - lw $t0, 0($t0) - -#ifdef __PIC__ - beqz $t0, .forward_\name -#else - beqz $t0, \not_found_handler -#endif - - move $v0, $t0 - j $ra - -.ret_nil_\name: -#ifdef __PIC__ - addiu $v0, $t9, nil_method-\name -#else - la $v0, nil_method -#endif - j $ra - -#ifdef __PIC__ -.forward_\name: - lui $gp, %hi(_gp_disp) - addiu $gp, $gp, %lo(_gp_disp) - addu $gp, $gp, $t9 - addiu $gp, $gp, .forward_\name-\name - - lw $t9, %call16(\not_found_handler)($gp) - jr $t9 -#endif -.type \name, %function -.size \name, .-\name -.endm - -.macro generate_lookup_super name lookup -\name: - lw $t0, 0($a0) - beqz $t0, .ret_nil_\name - - lw $t0, 4($a0) - lw $t0, 32($t0) - - b .main_\lookup - -.ret_nil_\name: -#ifdef __PIC__ - addiu $v0, $t9, nil_method-\name -#else - la $v0, nil_method -#endif - j $ra -.type \name, %function -.size \name, .-\name -.endm - -generate_lookup objc_msg_lookup objc_not_found_handler -generate_lookup objc_msg_lookup_stret objc_not_found_handler_stret -generate_lookup_super objc_msg_lookup_super objc_msg_lookup -generate_lookup_super objc_msg_lookup_super_stret objc_msg_lookup_stret - -nil_method: - move $v0, $zero - j $ra - -#ifdef __linux__ -.section .note.GNU-stack, "", %progbits -#endif DELETED src/runtime/lookup-asm-ppc-elf.S Index: src/runtime/lookup-asm-ppc-elf.S ================================================================== --- src/runtime/lookup-asm-ppc-elf.S +++ src/runtime/lookup-asm-ppc-elf.S @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 - * 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 -.macro generate_lookup name not_found_handler -\name: - cmpwi %r3, 0 - beq- ret_nil - - lwz %r5, 0(%r3) - lwz %r5, 32(%r5) - -.main_\name: -#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- .forward_\name - - mr %r3, %r5 - blr - -.forward_\name: - b \not_found_handler@plt -.type \name, %function -.size \name, .-\name -.endm - -.macro generate_lookup_super name lookup -\name: - lwz %r5, 0(%r3) - cmpwi %r5, 0 - beq- ret_nil - - lwz %r5, 4(%r3) - lwz %r5, 32(%r5) - - b .main_\lookup -.type \name, %function -.size \name, .-\name -.endm - -generate_lookup objc_msg_lookup objc_not_found_handler -generate_lookup objc_msg_lookup_stret objc_not_found_handler_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 -.L0: - addi %r3, %r3, nil_method-.L0 - blr - -nil_method: - li %r3, 0 - blr - -get_pc: - mflr %r3 - blr - -#ifdef __linux__ -.section .note.GNU-stack, "", %progbits -#endif DELETED src/runtime/lookup-asm-x86-elf.S Index: src/runtime/lookup-asm-x86-elf.S ================================================================== --- src/runtime/lookup-asm-x86-elf.S +++ src/runtime/lookup-asm-x86-elf.S @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 - * 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 -.macro generate_lookup name not_found_handler -\name: - movl 4(%esp), %edx - testl %edx, %edx - jz ret_nil - - movl (%edx), %edx - movl 32(%edx), %edx - -.main_\name: - movl 8(%esp), %eax - -#ifdef OF_SELUID24 - movzbl 2(%eax), %ecx - movl (%edx,%ecx,4), %edx -#endif - movzbl 1(%eax), %ecx - movl (%edx,%ecx,4), %edx - movzbl (%eax), %ecx - movl (%edx,%ecx,4), %eax - - testl %eax, %eax - jz .forward_\name - - ret - -.forward_\name: - call get_eip -.forward_L0_\name: - addl $\not_found_handler-.forward_L0_\name, %eax - jmp *%eax - -.type \name, %function -.size \name, .-\name -.endm - -.macro generate_lookup_super name lookup -\name: - movl 4(%esp), %edx - cmpl $0, (%edx) - je ret_nil - - movl 4(%edx), %edx - movl 32(%edx), %edx - jmp .main_\lookup -.type \name, %function -.size \name, .-\name -.endm - -generate_lookup objc_msg_lookup objc_not_found_handler -generate_lookup objc_msg_lookup_stret objc_not_found_handler_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: - call get_eip -.L0: - addl $nil_method-.L0, %eax - ret - -nil_method: - xorl %eax, %eax - ret - -get_eip: - movl (%esp), %eax - ret - -#ifdef __linux__ -.section .note.GNU-stack, "", %progbits -#endif DELETED src/runtime/lookup-asm.S Index: src/runtime/lookup-asm.S ================================================================== --- src/runtime/lookup-asm.S +++ src/runtime/lookup-asm.S @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 - * 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" - -#if defined(__ELF__) -# if defined(__amd64__) || defined(__x86_64__) -# include "lookup-asm-amd64-elf.S" -# elif defined(__i386__) -# include "lookup-asm-x86-elf.S" -# elif defined(__arm__) || defined(__ARM__) -# include "lookup-asm-arm-elf.S" -# elif defined(__ppc__) || defined(__PPC__) -# include "lookup-asm-ppc-elf.S" -# 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__) -# include "lookup-asm-amd64-macho.S" -# endif -#endif ADDED src/runtime/lookup-asm/Makefile Index: src/runtime/lookup-asm/Makefile ================================================================== --- src/runtime/lookup-asm/Makefile +++ src/runtime/lookup-asm/Makefile @@ -0,0 +1,10 @@ +include ../../../extra.mk + +STATIC_PIC_LIB_NOINST = ${LOOKUP_ASM_LIB_A} +STATIC_LIB_NOINST = ${LOOKUP_ASM_A} + +SRCS = lookup-asm.S + +include ../../../buildsys.mk + +ASFLAGS += -I../../.. ADDED src/runtime/lookup-asm/lookup-asm-amd64-elf.S Index: src/runtime/lookup-asm/lookup-asm-amd64-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-amd64-elf.S +++ src/runtime/lookup-asm/lookup-asm-amd64-elf.S @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 + * 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 +.macro generate_lookup name not_found_handler +\name: + testq %rdi, %rdi + jz ret_nil + + movq (%rdi), %r8 + movq 64(%r8), %r8 + +.main_\name: + movq (%rsi), %rax + movzbl %ah, %ecx + movzbl %al, %edx +#ifdef OF_SELUID24 + shrl $16, %eax + + movq (%r8,%rax,8), %r8 +#endif + movq (%r8,%rcx,8), %r8 + movq (%r8,%rdx,8), %rax + + testq %rax, %rax + jz \not_found_handler@PLT + + ret +.type \name, %function +.size \name, .-\name +.endm + +.macro generate_lookup_super name lookup +\name: + movq (%rdi), %rax + testq %rax, %rax + jz ret_nil + + movq 8(%rdi), %r8 + movq 64(%r8), %r8 + movq %rdi, %rax + jmp .main_\lookup +.type \name, %function +.size \name, .-\name +.endm + +generate_lookup objc_msg_lookup objc_not_found_handler +generate_lookup objc_msg_lookup_stret objc_not_found_handler_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: + leaq nil_method(%rip), %rax + ret + +nil_method: + xorq %rax, %rax + ret + +#ifdef __linux__ +.section .note.GNU-stack, "", %progbits +#endif ADDED src/runtime/lookup-asm/lookup-asm-amd64-macho.S 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 @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 + * 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: + testq %rdi, %rdi + jz ret_nil + + movq (%rdi), %r8 + movq 64(%r8), %r8 + +Lmain$0: + movq (%rsi), %rax + movzbl %ah, %ecx + movzbl %al, %edx +#ifdef OF_SELUID24 + shrl $16, %eax + + movq (%r8,%rax,8), %r8 +#endif + movq (%r8,%rcx,8), %r8 + movq (%r8,%rdx,8), %rax + + testq %rax, %rax + jz $1 + + ret +.endmacro + +.macro generate_lookup_super: +$0: + movq (%rdi), %rax + testq %rax, %rax + jz ret_nil + + movq 8(%rdi), %r8 + movq 64(%r8), %r8 + movq %rdi, %rax + jmp Lmain$1 +.endmacro + +generate_lookup _objc_msg_lookup, _objc_not_found_handler +generate_lookup _objc_msg_lookup_stret, _objc_not_found_handler_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: + leaq nil_method(%rip), %rax + ret + +nil_method: + movq %rdi, %rax + ret ADDED src/runtime/lookup-asm/lookup-asm-arm-elf.S Index: src/runtime/lookup-asm/lookup-asm-arm-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-arm-elf.S +++ src/runtime/lookup-asm/lookup-asm-arm-elf.S @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 + * 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 +.macro generate_lookup name not_found_handler +\name: + cmp r0, #0 + beq ret_nil + + ldr r2, [r0, #0] + ldr r2, [r2, #32] + +.main_\name: +#ifdef OF_SELUID24 + ldrb r3, [r1, #2] + ldr r2, [r2, r3, lsl #2] +#endif + ldrb r3, [r1, #1] + ldr r2, [r2, r3, lsl #2] + ldrb r3, [r1, #0] + ldr r2, [r2, r3, lsl #2] + + cmp r2, #0 + beq \not_found_handler(PLT) + + mov r0, r2 + bx lr +.type \name, %function +.size \name, .-\name +.endm + +.macro generate_lookup_super name lookup +\name: + ldr r2, [r0, #0] + cmp r0, #0 + beq ret_nil + + ldr r2, [r0, #4] + ldr r2, [r2, #32] + + b .main_\lookup +.type \name, %function +.size \name, .-\name +.endm + +generate_lookup objc_msg_lookup objc_not_found_handler +generate_lookup objc_msg_lookup_stret objc_not_found_handler_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: + adr r0, nil_method + bx lr + +nil_method: + mov r0, #0 + bx lr + +#ifdef __linux__ +.section .note.GNU-stack, "", %progbits +#endif ADDED src/runtime/lookup-asm/lookup-asm-mips-elf.S Index: src/runtime/lookup-asm/lookup-asm-mips-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-mips-elf.S +++ src/runtime/lookup-asm/lookup-asm-mips-elf.S @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 + * 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 +.macro generate_lookup name not_found_handler +\name: + beqz $a0, .ret_nil_\name + + lw $t0, 0($a0) + lw $t0, 32($t0) + +.main_\name: +#if defined(_MIPSEL) +# ifdef OF_SELUID24 + lbu $t1, 2($a1) +# endif + lbu $t2, 1($a1) + lbu $t3, 0($a1) +#elif defined(_MIPSEB) +# ifdef OF_SELUID24 + lbu $t1, 1($a1) +# endif + lbu $t2, 2($a1) + lbu $t3, 3($a1) +#else +# error Neither _MIPSEL nor _MIPSEB defined! +#endif + +#ifdef OF_SELUID24 + sll $t1, $t1, 2 +#endif + sll $t2, $t2, 2 + sll $t3, $t3, 2 + +#ifdef OF_SELUID24 + addu $t0, $t0, $t1 + lw $t0, 0($t0) +#endif + addu $t0, $t0, $t2 + lw $t0, 0($t0) + addu $t0, $t0, $t3 + lw $t0, 0($t0) + +#ifdef __PIC__ + beqz $t0, .forward_\name +#else + beqz $t0, \not_found_handler +#endif + + move $v0, $t0 + j $ra + +.ret_nil_\name: +#ifdef __PIC__ + addiu $v0, $t9, nil_method-\name +#else + la $v0, nil_method +#endif + j $ra + +#ifdef __PIC__ +.forward_\name: + lui $gp, %hi(_gp_disp) + addiu $gp, $gp, %lo(_gp_disp) + addu $gp, $gp, $t9 + addiu $gp, $gp, .forward_\name-\name + + lw $t9, %call16(\not_found_handler)($gp) + jr $t9 +#endif +.type \name, %function +.size \name, .-\name +.endm + +.macro generate_lookup_super name lookup +\name: + lw $t0, 0($a0) + beqz $t0, .ret_nil_\name + + lw $t0, 4($a0) + lw $t0, 32($t0) + + b .main_\lookup + +.ret_nil_\name: +#ifdef __PIC__ + addiu $v0, $t9, nil_method-\name +#else + la $v0, nil_method +#endif + j $ra +.type \name, %function +.size \name, .-\name +.endm + +generate_lookup objc_msg_lookup objc_not_found_handler +generate_lookup objc_msg_lookup_stret objc_not_found_handler_stret +generate_lookup_super objc_msg_lookup_super objc_msg_lookup +generate_lookup_super objc_msg_lookup_super_stret objc_msg_lookup_stret + +nil_method: + move $v0, $zero + j $ra + +#ifdef __linux__ +.section .note.GNU-stack, "", %progbits +#endif ADDED src/runtime/lookup-asm/lookup-asm-ppc-elf.S Index: src/runtime/lookup-asm/lookup-asm-ppc-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-ppc-elf.S +++ src/runtime/lookup-asm/lookup-asm-ppc-elf.S @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 + * 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 +.macro generate_lookup name not_found_handler +\name: + cmpwi %r3, 0 + beq- ret_nil + + lwz %r5, 0(%r3) + lwz %r5, 32(%r5) + +.main_\name: +#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- .forward_\name + + mr %r3, %r5 + blr + +.forward_\name: + b \not_found_handler@plt +.type \name, %function +.size \name, .-\name +.endm + +.macro generate_lookup_super name lookup +\name: + lwz %r5, 0(%r3) + cmpwi %r5, 0 + beq- ret_nil + + lwz %r5, 4(%r3) + lwz %r5, 32(%r5) + + b .main_\lookup +.type \name, %function +.size \name, .-\name +.endm + +generate_lookup objc_msg_lookup objc_not_found_handler +generate_lookup objc_msg_lookup_stret objc_not_found_handler_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 +.L0: + addi %r3, %r3, nil_method-.L0 + blr + +nil_method: + li %r3, 0 + blr + +get_pc: + mflr %r3 + blr + +#ifdef __linux__ +.section .note.GNU-stack, "", %progbits +#endif ADDED src/runtime/lookup-asm/lookup-asm-x86-elf.S 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 @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 + * 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 +.macro generate_lookup name not_found_handler +\name: + movl 4(%esp), %edx + testl %edx, %edx + jz ret_nil + + movl (%edx), %edx + movl 32(%edx), %edx + +.main_\name: + movl 8(%esp), %eax + +#ifdef OF_SELUID24 + movzbl 2(%eax), %ecx + movl (%edx,%ecx,4), %edx +#endif + movzbl 1(%eax), %ecx + movl (%edx,%ecx,4), %edx + movzbl (%eax), %ecx + movl (%edx,%ecx,4), %eax + + testl %eax, %eax + jz .forward_\name + + ret + +.forward_\name: + call get_eip +.forward_L0_\name: + addl $\not_found_handler-.forward_L0_\name, %eax + jmp *%eax + +.type \name, %function +.size \name, .-\name +.endm + +.macro generate_lookup_super name lookup +\name: + movl 4(%esp), %edx + cmpl $0, (%edx) + je ret_nil + + movl 4(%edx), %edx + movl 32(%edx), %edx + jmp .main_\lookup +.type \name, %function +.size \name, .-\name +.endm + +generate_lookup objc_msg_lookup objc_not_found_handler +generate_lookup objc_msg_lookup_stret objc_not_found_handler_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: + call get_eip +.L0: + addl $nil_method-.L0, %eax + ret + +nil_method: + xorl %eax, %eax + ret + +get_eip: + movl (%esp), %eax + ret + +#ifdef __linux__ +.section .note.GNU-stack, "", %progbits +#endif ADDED src/runtime/lookup-asm/lookup-asm.S Index: src/runtime/lookup-asm/lookup-asm.S ================================================================== --- src/runtime/lookup-asm/lookup-asm.S +++ src/runtime/lookup-asm/lookup-asm.S @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 + * 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" + +#if defined(__ELF__) +# if defined(__amd64__) || defined(__x86_64__) +# include "lookup-asm-amd64-elf.S" +# elif defined(__i386__) +# include "lookup-asm-x86-elf.S" +# elif defined(__arm__) || defined(__ARM__) +# include "lookup-asm-arm-elf.S" +# elif defined(__ppc__) || defined(__PPC__) +# include "lookup-asm-ppc-elf.S" +# 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__) +# include "lookup-asm-amd64-macho.S" +# endif +#endif