Skip to content

Commit

Permalink
Basic support for ppc32
Browse files Browse the repository at this point in the history
This commit applies a set of patches from: nodejs#30323 (comment)
  • Loading branch information
barracuda156 committed Nov 5, 2023
1 parent a3d2837 commit 3a4f6d9
Show file tree
Hide file tree
Showing 65 changed files with 1,428 additions and 236 deletions.
1 change: 1 addition & 0 deletions deps/v8/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ Vladimir Krivosheev <[email protected]>
Vladimir Shutoff <[email protected]>
Wenlu Wang <[email protected]>
Wiktor Garbacz <[email protected]>
Wouter Vermeiren <[email protected]>
Xiaoyin Liu <[email protected]>
Yannic Bonenberger <[email protected]>
Yong Wang <[email protected]>
Expand Down
47 changes: 43 additions & 4 deletions deps/v8/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,9 @@ config("toolchain") {
}
}
if (v8_current_cpu == "ppc" || v8_current_cpu == "ppc64") {
defines += [ "V8_TARGET_ARCH_PPC" ]
if (v8_current_cpu == "ppc64") {
if (v8_current_cpu == "ppc") {
defines += [ "V8_TARGET_ARCH_PPC" ]
} else if (v8_current_cpu == "ppc64") {
defines += [ "V8_TARGET_ARCH_PPC64" ]
}
if (host_byteorder == "little") {
Expand Down Expand Up @@ -1605,11 +1606,16 @@ v8_source_set("v8_initializers") {
### gcmole(arch:mips64el) ###
"src/builtins/mips64/builtins-mips64.cc",
]
} else if (v8_current_cpu == "ppc" || v8_current_cpu == "ppc64") {
} else if (v8_current_cpu == "ppc") {
sources += [
### gcmole(arch:ppc) ###
"src/builtins/ppc/builtins-ppc.cc",
]
} else if (v8_current_cpu == "ppc64") {
sources += [
### gcmole(arch:ppc64) ###
"src/builtins/ppc/builtins-ppc.cc",
]
} else if (v8_current_cpu == "s390" || v8_current_cpu == "s390x") {
sources += [
### gcmole(arch:s390) ###
Expand Down Expand Up @@ -3190,7 +3196,7 @@ v8_source_set("v8_base_without_compiler") {
"src/regexp/mips64/regexp-macro-assembler-mips64.h",
"src/wasm/baseline/mips64/liftoff-assembler-mips64.h",
]
} else if (v8_current_cpu == "ppc" || v8_current_cpu == "ppc64") {
} else if (v8_current_cpu == "ppc") {
sources += [ ### gcmole(arch:ppc) ###
"src/codegen/ppc/assembler-ppc-inl.h",
"src/codegen/ppc/assembler-ppc.cc",
Expand All @@ -3206,9 +3212,42 @@ v8_source_set("v8_base_without_compiler") {
"src/compiler/backend/ppc/instruction-codes-ppc.h",
"src/compiler/backend/ppc/instruction-scheduler-ppc.cc",
"src/compiler/backend/ppc/instruction-selector-ppc.cc",
"src/compiler/backend/ppc/unwinding-info-writer-ppc.cc",
"src/compiler/backend/ppc/unwinding-info-writer-ppc.h",
"src/debug/ppc/debug-ppc.cc",
"src/deoptimizer/ppc/deoptimizer-ppc.cc",
"src/diagnostics/ppc/disasm-ppc.cc",
"src/diagnostics/ppc/eh-frame-ppc.cc",
"src/execution/ppc/frame-constants-ppc.cc",
"src/execution/ppc/frame-constants-ppc.h",
"src/execution/ppc/simulator-ppc.cc",
"src/execution/ppc/simulator-ppc.h",
"src/regexp/ppc/regexp-macro-assembler-ppc.cc",
"src/regexp/ppc/regexp-macro-assembler-ppc.h",
"src/wasm/baseline/ppc/liftoff-assembler-ppc.h",
]
} else if (v8_current_cpu == "ppc64") {
sources += [ ### gcmole(arch:ppc64) ###
"src/codegen/ppc/assembler-ppc-inl.h",
"src/codegen/ppc/assembler-ppc.cc",
"src/codegen/ppc/assembler-ppc.h",
"src/codegen/ppc/constants-ppc.cc",
"src/codegen/ppc/constants-ppc.h",
"src/codegen/ppc/cpu-ppc.cc",
"src/codegen/ppc/interface-descriptors-ppc.cc",
"src/codegen/ppc/macro-assembler-ppc.cc",
"src/codegen/ppc/macro-assembler-ppc.h",
"src/codegen/ppc/register-ppc.h",
"src/compiler/backend/ppc/code-generator-ppc.cc",
"src/compiler/backend/ppc/instruction-codes-ppc.h",
"src/compiler/backend/ppc/instruction-scheduler-ppc.cc",
"src/compiler/backend/ppc/instruction-selector-ppc.cc",
"src/compiler/backend/ppc/unwinding-info-writer-ppc.cc",
"src/compiler/backend/ppc/unwinding-info-writer-ppc.h",
"src/debug/ppc/debug-ppc.cc",
"src/deoptimizer/ppc/deoptimizer-ppc.cc",
"src/diagnostics/ppc/disasm-ppc.cc",
"src/diagnostics/ppc/eh-frame-ppc.cc",
"src/execution/ppc/frame-constants-ppc.cc",
"src/execution/ppc/frame-constants-ppc.h",
"src/execution/ppc/simulator-ppc.cc",
Expand Down
4 changes: 4 additions & 0 deletions deps/v8/gni/snapshot_toolchain.gni
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ if (v8_snapshot_toolchain == "") {
}
} else if (v8_current_cpu == "arm" || v8_current_cpu == "mipsel") {
_cpus = "x86_v8_${v8_current_cpu}"
} else if (v8_current_cpu == "ppc") {
# reset clang to use gcc toolchain
_clang = ""
_cpus = "${v8_current_cpu}"
} else {
# This branch should not be reached; leave _cpus blank so the assert
# below will fail.
Expand Down
17 changes: 8 additions & 9 deletions deps/v8/src/base/build_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@
#elif defined(__MIPSEB__) || defined(__MIPSEL__)
#define V8_HOST_ARCH_MIPS 1
#define V8_HOST_ARCH_32_BIT 1
#elif defined(__PPC64__) || defined(_ARCH_PPC64)
#define V8_HOST_ARCH_PPC64 1
#define V8_HOST_ARCH_64_BIT 1
#elif defined(__PPC__) || defined(_ARCH_PPC)
#define V8_HOST_ARCH_PPC 1
#if defined(__PPC64__) || defined(_ARCH_PPC64)
#define V8_HOST_ARCH_64_BIT 1
#else
#define V8_HOST_ARCH_32_BIT 1
#endif
#elif defined(__s390__) || defined(__s390x__)
#define V8_HOST_ARCH_S390 1
#if defined(__s390x__)
Expand Down Expand Up @@ -78,7 +77,7 @@
// environment as presented by the compiler.
#if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM && \
!V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS && !V8_TARGET_ARCH_MIPS64 && \
!V8_TARGET_ARCH_PPC && !V8_TARGET_ARCH_S390
!V8_TARGET_ARCH_PPC && !V8_TARGET_ARCH_PPC64 && !V8_TARGET_ARCH_S390
#if defined(_M_X64) || defined(__x86_64__)
#define V8_TARGET_ARCH_X64 1
#elif defined(_M_IX86) || defined(__i386__)
Expand All @@ -91,6 +90,8 @@
#define V8_TARGET_ARCH_MIPS64 1
#elif defined(__MIPSEB__) || defined(__MIPSEL__)
#define V8_TARGET_ARCH_MIPS 1
#elif defined(_ARCH_PPC64)
#define V8_TARGET_ARCH_PPC64 1
#elif defined(_ARCH_PPC)
#define V8_TARGET_ARCH_PPC 1
#else
Expand Down Expand Up @@ -118,11 +119,9 @@
#elif V8_TARGET_ARCH_MIPS64
#define V8_TARGET_ARCH_64_BIT 1
#elif V8_TARGET_ARCH_PPC
#if V8_TARGET_ARCH_PPC64
#define V8_TARGET_ARCH_64_BIT 1
#else
#define V8_TARGET_ARCH_32_BIT 1
#endif
#elif V8_TARGET_ARCH_PPC64
#define V8_TARGET_ARCH_64_BIT 1
#elif V8_TARGET_ARCH_S390
#if V8_TARGET_ARCH_S390X
#define V8_TARGET_ARCH_64_BIT 1
Expand Down
8 changes: 5 additions & 3 deletions deps/v8/src/base/cpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#if V8_OS_QNX
#include <sys/syspage.h> // cpuinfo
#endif
#if V8_OS_LINUX && V8_HOST_ARCH_PPC
#if (V8_OS_LINUX && (V8_HOST_ARCH_PPC || V8_HOST_ARCH_PPC64))
#include <elf.h>
#endif
#if V8_OS_AIX
Expand Down Expand Up @@ -607,7 +607,7 @@ CPU::CPU()
#elif V8_HOST_ARCH_ARM64
// Implementer, variant and part are currently unused under ARM64.

#elif V8_HOST_ARCH_PPC
#elif V8_HOST_ARCH_PPC || V8_HOST_ARCH_PPC64

#ifndef USE_SIMULATOR
#if V8_OS_LINUX
Expand Down Expand Up @@ -659,6 +659,8 @@ CPU::CPU()
part_ = PPC_G5;
} else if (strcmp(auxv_cpu_type, "ppc7450") == 0) {
part_ = PPC_G4;
} else if (strcmp(auxv_cpu_type, "ppc440") == 0) {
part_ = PPC_G4;
} else if (strcmp(auxv_cpu_type, "pa6t") == 0) {
part_ = PPC_PA6T;
}
Expand Down Expand Up @@ -687,7 +689,7 @@ CPU::CPU()
}
#endif // V8_OS_AIX
#endif // !USE_SIMULATOR
#endif // V8_HOST_ARCH_PPC
#endif // V8_HOST_ARCH_PPC || V8_HOST_ARCH_PPC64
}

} // namespace base
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/base/debug/stack_trace_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <string>
#include <vector>

#if V8_LIBC_GLIBC || V8_LIBC_BSD || V8_LIBC_UCLIBC || V8_OS_SOLARIS
#if V8_LIBC_GLIBC || V8_LIBC_BSD || ( V8_LIBC_UCLIBC && __UCLIBC_HAS_BACKTRACE__ ) || V8_OS_SOLARIS
#define HAVE_EXECINFO_H 1
#endif

Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/base/platform/platform-posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ void OS::DebugBreak() {
asm("break");
#elif V8_HOST_ARCH_MIPS64
asm("break");
#elif V8_HOST_ARCH_PPC
#elif V8_HOST_ARCH_PPC || V8_HOST_ARCH_PPC64
asm("twge 2,2");
#elif V8_HOST_ARCH_IA32
asm("int $3");
Expand Down
33 changes: 20 additions & 13 deletions deps/v8/src/builtins/ppc/builtins-ppc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#if V8_TARGET_ARCH_PPC
#if V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64

#include "src/api/api-arguments.h"
#include "src/codegen/code-factory.h"
Expand Down Expand Up @@ -2807,7 +2807,7 @@ void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size,
}

void Builtins::Generate_DoubleToI(MacroAssembler* masm) {
Label out_of_range, only_low, negate, done, fastpath_done;
Label out_of_range, only_low, negate, done, fastpath_done, conv_inv, conv_ok;
Register result_reg = r3;

HardAbortScope hard_abort(masm); // Avoid calls to Abort.
Expand All @@ -2818,7 +2818,11 @@ void Builtins::Generate_DoubleToI(MacroAssembler* masm) {
Register scratch_high =
GetRegisterThatIsNotOneOf(result_reg, scratch, scratch_low);
DoubleRegister double_scratch = kScratchDoubleReg;

#if !V8_TARGET_ARCH_PPC64
CRegister cr = cr7;
int crbit = v8::internal::Assembler::encode_crbit(
cr, static_cast<CRBit>(VXCVI % CRWIDTH));
#endif
__ Push(result_reg, scratch);
// Account for saved regs.
int argument_offset = 2 * kPointerSize;
Expand All @@ -2827,17 +2831,20 @@ void Builtins::Generate_DoubleToI(MacroAssembler* masm) {
__ lfd(double_scratch, MemOperand(sp, argument_offset));

// Do fast-path convert from double to int.
__ ConvertDoubleToInt64(double_scratch,
#if !V8_TARGET_ARCH_PPC64
scratch,
#endif
result_reg, d0);

// Test for overflow
#if V8_TARGET_ARCH_PPC64
__ TestIfInt32(result_reg, r0);
__ mtfsb0(VXCVI);
__ ConvertDoubleToInt32NoPPC64(double_scratch, result_reg, scratch);
__ mcrfs(cr, VXCVI);
__ bc(__ branch_offset(&conv_inv), BT, crbit);
__ addi(scratch, result_reg, Operand(0));
__ b(&conv_ok);
__ bind(&conv_inv);
__ addi(scratch, result_reg, Operand(1));
__ bind(&conv_ok);
__ cmp(scratch, result_reg, cr);
#else
__ TestIfInt32(scratch, result_reg, r0);
__ ConvertDoubleToInt64(double_scratch, result_reg, d0);
__ TestIfInt32(result_reg, r0);
#endif
__ beq(&fastpath_done);

Expand Down Expand Up @@ -3337,4 +3344,4 @@ void Builtins::Generate_DirectCEntry(MacroAssembler* masm) {
} // namespace internal
} // namespace v8

#endif // V8_TARGET_ARCH_PPC
#endif // V8_TARGET_ARCH_PPC64 || V8_TARGET_ARCH_PPC64
2 changes: 1 addition & 1 deletion deps/v8/src/codegen/assembler-arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "src/codegen/arm64/assembler-arm64.h"
#elif V8_TARGET_ARCH_ARM
#include "src/codegen/arm/assembler-arm.h"
#elif V8_TARGET_ARCH_PPC
#elif V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64
#include "src/codegen/ppc/assembler-ppc.h"
#elif V8_TARGET_ARCH_MIPS
#include "src/codegen/mips/assembler-mips.h"
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/codegen/assembler-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "src/codegen/arm64/assembler-arm64-inl.h"
#elif V8_TARGET_ARCH_ARM
#include "src/codegen/arm/assembler-arm-inl.h"
#elif V8_TARGET_ARCH_PPC
#elif V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64
#include "src/codegen/ppc/assembler-ppc-inl.h"
#elif V8_TARGET_ARCH_MIPS
#include "src/codegen/mips/assembler-mips-inl.h"
Expand Down
4 changes: 2 additions & 2 deletions deps/v8/src/codegen/constant-pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace v8 {
namespace internal {

#if defined(V8_TARGET_ARCH_PPC)
#if defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_PPC64)

ConstantPoolBuilder::ConstantPoolBuilder(int ptr_reach_bits,
int double_reach_bits) {
Expand Down Expand Up @@ -209,7 +209,7 @@ int ConstantPoolBuilder::Emit(Assembler* assm) {
return !empty ? (assm->pc_offset() - emitted_label_.pos()) : 0;
}

#endif // defined(V8_TARGET_ARCH_PPC)
#endif // defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_PPC64)

#if defined(V8_TARGET_ARCH_ARM64)

Expand Down
4 changes: 2 additions & 2 deletions deps/v8/src/codegen/constant-pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class ConstantPoolEntry {
enum { SHARING_PROHIBITED = -2, SHARING_ALLOWED = -1 };
};

#if defined(V8_TARGET_ARCH_PPC)
#if defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_PPC64)

// -----------------------------------------------------------------------------
// Embedded constant pool support
Expand Down Expand Up @@ -162,7 +162,7 @@ class ConstantPoolBuilder {
PerTypeEntryInfo info_[ConstantPoolEntry::NUMBER_OF_TYPES];
};

#endif // defined(V8_TARGET_ARCH_PPC)
#endif // defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_PPC64)

#if defined(V8_TARGET_ARCH_ARM64)

Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/codegen/constants-arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "src/codegen/mips/constants-mips.h" // NOLINT
#elif V8_TARGET_ARCH_MIPS64
#include "src/codegen/mips64/constants-mips64.h" // NOLINT
#elif V8_TARGET_ARCH_PPC
#elif V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64
#include "src/codegen/ppc/constants-ppc.h" // NOLINT
#elif V8_TARGET_ARCH_S390
#include "src/codegen/s390/constants-s390.h" // NOLINT
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/codegen/external-reference.cc
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ ExternalReference ExternalReference::invoke_accessor_getter_callback() {
#define re_stack_check_func RegExpMacroAssemblerARM64::CheckStackGuardState
#elif V8_TARGET_ARCH_ARM
#define re_stack_check_func RegExpMacroAssemblerARM::CheckStackGuardState
#elif V8_TARGET_ARCH_PPC
#elif V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64
#define re_stack_check_func RegExpMacroAssemblerPPC::CheckStackGuardState
#elif V8_TARGET_ARCH_MIPS
#define re_stack_check_func RegExpMacroAssemblerMIPS::CheckStackGuardState
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/codegen/macro-assembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ enum AllocationFlags {
#elif V8_TARGET_ARCH_ARM
#include "src/codegen/arm/constants-arm.h"
#include "src/codegen/arm/macro-assembler-arm.h"
#elif V8_TARGET_ARCH_PPC
#elif V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64
#include "src/codegen/ppc/constants-ppc.h"
#include "src/codegen/ppc/macro-assembler-ppc.h"
#elif V8_TARGET_ARCH_MIPS
Expand Down
Loading

0 comments on commit 3a4f6d9

Please sign in to comment.