diff --git a/configure.ac b/configure.ac index 85d6c64be37..a2e935b64ec 100644 --- a/configure.ac +++ b/configure.ac @@ -2079,22 +2079,7 @@ AS_IF([test $rb_cv_stack_end_address != no], [ dnl Checks for library functions. AC_TYPE_GETGROUPS -AS_CASE(["${target_cpu}-${target_os}:${target_archs}"], -[powerpc*-darwin*], [ - AC_LIBSOURCES(alloca.c) - AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.${ac_objext}]) - AC_DEFINE(C_ALLOCA) - AC_DEFINE_UNQUOTED(alloca, alloca) - ], -[universal-darwin*:*ppc*], [ - AC_LIBSOURCES(alloca.c) - AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.${ac_objext}]) - RUBY_DEFINE_IF([defined __POWERPC__], C_ALLOCA, 1) # Darwin defines __POWERPC__ for ppc and ppc64 both - RUBY_DEFINE_IF([defined __POWERPC__], alloca, alloca) - ], -[ - AC_FUNC_ALLOCA - ]) +AC_FUNC_ALLOCA AS_IF([test "x$ALLOCA" = "x"], [ AC_CACHE_CHECK([for dynamic size alloca], rb_cv_dynamic_alloca, [ for chk in ok __chkstk; do @@ -2748,15 +2733,6 @@ AS_CASE([$coroutine_type], [yes|''], [ [arm64-darwin*], [ coroutine_type=arm64 ], - # Correct target name is powerpc*-, but Ruby seems to prefer ppc*-. - # Notice that Darwin PPC ABI differs from AIX and ELF. - # Adding PPC targets for AIX, *BSD and *Linux will require separate implementations. - [powerpc-darwin*|ppc-darwin*], [ - coroutine_type=ppc - ], - [powerpc64-darwin*|ppc64-darwin*], [ - coroutine_type=ppc64 - ], [x*64-linux*], [ AS_CASE(["$ac_cv_sizeof_voidp"], [8], [ coroutine_type=amd64 ], diff --git a/coroutine/ppc/Context.S b/coroutine/ppc/Context.S deleted file mode 100644 index ba87caef86d..00000000000 --- a/coroutine/ppc/Context.S +++ /dev/null @@ -1,96 +0,0 @@ -; Based on the code by Samuel Williams. Created by Sergey Fedorov on 04/06/2022. -; Credits to Samuel Williams, Rei Odaira and Iain Sandoe. Errors, if any, are mine. -; Some relevant examples: https://github.com/gcc-mirror/gcc/blob/master/libphobos/libdruntime/config/powerpc/switchcontext.S -; https://github.com/gcc-mirror/gcc/blob/master/libgcc/config/rs6000/darwin-gpsave.S -; https://www.ibm.com/docs/en/aix/7.2?topic=epilogs-saving-gprs-only -; ppc32 version may be re-written compactly with stmw/lwm, but the code won't be faster, see: https://github.com/ruby/ruby/pull/5927#issuecomment-1139730541 - -; Notice that this code is only for Darwin (macOS). Darwin ABI differs from AIX and ELF. -; To add support for AIX, *BSD or *Linux, please make separate implementations. - -#define TOKEN_PASTE(x,y) x##y - -.machine ppc7400 ; = G4, Rosetta -.text - -.globl PREFIXED_SYMBOL(coroutine_transfer) -.align 2 - -PREFIXED_SYMBOL(coroutine_transfer): - ; Make space on the stack for caller registers - ; (Should we rather use red zone? See libphobos example.) - subi r1,r1,80 - - ; Get LR - mflr r0 - - ; Save caller registers - stw r31,0(r1) - stw r30,4(r1) - stw r29,8(r1) - stw r28,12(r1) - stw r27,16(r1) - stw r26,20(r1) - stw r25,24(r1) - stw r24,28(r1) - stw r23,32(r1) - stw r22,36(r1) - stw r21,40(r1) - stw r20,44(r1) - stw r19,48(r1) - stw r18,52(r1) - stw r17,56(r1) - stw r16,60(r1) - stw r15,64(r1) - stw r14,68(r1) - stw r13,72(r1) - - ; Save return address - stw r0,76(r1) - - ; Save nonvolatile CR fields in the caller linkage area - mfcr r0 - stw r0,84(r1) - - ; Save stack pointer to first argument - stw r1,0(r3) - - ; Load stack pointer from second argument - lwz r1,0(r4) - - ; Load return address - lwz r0,76(r1) - - ; Restore caller registers - lwz r13,72(r1) - lwz r14,68(r1) - lwz r15,64(r1) - lwz r16,60(r1) - lwz r17,56(r1) - lwz r18,52(r1) - lwz r19,48(r1) - lwz r20,44(r1) - lwz r21,40(r1) - lwz r22,36(r1) - lwz r23,32(r1) - lwz r24,28(r1) - lwz r25,24(r1) - lwz r26,20(r1) - lwz r27,16(r1) - lwz r28,12(r1) - lwz r29,8(r1) - lwz r30,4(r1) - lwz r31,0(r1) - - ; Set LR - mtlr r0 - - ; Restore nonvolatile CR2-CR4 - lwz r0,84(r1) - mtcrf 56,r0 - - ; Pop stack frame - addi r1,r1,80 - - ; Jump to return address - blr diff --git a/coroutine/ppc/Context.h b/coroutine/ppc/Context.h deleted file mode 100644 index 8e35a799aa9..00000000000 --- a/coroutine/ppc/Context.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef COROUTINE_PPC_CONTEXT_H -#define COROUTINE_PPC_CONTEXT_H 1 - -#pragma once - -#include -#include -#include -#include - -#define COROUTINE __attribute__((noreturn)) void -#define COROUTINE_LIMITED_ADDRESS_SPACE - -enum { - COROUTINE_REGISTERS = - 20 /* 19 general purpose registers (r13-r31) and 1 return address */ - + 4 /* caller linkage area, including the condition register save slot */ -}; - -struct coroutine_context -{ - void **stack_pointer; - void *argument; -}; - -typedef COROUTINE(* coroutine_start)(struct coroutine_context *from, struct coroutine_context *self); - -static inline void coroutine_initialize_main(struct coroutine_context * context) { - context->stack_pointer = NULL; -} - -static inline void coroutine_initialize( - struct coroutine_context *context, - coroutine_start start, - void *stack, - size_t size -) { - assert(start && stack && size >= 1024); - - // Stack grows down. Force 16-byte alignment. - char * top = (char*)stack + size; - context->stack_pointer = (void**)((uintptr_t)top & ~0xF); - - context->stack_pointer -= COROUTINE_REGISTERS; - memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS); - - /* Skip a global prologue that sets the TOC register */ - context->stack_pointer[19] = ((char*)start) + 8; -} - -struct coroutine_context * coroutine_transfer(struct coroutine_context * current, struct coroutine_context * target); - -static inline void coroutine_destroy(struct coroutine_context * context) -{ - context->stack_pointer = NULL; -} - -#endif /* COROUTINE_PPC_CONTEXT_H */ diff --git a/coroutine/ppc64/Context.S b/coroutine/ppc64/Context.S deleted file mode 100644 index c21435d48b7..00000000000 --- a/coroutine/ppc64/Context.S +++ /dev/null @@ -1,95 +0,0 @@ -; Based on the code by Samuel Williams. Created by Sergey Fedorov on 04/06/2022. -; Credits to Samuel Williams, Rei Odaira and Iain Sandoe. Errors, if any, are mine. -; Some relevant examples: https://github.com/gcc-mirror/gcc/blob/master/libphobos/libdruntime/config/powerpc/switchcontext.S -; https://github.com/gcc-mirror/gcc/blob/master/libgcc/config/rs6000/darwin-gpsave.S -; https://www.ibm.com/docs/en/aix/7.2?topic=epilogs-saving-gprs-only - -; Notice that this code is only for Darwin (macOS). Darwin ABI differs from AIX and ELF. -; To add support for AIX, *BSD or *Linux, please make separate implementations. - -#define TOKEN_PASTE(x,y) x##y - -.machine ppc64 ; = G5 -.text - -.globl PREFIXED_SYMBOL(coroutine_transfer) -.align 2 - -PREFIXED_SYMBOL(coroutine_transfer): - ; Make space on the stack for caller registers - ; (Should we rather use red zone? See libphobos example.) - subi r1,r1,160 - - ; Get LR - mflr r0 - - ; Save caller registers - std r31,0(r1) - std r30,8(r1) - std r29,16(r1) - std r28,24(r1) - std r27,32(r1) - std r26,40(r1) - std r25,48(r1) - std r24,56(r1) - std r23,64(r1) - std r22,72(r1) - std r21,80(r1) - std r20,88(r1) - std r19,96(r1) - std r18,104(r1) - std r17,112(r1) - std r16,120(r1) - std r15,128(r1) - std r14,136(r1) - std r13,144(r1) - - ; Save return address - std r0,152(r1) - - ; Save nonvolatile CR fields in the caller linkage area - mfcr r0 - std r0,168(r1) - - ; Save stack pointer to first argument - std r1,0(r3) - - ; Load stack pointer from second argument - ld r1,0(r4) - - ; Load return address - ld r0,152(r1) - - ; Restore caller registers - ld r13,144(r1) - ld r14,136(r1) - ld r15,128(r1) - ld r16,120(r1) - ld r17,112(r1) - ld r18,104(r1) - ld r19,96(r1) - ld r20,88(r1) - ld r21,80(r1) - ld r22,72(r1) - ld r23,64(r1) - ld r24,56(r1) - ld r25,48(r1) - ld r26,40(r1) - ld r27,32(r1) - ld r28,24(r1) - ld r29,16(r1) - ld r30,8(r1) - ld r31,0(r1) - - ; Set LR - mtlr r0 - - ; Restore nonvolatile CR2-CR4 - ld r0,168(r1) - mtcrf 56,r0 - - ; Pop stack frame - addi r1,r1,160 - - ; Jump to return address - blr diff --git a/coroutine/ppc64/Context.h b/coroutine/ppc64/Context.h deleted file mode 100644 index 2cbfee67f04..00000000000 --- a/coroutine/ppc64/Context.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef COROUTINE_PPC64_CONTEXT_H -#define COROUTINE_PPC64_CONTEXT_H 1 - -#pragma once - -#include -#include -#include -#include - -#define COROUTINE __attribute__((noreturn)) void - -enum { - COROUTINE_REGISTERS = - 20 /* 19 general purpose registers (r13-r31) and 1 return address */ - + 4 /* caller linkage area, including the condition register save slot */ -}; - -struct coroutine_context -{ - void **stack_pointer; - void *argument; -}; - -typedef COROUTINE(* coroutine_start)(struct coroutine_context *from, struct coroutine_context *self); - -static inline void coroutine_initialize_main(struct coroutine_context * context) { - context->stack_pointer = NULL; -} - -static inline void coroutine_initialize( - struct coroutine_context *context, - coroutine_start start, - void *stack, - size_t size -) { - assert(start && stack && size >= 1024); - - // Stack grows down. Force 16-byte alignment. - char * top = (char*)stack + size; - context->stack_pointer = (void**)((uintptr_t)top & ~0xF); - - context->stack_pointer -= COROUTINE_REGISTERS; - memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS); - - /* Skip a global prologue that sets the TOC register */ - context->stack_pointer[19] = ((char*)start) + 8; -} - -struct coroutine_context * coroutine_transfer(struct coroutine_context * current, struct coroutine_context * target); - -static inline void coroutine_destroy(struct coroutine_context * context) -{ - context->stack_pointer = NULL; -} - -#endif /* COROUTINE_PPC64_CONTEXT_H */ diff --git a/coroutine/universal/Context.S b/coroutine/universal/Context.S index 11c80a79276..4b6135c8c25 100644 --- a/coroutine/universal/Context.S +++ b/coroutine/universal/Context.S @@ -3,12 +3,6 @@ # include "coroutine/amd64/Context.S" #elif defined __i386__ # include "coroutine/x86/Context.S" -#elif defined __ppc__ -# include "coroutine/ppc/Context.S" -#elif defined __ppc64__ && defined(WORDS_BIGENDIAN) -# include "coroutine/ppc64/Context.S" -#elif defined __ppc64__ && !defined(WORDS_BIGENDIAN) -# include "coroutine/ppc64le/Context.S" #elif defined __arm64__ # include "coroutine/arm64/Context.S" #else diff --git a/coroutine/universal/Context.h b/coroutine/universal/Context.h index ec4d2f484ab..9345416c52a 100644 --- a/coroutine/universal/Context.h +++ b/coroutine/universal/Context.h @@ -6,12 +6,6 @@ # include "coroutine/amd64/Context.h" #elif defined __i386__ # include "coroutine/x86/Context.h" -#elif defined __ppc__ -# include "coroutine/ppc/Context.h" -#elif defined __ppc64__ && defined(WORDS_BIGENDIAN) -# include "coroutine/ppc64/Context.h" -#elif defined __ppc64__ && !defined(WORDS_BIGENDIAN) -# include "coroutine/ppc64le/Context.h" #elif defined __arm64__ # include "coroutine/arm64/Context.h" #else diff --git a/error.c b/error.c index 500a27619f8..f4f09b56158 100644 --- a/error.c +++ b/error.c @@ -966,7 +966,7 @@ bug_important_message(FILE *out, const char *const msg, size_t len) #undef CRASH_REPORTER_MAY_BE_CREATED #if defined(__APPLE__) && \ - (!defined(MAC_OS_X_VERSION_10_6) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6 || defined(__POWERPC__)) /* 10.6 PPC case */ + (!defined(MAC_OS_X_VERSION_10_6) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6) # define CRASH_REPORTER_MAY_BE_CREATED #endif static void diff --git a/gc/default/default.c b/gc/default/default.c index 996fcd13d24..8792cbb6e03 100644 --- a/gc/default/default.c +++ b/gc/default/default.c @@ -1690,27 +1690,6 @@ tick(void) return val; } -#elif defined(__POWERPC__) && defined(__APPLE__) -/* Implementation for macOS PPC by @nobu - * See: https://github.com/ruby/ruby/pull/5975#discussion_r890045558 - */ -typedef unsigned long long tick_t; -#define PRItick "llu" - -static __inline__ tick_t -tick(void) -{ - unsigned long int upper, lower, tmp; - # define mftbu(r) __asm__ volatile("mftbu %0" : "=r"(r)) - # define mftb(r) __asm__ volatile("mftb %0" : "=r"(r)) - do { - mftbu(upper); - mftb(lower); - mftbu(tmp); - } while (tmp != upper); - return ((tick_t)upper << 32) | lower; -} - #elif defined(__aarch64__) && defined(__GNUC__) typedef unsigned long tick_t; #define PRItick "lu" diff --git a/internal/gc.h b/internal/gc.h index 83414f5e3e2..ed86477ca3e 100644 --- a/internal/gc.h +++ b/internal/gc.h @@ -26,12 +26,10 @@ struct rb_gc_zjit_fastpath; #define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("movq\t%%rsp, %0" : "=r" (*(p))) #elif defined(__i386) && defined(__GNUC__) #define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("movl\t%%esp, %0" : "=r" (*(p))) -#elif (defined(__powerpc__) || defined(__powerpc64__)) && defined(__GNUC__) && !defined(_AIX) && !defined(__APPLE__) // Not Apple is NEEDED to unbreak ppc64 build on Darwin. Don't ask. +#elif (defined(__powerpc__) || defined(__powerpc64__)) && defined(__GNUC__) && !defined(_AIX) #define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("mr\t%0, %%r1" : "=r" (*(p))) #elif (defined(__powerpc__) || defined(__powerpc64__)) && defined(__GNUC__) && defined(_AIX) #define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("mr %0,1" : "=r" (*(p))) -#elif defined(__POWERPC__) && defined(__APPLE__) // Darwin ppc and ppc64 -#define SET_MACHINE_STACK_END(p) __asm__ volatile("mr %0, r1" : "=r" (*(p))) #elif defined(__aarch64__) && defined(__GNUC__) #define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("mov\t%0, sp" : "=r" (*(p))) #else diff --git a/thread_pthread.c b/thread_pthread.c index 8f1564753ce..b4b40db8456 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1126,12 +1126,10 @@ native_thread_native_thread_id(rb_thread_t *target_th) #elif defined(__APPLE__) uint64_t tid; /* The first condition is needed because MAC_OS_X_VERSION_10_6 - is not defined on 10.5, and while __POWERPC__ takes care of ppc/ppc64, - i386 will be broken without this. Note, 10.5 is supported with GCC upstream, + is not defined on 10.5. Note, 10.5 is supported with GCC upstream, so it has C++17 and everything needed to build modern Ruby. */ # if (!defined(MAC_OS_X_VERSION_10_6) || \ - (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6) || \ - defined(__POWERPC__) /* never defined for PowerPC platforms */) + (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6)) const bool no_pthread_threadid_np = true; # define NO_PTHREAD_MACH_THREAD_NP 1 # elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 diff --git a/tool/m4/ruby_universal_arch.m4 b/tool/m4/ruby_universal_arch.m4 index d3e0dd0b477..3beb77ced85 100644 --- a/tool/m4/ruby_universal_arch.m4 +++ b/tool/m4/ruby_universal_arch.m4 @@ -60,12 +60,6 @@ AS_IF([test ${target_archs+set}], [ #ifdef __i386__ "processor-name=i386" #endif -#ifdef __ppc__ -"processor-name=powerpc" -#endif -#ifdef __ppc64__ -"processor-name=powerpc64" -#endif #ifdef __arm64__ "processor-name=arm64" #endif diff --git a/vm_core.h b/vm_core.h index 1be1f8373ea..5412dff0307 100644 --- a/vm_core.h +++ b/vm_core.h @@ -886,7 +886,7 @@ extern bool ruby_vm_during_cleanup; #define RUBY_VM_FIBER_VM_STACK_SIZE ( 16 * 1024 * sizeof(VALUE)) /* 64 KB or 128 KB */ #define RUBY_VM_FIBER_VM_STACK_SIZE_MIN ( 2 * 1024 * sizeof(VALUE)) /* 8 KB or 16 KB */ #define RUBY_VM_FIBER_MACHINE_STACK_SIZE ( 64 * 1024 * sizeof(VALUE)) /* 256 KB or 512 KB */ -#if defined(__powerpc64__) || defined(__ppc64__) // macOS has __ppc64__ +#if defined(__powerpc64__) #define RUBY_VM_FIBER_MACHINE_STACK_SIZE_MIN ( 32 * 1024 * sizeof(VALUE)) /* 128 KB or 256 KB */ #else #define RUBY_VM_FIBER_MACHINE_STACK_SIZE_MIN ( 16 * 1024 * sizeof(VALUE)) /* 64 KB or 128 KB */ diff --git a/vm_dump.c b/vm_dump.c index d570870ebcc..259f79e833f 100644 --- a/vm_dump.c +++ b/vm_dump.c @@ -778,7 +778,7 @@ rb_vmdebug_thread_dump_state(FILE *errout, VALUE self) # include # undef backtrace -# if defined(__arm64__) || defined(__POWERPC__) +# if defined(__arm64__) static bool is_coroutine_start(unw_word_t ip) { @@ -891,22 +891,19 @@ darwin_sigtramp: } return n; -# elif defined(__arm64__) || defined(__POWERPC__) +# elif defined(__arm64__) /* Since Darwin arm64's _sigtramp is implemented as normal function, * unwind can unwind frames without special code. * https://github.com/apple/darwin-libplatform/blob/215b09856ab5765b7462a91be7076183076600df/src/setjmp/generic/sigtramp.c */ while (n < size && unw_step(&cursor) > 0) { unw_get_reg(&cursor, UNW_REG_IP, &ip); -# if defined(__arm64__) // Strip Arm64's pointer authentication. // https://developer.apple.com/documentation/security/preparing_your_app_to_work_with_pointer_authentication // I wish I could use "ptrauth_strip()" but I get an error: // "this target does not support pointer authentication" trace[n++] = (void *)(ip & 0x7fffffffffffull); -# else - trace[n++] = (void *)ip; -# endif + // Apple's libunwind can't handle our coroutine switching code if (is_coroutine_start(ip)) break; }