113 lines
3.8 KiB
Diff
113 lines
3.8 KiB
Diff
|
Fix cache-flush on PPC
|
||
|
|
||
|
From:
|
||
|
r742 | zherczeg | 2011-11-06 09:05:33 +0100 (Ne, 06 lis 2011) | 3 lines
|
||
|
|
||
|
Fix cache-flush issue on PowerPC, adding some comments and a check for
|
||
|
disabled PCRE_EXTRA_TABLES.
|
||
|
|
||
|
Fix cache-flush issue on PowerPC (It is still an experimental JIT port).
|
||
|
PCRE_EXTRA_TABLES is not suported by JIT, and should be checked before
|
||
|
calling _pcre_jit_exec. Some extra comments are added.
|
||
|
|
||
|
Petr Pisar: Changelog removed
|
||
|
|
||
|
Index: pcre_exec.c
|
||
|
===================================================================
|
||
|
--- pcre_exec.c (revision 741)
|
||
|
+++ pcre_exec.c (revision 742)
|
||
|
@@ -6011,6 +6011,7 @@
|
||
|
if (extra_data != NULL
|
||
|
&& (extra_data->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0
|
||
|
&& extra_data->executable_jit != NULL
|
||
|
+ && (extra_data->flags & PCRE_EXTRA_TABLES) == 0
|
||
|
&& (options & ~(PCRE_NO_UTF8_CHECK | PCRE_NOTBOL | PCRE_NOTEOL |
|
||
|
PCRE_NOTEMPTY | PCRE_NOTEMPTY_ATSTART)) == 0)
|
||
|
return _pcre_jit_exec(re, extra_data->executable_jit, subject, length,
|
||
|
Index: sljit/sljitLir.h
|
||
|
===================================================================
|
||
|
--- sljit/sljitLir.h (revision 741)
|
||
|
+++ sljit/sljitLir.h (revision 742)
|
||
|
@@ -56,6 +56,9 @@
|
||
|
- mainly position independent code
|
||
|
- Optimizations (perhaps later)
|
||
|
- Only for basic blocks (when no labels inserted between LIR instructions)
|
||
|
+
|
||
|
+ For valgrind users:
|
||
|
+ - pass --smc-check=all argument to valgrind, since JIT is a "self-modifying code"
|
||
|
*/
|
||
|
|
||
|
#if !(defined SLJIT_NO_DEFAULT_CONFIG && SLJIT_NO_DEFAULT_CONFIG)
|
||
|
@@ -87,6 +90,7 @@
|
||
|
|
||
|
#define SLJIT_UNUSED 0
|
||
|
|
||
|
+/* Temporary (scratch) registers may not preserve their values across function calls. */
|
||
|
#define SLJIT_TEMPORARY_REG1 1
|
||
|
#define SLJIT_TEMPORARY_REG2 2
|
||
|
#define SLJIT_TEMPORARY_REG3 3
|
||
|
@@ -95,6 +99,7 @@
|
||
|
#define SLJIT_TEMPORARY_EREG1 4
|
||
|
#define SLJIT_TEMPORARY_EREG2 5
|
||
|
|
||
|
+/* General (saved) registers preserve their values across function calls. */
|
||
|
#define SLJIT_GENERAL_REG1 6
|
||
|
#define SLJIT_GENERAL_REG2 7
|
||
|
#define SLJIT_GENERAL_REG3 8
|
||
|
Index: sljit/sljitNativePPC_common.c
|
||
|
===================================================================
|
||
|
--- sljit/sljitNativePPC_common.c (revision 741)
|
||
|
+++ sljit/sljitNativePPC_common.c (revision 742)
|
||
|
@@ -37,6 +37,18 @@
|
||
|
Both for ppc-32 and ppc-64. */
|
||
|
typedef sljit_ui sljit_ins;
|
||
|
|
||
|
+static void ppc_cache_flush(sljit_ins *from, sljit_ins *to)
|
||
|
+{
|
||
|
+ while (from < to) {
|
||
|
+#ifdef __GNUC__
|
||
|
+ asm volatile ( "icbi 0, %0" : : "r"(from) );
|
||
|
+#else
|
||
|
+#error "Must implement icbi"
|
||
|
+#endif
|
||
|
+ from++;
|
||
|
+ }
|
||
|
+}
|
||
|
+
|
||
|
#define TMP_REG1 (SLJIT_NO_REGISTERS + 1)
|
||
|
#define TMP_REG2 (SLJIT_NO_REGISTERS + 2)
|
||
|
#define TMP_REG3 (SLJIT_NO_REGISTERS + 3)
|
||
|
Index: sljit/sljitConfigInternal.h
|
||
|
===================================================================
|
||
|
--- sljit/sljitConfigInternal.h (revision 741)
|
||
|
+++ sljit/sljitConfigInternal.h (revision 742)
|
||
|
@@ -178,13 +178,23 @@
|
||
|
|
||
|
#ifndef SLJIT_CACHE_FLUSH
|
||
|
|
||
|
-#if !(defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) && !(defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
|
||
|
- /* Just call __ARM_NR_cacheflush on Linux. */
|
||
|
+#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
|
||
|
+
|
||
|
+/* The __clear_cache() implementation of GCC is a dummy function on PowerPC. */
|
||
|
#define SLJIT_CACHE_FLUSH(from, to) \
|
||
|
+ ppc_cache_flush((from), (to))
|
||
|
+
|
||
|
+#elif (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
|
||
|
+
|
||
|
+/* Not required to implement on archs with unified caches. */
|
||
|
+#define SLJIT_CACHE_FLUSH(from, to)
|
||
|
+
|
||
|
+#else
|
||
|
+
|
||
|
+/* Calls __ARM_NR_cacheflush on ARM-Linux. */
|
||
|
+#define SLJIT_CACHE_FLUSH(from, to) \
|
||
|
__clear_cache((char*)(from), (char*)(to))
|
||
|
-#else
|
||
|
- /* Not required to implement on archs with unified caches. */
|
||
|
-#define SLJIT_CACHE_FLUSH(from, to)
|
||
|
+
|
||
|
#endif
|
||
|
|
||
|
#endif /* !SLJIT_CACHE_FLUSH */
|