From 4566d37810ca3056798848a44947e385f20063a2 Mon Sep 17 00:00:00 2001 From: "Mikhail R. Gadelha" Date: Mon, 27 Feb 2023 20:16:21 -0800 Subject: [PATCH 1/2] [JSC][32bit] Fix JIT being disabled when compiling JSC on linux with clang https://bugs.webkit.org/show_bug.cgi?id=234034 Reviewed by Justin Michaud. JIT was always disabled when building JSC with clang on linux 32 bits because CMake checked if the compiler defined __thumb2__ and while gcc does define it by default, clang doesn't. This patch adds extra compilation flags when compiling JSC with clang for arm (except on Darwin), so the expected __thumb2__ define is defined and JIT is enabled. Also some minor changes: (1) this patch also adds __ARM_ARCH_8__ and __ARM_ARCH_8A__ to the list that sets BTHUMB_ARCH_VERSION and WTF_THUMB_ARCH_VERSION to 4. These two seem to be used mostly for sanity check. (2) a small fix in AirArg where clang complains about a missing typename. gcc seems to accept either. * Source/JavaScriptCore/b3/air/AirArg.h: (JSC::B3::Air::Arg::isValidAddrForm): * Source/JavaScriptCore/wasm/WasmAirIRGeneratorBase.h: (JSC::Wasm::parseAndCompileAirImpl): * Source/WTF/wtf/PlatformCPU.h: * Source/bmalloc/bmalloc/BPlatform.h: * Source/cmake/OptionsCommon.cmake: Canonical link: https://commits.webkit.org/260921@main --- Source/WTF/wtf/PlatformCPU.h | 4 +++- Source/bmalloc/bmalloc/BPlatform.h | 4 +++- Source/cmake/OptionsCommon.cmake | 13 ++++++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Source/WTF/wtf/PlatformCPU.h b/Source/WTF/wtf/PlatformCPU.h index fd4dad9aeeca9..e5c41a0ce6e74 100644 --- a/Source/WTF/wtf/PlatformCPU.h +++ b/Source/WTF/wtf/PlatformCPU.h @@ -213,7 +213,9 @@ || defined(__ARM_ARCH_7K__) \ || defined(__ARM_ARCH_7M__) \ || defined(__ARM_ARCH_7R__) \ - || defined(__ARM_ARCH_7S__) + || defined(__ARM_ARCH_7S__) \ + || defined(__ARM_ARCH_8__) \ + || defined(__ARM_ARCH_8A__) #define WTF_THUMB_ARCH_VERSION 4 /* RVCT sets __TARGET_ARCH_THUMB */ diff --git a/Source/bmalloc/bmalloc/BPlatform.h b/Source/bmalloc/bmalloc/BPlatform.h index 0eae025bc8253..c1d8225126fd9 100644 --- a/Source/bmalloc/bmalloc/BPlatform.h +++ b/Source/bmalloc/bmalloc/BPlatform.h @@ -227,7 +227,9 @@ || defined(__ARM_ARCH_7K__) \ || defined(__ARM_ARCH_7M__) \ || defined(__ARM_ARCH_7R__) \ -|| defined(__ARM_ARCH_7S__) +|| defined(__ARM_ARCH_7S__) \ +|| defined(__ARM_ARCH_8__) \ +|| defined(__ARM_ARCH_8A__) #define BTHUMB_ARCH_VERSION 4 /* RVCT sets __TARGET_ARCH_THUMB */ diff --git a/Source/cmake/OptionsCommon.cmake b/Source/cmake/OptionsCommon.cmake index e742570346936..b04f768859ccb 100644 --- a/Source/cmake/OptionsCommon.cmake +++ b/Source/cmake/OptionsCommon.cmake @@ -16,9 +16,20 @@ if (WTF_CPU_ARM) #error \"Thumb2 instruction set isn't available\" #endif int main() {} - ") + ") + if (COMPILER_IS_CLANG AND NOT (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")) + set(CLANG_EXTRA_ARM_ARGS " -mthumb") + endif () + + set(CMAKE_REQUIRED_FLAGS "${CLANG_EXTRA_ARM_ARGS}") CHECK_CXX_SOURCE_COMPILES("${ARM_THUMB2_TEST_SOURCE}" ARM_THUMB2_DETECTED) + unset(CMAKE_REQUIRED_FLAGS) + + if (ARM_THUMB2_DETECTED AND NOT (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")) + string(APPEND CMAKE_C_FLAGS " ${CLANG_EXTRA_ARM_ARGS}") + string(APPEND CMAKE_CXX_FLAGS " ${CLANG_EXTRA_ARM_ARGS}") + endif () endif () # Use ld.lld when building with LTO, or for debug builds, if available. From 5627dbdf55d764372633e02262433bb3bc2bb6ac Mon Sep 17 00:00:00 2001 From: Justin Michaud Date: Sun, 25 Jan 2026 17:12:18 -0800 Subject: [PATCH 2/2] [ARMv7] Fix clang20 build https://bugs.webkit.org/show_bug.cgi?id=306182 Reviewed by Yusuke Suzuki. See WebPlatformForEmbedded#1600. We fix this build error: ``` :320:49: error: Relocation Not In Range 320 | movw r4, #:lower16:.Lllint_op_tail_call_varargs - .Lllint_relativePCBase | ^ :321:49: error: Relocation Not In Range 321 | movt r4, #:upper16:.Lllint_op_tail_call_varargs - .Lllint_relativePCBase ... by emiting a worse sequence, a jump + data + a pc-relative load. This is only emitted at startup, so the perf impact should be minimal. * Source/JavaScriptCore/offlineasm/arm.rb: Canonical link: https://commits.webkit.org/306181@main --- Source/JavaScriptCore/offlineasm/arm.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Source/JavaScriptCore/offlineasm/arm.rb b/Source/JavaScriptCore/offlineasm/arm.rb index a6f18229b54f3..509efd0f7e6b4 100644 --- a/Source/JavaScriptCore/offlineasm/arm.rb +++ b/Source/JavaScriptCore/offlineasm/arm.rb @@ -756,8 +756,14 @@ def lowerARMCommon armMoveImmediate(operands[0].value >> 32, operands[1]) armMoveImmediate(operands[0].value & 0xffffffff, operands[2]) when "mvlbl" - $asm.puts "movw #{operands[1].armOperand}, \#:lower16:#{operands[0].value}" - $asm.puts "movt #{operands[1].armOperand}, \#:upper16:#{operands[0].value}" + afterData = LocalLabel.unique("mvlbl") + data = LocalLabel.unique("mvlbl") + $asm.puts "b #{LocalLabelReference.new(codeOrigin, afterData).asmLabel}" + $asm.puts ".align 1" + data.lower("ARM") + $asm.puts ".word #{operands[0].value}" + afterData.lower("ARM") + $asm.puts "ldr #{operands[1].armOperand}, #{LocalLabelReference.new(codeOrigin, data).asmLabel}" when "sxb2i" $asm.puts "sxtb #{armFlippedOperands(operands)}" when "sxh2i" @@ -998,4 +1004,3 @@ def lowerARMCommon end end end -