Index: src/invocation/apple-call-x86_64.S ================================================================== --- src/invocation/apple-call-x86_64.S +++ src/invocation/apple-call-x86_64.S @@ -15,10 +15,12 @@ * file. */ #include "config.h" +#include "invoke-x86_64.h" + .globl _of_invocation_call .section __TEXT, __text, regular, pure_instructions _of_invocation_call: pushq %rbp @@ -63,17 +65,17 @@ movq 8(%rdi), %rsi movb 225(%rdi), %r11b movq 0(%rdi), %rdi - cmpb $1, %r11b + cmpb $RETURN_TYPE_STRET, %r11b je Lcall_send_stret - cmpb $4, %r11b + cmpb $RETURN_TYPE_JMP, %r11b je _objc_msgSend - cmpb $5, %r11b + cmpb $RETURN_TYPE_JMP_STRET, %r11b je _objc_msgSend_stret call _objc_msgSend Lafter_send: @@ -83,14 +85,14 @@ movdqa %xmm0, 64(%rdi) movdqa %xmm1, 80(%rdi) movb 225(%rdi), %r11b - cmpb $2, %r11b + cmpb $RETURN_TYPE_X87, %r11b je Lpop_long_double - cmpb $3, %r11b + cmpb $RETURN_TYPE_COMPLEX_X87, %r11b je Lpop_complex_long_double Lreturn: movq %rbp, %rsp popq %rbp Index: src/invocation/call-x86_64-elf.S ================================================================== --- src/invocation/call-x86_64-elf.S +++ src/invocation/call-x86_64-elf.S @@ -15,10 +15,12 @@ * file. */ #include "config.h" +#include "invoke-x86_64.h" + .globl of_invocation_call .section .text of_invocation_call: pushq %rbp @@ -27,13 +29,13 @@ subq $16, %rsp andq $-16, %rsp movq %rdi, -8(%rbp) movb 225(%rdi), %r11b - cmpb $1, %r11b + cmpb $RETURN_TYPE_STRET, %r11b je .lookup_stret - cmpb $4, %r11b + cmpb $RETURN_TYPE_JMP_STRET, %r11b je .lookup_stret movq 8(%rdi), %rsi movq 0(%rdi), %rdi call objc_msg_lookup@PLT @@ -77,13 +79,13 @@ movq 8(%rdi), %rsi movb 225(%rdi), %r11b movq 0(%rdi), %rdi - cmpb $4, %r11b + cmpb $RETURN_TYPE_JMP, %r11b je .jmp_into_method - cmpb $5, %r11b + cmpb $RETURN_TYPE_JMP_STRET, %r11b je .jmp_into_method movq -16(%rbp), %r11 call *%r11 @@ -94,14 +96,14 @@ movdqa %xmm0, 64(%rdi) movdqa %xmm1, 80(%rdi) movb 225(%rdi), %r11b - cmpb $2, %r11b + cmpb $RETURN_TYPE_X87, %r11b je .pop_long_double - cmpb $3, %r11b + cmpb $RETURN_TYPE_COMPLEX_X87, %r11b je .pop_complex_long_double .return: movq %rbp, %rsp popq %rbp ADDED src/invocation/invoke-x86_64.h Index: src/invocation/invoke-x86_64.h ================================================================== --- /dev/null +++ src/invocation/invoke-x86_64.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, + * 2018 + * 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. + */ + +#define RETURN_TYPE_NORMAL 0 +#define RETURN_TYPE_STRET 1 +#define RETURN_TYPE_X87 2 +#define RETURN_TYPE_COMPLEX_X87 3 +#define RETURN_TYPE_JMP 4 +#define RETURN_TYPE_JMP_STRET 5 Index: src/invocation/invoke-x86_64.m ================================================================== --- src/invocation/invoke-x86_64.m +++ src/invocation/invoke-x86_64.m @@ -25,26 +25,19 @@ #import "OFMethodSignature.h" #import "OFInvalidFormatException.h" #import "OFOutOfMemoryException.h" +#import "invoke-x86_64.h" + #import "macros.h" #define NUM_GPR_IN 6 #define NUM_GPR_OUT 2 #define NUM_SSE_IN 8 #define NUM_X87_OUT 2 -enum { - RETURN_TYPE_NORMAL, - RETURN_TYPE_STRUCT, - RETURN_TYPE_X87, - RETURN_TYPE_COMPLEX_X87, - RETURN_TYPE_JMP, - RETURN_TYPE_JMP_STRET -}; - struct call_context { uint64_t GPR[NUM_GPR_IN + NUM_GPR_OUT]; __m128 SSE[NUM_SSE_IN]; long double X87[NUM_X87_OUT]; uint8_t numSSEUsed;