-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade to WebkitGTK 2.24.2 and workaround __clear_cache issue o… (#114)
# Summary This PR includes three major changes: 1. Enable JIT back Community reported sensible performance drop from the no-JIT version, so I'd like to enable JIT back. 2. Upgrade to WebKitGTK 2.24.2. This seems to fix previous JSC crashes on Samsung S7 Edge. This version includes JIT new bytecode format as described from WebKit blog: https://webkit.org/blog/9329/a-new-bytecode-format-for-javascriptcore/ After the major change, x86 JIT is not supported and arm32 support was contributed by WebKit community (Thanks to Igalia). From my understanding, original JSC crashes happen at `operationLinkDirectCall()`. After the new bytecode format, there is no direct link call from Baseline JIT. Since we've disabled DFG JIT and FTL JIT, there's no call flow that will hit to `operationLinkDirectCall()`. That is why no more similar crash happens. 3. Workaround for ARM Cortex-A53 cache flush instruction issue: This is from V8's workaround and I believe it is worth to apply into JSC Android as well. https://codereview.chromium.org/1921173004 ARM Cortex-A53 had some errata for original "cvau" instruction, and officially recommended to use "civac" instruction instead. LLVM compiler-rt's `__clear_cache` still uses "cvau" and my patch replaced to "civac". ## Test Plan 1. Run measure scripts on my Samsung Note 5. 2. Provide an [experimented version](https://www.npmjs.com/package/@kudo-ci/jsc-android/v/245459.9000.0) for community who previously reported JSC crash and seems no more crashes happened. ## Measurement Added "@kudo-ci/jsc-android@245459-no-dfg-jit" to previous measurement result. The new result could compared to 241213-no-dfg-jit version. There are some performance improvement from the comparison. https://docs.google.com/spreadsheets/d/1hqX3ai-NCpN_J6YQDTKnKNBctWnMFA6EyOdVhPvwUas/edit#gid=193471288 <img width="735" alt="Screen Shot 2019-06-24 at 11 46 00 PM" src="https://user-images.githubusercontent.com/46429/60032978-44a1c480-96da-11e9-9eca-863aae3efe05.png"> <img width="413" alt="Screen Shot 2019-06-24 at 11 45 16 PM" src="https://user-images.githubusercontent.com/46429/60032980-44a1c480-96da-11e9-8f41-df30fa74235b.png"> <img width="414" alt="Screen Shot 2019-06-24 at 11 45 08 PM" src="https://user-images.githubusercontent.com/46429/60032981-453a5b00-96da-11e9-92a3-63318a7bb5fa.png"> <img width="427" alt="Screen Shot 2019-06-24 at 11 45 00 PM" src="https://user-images.githubusercontent.com/46429/60032982-453a5b00-96da-11e9-8d63-453ecc94c827.png"> <img width="426" alt="Screen Shot 2019-06-24 at 11 44 56 PM" src="https://user-images.githubusercontent.com/46429/60032983-453a5b00-96da-11e9-86c4-e5db0f6d86a9.png">
- Loading branch information
Showing
16 changed files
with
126 additions
and
106 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
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
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
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
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 2019-06-18 21:49:21.000000000 +0800 | ||
+++ target/webkit/Source/JavaScriptCore/assembler/ARM64Assembler.h 2019-06-19 15:14:46.000000000 +0800 | ||
@@ -2863,7 +2863,36 @@ | ||
|
||
unsigned debugOffset() { return m_buffer.debugOffset(); } | ||
|
||
-#if OS(LINUX) && COMPILER(GCC_COMPATIBLE) | ||
+#if defined(CUSTOMIZE_REACT_NATIVE) && CPU(ARM64) | ||
+ 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_COMPATIBLE) | ||
static inline void linuxPageFlush(uintptr_t begin, uintptr_t end) | ||
{ | ||
__builtin___clear_cache(reinterpret_cast<char*>(begin), reinterpret_cast<char*>(end)); |
This file was deleted.
Oops, something went wrong.
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
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
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,14 @@ | ||
diff -aur target-org/webkit/Source/JavaScriptCore/assembler/PerfLog.cpp target/webkit/Source/JavaScriptCore/assembler/PerfLog.cpp | ||
--- target-org/webkit/Source/JavaScriptCore/assembler/PerfLog.cpp 2019-06-18 21:49:21.000000000 +0800 | ||
+++ target/webkit/Source/JavaScriptCore/assembler/PerfLog.cpp 2019-06-18 23:12:38.000000000 +0800 | ||
@@ -41,6 +41,10 @@ | ||
#include <wtf/PageBlock.h> | ||
#include <wtf/ProcessID.h> | ||
|
||
+#if defined(CUSTOMIZE_REACT_NATIVE) | ||
+#include <array> | ||
+#endif // defined(CUSTOMIZE_REACT_NATIVE) | ||
+ | ||
namespace JSC { | ||
|
||
namespace PerfLogInternal { |
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 |
---|---|---|
@@ -1,30 +1,29 @@ | ||
diff -aur target-org/webkit/Source/WTF/wtf/CheckedArithmetic.h target/webkit/Source/WTF/wtf/CheckedArithmetic.h | ||
--- target-org/webkit/Source/WTF/wtf/CheckedArithmetic.h 2018-07-26 17:00:09.000000000 +0800 | ||
+++ target/webkit/Source/WTF/wtf/CheckedArithmetic.h 2019-04-12 12:03:55.000000000 +0800 | ||
@@ -317,7 +317,7 @@ | ||
|
||
--- target-org/webkit/Source/WTF/wtf/CheckedArithmetic.h 2019-06-18 21:49:53.000000000 +0800 | ||
+++ target/webkit/Source/WTF/wtf/CheckedArithmetic.h 2019-06-18 22:44:39.000000000 +0800 | ||
@@ -360,7 +360,7 @@ | ||
|
||
static inline bool multiply(LHS lhs, RHS rhs, ResultType& result) WARN_UNUSED_RETURN | ||
{ | ||
-#if COMPILER(GCC_OR_CLANG) | ||
+#if COMPILER(GCC_OR_CLANG) && CPU(ARM_THUMB2) && defined(NDEBUG) | ||
-#if COMPILER(GCC_COMPATIBLE) | ||
+#if COMPILER(GCC_COMPATIBLE) && CPU(ARM_THUMB2) && defined(NDEBUG) | ||
ResultType temp; | ||
if (__builtin_mul_overflow(lhs, rhs, &temp)) | ||
return false; | ||
@@ -390,7 +390,7 @@ | ||
|
||
@@ -433,7 +433,7 @@ | ||
static inline bool multiply(LHS lhs, RHS rhs, ResultType& result) WARN_UNUSED_RETURN | ||
{ | ||
-#if COMPILER(GCC_OR_CLANG) | ||
+#if COMPILER(GCC_OR_CLANG) && CPU(ARM_THUMB2) && defined(NDEBUG) | ||
-#if COMPILER(GCC_COMPATIBLE) | ||
+#if COMPILER(GCC_COMPATIBLE) && CPU(ARM_THUMB2) && defined(NDEBUG) | ||
ResultType temp; | ||
if (__builtin_mul_overflow(lhs, rhs, &temp)) | ||
return false; | ||
@@ -453,7 +453,7 @@ | ||
|
||
@@ -496,7 +496,7 @@ | ||
static inline bool multiply(int64_t lhs, int64_t rhs, ResultType& result) | ||
{ | ||
-#if COMPILER(GCC_OR_CLANG) | ||
+#if COMPILER(GCC_OR_CLANG) && CPU(ARM_THUMB2) && defined(NDEBUG) | ||
-#if COMPILER(GCC_COMPATIBLE) | ||
+#if COMPILER(GCC_COMPATIBLE) && CPU(ARM_THUMB2) && defined(NDEBUG) | ||
ResultType temp; | ||
if (__builtin_mul_overflow(lhs, rhs, &temp)) | ||
return false; |
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,15 @@ | ||
diff -aur target-org/webkit/Source/WTF/wtf/posix/FileSystemPOSIX.cpp target/webkit/Source/WTF/wtf/posix/FileSystemPOSIX.cpp | ||
--- target-org/webkit/Source/WTF/wtf/posix/FileSystemPOSIX.cpp 2019-06-18 21:49:52.000000000 +0800 | ||
+++ target/webkit/Source/WTF/wtf/posix/FileSystemPOSIX.cpp 2019-06-18 22:58:46.000000000 +0800 | ||
@@ -45,6 +45,11 @@ | ||
#include <wtf/text/StringBuilder.h> | ||
#include <wtf/text/WTFString.h> | ||
|
||
+#if defined(CUSTOMIZE_REACT_NATIVE) && defined(__ANDROID__) && __ANDROID_API__ < 19 | ||
+#include <sys/vfs.h> | ||
+#define statvfs statfs | ||
+#endif // defined(CUSTOMIZE_REACT_NATIVE) && defined(__ANDROID__) && __ANDROID_API__ < 19 | ||
+ | ||
namespace WTF { | ||
|
||
namespace FileSystemImpl { |
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
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
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
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
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