diff options
author | zherczeg <zherczeg@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2012-01-14 17:05:53 +0000 |
---|---|---|
committer | zherczeg <zherczeg@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2012-01-14 17:05:53 +0000 |
commit | 005bebb81eb7465ab104817236f9e23992956cb4 (patch) | |
tree | 23f1ad76431dda2f57795d3c626d72be04f1c654 | |
parent | 8c50e3dc8301b4d85307aff27cf9a55f6dbff434 (diff) | |
download | pcre-005bebb81eb7465ab104817236f9e23992956cb4.tar.gz |
JIT compiler update
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@875 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r-- | pcre_jit_compile.c | 2 | ||||
-rw-r--r-- | sljit/sljitConfigInternal.h | 7 | ||||
-rw-r--r-- | sljit/sljitLir.c | 78 | ||||
-rw-r--r-- | sljit/sljitLir.h | 15 | ||||
-rw-r--r-- | sljit/sljitNativeARM_Thumb2.c | 13 | ||||
-rw-r--r-- | sljit/sljitNativeARM_v5.c | 7 | ||||
-rw-r--r-- | sljit/sljitNativeMIPS_common.c | 10 | ||||
-rw-r--r-- | sljit/sljitNativePPC_common.c | 7 | ||||
-rw-r--r-- | sljit/sljitNativeX86_32.c | 9 | ||||
-rw-r--r-- | sljit/sljitNativeX86_64.c | 10 |
10 files changed, 101 insertions, 57 deletions
diff --git a/pcre_jit_compile.c b/pcre_jit_compile.c index 599619a..2bb343f 100644 --- a/pcre_jit_compile.c +++ b/pcre_jit_compile.c @@ -6532,7 +6532,7 @@ if (common->accept != NULL) /* This means we have a match. Update the ovector. */ copy_ovector(common, re->top_bracket + 1); leave = LABEL(); -sljit_emit_return(compiler, SLJIT_UNUSED, 0); +sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0); empty_match_fallback = LABEL(); compile_fallbackpath(common, rootfallback.top); diff --git a/sljit/sljitConfigInternal.h b/sljit/sljitConfigInternal.h index cbdcfb8..de6e9f0 100644 --- a/sljit/sljitConfigInternal.h +++ b/sljit/sljitConfigInternal.h @@ -230,7 +230,12 @@ typedef signed int sljit_i; /* Machine word type. Can encapsulate a pointer. 32 bit for 32 bit machines. 64 bit for 64 bit machines. */ -#if !(defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) && !(defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) +#if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) +/* Just to have something. */ +#define SLJIT_WORD_SHIFT 0 +typedef unsigned long int sljit_uw; +typedef long int sljit_w; +#elif !(defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) && !(defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) #define SLJIT_32BIT_ARCHITECTURE 1 #define SLJIT_WORD_SHIFT 2 typedef unsigned int sljit_uw; diff --git a/sljit/sljitLir.c b/sljit/sljitLir.c index 58c12bb..6588de4 100644 --- a/sljit/sljitLir.c +++ b/sljit/sljitLir.c @@ -714,25 +714,31 @@ static SLJIT_INLINE void check_sljit_set_context(struct sljit_compiler *compiler #endif } -static SLJIT_INLINE void check_sljit_emit_return(struct sljit_compiler *compiler, int src, sljit_w srcw) +static SLJIT_INLINE void check_sljit_emit_return(struct sljit_compiler *compiler, int op, int src, sljit_w 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 (src != SLJIT_UNUSED) { + if (op != SLJIT_UNUSED) { + SLJIT_ASSERT(op >= SLJIT_MOV && op <= SLJIT_MOV_SI); FUNCTION_CHECK_SRC(src, srcw); } else - SLJIT_ASSERT(srcw == 0); + SLJIT_ASSERT(src == 0 && srcw == 0); #endif #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) if (SLJIT_UNLIKELY(!!compiler->verbose)) { - fprintf(compiler->verbose, " return "); - sljit_verbose_param(src, srcw); - fprintf(compiler->verbose, "\n"); + if (op == SLJIT_UNUSED) + fprintf(compiler->verbose, " return\n"); + else { + fprintf(compiler->verbose, " return %s ", op_names[op]); + sljit_verbose_param(src, srcw); + fprintf(compiler->verbose, "\n"); + } } #endif } @@ -814,6 +820,13 @@ static SLJIT_INLINE void check_sljit_emit_op1(struct sljit_compiler *compiler, i 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; + } +#endif + SLJIT_ASSERT(GET_OPCODE(op) >= SLJIT_MOV && GET_OPCODE(op) <= SLJIT_CLZ); #if (defined SLJIT_DEBUG && SLJIT_DEBUG) FUNCTION_CHECK_OP(); @@ -895,13 +908,6 @@ static SLJIT_INLINE void check_sljit_emit_fop1(struct sljit_compiler *compiler, int dst, sljit_w dstw, int src, sljit_w srcw) { -#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG) - if (SLJIT_UNLIKELY(compiler->skip_checks)) { - compiler->skip_checks = 0; - return; - } -#endif - /* If debug and verbose are disabled, all arguments are unused. */ SLJIT_UNUSED_ARG(compiler); SLJIT_UNUSED_ARG(op); @@ -910,6 +916,13 @@ static SLJIT_INLINE void check_sljit_emit_fop1(struct sljit_compiler *compiler, 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; + } +#endif + SLJIT_ASSERT(sljit_is_fpu_available()); SLJIT_ASSERT(GET_OPCODE(op) >= SLJIT_FCMP && GET_OPCODE(op) <= SLJIT_FABS); #if (defined SLJIT_DEBUG && SLJIT_DEBUG) @@ -1120,6 +1133,26 @@ static SLJIT_INLINE void check_sljit_emit_const(struct sljit_compiler *compiler, #endif } +static SLJIT_INLINE int emit_mov_before_return(struct sljit_compiler *compiler, int op, int src, sljit_w srcw) +{ + /* Return if don't need to do anything. */ + if (op == SLJIT_UNUSED) + return SLJIT_SUCCESS; + +#if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE) + if (src == SLJIT_RETURN_REG && op == SLJIT_MOV) + return SLJIT_SUCCESS; +#else + if (src == SLJIT_RETURN_REG && (op == SLJIT_MOV || op == SLJIT_MOV_UI || op == SLJIT_MOV_SI)) + return SLJIT_SUCCESS; +#endif + +#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG) + compiler->skip_checks = 1; +#endif + return sljit_emit_op1(compiler, op, SLJIT_RETURN_REG, 0, src, srcw); +} + #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) #include "sljitNativeX86_common.c" #elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) @@ -1306,9 +1339,10 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler, SLJIT_ASSERT_STOP(); } -SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int src, sljit_w srcw) +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int op, int src, sljit_w srcw) { SLJIT_UNUSED_ARG(compiler); + SLJIT_UNUSED_ARG(op); SLJIT_UNUSED_ARG(src); SLJIT_UNUSED_ARG(srcw); SLJIT_ASSERT_STOP(); @@ -1376,6 +1410,22 @@ SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op2(struct sljit_compiler *compiler, int return SLJIT_ERR_UNSUPPORTED; } +SLJIT_API_FUNC_ATTRIBUTE int sljit_get_register_index(int reg) +{ + SLJIT_ASSERT_STOP(); + return reg; +} + +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op_custom(struct sljit_compiler *compiler, + void *instruction, int size) +{ + SLJIT_UNUSED_ARG(compiler); + SLJIT_UNUSED_ARG(instruction); + SLJIT_UNUSED_ARG(size); + SLJIT_ASSERT_STOP(); + return SLJIT_ERR_UNSUPPORTED; +} + SLJIT_API_FUNC_ATTRIBUTE int sljit_is_fpu_available(void) { SLJIT_ASSERT_STOP(); diff --git a/sljit/sljitLir.h b/sljit/sljitLir.h index 685ee80..589e2ea 100644 --- a/sljit/sljitLir.h +++ b/sljit/sljitLir.h @@ -337,7 +337,8 @@ static SLJIT_INLINE sljit_uw sljit_get_generated_code_size(struct sljit_compiler #define SLJIT_MAX_LOCAL_SIZE 65536 -SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, int generals, int local_size); +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_enter(struct sljit_compiler *compiler, + int args, int temporaries, int generals, int local_size); /* The machine code has a context (which contains the local stack space size, number of used registers, etc.) which initialized by sljit_emit_enter. Several @@ -351,10 +352,16 @@ SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_enter(struct sljit_compiler *compiler, i /* Note: multiple calls of this function overwrites the previous call. */ -SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler, int args, int temporaries, int generals, int local_size); +SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler, + int args, int temporaries, int generals, int local_size); -/* Return from jit. See below the possible values for src and srcw. */ -SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int src, sljit_w srcw); +/* Return from machine code. The op argument can be SLJIT_UNUSED which means the + function does not return with anything or any opcode between SLJIT_MOV and + SLJIT_MOV_SI (see sljit_emit_op1). As for src and srcw they must be 0 if op + is SLJIT_UNUSED, otherwise see below the description about source and + destination arguments. */ +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int op, + int src, sljit_w srcw); /* Really fast calling method for utility functions inside sljit (see SLJIT_FAST_CALL). All registers and even the stack frame is passed to the callee. The return address is diff --git a/sljit/sljitNativeARM_Thumb2.c b/sljit/sljitNativeARM_Thumb2.c index f69f91a..363f022 100644 --- a/sljit/sljitNativeARM_Thumb2.c +++ b/sljit/sljitNativeARM_Thumb2.c @@ -1169,21 +1169,14 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler, compiler->local_size = local_size; } -SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int src, sljit_w srcw) +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int op, int src, sljit_w srcw) { sljit_ins pop; CHECK_ERROR(); - check_sljit_emit_return(compiler, src, srcw); + check_sljit_emit_return(compiler, op, src, srcw); - if (src != SLJIT_UNUSED && src != SLJIT_RETURN_REG) { - if (src >= SLJIT_TEMPORARY_REG1 && src <= TMP_REG3) - FAIL_IF(push_inst16(compiler, MOV | SET_REGS44(SLJIT_RETURN_REG, src))); - else if (src & SLJIT_IMM) - FAIL_IF(load_immediate(compiler, SLJIT_RETURN_REG, srcw)); - else - FAIL_IF(emit_op_mem(compiler, WORD_SIZE, SLJIT_RETURN_REG, src, srcw)); - } + FAIL_IF(emit_mov_before_return(compiler, op, src, srcw)); if (compiler->local_size > 0) { if (compiler->local_size <= (127 << 2)) diff --git a/sljit/sljitNativeARM_v5.c b/sljit/sljitNativeARM_v5.c index c83b3c3..e22c249 100644 --- a/sljit/sljitNativeARM_v5.c +++ b/sljit/sljitNativeARM_v5.c @@ -890,15 +890,14 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler, compiler->local_size = local_size; } -SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int src, sljit_w srcw) +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int op, int src, sljit_w srcw) { sljit_uw pop; CHECK_ERROR(); - check_sljit_emit_return(compiler, src, srcw); + check_sljit_emit_return(compiler, op, src, srcw); - if (src != SLJIT_UNUSED && src != SLJIT_RETURN_REG) - FAIL_IF(emit_op(compiler, SLJIT_MOV, ALLOW_ANY_IMM, SLJIT_RETURN_REG, 0, TMP_REG1, 0, src, srcw)); + FAIL_IF(emit_mov_before_return(compiler, op, src, srcw)); if (compiler->local_size > 0) FAIL_IF(emit_op(compiler, SLJIT_ADD, ALLOW_IMM, SLJIT_LOCALS_REG, 0, SLJIT_LOCALS_REG, 0, SLJIT_IMM, compiler->local_size)); diff --git a/sljit/sljitNativeMIPS_common.c b/sljit/sljitNativeMIPS_common.c index a1026f9..26c9555 100644 --- a/sljit/sljitNativeMIPS_common.c +++ b/sljit/sljitNativeMIPS_common.c @@ -527,19 +527,17 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler, compiler->local_size = (local_size + 15) & ~0xf; } -SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int src, sljit_w srcw) +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int op, int src, sljit_w srcw) { int local_size; sljit_ins base; CHECK_ERROR(); - check_sljit_emit_return(compiler, src, srcw); + check_sljit_emit_return(compiler, op, src, srcw); - local_size = compiler->local_size; - - if (src != SLJIT_UNUSED && src != SLJIT_RETURN_REG) - FAIL_IF(emit_op(compiler, SLJIT_MOV, WORD_DATA, SLJIT_RETURN_REG, 0, TMP_REG1, 0, src, srcw)); + FAIL_IF(emit_mov_before_return(compiler, op, src, srcw)); + local_size = compiler->local_size; if (local_size <= SIMM_MAX) base = S(REAL_STACK_PTR); else { diff --git a/sljit/sljitNativePPC_common.c b/sljit/sljitNativePPC_common.c index 462ccc3..bb0552c 100644 --- a/sljit/sljitNativePPC_common.c +++ b/sljit/sljitNativePPC_common.c @@ -517,13 +517,12 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler, compiler->local_size = (compiler->local_size + 15) & ~0xf; } -SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int src, sljit_w srcw) +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int op, int src, sljit_w srcw) { CHECK_ERROR(); - check_sljit_emit_return(compiler, src, srcw); + check_sljit_emit_return(compiler, op, src, srcw); - if (src != SLJIT_UNUSED && src != SLJIT_RETURN_REG) - FAIL_IF(emit_op(compiler, SLJIT_MOV, WORD_DATA, SLJIT_RETURN_REG, 0, TMP_REG1, 0, src, srcw)); + FAIL_IF(emit_mov_before_return(compiler, op, src, srcw)); if (compiler->local_size <= SIMM_MAX) FAIL_IF(push_inst(compiler, ADDI | D(REAL_STACK_PTR) | A(REAL_STACK_PTR) | IMM(compiler->local_size))); diff --git a/sljit/sljitNativeX86_32.c b/sljit/sljitNativeX86_32.c index 1470c5f..4e316dc 100644 --- a/sljit/sljitNativeX86_32.c +++ b/sljit/sljitNativeX86_32.c @@ -173,20 +173,17 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler, compiler->local_size += (generals - 3) * sizeof(sljit_uw); } -SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int src, sljit_w srcw) +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int op, int src, sljit_w srcw) { int size; sljit_ub *buf; CHECK_ERROR(); - check_sljit_emit_return(compiler, src, srcw); + check_sljit_emit_return(compiler, op, src, srcw); SLJIT_ASSERT(compiler->args >= 0); compiler->flags_saved = 0; - CHECK_EXTRA_REGS(src, srcw, (void)0); - - if (src != SLJIT_UNUSED && src != SLJIT_RETURN_REG) - FAIL_IF(emit_mov(compiler, SLJIT_RETURN_REG, 0, src, srcw)); + FAIL_IF(emit_mov_before_return(compiler, op, src, srcw)); if (compiler->local_size > 0) FAIL_IF(emit_cum_binary(compiler, 0x03, 0x01, 0x0 << 3, 0x05, diff --git a/sljit/sljitNativeX86_64.c b/sljit/sljitNativeX86_64.c index 587c53a..e54c8cf 100644 --- a/sljit/sljitNativeX86_64.c +++ b/sljit/sljitNativeX86_64.c @@ -297,20 +297,16 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler, #endif } -SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int src, sljit_w srcw) +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int op, int src, sljit_w srcw) { int size; sljit_ub *buf; CHECK_ERROR(); - check_sljit_emit_return(compiler, src, srcw); + check_sljit_emit_return(compiler, op, src, srcw); compiler->flags_saved = 0; - - if (src != SLJIT_UNUSED && src != SLJIT_RETURN_REG) { - compiler->mode32 = 0; - FAIL_IF(emit_mov(compiler, SLJIT_RETURN_REG, 0, src, srcw)); - } + FAIL_IF(emit_mov_before_return(compiler, op, src, srcw)); if (compiler->local_size > 0) { if (compiler->local_size <= 127) { |