[Pcre-svn] [987] code/trunk: Supporting IBM XL C compilers f…

Startseite
Nachricht löschen
Autor: Subversion repository
Datum:  
To: pcre-svn
Betreff: [Pcre-svn] [987] code/trunk: Supporting IBM XL C compilers for PPC architectures in the JIT compiler.
Revision: 987
          http://vcs.pcre.org/viewvc?view=rev&revision=987
Author:   zherczeg
Date:     2012-07-07 05:11:29 +0100 (Sat, 07 Jul 2012)


Log Message:
-----------
Supporting IBM XL C compilers for PPC architectures in the JIT compiler.

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/pcre_jit_compile.c
    code/trunk/sljit/sljitConfigInternal.h
    code/trunk/sljit/sljitNativePPC_64.c
    code/trunk/sljit/sljitNativePPC_common.c
    code/trunk/sljit/sljitUtils.c


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2012-07-07 03:33:54 UTC (rev 986)
+++ code/trunk/ChangeLog    2012-07-07 04:11:29 UTC (rev 987)
@@ -7,7 +7,10 @@
 1.  Improved JIT compiler optimizations for first character search and single
     character iterators.


+2.  Supporting IBM XL C compilers for PPC architectures in the JIT compiler.
+    Patch by Daniel Richard G.


+
Version 8.31 06-July-2012
-------------------------


Modified: code/trunk/pcre_jit_compile.c
===================================================================
--- code/trunk/pcre_jit_compile.c    2012-07-07 03:33:54 UTC (rev 986)
+++ code/trunk/pcre_jit_compile.c    2012-07-07 04:11:29 UTC (rev 987)
@@ -7834,6 +7834,15 @@
   functions = (executable_functions *)extra->executable_jit;
 else
   {
+  /* Note: If your memory-checker has flagged the allocation below as a
+   * memory leak, it is probably because you either forgot to call
+   * pcre_free_study() (or pcre16_free_study()) on the pcre_extra (or
+   * pcre16_extra) object, or you called said function after having
+   * cleared the PCRE_EXTRA_EXECUTABLE_JIT bit from the "flags" field
+   * of the object. (The function will only free the JIT data if the
+   * bit remains set, as the bit indicates that the pointer to the data
+   * is valid.)
+   */
   functions = SLJIT_MALLOC(sizeof(executable_functions));
   if (functions == NULL)
     {


Modified: code/trunk/sljit/sljitConfigInternal.h
===================================================================
--- code/trunk/sljit/sljitConfigInternal.h    2012-07-07 03:33:54 UTC (rev 986)
+++ code/trunk/sljit/sljitConfigInternal.h    2012-07-07 04:11:29 UTC (rev 987)
@@ -93,9 +93,9 @@
 #else
 #define SLJIT_CONFIG_ARM_V5 1
 #endif
-#elif defined(__ppc64__) || defined(__powerpc64__)
+#elif defined(__ppc64__) || defined(__powerpc64__) || defined(_ARCH_PPC64)
 #define SLJIT_CONFIG_PPC_64 1
-#elif defined(__ppc__) || defined(__powerpc__)
+#elif defined(__ppc__) || defined(__powerpc__) || defined(_ARCH_PPC)
 #define SLJIT_CONFIG_PPC_32 1
 #elif defined(__mips__)
 #define SLJIT_CONFIG_MIPS_32 1


Modified: code/trunk/sljit/sljitNativePPC_64.c
===================================================================
--- code/trunk/sljit/sljitNativePPC_64.c    2012-07-07 03:33:54 UTC (rev 986)
+++ code/trunk/sljit/sljitNativePPC_64.c    2012-07-07 04:11:29 UTC (rev 987)
@@ -26,9 +26,11 @@


/* ppc 64-bit arch dependent functions. */

-#ifdef __GNUC__
+#if defined(__GNUC__) || (defined(__IBM_GCC_ASM) && __IBM_GCC_ASM)
 #define ASM_SLJIT_CLZ(src, dst) \
-    asm volatile ( "cntlzd %0, %1" : "=r"(dst) : "r"(src) )
+    __asm__ volatile ( "cntlzd %0, %1" : "=r"(dst) : "r"(src) )
+#elif defined(__xlc__)
+#error "Please enable GCC syntax for inline assembly statements"
 #else
 #error "Must implement count leading zeroes"
 #endif


Modified: code/trunk/sljit/sljitNativePPC_common.c
===================================================================
--- code/trunk/sljit/sljitNativePPC_common.c    2012-07-07 03:33:54 UTC (rev 986)
+++ code/trunk/sljit/sljitNativePPC_common.c    2012-07-07 04:11:29 UTC (rev 987)
@@ -36,10 +36,15 @@
 static void ppc_cache_flush(sljit_ins *from, sljit_ins *to)
 {
     while (from < to) {
-#ifdef __GNUC__
-        asm volatile ( "icbi 0, %0" : : "r"(from) );
+#if defined(__GNUC__) || (defined(__IBM_GCC_ASM) && __IBM_GCC_ASM)
+        __asm__ volatile ( "icbi 0, %0" : : "r"(from) );
+#ifdef __xlc__
+#warning "This file may fail to compile if -qfuncsect is used"
+#endif
+#elif defined(__xlc__)
+#error "Please enable GCC syntax for inline assembly statements with -qasm=gcc"
 #else
-#error "Must implement icbi"
+#error "This platform requires a cache flush implementation."
 #endif
         from++;
     }
@@ -361,7 +366,7 @@
 #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
     if (((sljit_w)code_ptr) & 0x4)
         code_ptr++;
-    sljit_set_function_context(NULL, (struct sljit_function_context*)code_ptr, (sljit_w)code, sljit_generate_code);
+    sljit_set_function_context(NULL, (struct sljit_function_context*)code_ptr, (sljit_w)code, (void*)sljit_generate_code);
     return code_ptr;
 #else
     return code;


Modified: code/trunk/sljit/sljitUtils.c
===================================================================
--- code/trunk/sljit/sljitUtils.c    2012-07-07 03:33:54 UTC (rev 986)
+++ code/trunk/sljit/sljitUtils.c    2012-07-07 04:11:29 UTC (rev 987)
@@ -106,7 +106,7 @@


#else /* _WIN32 */

-#include "pthread.h"
+#include <pthread.h>

#if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)

@@ -262,8 +262,14 @@
     }
     aligned_new_limit = (new_limit + sljit_page_align) & ~sljit_page_align;
     aligned_old_limit = (stack->limit + sljit_page_align) & ~sljit_page_align;
+    /* If madvise is available, we release the unnecessary space. */
+#if defined(POSIX_MADV_DONTNEED)
     if (aligned_new_limit < aligned_old_limit)
         posix_madvise((void*)aligned_new_limit, aligned_old_limit - aligned_new_limit, POSIX_MADV_DONTNEED);
+#elif defined(MADV_DONTNEED)
+    if (aligned_new_limit < aligned_old_limit)
+        madvise((void*)aligned_new_limit, aligned_old_limit - aligned_new_limit, MADV_DONTNEED);
+#endif
     stack->limit = new_limit;
     return 0;
 #endif