Skip to content

Commit

Permalink
Initial Linux/LoongArch64 Port
Browse files Browse the repository at this point in the history
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
  • Loading branch information
xiangzhai authored and mcatanzaro committed Sep 5, 2022
1 parent 3a16b3c commit 647e67b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Source/JavaScriptCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Source/WTF/wtf/PageBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions Source/WTF/wtf/PlatformCPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__)) \
Expand Down
1 change: 1 addition & 0 deletions Source/WTF/wtf/dtoa/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__) || \
Expand Down
2 changes: 2 additions & 0 deletions Source/cmake/WebKitCommon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down

0 comments on commit 647e67b

Please sign in to comment.