summaryrefslogtreecommitdiff
path: root/pcre/sljit
diff options
context:
space:
mode:
Diffstat (limited to 'pcre/sljit')
-rw-r--r--pcre/sljit/sljitConfig.h8
-rw-r--r--pcre/sljit/sljitConfigInternal.h325
-rw-r--r--pcre/sljit/sljitLir.c965
-rw-r--r--pcre/sljit/sljitLir.h210
-rw-r--r--pcre/sljit/sljitNativeARM_32.c156
-rw-r--r--pcre/sljit/sljitNativeARM_64.c250
-rw-r--r--pcre/sljit/sljitNativeARM_T2_32.c138
-rw-r--r--pcre/sljit/sljitNativeMIPS_common.c247
-rw-r--r--pcre/sljit/sljitNativePPC_common.c191
-rw-r--r--pcre/sljit/sljitNativeSPARC_common.c159
-rw-r--r--pcre/sljit/sljitNativeTILEGX_64.c20
-rw-r--r--pcre/sljit/sljitNativeX86_32.c87
-rw-r--r--pcre/sljit/sljitNativeX86_64.c41
-rw-r--r--pcre/sljit/sljitNativeX86_common.c132
-rw-r--r--pcre/sljit/sljitUtils.c18
15 files changed, 1504 insertions, 1443 deletions
diff --git a/pcre/sljit/sljitConfig.h b/pcre/sljit/sljitConfig.h
index 4d93f4f78cc..10364c3b60a 100644
--- a/pcre/sljit/sljitConfig.h
+++ b/pcre/sljit/sljitConfig.h
@@ -96,13 +96,19 @@
#define SLJIT_EXECUTABLE_ALLOCATOR 1
#endif
+/* Return with error when an invalid argument is passed. */
+#ifndef SLJIT_ARGUMENT_CHECKS
+/* Disabled by default */
+#define SLJIT_ARGUMENT_CHECKS 0
+#endif
+
/* Debug checks (assertions, etc.). */
#ifndef SLJIT_DEBUG
/* Enabled by default */
#define SLJIT_DEBUG 1
#endif
-/* Verbose operations */
+/* Verbose operations. */
#ifndef SLJIT_VERBOSE
/* Enabled by default */
#define SLJIT_VERBOSE 1
diff --git a/pcre/sljit/sljitConfigInternal.h b/pcre/sljit/sljitConfigInternal.h
index 6351e5b1685..3284012f19a 100644
--- a/pcre/sljit/sljitConfigInternal.h
+++ b/pcre/sljit/sljitConfigInternal.h
@@ -60,6 +60,7 @@
a double precision floating point array by index
SLJIT_SINGLE_SHIFT : the shift required to apply when accessing
a single precision floating point array by index
+ SLJIT_LOCALS_OFFSET : local space starting offset (SLJIT_SP + SLJIT_LOCALS_OFFSET)
SLJIT_RETURN_ADDRESS_OFFSET : a return instruction always adds this offset to the return address
Other macros:
@@ -67,6 +68,10 @@
SLJIT_W(number) : defining 64 bit constants on 64 bit architectures (compiler independent helper)
*/
+/*****************/
+/* Sanity check. */
+/*****************/
+
#if !((defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
|| (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
|| (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) \
@@ -84,7 +89,6 @@
#error "An architecture must be selected"
#endif
-/* Sanity check. */
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
+ (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
+ (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) \
@@ -102,7 +106,10 @@
#error "Multiple architectures are selected"
#endif
-/* Auto select option (requires compiler support) */
+/********************************************************/
+/* Automatic CPU detection (requires compiler support). */
+/********************************************************/
+
#if (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO)
#ifndef _WIN32
@@ -155,6 +162,10 @@
#undef SLJIT_EXECUTABLE_ALLOCATOR
#endif
+/******************************/
+/* CPU family type detection. */
+/******************************/
+
#if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
|| (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
#define SLJIT_CONFIG_ARM_32 1
@@ -172,52 +183,9 @@
#define SLJIT_CONFIG_SPARC 1
#endif
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
-#define SLJIT_NUMBER_OF_REGISTERS 10
-#define SLJIT_NUMBER_OF_SAVED_REGISTERS 7
-#elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
-#ifndef _WIN64
-#define SLJIT_NUMBER_OF_REGISTERS 12
-#define SLJIT_NUMBER_OF_SAVED_REGISTERS 6
-#else
-#define SLJIT_NUMBER_OF_REGISTERS 12
-#define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
-#endif /* _WIN64 */
-#elif (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
-#define SLJIT_NUMBER_OF_REGISTERS 11
-#define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
-#elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
-#define SLJIT_NUMBER_OF_REGISTERS 11
-#define SLJIT_NUMBER_OF_SAVED_REGISTERS 7
-#elif (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
-#define SLJIT_NUMBER_OF_REGISTERS 23
-#define SLJIT_NUMBER_OF_SAVED_REGISTERS 10
-#elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
-#define SLJIT_NUMBER_OF_REGISTERS 22
-#define SLJIT_NUMBER_OF_SAVED_REGISTERS 17
-#elif (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
-#define SLJIT_NUMBER_OF_REGISTERS 17
-#define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
-#elif (defined SLJIT_CONFIG_SPARC && SLJIT_CONFIG_SPARC)
-#define SLJIT_NUMBER_OF_REGISTERS 18
-#define SLJIT_NUMBER_OF_SAVED_REGISTERS 14
-#elif (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
-#define SLJIT_NUMBER_OF_REGISTERS 0
-#define SLJIT_NUMBER_OF_SAVED_REGISTERS 0
-#endif
-
-#define SLJIT_NUMBER_OF_SCRATCH_REGISTERS \
- (SLJIT_NUMBER_OF_REGISTERS - SLJIT_NUMBER_OF_SAVED_REGISTERS)
-
-#define SLJIT_NUMBER_OF_FLOAT_REGISTERS 6
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) && (defined _WIN64)
-#define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 1
-#else
-#define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 0
-#endif
-
-#define SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS \
- (SLJIT_NUMBER_OF_FLOAT_REGISTERS - SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS)
+/**********************************/
+/* External function definitions. */
+/**********************************/
#if !(defined SLJIT_STD_MACROS_DEFINED && SLJIT_STD_MACROS_DEFINED)
@@ -225,20 +193,21 @@
#include <stdlib.h>
#include <string.h>
-#endif /* STD_MACROS_DEFINED */
+#endif /* SLJIT_STD_MACROS_DEFINED */
/* General macros:
Note: SLJIT is designed to be independent from them as possible.
- In release mode (SLJIT_DEBUG is not defined) only the following macros are needed:
+ In release mode (SLJIT_DEBUG is not defined) only the following
+ external functions are needed:
*/
#ifndef SLJIT_MALLOC
-#define SLJIT_MALLOC(size) malloc(size)
+#define SLJIT_MALLOC(size, allocator_data) malloc(size)
#endif
#ifndef SLJIT_FREE
-#define SLJIT_FREE(ptr) free(ptr)
+#define SLJIT_FREE(ptr, allocator_data) free(ptr)
#endif
#ifndef SLJIT_MEMMOVE
@@ -249,6 +218,10 @@
#define SLJIT_ZEROMEM(dest, len) memset(dest, 0, len)
#endif
+/***************************/
+/* Compiler helper macros. */
+/***************************/
+
#if !defined(SLJIT_LIKELY) && !defined(SLJIT_UNLIKELY)
#if defined(__GNUC__) && (__GNUC__ >= 3)
@@ -270,6 +243,15 @@
#endif
#endif /* !SLJIT_INLINE */
+#ifndef SLJIT_NOINLINE
+/* Not inline functions. */
+#if defined(__GNUC__)
+#define SLJIT_NOINLINE __attribute__ ((noinline))
+#else
+#define SLJIT_NOINLINE
+#endif
+#endif /* !SLJIT_INLINE */
+
#ifndef SLJIT_CONST
/* Const variables. */
#define SLJIT_CONST const
@@ -280,6 +262,10 @@
#define SLJIT_UNUSED_ARG(arg) (void)arg
#endif
+/*********************************/
+/* Type of public API functions. */
+/*********************************/
+
#if (defined SLJIT_CONFIG_STATIC && SLJIT_CONFIG_STATIC)
/* Static ABI functions. For all-in-one programs. */
@@ -294,6 +280,10 @@
#define SLJIT_API_FUNC_ATTRIBUTE
#endif /* (defined SLJIT_CONFIG_STATIC && SLJIT_CONFIG_STATIC) */
+/****************************/
+/* Instruction cache flush. */
+/****************************/
+
#ifndef SLJIT_CACHE_FLUSH
#if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
@@ -339,6 +329,10 @@
#endif /* !SLJIT_CACHE_FLUSH */
+/******************************************************/
+/* Byte/half/int/word/single/double type definitions. */
+/******************************************************/
+
/* 8 bit byte type. */
typedef unsigned char sljit_ub;
typedef signed char sljit_sb;
@@ -351,7 +345,7 @@ typedef signed short int sljit_sh;
typedef unsigned int sljit_ui;
typedef signed int sljit_si;
-/* Machine word type. Can encapsulate a pointer.
+/* Machine word type. Enough for storing a pointer.
32 bit for 32 bit machines.
64 bit for 64 bit machines. */
#if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
@@ -404,44 +398,13 @@ typedef double sljit_d;
#endif /* !SLJIT_W */
-#ifndef SLJIT_CALL
-
-/* ABI (Application Binary Interface) types. */
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
-
-#if defined(__GNUC__) && !defined(__APPLE__)
-
-#define SLJIT_CALL __attribute__ ((fastcall))
-#define SLJIT_X86_32_FASTCALL 1
-
-#elif defined(_MSC_VER)
-
-#define SLJIT_CALL __fastcall
-#define SLJIT_X86_32_FASTCALL 1
-
-#elif defined(__BORLANDC__)
-
-#define SLJIT_CALL __msfastcall
-#define SLJIT_X86_32_FASTCALL 1
-
-#else /* Unknown compiler. */
-
-/* The cdecl attribute is the default. */
-#define SLJIT_CALL
-
-#endif
-
-#else /* Non x86-32 architectures. */
-
-#define SLJIT_CALL
-
-#endif /* SLJIT_CONFIG_X86_32 */
-
-#endif /* !SLJIT_CALL */
+/*************************/
+/* Endianness detection. */
+/*************************/
#if !defined(SLJIT_BIG_ENDIAN) && !defined(SLJIT_LITTLE_ENDIAN)
-/* These macros are useful for the applications. */
+/* These macros are mostly useful for the applications. */
#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
|| (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
@@ -479,6 +442,64 @@ typedef double sljit_d;
#error "Exactly one endianness must be selected"
#endif
+#ifndef SLJIT_UNALIGNED
+
+#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
+ || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
+ || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
+ || (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
+ || (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
+ || (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
+ || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
+#define SLJIT_UNALIGNED 1
+#endif
+
+#endif /* !SLJIT_UNALIGNED */
+
+#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
+/* Auto detect SSE2 support using CPUID.
+ On 64 bit x86 cpus, sse2 must be present. */
+#define SLJIT_DETECT_SSE2 1
+#endif
+
+/*****************************************************************************************/
+/* Calling convention of functions generated by SLJIT or called from the generated code. */
+/*****************************************************************************************/
+
+#ifndef SLJIT_CALL
+
+#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
+
+#if defined(__GNUC__) && !defined(__APPLE__)
+
+#define SLJIT_CALL __attribute__ ((fastcall))
+#define SLJIT_X86_32_FASTCALL 1
+
+#elif defined(_MSC_VER)
+
+#define SLJIT_CALL __fastcall
+#define SLJIT_X86_32_FASTCALL 1
+
+#elif defined(__BORLANDC__)
+
+#define SLJIT_CALL __msfastcall
+#define SLJIT_X86_32_FASTCALL 1
+
+#else /* Unknown compiler. */
+
+/* The cdecl attribute is the default. */
+#define SLJIT_CALL
+
+#endif
+
+#else /* Non x86-32 architectures. */
+
+#define SLJIT_CALL
+
+#endif /* SLJIT_CONFIG_X86_32 */
+
+#endif /* !SLJIT_CALL */
+
#ifndef SLJIT_INDIRECT_CALL
#if ((defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) && (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN)) \
|| ((defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) && defined _AIX)
@@ -488,6 +509,8 @@ typedef double sljit_d;
#endif
#endif /* SLJIT_INDIRECT_CALL */
+/* The offset which needs to be substracted from the return address to
+determine the next executed instruction after return. */
#ifndef SLJIT_RETURN_ADDRESS_OFFSET
#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
#define SLJIT_RETURN_ADDRESS_OFFSET 8
@@ -496,25 +519,9 @@ typedef double sljit_d;
#endif
#endif /* SLJIT_RETURN_ADDRESS_OFFSET */
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
-/* Auto detect SSE2 support using CPUID.
- On 64 bit x86 cpus, sse2 must be present. */
-#define SLJIT_DETECT_SSE2 1
-#endif
-
-#ifndef SLJIT_UNALIGNED
-
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
- || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
- || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
- || (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
- || (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
- || (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
- || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
-#define SLJIT_UNALIGNED 1
-#endif
-
-#endif /* !SLJIT_UNALIGNED */
+/***************************************************/
+/* Functions of the built-in executable allocator. */
+/***************************************************/
#if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size);
@@ -524,6 +531,110 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void);
#define SLJIT_FREE_EXEC(ptr) sljit_free_exec(ptr)
#endif
+/**********************************************/
+/* Registers and locals offset determination. */
+/**********************************************/
+
+#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
+
+#define SLJIT_NUMBER_OF_REGISTERS 10
+#define SLJIT_NUMBER_OF_SAVED_REGISTERS 7
+#if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
+#define SLJIT_LOCALS_OFFSET_BASE ((2 + 4) * sizeof(sljit_sw))
+#else
+/* Maximum 3 arguments are passed on the stack, +1 for double alignment. */
+#define SLJIT_LOCALS_OFFSET_BASE ((3 + 1 + 4) * sizeof(sljit_sw))
+#endif /* SLJIT_X86_32_FASTCALL */
+
+#elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
+
+#ifndef _WIN64
+#define SLJIT_NUMBER_OF_REGISTERS 12
+#define SLJIT_NUMBER_OF_SAVED_REGISTERS 6
+#define SLJIT_LOCALS_OFFSET_BASE (sizeof(sljit_sw))
+#else
+#define SLJIT_NUMBER_OF_REGISTERS 12
+#define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
+#define SLJIT_LOCALS_OFFSET_BASE ((4 + 2) * sizeof(sljit_sw))
+#endif /* _WIN64 */
+
+#elif (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
+
+#define SLJIT_NUMBER_OF_REGISTERS 11
+#define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
+#define SLJIT_LOCALS_OFFSET_BASE 0
+
+#elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
+
+#define SLJIT_NUMBER_OF_REGISTERS 11
+#define SLJIT_NUMBER_OF_SAVED_REGISTERS 7
+#define SLJIT_LOCALS_OFFSET_BASE 0
+
+#elif (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
+
+#define SLJIT_NUMBER_OF_REGISTERS 25
+#define SLJIT_NUMBER_OF_SAVED_REGISTERS 10
+#define SLJIT_LOCALS_OFFSET_BASE (2 * sizeof(sljit_sw))
+
+#elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
+
+#define SLJIT_NUMBER_OF_REGISTERS 22
+#define SLJIT_NUMBER_OF_SAVED_REGISTERS 17
+#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) || (defined _AIX)
+#define SLJIT_LOCALS_OFFSET_BASE ((6 + 8) * sizeof(sljit_sw))
+#elif (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
+/* Add +1 for double alignment. */
+#define SLJIT_LOCALS_OFFSET_BASE ((3 + 1) * sizeof(sljit_sw))
+#else
+#define SLJIT_LOCALS_OFFSET_BASE (3 * sizeof(sljit_sw))
+#endif /* SLJIT_CONFIG_PPC_64 || _AIX */
+
+#elif (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
+
+#define SLJIT_NUMBER_OF_REGISTERS 17
+#define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
+#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
+#define SLJIT_LOCALS_OFFSET_BASE (4 * sizeof(sljit_sw))
+#else
+#define SLJIT_LOCALS_OFFSET_BASE 0
+#endif
+
+#elif (defined SLJIT_CONFIG_SPARC && SLJIT_CONFIG_SPARC)
+
+#define SLJIT_NUMBER_OF_REGISTERS 18
+#define SLJIT_NUMBER_OF_SAVED_REGISTERS 14
+#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
+/* Add +1 for double alignment. */
+#define SLJIT_LOCALS_OFFSET_BASE ((23 + 1) * sizeof(sljit_sw))
+#endif
+
+#elif (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
+
+#define SLJIT_NUMBER_OF_REGISTERS 0
+#define SLJIT_NUMBER_OF_SAVED_REGISTERS 0
+#define SLJIT_LOCALS_OFFSET_BASE 0
+
+#endif
+
+#define SLJIT_LOCALS_OFFSET (SLJIT_LOCALS_OFFSET_BASE)
+
+#define SLJIT_NUMBER_OF_SCRATCH_REGISTERS \
+ (SLJIT_NUMBER_OF_REGISTERS - SLJIT_NUMBER_OF_SAVED_REGISTERS)
+
+#define SLJIT_NUMBER_OF_FLOAT_REGISTERS 6
+#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) && (defined _WIN64)
+#define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 1
+#else
+#define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 0
+#endif
+
+#define SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS \
+ (SLJIT_NUMBER_OF_FLOAT_REGISTERS - SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS)
+
+/*************************************/
+/* Debug and verbose related macros. */
+/*************************************/
+
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
#include <stdio.h>
#endif
diff --git a/pcre/sljit/sljitLir.c b/pcre/sljit/sljitLir.c
index 69c4b109165..5039a7e04ed 100644
--- a/pcre/sljit/sljitLir.c
+++ b/pcre/sljit/sljitLir.c
@@ -38,12 +38,6 @@
return NULL; \
} while (0)
-#define CHECK_ERROR_VOID() \
- do { \
- if (SLJIT_UNLIKELY(compiler->error)) \
- return; \
- } while (0)
-
#define FAIL_IF(expr) \
do { \
if (SLJIT_UNLIKELY(expr)) \
@@ -236,88 +230,89 @@
(saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? saveds : SLJIT_NUMBER_OF_SAVED_REGISTERS) + \
extra) * sizeof(sljit_sw))
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
-#define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
+#define ADJUST_LOCAL_OFFSET(p, i) \
+ if ((p) == (SLJIT_MEM1(SLJIT_SP))) \
+ (i) += SLJIT_LOCALS_OFFSET;
-#if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
-#define FIXED_LOCALS_OFFSET ((2 + 4) * sizeof(sljit_sw))
-#else
-/* Maximum 3 arguments are passed on the stack. */
-#define FIXED_LOCALS_OFFSET ((3 + 4) * sizeof(sljit_sw))
-#endif
+#endif /* !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) */
-#endif /* SLJIT_CONFIG_X86_32 */
+/* Utils can still be used even if SLJIT_CONFIG_UNSUPPORTED is set. */
+#include "sljitUtils.c"
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
-#define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
-#ifdef _WIN64
-#define FIXED_LOCALS_OFFSET ((4 + 2) * sizeof(sljit_sw))
-#else
-#define FIXED_LOCALS_OFFSET (sizeof(sljit_sw))
-#endif
-#endif
+#if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
-#if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
-#define SLJIT_HAS_VARIABLE_LOCALS_OFFSET 1
+#if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
+#include "sljitExecAllocator.c"
#endif
-#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
-#define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
-#ifdef _AIX
-#define FIXED_LOCALS_OFFSET ((6 + 8) * sizeof(sljit_sw))
-#else
-#define FIXED_LOCALS_OFFSET (3 * sizeof(sljit_sw))
-#endif
-#endif
+/* Argument checking features. */
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
-#define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
-#define FIXED_LOCALS_OFFSET ((6 + 8) * sizeof(sljit_sw))
-#endif
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
-#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
-#define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
-#define FIXED_LOCALS_OFFSET (4 * sizeof(sljit_sw))
-#endif
+/* Returns with error when an invalid argument is passed. */
-#if (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
-#define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
-#define FIXED_LOCALS_OFFSET 0
-#endif
+#define CHECK_ARGUMENT(x) \
+ do { \
+ if (SLJIT_UNLIKELY(!(x))) \
+ return 1; \
+ } while (0)
-#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
-#define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
-#define FIXED_LOCALS_OFFSET (23 * sizeof(sljit_sw))
-#endif
+#define CHECK_RETURN_TYPE sljit_si
+#define CHECK_RETURN_OK return 0
-#if (defined SLJIT_HAS_VARIABLE_LOCALS_OFFSET && SLJIT_HAS_VARIABLE_LOCALS_OFFSET)
+#define CHECK(x) \
+ do { \
+ if (SLJIT_UNLIKELY(x)) { \
+ compiler->error = SLJIT_ERR_BAD_ARGUMENT; \
+ return SLJIT_ERR_BAD_ARGUMENT; \
+ } \
+ } while (0)
-#define ADJUST_LOCAL_OFFSET(p, i) \
- if ((p) == (SLJIT_MEM1(SLJIT_SP))) \
- (i) += compiler->locals_offset;
+#define CHECK_PTR(x) \
+ do { \
+ if (SLJIT_UNLIKELY(x)) { \
+ compiler->error = SLJIT_ERR_BAD_ARGUMENT; \
+ return NULL; \
+ } \
+ } while (0)
-#elif (defined SLJIT_HAS_FIXED_LOCALS_OFFSET && SLJIT_HAS_FIXED_LOCALS_OFFSET)
+#define CHECK_REG_INDEX(x) \
+ do { \
+ if (SLJIT_UNLIKELY(x)) { \
+ return -2; \
+ } \
+ } while (0)
-#define ADJUST_LOCAL_OFFSET(p, i) \
- if ((p) == (SLJIT_MEM1(SLJIT_SP))) \
- (i) += FIXED_LOCALS_OFFSET;
+#elif (defined SLJIT_DEBUG && SLJIT_DEBUG)
-#else
+/* Assertion failure occures if an invalid argument is passed. */
+#undef SLJIT_ARGUMENT_CHECKS
+#define SLJIT_ARGUMENT_CHECKS 1
-#define ADJUST_LOCAL_OFFSET(p, i)
+#define CHECK_ARGUMENT(x) SLJIT_ASSERT(x)
+#define CHECK_RETURN_TYPE void
+#define CHECK_RETURN_OK return
+#define CHECK(x) x
+#define CHECK_PTR(x) x
+#define CHECK_REG_INDEX(x) x
-#endif
+#elif (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
-#endif /* !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) */
+/* Arguments are not checked. */
+#define CHECK_RETURN_TYPE void
+#define CHECK_RETURN_OK return
+#define CHECK(x) x
+#define CHECK_PTR(x) x
+#define CHECK_REG_INDEX(x) x
-/* Utils can still be used even if SLJIT_CONFIG_UNSUPPORTED is set. */
-#include "sljitUtils.c"
+#else
-#if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
+/* Arguments are not checked. */
+#define CHECK(x)
+#define CHECK_PTR(x)
+#define CHECK_REG_INDEX(x)
-#if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
-#include "sljitExecAllocator.c"
-#endif
+#endif /* SLJIT_ARGUMENT_CHECKS */
/* --------------------------------------------------------------------- */
/* Public functions */
@@ -330,9 +325,9 @@ static sljit_si compiler_initialized = 0;
static void init_compiler(void);
#endif
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void)
+SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void *allocator_data)
{
- struct sljit_compiler *compiler = (struct sljit_compiler*)SLJIT_MALLOC(sizeof(struct sljit_compiler));
+ struct sljit_compiler *compiler = (struct sljit_compiler*)SLJIT_MALLOC(sizeof(struct sljit_compiler), allocator_data);
if (!compiler)
return NULL;
SLJIT_ZEROMEM(compiler, sizeof(struct sljit_compiler));
@@ -354,15 +349,16 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void)
/* Only the non-zero members must be set. */
compiler->error = SLJIT_SUCCESS;
- compiler->buf = (struct sljit_memory_fragment*)SLJIT_MALLOC(BUF_SIZE);
- compiler->abuf = (struct sljit_memory_fragment*)SLJIT_MALLOC(ABUF_SIZE);
+ compiler->allocator_data = allocator_data;
+ compiler->buf = (struct sljit_memory_fragment*)SLJIT_MALLOC(BUF_SIZE, allocator_data);
+ compiler->abuf = (struct sljit_memory_fragment*)SLJIT_MALLOC(ABUF_SIZE, allocator_data);
if (!compiler->buf || !compiler->abuf) {
if (compiler->buf)
- SLJIT_FREE(compiler->buf);
+ SLJIT_FREE(compiler->buf, allocator_data);
if (compiler->abuf)
- SLJIT_FREE(compiler->abuf);
- SLJIT_FREE(compiler);
+ SLJIT_FREE(compiler->abuf, allocator_data);
+ SLJIT_FREE(compiler, allocator_data);
return NULL;
}
@@ -375,17 +371,19 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void)
compiler->saveds = -1;
compiler->fscratches = -1;
compiler->fsaveds = -1;
+ compiler->local_size = -1;
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
compiler->args = -1;
#endif
#if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
- compiler->cpool = (sljit_uw*)SLJIT_MALLOC(CPOOL_SIZE * sizeof(sljit_uw) + CPOOL_SIZE * sizeof(sljit_ub));
+ compiler->cpool = (sljit_uw*)SLJIT_MALLOC(CPOOL_SIZE * sizeof(sljit_uw)
+ + CPOOL_SIZE * sizeof(sljit_ub), allocator_data);
if (!compiler->cpool) {
- SLJIT_FREE(compiler->buf);
- SLJIT_FREE(compiler->abuf);
- SLJIT_FREE(compiler);
+ SLJIT_FREE(compiler->buf, allocator_data);
+ SLJIT_FREE(compiler->abuf, allocator_data);
+ SLJIT_FREE(compiler, allocator_data);
return NULL;
}
compiler->cpool_unique = (sljit_ub*)(compiler->cpool + CPOOL_SIZE);
@@ -414,25 +412,33 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_compiler(struct sljit_compiler *compile
{
struct sljit_memory_fragment *buf;
struct sljit_memory_fragment *curr;
+ void *allocator_data = compiler->allocator_data;
+ SLJIT_UNUSED_ARG(allocator_data);
buf = compiler->buf;
while (buf) {
curr = buf;
buf = buf->next;
- SLJIT_FREE(curr);
+ SLJIT_FREE(curr, allocator_data);
}
buf = compiler->abuf;
while (buf) {
curr = buf;
buf = buf->next;
- SLJIT_FREE(curr);
+ SLJIT_FREE(curr, allocator_data);
}
#if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
- SLJIT_FREE(compiler->cpool);
+ SLJIT_FREE(compiler->cpool, allocator_data);
#endif
- SLJIT_FREE(compiler);
+ SLJIT_FREE(compiler, allocator_data);
+}
+
+SLJIT_API_FUNC_ATTRIBUTE void sljit_set_compiler_memory_error(struct sljit_compiler *compiler)
+{
+ if (compiler->error == SLJIT_SUCCESS)
+ compiler->error = SLJIT_ERR_ALLOC_FAILED;
}
#if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
@@ -488,7 +494,7 @@ static void* ensure_buf(struct sljit_compiler *compiler, sljit_uw size)
compiler->buf->used_size += size;
return ret;
}
- new_frag = (struct sljit_memory_fragment*)SLJIT_MALLOC(BUF_SIZE);
+ new_frag = (struct sljit_memory_fragment*)SLJIT_MALLOC(BUF_SIZE, compiler->allocator_data);
PTR_FAIL_IF_NULL(new_frag);
new_frag->next = compiler->buf;
compiler->buf = new_frag;
@@ -507,7 +513,7 @@ static void* ensure_abuf(struct sljit_compiler *compiler, sljit_uw size)
compiler->abuf->used_size += size;
return ret;
}
- new_frag = (struct sljit_memory_fragment*)SLJIT_MALLOC(ABUF_SIZE);
+ new_frag = (struct sljit_memory_fragment*)SLJIT_MALLOC(ABUF_SIZE, compiler->allocator_data);
PTR_FAIL_IF_NULL(new_frag);
new_frag->next = compiler->abuf;
compiler->abuf = new_frag;
@@ -547,6 +553,40 @@ static SLJIT_INLINE void reverse_buf(struct sljit_compiler *compiler)
compiler->buf = prev;
}
+static SLJIT_INLINE void set_emit_enter(struct sljit_compiler *compiler,
+ sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
+ sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
+{
+ SLJIT_UNUSED_ARG(args);
+ SLJIT_UNUSED_ARG(local_size);
+
+ compiler->options = options;
+ compiler->scratches = scratches;
+ compiler->saveds = saveds;
+ compiler->fscratches = fscratches;
+ compiler->fsaveds = fsaveds;
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
+ compiler->logical_local_size = local_size;
+#endif
+}
+
+static SLJIT_INLINE void set_set_context(struct sljit_compiler *compiler,
+ sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
+ sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
+{
+ SLJIT_UNUSED_ARG(args);
+ SLJIT_UNUSED_ARG(local_size);
+
+ compiler->options = options;
+ compiler->scratches = scratches;
+ compiler->saveds = saveds;
+ compiler->fscratches = fscratches;
+ compiler->fsaveds = fsaveds;
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
+ compiler->logical_local_size = local_size;
+#endif
+}
+
static SLJIT_INLINE void set_label(struct sljit_label *label, struct sljit_compiler *compiler)
{
label->next = NULL;
@@ -583,9 +623,9 @@ static SLJIT_INLINE void set_const(struct sljit_const *const_, struct sljit_comp
#define ADDRESSING_DEPENDS_ON(exp, reg) \
(((exp) & SLJIT_MEM) && (((exp) & REG_MASK) == reg || OFFS_REG(exp) == reg))
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
#define FUNCTION_CHECK_OP() \
- SLJIT_ASSERT(!GET_FLAGS(op) || !(op & SLJIT_KEEP_FLAGS)); \
+ CHECK_ARGUMENT(!GET_FLAGS(op) || !(op & SLJIT_KEEP_FLAGS)); \
switch (GET_OPCODE(op)) { \
case SLJIT_NOT: \
case SLJIT_CLZ: \
@@ -595,27 +635,27 @@ static SLJIT_INLINE void set_const(struct sljit_const *const_, struct sljit_comp
case SLJIT_SHL: \
case SLJIT_LSHR: \
case SLJIT_ASHR: \
- SLJIT_ASSERT(!(op & (SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C))); \
+ CHECK_ARGUMENT(!(op & (SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C))); \
break; \
case SLJIT_NEG: \
- SLJIT_ASSERT(!(op & (SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_C))); \
+ CHECK_ARGUMENT(!(op & (SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_C))); \
break; \
case SLJIT_MUL: \
- SLJIT_ASSERT(!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_C))); \
+ CHECK_ARGUMENT(!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_C))); \
break; \
case SLJIT_ADD: \
- SLJIT_ASSERT(!(op & (SLJIT_SET_U | SLJIT_SET_S))); \
+ CHECK_ARGUMENT(!(op & (SLJIT_SET_U | SLJIT_SET_S))); \
break; \
case SLJIT_SUB: \
break; \
case SLJIT_ADDC: \
case SLJIT_SUBC: \
- SLJIT_ASSERT(!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O))); \
+ CHECK_ARGUMENT(!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O))); \
break; \
case SLJIT_BREAKPOINT: \
case SLJIT_NOP: \
- case SLJIT_UMUL: \
- case SLJIT_SMUL: \
+ case SLJIT_LUMUL: \
+ case SLJIT_LSMUL: \
case SLJIT_MOV: \
case SLJIT_MOV_UI: \
case SLJIT_MOV_P: \
@@ -623,109 +663,112 @@ static SLJIT_INLINE void set_const(struct sljit_const *const_, struct sljit_comp
case SLJIT_MOVU_UI: \
case SLJIT_MOVU_P: \
/* Nothing allowed */ \
- SLJIT_ASSERT(!(op & (SLJIT_INT_OP | SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
+ CHECK_ARGUMENT(!(op & (SLJIT_INT_OP | SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
break; \
default: \
/* Only SLJIT_INT_OP or SLJIT_SINGLE_OP is allowed. */ \
- SLJIT_ASSERT(!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
+ CHECK_ARGUMENT(!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
break; \
}
#define FUNCTION_CHECK_FOP() \
- SLJIT_ASSERT(!GET_FLAGS(op) || !(op & SLJIT_KEEP_FLAGS)); \
+ CHECK_ARGUMENT(!GET_FLAGS(op) || !(op & SLJIT_KEEP_FLAGS)); \
switch (GET_OPCODE(op)) { \
- case SLJIT_CMPD: \
- SLJIT_ASSERT(!(op & (SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
- SLJIT_ASSERT((op & (SLJIT_SET_E | SLJIT_SET_S))); \
+ case SLJIT_DCMP: \
+ CHECK_ARGUMENT(!(op & (SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
+ CHECK_ARGUMENT((op & (SLJIT_SET_E | SLJIT_SET_S))); \
break; \
default: \
/* Only SLJIT_INT_OP or SLJIT_SINGLE_OP is allowed. */ \
- SLJIT_ASSERT(!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
+ CHECK_ARGUMENT(!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
break; \
}
#define FUNCTION_CHECK_IS_REG(r) \
+ (((r) >= SLJIT_R0 && (r) < (SLJIT_R0 + compiler->scratches)) || \
+ ((r) > (SLJIT_S0 - compiler->saveds) && (r) <= SLJIT_S0))
+
+#define FUNCTION_CHECK_IS_REG_OR_UNUSED(r) \
((r) == SLJIT_UNUSED || \
((r) >= SLJIT_R0 && (r) < (SLJIT_R0 + compiler->scratches)) || \
((r) > (SLJIT_S0 - compiler->saveds) && (r) <= SLJIT_S0))
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
-#define FUNCTION_ASSERT_IF_VIRTUAL(p) \
- SLJIT_ASSERT((p) < SLJIT_R3 || (p) > SLJIT_R6);
+#define CHECK_NOT_VIRTUAL_REGISTER(p) \
+ CHECK_ARGUMENT((p) < SLJIT_R3 || (p) > SLJIT_R6);
#else
-#define FUNCTION_ASSERT_IF_VIRTUAL(p)
+#define CHECK_NOT_VIRTUAL_REGISTER(p)
#endif
#define FUNCTION_CHECK_SRC(p, i) \
- SLJIT_ASSERT(compiler->scratches != -1 && compiler->saveds != -1); \
+ CHECK_ARGUMENT(compiler->scratches != -1 && compiler->saveds != -1); \
if (FUNCTION_CHECK_IS_REG(p)) \
- SLJIT_ASSERT((i) == 0 && (p) != SLJIT_UNUSED); \
+ CHECK_ARGUMENT((i) == 0); \
else if ((p) == SLJIT_IMM) \
; \
else if ((p) == (SLJIT_MEM1(SLJIT_SP))) \
- SLJIT_ASSERT((i) >= 0 && (i) < compiler->logical_local_size); \
- else if ((p) & SLJIT_MEM) { \
- SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & REG_MASK)); \
- FUNCTION_ASSERT_IF_VIRTUAL((p) & REG_MASK); \
+ CHECK_ARGUMENT((i) >= 0 && (i) < compiler->logical_local_size); \
+ else { \
+ CHECK_ARGUMENT((p) & SLJIT_MEM); \
+ CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG_OR_UNUSED((p) & REG_MASK)); \
+ CHECK_NOT_VIRTUAL_REGISTER((p) & REG_MASK); \
if ((p) & OFFS_REG_MASK) { \
- SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(OFFS_REG(p))); \
- FUNCTION_ASSERT_IF_VIRTUAL(OFFS_REG(p)); \
- SLJIT_ASSERT(!((i) & ~0x3)); \
+ CHECK_ARGUMENT(((p) & REG_MASK) != SLJIT_UNUSED); \
+ CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG(OFFS_REG(p))); \
+ CHECK_NOT_VIRTUAL_REGISTER(OFFS_REG(p)); \
+ CHECK_ARGUMENT(!((i) & ~0x3)); \
} \
- SLJIT_ASSERT(!((p) & ~(SLJIT_MEM | SLJIT_IMM | REG_MASK | OFFS_REG_MASK))); \
- } \
- else \
- SLJIT_ASSERT_STOP();
+ CHECK_ARGUMENT(!((p) & ~(SLJIT_MEM | SLJIT_IMM | REG_MASK | OFFS_REG_MASK))); \
+ }
#define FUNCTION_CHECK_DST(p, i) \
- SLJIT_ASSERT(compiler->scratches != -1 && compiler->saveds != -1); \
- if (FUNCTION_CHECK_IS_REG(p)) \
- SLJIT_ASSERT((i) == 0); \
+ CHECK_ARGUMENT(compiler->scratches != -1 && compiler->saveds != -1); \
+ if (FUNCTION_CHECK_IS_REG_OR_UNUSED(p)) \
+ CHECK_ARGUMENT((i) == 0); \
else if ((p) == (SLJIT_MEM1(SLJIT_SP))) \
- SLJIT_ASSERT((i) >= 0 && (i) < compiler->logical_local_size); \
- else if ((p) & SLJIT_MEM) { \
- SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & REG_MASK)); \
- FUNCTION_ASSERT_IF_VIRTUAL((p) & REG_MASK); \
+ CHECK_ARGUMENT((i) >= 0 && (i) < compiler->logical_local_size); \
+ else { \
+ CHECK_ARGUMENT((p) & SLJIT_MEM); \
+ CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG_OR_UNUSED((p) & REG_MASK)); \
+ CHECK_NOT_VIRTUAL_REGISTER((p) & REG_MASK); \
if ((p) & OFFS_REG_MASK) { \
- SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(OFFS_REG(p))); \
- FUNCTION_ASSERT_IF_VIRTUAL(OFFS_REG(p)); \
- SLJIT_ASSERT(!((i) & ~0x3)); \
+ CHECK_ARGUMENT(((p) & REG_MASK) != SLJIT_UNUSED); \
+ CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG(OFFS_REG(p))); \
+ CHECK_NOT_VIRTUAL_REGISTER(OFFS_REG(p)); \
+ CHECK_ARGUMENT(!((i) & ~0x3)); \
} \
- SLJIT_ASSERT(!((p) & ~(SLJIT_MEM | SLJIT_IMM | REG_MASK | OFFS_REG_MASK))); \
- } \
- else \
- SLJIT_ASSERT_STOP();
+ CHECK_ARGUMENT(!((p) & ~(SLJIT_MEM | SLJIT_IMM | REG_MASK | OFFS_REG_MASK))); \
+ }
#define FUNCTION_FCHECK(p, i) \
- SLJIT_ASSERT(compiler->fscratches != -1 && compiler->fsaveds != -1); \
+ CHECK_ARGUMENT(compiler->fscratches != -1 && compiler->fsaveds != -1); \
if (((p) >= SLJIT_FR0 && (p) < (SLJIT_FR0 + compiler->fscratches)) || \
((p) > (SLJIT_FS0 - compiler->fsaveds) && (p) <= SLJIT_FS0)) \
- SLJIT_ASSERT(i == 0); \
+ CHECK_ARGUMENT(i == 0); \
else if ((p) == (SLJIT_MEM1(SLJIT_SP))) \
- SLJIT_ASSERT((i) >= 0 && (i) < compiler->logical_local_size); \
- else if ((p) & SLJIT_MEM) { \
- SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & REG_MASK)); \
- FUNCTION_ASSERT_IF_VIRTUAL((p) & REG_MASK); \
+ CHECK_ARGUMENT((i) >= 0 && (i) < compiler->logical_local_size); \
+ else { \
+ CHECK_ARGUMENT((p) & SLJIT_MEM); \
+ CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG_OR_UNUSED((p) & REG_MASK)); \
+ CHECK_NOT_VIRTUAL_REGISTER((p) & REG_MASK); \
if ((p) & OFFS_REG_MASK) { \
- SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(OFFS_REG(p))); \
- FUNCTION_ASSERT_IF_VIRTUAL(OFFS_REG(p)); \
- SLJIT_ASSERT(((p) & OFFS_REG_MASK) != TO_OFFS_REG(SLJIT_SP) && !(i & ~0x3)); \
- } else \
- SLJIT_ASSERT(OFFS_REG(p) == 0); \
- SLJIT_ASSERT(!((p) & ~(SLJIT_MEM | SLJIT_IMM | REG_MASK | OFFS_REG_MASK))); \
- } \
- else \
- SLJIT_ASSERT_STOP();
+ CHECK_ARGUMENT(((p) & REG_MASK) != SLJIT_UNUSED); \
+ CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG(OFFS_REG(p))); \
+ CHECK_NOT_VIRTUAL_REGISTER(OFFS_REG(p)); \
+ CHECK_ARGUMENT(((p) & OFFS_REG_MASK) != TO_OFFS_REG(SLJIT_SP) && !(i & ~0x3)); \
+ } \
+ CHECK_ARGUMENT(!((p) & ~(SLJIT_MEM | SLJIT_IMM | REG_MASK | OFFS_REG_MASK))); \
+ }
#define FUNCTION_CHECK_OP1() \
if (GET_OPCODE(op) >= SLJIT_MOVU && GET_OPCODE(op) <= SLJIT_MOVU_P) { \
- SLJIT_ASSERT(!(src & SLJIT_MEM) || (src & REG_MASK) != SLJIT_SP); \
- SLJIT_ASSERT(!(dst & SLJIT_MEM) || (dst & REG_MASK) != SLJIT_SP); \
+ CHECK_ARGUMENT(!(src & SLJIT_MEM) || (src & REG_MASK) != SLJIT_SP); \
+ CHECK_ARGUMENT(!(dst & SLJIT_MEM) || (dst & REG_MASK) != SLJIT_SP); \
if ((src & SLJIT_MEM) && (src & REG_MASK)) \
- SLJIT_ASSERT((dst & REG_MASK) != (src & REG_MASK) && OFFS_REG(dst) != (src & REG_MASK)); \
+ CHECK_ARGUMENT((dst & REG_MASK) != (src & REG_MASK) && OFFS_REG(dst) != (src & REG_MASK)); \
}
-#endif
+#endif /* SLJIT_ARGUMENT_CHECKS */
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
@@ -803,14 +846,14 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_compiler_verbose(struct sljit_compiler *comp
static SLJIT_CONST char* op0_names[] = {
(char*)"breakpoint", (char*)"nop",
- (char*)"umul", (char*)"smul", (char*)"udiv", (char*)"sdiv",
+ (char*)"lumul", (char*)"lsmul", (char*)"ludiv", (char*)"lsdiv",
};
static SLJIT_CONST char* op1_names[] = {
- (char*)"mov", (char*)"mov.ub", (char*)"mov.sb", (char*)"mov.uh",
- (char*)"mov.sh", (char*)"mov.ui", (char*)"mov.si", (char*)"mov.p",
- (char*)"movu", (char*)"movu.ub", (char*)"movu.sb", (char*)"movu.uh",
- (char*)"movu.sh", (char*)"movu.ui", (char*)"movu.si", (char*)"movu.p",
+ (char*)"mov", (char*)"mov_ub", (char*)"mov_sb", (char*)"mov_uh",
+ (char*)"mov_sh", (char*)"mov_ui", (char*)"mov_si", (char*)"mov_p",
+ (char*)"movu", (char*)"movu_ub", (char*)"movu_sb", (char*)"movu_uh",
+ (char*)"movu_sh", (char*)"movu_ui", (char*)"movu_si", (char*)"movu_p",
(char*)"not", (char*)"neg", (char*)"clz",
};
@@ -830,6 +873,10 @@ static SLJIT_CONST char* fop2_names[] = {
(char*)"add", (char*)"sub", (char*)"mul", (char*)"div"
};
+#define JUMP_PREFIX(type) \
+ ((type & 0xff) <= SLJIT_MUL_NOT_OVERFLOW ? ((type & SLJIT_INT_OP) ? "i_" : "") \
+ : ((type & 0xff) <= SLJIT_D_ORDERED ? ((type & SLJIT_SINGLE_OP) ? "s_" : "d_") : ""))
+
static char* jump_names[] = {
(char*)"equal", (char*)"not_equal",
(char*)"less", (char*)"greater_equal",
@@ -838,123 +885,108 @@ static char* jump_names[] = {
(char*)"sig_greater", (char*)"sig_less_equal",
(char*)"overflow", (char*)"not_overflow",
(char*)"mul_overflow", (char*)"mul_not_overflow",
- (char*)"float_equal", (char*)"float_not_equal",
- (char*)"float_less", (char*)"float_greater_equal",
- (char*)"float_greater", (char*)"float_less_equal",
- (char*)"float_unordered", (char*)"float_ordered",
+ (char*)"equal", (char*)"not_equal",
+ (char*)"less", (char*)"greater_equal",
+ (char*)"greater", (char*)"less_equal",
+ (char*)"unordered", (char*)"ordered",
(char*)"jump", (char*)"fast_call",
(char*)"call0", (char*)"call1", (char*)"call2", (char*)"call3"
};
-#endif
+#endif /* SLJIT_VERBOSE */
/* --------------------------------------------------------------------- */
/* Arch dependent */
/* --------------------------------------------------------------------- */
-static SLJIT_INLINE void check_sljit_generate_code(struct sljit_compiler *compiler)
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS) \
+ || (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
+
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_generate_code(struct sljit_compiler *compiler)
{
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
struct sljit_jump *jump;
#endif
- /* If debug and verbose are disabled, all arguments are unused. */
+
SLJIT_UNUSED_ARG(compiler);
- SLJIT_ASSERT(compiler->size > 0);
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
+ CHECK_ARGUMENT(compiler->size > 0);
jump = compiler->jumps;
while (jump) {
/* All jumps have target. */
- SLJIT_ASSERT(jump->flags & (JUMP_LABEL | JUMP_ADDR));
+ CHECK_ARGUMENT(jump->flags & (JUMP_LABEL | JUMP_ADDR));
jump = jump->next;
}
#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_emit_enter(struct sljit_compiler *compiler,
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_enter(struct sljit_compiler *compiler,
sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
{
- /* If debug and verbose are disabled, all arguments are unused. */
SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(options);
- SLJIT_UNUSED_ARG(args);
- SLJIT_UNUSED_ARG(scratches);
- SLJIT_UNUSED_ARG(saveds);
- SLJIT_UNUSED_ARG(fscratches);
- SLJIT_UNUSED_ARG(fsaveds);
- SLJIT_UNUSED_ARG(local_size);
- SLJIT_ASSERT(options == 0);
- SLJIT_ASSERT(args >= 0 && args <= 3);
- SLJIT_ASSERT(scratches >= 0 && scratches <= SLJIT_NUMBER_OF_REGISTERS);
- SLJIT_ASSERT(saveds >= 0 && saveds <= SLJIT_NUMBER_OF_REGISTERS);
- SLJIT_ASSERT(scratches + saveds <= SLJIT_NUMBER_OF_REGISTERS);
- SLJIT_ASSERT(args <= saveds);
- SLJIT_ASSERT(fscratches >= 0 && fscratches <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
- SLJIT_ASSERT(fsaveds >= 0 && fsaveds <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
- SLJIT_ASSERT(fscratches + fsaveds <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
- SLJIT_ASSERT(local_size >= 0 && local_size <= SLJIT_MAX_LOCAL_SIZE);
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
+ CHECK_ARGUMENT(!(options & ~SLJIT_DOUBLE_ALIGNMENT));
+ CHECK_ARGUMENT(args >= 0 && args <= 3);
+ CHECK_ARGUMENT(scratches >= 0 && scratches <= SLJIT_NUMBER_OF_REGISTERS);
+ CHECK_ARGUMENT(saveds >= 0 && saveds <= SLJIT_NUMBER_OF_REGISTERS);
+ CHECK_ARGUMENT(scratches + saveds <= SLJIT_NUMBER_OF_REGISTERS);
+ CHECK_ARGUMENT(args <= saveds);
+ CHECK_ARGUMENT(fscratches >= 0 && fscratches <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
+ CHECK_ARGUMENT(fsaveds >= 0 && fsaveds <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
+ CHECK_ARGUMENT(fscratches + fsaveds <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
+ CHECK_ARGUMENT(local_size >= 0 && local_size <= SLJIT_MAX_LOCAL_SIZE);
+#endif
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
if (SLJIT_UNLIKELY(!!compiler->verbose))
fprintf(compiler->verbose, " enter options:none args:%d scratches:%d saveds:%d fscratches:%d fsaveds:%d local_size:%d\n",
args, scratches, saveds, fscratches, fsaveds, local_size);
#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_set_context(struct sljit_compiler *compiler,
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_set_context(struct sljit_compiler *compiler,
sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
{
- /* If debug and verbose are disabled, all arguments are unused. */
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(options);
- SLJIT_UNUSED_ARG(args);
- SLJIT_UNUSED_ARG(scratches);
- SLJIT_UNUSED_ARG(saveds);
- SLJIT_UNUSED_ARG(fscratches);
- SLJIT_UNUSED_ARG(fsaveds);
- SLJIT_UNUSED_ARG(local_size);
-
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
if (SLJIT_UNLIKELY(compiler->skip_checks)) {
compiler->skip_checks = 0;
- return;
+ CHECK_RETURN_OK;
}
-#endif
- SLJIT_ASSERT(options == 0);
- SLJIT_ASSERT(args >= 0 && args <= 3);
- SLJIT_ASSERT(scratches >= 0 && scratches <= SLJIT_NUMBER_OF_REGISTERS);
- SLJIT_ASSERT(saveds >= 0 && saveds <= SLJIT_NUMBER_OF_REGISTERS);
- SLJIT_ASSERT(scratches + saveds <= SLJIT_NUMBER_OF_REGISTERS);
- SLJIT_ASSERT(args <= saveds);
- SLJIT_ASSERT(fscratches >= 0 && fscratches <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
- SLJIT_ASSERT(fsaveds >= 0 && fsaveds <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
- SLJIT_ASSERT(fscratches + fsaveds <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
- SLJIT_ASSERT(local_size >= 0 && local_size <= SLJIT_MAX_LOCAL_SIZE);
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
+ CHECK_ARGUMENT(!(options & ~SLJIT_DOUBLE_ALIGNMENT));
+ CHECK_ARGUMENT(args >= 0 && args <= 3);
+ CHECK_ARGUMENT(scratches >= 0 && scratches <= SLJIT_NUMBER_OF_REGISTERS);
+ CHECK_ARGUMENT(saveds >= 0 && saveds <= SLJIT_NUMBER_OF_REGISTERS);
+ CHECK_ARGUMENT(scratches + saveds <= SLJIT_NUMBER_OF_REGISTERS);
+ CHECK_ARGUMENT(args <= saveds);
+ CHECK_ARGUMENT(fscratches >= 0 && fscratches <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
+ CHECK_ARGUMENT(fsaveds >= 0 && fsaveds <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
+ CHECK_ARGUMENT(fscratches + fsaveds <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
+ CHECK_ARGUMENT(local_size >= 0 && local_size <= SLJIT_MAX_LOCAL_SIZE);
+#endif
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
if (SLJIT_UNLIKELY(!!compiler->verbose))
fprintf(compiler->verbose, " set_context options:none args:%d scratches:%d saveds:%d fscratches:%d fsaveds:%d local_size:%d\n",
args, scratches, saveds, fscratches, fsaveds, local_size);
#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
{
- /* If debug and verbose are disabled, all arguments are unused. */
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(op);
- SLJIT_UNUSED_ARG(src);
- SLJIT_UNUSED_ARG(srcw);
-
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
+ CHECK_ARGUMENT(compiler->scratches >= 0);
if (op != SLJIT_UNUSED) {
- SLJIT_ASSERT(op >= SLJIT_MOV && op <= SLJIT_MOV_P);
+ CHECK_ARGUMENT(op >= SLJIT_MOV && op <= SLJIT_MOV_P);
FUNCTION_CHECK_SRC(src, srcw);
}
else
- SLJIT_ASSERT(src == 0 && srcw == 0);
+ CHECK_ARGUMENT(src == 0 && srcw == 0);
#endif
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
if (SLJIT_UNLIKELY(!!compiler->verbose)) {
@@ -967,16 +999,12 @@ static SLJIT_INLINE void check_sljit_emit_return(struct sljit_compiler *compiler
}
}
#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw)
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw)
{
- /* If debug and verbose are disabled, all arguments are unused. */
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(dst);
- SLJIT_UNUSED_ARG(dstw);
-
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
FUNCTION_CHECK_DST(dst, dstw);
#endif
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
@@ -986,16 +1014,12 @@ static SLJIT_INLINE void check_sljit_emit_fast_enter(struct sljit_compiler *comp
fprintf(compiler->verbose, "\n");
}
#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw)
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw)
{
- /* If debug and verbose are disabled, all arguments are unused. */
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(src);
- SLJIT_UNUSED_ARG(srcw);
-
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
FUNCTION_CHECK_SRC(src, srcw);
#endif
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
@@ -1005,44 +1029,34 @@ static SLJIT_INLINE void check_sljit_emit_fast_return(struct sljit_compiler *com
fprintf(compiler->verbose, "\n");
}
#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op)
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op)
{
- /* If debug and verbose are disabled, all arguments are unused. */
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(op);
-
- SLJIT_ASSERT((op >= SLJIT_BREAKPOINT && op <= SLJIT_SMUL)
- || ((op & ~SLJIT_INT_OP) >= SLJIT_UDIV && (op & ~SLJIT_INT_OP) <= SLJIT_SDIV));
- SLJIT_ASSERT(op < SLJIT_UMUL || compiler->scratches >= 2);
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
+ CHECK_ARGUMENT((op >= SLJIT_BREAKPOINT && op <= SLJIT_LSMUL)
+ || ((op & ~SLJIT_INT_OP) >= SLJIT_LUDIV && (op & ~SLJIT_INT_OP) <= SLJIT_LSDIV));
+ CHECK_ARGUMENT(op < SLJIT_LUMUL || compiler->scratches >= 2);
+#endif
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
if (SLJIT_UNLIKELY(!!compiler->verbose))
fprintf(compiler->verbose, " %s%s\n", !(op & SLJIT_INT_OP) ? "" : "i", op0_names[GET_OPCODE(op) - SLJIT_OP0_BASE]);
#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_emit_op1(struct sljit_compiler *compiler, sljit_si op,
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_op1(struct sljit_compiler *compiler, sljit_si op,
sljit_si dst, sljit_sw dstw,
sljit_si src, sljit_sw srcw)
{
- /* If debug and verbose are disabled, all arguments are unused. */
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(op);
- SLJIT_UNUSED_ARG(dst);
- SLJIT_UNUSED_ARG(dstw);
- SLJIT_UNUSED_ARG(src);
- SLJIT_UNUSED_ARG(srcw);
-
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
if (SLJIT_UNLIKELY(compiler->skip_checks)) {
compiler->skip_checks = 0;
- return;
+ CHECK_RETURN_OK;
}
-#endif
- SLJIT_ASSERT(GET_OPCODE(op) >= SLJIT_MOV && GET_OPCODE(op) <= SLJIT_CLZ);
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
+ CHECK_ARGUMENT(GET_OPCODE(op) >= SLJIT_MOV && GET_OPCODE(op) <= SLJIT_CLZ);
FUNCTION_CHECK_OP();
FUNCTION_CHECK_SRC(src, srcw);
FUNCTION_CHECK_DST(dst, dstw);
@@ -1059,32 +1073,21 @@ static SLJIT_INLINE void check_sljit_emit_op1(struct sljit_compiler *compiler, s
fprintf(compiler->verbose, "\n");
}
#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_emit_op2(struct sljit_compiler *compiler, sljit_si op,
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_op2(struct sljit_compiler *compiler, sljit_si op,
sljit_si dst, sljit_sw dstw,
sljit_si src1, sljit_sw src1w,
sljit_si src2, sljit_sw src2w)
{
- /* If debug and verbose are disabled, all arguments are unused. */
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(op);
- SLJIT_UNUSED_ARG(dst);
- SLJIT_UNUSED_ARG(dstw);
- SLJIT_UNUSED_ARG(src1);
- SLJIT_UNUSED_ARG(src1w);
- SLJIT_UNUSED_ARG(src2);
- SLJIT_UNUSED_ARG(src2w);
-
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
if (SLJIT_UNLIKELY(compiler->skip_checks)) {
compiler->skip_checks = 0;
- return;
+ CHECK_RETURN_OK;
}
-#endif
- SLJIT_ASSERT(GET_OPCODE(op) >= SLJIT_ADD && GET_OPCODE(op) <= SLJIT_ASHR);
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
+ CHECK_ARGUMENT(GET_OPCODE(op) >= SLJIT_ADD && GET_OPCODE(op) <= SLJIT_ASHR);
FUNCTION_CHECK_OP();
FUNCTION_CHECK_SRC(src1, src1w);
FUNCTION_CHECK_SRC(src2, src2w);
@@ -1103,152 +1106,134 @@ static SLJIT_INLINE void check_sljit_emit_op2(struct sljit_compiler *compiler, s
fprintf(compiler->verbose, "\n");
}
#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_get_register_index(sljit_si reg)
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_get_register_index(sljit_si reg)
{
SLJIT_UNUSED_ARG(reg);
- SLJIT_ASSERT(reg > 0 && reg <= SLJIT_NUMBER_OF_REGISTERS);
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
+ CHECK_ARGUMENT(reg > 0 && reg <= SLJIT_NUMBER_OF_REGISTERS);
+#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_get_float_register_index(sljit_si reg)
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_get_float_register_index(sljit_si reg)
{
SLJIT_UNUSED_ARG(reg);
- SLJIT_ASSERT(reg > 0 && reg <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
+ CHECK_ARGUMENT(reg > 0 && reg <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
+#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_emit_op_custom(struct sljit_compiler *compiler,
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_op_custom(struct sljit_compiler *compiler,
void *instruction, sljit_si size)
{
+#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
+ int i;
+#endif
+
SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(instruction);
- SLJIT_UNUSED_ARG(size);
- SLJIT_ASSERT(instruction);
-}
-#define SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw) \
- SLJIT_ASSERT(sljit_is_fpu_available()); \
- SLJIT_COMPILE_ASSERT(!(SLJIT_CONVW_FROMD & 0x1) && !(SLJIT_CONVD_FROMW & 0x1), \
- invalid_float_opcodes); \
- if (GET_OPCODE(op) >= SLJIT_CONVW_FROMD && GET_OPCODE(op) <= SLJIT_CMPD) { \
- if (GET_OPCODE(op) == SLJIT_CMPD) { \
- check_sljit_emit_fop1_cmp(compiler, op, dst, dstw, src, srcw); \
- ADJUST_LOCAL_OFFSET(dst, dstw); \
- ADJUST_LOCAL_OFFSET(src, srcw); \
- return sljit_emit_fop1_cmp(compiler, op, dst, dstw, src, srcw); \
- } \
- if ((GET_OPCODE(op) | 0x1) == SLJIT_CONVI_FROMD) { \
- check_sljit_emit_fop1_convw_fromd(compiler, op, dst, dstw, src, srcw); \
- ADJUST_LOCAL_OFFSET(dst, dstw); \
- ADJUST_LOCAL_OFFSET(src, srcw); \
- return sljit_emit_fop1_convw_fromd(compiler, op, dst, dstw, src, srcw); \
- } \
- check_sljit_emit_fop1_convd_fromw(compiler, op, dst, dstw, src, srcw); \
- ADJUST_LOCAL_OFFSET(dst, dstw); \
- ADJUST_LOCAL_OFFSET(src, srcw); \
- return sljit_emit_fop1_convd_fromw(compiler, op, dst, dstw, src, srcw); \
- } \
- check_sljit_emit_fop1(compiler, op, dst, dstw, src, srcw); \
- ADJUST_LOCAL_OFFSET(dst, dstw); \
- ADJUST_LOCAL_OFFSET(src, srcw);
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
+ CHECK_ARGUMENT(instruction);
+#if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
+ CHECK_ARGUMENT(size > 0 && size < 16);
+#elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
+ CHECK_ARGUMENT((size == 2 && (((sljit_sw)instruction) & 0x1) == 0)
+ || (size == 4 && (((sljit_sw)instruction) & 0x3) == 0));
+#else
+ CHECK_ARGUMENT(size == 4 && (((sljit_sw)instruction) & 0x3) == 0);
+#endif
-static SLJIT_INLINE void check_sljit_emit_fop1(struct sljit_compiler *compiler, sljit_si op,
+#endif
+#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
+ if (SLJIT_UNLIKELY(!!compiler->verbose)) {
+ fprintf(compiler->verbose, " op_custom");
+ for (i = 0; i < size; i++)
+ fprintf(compiler->verbose, " 0x%x", ((sljit_ub*)instruction)[i]);
+ fprintf(compiler->verbose, "\n");
+ }
+#endif
+ CHECK_RETURN_OK;
+}
+
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fop1(struct sljit_compiler *compiler, sljit_si op,
sljit_si dst, sljit_sw dstw,
sljit_si src, sljit_sw srcw)
{
- /* If debug and verbose are disabled, all arguments are unused. */
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(op);
- SLJIT_UNUSED_ARG(dst);
- SLJIT_UNUSED_ARG(dstw);
- SLJIT_UNUSED_ARG(src);
- SLJIT_UNUSED_ARG(srcw);
-
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
if (SLJIT_UNLIKELY(compiler->skip_checks)) {
compiler->skip_checks = 0;
- return;
+ CHECK_RETURN_OK;
}
-#endif
- SLJIT_ASSERT(GET_OPCODE(op) >= SLJIT_MOVD && GET_OPCODE(op) <= SLJIT_ABSD);
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
+ CHECK_ARGUMENT(sljit_is_fpu_available());
+ CHECK_ARGUMENT(GET_OPCODE(op) >= SLJIT_DMOV && GET_OPCODE(op) <= SLJIT_DABS);
FUNCTION_CHECK_FOP();
FUNCTION_FCHECK(src, srcw);
FUNCTION_FCHECK(dst, dstw);
#endif
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- fprintf(compiler->verbose, " %s%s ", fop1_names[GET_OPCODE(op) - SLJIT_FOP1_BASE],
- (GET_OPCODE(op) == SLJIT_CONVD_FROMS)
- ? ((op & SLJIT_SINGLE_OP) ? "s.fromd" : "d.froms")
- : ((op & SLJIT_SINGLE_OP) ? "s" : "d"));
+ if (GET_OPCODE(op) == SLJIT_CONVD_FROMS)
+ fprintf(compiler->verbose, " %s%s ", fop1_names[SLJIT_CONVD_FROMS - SLJIT_FOP1_BASE],
+ (op & SLJIT_SINGLE_OP) ? "s.fromd" : "d.froms");
+ else
+ fprintf(compiler->verbose, " %s%s ", (op & SLJIT_SINGLE_OP) ? "s" : "d",
+ fop1_names[GET_OPCODE(op) - SLJIT_FOP1_BASE]);
+
sljit_verbose_fparam(compiler, dst, dstw);
fprintf(compiler->verbose, ", ");
sljit_verbose_fparam(compiler, src, srcw);
fprintf(compiler->verbose, "\n");
}
#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_emit_fop1_cmp(struct sljit_compiler *compiler, sljit_si op,
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fop1_cmp(struct sljit_compiler *compiler, sljit_si op,
sljit_si src1, sljit_sw src1w,
sljit_si src2, sljit_sw src2w)
{
- /* If debug and verbose are disabled, all arguments are unused. */
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(op);
- SLJIT_UNUSED_ARG(src1);
- SLJIT_UNUSED_ARG(src1w);
- SLJIT_UNUSED_ARG(src2);
- SLJIT_UNUSED_ARG(src2w);
-
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
if (SLJIT_UNLIKELY(compiler->skip_checks)) {
compiler->skip_checks = 0;
- return;
+ CHECK_RETURN_OK;
}
-#endif
- SLJIT_ASSERT(GET_OPCODE(op) == SLJIT_CMPD);
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
+ CHECK_ARGUMENT(sljit_is_fpu_available());
+ CHECK_ARGUMENT(GET_OPCODE(op) == SLJIT_DCMP);
FUNCTION_CHECK_FOP();
FUNCTION_FCHECK(src1, src1w);
FUNCTION_FCHECK(src2, src2w);
#endif
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- fprintf(compiler->verbose, " %s%s%s%s ", fop1_names[GET_OPCODE(op) - SLJIT_FOP1_BASE], (op & SLJIT_SINGLE_OP) ? "s" : "d",
- !(op & SLJIT_SET_E) ? "" : ".e", !(op & SLJIT_SET_S) ? "" : ".s");
+ fprintf(compiler->verbose, " %s%s%s%s ", (op & SLJIT_SINGLE_OP) ? "s" : "d", fop1_names[SLJIT_DCMP - SLJIT_FOP1_BASE],
+ (op & SLJIT_SET_E) ? ".e" : "", (op & SLJIT_SET_S) ? ".s" : "");
sljit_verbose_fparam(compiler, src1, src1w);
fprintf(compiler->verbose, ", ");
sljit_verbose_fparam(compiler, src2, src2w);
fprintf(compiler->verbose, "\n");
}
#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_emit_fop1_convw_fromd(struct sljit_compiler *compiler, sljit_si op,
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fop1_convw_fromd(struct sljit_compiler *compiler, sljit_si op,
sljit_si dst, sljit_sw dstw,
sljit_si src, sljit_sw srcw)
{
- /* If debug and verbose are disabled, all arguments are unused. */
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(op);
- SLJIT_UNUSED_ARG(dst);
- SLJIT_UNUSED_ARG(dstw);
- SLJIT_UNUSED_ARG(src);
- SLJIT_UNUSED_ARG(srcw);
-
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
if (SLJIT_UNLIKELY(compiler->skip_checks)) {
compiler->skip_checks = 0;
- return;
+ CHECK_RETURN_OK;
}
-#endif
- SLJIT_ASSERT(GET_OPCODE(op) >= SLJIT_CONVW_FROMD && GET_OPCODE(op) <= SLJIT_CONVI_FROMD);
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
+ CHECK_ARGUMENT(sljit_is_fpu_available());
+ CHECK_ARGUMENT(GET_OPCODE(op) >= SLJIT_CONVW_FROMD && GET_OPCODE(op) <= SLJIT_CONVI_FROMD);
FUNCTION_CHECK_FOP();
FUNCTION_FCHECK(src, srcw);
FUNCTION_CHECK_DST(dst, dstw);
@@ -1264,29 +1249,21 @@ static SLJIT_INLINE void check_sljit_emit_fop1_convw_fromd(struct sljit_compiler
fprintf(compiler->verbose, "\n");
}
#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_emit_fop1_convd_fromw(struct sljit_compiler *compiler, sljit_si op,
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fop1_convd_fromw(struct sljit_compiler *compiler, sljit_si op,
sljit_si dst, sljit_sw dstw,
sljit_si src, sljit_sw srcw)
{
- /* If debug and verbose are disabled, all arguments are unused. */
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(op);
- SLJIT_UNUSED_ARG(dst);
- SLJIT_UNUSED_ARG(dstw);
- SLJIT_UNUSED_ARG(src);
- SLJIT_UNUSED_ARG(srcw);
-
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
if (SLJIT_UNLIKELY(compiler->skip_checks)) {
compiler->skip_checks = 0;
- return;
+ CHECK_RETURN_OK;
}
-#endif
- SLJIT_ASSERT(GET_OPCODE(op) >= SLJIT_CONVD_FROMW && GET_OPCODE(op) <= SLJIT_CONVD_FROMI);
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
+ CHECK_ARGUMENT(sljit_is_fpu_available());
+ CHECK_ARGUMENT(GET_OPCODE(op) >= SLJIT_CONVD_FROMW && GET_OPCODE(op) <= SLJIT_CONVD_FROMI);
FUNCTION_CHECK_FOP();
FUNCTION_CHECK_SRC(src, srcw);
FUNCTION_FCHECK(dst, dstw);
@@ -1302,26 +1279,17 @@ static SLJIT_INLINE void check_sljit_emit_fop1_convd_fromw(struct sljit_compiler
fprintf(compiler->verbose, "\n");
}
#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_emit_fop2(struct sljit_compiler *compiler, sljit_si op,
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fop2(struct sljit_compiler *compiler, sljit_si op,
sljit_si dst, sljit_sw dstw,
sljit_si src1, sljit_sw src1w,
sljit_si src2, sljit_sw src2w)
{
- /* If debug and verbose are disabled, all arguments are unused. */
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(op);
- SLJIT_UNUSED_ARG(dst);
- SLJIT_UNUSED_ARG(dstw);
- SLJIT_UNUSED_ARG(src1);
- SLJIT_UNUSED_ARG(src1w);
- SLJIT_UNUSED_ARG(src2);
- SLJIT_UNUSED_ARG(src2w);
-
- SLJIT_ASSERT(sljit_is_fpu_available());
- SLJIT_ASSERT(GET_OPCODE(op) >= SLJIT_ADDD && GET_OPCODE(op) <= SLJIT_DIVD);
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
+ CHECK_ARGUMENT(sljit_is_fpu_available());
+ CHECK_ARGUMENT(GET_OPCODE(op) >= SLJIT_DADD && GET_OPCODE(op) <= SLJIT_DDIV);
FUNCTION_CHECK_FOP();
FUNCTION_FCHECK(src1, src1w);
FUNCTION_FCHECK(src2, src2w);
@@ -1329,7 +1297,7 @@ static SLJIT_INLINE void check_sljit_emit_fop2(struct sljit_compiler *compiler,
#endif
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- fprintf(compiler->verbose, " %s%s ", fop2_names[GET_OPCODE(op) - SLJIT_FOP2_BASE], (op & SLJIT_SINGLE_OP) ? "s" : "d");
+ fprintf(compiler->verbose, " %s%s ", (op & SLJIT_SINGLE_OP) ? "s" : "d", fop2_names[GET_OPCODE(op) - SLJIT_FOP2_BASE]);
sljit_verbose_fparam(compiler, dst, dstw);
fprintf(compiler->verbose, ", ");
sljit_verbose_fparam(compiler, src1, src1w);
@@ -1338,115 +1306,98 @@ static SLJIT_INLINE void check_sljit_emit_fop2(struct sljit_compiler *compiler,
fprintf(compiler->verbose, "\n");
}
#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_emit_label(struct sljit_compiler *compiler)
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_label(struct sljit_compiler *compiler)
{
- /* If debug and verbose are disabled, all arguments are unused. */
SLJIT_UNUSED_ARG(compiler);
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
if (SLJIT_UNLIKELY(!!compiler->verbose))
fprintf(compiler->verbose, "label:\n");
#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_emit_jump(struct sljit_compiler *compiler, sljit_si type)
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_jump(struct sljit_compiler *compiler, sljit_si type)
{
- /* If debug and verbose are disabled, all arguments are unused. */
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(type);
-
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
if (SLJIT_UNLIKELY(compiler->skip_checks)) {
compiler->skip_checks = 0;
- return;
+ CHECK_RETURN_OK;
}
-#endif
- SLJIT_ASSERT(!(type & ~(0xff | SLJIT_REWRITABLE_JUMP)));
- SLJIT_ASSERT((type & 0xff) >= SLJIT_C_EQUAL && (type & 0xff) <= SLJIT_CALL3);
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
+ CHECK_ARGUMENT(!(type & ~(0xff | SLJIT_REWRITABLE_JUMP | SLJIT_INT_OP)));
+ CHECK_ARGUMENT((type & 0xff) >= SLJIT_EQUAL && (type & 0xff) <= SLJIT_CALL3);
+ CHECK_ARGUMENT((type & 0xff) < SLJIT_JUMP || !(type & SLJIT_INT_OP));
+ CHECK_ARGUMENT((type & 0xff) <= SLJIT_CALL0 || ((type & 0xff) - SLJIT_CALL0) <= compiler->scratches);
+#endif
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
if (SLJIT_UNLIKELY(!!compiler->verbose))
- fprintf(compiler->verbose, " jump%s.%s\n", !(type & SLJIT_REWRITABLE_JUMP) ? "" : ".r", jump_names[type & 0xff]);
+ fprintf(compiler->verbose, " jump%s.%s%s\n", !(type & SLJIT_REWRITABLE_JUMP) ? "" : ".r",
+ JUMP_PREFIX(type), jump_names[type & 0xff]);
#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_emit_cmp(struct sljit_compiler *compiler, sljit_si type,
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_cmp(struct sljit_compiler *compiler, sljit_si type,
sljit_si src1, sljit_sw src1w,
sljit_si src2, sljit_sw src2w)
{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(type);
- SLJIT_UNUSED_ARG(src1);
- SLJIT_UNUSED_ARG(src1w);
- SLJIT_UNUSED_ARG(src2);
- SLJIT_UNUSED_ARG(src2w);
-
- SLJIT_ASSERT(!(type & ~(0xff | SLJIT_REWRITABLE_JUMP | SLJIT_INT_OP)));
- SLJIT_ASSERT((type & 0xff) >= SLJIT_C_EQUAL && (type & 0xff) <= SLJIT_C_SIG_LESS_EQUAL);
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
+ CHECK_ARGUMENT(!(type & ~(0xff | SLJIT_REWRITABLE_JUMP | SLJIT_INT_OP)));
+ CHECK_ARGUMENT((type & 0xff) >= SLJIT_EQUAL && (type & 0xff) <= SLJIT_SIG_LESS_EQUAL);
FUNCTION_CHECK_SRC(src1, src1w);
FUNCTION_CHECK_SRC(src2, src2w);
#endif
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- fprintf(compiler->verbose, " %scmp%s.%s ", !(type & SLJIT_INT_OP) ? "" : "i", !(type & SLJIT_REWRITABLE_JUMP) ? "" : ".r", jump_names[type & 0xff]);
+ fprintf(compiler->verbose, " cmp%s.%s%s ", !(type & SLJIT_REWRITABLE_JUMP) ? "" : ".r",
+ (type & SLJIT_INT_OP) ? "i_" : "", jump_names[type & 0xff]);
sljit_verbose_param(compiler, src1, src1w);
fprintf(compiler->verbose, ", ");
sljit_verbose_param(compiler, src2, src2w);
fprintf(compiler->verbose, "\n");
}
#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_emit_fcmp(struct sljit_compiler *compiler, sljit_si type,
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fcmp(struct sljit_compiler *compiler, sljit_si type,
sljit_si src1, sljit_sw src1w,
sljit_si src2, sljit_sw src2w)
{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(type);
- SLJIT_UNUSED_ARG(src1);
- SLJIT_UNUSED_ARG(src1w);
- SLJIT_UNUSED_ARG(src2);
- SLJIT_UNUSED_ARG(src2w);
-
- SLJIT_ASSERT(sljit_is_fpu_available());
- SLJIT_ASSERT(!(type & ~(0xff | SLJIT_REWRITABLE_JUMP | SLJIT_SINGLE_OP)));
- SLJIT_ASSERT((type & 0xff) >= SLJIT_C_FLOAT_EQUAL && (type & 0xff) <= SLJIT_C_FLOAT_ORDERED);
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
+ CHECK_ARGUMENT(sljit_is_fpu_available());
+ CHECK_ARGUMENT(!(type & ~(0xff | SLJIT_REWRITABLE_JUMP | SLJIT_SINGLE_OP)));
+ CHECK_ARGUMENT((type & 0xff) >= SLJIT_D_EQUAL && (type & 0xff) <= SLJIT_D_ORDERED);
FUNCTION_FCHECK(src1, src1w);
FUNCTION_FCHECK(src2, src2w);
#endif
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- fprintf(compiler->verbose, " %scmp%s.%s ", (type & SLJIT_SINGLE_OP) ? "s" : "d",
- !(type & SLJIT_REWRITABLE_JUMP) ? "" : ".r", jump_names[type & 0xff]);
+ fprintf(compiler->verbose, " fcmp%s.%s%s ", !(type & SLJIT_REWRITABLE_JUMP) ? "" : ".r",
+ (type & SLJIT_SINGLE_OP) ? "s_" : "d_", jump_names[type & 0xff]);
sljit_verbose_fparam(compiler, src1, src1w);
fprintf(compiler->verbose, ", ");
sljit_verbose_fparam(compiler, src2, src2w);
fprintf(compiler->verbose, "\n");
}
#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_emit_ijump(struct sljit_compiler *compiler, sljit_si type, sljit_si src, sljit_sw srcw)
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_ijump(struct sljit_compiler *compiler, sljit_si type, sljit_si src, sljit_sw srcw)
{
- /* If debug and verbose are disabled, all arguments are unused. */
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(type);
- SLJIT_UNUSED_ARG(src);
- SLJIT_UNUSED_ARG(srcw);
-
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
if (SLJIT_UNLIKELY(compiler->skip_checks)) {
compiler->skip_checks = 0;
- return;
+ CHECK_RETURN_OK;
}
-#endif
- SLJIT_ASSERT(type >= SLJIT_JUMP && type <= SLJIT_CALL3);
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
+ CHECK_ARGUMENT(type >= SLJIT_JUMP && type <= SLJIT_CALL3);
+ CHECK_ARGUMENT(type <= SLJIT_CALL0 || (type - SLJIT_CALL0) <= compiler->scratches);
FUNCTION_CHECK_SRC(src, srcw);
#endif
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
@@ -1456,38 +1407,31 @@ static SLJIT_INLINE void check_sljit_emit_ijump(struct sljit_compiler *compiler,
fprintf(compiler->verbose, "\n");
}
#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_emit_op_flags(struct sljit_compiler *compiler, sljit_si op,
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_op_flags(struct sljit_compiler *compiler, sljit_si op,
sljit_si dst, sljit_sw dstw,
sljit_si src, sljit_sw srcw,
sljit_si type)
{
- /* If debug and verbose are disabled, all arguments are unused. */
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(op);
- SLJIT_UNUSED_ARG(dst);
- SLJIT_UNUSED_ARG(dstw);
- SLJIT_UNUSED_ARG(src);
- SLJIT_UNUSED_ARG(srcw);
- SLJIT_UNUSED_ARG(type);
-
- SLJIT_ASSERT(type >= SLJIT_C_EQUAL && type < SLJIT_JUMP);
- SLJIT_ASSERT(op == SLJIT_MOV || GET_OPCODE(op) == SLJIT_MOV_UI || GET_OPCODE(op) == SLJIT_MOV_SI
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
+ CHECK_ARGUMENT(!(type & ~(0xff | SLJIT_INT_OP)));
+ CHECK_ARGUMENT((type & 0xff) >= SLJIT_EQUAL && (type & 0xff) <= SLJIT_D_ORDERED);
+ CHECK_ARGUMENT(op == SLJIT_MOV || GET_OPCODE(op) == SLJIT_MOV_UI || GET_OPCODE(op) == SLJIT_MOV_SI
|| (GET_OPCODE(op) >= SLJIT_AND && GET_OPCODE(op) <= SLJIT_XOR));
- SLJIT_ASSERT((op & (SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C)) == 0);
- SLJIT_ASSERT((op & (SLJIT_SET_E | SLJIT_KEEP_FLAGS)) != (SLJIT_SET_E | SLJIT_KEEP_FLAGS));
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
+ CHECK_ARGUMENT((op & (SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C)) == 0);
+ CHECK_ARGUMENT((op & (SLJIT_SET_E | SLJIT_KEEP_FLAGS)) != (SLJIT_SET_E | SLJIT_KEEP_FLAGS));
if (GET_OPCODE(op) < SLJIT_ADD) {
- SLJIT_ASSERT(src == SLJIT_UNUSED && srcw == 0);
+ CHECK_ARGUMENT(src == SLJIT_UNUSED && srcw == 0);
} else {
- SLJIT_ASSERT(src == dst && srcw == dstw);
+ CHECK_ARGUMENT(src == dst && srcw == dstw);
}
FUNCTION_CHECK_DST(dst, dstw);
#endif
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- fprintf(compiler->verbose, " %sflags.%s%s%s ", !(op & SLJIT_INT_OP) ? "" : "i",
+ fprintf(compiler->verbose, " flags.%s%s%s%s ", !(op & SLJIT_INT_OP) ? "" : "i",
GET_OPCODE(op) >= SLJIT_OP2_BASE ? op2_names[GET_OPCODE(op) - SLJIT_OP2_BASE] : op1_names[GET_OPCODE(op) - SLJIT_OP1_BASE],
!(op & SLJIT_SET_E) ? "" : ".e", !(op & SLJIT_KEEP_FLAGS) ? "" : ".k");
sljit_verbose_param(compiler, dst, dstw);
@@ -1495,19 +1439,15 @@ static SLJIT_INLINE void check_sljit_emit_op_flags(struct sljit_compiler *compil
fprintf(compiler->verbose, ", ");
sljit_verbose_param(compiler, src, srcw);
}
- fprintf(compiler->verbose, ", %s\n", jump_names[type]);
+ fprintf(compiler->verbose, ", %s%s\n", JUMP_PREFIX(type), jump_names[type & 0xff]);
}
#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_get_local_base(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw, sljit_sw offset)
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_get_local_base(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw, sljit_sw offset)
{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(dst);
- SLJIT_UNUSED_ARG(dstw);
- SLJIT_UNUSED_ARG(offset);
-
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
FUNCTION_CHECK_DST(dst, dstw);
#endif
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
@@ -1517,17 +1457,12 @@ static SLJIT_INLINE void check_sljit_get_local_base(struct sljit_compiler *compi
fprintf(compiler->verbose, ", #%" SLJIT_PRINT_D "d\n", offset);
}
#endif
+ CHECK_RETURN_OK;
}
-static SLJIT_INLINE void check_sljit_emit_const(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw, sljit_sw init_value)
+static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_const(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw, sljit_sw init_value)
{
- /* If debug and verbose are disabled, all arguments are unused. */
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(dst);
- SLJIT_UNUSED_ARG(dstw);
- SLJIT_UNUSED_ARG(init_value);
-
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
FUNCTION_CHECK_DST(dst, dstw);
#endif
#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
@@ -1537,8 +1472,36 @@ static SLJIT_INLINE void check_sljit_emit_const(struct sljit_compiler *compiler,
fprintf(compiler->verbose, ", #%" SLJIT_PRINT_D "d\n", init_value);
}
#endif
+ CHECK_RETURN_OK;
}
+#endif /* SLJIT_ARGUMENT_CHECKS || SLJIT_VERBOSE */
+
+#define SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw) \
+ SLJIT_COMPILE_ASSERT(!(SLJIT_CONVW_FROMD & 0x1) && !(SLJIT_CONVD_FROMW & 0x1), \
+ invalid_float_opcodes); \
+ if (GET_OPCODE(op) >= SLJIT_CONVW_FROMD && GET_OPCODE(op) <= SLJIT_DCMP) { \
+ if (GET_OPCODE(op) == SLJIT_DCMP) { \
+ CHECK(check_sljit_emit_fop1_cmp(compiler, op, dst, dstw, src, srcw)); \
+ ADJUST_LOCAL_OFFSET(dst, dstw); \
+ ADJUST_LOCAL_OFFSET(src, srcw); \
+ return sljit_emit_fop1_cmp(compiler, op, dst, dstw, src, srcw); \
+ } \
+ if ((GET_OPCODE(op) | 0x1) == SLJIT_CONVI_FROMD) { \
+ CHECK(check_sljit_emit_fop1_convw_fromd(compiler, op, dst, dstw, src, srcw)); \
+ ADJUST_LOCAL_OFFSET(dst, dstw); \
+ ADJUST_LOCAL_OFFSET(src, srcw); \
+ return sljit_emit_fop1_convw_fromd(compiler, op, dst, dstw, src, srcw); \
+ } \
+ CHECK(check_sljit_emit_fop1_convd_fromw(compiler, op, dst, dstw, src, srcw)); \
+ ADJUST_LOCAL_OFFSET(dst, dstw); \
+ ADJUST_LOCAL_OFFSET(src, srcw); \
+ return sljit_emit_fop1_convd_fromw(compiler, op, dst, dstw, src, srcw); \
+ } \
+ CHECK(check_sljit_emit_fop1(compiler, op, dst, dstw, src, srcw)); \
+ ADJUST_LOCAL_OFFSET(dst, dstw); \
+ ADJUST_LOCAL_OFFSET(src, srcw);
+
static SLJIT_INLINE sljit_si emit_mov_before_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
{
/* Return if don't need to do anything. */
@@ -1554,7 +1517,8 @@ static SLJIT_INLINE sljit_si emit_mov_before_return(struct sljit_compiler *compi
return SLJIT_SUCCESS;
#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS) \
+ || (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
compiler->skip_checks = 1;
#endif
return sljit_emit_op1(compiler, op, SLJIT_RETURN_REG, 0, src, srcw);
@@ -1617,11 +1581,11 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler
sljit_sw tmp_srcw;
CHECK_ERROR_PTR();
- check_sljit_emit_cmp(compiler, type, src1, src1w, src2, src2w);
+ CHECK_PTR(check_sljit_emit_cmp(compiler, type, src1, src1w, src2, src2w));
condition = type & 0xff;
#if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
- if ((condition == SLJIT_C_EQUAL || condition == SLJIT_C_NOT_EQUAL)) {
+ if ((condition == SLJIT_EQUAL || condition == SLJIT_NOT_EQUAL)) {
if ((src1 & SLJIT_IMM) && !src1w) {
src1 = src2;
src1w = src2w;
@@ -1636,29 +1600,29 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler
if (SLJIT_UNLIKELY((src1 & SLJIT_IMM) && !(src2 & SLJIT_IMM))) {
/* Immediate is prefered as second argument by most architectures. */
switch (condition) {
- case SLJIT_C_LESS:
- condition = SLJIT_C_GREATER;
+ case SLJIT_LESS:
+ condition = SLJIT_GREATER;
break;
- case SLJIT_C_GREATER_EQUAL:
- condition = SLJIT_C_LESS_EQUAL;
+ case SLJIT_GREATER_EQUAL:
+ condition = SLJIT_LESS_EQUAL;
break;
- case SLJIT_C_GREATER:
- condition = SLJIT_C_LESS;
+ case SLJIT_GREATER:
+ condition = SLJIT_LESS;
break;
- case SLJIT_C_LESS_EQUAL:
- condition = SLJIT_C_GREATER_EQUAL;
+ case SLJIT_LESS_EQUAL:
+ condition = SLJIT_GREATER_EQUAL;
break;
- case SLJIT_C_SIG_LESS:
- condition = SLJIT_C_SIG_GREATER;
+ case SLJIT_SIG_LESS:
+ condition = SLJIT_SIG_GREATER;
break;
- case SLJIT_C_SIG_GREATER_EQUAL:
- condition = SLJIT_C_SIG_LESS_EQUAL;
+ case SLJIT_SIG_GREATER_EQUAL:
+ condition = SLJIT_SIG_LESS_EQUAL;
break;
- case SLJIT_C_SIG_GREATER:
- condition = SLJIT_C_SIG_LESS;
+ case SLJIT_SIG_GREATER:
+ condition = SLJIT_SIG_LESS;
break;
- case SLJIT_C_SIG_LESS_EQUAL:
- condition = SLJIT_C_SIG_GREATER_EQUAL;
+ case SLJIT_SIG_LESS_EQUAL:
+ condition = SLJIT_SIG_GREATER_EQUAL;
break;
}
type = condition | (type & (SLJIT_INT_OP | SLJIT_REWRITABLE_JUMP));
@@ -1670,19 +1634,21 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler
src2w = tmp_srcw;
}
- if (condition <= SLJIT_C_NOT_ZERO)
+ if (condition <= SLJIT_NOT_ZERO)
flags = SLJIT_SET_E;
- else if (condition <= SLJIT_C_LESS_EQUAL)
+ else if (condition <= SLJIT_LESS_EQUAL)
flags = SLJIT_SET_U;
else
flags = SLJIT_SET_S;
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
+ || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
compiler->skip_checks = 1;
#endif
PTR_FAIL_IF(sljit_emit_op2(compiler, SLJIT_SUB | flags | (type & SLJIT_INT_OP),
SLJIT_UNUSED, 0, src1, src1w, src2, src2w));
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
+ || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
compiler->skip_checks = 1;
#endif
return sljit_emit_jump(compiler, condition | (type & SLJIT_REWRITABLE_JUMP));
@@ -1694,19 +1660,22 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_fcmp(struct sljit_compile
{
sljit_si flags, condition;
- check_sljit_emit_fcmp(compiler, type, src1, src1w, src2, src2w);
+ CHECK_ERROR_PTR();
+ CHECK_PTR(check_sljit_emit_fcmp(compiler, type, src1, src1w, src2, src2w));
condition = type & 0xff;
- flags = (condition <= SLJIT_C_FLOAT_NOT_EQUAL) ? SLJIT_SET_E : SLJIT_SET_S;
+ flags = (condition <= SLJIT_D_NOT_EQUAL) ? SLJIT_SET_E : SLJIT_SET_S;
if (type & SLJIT_SINGLE_OP)
flags |= SLJIT_SINGLE_OP;
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
+ || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
compiler->skip_checks = 1;
#endif
- sljit_emit_fop1(compiler, SLJIT_CMPD | flags, src1, src1w, src2, src2w);
+ sljit_emit_fop1(compiler, SLJIT_DCMP | flags, src1, src1w, src2, src2w);
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
+ || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
compiler->skip_checks = 1;
#endif
return sljit_emit_jump(compiler, condition | (type & SLJIT_REWRITABLE_JUMP));
@@ -1719,10 +1688,11 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_fcmp(struct sljit_compile
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_local_base(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw, sljit_sw offset)
{
CHECK_ERROR();
- check_sljit_get_local_base(compiler, dst, dstw, offset);
+ CHECK(check_sljit_get_local_base(compiler, dst, dstw, offset));
ADJUST_LOCAL_OFFSET(SLJIT_MEM1(SLJIT_SP), offset);
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
+ || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
compiler->skip_checks = 1;
#endif
if (offset != 0)
@@ -1799,7 +1769,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
return SLJIT_ERR_UNSUPPORTED;
}
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler,
+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler,
sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
{
@@ -1812,6 +1782,7 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler,
SLJIT_UNUSED_ARG(fsaveds);
SLJIT_UNUSED_ARG(local_size);
SLJIT_ASSERT_STOP();
+ return SLJIT_ERR_UNSUPPORTED;
}
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
diff --git a/pcre/sljit/sljitLir.h b/pcre/sljit/sljitLir.h
index 97188719390..24c0f603992 100644
--- a/pcre/sljit/sljitLir.h
+++ b/pcre/sljit/sljitLir.h
@@ -95,8 +95,10 @@ of sljitConfigInternal.h */
/* Cannot allocate executable memory.
Only for sljit_generate_code() */
#define SLJIT_ERR_EX_ALLOC_FAILED 3
-/* return value for SLJIT_CONFIG_UNSUPPORTED empty architecture. */
+/* Return value for SLJIT_CONFIG_UNSUPPORTED placeholder architecture. */
#define SLJIT_ERR_UNSUPPORTED 4
+/* An ivalid argument is passed to any SLJIT function. */
+#define SLJIT_ERR_BAD_ARGUMENT 5
/* --------------------------------------------------------------------- */
/* Registers */
@@ -305,6 +307,7 @@ struct sljit_compiler {
struct sljit_jump *last_jump;
struct sljit_const *last_const;
+ void *allocator_data;
struct sljit_memory_fragment *buf;
struct sljit_memory_fragment *abuf;
@@ -359,7 +362,6 @@ struct sljit_compiler {
#endif
#if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
- sljit_si locals_offset;
sljit_si cache_arg;
sljit_sw cache_argw;
#endif
@@ -391,12 +393,15 @@ struct sljit_compiler {
FILE* verbose;
#endif
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS) \
+ || (defined SLJIT_DEBUG && SLJIT_DEBUG)
/* Local size passed to the functions. */
sljit_si logical_local_size;
#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS) \
+ || (defined SLJIT_DEBUG && SLJIT_DEBUG) \
+ || (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
sljit_si skip_checks;
#endif
};
@@ -405,11 +410,16 @@ struct sljit_compiler {
/* Main functions */
/* --------------------------------------------------------------------- */
-/* Creates an sljit compiler.
+/* Creates an sljit compiler. The allocator_data is required by some
+ custom memory managers. This pointer is passed to SLJIT_MALLOC
+ and SLJIT_FREE macros. Most allocators (including the default
+ one) ignores this value, and it is recommended to pass NULL
+ as a dummy value for allocator_data.
+
Returns NULL if failed. */
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void);
+SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void *allocator_data);
-/* Free everything except the compiled machine code. */
+/* Frees everything except the compiled machine code. */
SLJIT_API_FUNC_ATTRIBUTE void sljit_free_compiler(struct sljit_compiler *compiler);
/* Returns the current error code. If an error is occurred, future sljit
@@ -419,6 +429,14 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_compiler(struct sljit_compiler *compile
these checks increases the performance of the compiling process. */
static SLJIT_INLINE sljit_si sljit_get_compiler_error(struct sljit_compiler *compiler) { return compiler->error; }
+/* Sets the compiler error code to SLJIT_ERR_ALLOC_FAILED except
+ if an error was detected before. After the error code is set
+ the compiler behaves as if the allocation failure happened
+ during an sljit function call. This can greatly simplify error
+ checking, since only the compiler status needs to be checked
+ after the compilation. */
+SLJIT_API_FUNC_ATTRIBUTE void sljit_set_compiler_memory_error(struct sljit_compiler *compiler);
+
/*
Allocate a small amount of memory. The size must be <= 64 bytes on 32 bit,
and <= 128 bytes on 64 bit architectures. The memory area is owned by the
@@ -461,8 +479,8 @@ static SLJIT_INLINE sljit_uw sljit_get_generated_code_size(struct sljit_compiler
sljit_emit_enter function emits the necessary instructions for
setting up a new context for the executable code and moves function
arguments to the saved registers. Furthermore the options argument
- can be used to pass configuration options to the compiler. Currently
- there are no options, so it must be set to 0.
+ can be used to pass configuration options to the compiler. The
+ available options are listed before sljit_emit_enter.
The number of sljit_sw arguments passed to the generated function
are specified in the "args" parameter. The number of arguments must
@@ -493,6 +511,11 @@ static SLJIT_INLINE sljit_uw sljit_get_generated_code_size(struct sljit_compiler
overwrites the previous context.
*/
+/* The absolute address returned by sljit_get_local_base with
+offset 0 is aligned to sljit_d. Otherwise it is aligned to sljit_uw. */
+#define SLJIT_DOUBLE_ALIGNMENT 0x00000001
+
+/* The local_size must be >= 0 and <= SLJIT_MAX_LOCAL_SIZE. */
#define SLJIT_MAX_LOCAL_SIZE 65536
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compiler,
@@ -509,7 +532,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
Note: every call of sljit_emit_enter and sljit_set_context overwrites
the previous context. */
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler,
+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler,
sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
sljit_si fscratches, sljit_si fsaveds, sljit_si local_size);
@@ -674,23 +697,23 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *
/* Flags: - (may destroy flags)
Unsigned multiplication of SLJIT_R0 and SLJIT_R1.
Result goes to SLJIT_R1:SLJIT_R0 (high:low) word */
-#define SLJIT_UMUL (SLJIT_OP0_BASE + 2)
+#define SLJIT_LUMUL (SLJIT_OP0_BASE + 2)
/* Flags: - (may destroy flags)
Signed multiplication of SLJIT_R0 and SLJIT_R1.
Result goes to SLJIT_R1:SLJIT_R0 (high:low) word */
-#define SLJIT_SMUL (SLJIT_OP0_BASE + 3)
+#define SLJIT_LSMUL (SLJIT_OP0_BASE + 3)
/* Flags: I - (may destroy flags)
Unsigned divide of the value in SLJIT_R0 by the value in SLJIT_R1.
The result is placed in SLJIT_R0 and the remainder goes to SLJIT_R1.
Note: if SLJIT_R1 contains 0, the behaviour is undefined. */
-#define SLJIT_UDIV (SLJIT_OP0_BASE + 4)
-#define SLJIT_IUDIV (SLJIT_UDIV | SLJIT_INT_OP)
+#define SLJIT_LUDIV (SLJIT_OP0_BASE + 4)
+#define SLJIT_ILUDIV (SLJIT_LUDIV | SLJIT_INT_OP)
/* Flags: I - (may destroy flags)
Signed divide of the value in SLJIT_R0 by the value in SLJIT_R1.
The result is placed in SLJIT_R0 and the remainder goes to SLJIT_R1.
Note: if SLJIT_R1 contains 0, the behaviour is undefined. */
-#define SLJIT_SDIV (SLJIT_OP0_BASE + 5)
-#define SLJIT_ISDIV (SLJIT_SDIV | SLJIT_INT_OP)
+#define SLJIT_LSDIV (SLJIT_OP0_BASE + 5)
+#define SLJIT_ILSDIV (SLJIT_LSDIV | SLJIT_INT_OP)
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op);
@@ -838,7 +861,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_register_index(sljit_si reg);
/* The following function is a helper function for sljit_emit_op_custom.
It returns with the real machine register index of any SLJIT_FLOAT register.
-
+
Note: the index is always an even number on ARM (except ARM-64), MIPS, and SPARC. */
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_float_register_index(sljit_si reg);
@@ -864,8 +887,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_is_fpu_available(void);
#define SLJIT_FOP1_BASE 128
/* Flags: SP - (never set any flags) */
-#define SLJIT_MOVD (SLJIT_FOP1_BASE + 0)
-#define SLJIT_MOVS (SLJIT_MOVD | SLJIT_SINGLE_OP)
+#define SLJIT_DMOV (SLJIT_FOP1_BASE + 0)
+#define SLJIT_SMOV (SLJIT_DMOV | SLJIT_SINGLE_OP)
/* Convert opcodes: CONV[DST_TYPE].FROM[SRC_TYPE]
SRC/DST TYPE can be: D - double, S - single, W - signed word, I - signed int
Rounding mode when the destination is W or I: round towards zero. */
@@ -888,14 +911,14 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_is_fpu_available(void);
Note: NaN check is always performed. If SLJIT_C_FLOAT_UNORDERED flag
is set, the comparison result is unpredictable.
Flags: SP | E | S (see SLJIT_C_FLOAT_*) */
-#define SLJIT_CMPD (SLJIT_FOP1_BASE + 6)
-#define SLJIT_CMPS (SLJIT_CMPD | SLJIT_SINGLE_OP)
+#define SLJIT_DCMP (SLJIT_FOP1_BASE + 6)
+#define SLJIT_SCMP (SLJIT_DCMP | SLJIT_SINGLE_OP)
/* Flags: SP - (never set any flags) */
-#define SLJIT_NEGD (SLJIT_FOP1_BASE + 7)
-#define SLJIT_NEGS (SLJIT_NEGD | SLJIT_SINGLE_OP)
+#define SLJIT_DNEG (SLJIT_FOP1_BASE + 7)
+#define SLJIT_SNEG (SLJIT_DNEG | SLJIT_SINGLE_OP)
/* Flags: SP - (never set any flags) */
-#define SLJIT_ABSD (SLJIT_FOP1_BASE + 8)
-#define SLJIT_ABSS (SLJIT_ABSD | SLJIT_SINGLE_OP)
+#define SLJIT_DABS (SLJIT_FOP1_BASE + 8)
+#define SLJIT_SABS (SLJIT_DABS | SLJIT_SINGLE_OP)
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compiler, sljit_si op,
sljit_si dst, sljit_sw dstw,
@@ -905,17 +928,17 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compile
#define SLJIT_FOP2_BASE 160
/* Flags: SP - (never set any flags) */
-#define SLJIT_ADDD (SLJIT_FOP2_BASE + 0)
-#define SLJIT_ADDS (SLJIT_ADDD | SLJIT_SINGLE_OP)
+#define SLJIT_DADD (SLJIT_FOP2_BASE + 0)
+#define SLJIT_SADD (SLJIT_DADD | SLJIT_SINGLE_OP)
/* Flags: SP - (never set any flags) */
-#define SLJIT_SUBD (SLJIT_FOP2_BASE + 1)
-#define SLJIT_SUBS (SLJIT_SUBD | SLJIT_SINGLE_OP)
+#define SLJIT_DSUB (SLJIT_FOP2_BASE + 1)
+#define SLJIT_SSUB (SLJIT_DSUB | SLJIT_SINGLE_OP)
/* Flags: SP - (never set any flags) */
-#define SLJIT_MULD (SLJIT_FOP2_BASE + 2)
-#define SLJIT_MULS (SLJIT_MULD | SLJIT_SINGLE_OP)
+#define SLJIT_DMUL (SLJIT_FOP2_BASE + 2)
+#define SLJIT_SMUL (SLJIT_DMUL | SLJIT_SINGLE_OP)
/* Flags: SP - (never set any flags) */
-#define SLJIT_DIVD (SLJIT_FOP2_BASE + 3)
-#define SLJIT_DIVS (SLJIT_DIVD | SLJIT_SINGLE_OP)
+#define SLJIT_DDIV (SLJIT_FOP2_BASE + 3)
+#define SLJIT_SDIV (SLJIT_DDIV | SLJIT_SINGLE_OP)
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compiler, sljit_si op,
sljit_si dst, sljit_sw dstw,
@@ -926,36 +949,64 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler);
-/* Invert conditional instruction: xor (^) with 0x1 */
-#define SLJIT_C_EQUAL 0
-#define SLJIT_C_ZERO 0
-#define SLJIT_C_NOT_EQUAL 1
-#define SLJIT_C_NOT_ZERO 1
-
-#define SLJIT_C_LESS 2
-#define SLJIT_C_GREATER_EQUAL 3
-#define SLJIT_C_GREATER 4
-#define SLJIT_C_LESS_EQUAL 5
-#define SLJIT_C_SIG_LESS 6
-#define SLJIT_C_SIG_GREATER_EQUAL 7
-#define SLJIT_C_SIG_GREATER 8
-#define SLJIT_C_SIG_LESS_EQUAL 9
-
-#define SLJIT_C_OVERFLOW 10
-#define SLJIT_C_NOT_OVERFLOW 11
-
-#define SLJIT_C_MUL_OVERFLOW 12
-#define SLJIT_C_MUL_NOT_OVERFLOW 13
-
-#define SLJIT_C_FLOAT_EQUAL 14
-#define SLJIT_C_FLOAT_NOT_EQUAL 15
-#define SLJIT_C_FLOAT_LESS 16
-#define SLJIT_C_FLOAT_GREATER_EQUAL 17
-#define SLJIT_C_FLOAT_GREATER 18
-#define SLJIT_C_FLOAT_LESS_EQUAL 19
-#define SLJIT_C_FLOAT_UNORDERED 20
-#define SLJIT_C_FLOAT_ORDERED 21
-
+/* Invert (negate) conditional type: xor (^) with 0x1 */
+
+/* Integer comparison types. */
+#define SLJIT_EQUAL 0
+#define SLJIT_I_EQUAL (SLJIT_EQUAL | SLJIT_INT_OP)
+#define SLJIT_ZERO 0
+#define SLJIT_I_ZERO (SLJIT_ZERO | SLJIT_INT_OP)
+#define SLJIT_NOT_EQUAL 1
+#define SLJIT_I_NOT_EQUAL (SLJIT_NOT_EQUAL | SLJIT_INT_OP)
+#define SLJIT_NOT_ZERO 1
+#define SLJIT_I_NOT_ZERO (SLJIT_NOT_ZERO | SLJIT_INT_OP)
+
+#define SLJIT_LESS 2
+#define SLJIT_I_LESS (SLJIT_LESS | SLJIT_INT_OP)
+#define SLJIT_GREATER_EQUAL 3
+#define SLJIT_I_GREATER_EQUAL (SLJIT_GREATER_EQUAL | SLJIT_INT_OP)
+#define SLJIT_GREATER 4
+#define SLJIT_I_GREATER (SLJIT_GREATER | SLJIT_INT_OP)
+#define SLJIT_LESS_EQUAL 5
+#define SLJIT_I_LESS_EQUAL (SLJIT_LESS_EQUAL | SLJIT_INT_OP)
+#define SLJIT_SIG_LESS 6
+#define SLJIT_I_SIG_LESS (SLJIT_SIG_LESS | SLJIT_INT_OP)
+#define SLJIT_SIG_GREATER_EQUAL 7
+#define SLJIT_I_SIG_GREATER_EQUAL (SLJIT_SIG_GREATER_EQUAL | SLJIT_INT_OP)
+#define SLJIT_SIG_GREATER 8
+#define SLJIT_I_SIG_GREATER (SLJIT_SIG_GREATER | SLJIT_INT_OP)
+#define SLJIT_SIG_LESS_EQUAL 9
+#define SLJIT_I_SIG_LESS_EQUAL (SLJIT_SIG_LESS_EQUAL | SLJIT_INT_OP)
+
+#define SLJIT_OVERFLOW 10
+#define SLJIT_I_OVERFLOW (SLJIT_OVERFLOW | SLJIT_INT_OP)
+#define SLJIT_NOT_OVERFLOW 11
+#define SLJIT_I_NOT_OVERFLOW (SLJIT_NOT_OVERFLOW | SLJIT_INT_OP)
+
+#define SLJIT_MUL_OVERFLOW 12
+#define SLJIT_I_MUL_OVERFLOW (SLJIT_MUL_OVERFLOW | SLJIT_INT_OP)
+#define SLJIT_MUL_NOT_OVERFLOW 13
+#define SLJIT_I_MUL_NOT_OVERFLOW (SLJIT_MUL_NOT_OVERFLOW | SLJIT_INT_OP)
+
+/* Floating point comparison types. */
+#define SLJIT_D_EQUAL 14
+#define SLJIT_S_EQUAL (SLJIT_D_EQUAL | SLJIT_SINGLE_OP)
+#define SLJIT_D_NOT_EQUAL 15
+#define SLJIT_S_NOT_EQUAL (SLJIT_D_NOT_EQUAL | SLJIT_SINGLE_OP)
+#define SLJIT_D_LESS 16
+#define SLJIT_S_LESS (SLJIT_D_LESS | SLJIT_SINGLE_OP)
+#define SLJIT_D_GREATER_EQUAL 17
+#define SLJIT_S_GREATER_EQUAL (SLJIT_D_GREATER_EQUAL | SLJIT_SINGLE_OP)
+#define SLJIT_D_GREATER 18
+#define SLJIT_S_GREATER (SLJIT_D_GREATER | SLJIT_SINGLE_OP)
+#define SLJIT_D_LESS_EQUAL 19
+#define SLJIT_S_LESS_EQUAL (SLJIT_D_LESS_EQUAL | SLJIT_SINGLE_OP)
+#define SLJIT_D_UNORDERED 20
+#define SLJIT_S_UNORDERED (SLJIT_D_UNORDERED | SLJIT_SINGLE_OP)
+#define SLJIT_D_ORDERED 21
+#define SLJIT_S_ORDERED (SLJIT_D_ORDERED | SLJIT_SINGLE_OP)
+
+/* Unconditional jump types. */
#define SLJIT_JUMP 22
#define SLJIT_FAST_CALL 23
#define SLJIT_CALL0 24
@@ -969,7 +1020,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compi
#define SLJIT_REWRITABLE_JUMP 0x1000
/* Emit a jump instruction. The destination is not set, only the type of the jump.
- type must be between SLJIT_C_EQUAL and SLJIT_CALL3
+ type must be between SLJIT_EQUAL and SLJIT_CALL3
type can be combined (or'ed) with SLJIT_REWRITABLE_JUMP
Flags: - (never set any flags) for both conditional and unconditional jumps.
Flags: destroy all flags for calls. */
@@ -978,10 +1029,10 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile
/* Basic arithmetic comparison. In most architectures it is implemented as
an SLJIT_SUB operation (with SLJIT_UNUSED destination and setting
appropriate flags) followed by a sljit_emit_jump. However some
- architectures (i.e: MIPS) may employ special optimizations here. It is
- suggested to use this comparison form when appropriate.
- type must be between SLJIT_C_EQUAL and SLJIT_C_SIG_LESS_EQUAL
- type can be combined (or'ed) with SLJIT_REWRITABLE_JUMP or SLJIT_INT_OP
+ architectures (i.e: ARM64 or MIPS) may employ special optimizations here.
+ It is suggested to use this comparison form when appropriate.
+ type must be between SLJIT_EQUAL and SLJIT_I_SIG_LESS_EQUAL
+ type can be combined (or'ed) with SLJIT_REWRITABLE_JUMP
Flags: destroy flags. */
SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler *compiler, sljit_si type,
sljit_si src1, sljit_sw src1w,
@@ -992,11 +1043,11 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler
sljit_emit_jump. However some architectures (i.e: MIPS) may employ
special optimizations here. It is suggested to use this comparison form
when appropriate.
- type must be between SLJIT_C_FLOAT_EQUAL and SLJIT_C_FLOAT_ORDERED
- type can be combined (or'ed) with SLJIT_REWRITABLE_JUMP and SLJIT_SINGLE_OP
+ type must be between SLJIT_D_EQUAL and SLJIT_S_ORDERED
+ type can be combined (or'ed) with SLJIT_REWRITABLE_JUMP
Flags: destroy flags.
Note: if either operand is NaN, the behaviour is undefined for
- type <= SLJIT_C_FLOAT_LESS_EQUAL. */
+ types up to SLJIT_S_LESS_EQUAL. */
SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_fcmp(struct sljit_compiler *compiler, sljit_si type,
sljit_si src1, sljit_sw src1w,
sljit_si src2, sljit_sw src2w);
@@ -1015,8 +1066,8 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_target(struct sljit_jump *jump, sljit_uw
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_ijump(struct sljit_compiler *compiler, sljit_si type, sljit_si src, sljit_sw srcw);
/* Perform the operation using the conditional flags as the second argument.
- Type must always be between SLJIT_C_EQUAL and SLJIT_C_FLOAT_ORDERED. The
- value represented by the type is 1, if the condition represented by the type
+ Type must always be between SLJIT_EQUAL and SLJIT_S_ORDERED. The value
+ represented by the type is 1, if the condition represented by the type
is fulfilled, and 0 otherwise.
If op == SLJIT_MOV, SLJIT_MOV_SI, SLJIT_MOV_UI:
@@ -1058,7 +1109,7 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_consta
/* --------------------------------------------------------------------- */
#define SLJIT_MAJOR_VERSION 0
-#define SLJIT_MINOR_VERSION 92
+#define SLJIT_MINOR_VERSION 93
/* Get the human readable name of the platform. Can be useful on platforms
like ARM, where ARM and Thumb2 functions can be mixed, and
@@ -1104,10 +1155,11 @@ struct sljit_stack {
};
/* Returns NULL if unsuccessful.
- Note: limit and max_limit contains the size for stack allocation
- Note: the top field is initialized to base. */
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CALL sljit_allocate_stack(sljit_uw limit, sljit_uw max_limit);
-SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_free_stack(struct sljit_stack* stack);
+ Note: limit and max_limit contains the size for stack allocation.
+ Note: the top field is initialized to base.
+ Note: see sljit_create_compiler for the explanation of allocator_data. */
+SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CALL sljit_allocate_stack(sljit_uw limit, sljit_uw max_limit, void *allocator_data);
+SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_free_stack(struct sljit_stack *stack, void *allocator_data);
/* Can be used to increase (allocate) or decrease (free) the memory area.
Returns with a non-zero value if unsuccessful. If new_limit is greater than
@@ -1115,7 +1167,7 @@ SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_free_stack(struct sljit_stack* st
since the growth ratio can be added to the current limit, and sljit_stack_resize
will do all the necessary checks. The fields of the stack are not changed if
sljit_stack_resize fails. */
-SLJIT_API_FUNC_ATTRIBUTE sljit_sw SLJIT_CALL sljit_stack_resize(struct sljit_stack* stack, sljit_uw new_limit);
+SLJIT_API_FUNC_ATTRIBUTE sljit_sw SLJIT_CALL sljit_stack_resize(struct sljit_stack *stack, sljit_uw new_limit);
#endif /* (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK) */
diff --git a/pcre/sljit/sljitNativeARM_32.c b/pcre/sljit/sljitNativeARM_32.c
index 0998423b86c..aca1d31fdf6 100644
--- a/pcre/sljit/sljitNativeARM_32.c
+++ b/pcre/sljit/sljitNativeARM_32.c
@@ -315,11 +315,13 @@ struct future_patch {
sljit_si value;
};
-static SLJIT_INLINE sljit_si resolve_const_pool_index(struct future_patch **first_patch, sljit_uw cpool_current_index, sljit_uw *cpool_start_address, sljit_uw *buf_ptr)
+static sljit_si resolve_const_pool_index(struct sljit_compiler *compiler, struct future_patch **first_patch, sljit_uw cpool_current_index, sljit_uw *cpool_start_address, sljit_uw *buf_ptr)
{
sljit_si value;
struct future_patch *curr_patch, *prev_patch;
+ SLJIT_UNUSED_ARG(compiler);
+
/* Using the values generated by patch_pc_relative_loads. */
if (!*first_patch)
value = (sljit_si)cpool_start_address[cpool_current_index];
@@ -337,7 +339,7 @@ static SLJIT_INLINE sljit_si resolve_const_pool_index(struct future_patch **firs
prev_patch->next = curr_patch->next;
else
*first_patch = curr_patch->next;
- SLJIT_FREE(curr_patch);
+ SLJIT_FREE(curr_patch, compiler->allocator_data);
break;
}
prev_patch = curr_patch;
@@ -347,12 +349,12 @@ static SLJIT_INLINE sljit_si resolve_const_pool_index(struct future_patch **firs
if (value >= 0) {
if ((sljit_uw)value > cpool_current_index) {
- curr_patch = (struct future_patch*)SLJIT_MALLOC(sizeof(struct future_patch));
+ curr_patch = (struct future_patch*)SLJIT_MALLOC(sizeof(struct future_patch), compiler->allocator_data);
if (!curr_patch) {
while (*first_patch) {
curr_patch = *first_patch;
*first_patch = (*first_patch)->next;
- SLJIT_FREE(curr_patch);
+ SLJIT_FREE(curr_patch, compiler->allocator_data);
}
return SLJIT_ERR_ALLOC_FAILED;
}
@@ -574,7 +576,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
struct sljit_const *const_;
CHECK_ERROR_PTR();
- check_sljit_generate_code(compiler);
+ CHECK_PTR(check_sljit_generate_code(compiler));
reverse_buf(compiler);
/* Second code generation pass. */
@@ -623,7 +625,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
cpool_skip_alignment--;
}
else {
- if (SLJIT_UNLIKELY(resolve_const_pool_index(&first_patch, cpool_current_index, cpool_start_address, buf_ptr))) {
+ if (SLJIT_UNLIKELY(resolve_const_pool_index(compiler, &first_patch, cpool_current_index, cpool_start_address, buf_ptr))) {
SLJIT_FREE_EXEC(code);
compiler->error = SLJIT_ERR_ALLOC_FAILED;
return NULL;
@@ -713,7 +715,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
buf_end = buf_ptr + compiler->cpool_fill;
cpool_current_index = 0;
while (buf_ptr < buf_end) {
- if (SLJIT_UNLIKELY(resolve_const_pool_index(&first_patch, cpool_current_index, cpool_start_address, buf_ptr))) {
+ if (SLJIT_UNLIKELY(resolve_const_pool_index(compiler, &first_patch, cpool_current_index, cpool_start_address, buf_ptr))) {
SLJIT_FREE_EXEC(code);
compiler->error = SLJIT_ERR_ALLOC_FAILED;
return NULL;
@@ -831,16 +833,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
sljit_uw push;
CHECK_ERROR();
- check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- compiler->options = options;
- compiler->scratches = scratches;
- compiler->saveds = saveds;
- compiler->fscratches = fscratches;
- compiler->fsaveds = fsaveds;
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
- compiler->logical_local_size = local_size;
-#endif
+ CHECK(check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
+ set_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
/* Push saved registers, temporary registers
stmdb sp!, {..., lr} */
@@ -872,26 +866,19 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
return SLJIT_SUCCESS;
}
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler,
+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler,
sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
{
sljit_si size;
- CHECK_ERROR_VOID();
- check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- compiler->options = options;
- compiler->scratches = scratches;
- compiler->saveds = saveds;
- compiler->fscratches = fscratches;
- compiler->fsaveds = fsaveds;
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
- compiler->logical_local_size = local_size;
-#endif
+ CHECK_ERROR();
+ CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
+ set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
size = GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1);
compiler->local_size = ((size + local_size + 7) & ~7) - size;
+ return SLJIT_SUCCESS;
}
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
@@ -900,7 +887,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compi
sljit_uw pop;
CHECK_ERROR();
- check_sljit_emit_return(compiler, op, src, srcw);
+ CHECK(check_sljit_emit_return(compiler, op, src, srcw));
FAIL_IF(emit_mov_before_return(compiler, op, src, srcw));
@@ -1820,7 +1807,7 @@ extern int __aeabi_idivmod(int numerator, int denominator);
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op)
{
CHECK_ERROR();
- check_sljit_emit_op0(compiler, op);
+ CHECK(check_sljit_emit_op0(compiler, op));
op = GET_OPCODE(op);
switch (op) {
@@ -1830,29 +1817,29 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
case SLJIT_NOP:
FAIL_IF(push_inst(compiler, NOP));
break;
- case SLJIT_UMUL:
- case SLJIT_SMUL:
+ case SLJIT_LUMUL:
+ case SLJIT_LSMUL:
#if (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
- return push_inst(compiler, (op == SLJIT_UMUL ? UMULL : SMULL)
+ return push_inst(compiler, (op == SLJIT_LUMUL ? UMULL : SMULL)
| (reg_map[SLJIT_R1] << 16)
| (reg_map[SLJIT_R0] << 12)
| (reg_map[SLJIT_R0] << 8)
| reg_map[SLJIT_R1]);
#else
FAIL_IF(push_inst(compiler, EMIT_DATA_PROCESS_INS(MOV_DP, 0, TMP_REG1, SLJIT_UNUSED, RM(SLJIT_R1))));
- return push_inst(compiler, (op == SLJIT_UMUL ? UMULL : SMULL)
+ return push_inst(compiler, (op == SLJIT_LUMUL ? UMULL : SMULL)
| (reg_map[SLJIT_R1] << 16)
| (reg_map[SLJIT_R0] << 12)
| (reg_map[SLJIT_R0] << 8)
| reg_map[TMP_REG1]);
#endif
- case SLJIT_UDIV:
- case SLJIT_SDIV:
+ case SLJIT_LUDIV:
+ case SLJIT_LSDIV:
if (compiler->scratches >= 3)
FAIL_IF(push_inst(compiler, 0xe52d2008 /* str r2, [sp, #-8]! */));
#if defined(__GNUC__)
FAIL_IF(sljit_emit_ijump(compiler, SLJIT_FAST_CALL, SLJIT_IMM,
- (op == SLJIT_UDIV ? SLJIT_FUNC_OFFSET(__aeabi_uidivmod) : SLJIT_FUNC_OFFSET(__aeabi_idivmod))));
+ (op == SLJIT_LUDIV ? SLJIT_FUNC_OFFSET(__aeabi_uidivmod) : SLJIT_FUNC_OFFSET(__aeabi_idivmod))));
#else
#error "Software divmod functions are needed"
#endif
@@ -1869,7 +1856,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler
sljit_si src, sljit_sw srcw)
{
CHECK_ERROR();
- check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw);
+ CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src, srcw);
@@ -1914,7 +1901,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler
return emit_op(compiler, op, ALLOW_ANY_IMM, dst, dstw, TMP_REG1, 0, src, srcw);
case SLJIT_NEG:
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
+ || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
compiler->skip_checks = 1;
#endif
return sljit_emit_op2(compiler, SLJIT_SUB | GET_ALL_FLAGS(op), dst, dstw, SLJIT_IMM, 0, src, srcw);
@@ -1932,7 +1920,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler
sljit_si src2, sljit_sw src2w)
{
CHECK_ERROR();
- check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
+ CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src1, src1w);
ADJUST_LOCAL_OFFSET(src2, src2w);
@@ -1970,13 +1958,13 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_register_index(sljit_si reg)
{
- check_sljit_get_register_index(reg);
+ CHECK_REG_INDEX(check_sljit_get_register_index(reg));
return reg_map[reg];
}
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_float_register_index(sljit_si reg)
{
- check_sljit_get_float_register_index(reg);
+ CHECK_REG_INDEX(check_sljit_get_float_register_index(reg));
return reg << 1;
}
@@ -1984,8 +1972,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *co
void *instruction, sljit_si size)
{
CHECK_ERROR();
- check_sljit_emit_op_custom(compiler, instruction, size);
- SLJIT_ASSERT(size == 4);
+ CHECK(check_sljit_emit_op_custom(compiler, instruction, size));
return push_inst(compiler, *(sljit_uw*)instruction);
}
@@ -2188,7 +2175,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compile
}
switch (GET_OPCODE(op)) {
- case SLJIT_MOVD:
+ case SLJIT_DMOV:
if (src != dst_r) {
if (dst_r != TMP_FREG1)
FAIL_IF(push_inst(compiler, EMIT_FPU_OPERATION(VMOV_F32, op & SLJIT_SINGLE_OP, dst_r, src, 0)));
@@ -2196,10 +2183,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compile
dst_r = src;
}
break;
- case SLJIT_NEGD:
+ case SLJIT_DNEG:
FAIL_IF(push_inst(compiler, EMIT_FPU_OPERATION(VNEG_F32, op & SLJIT_SINGLE_OP, dst_r, src, 0)));
break;
- case SLJIT_ABSD:
+ case SLJIT_DABS:
FAIL_IF(push_inst(compiler, EMIT_FPU_OPERATION(VABS_F32, op & SLJIT_SINGLE_OP, dst_r, src, 0)));
break;
case SLJIT_CONVD_FROMS:
@@ -2221,7 +2208,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
sljit_si dst_r;
CHECK_ERROR();
- check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
+ CHECK(check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src1, src1w);
ADJUST_LOCAL_OFFSET(src2, src2w);
@@ -2243,19 +2230,19 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
}
switch (GET_OPCODE(op)) {
- case SLJIT_ADDD:
+ case SLJIT_DADD:
FAIL_IF(push_inst(compiler, EMIT_FPU_OPERATION(VADD_F32, op & SLJIT_SINGLE_OP, dst_r, src2, src1)));
break;
- case SLJIT_SUBD:
+ case SLJIT_DSUB:
FAIL_IF(push_inst(compiler, EMIT_FPU_OPERATION(VSUB_F32, op & SLJIT_SINGLE_OP, dst_r, src2, src1)));
break;
- case SLJIT_MULD:
+ case SLJIT_DMUL:
FAIL_IF(push_inst(compiler, EMIT_FPU_OPERATION(VMUL_F32, op & SLJIT_SINGLE_OP, dst_r, src2, src1)));
break;
- case SLJIT_DIVD:
+ case SLJIT_DDIV:
FAIL_IF(push_inst(compiler, EMIT_FPU_OPERATION(VDIV_F32, op & SLJIT_SINGLE_OP, dst_r, src2, src1)));
break;
}
@@ -2277,7 +2264,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw)
{
CHECK_ERROR();
- check_sljit_emit_fast_enter(compiler, dst, dstw);
+ CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw));
ADJUST_LOCAL_OFFSET(dst, dstw);
/* For UNUSED dst. Uncommon, but possible. */
@@ -2300,7 +2287,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *c
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw)
{
CHECK_ERROR();
- check_sljit_emit_fast_return(compiler, src, srcw);
+ CHECK(check_sljit_emit_fast_return(compiler, src, srcw));
ADJUST_LOCAL_OFFSET(src, srcw);
if (FAST_IS_REG(src))
@@ -2327,53 +2314,54 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *
static sljit_uw get_cc(sljit_si type)
{
switch (type) {
- case SLJIT_C_EQUAL:
- case SLJIT_C_MUL_NOT_OVERFLOW:
- case SLJIT_C_FLOAT_EQUAL:
+ case SLJIT_EQUAL:
+ case SLJIT_MUL_NOT_OVERFLOW:
+ case SLJIT_D_EQUAL:
return 0x00000000;
- case SLJIT_C_NOT_EQUAL:
- case SLJIT_C_MUL_OVERFLOW:
- case SLJIT_C_FLOAT_NOT_EQUAL:
+ case SLJIT_NOT_EQUAL:
+ case SLJIT_MUL_OVERFLOW:
+ case SLJIT_D_NOT_EQUAL:
return 0x10000000;
- case SLJIT_C_LESS:
- case SLJIT_C_FLOAT_LESS:
+ case SLJIT_LESS:
+ case SLJIT_D_LESS:
return 0x30000000;
- case SLJIT_C_GREATER_EQUAL:
- case SLJIT_C_FLOAT_GREATER_EQUAL:
+ case SLJIT_GREATER_EQUAL:
+ case SLJIT_D_GREATER_EQUAL:
return 0x20000000;
- case SLJIT_C_GREATER:
- case SLJIT_C_FLOAT_GREATER:
+ case SLJIT_GREATER:
+ case SLJIT_D_GREATER:
return 0x80000000;
- case SLJIT_C_LESS_EQUAL:
- case SLJIT_C_FLOAT_LESS_EQUAL:
+ case SLJIT_LESS_EQUAL:
+ case SLJIT_D_LESS_EQUAL:
return 0x90000000;
- case SLJIT_C_SIG_LESS:
+ case SLJIT_SIG_LESS:
return 0xb0000000;
- case SLJIT_C_SIG_GREATER_EQUAL:
+ case SLJIT_SIG_GREATER_EQUAL:
return 0xa0000000;
- case SLJIT_C_SIG_GREATER:
+ case SLJIT_SIG_GREATER:
return 0xc0000000;
- case SLJIT_C_SIG_LESS_EQUAL:
+ case SLJIT_SIG_LESS_EQUAL:
return 0xd0000000;
- case SLJIT_C_OVERFLOW:
- case SLJIT_C_FLOAT_UNORDERED:
+ case SLJIT_OVERFLOW:
+ case SLJIT_D_UNORDERED:
return 0x60000000;
- case SLJIT_C_NOT_OVERFLOW:
- case SLJIT_C_FLOAT_ORDERED:
+ case SLJIT_NOT_OVERFLOW:
+ case SLJIT_D_ORDERED:
return 0x70000000;
- default: /* SLJIT_JUMP */
+ default:
+ SLJIT_ASSERT(type >= SLJIT_JUMP && type <= SLJIT_CALL3);
return 0xe0000000;
}
}
@@ -2383,7 +2371,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compi
struct sljit_label *label;
CHECK_ERROR_PTR();
- check_sljit_emit_label(compiler);
+ CHECK_PTR(check_sljit_emit_label(compiler));
if (compiler->last_label && compiler->last_label->size == compiler->size)
return compiler->last_label;
@@ -2399,7 +2387,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile
struct sljit_jump *jump;
CHECK_ERROR_PTR();
- check_sljit_emit_jump(compiler, type);
+ CHECK_PTR(check_sljit_emit_jump(compiler, type));
jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
PTR_FAIL_IF(!jump);
@@ -2440,7 +2428,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_ijump(struct sljit_compiler *compil
struct sljit_jump *jump;
CHECK_ERROR();
- check_sljit_emit_ijump(compiler, type, src, srcw);
+ CHECK(check_sljit_emit_ijump(compiler, type, src, srcw));
ADJUST_LOCAL_OFFSET(src, srcw);
/* In ARM, we don't need to touch the arguments. */
@@ -2481,7 +2469,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
sljit_uw cc, ins;
CHECK_ERROR();
- check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type);
+ CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src, srcw);
@@ -2489,7 +2477,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
return SLJIT_SUCCESS;
op = GET_OPCODE(op);
- cc = get_cc(type);
+ cc = get_cc(type & 0xff);
dst_r = FAST_IS_REG(dst) ? dst : TMP_REG2;
if (op < SLJIT_ADD) {
@@ -2531,7 +2519,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compi
sljit_si reg;
CHECK_ERROR_PTR();
- check_sljit_emit_const(compiler, dst, dstw, init_value);
+ CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value));
ADJUST_LOCAL_OFFSET(dst, dstw);
const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const));
diff --git a/pcre/sljit/sljitNativeARM_64.c b/pcre/sljit/sljitNativeARM_64.c
index fba664ec9b9..b66455f7569 100644
--- a/pcre/sljit/sljitNativeARM_64.c
+++ b/pcre/sljit/sljitNativeARM_64.c
@@ -32,20 +32,19 @@ SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name(void)
/* Length of an instruction word */
typedef sljit_ui sljit_ins;
-#define TMP_ZERO 0
+#define TMP_ZERO (0)
#define TMP_REG1 (SLJIT_NUMBER_OF_REGISTERS + 2)
#define TMP_REG2 (SLJIT_NUMBER_OF_REGISTERS + 3)
#define TMP_REG3 (SLJIT_NUMBER_OF_REGISTERS + 4)
-#define TMP_REG4 (SLJIT_NUMBER_OF_REGISTERS + 5)
-#define TMP_LR (SLJIT_NUMBER_OF_REGISTERS + 6)
-#define TMP_SP (SLJIT_NUMBER_OF_REGISTERS + 7)
+#define TMP_LR (SLJIT_NUMBER_OF_REGISTERS + 5)
+#define TMP_SP (SLJIT_NUMBER_OF_REGISTERS + 6)
#define TMP_FREG1 (0)
#define TMP_FREG2 (SLJIT_NUMBER_OF_FLOAT_REGISTERS + 1)
static SLJIT_CONST sljit_ub reg_map[SLJIT_NUMBER_OF_REGISTERS + 8] = {
- 31, 0, 1, 2, 3, 4, 5, 6, 7, 13, 14, 15, 16, 17, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 29, 9, 10, 11, 12, 30, 31
+ 31, 0, 1, 2, 3, 4, 5, 6, 7, 12, 13, 14, 15, 16, 17, 8, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 29, 9, 10, 11, 30, 31
};
#define W_OP (1 << 31)
@@ -220,7 +219,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
struct sljit_const *const_;
CHECK_ERROR_PTR();
- check_sljit_generate_code(compiler);
+ CHECK_PTR(check_sljit_generate_code(compiler));
reverse_buf(compiler);
code = (sljit_ins*)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_ins));
@@ -730,12 +729,12 @@ static sljit_si emit_op_imm(struct sljit_compiler *compiler, sljit_si flags, slj
return push_inst(compiler, (MADD ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2) | RT2(TMP_ZERO));
if (flags & INT_OP) {
FAIL_IF(push_inst(compiler, SMADDL | RD(dst) | RN(arg1) | RM(arg2) | (31 << 10)));
- FAIL_IF(push_inst(compiler, ADD | RD(TMP_REG4) | RN(TMP_ZERO) | RM(dst) | (2 << 22) | (31 << 10)));
- return push_inst(compiler, SUBS | RD(TMP_ZERO) | RN(TMP_REG4) | RM(dst) | (2 << 22) | (63 << 10));
+ FAIL_IF(push_inst(compiler, ADD | RD(TMP_LR) | RN(TMP_ZERO) | RM(dst) | (2 << 22) | (31 << 10)));
+ return push_inst(compiler, SUBS | RD(TMP_ZERO) | RN(TMP_LR) | RM(dst) | (2 << 22) | (63 << 10));
}
- FAIL_IF(push_inst(compiler, SMULH | RD(TMP_REG4) | RN(arg1) | RM(arg2)));
+ FAIL_IF(push_inst(compiler, SMULH | RD(TMP_LR) | RN(arg1) | RM(arg2)));
FAIL_IF(push_inst(compiler, MADD | RD(dst) | RN(arg1) | RM(arg2) | RT2(TMP_ZERO)));
- return push_inst(compiler, SUBS | RD(TMP_ZERO) | RN(TMP_REG4) | RM(dst) | (2 << 22) | (63 << 10));
+ return push_inst(compiler, SUBS | RD(TMP_ZERO) | RN(TMP_LR) | RM(dst) | (2 << 22) | (63 << 10));
case SLJIT_AND:
CHECK_FLAGS(3 << 29);
return push_inst(compiler, (AND ^ inv_bits) | RD(dst) | RN(arg1) | RM(arg2));
@@ -976,9 +975,9 @@ static sljit_si getput_arg(struct sljit_compiler *compiler, sljit_si flags, slji
FAIL_IF(push_inst(compiler, ADD | RD(arg) | RN(arg) | RM(other_r) | (argw << 10)));
return push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(arg));
}
- FAIL_IF(push_inst(compiler, ADD | RD(TMP_REG4) | RN(arg) | RM(other_r) | (argw << 10)));
- FAIL_IF(push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(TMP_REG4)));
- return push_inst(compiler, ORR | RD(arg) | RN(TMP_ZERO) | RM(TMP_REG4));
+ FAIL_IF(push_inst(compiler, ADD | RD(TMP_LR) | RN(arg) | RM(other_r) | (argw << 10)));
+ FAIL_IF(push_inst(compiler, sljit_mem_imm[flags & 0x3] | (shift << 30) | RT(reg) | RN(TMP_LR)));
+ return push_inst(compiler, ORR | RD(arg) | RN(TMP_ZERO) | RM(TMP_LR));
}
if (arg & OFFS_REG_MASK) {
@@ -1065,41 +1064,33 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
{
- sljit_si i, tmp, offs, prev;
+ sljit_si i, tmp, offs, prev, saved_regs_size;
CHECK_ERROR();
- check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- compiler->options = options;
- compiler->scratches = scratches;
- compiler->saveds = saveds;
- compiler->fscratches = fscratches;
- compiler->fsaveds = fsaveds;
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
- compiler->logical_local_size = local_size;
-#endif
- compiler->locals_offset = GET_SAVED_REGISTERS_SIZE(scratches, saveds, 2);
- local_size = (compiler->locals_offset + local_size + 15) & ~15;
+ CHECK(check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
+ set_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
+
+ saved_regs_size = GET_SAVED_REGISTERS_SIZE(scratches, saveds, 0);
+ local_size += saved_regs_size + SLJIT_LOCALS_OFFSET;
+ local_size = (local_size + 15) & ~0xf;
compiler->local_size = local_size;
- if (local_size <= (64 << 3))
+ if (local_size <= (63 * sizeof(sljit_sw))) {
FAIL_IF(push_inst(compiler, STP_PRE | 29 | RT2(TMP_LR)
| RN(TMP_SP) | ((-(local_size >> 3) & 0x7f) << 15)));
- else {
- local_size -= (64 << 3);
- if (local_size > 0xfff) {
- FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | ((local_size >> 12) << 10) | (1 << 22)));
- local_size &= 0xfff;
+ FAIL_IF(push_inst(compiler, ADDI | RD(SLJIT_SP) | RN(TMP_SP) | (0 << 10)));
+ offs = (local_size - saved_regs_size) << (15 - 3);
+ } else {
+ offs = 0 << 15;
+ if (saved_regs_size & 0x8) {
+ offs = 1 << 15;
+ saved_regs_size += sizeof(sljit_sw);
}
- if (local_size)
- FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | (local_size << 10)));
- FAIL_IF(push_inst(compiler, STP_PRE | 29 | RT2(TMP_LR) | RN(TMP_SP) | (0x40 << 15)));
+ local_size -= saved_regs_size + SLJIT_LOCALS_OFFSET;
+ FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | (saved_regs_size << 10)));
}
- FAIL_IF(push_inst(compiler, ADDI | RD(SLJIT_SP) | RN(TMP_SP)));
-
tmp = saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - saveds) : SLJIT_FIRST_SAVED_REG;
- offs = 2 << 15;
prev = -1;
for (i = SLJIT_S0; i >= tmp; i--) {
if (prev == -1) {
@@ -1124,6 +1115,19 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
if (prev != -1)
FAIL_IF(push_inst(compiler, STRI | RT(prev) | RN(TMP_SP) | (offs >> 5)));
+ if (compiler->local_size > (63 * sizeof(sljit_sw))) {
+ /* The local_size is already adjusted by the saved registers. */
+ if (local_size > 0xfff) {
+ FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | ((local_size >> 12) << 10) | (1 << 22)));
+ local_size &= 0xfff;
+ }
+ if (local_size)
+ FAIL_IF(push_inst(compiler, SUBI | RD(TMP_SP) | RN(TMP_SP) | (local_size << 10)));
+ FAIL_IF(push_inst(compiler, STP_PRE | 29 | RT2(TMP_LR)
+ | RN(TMP_SP) | ((-(16 >> 3) & 0x7f) << 15)));
+ FAIL_IF(push_inst(compiler, ADDI | RD(SLJIT_SP) | RN(TMP_SP) | (0 << 10)));
+ }
+
if (args >= 1)
FAIL_IF(push_inst(compiler, ORR | RD(SLJIT_S0) | RN(TMP_ZERO) | RM(SLJIT_R0)));
if (args >= 2)
@@ -1134,37 +1138,53 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
return SLJIT_SUCCESS;
}
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler,
+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler,
sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
{
- CHECK_ERROR_VOID();
- check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- compiler->options = options;
- compiler->scratches = scratches;
- compiler->saveds = saveds;
- compiler->fscratches = fscratches;
- compiler->fsaveds = fsaveds;
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
- compiler->logical_local_size = local_size;
-#endif
- compiler->locals_offset = GET_SAVED_REGISTERS_SIZE(scratches, saveds, 2);
- compiler->local_size = (compiler->locals_offset + local_size + 15) & ~15;
+ CHECK_ERROR();
+ CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
+ set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
+
+ local_size += GET_SAVED_REGISTERS_SIZE(scratches, saveds, 0) + SLJIT_LOCALS_OFFSET;
+ local_size = (local_size + 15) & ~0xf;
+ compiler->local_size = local_size;
+ return SLJIT_SUCCESS;
}
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
{
sljit_si local_size;
- sljit_si i, tmp, offs, prev;
+ sljit_si i, tmp, offs, prev, saved_regs_size;
CHECK_ERROR();
- check_sljit_emit_return(compiler, op, src, srcw);
+ CHECK(check_sljit_emit_return(compiler, op, src, srcw));
FAIL_IF(emit_mov_before_return(compiler, op, src, srcw));
+ local_size = compiler->local_size;
+
+ saved_regs_size = GET_SAVED_REGISTERS_SIZE(compiler->scratches, compiler->saveds, 0);
+ if (local_size <= (63 * sizeof(sljit_sw)))
+ offs = (local_size - saved_regs_size) << (15 - 3);
+ else {
+ FAIL_IF(push_inst(compiler, LDP_PST | 29 | RT2(TMP_LR)
+ | RN(TMP_SP) | (((16 >> 3) & 0x7f) << 15)));
+ offs = 0 << 15;
+ if (saved_regs_size & 0x8) {
+ offs = 1 << 15;
+ saved_regs_size += sizeof(sljit_sw);
+ }
+ local_size -= saved_regs_size + SLJIT_LOCALS_OFFSET;
+ if (local_size > 0xfff) {
+ FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | ((local_size >> 12) << 10) | (1 << 22)));
+ local_size &= 0xfff;
+ }
+ if (local_size)
+ FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | (local_size << 10)));
+ }
+
tmp = compiler->saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - compiler->saveds) : SLJIT_FIRST_SAVED_REG;
- offs = 2 << 15;
prev = -1;
for (i = SLJIT_S0; i >= tmp; i--) {
if (prev == -1) {
@@ -1189,20 +1209,11 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compi
if (prev != -1)
FAIL_IF(push_inst(compiler, LDRI | RT(prev) | RN(TMP_SP) | (offs >> 5)));
- local_size = compiler->local_size;
-
- if (local_size <= (62 << 3))
+ if (compiler->local_size <= (63 * sizeof(sljit_sw))) {
FAIL_IF(push_inst(compiler, LDP_PST | 29 | RT2(TMP_LR)
| RN(TMP_SP) | (((local_size >> 3) & 0x7f) << 15)));
- else {
- FAIL_IF(push_inst(compiler, LDP_PST | 29 | RT2(TMP_LR) | RN(TMP_SP) | (0x3e << 15)));
- local_size -= (62 << 3);
- if (local_size > 0xfff) {
- FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | ((local_size >> 12) << 10) | (1 << 22)));
- local_size &= 0xfff;
- }
- if (local_size)
- FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | (local_size << 10)));
+ } else {
+ FAIL_IF(push_inst(compiler, ADDI | RD(TMP_SP) | RN(TMP_SP) | (saved_regs_size << 10)));
}
FAIL_IF(push_inst(compiler, RET | RN(TMP_LR)));
@@ -1218,7 +1229,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
sljit_ins inv_bits = (op & SLJIT_INT_OP) ? (1 << 31) : 0;
CHECK_ERROR();
- check_sljit_emit_op0(compiler, op);
+ CHECK(check_sljit_emit_op0(compiler, op));
op = GET_OPCODE(op);
switch (op) {
@@ -1226,15 +1237,15 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
return push_inst(compiler, BRK);
case SLJIT_NOP:
return push_inst(compiler, NOP);
- case SLJIT_UMUL:
- case SLJIT_SMUL:
+ case SLJIT_LUMUL:
+ case SLJIT_LSMUL:
FAIL_IF(push_inst(compiler, ORR | RD(TMP_REG1) | RN(TMP_ZERO) | RM(SLJIT_R0)));
FAIL_IF(push_inst(compiler, MADD | RD(SLJIT_R0) | RN(SLJIT_R0) | RM(SLJIT_R1) | RT2(TMP_ZERO)));
- return push_inst(compiler, (op == SLJIT_SMUL ? SMULH : UMULH) | RD(SLJIT_R1) | RN(TMP_REG1) | RM(SLJIT_R1));
- case SLJIT_UDIV:
- case SLJIT_SDIV:
+ return push_inst(compiler, (op == SLJIT_LUMUL ? UMULH : SMULH) | RD(SLJIT_R1) | RN(TMP_REG1) | RM(SLJIT_R1));
+ case SLJIT_LUDIV:
+ case SLJIT_LSDIV:
FAIL_IF(push_inst(compiler, (ORR ^ inv_bits) | RD(TMP_REG1) | RN(TMP_ZERO) | RM(SLJIT_R0)));
- FAIL_IF(push_inst(compiler, ((op == SLJIT_SDIV ? SDIV : UDIV) ^ inv_bits) | RD(SLJIT_R0) | RN(SLJIT_R0) | RM(SLJIT_R1)));
+ FAIL_IF(push_inst(compiler, ((op == SLJIT_LUDIV ? UDIV : SDIV) ^ inv_bits) | RD(SLJIT_R0) | RN(SLJIT_R0) | RM(SLJIT_R1)));
FAIL_IF(push_inst(compiler, (MADD ^ inv_bits) | RD(SLJIT_R1) | RN(SLJIT_R0) | RM(SLJIT_R1) | RT2(TMP_ZERO)));
return push_inst(compiler, (SUB ^ inv_bits) | RD(SLJIT_R1) | RN(TMP_REG1) | RM(SLJIT_R1));
}
@@ -1250,7 +1261,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler
sljit_si op_flags = GET_ALL_FLAGS(op);
CHECK_ERROR();
- check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw);
+ CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src, srcw);
@@ -1402,7 +1413,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler
sljit_si dst_r, flags, mem_flags;
CHECK_ERROR();
- check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
+ CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src1, src1w);
ADJUST_LOCAL_OFFSET(src2, src2w);
@@ -1481,13 +1492,13 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_register_index(sljit_si reg)
{
- check_sljit_get_register_index(reg);
+ CHECK_REG_INDEX(check_sljit_get_register_index(reg));
return reg_map[reg];
}
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_float_register_index(sljit_si reg)
{
- check_sljit_get_float_register_index(reg);
+ CHECK_REG_INDEX(check_sljit_get_float_register_index(reg));
return reg;
}
@@ -1495,8 +1506,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *co
void *instruction, sljit_si size)
{
CHECK_ERROR();
- check_sljit_emit_op_custom(compiler, instruction, size);
- SLJIT_ASSERT(size == 4);
+ CHECK(check_sljit_emit_op_custom(compiler, instruction, size));
return push_inst(compiler, *(sljit_ins*)instruction);
}
@@ -1662,7 +1672,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compile
}
switch (GET_OPCODE(op)) {
- case SLJIT_MOVD:
+ case SLJIT_DMOV:
if (src != dst_r) {
if (dst_r != TMP_FREG1)
FAIL_IF(push_inst(compiler, (FMOV ^ inv_bits) | VD(dst_r) | VN(src)));
@@ -1670,10 +1680,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compile
dst_r = src;
}
break;
- case SLJIT_NEGD:
+ case SLJIT_DNEG:
FAIL_IF(push_inst(compiler, (FNEG ^ inv_bits) | VD(dst_r) | VN(src)));
break;
- case SLJIT_ABSD:
+ case SLJIT_DABS:
FAIL_IF(push_inst(compiler, (FABS ^ inv_bits) | VD(dst_r) | VN(src)));
break;
case SLJIT_CONVD_FROMS:
@@ -1695,7 +1705,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
sljit_ins inv_bits = (op & SLJIT_SINGLE_OP) ? (1 << 22) : 0;
CHECK_ERROR();
- check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
+ CHECK(check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src1, src1w);
ADJUST_LOCAL_OFFSET(src2, src2w);
@@ -1714,16 +1724,16 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
}
switch (GET_OPCODE(op)) {
- case SLJIT_ADDD:
+ case SLJIT_DADD:
FAIL_IF(push_inst(compiler, (FADD ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2)));
break;
- case SLJIT_SUBD:
+ case SLJIT_DSUB:
FAIL_IF(push_inst(compiler, (FSUB ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2)));
break;
- case SLJIT_MULD:
+ case SLJIT_DMUL:
FAIL_IF(push_inst(compiler, (FMUL ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2)));
break;
- case SLJIT_DIVD:
+ case SLJIT_DDIV:
FAIL_IF(push_inst(compiler, (FDIV ^ inv_bits) | VD(dst_r) | VN(src1) | VM(src2)));
break;
}
@@ -1740,7 +1750,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw)
{
CHECK_ERROR();
- check_sljit_emit_fast_enter(compiler, dst, dstw);
+ CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw));
ADJUST_LOCAL_OFFSET(dst, dstw);
/* For UNUSED dst. Uncommon, but possible. */
@@ -1757,7 +1767,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *c
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw)
{
CHECK_ERROR();
- check_sljit_emit_fast_return(compiler, src, srcw);
+ CHECK(check_sljit_emit_fast_return(compiler, src, srcw));
ADJUST_LOCAL_OFFSET(src, srcw);
if (FAST_IS_REG(src))
@@ -1777,50 +1787,50 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *
static sljit_uw get_cc(sljit_si type)
{
switch (type) {
- case SLJIT_C_EQUAL:
- case SLJIT_C_MUL_NOT_OVERFLOW:
- case SLJIT_C_FLOAT_EQUAL:
+ case SLJIT_EQUAL:
+ case SLJIT_MUL_NOT_OVERFLOW:
+ case SLJIT_D_EQUAL:
return 0x1;
- case SLJIT_C_NOT_EQUAL:
- case SLJIT_C_MUL_OVERFLOW:
- case SLJIT_C_FLOAT_NOT_EQUAL:
+ case SLJIT_NOT_EQUAL:
+ case SLJIT_MUL_OVERFLOW:
+ case SLJIT_D_NOT_EQUAL:
return 0x0;
- case SLJIT_C_LESS:
- case SLJIT_C_FLOAT_LESS:
+ case SLJIT_LESS:
+ case SLJIT_D_LESS:
return 0x2;
- case SLJIT_C_GREATER_EQUAL:
- case SLJIT_C_FLOAT_GREATER_EQUAL:
+ case SLJIT_GREATER_EQUAL:
+ case SLJIT_D_GREATER_EQUAL:
return 0x3;
- case SLJIT_C_GREATER:
- case SLJIT_C_FLOAT_GREATER:
+ case SLJIT_GREATER:
+ case SLJIT_D_GREATER:
return 0x9;
- case SLJIT_C_LESS_EQUAL:
- case SLJIT_C_FLOAT_LESS_EQUAL:
+ case SLJIT_LESS_EQUAL:
+ case SLJIT_D_LESS_EQUAL:
return 0x8;
- case SLJIT_C_SIG_LESS:
+ case SLJIT_SIG_LESS:
return 0xa;
- case SLJIT_C_SIG_GREATER_EQUAL:
+ case SLJIT_SIG_GREATER_EQUAL:
return 0xb;
- case SLJIT_C_SIG_GREATER:
+ case SLJIT_SIG_GREATER:
return 0xd;
- case SLJIT_C_SIG_LESS_EQUAL:
+ case SLJIT_SIG_LESS_EQUAL:
return 0xc;
- case SLJIT_C_OVERFLOW:
- case SLJIT_C_FLOAT_UNORDERED:
+ case SLJIT_OVERFLOW:
+ case SLJIT_D_UNORDERED:
return 0x7;
- case SLJIT_C_NOT_OVERFLOW:
- case SLJIT_C_FLOAT_ORDERED:
+ case SLJIT_NOT_OVERFLOW:
+ case SLJIT_D_ORDERED:
return 0x6;
default:
@@ -1834,7 +1844,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compi
struct sljit_label *label;
CHECK_ERROR_PTR();
- check_sljit_emit_label(compiler);
+ CHECK_PTR(check_sljit_emit_label(compiler));
if (compiler->last_label && compiler->last_label->size == compiler->size)
return compiler->last_label;
@@ -1850,7 +1860,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile
struct sljit_jump *jump;
CHECK_ERROR_PTR();
- check_sljit_emit_jump(compiler, type);
+ CHECK_PTR(check_sljit_emit_jump(compiler, type));
jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
PTR_FAIL_IF(!jump);
@@ -1877,7 +1887,7 @@ static SLJIT_INLINE struct sljit_jump* emit_cmp_to0(struct sljit_compiler *compi
struct sljit_jump *jump;
sljit_ins inv_bits = (type & SLJIT_INT_OP) ? (1 << 31) : 0;
- SLJIT_ASSERT((type & 0xff) == SLJIT_C_EQUAL || (type & 0xff) == SLJIT_C_NOT_EQUAL);
+ SLJIT_ASSERT((type & 0xff) == SLJIT_EQUAL || (type & 0xff) == SLJIT_NOT_EQUAL);
ADJUST_LOCAL_OFFSET(src, srcw);
jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
@@ -1895,7 +1905,7 @@ static SLJIT_INLINE struct sljit_jump* emit_cmp_to0(struct sljit_compiler *compi
}
SLJIT_ASSERT(FAST_IS_REG(src));
- if ((type & 0xff) == SLJIT_C_EQUAL)
+ if ((type & 0xff) == SLJIT_EQUAL)
inv_bits |= 1 << 24;
PTR_FAIL_IF(push_inst(compiler, (CBZ ^ inv_bits) | (6 << 5) | RT(src)));
@@ -1910,7 +1920,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_ijump(struct sljit_compiler *compil
struct sljit_jump *jump;
CHECK_ERROR();
- check_sljit_emit_ijump(compiler, type, src, srcw);
+ CHECK(check_sljit_emit_ijump(compiler, type, src, srcw));
ADJUST_LOCAL_OFFSET(src, srcw);
/* In ARM, we don't need to touch the arguments. */
@@ -1941,14 +1951,14 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
sljit_ins cc;
CHECK_ERROR();
- check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type);
+ CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src, srcw);
if (dst == SLJIT_UNUSED)
return SLJIT_SUCCESS;
- cc = get_cc(type);
+ cc = get_cc(type & 0xff);
dst_r = FAST_IS_REG(dst) ? dst : TMP_REG1;
if (GET_OPCODE(op) < SLJIT_ADD) {
@@ -1988,7 +1998,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compi
sljit_si dst_r;
CHECK_ERROR_PTR();
- check_sljit_emit_const(compiler, dst, dstw, init_value);
+ CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value));
ADJUST_LOCAL_OFFSET(dst, dstw);
const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const));
diff --git a/pcre/sljit/sljitNativeARM_T2_32.c b/pcre/sljit/sljitNativeARM_T2_32.c
index 7ea8cd7d823..6e38cec899d 100644
--- a/pcre/sljit/sljitNativeARM_T2_32.c
+++ b/pcre/sljit/sljitNativeARM_T2_32.c
@@ -353,7 +353,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
struct sljit_const *const_;
CHECK_ERROR_PTR();
- check_sljit_generate_code(compiler);
+ CHECK_PTR(check_sljit_generate_code(compiler));
reverse_buf(compiler);
code = (sljit_uh*)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_uh));
@@ -1135,16 +1135,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
sljit_ins push;
CHECK_ERROR();
- check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- compiler->options = options;
- compiler->scratches = scratches;
- compiler->saveds = saveds;
- compiler->fscratches = fscratches;
- compiler->fsaveds = fsaveds;
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
- compiler->logical_local_size = local_size;
-#endif
+ CHECK(check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
+ set_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
push = (1 << 4);
@@ -1180,26 +1172,19 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
return SLJIT_SUCCESS;
}
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler,
+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler,
sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
{
sljit_si size;
- CHECK_ERROR_VOID();
- check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- compiler->options = options;
- compiler->scratches = scratches;
- compiler->saveds = saveds;
- compiler->fscratches = fscratches;
- compiler->fsaveds = fsaveds;
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
- compiler->logical_local_size = local_size;
-#endif
+ CHECK_ERROR();
+ CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
+ set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
size = GET_SAVED_REGISTERS_SIZE(scratches, saveds, 2);
compiler->local_size = ((size + local_size + 7) & ~7) - size;
+ return SLJIT_SUCCESS;
}
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
@@ -1208,7 +1193,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compi
sljit_ins pop;
CHECK_ERROR();
- check_sljit_emit_return(compiler, op, src, srcw);
+ CHECK(check_sljit_emit_return(compiler, op, src, srcw));
FAIL_IF(emit_mov_before_return(compiler, op, src, srcw));
@@ -1255,7 +1240,7 @@ extern int __aeabi_idivmod(int numerator, int denominator);
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op)
{
CHECK_ERROR();
- check_sljit_emit_op0(compiler, op);
+ CHECK(check_sljit_emit_op0(compiler, op));
op = GET_OPCODE(op);
switch (op) {
@@ -1263,15 +1248,15 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
return push_inst16(compiler, BKPT);
case SLJIT_NOP:
return push_inst16(compiler, NOP);
- case SLJIT_UMUL:
- case SLJIT_SMUL:
- return push_inst32(compiler, (op == SLJIT_UMUL ? UMULL : SMULL)
+ case SLJIT_LUMUL:
+ case SLJIT_LSMUL:
+ return push_inst32(compiler, (op == SLJIT_LUMUL ? UMULL : SMULL)
| (reg_map[SLJIT_R1] << 8)
| (reg_map[SLJIT_R0] << 12)
| (reg_map[SLJIT_R0] << 16)
| reg_map[SLJIT_R1]);
- case SLJIT_UDIV:
- case SLJIT_SDIV:
+ case SLJIT_LUDIV:
+ case SLJIT_LSDIV:
if (compiler->scratches >= 4) {
FAIL_IF(push_inst32(compiler, 0xf84d2d04 /* str r2, [sp, #-4]! */));
FAIL_IF(push_inst32(compiler, 0xf84dcd04 /* str ip, [sp, #-4]! */));
@@ -1279,7 +1264,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
FAIL_IF(push_inst32(compiler, 0xf84d2d08 /* str r2, [sp, #-8]! */));
#if defined(__GNUC__)
FAIL_IF(sljit_emit_ijump(compiler, SLJIT_FAST_CALL, SLJIT_IMM,
- (op == SLJIT_UDIV ? SLJIT_FUNC_OFFSET(__aeabi_uidivmod) : SLJIT_FUNC_OFFSET(__aeabi_idivmod))));
+ (op == SLJIT_LUDIV ? SLJIT_FUNC_OFFSET(__aeabi_uidivmod) : SLJIT_FUNC_OFFSET(__aeabi_idivmod))));
#else
#error "Software divmod functions are needed"
#endif
@@ -1302,7 +1287,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler
sljit_si op_flags = GET_ALL_FLAGS(op);
CHECK_ERROR();
- check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw);
+ CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src, srcw);
@@ -1395,7 +1380,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler
}
if (op == SLJIT_NEG) {
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
+ || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
compiler->skip_checks = 1;
#endif
return sljit_emit_op2(compiler, SLJIT_SUB | op_flags, dst, dstw, SLJIT_IMM, 0, src, srcw);
@@ -1434,7 +1420,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler
sljit_si dst_r, flags;
CHECK_ERROR();
- check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
+ CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src1, src1w);
ADJUST_LOCAL_OFFSET(src2, src2w);
@@ -1507,13 +1493,13 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_register_index(sljit_si reg)
{
- check_sljit_get_register_index(reg);
+ CHECK_REG_INDEX(check_sljit_get_register_index(reg));
return reg_map[reg];
}
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_float_register_index(sljit_si reg)
{
- check_sljit_get_float_register_index(reg);
+ CHECK_REG_INDEX(check_sljit_get_float_register_index(reg));
return reg << 1;
}
@@ -1521,8 +1507,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *co
void *instruction, sljit_si size)
{
CHECK_ERROR();
- check_sljit_emit_op_custom(compiler, instruction, size);
- SLJIT_ASSERT(size == 2 || size == 4);
+ CHECK(check_sljit_emit_op_custom(compiler, instruction, size));
if (size == 2)
return push_inst16(compiler, *(sljit_uh*)instruction);
@@ -1695,7 +1680,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compile
}
switch (GET_OPCODE(op)) {
- case SLJIT_MOVD:
+ case SLJIT_DMOV:
if (src != dst_r) {
if (dst_r != TMP_FREG1)
FAIL_IF(push_inst32(compiler, VMOV_F32 | (op & SLJIT_SINGLE_OP) | DD4(dst_r) | DM4(src)));
@@ -1703,10 +1688,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compile
dst_r = src;
}
break;
- case SLJIT_NEGD:
+ case SLJIT_DNEG:
FAIL_IF(push_inst32(compiler, VNEG_F32 | (op & SLJIT_SINGLE_OP) | DD4(dst_r) | DM4(src)));
break;
- case SLJIT_ABSD:
+ case SLJIT_DABS:
FAIL_IF(push_inst32(compiler, VABS_F32 | (op & SLJIT_SINGLE_OP) | DD4(dst_r) | DM4(src)));
break;
case SLJIT_CONVD_FROMS:
@@ -1728,7 +1713,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
sljit_si dst_r;
CHECK_ERROR();
- check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
+ CHECK(check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src1, src1w);
ADJUST_LOCAL_OFFSET(src2, src2w);
@@ -1748,16 +1733,16 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
}
switch (GET_OPCODE(op)) {
- case SLJIT_ADDD:
+ case SLJIT_DADD:
FAIL_IF(push_inst32(compiler, VADD_F32 | (op & SLJIT_SINGLE_OP) | DD4(dst_r) | DN4(src1) | DM4(src2)));
break;
- case SLJIT_SUBD:
+ case SLJIT_DSUB:
FAIL_IF(push_inst32(compiler, VSUB_F32 | (op & SLJIT_SINGLE_OP) | DD4(dst_r) | DN4(src1) | DM4(src2)));
break;
- case SLJIT_MULD:
+ case SLJIT_DMUL:
FAIL_IF(push_inst32(compiler, VMUL_F32 | (op & SLJIT_SINGLE_OP) | DD4(dst_r) | DN4(src1) | DM4(src2)));
break;
- case SLJIT_DIVD:
+ case SLJIT_DDIV:
FAIL_IF(push_inst32(compiler, VDIV_F32 | (op & SLJIT_SINGLE_OP) | DD4(dst_r) | DN4(src1) | DM4(src2)));
break;
}
@@ -1776,7 +1761,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw)
{
CHECK_ERROR();
- check_sljit_emit_fast_enter(compiler, dst, dstw);
+ CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw));
ADJUST_LOCAL_OFFSET(dst, dstw);
/* For UNUSED dst. Uncommon, but possible. */
@@ -1799,7 +1784,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *c
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw)
{
CHECK_ERROR();
- check_sljit_emit_fast_return(compiler, src, srcw);
+ CHECK(check_sljit_emit_fast_return(compiler, src, srcw));
ADJUST_LOCAL_OFFSET(src, srcw);
if (FAST_IS_REG(src))
@@ -1826,53 +1811,54 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *
static sljit_uw get_cc(sljit_si type)
{
switch (type) {
- case SLJIT_C_EQUAL:
- case SLJIT_C_MUL_NOT_OVERFLOW:
- case SLJIT_C_FLOAT_EQUAL:
+ case SLJIT_EQUAL:
+ case SLJIT_MUL_NOT_OVERFLOW:
+ case SLJIT_D_EQUAL:
return 0x0;
- case SLJIT_C_NOT_EQUAL:
- case SLJIT_C_MUL_OVERFLOW:
- case SLJIT_C_FLOAT_NOT_EQUAL:
+ case SLJIT_NOT_EQUAL:
+ case SLJIT_MUL_OVERFLOW:
+ case SLJIT_D_NOT_EQUAL:
return 0x1;
- case SLJIT_C_LESS:
- case SLJIT_C_FLOAT_LESS:
+ case SLJIT_LESS:
+ case SLJIT_D_LESS:
return 0x3;
- case SLJIT_C_GREATER_EQUAL:
- case SLJIT_C_FLOAT_GREATER_EQUAL:
+ case SLJIT_GREATER_EQUAL:
+ case SLJIT_D_GREATER_EQUAL:
return 0x2;
- case SLJIT_C_GREATER:
- case SLJIT_C_FLOAT_GREATER:
+ case SLJIT_GREATER:
+ case SLJIT_D_GREATER:
return 0x8;
- case SLJIT_C_LESS_EQUAL:
- case SLJIT_C_FLOAT_LESS_EQUAL:
+ case SLJIT_LESS_EQUAL:
+ case SLJIT_D_LESS_EQUAL:
return 0x9;
- case SLJIT_C_SIG_LESS:
+ case SLJIT_SIG_LESS:
return 0xb;
- case SLJIT_C_SIG_GREATER_EQUAL:
+ case SLJIT_SIG_GREATER_EQUAL:
return 0xa;
- case SLJIT_C_SIG_GREATER:
+ case SLJIT_SIG_GREATER:
return 0xc;
- case SLJIT_C_SIG_LESS_EQUAL:
+ case SLJIT_SIG_LESS_EQUAL:
return 0xd;
- case SLJIT_C_OVERFLOW:
- case SLJIT_C_FLOAT_UNORDERED:
+ case SLJIT_OVERFLOW:
+ case SLJIT_D_UNORDERED:
return 0x6;
- case SLJIT_C_NOT_OVERFLOW:
- case SLJIT_C_FLOAT_ORDERED:
+ case SLJIT_NOT_OVERFLOW:
+ case SLJIT_D_ORDERED:
return 0x7;
default: /* SLJIT_JUMP */
+ SLJIT_ASSERT_STOP();
return 0xe;
}
}
@@ -1882,7 +1868,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compi
struct sljit_label *label;
CHECK_ERROR_PTR();
- check_sljit_emit_label(compiler);
+ CHECK_PTR(check_sljit_emit_label(compiler));
if (compiler->last_label && compiler->last_label->size == compiler->size)
return compiler->last_label;
@@ -1899,7 +1885,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile
sljit_ins cc;
CHECK_ERROR_PTR();
- check_sljit_emit_jump(compiler, type);
+ CHECK_PTR(check_sljit_emit_jump(compiler, type));
jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
PTR_FAIL_IF(!jump);
@@ -1931,7 +1917,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_ijump(struct sljit_compiler *compil
struct sljit_jump *jump;
CHECK_ERROR();
- check_sljit_emit_ijump(compiler, type, src, srcw);
+ CHECK(check_sljit_emit_ijump(compiler, type, src, srcw));
ADJUST_LOCAL_OFFSET(src, srcw);
/* In ARM, we don't need to touch the arguments. */
@@ -1963,7 +1949,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
sljit_ins cc, ins;
CHECK_ERROR();
- check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type);
+ CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src, srcw);
@@ -1971,7 +1957,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
return SLJIT_SUCCESS;
op = GET_OPCODE(op);
- cc = get_cc(type);
+ cc = get_cc(type & 0xff);
dst_r = FAST_IS_REG(dst) ? dst : TMP_REG2;
if (op < SLJIT_ADD) {
@@ -2042,7 +2028,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compi
sljit_si dst_r;
CHECK_ERROR_PTR();
- check_sljit_emit_const(compiler, dst, dstw, init_value);
+ CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value));
ADJUST_LOCAL_OFFSET(dst, dstw);
const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const));
diff --git a/pcre/sljit/sljitNativeMIPS_common.c b/pcre/sljit/sljitNativeMIPS_common.c
index f1f9f70c678..3e2c9f02327 100644
--- a/pcre/sljit/sljitNativeMIPS_common.c
+++ b/pcre/sljit/sljitNativeMIPS_common.c
@@ -371,7 +371,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
struct sljit_const *const_;
CHECK_ERROR_PTR();
- check_sljit_generate_code(compiler);
+ CHECK_PTR(check_sljit_generate_code(compiler));
reverse_buf(compiler);
code = (sljit_ins*)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_ins));
@@ -546,18 +546,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
sljit_si i, tmp, offs;
CHECK_ERROR();
- check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- compiler->options = options;
- compiler->scratches = scratches;
- compiler->saveds = saveds;
- compiler->fscratches = fscratches;
- compiler->fsaveds = fsaveds;
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
- compiler->logical_local_size = local_size;
-#endif
+ CHECK(check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
+ set_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
- local_size += GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1) + FIXED_LOCALS_OFFSET;
+ local_size += GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1) + SLJIT_LOCALS_OFFSET;
#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
local_size = (local_size + 15) & ~0xf;
#else
@@ -602,28 +594,21 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
return SLJIT_SUCCESS;
}
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler,
+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler,
sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
{
- CHECK_ERROR_VOID();
- check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- compiler->options = options;
- compiler->scratches = scratches;
- compiler->saveds = saveds;
- compiler->fscratches = fscratches;
- compiler->fsaveds = fsaveds;
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
- compiler->logical_local_size = local_size;
-#endif
+ CHECK_ERROR();
+ CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
+ set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
- local_size += GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1) + FIXED_LOCALS_OFFSET;
+ local_size += GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1) + SLJIT_LOCALS_OFFSET;
#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
compiler->local_size = (local_size + 15) & ~0xf;
#else
compiler->local_size = (local_size + 31) & ~0x1f;
#endif
+ return SLJIT_SUCCESS;
}
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
@@ -632,7 +617,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compi
sljit_ins base;
CHECK_ERROR();
- check_sljit_emit_return(compiler, op, src, srcw);
+ CHECK(check_sljit_emit_return(compiler, op, src, srcw));
FAIL_IF(emit_mov_before_return(compiler, op, src, srcw));
@@ -1051,7 +1036,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
#endif
CHECK_ERROR();
- check_sljit_emit_op0(compiler, op);
+ CHECK(check_sljit_emit_op0(compiler, op));
op = GET_OPCODE(op);
switch (op) {
@@ -1059,17 +1044,17 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
return push_inst(compiler, BREAK, UNMOVABLE_INS);
case SLJIT_NOP:
return push_inst(compiler, NOP, UNMOVABLE_INS);
- case SLJIT_UMUL:
- case SLJIT_SMUL:
+ case SLJIT_LUMUL:
+ case SLJIT_LSMUL:
#if (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
- FAIL_IF(push_inst(compiler, (op == SLJIT_UMUL ? DMULTU : DMULT) | S(SLJIT_R0) | T(SLJIT_R1), MOVABLE_INS));
+ FAIL_IF(push_inst(compiler, (op == SLJIT_LUMUL ? DMULTU : DMULT) | S(SLJIT_R0) | T(SLJIT_R1), MOVABLE_INS));
#else
- FAIL_IF(push_inst(compiler, (op == SLJIT_UMUL ? MULTU : MULT) | S(SLJIT_R0) | T(SLJIT_R1), MOVABLE_INS));
+ FAIL_IF(push_inst(compiler, (op == SLJIT_LUMUL ? MULTU : MULT) | S(SLJIT_R0) | T(SLJIT_R1), MOVABLE_INS));
#endif
FAIL_IF(push_inst(compiler, MFLO | D(SLJIT_R0), DR(SLJIT_R0)));
return push_inst(compiler, MFHI | D(SLJIT_R1), DR(SLJIT_R1));
- case SLJIT_UDIV:
- case SLJIT_SDIV:
+ case SLJIT_LUDIV:
+ case SLJIT_LSDIV:
#if !(defined SLJIT_MIPS_R1 && SLJIT_MIPS_R1)
FAIL_IF(push_inst(compiler, NOP, UNMOVABLE_INS));
FAIL_IF(push_inst(compiler, NOP, UNMOVABLE_INS));
@@ -1077,11 +1062,11 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
#if (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
if (int_op)
- FAIL_IF(push_inst(compiler, (op == SLJIT_UDIV ? DIVU : DIV) | S(SLJIT_R0) | T(SLJIT_R1), MOVABLE_INS));
+ FAIL_IF(push_inst(compiler, (op == SLJIT_LUDIV ? DIVU : DIV) | S(SLJIT_R0) | T(SLJIT_R1), MOVABLE_INS));
else
- FAIL_IF(push_inst(compiler, (op == SLJIT_UDIV ? DDIVU : DDIV) | S(SLJIT_R0) | T(SLJIT_R1), MOVABLE_INS));
+ FAIL_IF(push_inst(compiler, (op == SLJIT_LUDIV ? DDIVU : DDIV) | S(SLJIT_R0) | T(SLJIT_R1), MOVABLE_INS));
#else
- FAIL_IF(push_inst(compiler, (op == SLJIT_UDIV ? DIVU : DIV) | S(SLJIT_R0) | T(SLJIT_R1), MOVABLE_INS));
+ FAIL_IF(push_inst(compiler, (op == SLJIT_LUDIV ? DIVU : DIV) | S(SLJIT_R0) | T(SLJIT_R1), MOVABLE_INS));
#endif
FAIL_IF(push_inst(compiler, MFLO | D(SLJIT_R0), DR(SLJIT_R0)));
@@ -1102,7 +1087,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler
#endif
CHECK_ERROR();
- check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw);
+ CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src, srcw);
@@ -1204,7 +1189,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler
#endif
CHECK_ERROR();
- check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
+ CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src1, src1w);
ADJUST_LOCAL_OFFSET(src2, src2w);
@@ -1262,13 +1247,13 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_register_index(sljit_si reg)
{
- check_sljit_get_register_index(reg);
+ CHECK_REG_INDEX(check_sljit_get_register_index(reg));
return reg_map[reg];
}
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_float_register_index(sljit_si reg)
{
- check_sljit_get_float_register_index(reg);
+ CHECK_REG_INDEX(check_sljit_get_float_register_index(reg));
return reg << 1;
}
@@ -1276,8 +1261,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *co
void *instruction, sljit_si size)
{
CHECK_ERROR();
- check_sljit_emit_op_custom(compiler, instruction, size);
- SLJIT_ASSERT(size == 4);
+ CHECK(check_sljit_emit_op_custom(compiler, instruction, size));
return push_inst(compiler, *(sljit_ins*)instruction, UNMOVABLE_INS);
}
@@ -1438,7 +1422,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compile
src <<= 1;
switch (GET_OPCODE(op)) {
- case SLJIT_MOVD:
+ case SLJIT_DMOV:
if (src != dst_r) {
if (dst_r != TMP_FREG1)
FAIL_IF(push_inst(compiler, MOV_S | FMT(op) | FS(src) | FD(dst_r), MOVABLE_INS));
@@ -1446,10 +1430,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compile
dst_r = src;
}
break;
- case SLJIT_NEGD:
+ case SLJIT_DNEG:
FAIL_IF(push_inst(compiler, NEG_S | FMT(op) | FS(src) | FD(dst_r), MOVABLE_INS));
break;
- case SLJIT_ABSD:
+ case SLJIT_DABS:
FAIL_IF(push_inst(compiler, ABS_S | FMT(op) | FS(src) | FD(dst_r), MOVABLE_INS));
break;
case SLJIT_CONVD_FROMS:
@@ -1471,7 +1455,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
sljit_si dst_r, flags = 0;
CHECK_ERROR();
- check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
+ CHECK(check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src1, src1w);
ADJUST_LOCAL_OFFSET(src2, src2w);
@@ -1522,19 +1506,19 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
src2 = TMP_FREG2;
switch (GET_OPCODE(op)) {
- case SLJIT_ADDD:
+ case SLJIT_DADD:
FAIL_IF(push_inst(compiler, ADD_S | FMT(op) | FT(src2) | FS(src1) | FD(dst_r), MOVABLE_INS));
break;
- case SLJIT_SUBD:
+ case SLJIT_DSUB:
FAIL_IF(push_inst(compiler, SUB_S | FMT(op) | FT(src2) | FS(src1) | FD(dst_r), MOVABLE_INS));
break;
- case SLJIT_MULD:
+ case SLJIT_DMUL:
FAIL_IF(push_inst(compiler, MUL_S | FMT(op) | FT(src2) | FS(src1) | FD(dst_r), MOVABLE_INS));
break;
- case SLJIT_DIVD:
+ case SLJIT_DDIV:
FAIL_IF(push_inst(compiler, DIV_S | FMT(op) | FT(src2) | FS(src1) | FD(dst_r), MOVABLE_INS));
break;
}
@@ -1552,7 +1536,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw)
{
CHECK_ERROR();
- check_sljit_emit_fast_enter(compiler, dst, dstw);
+ CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw));
ADJUST_LOCAL_OFFSET(dst, dstw);
/* For UNUSED dst. Uncommon, but possible. */
@@ -1569,7 +1553,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *c
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw)
{
CHECK_ERROR();
- check_sljit_emit_fast_return(compiler, src, srcw);
+ CHECK(check_sljit_emit_fast_return(compiler, src, srcw));
ADJUST_LOCAL_OFFSET(src, srcw);
if (FAST_IS_REG(src))
@@ -1592,7 +1576,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compi
struct sljit_label *label;
CHECK_ERROR_PTR();
- check_sljit_emit_label(compiler);
+ CHECK_PTR(check_sljit_emit_label(compiler));
if (compiler->last_label && compiler->last_label->size == compiler->size)
return compiler->last_label;
@@ -1638,7 +1622,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile
sljit_si delay_check = UNMOVABLE_INS;
CHECK_ERROR_PTR();
- check_sljit_emit_jump(compiler, type);
+ CHECK_PTR(check_sljit_emit_jump(compiler, type));
jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
PTR_FAIL_IF(!jump);
@@ -1646,54 +1630,54 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile
type &= 0xff;
switch (type) {
- case SLJIT_C_EQUAL:
- case SLJIT_C_FLOAT_NOT_EQUAL:
+ case SLJIT_EQUAL:
+ case SLJIT_D_NOT_EQUAL:
BR_NZ(EQUAL_FLAG);
break;
- case SLJIT_C_NOT_EQUAL:
- case SLJIT_C_FLOAT_EQUAL:
+ case SLJIT_NOT_EQUAL:
+ case SLJIT_D_EQUAL:
BR_Z(EQUAL_FLAG);
break;
- case SLJIT_C_LESS:
- case SLJIT_C_FLOAT_LESS:
+ case SLJIT_LESS:
+ case SLJIT_D_LESS:
BR_Z(ULESS_FLAG);
break;
- case SLJIT_C_GREATER_EQUAL:
- case SLJIT_C_FLOAT_GREATER_EQUAL:
+ case SLJIT_GREATER_EQUAL:
+ case SLJIT_D_GREATER_EQUAL:
BR_NZ(ULESS_FLAG);
break;
- case SLJIT_C_GREATER:
- case SLJIT_C_FLOAT_GREATER:
+ case SLJIT_GREATER:
+ case SLJIT_D_GREATER:
BR_Z(UGREATER_FLAG);
break;
- case SLJIT_C_LESS_EQUAL:
- case SLJIT_C_FLOAT_LESS_EQUAL:
+ case SLJIT_LESS_EQUAL:
+ case SLJIT_D_LESS_EQUAL:
BR_NZ(UGREATER_FLAG);
break;
- case SLJIT_C_SIG_LESS:
+ case SLJIT_SIG_LESS:
BR_Z(LESS_FLAG);
break;
- case SLJIT_C_SIG_GREATER_EQUAL:
+ case SLJIT_SIG_GREATER_EQUAL:
BR_NZ(LESS_FLAG);
break;
- case SLJIT_C_SIG_GREATER:
+ case SLJIT_SIG_GREATER:
BR_Z(GREATER_FLAG);
break;
- case SLJIT_C_SIG_LESS_EQUAL:
+ case SLJIT_SIG_LESS_EQUAL:
BR_NZ(GREATER_FLAG);
break;
- case SLJIT_C_OVERFLOW:
- case SLJIT_C_MUL_OVERFLOW:
+ case SLJIT_OVERFLOW:
+ case SLJIT_MUL_OVERFLOW:
BR_Z(OVERFLOW_FLAG);
break;
- case SLJIT_C_NOT_OVERFLOW:
- case SLJIT_C_MUL_NOT_OVERFLOW:
+ case SLJIT_NOT_OVERFLOW:
+ case SLJIT_MUL_NOT_OVERFLOW:
BR_NZ(OVERFLOW_FLAG);
break;
- case SLJIT_C_FLOAT_UNORDERED:
+ case SLJIT_D_UNORDERED:
BR_F();
break;
- case SLJIT_C_FLOAT_ORDERED:
+ case SLJIT_D_ORDERED:
BR_T();
break;
default:
@@ -1755,7 +1739,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler
sljit_ins inst;
CHECK_ERROR_PTR();
- check_sljit_emit_cmp(compiler, type, src1, src1w, src2, src2w);
+ CHECK_PTR(check_sljit_emit_cmp(compiler, type, src1, src1w, src2, src2w));
ADJUST_LOCAL_OFFSET(src1, src1w);
ADJUST_LOCAL_OFFSET(src2, src2w);
@@ -1776,32 +1760,32 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler
set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP);
type &= 0xff;
- if (type <= SLJIT_C_NOT_EQUAL) {
+ if (type <= SLJIT_NOT_EQUAL) {
RESOLVE_IMM1();
RESOLVE_IMM2();
jump->flags |= IS_BIT26_COND;
if (compiler->delay_slot == MOVABLE_INS || (compiler->delay_slot != UNMOVABLE_INS && compiler->delay_slot != DR(src1) && compiler->delay_slot != DR(src2)))
jump->flags |= IS_MOVABLE;
- PTR_FAIL_IF(push_inst(compiler, (type == SLJIT_C_EQUAL ? BNE : BEQ) | S(src1) | T(src2) | JUMP_LENGTH, UNMOVABLE_INS));
+ PTR_FAIL_IF(push_inst(compiler, (type == SLJIT_EQUAL ? BNE : BEQ) | S(src1) | T(src2) | JUMP_LENGTH, UNMOVABLE_INS));
}
- else if (type >= SLJIT_C_SIG_LESS && (((src1 & SLJIT_IMM) && (src1w == 0)) || ((src2 & SLJIT_IMM) && (src2w == 0)))) {
+ else if (type >= SLJIT_SIG_LESS && (((src1 & SLJIT_IMM) && (src1w == 0)) || ((src2 & SLJIT_IMM) && (src2w == 0)))) {
inst = NOP;
if ((src1 & SLJIT_IMM) && (src1w == 0)) {
RESOLVE_IMM2();
switch (type) {
- case SLJIT_C_SIG_LESS:
+ case SLJIT_SIG_LESS:
inst = BLEZ;
jump->flags |= IS_BIT26_COND;
break;
- case SLJIT_C_SIG_GREATER_EQUAL:
+ case SLJIT_SIG_GREATER_EQUAL:
inst = BGTZ;
jump->flags |= IS_BIT26_COND;
break;
- case SLJIT_C_SIG_GREATER:
+ case SLJIT_SIG_GREATER:
inst = BGEZ;
jump->flags |= IS_BIT16_COND;
break;
- case SLJIT_C_SIG_LESS_EQUAL:
+ case SLJIT_SIG_LESS_EQUAL:
inst = BLTZ;
jump->flags |= IS_BIT16_COND;
break;
@@ -1811,19 +1795,19 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler
else {
RESOLVE_IMM1();
switch (type) {
- case SLJIT_C_SIG_LESS:
+ case SLJIT_SIG_LESS:
inst = BGEZ;
jump->flags |= IS_BIT16_COND;
break;
- case SLJIT_C_SIG_GREATER_EQUAL:
+ case SLJIT_SIG_GREATER_EQUAL:
inst = BLTZ;
jump->flags |= IS_BIT16_COND;
break;
- case SLJIT_C_SIG_GREATER:
+ case SLJIT_SIG_GREATER:
inst = BLEZ;
jump->flags |= IS_BIT26_COND;
break;
- case SLJIT_C_SIG_LESS_EQUAL:
+ case SLJIT_SIG_LESS_EQUAL:
inst = BGTZ;
jump->flags |= IS_BIT26_COND;
break;
@@ -1832,29 +1816,29 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler
PTR_FAIL_IF(push_inst(compiler, inst | S(src1) | JUMP_LENGTH, UNMOVABLE_INS));
}
else {
- if (type == SLJIT_C_LESS || type == SLJIT_C_GREATER_EQUAL || type == SLJIT_C_SIG_LESS || type == SLJIT_C_SIG_GREATER_EQUAL) {
+ if (type == SLJIT_LESS || type == SLJIT_GREATER_EQUAL || type == SLJIT_SIG_LESS || type == SLJIT_SIG_GREATER_EQUAL) {
RESOLVE_IMM1();
if ((src2 & SLJIT_IMM) && src2w <= SIMM_MAX && src2w >= SIMM_MIN)
- PTR_FAIL_IF(push_inst(compiler, (type <= SLJIT_C_LESS_EQUAL ? SLTIU : SLTI) | S(src1) | T(TMP_REG1) | IMM(src2w), DR(TMP_REG1)));
+ PTR_FAIL_IF(push_inst(compiler, (type <= SLJIT_LESS_EQUAL ? SLTIU : SLTI) | S(src1) | T(TMP_REG1) | IMM(src2w), DR(TMP_REG1)));
else {
RESOLVE_IMM2();
- PTR_FAIL_IF(push_inst(compiler, (type <= SLJIT_C_LESS_EQUAL ? SLTU : SLT) | S(src1) | T(src2) | D(TMP_REG1), DR(TMP_REG1)));
+ PTR_FAIL_IF(push_inst(compiler, (type <= SLJIT_LESS_EQUAL ? SLTU : SLT) | S(src1) | T(src2) | D(TMP_REG1), DR(TMP_REG1)));
}
- type = (type == SLJIT_C_LESS || type == SLJIT_C_SIG_LESS) ? SLJIT_C_NOT_EQUAL : SLJIT_C_EQUAL;
+ type = (type == SLJIT_LESS || type == SLJIT_SIG_LESS) ? SLJIT_NOT_EQUAL : SLJIT_EQUAL;
}
else {
RESOLVE_IMM2();
if ((src1 & SLJIT_IMM) && src1w <= SIMM_MAX && src1w >= SIMM_MIN)
- PTR_FAIL_IF(push_inst(compiler, (type <= SLJIT_C_LESS_EQUAL ? SLTIU : SLTI) | S(src2) | T(TMP_REG1) | IMM(src1w), DR(TMP_REG1)));
+ PTR_FAIL_IF(push_inst(compiler, (type <= SLJIT_LESS_EQUAL ? SLTIU : SLTI) | S(src2) | T(TMP_REG1) | IMM(src1w), DR(TMP_REG1)));
else {
RESOLVE_IMM1();
- PTR_FAIL_IF(push_inst(compiler, (type <= SLJIT_C_LESS_EQUAL ? SLTU : SLT) | S(src2) | T(src1) | D(TMP_REG1), DR(TMP_REG1)));
+ PTR_FAIL_IF(push_inst(compiler, (type <= SLJIT_LESS_EQUAL ? SLTU : SLT) | S(src2) | T(src1) | D(TMP_REG1), DR(TMP_REG1)));
}
- type = (type == SLJIT_C_GREATER || type == SLJIT_C_SIG_GREATER) ? SLJIT_C_NOT_EQUAL : SLJIT_C_EQUAL;
+ type = (type == SLJIT_GREATER || type == SLJIT_SIG_GREATER) ? SLJIT_NOT_EQUAL : SLJIT_EQUAL;
}
jump->flags |= IS_BIT26_COND;
- PTR_FAIL_IF(push_inst(compiler, (type == SLJIT_C_EQUAL ? BNE : BEQ) | S(TMP_REG1) | TA(0) | JUMP_LENGTH, UNMOVABLE_INS));
+ PTR_FAIL_IF(push_inst(compiler, (type == SLJIT_EQUAL ? BNE : BEQ) | S(TMP_REG1) | TA(0) | JUMP_LENGTH, UNMOVABLE_INS));
}
PTR_FAIL_IF(emit_const(compiler, TMP_REG2, 0));
@@ -1876,7 +1860,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_fcmp(struct sljit_compile
sljit_si if_true;
CHECK_ERROR_PTR();
- check_sljit_emit_fcmp(compiler, type, src1, src1w, src2, src2w);
+ CHECK_PTR(check_sljit_emit_fcmp(compiler, type, src1, src1w, src2, src2w));
compiler->cache_arg = 0;
compiler->cache_argw = 0;
@@ -1901,36 +1885,37 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_fcmp(struct sljit_compile
jump->flags |= IS_BIT16_COND;
switch (type & 0xff) {
- case SLJIT_C_FLOAT_EQUAL:
+ case SLJIT_D_EQUAL:
inst = C_UEQ_S;
if_true = 1;
break;
- case SLJIT_C_FLOAT_NOT_EQUAL:
+ case SLJIT_D_NOT_EQUAL:
inst = C_UEQ_S;
if_true = 0;
break;
- case SLJIT_C_FLOAT_LESS:
+ case SLJIT_D_LESS:
inst = C_ULT_S;
if_true = 1;
break;
- case SLJIT_C_FLOAT_GREATER_EQUAL:
+ case SLJIT_D_GREATER_EQUAL:
inst = C_ULT_S;
if_true = 0;
break;
- case SLJIT_C_FLOAT_GREATER:
+ case SLJIT_D_GREATER:
inst = C_ULE_S;
if_true = 0;
break;
- case SLJIT_C_FLOAT_LESS_EQUAL:
+ case SLJIT_D_LESS_EQUAL:
inst = C_ULE_S;
if_true = 1;
break;
- case SLJIT_C_FLOAT_UNORDERED:
+ case SLJIT_D_UNORDERED:
inst = C_UN_S;
if_true = 1;
break;
- case SLJIT_C_FLOAT_ORDERED:
default: /* Make compilers happy. */
+ SLJIT_ASSERT_STOP();
+ case SLJIT_D_ORDERED:
inst = C_UN_S;
if_true = 0;
break;
@@ -1961,7 +1946,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_ijump(struct sljit_compiler *compil
struct sljit_jump *jump = NULL;
CHECK_ERROR();
- check_sljit_emit_ijump(compiler, type, src, srcw);
+ CHECK(check_sljit_emit_ijump(compiler, type, src, srcw));
ADJUST_LOCAL_OFFSET(src, srcw);
if (FAST_IS_REG(src)) {
@@ -2027,7 +2012,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
#endif
CHECK_ERROR();
- check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type);
+ CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type));
ADJUST_LOCAL_OFFSET(dst, dstw);
if (dst == SLJIT_UNUSED)
@@ -2049,49 +2034,49 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
srcw = 0;
}
- switch (type) {
- case SLJIT_C_EQUAL:
- case SLJIT_C_NOT_EQUAL:
+ switch (type & 0xff) {
+ case SLJIT_EQUAL:
+ case SLJIT_NOT_EQUAL:
FAIL_IF(push_inst(compiler, SLTIU | SA(EQUAL_FLAG) | TA(sugg_dst_ar) | IMM(1), sugg_dst_ar));
dst_ar = sugg_dst_ar;
break;
- case SLJIT_C_LESS:
- case SLJIT_C_GREATER_EQUAL:
- case SLJIT_C_FLOAT_LESS:
- case SLJIT_C_FLOAT_GREATER_EQUAL:
+ case SLJIT_LESS:
+ case SLJIT_GREATER_EQUAL:
+ case SLJIT_D_LESS:
+ case SLJIT_D_GREATER_EQUAL:
dst_ar = ULESS_FLAG;
break;
- case SLJIT_C_GREATER:
- case SLJIT_C_LESS_EQUAL:
- case SLJIT_C_FLOAT_GREATER:
- case SLJIT_C_FLOAT_LESS_EQUAL:
+ case SLJIT_GREATER:
+ case SLJIT_LESS_EQUAL:
+ case SLJIT_D_GREATER:
+ case SLJIT_D_LESS_EQUAL:
dst_ar = UGREATER_FLAG;
break;
- case SLJIT_C_SIG_LESS:
- case SLJIT_C_SIG_GREATER_EQUAL:
+ case SLJIT_SIG_LESS:
+ case SLJIT_SIG_GREATER_EQUAL:
dst_ar = LESS_FLAG;
break;
- case SLJIT_C_SIG_GREATER:
- case SLJIT_C_SIG_LESS_EQUAL:
+ case SLJIT_SIG_GREATER:
+ case SLJIT_SIG_LESS_EQUAL:
dst_ar = GREATER_FLAG;
break;
- case SLJIT_C_OVERFLOW:
- case SLJIT_C_NOT_OVERFLOW:
+ case SLJIT_OVERFLOW:
+ case SLJIT_NOT_OVERFLOW:
dst_ar = OVERFLOW_FLAG;
break;
- case SLJIT_C_MUL_OVERFLOW:
- case SLJIT_C_MUL_NOT_OVERFLOW:
+ case SLJIT_MUL_OVERFLOW:
+ case SLJIT_MUL_NOT_OVERFLOW:
FAIL_IF(push_inst(compiler, SLTIU | SA(OVERFLOW_FLAG) | TA(sugg_dst_ar) | IMM(1), sugg_dst_ar));
dst_ar = sugg_dst_ar;
type ^= 0x1; /* Flip type bit for the XORI below. */
break;
- case SLJIT_C_FLOAT_EQUAL:
- case SLJIT_C_FLOAT_NOT_EQUAL:
+ case SLJIT_D_EQUAL:
+ case SLJIT_D_NOT_EQUAL:
dst_ar = EQUAL_FLAG;
break;
- case SLJIT_C_FLOAT_UNORDERED:
- case SLJIT_C_FLOAT_ORDERED:
+ case SLJIT_D_UNORDERED:
+ case SLJIT_D_ORDERED:
FAIL_IF(push_inst(compiler, CFC1 | TA(sugg_dst_ar) | DA(FCSR_REG), sugg_dst_ar));
FAIL_IF(push_inst(compiler, SRL | TA(sugg_dst_ar) | DA(sugg_dst_ar) | SH_IMM(23), sugg_dst_ar));
FAIL_IF(push_inst(compiler, ANDI | SA(sugg_dst_ar) | TA(sugg_dst_ar) | IMM(1), sugg_dst_ar));
@@ -2133,7 +2118,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compi
sljit_si reg;
CHECK_ERROR_PTR();
- check_sljit_emit_const(compiler, dst, dstw, init_value);
+ CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value));
ADJUST_LOCAL_OFFSET(dst, dstw);
const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const));
diff --git a/pcre/sljit/sljitNativePPC_common.c b/pcre/sljit/sljitNativePPC_common.c
index 01cb771409b..08d5356f5ae 100644
--- a/pcre/sljit/sljitNativePPC_common.c
+++ b/pcre/sljit/sljitNativePPC_common.c
@@ -329,7 +329,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
struct sljit_const *const_;
CHECK_ERROR_PTR();
- check_sljit_generate_code(compiler);
+ CHECK_PTR(check_sljit_generate_code(compiler));
reverse_buf(compiler);
#if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
@@ -578,16 +578,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
sljit_si i, tmp, offs;
CHECK_ERROR();
- check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- compiler->options = options;
- compiler->scratches = scratches;
- compiler->saveds = saveds;
- compiler->fscratches = fscratches;
- compiler->fsaveds = fsaveds;
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
- compiler->logical_local_size = local_size;
-#endif
+ CHECK(check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
+ set_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
FAIL_IF(push_inst(compiler, MFLR | D(0)));
offs = -(sljit_si)(sizeof(sljit_sw));
@@ -620,7 +612,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
if (args >= 3)
FAIL_IF(push_inst(compiler, OR | S(SLJIT_R2) | A(SLJIT_S2) | B(SLJIT_R2)));
- local_size += GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1) + FIXED_LOCALS_OFFSET;
+ local_size += GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1) + SLJIT_LOCALS_OFFSET;
local_size = (local_size + 15) & ~0xf;
compiler->local_size = local_size;
@@ -643,24 +635,17 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
return SLJIT_SUCCESS;
}
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler,
+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler,
sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
{
- CHECK_ERROR_VOID();
- check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- compiler->options = options;
- compiler->scratches = scratches;
- compiler->saveds = saveds;
- compiler->fscratches = fscratches;
- compiler->fsaveds = fsaveds;
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
- compiler->logical_local_size = local_size;
-#endif
+ CHECK_ERROR();
+ CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
+ set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
- local_size += GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1) + FIXED_LOCALS_OFFSET;
+ local_size += GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1) + SLJIT_LOCALS_OFFSET;
compiler->local_size = (local_size + 15) & ~0xf;
+ return SLJIT_SUCCESS;
}
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
@@ -668,7 +653,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compi
sljit_si i, tmp, offs;
CHECK_ERROR();
- check_sljit_emit_return(compiler, op, src, srcw);
+ CHECK(check_sljit_emit_return(compiler, op, src, srcw));
FAIL_IF(emit_mov_before_return(compiler, op, src, srcw));
@@ -1265,37 +1250,37 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
#endif
CHECK_ERROR();
- check_sljit_emit_op0(compiler, op);
+ CHECK(check_sljit_emit_op0(compiler, op));
op = GET_OPCODE(op);
switch (op) {
case SLJIT_BREAKPOINT:
case SLJIT_NOP:
return push_inst(compiler, NOP);
- case SLJIT_UMUL:
- case SLJIT_SMUL:
+ case SLJIT_LUMUL:
+ case SLJIT_LSMUL:
FAIL_IF(push_inst(compiler, OR | S(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R0)));
#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
FAIL_IF(push_inst(compiler, MULLD | D(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R1)));
- return push_inst(compiler, (op == SLJIT_UMUL ? MULHDU : MULHD) | D(SLJIT_R1) | A(TMP_REG1) | B(SLJIT_R1));
+ return push_inst(compiler, (op == SLJIT_LUMUL ? MULHDU : MULHD) | D(SLJIT_R1) | A(TMP_REG1) | B(SLJIT_R1));
#else
FAIL_IF(push_inst(compiler, MULLW | D(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R1)));
- return push_inst(compiler, (op == SLJIT_UMUL ? MULHWU : MULHW) | D(SLJIT_R1) | A(TMP_REG1) | B(SLJIT_R1));
+ return push_inst(compiler, (op == SLJIT_LUMUL ? MULHWU : MULHW) | D(SLJIT_R1) | A(TMP_REG1) | B(SLJIT_R1));
#endif
- case SLJIT_UDIV:
- case SLJIT_SDIV:
+ case SLJIT_LUDIV:
+ case SLJIT_LSDIV:
FAIL_IF(push_inst(compiler, OR | S(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R0)));
#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
if (int_op) {
- FAIL_IF(push_inst(compiler, (op == SLJIT_UDIV ? DIVWU : DIVW) | D(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R1)));
+ FAIL_IF(push_inst(compiler, (op == SLJIT_LUDIV ? DIVWU : DIVW) | D(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R1)));
FAIL_IF(push_inst(compiler, MULLW | D(SLJIT_R1) | A(SLJIT_R0) | B(SLJIT_R1)));
} else {
- FAIL_IF(push_inst(compiler, (op == SLJIT_UDIV ? DIVDU : DIVD) | D(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R1)));
+ FAIL_IF(push_inst(compiler, (op == SLJIT_LUDIV ? DIVDU : DIVD) | D(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R1)));
FAIL_IF(push_inst(compiler, MULLD | D(SLJIT_R1) | A(SLJIT_R0) | B(SLJIT_R1)));
}
return push_inst(compiler, SUBF | D(SLJIT_R1) | A(SLJIT_R1) | B(TMP_REG1));
#else
- FAIL_IF(push_inst(compiler, (op == SLJIT_UDIV ? DIVWU : DIVW) | D(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R1)));
+ FAIL_IF(push_inst(compiler, (op == SLJIT_LUDIV ? DIVWU : DIVW) | D(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R1)));
FAIL_IF(push_inst(compiler, MULLW | D(SLJIT_R1) | A(SLJIT_R0) | B(SLJIT_R1)));
return push_inst(compiler, SUBF | D(SLJIT_R1) | A(SLJIT_R1) | B(TMP_REG1));
#endif
@@ -1315,7 +1300,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler
sljit_si op_flags = GET_ALL_FLAGS(op);
CHECK_ERROR();
- check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw);
+ CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src, srcw);
@@ -1470,7 +1455,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler
sljit_si flags = GET_FLAGS(op) ? ALT_SET_FLAGS : 0;
CHECK_ERROR();
- check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
+ CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src1, src1w);
ADJUST_LOCAL_OFFSET(src2, src2w);
@@ -1672,13 +1657,13 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_register_index(sljit_si reg)
{
- check_sljit_get_register_index(reg);
+ CHECK_REG_INDEX(check_sljit_get_register_index(reg));
return reg_map[reg];
}
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_float_register_index(sljit_si reg)
{
- check_sljit_get_float_register_index(reg);
+ CHECK_REG_INDEX(check_sljit_get_float_register_index(reg));
return reg;
}
@@ -1686,8 +1671,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *co
void *instruction, sljit_si size)
{
CHECK_ERROR();
- check_sljit_emit_op_custom(compiler, instruction, size);
- SLJIT_ASSERT(size == 4);
+ CHECK(check_sljit_emit_op_custom(compiler, instruction, size));
return push_inst(compiler, *(sljit_ins*)instruction);
}
@@ -1918,7 +1902,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compile
break;
}
/* Fall through. */
- case SLJIT_MOVD:
+ case SLJIT_DMOV:
if (src != dst_r) {
if (dst_r != TMP_FREG1)
FAIL_IF(push_inst(compiler, FMR | FD(dst_r) | FB(src)));
@@ -1926,10 +1910,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compile
dst_r = src;
}
break;
- case SLJIT_NEGD:
+ case SLJIT_DNEG:
FAIL_IF(push_inst(compiler, FNEG | FD(dst_r) | FB(src)));
break;
- case SLJIT_ABSD:
+ case SLJIT_DABS:
FAIL_IF(push_inst(compiler, FABS | FD(dst_r) | FB(src)));
break;
}
@@ -1947,7 +1931,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
sljit_si dst_r, flags = 0;
CHECK_ERROR();
- check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
+ CHECK(check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src1, src1w);
ADJUST_LOCAL_OFFSET(src2, src2w);
@@ -1994,19 +1978,19 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
src2 = TMP_FREG2;
switch (GET_OPCODE(op)) {
- case SLJIT_ADDD:
+ case SLJIT_DADD:
FAIL_IF(push_inst(compiler, SELECT_FOP(op, FADDS, FADD) | FD(dst_r) | FA(src1) | FB(src2)));
break;
- case SLJIT_SUBD:
+ case SLJIT_DSUB:
FAIL_IF(push_inst(compiler, SELECT_FOP(op, FSUBS, FSUB) | FD(dst_r) | FA(src1) | FB(src2)));
break;
- case SLJIT_MULD:
+ case SLJIT_DMUL:
FAIL_IF(push_inst(compiler, SELECT_FOP(op, FMULS, FMUL) | FD(dst_r) | FA(src1) | FC(src2) /* FMUL use FC as src2 */));
break;
- case SLJIT_DIVD:
+ case SLJIT_DDIV:
FAIL_IF(push_inst(compiler, SELECT_FOP(op, FDIVS, FDIV) | FD(dst_r) | FA(src1) | FB(src2)));
break;
}
@@ -2027,7 +2011,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw)
{
CHECK_ERROR();
- check_sljit_emit_fast_enter(compiler, dst, dstw);
+ CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw));
ADJUST_LOCAL_OFFSET(dst, dstw);
/* For UNUSED dst. Uncommon, but possible. */
@@ -2045,7 +2029,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *c
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw)
{
CHECK_ERROR();
- check_sljit_emit_fast_return(compiler, src, srcw);
+ CHECK(check_sljit_emit_fast_return(compiler, src, srcw));
ADJUST_LOCAL_OFFSET(src, srcw);
if (FAST_IS_REG(src))
@@ -2069,7 +2053,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compi
struct sljit_label *label;
CHECK_ERROR_PTR();
- check_sljit_emit_label(compiler);
+ CHECK_PTR(check_sljit_emit_label(compiler));
if (compiler->last_label && compiler->last_label->size == compiler->size)
return compiler->last_label;
@@ -2083,58 +2067,58 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compi
static sljit_ins get_bo_bi_flags(sljit_si type)
{
switch (type) {
- case SLJIT_C_EQUAL:
+ case SLJIT_EQUAL:
return (12 << 21) | (2 << 16);
- case SLJIT_C_NOT_EQUAL:
+ case SLJIT_NOT_EQUAL:
return (4 << 21) | (2 << 16);
- case SLJIT_C_LESS:
- case SLJIT_C_FLOAT_LESS:
+ case SLJIT_LESS:
+ case SLJIT_D_LESS:
return (12 << 21) | ((4 + 0) << 16);
- case SLJIT_C_GREATER_EQUAL:
- case SLJIT_C_FLOAT_GREATER_EQUAL:
+ case SLJIT_GREATER_EQUAL:
+ case SLJIT_D_GREATER_EQUAL:
return (4 << 21) | ((4 + 0) << 16);
- case SLJIT_C_GREATER:
- case SLJIT_C_FLOAT_GREATER:
+ case SLJIT_GREATER:
+ case SLJIT_D_GREATER:
return (12 << 21) | ((4 + 1) << 16);
- case SLJIT_C_LESS_EQUAL:
- case SLJIT_C_FLOAT_LESS_EQUAL:
+ case SLJIT_LESS_EQUAL:
+ case SLJIT_D_LESS_EQUAL:
return (4 << 21) | ((4 + 1) << 16);
- case SLJIT_C_SIG_LESS:
+ case SLJIT_SIG_LESS:
return (12 << 21) | (0 << 16);
- case SLJIT_C_SIG_GREATER_EQUAL:
+ case SLJIT_SIG_GREATER_EQUAL:
return (4 << 21) | (0 << 16);
- case SLJIT_C_SIG_GREATER:
+ case SLJIT_SIG_GREATER:
return (12 << 21) | (1 << 16);
- case SLJIT_C_SIG_LESS_EQUAL:
+ case SLJIT_SIG_LESS_EQUAL:
return (4 << 21) | (1 << 16);
- case SLJIT_C_OVERFLOW:
- case SLJIT_C_MUL_OVERFLOW:
+ case SLJIT_OVERFLOW:
+ case SLJIT_MUL_OVERFLOW:
return (12 << 21) | (3 << 16);
- case SLJIT_C_NOT_OVERFLOW:
- case SLJIT_C_MUL_NOT_OVERFLOW:
+ case SLJIT_NOT_OVERFLOW:
+ case SLJIT_MUL_NOT_OVERFLOW:
return (4 << 21) | (3 << 16);
- case SLJIT_C_FLOAT_EQUAL:
+ case SLJIT_D_EQUAL:
return (12 << 21) | ((4 + 2) << 16);
- case SLJIT_C_FLOAT_NOT_EQUAL:
+ case SLJIT_D_NOT_EQUAL:
return (4 << 21) | ((4 + 2) << 16);
- case SLJIT_C_FLOAT_UNORDERED:
+ case SLJIT_D_UNORDERED:
return (12 << 21) | ((4 + 3) << 16);
- case SLJIT_C_FLOAT_ORDERED:
+ case SLJIT_D_ORDERED:
return (4 << 21) | ((4 + 3) << 16);
default:
@@ -2149,7 +2133,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile
sljit_ins bo_bi_flags;
CHECK_ERROR_PTR();
- check_sljit_emit_jump(compiler, type);
+ CHECK_PTR(check_sljit_emit_jump(compiler, type));
bo_bi_flags = get_bo_bi_flags(type & 0xff);
if (!bo_bi_flags)
@@ -2181,7 +2165,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_ijump(struct sljit_compiler *compil
sljit_si src_r;
CHECK_ERROR();
- check_sljit_emit_ijump(compiler, type, src, srcw);
+ CHECK(check_sljit_emit_ijump(compiler, type, src, srcw));
ADJUST_LOCAL_OFFSET(src, srcw);
if (FAST_IS_REG(src)) {
@@ -2236,7 +2220,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
sljit_sw original_dstw = dstw;
CHECK_ERROR();
- check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type);
+ CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type));
ADJUST_LOCAL_OFFSET(dst, dstw);
if (dst == SLJIT_UNUSED)
@@ -2259,81 +2243,81 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
srcw = 0;
}
- switch (type) {
- case SLJIT_C_EQUAL:
+ switch (type & 0xff) {
+ case SLJIT_EQUAL:
GET_CR_BIT(2, reg);
break;
- case SLJIT_C_NOT_EQUAL:
+ case SLJIT_NOT_EQUAL:
GET_CR_BIT(2, reg);
INVERT_BIT(reg);
break;
- case SLJIT_C_LESS:
- case SLJIT_C_FLOAT_LESS:
+ case SLJIT_LESS:
+ case SLJIT_D_LESS:
GET_CR_BIT(4 + 0, reg);
break;
- case SLJIT_C_GREATER_EQUAL:
- case SLJIT_C_FLOAT_GREATER_EQUAL:
+ case SLJIT_GREATER_EQUAL:
+ case SLJIT_D_GREATER_EQUAL:
GET_CR_BIT(4 + 0, reg);
INVERT_BIT(reg);
break;
- case SLJIT_C_GREATER:
- case SLJIT_C_FLOAT_GREATER:
+ case SLJIT_GREATER:
+ case SLJIT_D_GREATER:
GET_CR_BIT(4 + 1, reg);
break;
- case SLJIT_C_LESS_EQUAL:
- case SLJIT_C_FLOAT_LESS_EQUAL:
+ case SLJIT_LESS_EQUAL:
+ case SLJIT_D_LESS_EQUAL:
GET_CR_BIT(4 + 1, reg);
INVERT_BIT(reg);
break;
- case SLJIT_C_SIG_LESS:
+ case SLJIT_SIG_LESS:
GET_CR_BIT(0, reg);
break;
- case SLJIT_C_SIG_GREATER_EQUAL:
+ case SLJIT_SIG_GREATER_EQUAL:
GET_CR_BIT(0, reg);
INVERT_BIT(reg);
break;
- case SLJIT_C_SIG_GREATER:
+ case SLJIT_SIG_GREATER:
GET_CR_BIT(1, reg);
break;
- case SLJIT_C_SIG_LESS_EQUAL:
+ case SLJIT_SIG_LESS_EQUAL:
GET_CR_BIT(1, reg);
INVERT_BIT(reg);
break;
- case SLJIT_C_OVERFLOW:
- case SLJIT_C_MUL_OVERFLOW:
+ case SLJIT_OVERFLOW:
+ case SLJIT_MUL_OVERFLOW:
GET_CR_BIT(3, reg);
break;
- case SLJIT_C_NOT_OVERFLOW:
- case SLJIT_C_MUL_NOT_OVERFLOW:
+ case SLJIT_NOT_OVERFLOW:
+ case SLJIT_MUL_NOT_OVERFLOW:
GET_CR_BIT(3, reg);
INVERT_BIT(reg);
break;
- case SLJIT_C_FLOAT_EQUAL:
+ case SLJIT_D_EQUAL:
GET_CR_BIT(4 + 2, reg);
break;
- case SLJIT_C_FLOAT_NOT_EQUAL:
+ case SLJIT_D_NOT_EQUAL:
GET_CR_BIT(4 + 2, reg);
INVERT_BIT(reg);
break;
- case SLJIT_C_FLOAT_UNORDERED:
+ case SLJIT_D_UNORDERED:
GET_CR_BIT(4 + 3, reg);
break;
- case SLJIT_C_FLOAT_ORDERED:
+ case SLJIT_D_ORDERED:
GET_CR_BIT(4 + 3, reg);
INVERT_BIT(reg);
break;
@@ -2360,7 +2344,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
return emit_op(compiler, op, input_flags, dst, dstw, TMP_REG1, 0, TMP_REG2, 0);
}
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
+ || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
compiler->skip_checks = 1;
#endif
return sljit_emit_op2(compiler, op | flags, dst, original_dstw, src, srcw, TMP_REG2, 0);
@@ -2372,7 +2357,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compi
sljit_si reg;
CHECK_ERROR_PTR();
- check_sljit_emit_const(compiler, dst, dstw, init_value);
+ CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value));
ADJUST_LOCAL_OFFSET(dst, dstw);
const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const));
diff --git a/pcre/sljit/sljitNativeSPARC_common.c b/pcre/sljit/sljitNativeSPARC_common.c
index 8926a606260..0b1927a8245 100644
--- a/pcre/sljit/sljitNativeSPARC_common.c
+++ b/pcre/sljit/sljitNativeSPARC_common.c
@@ -283,7 +283,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
struct sljit_const *const_;
CHECK_ERROR_PTR();
- check_sljit_generate_code(compiler);
+ CHECK_PTR(check_sljit_generate_code(compiler));
reverse_buf(compiler);
code = (sljit_ins*)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_ins));
@@ -423,18 +423,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
{
CHECK_ERROR();
- check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- compiler->options = options;
- compiler->scratches = scratches;
- compiler->saveds = saveds;
- compiler->fscratches = fscratches;
- compiler->fsaveds = fsaveds;
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
- compiler->logical_local_size = local_size;
-#endif
+ CHECK(check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
+ set_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
- local_size = (local_size + FIXED_LOCALS_OFFSET + 7) & ~0x7;
+ local_size = (local_size + SLJIT_LOCALS_OFFSET + 7) & ~0x7;
compiler->local_size = local_size;
if (local_size <= SIMM_MAX) {
@@ -450,29 +442,22 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
return SLJIT_SUCCESS;
}
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler,
+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler,
sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
{
- CHECK_ERROR_VOID();
- check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- compiler->options = options;
- compiler->scratches = scratches;
- compiler->saveds = saveds;
- compiler->fscratches = fscratches;
- compiler->fsaveds = fsaveds;
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
- compiler->logical_local_size = local_size;
-#endif
+ CHECK_ERROR();
+ CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
+ set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
- compiler->local_size = (local_size + FIXED_LOCALS_OFFSET + 7) & ~0x7;
+ compiler->local_size = (local_size + SLJIT_LOCALS_OFFSET + 7) & ~0x7;
+ return SLJIT_SUCCESS;
}
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
{
CHECK_ERROR();
- check_sljit_emit_return(compiler, op, src, srcw);
+ CHECK(check_sljit_emit_return(compiler, op, src, srcw));
if (op != SLJIT_MOV || !FAST_IS_REG(src)) {
FAIL_IF(emit_mov_before_return(compiler, op, src, srcw));
@@ -776,7 +761,7 @@ static sljit_si emit_op(struct sljit_compiler *compiler, sljit_si op, sljit_si f
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op)
{
CHECK_ERROR();
- check_sljit_emit_op0(compiler, op);
+ CHECK(check_sljit_emit_op0(compiler, op));
op = GET_OPCODE(op);
switch (op) {
@@ -784,25 +769,25 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
return push_inst(compiler, TA, UNMOVABLE_INS);
case SLJIT_NOP:
return push_inst(compiler, NOP, UNMOVABLE_INS);
- case SLJIT_UMUL:
- case SLJIT_SMUL:
+ case SLJIT_LUMUL:
+ case SLJIT_LSMUL:
#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
- FAIL_IF(push_inst(compiler, (op == SLJIT_UMUL ? UMUL : SMUL) | D(SLJIT_R0) | S1(SLJIT_R0) | S2(SLJIT_R1), DR(SLJIT_R0)));
+ FAIL_IF(push_inst(compiler, (op == SLJIT_LUMUL ? UMUL : SMUL) | D(SLJIT_R0) | S1(SLJIT_R0) | S2(SLJIT_R1), DR(SLJIT_R0)));
return push_inst(compiler, RDY | D(SLJIT_R1), DR(SLJIT_R1));
#else
#error "Implementation required"
#endif
- case SLJIT_UDIV:
- case SLJIT_SDIV:
+ case SLJIT_LUDIV:
+ case SLJIT_LSDIV:
#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
- if (op == SLJIT_UDIV)
+ if (op == SLJIT_LUDIV)
FAIL_IF(push_inst(compiler, WRY | S1(0), MOVABLE_INS));
else {
FAIL_IF(push_inst(compiler, SRA | D(TMP_REG1) | S1(SLJIT_R0) | IMM(31), DR(TMP_REG1)));
FAIL_IF(push_inst(compiler, WRY | S1(TMP_REG1), MOVABLE_INS));
}
FAIL_IF(push_inst(compiler, OR | D(TMP_REG2) | S1(0) | S2(SLJIT_R0), DR(TMP_REG2)));
- FAIL_IF(push_inst(compiler, (op == SLJIT_UDIV ? UDIV : SDIV) | D(SLJIT_R0) | S1(SLJIT_R0) | S2(SLJIT_R1), DR(SLJIT_R0)));
+ FAIL_IF(push_inst(compiler, (op == SLJIT_LUDIV ? UDIV : SDIV) | D(SLJIT_R0) | S1(SLJIT_R0) | S2(SLJIT_R1), DR(SLJIT_R0)));
FAIL_IF(push_inst(compiler, SMUL | D(SLJIT_R1) | S1(SLJIT_R0) | S2(SLJIT_R1), DR(SLJIT_R1)));
FAIL_IF(push_inst(compiler, SUB | D(SLJIT_R1) | S1(TMP_REG2) | S2(SLJIT_R1), DR(SLJIT_R1)));
return SLJIT_SUCCESS;
@@ -821,7 +806,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler
sljit_si flags = GET_FLAGS(op) ? SET_FLAGS : 0;
CHECK_ERROR();
- check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw);
+ CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src, srcw);
@@ -890,7 +875,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler
sljit_si flags = GET_FLAGS(op) ? SET_FLAGS : 0;
CHECK_ERROR();
- check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
+ CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src1, src1w);
ADJUST_LOCAL_OFFSET(src2, src2w);
@@ -926,13 +911,13 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_register_index(sljit_si reg)
{
- check_sljit_get_register_index(reg);
+ CHECK_REG_INDEX(check_sljit_get_register_index(reg));
return reg_map[reg];
}
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_float_register_index(sljit_si reg)
{
- check_sljit_get_float_register_index(reg);
+ CHECK_REG_INDEX(check_sljit_get_float_register_index(reg));
return reg << 1;
}
@@ -940,8 +925,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *co
void *instruction, sljit_si size)
{
CHECK_ERROR();
- check_sljit_emit_op_custom(compiler, instruction, size);
- SLJIT_ASSERT(size == 4);
+ CHECK(check_sljit_emit_op_custom(compiler, instruction, size));
return push_inst(compiler, *(sljit_ins*)instruction, UNMOVABLE_INS);
}
@@ -1066,7 +1050,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compile
src <<= 1;
switch (GET_OPCODE(op)) {
- case SLJIT_MOVD:
+ case SLJIT_DMOV:
if (src != dst_r) {
if (dst_r != TMP_FREG1) {
FAIL_IF(push_inst(compiler, FMOVS | DA(dst_r) | S2A(src), MOVABLE_INS));
@@ -1077,12 +1061,12 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compile
dst_r = src;
}
break;
- case SLJIT_NEGD:
+ case SLJIT_DNEG:
FAIL_IF(push_inst(compiler, FNEGS | DA(dst_r) | S2A(src), MOVABLE_INS));
if (dst_r != src && !(op & SLJIT_SINGLE_OP))
FAIL_IF(push_inst(compiler, FMOVS | DA(dst_r | 1) | S2A(src | 1), MOVABLE_INS));
break;
- case SLJIT_ABSD:
+ case SLJIT_DABS:
FAIL_IF(push_inst(compiler, FABSS | DA(dst_r) | S2A(src), MOVABLE_INS));
if (dst_r != src && !(op & SLJIT_SINGLE_OP))
FAIL_IF(push_inst(compiler, FMOVS | DA(dst_r | 1) | S2A(src | 1), MOVABLE_INS));
@@ -1106,7 +1090,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
sljit_si dst_r, flags = 0;
CHECK_ERROR();
- check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
+ CHECK(check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src1, src1w);
ADJUST_LOCAL_OFFSET(src2, src2w);
@@ -1157,19 +1141,19 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
src2 = TMP_FREG2;
switch (GET_OPCODE(op)) {
- case SLJIT_ADDD:
+ case SLJIT_DADD:
FAIL_IF(push_inst(compiler, SELECT_FOP(op, FADDS, FADDD) | DA(dst_r) | S1A(src1) | S2A(src2), MOVABLE_INS));
break;
- case SLJIT_SUBD:
+ case SLJIT_DSUB:
FAIL_IF(push_inst(compiler, SELECT_FOP(op, FSUBS, FSUBD) | DA(dst_r) | S1A(src1) | S2A(src2), MOVABLE_INS));
break;
- case SLJIT_MULD:
+ case SLJIT_DMUL:
FAIL_IF(push_inst(compiler, SELECT_FOP(op, FMULS, FMULD) | DA(dst_r) | S1A(src1) | S2A(src2), MOVABLE_INS));
break;
- case SLJIT_DIVD:
+ case SLJIT_DDIV:
FAIL_IF(push_inst(compiler, SELECT_FOP(op, FDIVS, FDIVD) | DA(dst_r) | S1A(src1) | S2A(src2), MOVABLE_INS));
break;
}
@@ -1190,7 +1174,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw)
{
CHECK_ERROR();
- check_sljit_emit_fast_enter(compiler, dst, dstw);
+ CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw));
ADJUST_LOCAL_OFFSET(dst, dstw);
/* For UNUSED dst. Uncommon, but possible. */
@@ -1207,7 +1191,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *c
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw)
{
CHECK_ERROR();
- check_sljit_emit_fast_return(compiler, src, srcw);
+ CHECK(check_sljit_emit_fast_return(compiler, src, srcw));
ADJUST_LOCAL_OFFSET(src, srcw);
if (FAST_IS_REG(src))
@@ -1230,7 +1214,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compi
struct sljit_label *label;
CHECK_ERROR_PTR();
- check_sljit_emit_label(compiler);
+ CHECK_PTR(check_sljit_emit_label(compiler));
if (compiler->last_label && compiler->last_label->size == compiler->size)
return compiler->last_label;
@@ -1245,66 +1229,50 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compi
static sljit_ins get_cc(sljit_si type)
{
switch (type) {
- case SLJIT_C_EQUAL:
- case SLJIT_C_MUL_NOT_OVERFLOW:
+ case SLJIT_EQUAL:
+ case SLJIT_MUL_NOT_OVERFLOW:
+ case SLJIT_D_NOT_EQUAL: /* Unordered. */
return DA(0x1);
- case SLJIT_C_NOT_EQUAL:
- case SLJIT_C_MUL_OVERFLOW:
+ case SLJIT_NOT_EQUAL:
+ case SLJIT_MUL_OVERFLOW:
+ case SLJIT_D_EQUAL:
return DA(0x9);
- case SLJIT_C_LESS:
+ case SLJIT_LESS:
+ case SLJIT_D_GREATER: /* Unordered. */
return DA(0x5);
- case SLJIT_C_GREATER_EQUAL:
+ case SLJIT_GREATER_EQUAL:
+ case SLJIT_D_LESS_EQUAL:
return DA(0xd);
- case SLJIT_C_GREATER:
+ case SLJIT_GREATER:
+ case SLJIT_D_GREATER_EQUAL: /* Unordered. */
return DA(0xc);
- case SLJIT_C_LESS_EQUAL:
+ case SLJIT_LESS_EQUAL:
+ case SLJIT_D_LESS:
return DA(0x4);
- case SLJIT_C_SIG_LESS:
+ case SLJIT_SIG_LESS:
return DA(0x3);
- case SLJIT_C_SIG_GREATER_EQUAL:
+ case SLJIT_SIG_GREATER_EQUAL:
return DA(0xb);
- case SLJIT_C_SIG_GREATER:
+ case SLJIT_SIG_GREATER:
return DA(0xa);
- case SLJIT_C_SIG_LESS_EQUAL:
+ case SLJIT_SIG_LESS_EQUAL:
return DA(0x2);
- case SLJIT_C_OVERFLOW:
+ case SLJIT_OVERFLOW:
+ case SLJIT_D_UNORDERED:
return DA(0x7);
- case SLJIT_C_NOT_OVERFLOW:
- return DA(0xf);
-
- case SLJIT_C_FLOAT_EQUAL:
- return DA(0x9);
-
- case SLJIT_C_FLOAT_NOT_EQUAL: /* Unordered. */
- return DA(0x1);
-
- case SLJIT_C_FLOAT_LESS:
- return DA(0x4);
-
- case SLJIT_C_FLOAT_GREATER_EQUAL: /* Unordered. */
- return DA(0xc);
-
- case SLJIT_C_FLOAT_LESS_EQUAL:
- return DA(0xd);
-
- case SLJIT_C_FLOAT_GREATER: /* Unordered. */
- return DA(0x5);
-
- case SLJIT_C_FLOAT_UNORDERED:
- return DA(0x7);
-
- case SLJIT_C_FLOAT_ORDERED:
+ case SLJIT_NOT_OVERFLOW:
+ case SLJIT_D_ORDERED:
return DA(0xf);
default:
@@ -1318,14 +1286,14 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile
struct sljit_jump *jump;
CHECK_ERROR_PTR();
- check_sljit_emit_jump(compiler, type);
+ CHECK_PTR(check_sljit_emit_jump(compiler, type));
jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
PTR_FAIL_IF(!jump);
set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP);
type &= 0xff;
- if (type < SLJIT_C_FLOAT_EQUAL) {
+ if (type < SLJIT_D_EQUAL) {
jump->flags |= IS_COND;
if (((compiler->delay_slot & DST_INS_MASK) != UNMOVABLE_INS) && !(compiler->delay_slot & ICC_IS_SET))
jump->flags |= IS_MOVABLE;
@@ -1365,7 +1333,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_ijump(struct sljit_compiler *compil
sljit_si src_r;
CHECK_ERROR();
- check_sljit_emit_ijump(compiler, type, src, srcw);
+ CHECK(check_sljit_emit_ijump(compiler, type, src, srcw));
ADJUST_LOCAL_OFFSET(src, srcw);
if (FAST_IS_REG(src))
@@ -1402,7 +1370,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
sljit_si reg, flags = (GET_FLAGS(op) ? SET_FLAGS : 0);
CHECK_ERROR();
- check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type);
+ CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type));
ADJUST_LOCAL_OFFSET(dst, dstw);
if (dst == SLJIT_UNUSED)
@@ -1421,7 +1389,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
srcw = 0;
}
- if (type < SLJIT_C_FLOAT_EQUAL)
+ type &= 0xff;
+ if (type < SLJIT_D_EQUAL)
FAIL_IF(push_inst(compiler, BICC | get_cc(type) | 3, UNMOVABLE_INS));
else
FAIL_IF(push_inst(compiler, FBFCC | get_cc(type) | 3, UNMOVABLE_INS));
@@ -1444,7 +1413,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compi
struct sljit_const *const_;
CHECK_ERROR_PTR();
- check_sljit_emit_const(compiler, dst, dstw, init_value);
+ CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value));
ADJUST_LOCAL_OFFSET(dst, dstw);
const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const));
diff --git a/pcre/sljit/sljitNativeTILEGX_64.c b/pcre/sljit/sljitNativeTILEGX_64.c
index fb4cd383b5f..1d6aa5a110f 100644
--- a/pcre/sljit/sljitNativeTILEGX_64.c
+++ b/pcre/sljit/sljitNativeTILEGX_64.c
@@ -1182,15 +1182,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
CHECK_ERROR();
check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- compiler->options = options;
- compiler->scratches = scratches;
- compiler->saveds = saveds;
- compiler->fscratches = fscratches;
- compiler->fsaveds = fsaveds;
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
- compiler->logical_local_size = local_size;
-#endif
+ set_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
local_size += (saveds + 1) * sizeof(sljit_sw);
local_size = (local_size + 7) & ~7;
@@ -1244,15 +1236,7 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler,
{
CHECK_ERROR_VOID();
check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- compiler->options = options;
- compiler->scratches = scratches;
- compiler->saveds = saveds;
- compiler->fscratches = fscratches;
- compiler->fsaveds = fsaveds;
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
- compiler->logical_local_size = local_size;
-#endif
+ set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
local_size += (saveds + 1) * sizeof(sljit_sw);
compiler->local_size = (local_size + 7) & ~7;
diff --git a/pcre/sljit/sljitNativeX86_32.c b/pcre/sljit/sljitNativeX86_32.c
index 515bf7e746d..d7129c8e26d 100644
--- a/pcre/sljit/sljitNativeX86_32.c
+++ b/pcre/sljit/sljitNativeX86_32.c
@@ -71,18 +71,11 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
sljit_ub *inst;
CHECK_ERROR();
- check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
+ CHECK(check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
+ set_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
- compiler->options = options;
- compiler->scratches = scratches;
- compiler->saveds = saveds;
- compiler->fscratches = fscratches;
- compiler->fsaveds = fsaveds;
compiler->args = args;
compiler->flags_saved = 0;
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
- compiler->logical_local_size = local_size;
-#endif
size = 1 + (scratches > 7 ? (scratches - 7) : 0) + (saveds <= 3 ? saveds : 3);
#if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
@@ -141,14 +134,33 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
}
#endif
- SLJIT_COMPILE_ASSERT(FIXED_LOCALS_OFFSET >= (2 + 4) * sizeof(sljit_uw), require_at_least_two_words);
+ SLJIT_COMPILE_ASSERT(SLJIT_LOCALS_OFFSET >= (2 + 4) * sizeof(sljit_uw), require_at_least_two_words);
#if defined(__APPLE__)
- /* Ignore pushed registers and FIXED_LOCALS_OFFSET when
- computing the aligned local size. */
+ /* Ignore pushed registers and SLJIT_LOCALS_OFFSET when computing the aligned local size. */
saveds = (2 + (scratches > 7 ? (scratches - 7) : 0) + (saveds <= 3 ? saveds : 3)) * sizeof(sljit_uw);
- local_size = ((FIXED_LOCALS_OFFSET + saveds + local_size + 15) & ~15) - saveds;
+ local_size = ((SLJIT_LOCALS_OFFSET + saveds + local_size + 15) & ~15) - saveds;
#else
- local_size = FIXED_LOCALS_OFFSET + ((local_size + sizeof(sljit_uw) - 1) & ~(sizeof(sljit_uw) - 1));
+ if (options & SLJIT_DOUBLE_ALIGNMENT) {
+ local_size = SLJIT_LOCALS_OFFSET + ((local_size + 7) & ~7);
+
+ inst = (sljit_ub*)ensure_buf(compiler, 1 + 17);
+ FAIL_IF(!inst);
+
+ INC_SIZE(17);
+ inst[0] = MOV_r_rm;
+ inst[1] = MOD_REG | (reg_map[TMP_REG1] << 3) | reg_map[SLJIT_SP];
+ inst[2] = GROUP_F7;
+ inst[3] = MOD_REG | (0 << 3) | reg_map[SLJIT_SP];
+ *(sljit_sw*)(inst + 4) = 0x4;
+ inst[8] = JNE_i8;
+ inst[9] = 6;
+ inst[10] = GROUP_BINARY_81;
+ inst[11] = MOD_REG | (5 << 3) | reg_map[SLJIT_SP];
+ *(sljit_sw*)(inst + 12) = 0x4;
+ inst[16] = PUSH_r + reg_map[TMP_REG1];
+ }
+ else
+ local_size = SLJIT_LOCALS_OFFSET + ((local_size + 3) & ~3);
#endif
compiler->local_size = local_size;
@@ -157,10 +169,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
#if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
FAIL_IF(emit_do_imm(compiler, MOV_r_i32 + reg_map[SLJIT_R0], local_size));
#else
- local_size -= FIXED_LOCALS_OFFSET;
+ local_size -= SLJIT_LOCALS_OFFSET;
FAIL_IF(emit_do_imm(compiler, MOV_r_i32 + reg_map[SLJIT_R0], local_size));
FAIL_IF(emit_non_cum_binary(compiler, SUB_r_rm, SUB_rm_r, SUB, SUB_EAX_i32,
- SLJIT_SP, 0, SLJIT_SP, 0, SLJIT_IMM, FIXED_LOCALS_OFFSET));
+ SLJIT_SP, 0, SLJIT_SP, 0, SLJIT_IMM, SLJIT_LOCALS_OFFSET));
#endif
FAIL_IF(sljit_emit_ijump(compiler, SLJIT_CALL1, SLJIT_IMM, SLJIT_FUNC_OFFSET(sljit_grow_stack)));
}
@@ -171,29 +183,26 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
SLJIT_SP, 0, SLJIT_SP, 0, SLJIT_IMM, local_size);
}
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler,
+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler,
sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
{
- CHECK_ERROR_VOID();
- check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- compiler->options = options;
- compiler->scratches = scratches;
- compiler->saveds = saveds;
- compiler->fscratches = fscratches;
- compiler->fsaveds = fsaveds;
+ CHECK_ERROR();
+ CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
+ set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
+
compiler->args = args;
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
- compiler->logical_local_size = local_size;
-#endif
#if defined(__APPLE__)
saveds = (2 + (scratches > 7 ? (scratches - 7) : 0) + (saveds <= 3 ? saveds : 3)) * sizeof(sljit_uw);
- compiler->local_size = ((FIXED_LOCALS_OFFSET + saveds + local_size + 15) & ~15) - saveds;
+ compiler->local_size = ((SLJIT_LOCALS_OFFSET + saveds + local_size + 15) & ~15) - saveds;
#else
- compiler->local_size = FIXED_LOCALS_OFFSET + ((local_size + sizeof(sljit_uw) - 1) & ~(sizeof(sljit_uw) - 1));
+ if (options & SLJIT_DOUBLE_ALIGNMENT)
+ compiler->local_size = SLJIT_LOCALS_OFFSET + ((local_size + 7) & ~7);
+ else
+ compiler->local_size = SLJIT_LOCALS_OFFSET + ((local_size + 3) & ~3);
#endif
+ return SLJIT_SUCCESS;
}
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
@@ -202,7 +211,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compi
sljit_ub *inst;
CHECK_ERROR();
- check_sljit_emit_return(compiler, op, src, srcw);
+ CHECK(check_sljit_emit_return(compiler, op, src, srcw));
SLJIT_ASSERT(compiler->args >= 0);
compiler->flags_saved = 0;
@@ -212,6 +221,18 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compi
FAIL_IF(emit_cum_binary(compiler, ADD_r_rm, ADD_rm_r, ADD, ADD_EAX_i32,
SLJIT_SP, 0, SLJIT_SP, 0, SLJIT_IMM, compiler->local_size));
+#if !defined(__APPLE__)
+ if (compiler->options & SLJIT_DOUBLE_ALIGNMENT) {
+ inst = (sljit_ub*)ensure_buf(compiler, 1 + 3);
+ FAIL_IF(!inst);
+
+ INC_SIZE(3);
+ inst[0] = MOV_r_rm;
+ inst[1] = (reg_map[SLJIT_SP] << 3) | 0x4 /* SIB */;
+ inst[2] = (4 << 3) | reg_map[SLJIT_SP];
+ }
+#endif
+
size = 2 + (compiler->scratches > 7 ? (compiler->scratches - 7) : 0) +
(compiler->saveds <= 3 ? compiler->saveds : 3);
#if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
@@ -460,7 +481,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *c
sljit_ub *inst;
CHECK_ERROR();
- check_sljit_emit_fast_enter(compiler, dst, dstw);
+ CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw));
ADJUST_LOCAL_OFFSET(dst, dstw);
CHECK_EXTRA_REGS(dst, dstw, (void)0);
@@ -491,7 +512,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *
sljit_ub *inst;
CHECK_ERROR();
- check_sljit_emit_fast_return(compiler, src, srcw);
+ CHECK(check_sljit_emit_fast_return(compiler, src, srcw));
ADJUST_LOCAL_OFFSET(src, srcw);
CHECK_EXTRA_REGS(src, srcw, (void)0);
diff --git a/pcre/sljit/sljitNativeX86_64.c b/pcre/sljit/sljitNativeX86_64.c
index f356f1c39c6..1790d8a4d0a 100644
--- a/pcre/sljit/sljitNativeX86_64.c
+++ b/pcre/sljit/sljitNativeX86_64.c
@@ -95,17 +95,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
sljit_ub *inst;
CHECK_ERROR();
- check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
+ CHECK(check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
+ set_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
- compiler->options = options;
- compiler->scratches = scratches;
- compiler->saveds = saveds;
- compiler->fscratches = fscratches;
- compiler->fsaveds = fsaveds;
compiler->flags_saved = 0;
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
- compiler->logical_local_size = local_size;
-#endif
/* Including the return address saved by the call instruction. */
saved_register_size = GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1);
@@ -173,7 +166,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
#endif
}
- local_size = ((local_size + FIXED_LOCALS_OFFSET + saved_register_size + 16 - 1) & ~(16 - 1)) - saved_register_size;
+ local_size = ((local_size + SLJIT_LOCALS_OFFSET + saved_register_size + 15) & ~15) - saved_register_size;
compiler->local_size = local_size;
#ifdef _WIN64
@@ -201,7 +194,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
*inst++ = MOV_rm_i32;
*inst++ = MOD_REG | reg_lmap[SLJIT_R0];
*(sljit_si*)inst = local_size;
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
+ || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
compiler->skip_checks = 1;
#endif
FAIL_IF(sljit_emit_ijump(compiler, SLJIT_CALL1, SLJIT_IMM, SLJIT_FUNC_OFFSET(sljit_grow_stack)));
@@ -243,27 +237,20 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compil
return SLJIT_SUCCESS;
}
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler,
+SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler,
sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
{
sljit_si saved_register_size;
- CHECK_ERROR_VOID();
- check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- compiler->options = options;
- compiler->scratches = scratches;
- compiler->saveds = saveds;
- compiler->fscratches = fscratches;
- compiler->fsaveds = fsaveds;
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
- compiler->logical_local_size = local_size;
-#endif
+ CHECK_ERROR();
+ CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
+ set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
/* Including the return address saved by the call instruction. */
saved_register_size = GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1);
- compiler->local_size = ((local_size + FIXED_LOCALS_OFFSET + saved_register_size + 16 - 1) & ~(16 - 1)) - saved_register_size;
+ compiler->local_size = ((local_size + SLJIT_LOCALS_OFFSET + saved_register_size + 15) & ~15) - saved_register_size;
+ return SLJIT_SUCCESS;
}
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
@@ -272,7 +259,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compi
sljit_ub *inst;
CHECK_ERROR();
- check_sljit_emit_return(compiler, op, src, srcw);
+ CHECK(check_sljit_emit_return(compiler, op, src, srcw));
compiler->flags_saved = 0;
FAIL_IF(emit_mov_before_return(compiler, op, src, srcw));
@@ -607,7 +594,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *c
sljit_ub *inst;
CHECK_ERROR();
- check_sljit_emit_fast_enter(compiler, dst, dstw);
+ CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw));
ADJUST_LOCAL_OFFSET(dst, dstw);
/* For UNUSED dst. Uncommon, but possible. */
@@ -644,7 +631,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *
sljit_ub *inst;
CHECK_ERROR();
- check_sljit_emit_fast_return(compiler, src, srcw);
+ CHECK(check_sljit_emit_fast_return(compiler, src, srcw));
ADJUST_LOCAL_OFFSET(src, srcw);
if ((src & SLJIT_IMM) && NOT_HALFWORD(srcw)) {
diff --git a/pcre/sljit/sljitNativeX86_common.c b/pcre/sljit/sljitNativeX86_common.c
index 71442fef254..22a163fcc66 100644
--- a/pcre/sljit/sljitNativeX86_common.c
+++ b/pcre/sljit/sljitNativeX86_common.c
@@ -72,7 +72,7 @@ static SLJIT_CONST sljit_ub reg_map[SLJIT_NUMBER_OF_REGISTERS + 3] = {
#define CHECK_EXTRA_REGS(p, w, do) \
if (p >= SLJIT_R3 && p <= SLJIT_R6) { \
- w = FIXED_LOCALS_OFFSET + ((p) - (SLJIT_R3 + 4)) * sizeof(sljit_sw); \
+ w = SLJIT_LOCALS_OFFSET + ((p) - (SLJIT_R3 + 4)) * sizeof(sljit_sw); \
p = SLJIT_MEM1(SLJIT_SP); \
do; \
}
@@ -183,6 +183,7 @@ static SLJIT_CONST sljit_ub reg_lmap[SLJIT_NUMBER_OF_REGISTERS + 5] = {
#define IMUL_r_rm_i8 0x6b
#define IMUL_r_rm_i32 0x69
#define JE_i8 0x74
+#define JNE_i8 0x75
#define JMP_i8 0xeb
#define JMP_i32 0xe9
#define JMP_rm (/* GROUP_FF */ 4 << 3)
@@ -330,54 +331,54 @@ static void get_cpu_features(void)
static sljit_ub get_jump_code(sljit_si type)
{
switch (type) {
- case SLJIT_C_EQUAL:
- case SLJIT_C_FLOAT_EQUAL:
+ case SLJIT_EQUAL:
+ case SLJIT_D_EQUAL:
return 0x84 /* je */;
- case SLJIT_C_NOT_EQUAL:
- case SLJIT_C_FLOAT_NOT_EQUAL:
+ case SLJIT_NOT_EQUAL:
+ case SLJIT_D_NOT_EQUAL:
return 0x85 /* jne */;
- case SLJIT_C_LESS:
- case SLJIT_C_FLOAT_LESS:
+ case SLJIT_LESS:
+ case SLJIT_D_LESS:
return 0x82 /* jc */;
- case SLJIT_C_GREATER_EQUAL:
- case SLJIT_C_FLOAT_GREATER_EQUAL:
+ case SLJIT_GREATER_EQUAL:
+ case SLJIT_D_GREATER_EQUAL:
return 0x83 /* jae */;
- case SLJIT_C_GREATER:
- case SLJIT_C_FLOAT_GREATER:
+ case SLJIT_GREATER:
+ case SLJIT_D_GREATER:
return 0x87 /* jnbe */;
- case SLJIT_C_LESS_EQUAL:
- case SLJIT_C_FLOAT_LESS_EQUAL:
+ case SLJIT_LESS_EQUAL:
+ case SLJIT_D_LESS_EQUAL:
return 0x86 /* jbe */;
- case SLJIT_C_SIG_LESS:
+ case SLJIT_SIG_LESS:
return 0x8c /* jl */;
- case SLJIT_C_SIG_GREATER_EQUAL:
+ case SLJIT_SIG_GREATER_EQUAL:
return 0x8d /* jnl */;
- case SLJIT_C_SIG_GREATER:
+ case SLJIT_SIG_GREATER:
return 0x8f /* jnle */;
- case SLJIT_C_SIG_LESS_EQUAL:
+ case SLJIT_SIG_LESS_EQUAL:
return 0x8e /* jle */;
- case SLJIT_C_OVERFLOW:
- case SLJIT_C_MUL_OVERFLOW:
+ case SLJIT_OVERFLOW:
+ case SLJIT_MUL_OVERFLOW:
return 0x80 /* jo */;
- case SLJIT_C_NOT_OVERFLOW:
- case SLJIT_C_MUL_NOT_OVERFLOW:
+ case SLJIT_NOT_OVERFLOW:
+ case SLJIT_MUL_NOT_OVERFLOW:
return 0x81 /* jno */;
- case SLJIT_C_FLOAT_UNORDERED:
+ case SLJIT_D_UNORDERED:
return 0x8a /* jp */;
- case SLJIT_C_FLOAT_ORDERED:
+ case SLJIT_D_ORDERED:
return 0x8b /* jpo */;
}
return 0;
@@ -456,7 +457,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil
struct sljit_const *const_;
CHECK_ERROR_PTR();
- check_sljit_generate_code(compiler);
+ CHECK_PTR(check_sljit_generate_code(compiler));
reverse_buf(compiler);
/* Second code generation pass. */
@@ -724,7 +725,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
#endif
CHECK_ERROR();
- check_sljit_emit_op0(compiler, op);
+ CHECK(check_sljit_emit_op0(compiler, op));
switch (GET_OPCODE(op)) {
case SLJIT_BREAKPOINT:
@@ -739,10 +740,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
INC_SIZE(1);
*inst = NOP;
break;
- case SLJIT_UMUL:
- case SLJIT_SMUL:
- case SLJIT_UDIV:
- case SLJIT_SDIV:
+ case SLJIT_LUMUL:
+ case SLJIT_LSMUL:
+ case SLJIT_LUDIV:
+ case SLJIT_LSDIV:
compiler->flags_saved = 0;
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
#ifdef _WIN64
@@ -762,7 +763,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
#endif
op = GET_OPCODE(op);
- if (op == SLJIT_UDIV) {
+ if (op == SLJIT_LUDIV) {
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || defined(_WIN64)
EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_R1, 0);
inst = emit_x86_instruction(compiler, 1, SLJIT_R1, 0, SLJIT_R1, 0);
@@ -773,7 +774,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
*inst = XOR_r_rm;
}
- if (op == SLJIT_SDIV) {
+ if (op == SLJIT_LSDIV) {
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || defined(_WIN64)
EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_R1, 0);
#endif
@@ -804,10 +805,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
FAIL_IF(!inst);
INC_SIZE(2);
*inst++ = GROUP_F7;
- *inst = MOD_REG | ((op >= SLJIT_UDIV) ? reg_map[TMP_REG1] : reg_map[SLJIT_R1]);
+ *inst = MOD_REG | ((op >= SLJIT_LUDIV) ? reg_map[TMP_REG1] : reg_map[SLJIT_R1]);
#else
#ifdef _WIN64
- size = (!compiler->mode32 || op >= SLJIT_UDIV) ? 3 : 2;
+ size = (!compiler->mode32 || op >= SLJIT_LUDIV) ? 3 : 2;
#else
size = (!compiler->mode32) ? 3 : 2;
#endif
@@ -816,11 +817,11 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
INC_SIZE(size);
#ifdef _WIN64
if (!compiler->mode32)
- *inst++ = REX_W | ((op >= SLJIT_UDIV) ? REX_B : 0);
- else if (op >= SLJIT_UDIV)
+ *inst++ = REX_W | ((op >= SLJIT_LUDIV) ? REX_B : 0);
+ else if (op >= SLJIT_LUDIV)
*inst++ = REX_B;
*inst++ = GROUP_F7;
- *inst = MOD_REG | ((op >= SLJIT_UDIV) ? reg_lmap[TMP_REG1] : reg_lmap[SLJIT_R1]);
+ *inst = MOD_REG | ((op >= SLJIT_LUDIV) ? reg_lmap[TMP_REG1] : reg_lmap[SLJIT_R1]);
#else
if (!compiler->mode32)
*inst++ = REX_W;
@@ -829,16 +830,16 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler
#endif
#endif
switch (op) {
- case SLJIT_UMUL:
+ case SLJIT_LUMUL:
*inst |= MUL;
break;
- case SLJIT_SMUL:
+ case SLJIT_LSMUL:
*inst |= IMUL;
break;
- case SLJIT_UDIV:
+ case SLJIT_LUDIV:
*inst |= DIV;
break;
- case SLJIT_SDIV:
+ case SLJIT_LSDIV:
*inst |= IDIV;
break;
}
@@ -1258,7 +1259,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler
#endif
CHECK_ERROR();
- check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw);
+ CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src, srcw);
@@ -1743,7 +1744,7 @@ static sljit_si emit_mul(struct sljit_compiler *compiler,
*(sljit_si*)inst = (sljit_si)src2w;
}
else {
- EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_IMM, src1w);
+ EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_IMM, src2w);
if (dst_r != src1)
EMIT_MOV(compiler, dst_r, 0, src1, src1w);
inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG2, 0);
@@ -2118,7 +2119,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler
sljit_si src2, sljit_sw src2w)
{
CHECK_ERROR();
- check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
+ CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src1, src1w);
ADJUST_LOCAL_OFFSET(src2, src2w);
@@ -2209,7 +2210,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_register_index(sljit_si reg)
{
- check_sljit_get_register_index(reg);
+ CHECK_REG_INDEX(check_sljit_get_register_index(reg));
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
if (reg >= SLJIT_R3 && reg <= SLJIT_R6)
return -1;
@@ -2219,7 +2220,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_register_index(sljit_si reg)
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_float_register_index(sljit_si reg)
{
- check_sljit_get_float_register_index(reg);
+ CHECK_REG_INDEX(check_sljit_get_float_register_index(reg));
return reg;
}
@@ -2229,8 +2230,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *co
sljit_ub *inst;
CHECK_ERROR();
- check_sljit_emit_op_custom(compiler, instruction, size);
- SLJIT_ASSERT(size > 0 && size < 16);
+ CHECK(check_sljit_emit_op_custom(compiler, instruction, size));
inst = (sljit_ub*)ensure_buf(compiler, 1 + size);
FAIL_IF(!inst);
@@ -2391,7 +2391,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compile
CHECK_ERROR();
SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw);
- if (GET_OPCODE(op) == SLJIT_MOVD) {
+ if (GET_OPCODE(op) == SLJIT_DMOV) {
if (FAST_IS_REG(dst))
return emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, dst, src, srcw);
if (FAST_IS_REG(src))
@@ -2430,11 +2430,11 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compile
}
switch (GET_OPCODE(op)) {
- case SLJIT_NEGD:
+ case SLJIT_DNEG:
FAIL_IF(emit_sse2_logic(compiler, XORPD_x_xm, 1, dst_r, SLJIT_MEM0(), (sljit_sw)(op & SLJIT_SINGLE_OP ? sse2_buffer : sse2_buffer + 8)));
break;
- case SLJIT_ABSD:
+ case SLJIT_DABS:
FAIL_IF(emit_sse2_logic(compiler, ANDPD_x_xm, 1, dst_r, SLJIT_MEM0(), (sljit_sw)(op & SLJIT_SINGLE_OP ? sse2_buffer + 4 : sse2_buffer + 12)));
break;
}
@@ -2452,7 +2452,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
sljit_si dst_r;
CHECK_ERROR();
- check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w);
+ CHECK(check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
ADJUST_LOCAL_OFFSET(dst, dstw);
ADJUST_LOCAL_OFFSET(src1, src1w);
ADJUST_LOCAL_OFFSET(src2, src2w);
@@ -2465,7 +2465,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
dst_r = dst;
if (dst == src1)
; /* Do nothing here. */
- else if (dst == src2 && (op == SLJIT_ADDD || op == SLJIT_MULD)) {
+ else if (dst == src2 && (op == SLJIT_DADD || op == SLJIT_DMUL)) {
/* Swap arguments. */
src2 = src1;
src2w = src1w;
@@ -2483,19 +2483,19 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compile
}
switch (GET_OPCODE(op)) {
- case SLJIT_ADDD:
+ case SLJIT_DADD:
FAIL_IF(emit_sse2(compiler, ADDSD_x_xm, op & SLJIT_SINGLE_OP, dst_r, src2, src2w));
break;
- case SLJIT_SUBD:
+ case SLJIT_DSUB:
FAIL_IF(emit_sse2(compiler, SUBSD_x_xm, op & SLJIT_SINGLE_OP, dst_r, src2, src2w));
break;
- case SLJIT_MULD:
+ case SLJIT_DMUL:
FAIL_IF(emit_sse2(compiler, MULSD_x_xm, op & SLJIT_SINGLE_OP, dst_r, src2, src2w));
break;
- case SLJIT_DIVD:
+ case SLJIT_DDIV:
FAIL_IF(emit_sse2(compiler, DIVSD_x_xm, op & SLJIT_SINGLE_OP, dst_r, src2, src2w));
break;
}
@@ -2515,7 +2515,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compi
struct sljit_label *label;
CHECK_ERROR_PTR();
- check_sljit_emit_label(compiler);
+ CHECK_PTR(check_sljit_emit_label(compiler));
/* We should restore the flags before the label,
since other taken jumps has their own flags as well. */
@@ -2544,7 +2544,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile
struct sljit_jump *jump;
CHECK_ERROR_PTR();
- check_sljit_emit_jump(compiler, type);
+ CHECK_PTR(check_sljit_emit_jump(compiler, type));
if (SLJIT_UNLIKELY(compiler->flags_saved)) {
if ((type & 0xff) <= SLJIT_JUMP)
@@ -2581,7 +2581,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_ijump(struct sljit_compiler *compil
struct sljit_jump *jump;
CHECK_ERROR();
- check_sljit_emit_ijump(compiler, type, src, srcw);
+ CHECK(check_sljit_emit_ijump(compiler, type, src, srcw));
ADJUST_LOCAL_OFFSET(src, srcw);
CHECK_EXTRA_REGS(src, srcw, (void)0);
@@ -2660,7 +2660,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
#endif
CHECK_ERROR();
- check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type);
+ CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type));
+ SLJIT_UNUSED_ARG(srcw);
if (dst == SLJIT_UNUSED)
return SLJIT_SUCCESS;
@@ -2670,6 +2671,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
if (SLJIT_UNLIKELY(compiler->flags_saved))
FAIL_IF(emit_restore_flags(compiler, op & SLJIT_KEEP_FLAGS));
+ type &= 0xff;
/* setcc = jcc + 0x10. */
cond_set = get_jump_code(type) + 0x10;
@@ -2711,7 +2713,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
compiler->mode32 = GET_OPCODE(op) != SLJIT_MOV;
return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
}
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
+ || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
compiler->skip_checks = 1;
#endif
return sljit_emit_op2(compiler, op, dst, dstw, dst, dstw, TMP_REG1, 0);
@@ -2821,7 +2824,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
if (GET_OPCODE(op) < SLJIT_ADD)
return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
+#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
+ || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
compiler->skip_checks = 1;
#endif
return sljit_emit_op2(compiler, op, dst_save, dstw_save, dst_save, dstw_save, TMP_REG1, 0);
@@ -2831,7 +2835,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *com
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_local_base(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw, sljit_sw offset)
{
CHECK_ERROR();
- check_sljit_get_local_base(compiler, dst, dstw, offset);
+ CHECK(check_sljit_get_local_base(compiler, dst, dstw, offset));
ADJUST_LOCAL_OFFSET(dst, dstw);
CHECK_EXTRA_REGS(dst, dstw, (void)0);
@@ -2868,7 +2872,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compi
#endif
CHECK_ERROR_PTR();
- check_sljit_emit_const(compiler, dst, dstw, init_value);
+ CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value));
ADJUST_LOCAL_OFFSET(dst, dstw);
CHECK_EXTRA_REGS(dst, dstw, (void)0);
diff --git a/pcre/sljit/sljitUtils.c b/pcre/sljit/sljitUtils.c
index b29b4036b30..5294b5f3f9b 100644
--- a/pcre/sljit/sljitUtils.c
+++ b/pcre/sljit/sljitUtils.c
@@ -200,7 +200,7 @@ static SLJIT_INLINE sljit_si open_dev_zero(void)
/* Planning to make it even more clever in the future. */
static sljit_sw sljit_page_align = 0;
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CALL sljit_allocate_stack(sljit_uw limit, sljit_uw max_limit)
+SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CALL sljit_allocate_stack(sljit_uw limit, sljit_uw max_limit, void *allocator_data)
{
struct sljit_stack *stack;
union {
@@ -211,6 +211,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CALL sljit_allocate_stack(slj
SYSTEM_INFO si;
#endif
+ SLJIT_UNUSED_ARG(allocator_data);
if (limit > max_limit || limit < 1)
return NULL;
@@ -232,21 +233,21 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CALL sljit_allocate_stack(slj
/* Align limit and max_limit. */
max_limit = (max_limit + sljit_page_align) & ~sljit_page_align;
- stack = (struct sljit_stack*)SLJIT_MALLOC(sizeof(struct sljit_stack));
+ stack = (struct sljit_stack*)SLJIT_MALLOC(sizeof(struct sljit_stack), allocator_data);
if (!stack)
return NULL;
#ifdef _WIN32
base.ptr = VirtualAlloc(NULL, max_limit, MEM_RESERVE, PAGE_READWRITE);
if (!base.ptr) {
- SLJIT_FREE(stack);
+ SLJIT_FREE(stack, allocator_data);
return NULL;
}
stack->base = base.uw;
stack->limit = stack->base;
stack->max_limit = stack->base + max_limit;
if (sljit_stack_resize(stack, stack->base + limit)) {
- sljit_free_stack(stack);
+ sljit_free_stack(stack, allocator_data);
return NULL;
}
#else
@@ -255,14 +256,14 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CALL sljit_allocate_stack(slj
#else
if (dev_zero < 0) {
if (open_dev_zero()) {
- SLJIT_FREE(stack);
+ SLJIT_FREE(stack, allocator_data);
return NULL;
}
}
base.ptr = mmap(NULL, max_limit, PROT_READ | PROT_WRITE, MAP_PRIVATE, dev_zero, 0);
#endif
if (base.ptr == MAP_FAILED) {
- SLJIT_FREE(stack);
+ SLJIT_FREE(stack, allocator_data);
return NULL;
}
stack->base = base.uw;
@@ -275,14 +276,15 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CALL sljit_allocate_stack(slj
#undef PAGE_ALIGN
-SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_free_stack(struct sljit_stack* stack)
+SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_free_stack(struct sljit_stack* stack, void *allocator_data)
{
+ SLJIT_UNUSED_ARG(allocator_data);
#ifdef _WIN32
VirtualFree((void*)stack->base, 0, MEM_RELEASE);
#else
munmap((void*)stack->base, stack->max_limit - stack->base);
#endif
- SLJIT_FREE(stack);
+ SLJIT_FREE(stack, allocator_data);
}
SLJIT_API_FUNC_ATTRIBUTE sljit_sw SLJIT_CALL sljit_stack_resize(struct sljit_stack* stack, sljit_uw new_limit)