ADDED src/runtime/lookup-asm/lookup-asm-arm64-win64.S Index: src/runtime/lookup-asm/lookup-asm-arm64-win64.S ================================================================== --- /dev/null +++ src/runtime/lookup-asm/lookup-asm-arm64-win64.S @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2008-2024 Jonathan Schleifer + * + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3.0 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * version 3.0 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3.0 along with this program. If not, see + * . + */ + +#include "config.h" + +#include "platform.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 notFound +\name: +#ifdef HAVE_BTI + bti c +#endif + + cbz x0, .LreturnNilMethod + + tbnz x0, #0, .LtaggedPointer_\name + + ldr x2, [x0] + ldr x2, [x2, #56] + +.Lmain_\name: +#ifdef OF_SELUID24 + ldrb w3, [x1, #2] + ldr x2, [x2, x3, lsl #3] +#endif + ldrb w3, [x1, #1] + ldr x2, [x2, x3, lsl #3] + ldrb w3, [x1] + ldr x2, [x2, x3, lsl #3] + + cbz x2, \notFound + + mov x0, x2 + ret + +.LtaggedPointer_\name: + adrp x2, objc_taggedPointerSecret + ldr x2, [x2, :lo12:objc_taggedPointerSecret] + eor x0, x0, x2 + and x0, x0, #0xE + lsl x0, x0, #2 + + adrp x2, objc_taggedPointerClasses + add x2, x2, :lo12:objc_taggedPointerClasses + ldr x2, [x2, x0] + ldr x2, [x2, #56] + + b .Lmain_\name +.def \name +.scl 2 +.type 32 +.endef +.endm + +.macro GENERATE_LOOKUP_SUPER name lookup +\name: +#ifdef HAVE_BTI + bti c +#endif + + mov x2, x0 + ldr x0, [x0] + cbz x0, .LreturnNilMethod + + ldr x2, [x2, #8] + ldr x2, [x2, #56] + + b .Lmain_\lookup +.def \name +.scl 2 +.type 32 +.endef +.endm + +GENERATE_LOOKUP objc_msg_lookup objc_methodNotFound +GENERATE_LOOKUP objc_msg_lookup_stret objc_methodNotFound_stret +GENERATE_LOOKUP_SUPER objc_msg_lookup_super objc_msg_lookup +GENERATE_LOOKUP_SUPER objc_msg_lookup_super_stret objc_msg_lookup_stret + +.LreturnNilMethod: + adr x0, .LnilMethod + ret + +.LnilMethod: +#ifdef HAVE_BTI + bti c +#endif + + mov x0, #0 + ret Index: src/runtime/lookup-asm/lookup-asm.S ================================================================== --- src/runtime/lookup-asm/lookup-asm.S +++ src/runtime/lookup-asm/lookup-asm.S @@ -54,7 +54,9 @@ #elif defined(OF_WINDOWS) # if defined(OF_AMD64) # include "lookup-asm-amd64-win64.S" # elif defined(OF_X86) # include "lookup-asm-x86-win32.S" +# elif defined(OF_ARM64) +# include "lookup-asm-arm64-win64.S" # endif #endif Index: src/runtime/private.h ================================================================== --- src/runtime/private.h +++ src/runtime/private.h @@ -320,11 +320,11 @@ #elif defined(OF_MACH_O) # if defined(OF_AMD64) # define OF_ASM_LOOKUP # endif #elif defined(OF_WINDOWS) -# if defined(OF_AMD64) || defined(OF_X86) +# if defined(OF_AMD64) || defined(OF_X86) || defined(OF_ARM64) # define OF_ASM_LOOKUP # endif #endif @interface DummyObject