From dd1b13a50b55652253cc04cc3fa52d2280f1da56 Mon Sep 17 00:00:00 2001 From: Kimmo Ollila Date: Wed, 25 Apr 2018 12:57:55 +0300 Subject: Enable JIT on INTEGRITY ARM64 This patch enables JIT on INTEGRITY s820Am and other ARM64 builds Change-Id: I2fa130f41a6c5bc6aa86bcfd5a01c2d431300561 Reviewed-by: Simon Hausmann Reviewed-by: Nikola Velinov --- src/3rdparty/masm/assembler/ARM64Assembler.h | 6 ++++++ src/3rdparty/masm/stubs/ExecutableAllocator.h | 8 ++++++++ src/3rdparty/masm/wtf/OSAllocator.h | 4 ++++ src/3rdparty/masm/wtf/OSAllocatorIntegrity.cpp | 12 ++++++++++++ src/3rdparty/masm/wtf/Platform.h | 5 +++++ src/qml/jsruntime/qv4global_p.h | 2 +- 6 files changed, 36 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/3rdparty/masm/assembler/ARM64Assembler.h b/src/3rdparty/masm/assembler/ARM64Assembler.h index 008f03bccf..1787e921e8 100644 --- a/src/3rdparty/masm/assembler/ARM64Assembler.h +++ b/src/3rdparty/masm/assembler/ARM64Assembler.h @@ -39,6 +39,10 @@ #include #endif +#if OS(INTEGRITY) +#include +#endif + #define CHECK_DATASIZE_OF(datasize) ASSERT(datasize == 32 || datasize == 64) #define DATASIZE_OF(datasize) ((datasize == 64) ? Datasize_64 : Datasize_32) #define MEMOPSIZE_OF(datasize) ((datasize == 8 || datasize == 128) ? MemOpSize_8_or_128 : (datasize == 16) ? MemOpSize_16 : (datasize == 32) ? MemOpSize_32 : MemOpSize_64) @@ -3039,6 +3043,8 @@ public: UNUSED_PARAM(code); UNUSED_PARAM(size); #endif +#elif OS(INTEGRITY) + ManageCaches((Address)code, size, ACCESS_DST_COHERENT); #else #error "The cacheFlush support is missing on this platform." #endif diff --git a/src/3rdparty/masm/stubs/ExecutableAllocator.h b/src/3rdparty/masm/stubs/ExecutableAllocator.h index 3b84b5c986..1ab28588fb 100644 --- a/src/3rdparty/masm/stubs/ExecutableAllocator.h +++ b/src/3rdparty/masm/stubs/ExecutableAllocator.h @@ -45,6 +45,10 @@ #include +#if OS(INTEGRITY) +#include "OSAllocator.h" +#endif + #if OS(WINDOWS) #include #else @@ -118,6 +122,8 @@ struct ExecutableAllocator { Q_UNREACHABLE(); } # endif +# elif OS(INTEGRITY) + OSAllocator::setMemoryAttributes(addr, /*writable*/ true, /*executable*/ false); # else int mode = PROT_READ | PROT_WRITE; if (mprotect(addr, size, mode) != 0) { @@ -152,6 +158,8 @@ struct ExecutableAllocator { Q_UNREACHABLE(); } # endif +# elif OS(INTEGRITY) + OSAllocator::setMemoryAttributes(addr, /*writable*/ false, /*executable*/ true); # else int mode = PROT_READ | PROT_EXEC; if (mprotect(addr, size, mode) != 0) { diff --git a/src/3rdparty/masm/wtf/OSAllocator.h b/src/3rdparty/masm/wtf/OSAllocator.h index 933b3cda0a..366dd73993 100644 --- a/src/3rdparty/masm/wtf/OSAllocator.h +++ b/src/3rdparty/masm/wtf/OSAllocator.h @@ -73,6 +73,10 @@ public: static T* reallocateCommitted(T*, size_t oldSize, size_t newSize, Usage = UnknownUsage, bool writable = true, bool executable = false); static bool canAllocateExecutableMemory(); + +#if defined(Q_OS_INTEGRITY) + static void setMemoryAttributes(void* addr, bool writable, bool executable); +#endif }; inline void* OSAllocator::reserveAndCommit(size_t reserveSize, size_t commitSize, Usage usage, bool writable, bool executable) diff --git a/src/3rdparty/masm/wtf/OSAllocatorIntegrity.cpp b/src/3rdparty/masm/wtf/OSAllocatorIntegrity.cpp index 451ca147d1..7addf9e5c2 100644 --- a/src/3rdparty/masm/wtf/OSAllocatorIntegrity.cpp +++ b/src/3rdparty/masm/wtf/OSAllocatorIntegrity.cpp @@ -123,6 +123,12 @@ Error setAttributes(MemoryRegion mr, bool writable, bool executable) return SetMemoryRegionAttributes(mr, attributes); } +void OSAllocator::setMemoryAttributes(void* addr, bool writable, bool executable) +{ + const MRPair* pair = memoryRegionsContainer.getMRPair((Address)addr); + CheckSuccess(setAttributes(pair->vmr, writable, executable)); +} + void* OSAllocator::reserveUncommitted(size_t bytes, Usage usage, bool writable, bool executable) { MemoryRegion VMR; @@ -229,4 +235,10 @@ void OSAllocator::releaseDecommitted(void* address, size_t bytes) memoryRegionsContainer.deleteMRPair(pair); } } + +bool OSAllocator::canAllocateExecutableMemory() +{ + return true; +} + } // namespace WTF diff --git a/src/3rdparty/masm/wtf/Platform.h b/src/3rdparty/masm/wtf/Platform.h index 4f37245495..5905f42f45 100644 --- a/src/3rdparty/masm/wtf/Platform.h +++ b/src/3rdparty/masm/wtf/Platform.h @@ -171,6 +171,11 @@ #define WTF_CPU_ARM64 1 #endif +/* CPU(ARM64) - INTEGRITY */ +#if (defined(__ARM64__)) +#define WTF_CPU_ARM64 1 +#endif + /* CPU(ARM) - ARM, any version*/ #define WTF_ARM_ARCH_AT_LEAST(N) (CPU(ARM) && WTF_ARM_ARCH_VERSION >= N) diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h index 9b13d4e341..1fa4bae049 100644 --- a/src/qml/jsruntime/qv4global_p.h +++ b/src/qml/jsruntime/qv4global_p.h @@ -101,7 +101,7 @@ inline double trunc(double d) { return d > 0 ? floor(d) : ceil(d); } # define V4_ENABLE_JIT # endif #elif defined(Q_PROCESSOR_ARM_64) && (QT_POINTER_SIZE == 8) -# if defined(Q_OS_LINUX) || defined(Q_OS_QNX) +# if defined(Q_OS_LINUX) || defined(Q_OS_QNX) || defined(Q_OS_INTEGRITY) # define V4_ENABLE_JIT # endif //#elif defined(Q_PROCESSOR_MIPS_32) && defined(Q_OS_LINUX) -- cgit v1.2.3