forked from react-native-community/jsc-android-buildscripts
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround JIT crash on arm64, especially for Saumsung S7 Edge
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
diff -aur target-org/webkit/Source/JavaScriptCore/assembler/ARM64Assembler.h target/webkit/Source/JavaScriptCore/assembler/ARM64Assembler.h | ||
--- target-org/webkit/Source/JavaScriptCore/assembler/ARM64Assembler.h 2018-08-20 20:52:54.000000000 +0800 | ||
+++ target/webkit/Source/JavaScriptCore/assembler/ARM64Assembler.h 2019-05-28 13:50:53.000000000 +0800 | ||
@@ -2852,7 +2852,36 @@ | ||
|
||
unsigned debugOffset() { return m_buffer.debugOffset(); } | ||
|
||
-#if OS(LINUX) && COMPILER(GCC_OR_CLANG) | ||
+#if defined(CUSTOMIZE_REACT_NATIVE) | ||
+ static inline void linuxPageFlush(uintptr_t start, uintptr_t end) | ||
+ { | ||
+ // NOTE(CUSTOMIZE_REACT_NATIVE): The code mostly copied from LLVM compiler-rt | ||
+ // https://github.com/llvm-mirror/compiler-rt/blob/ff75f2a0260b1940436a483413091c5770427c04/lib/builtins/clear_cache.c#L142 | ||
+ // But only to modify "dc cvau" to "dc civac" | ||
+ | ||
+ uint64_t xstart = (uint64_t)(uintptr_t)start; | ||
+ uint64_t xend = (uint64_t)(uintptr_t)end; | ||
+ uint64_t addr; | ||
+ | ||
+ // Get Cache Type Info | ||
+ uint64_t ctr_el0; | ||
+ __asm __volatile("mrs %0, ctr_el0" : "=r"(ctr_el0)); | ||
+ | ||
+ // dc & ic instructions must use 64bit registers so we don't use | ||
+ // uintptr_t in case this runs in an IPL32 environment. | ||
+ const size_t dcache_line_size = 4 << ((ctr_el0 >> 16) & 15); | ||
+ for (addr = xstart & ~(dcache_line_size - 1); addr < xend; | ||
+ addr += dcache_line_size) | ||
+ __asm __volatile("dc civac, %0" ::"r"(addr)); | ||
+ __asm __volatile("dsb ish"); | ||
+ | ||
+ const size_t icache_line_size = 4 << ((ctr_el0 >> 0) & 15); | ||
+ for (addr = xstart & ~(icache_line_size - 1); addr < xend; | ||
+ addr += icache_line_size) | ||
+ __asm __volatile("ic ivau, %0" ::"r"(addr)); | ||
+ __asm __volatile("isb sy"); | ||
+ } | ||
+#elif OS(LINUX) && COMPILER(GCC_OR_CLANG) | ||
static inline void linuxPageFlush(uintptr_t begin, uintptr_t end) | ||
{ | ||
__builtin___clear_cache(reinterpret_cast<char*>(begin), reinterpret_cast<char*>(end)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters