From 647e67b23883960fef8890465c0f70d7ab6e63f1 Mon Sep 17 00:00:00 2001 From: zhaixiang Date: Sun, 4 Sep 2022 20:56:30 -0700 Subject: [PATCH] Initial Linux/LoongArch64 Port https://bugs.webkit.org/show_bug.cgi?id=244664 Reviewed by Michael Catanzaro. * Source/JavaScriptCore/CMakeLists.txt: * Source/WTF/wtf/PageBlock.h: * Source/WTF/wtf/PlatformCPU.h: * Source/WTF/wtf/dtoa/utils.h: * Source/cmake/WebKitCommon.cmake: Canonical link: https://commits.webkit.org/254155@main --- Source/JavaScriptCore/CMakeLists.txt | 6 +++++- Source/WTF/wtf/PageBlock.h | 2 +- Source/WTF/wtf/PlatformCPU.h | 6 ++++++ Source/WTF/wtf/dtoa/utils.h | 1 + Source/cmake/WebKitCommon.cmake | 2 ++ 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Source/JavaScriptCore/CMakeLists.txt b/Source/JavaScriptCore/CMakeLists.txt index 033a85b20858..f4919e6e8523 100644 --- a/Source/JavaScriptCore/CMakeLists.txt +++ b/Source/JavaScriptCore/CMakeLists.txt @@ -1436,7 +1436,11 @@ WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS() if (COMPILER_IS_GCC_OR_CLANG) # Avoid using fused multiply-add instructions since this could give different results # for e.g. parseInt depending on the platform and compilation flags. - WEBKIT_ADD_TARGET_CXX_FLAGS(JavaScriptCore -ffp-contract=off -fno-slp-vectorize) + if (WTF_CPU_LOONGARCH64) + WEBKIT_ADD_TARGET_CXX_FLAGS(JavaScriptCore -ffp-contract=off) + else () + WEBKIT_ADD_TARGET_CXX_FLAGS(JavaScriptCore -ffp-contract=off -fno-slp-vectorize) + endif () # On MIPS we have to explicitly disable madd4, since some versions of gcc still generate # such instructions despite -ffp-contract=off diff --git a/Source/WTF/wtf/PageBlock.h b/Source/WTF/wtf/PageBlock.h index 37796c0cedd3..4c73f5abe2f4 100644 --- a/Source/WTF/wtf/PageBlock.h +++ b/Source/WTF/wtf/PageBlock.h @@ -49,7 +49,7 @@ namespace WTF { // aarch64 by default. USE(64KB_PAGE_BLOCK) allows overriding this. // // Use 64 KiB for any unknown CPUs to be conservative. -#if OS(DARWIN) || PLATFORM(PLAYSTATION) || CPU(MIPS) || CPU(MIPS64) || (OS(LINUX) && CPU(ARM64) && !USE(64KB_PAGE_BLOCK)) +#if OS(DARWIN) || PLATFORM(PLAYSTATION) || CPU(MIPS) || CPU(MIPS64) || CPU(LOONGARCH64) || (OS(LINUX) && CPU(ARM64) && !USE(64KB_PAGE_BLOCK)) constexpr size_t CeilingOnPageSize = 16 * KB; #elif USE(64KB_PAGE_BLOCK) || CPU(PPC) || CPU(PPC64) || CPU(PPC64LE) || CPU(UNKNOWN) constexpr size_t CeilingOnPageSize = 64 * KB; diff --git a/Source/WTF/wtf/PlatformCPU.h b/Source/WTF/wtf/PlatformCPU.h index 238334178676..58cf04f4d788 100644 --- a/Source/WTF/wtf/PlatformCPU.h +++ b/Source/WTF/wtf/PlatformCPU.h @@ -55,6 +55,12 @@ #define WTF_MIPS_FP64 (defined __mips_fpr && __mips_fpr == 64) #endif +/* CPU(LOONGARCH64) - LOONGARCH64 */ +#if defined(__loongarch64) +#define WTF_CPU_LOONGARCH64 1 +#define WTF_CPU_KNOWN 1 +#endif + /* CPU(PPC64) - PowerPC 64-bit Big Endian */ #if ( defined(__ppc64__) \ || defined(__PPC64__)) \ diff --git a/Source/WTF/wtf/dtoa/utils.h b/Source/WTF/wtf/dtoa/utils.h index 96d5bd7b5568..aa0786de10cb 100644 --- a/Source/WTF/wtf/dtoa/utils.h +++ b/Source/WTF/wtf/dtoa/utils.h @@ -83,6 +83,7 @@ int main(int argc, char** argv) { defined(__ARMEL__) || defined(__avr32__) || defined(_M_ARM) || defined(_M_ARM64) || \ defined(__hppa__) || defined(__ia64__) || \ defined(__mips__) || \ + defined(__loongarch__) || \ defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__) || \ defined(_POWER) || defined(_ARCH_PPC) || defined(_ARCH_PPC64) || \ defined(__sparc__) || defined(__sparc) || defined(__s390__) || \ diff --git a/Source/cmake/WebKitCommon.cmake b/Source/cmake/WebKitCommon.cmake index 4cf232376155..bbf4b25f6df5 100644 --- a/Source/cmake/WebKitCommon.cmake +++ b/Source/cmake/WebKitCommon.cmake @@ -119,6 +119,8 @@ if (NOT HAS_RUN_WEBKIT_COMMON) set(WTF_CPU_PPC64LE 1) elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^riscv64") set(WTF_CPU_RISCV64 1) + elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "^loongarch64") + set(WTF_CPU_LOONGARCH64 1) else () set(WTF_CPU_UNKNOWN 1) endif ()