64 lines
2.2 KiB
Diff
64 lines
2.2 KiB
Diff
From ed5a63c21c4faa0f5a17ebd7a0ccd135b8a880a2 Mon Sep 17 00:00:00 2001
|
|
From: Daniel Kolesa <daniel@octaforge.org>
|
|
Date: Thu, 7 May 2020 19:39:34 +0200
|
|
Subject: [PATCH] Fix gcSafeMemcpy on non-x86_64/aarch64 64-bit architectures
|
|
|
|
The problem at hand here is that the control flow is wrong. As
|
|
it was, we'd do something like:
|
|
|
|
```
|
|
if (bytes <= smallCutoff) {
|
|
slow path
|
|
} else if (aarch64 || bytes <= mediumCutoff) {
|
|
either x86_64 path, aarch64 path or slow path
|
|
} else {
|
|
assert(x86_64)
|
|
do x86_64 path, or nothing on other archs
|
|
}
|
|
```
|
|
|
|
That means everything on non-x86_64/aarch64 that tried to memcpy
|
|
more than mediumCutoff would end up doing nothing.
|
|
|
|
Fix the code so that slow path is taken automatically always
|
|
if running non-x86_64/aarch64 architectures. Remove the #else
|
|
in the mediumCutoff branch as that is now never taken.
|
|
---
|
|
Source/JavaScriptCore/ChangeLog | 16 ++++++++++++++++
|
|
Source/JavaScriptCore/heap/GCMemoryOperations.h | 6 ++----
|
|
2 files changed, 18 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/Source/JavaScriptCore/heap/GCMemoryOperations.h b/Source/JavaScriptCore/heap/GCMemoryOperations.h
|
|
index f2b9e385bc9..ff66071db20 100644
|
|
--- Source/JavaScriptCore/heap/GCMemoryOperations.h
|
|
+++ Source/JavaScriptCore/heap/GCMemoryOperations.h
|
|
@@ -53,7 +53,7 @@ ALWAYS_INLINE void gcSafeMemcpy(T* dst, T* src, size_t bytes)
|
|
bitwise_cast<volatile uint64_t*>(dst)[i] = bitwise_cast<volatile uint64_t*>(src)[i];
|
|
};
|
|
|
|
-#if COMPILER(GCC_COMPATIBLE) && USE(JSVALUE64)
|
|
+#if COMPILER(GCC_COMPATIBLE) && (CPU(X86_64) || CPU(ARM64))
|
|
if (bytes <= smallCutoff)
|
|
slowPathForwardMemcpy();
|
|
else if (isARM64() || bytes <= mediumCutoff) {
|
|
@@ -121,8 +121,6 @@ ALWAYS_INLINE void gcSafeMemcpy(T* dst, T* src, size_t bytes)
|
|
:
|
|
: "d0", "d1", "memory"
|
|
);
|
|
-#else
|
|
- slowPathForwardMemcpy();
|
|
#endif // CPU(X86_64)
|
|
} else {
|
|
RELEASE_ASSERT(isX86_64());
|
|
@@ -139,7 +137,7 @@ ALWAYS_INLINE void gcSafeMemcpy(T* dst, T* src, size_t bytes)
|
|
}
|
|
#else
|
|
slowPathForwardMemcpy();
|
|
-#endif // COMPILER(GCC_COMPATIBLE)
|
|
+#endif // COMPILER(GCC_COMPATIBLE) && (CPU(X86_64) || CPU(ARM64))
|
|
#else
|
|
memcpy(dst, src, bytes);
|
|
#endif // USE(JSVALUE64)
|
|
--
|
|
2.26.2
|
|
|