--- embedaddon/pcre/sljit/sljitNativeARM_v5.c 2012/02/21 23:50:25 1.1.1.2 +++ embedaddon/pcre/sljit/sljitNativeARM_v5.c 2012/10/09 09:19:18 1.1.1.3 @@ -830,6 +830,9 @@ SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_enter(struct s compiler->temporaries = temporaries; compiler->saveds = saveds; +#if (defined SLJIT_DEBUG && SLJIT_DEBUG) + compiler->logical_local_size = local_size; +#endif /* Push saved registers, temporary registers stmdb sp!, {..., lr} */ @@ -880,6 +883,9 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct compiler->temporaries = temporaries; compiler->saveds = saveds; +#if (defined SLJIT_DEBUG && SLJIT_DEBUG) + compiler->logical_local_size = local_size; +#endif size = (1 + saveds) * sizeof(sljit_uw); if (temporaries >= 4) @@ -896,6 +902,7 @@ SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct CHECK_ERROR(); check_sljit_emit_return(compiler, op, src, srcw); + ADJUST_LOCAL_OFFSET(src, srcw); FAIL_IF(emit_mov_before_return(compiler, op, src, srcw)); @@ -1648,7 +1655,8 @@ static int emit_op(struct sljit_compiler *compiler, in src2 = src1; src2w = src1w; } - else { + else do { /* do { } while(0) is used because of breaks. */ + src1_r = 0; if ((inp_flags & ALLOW_ANY_IMM) && (src1 & SLJIT_IMM)) { /* The second check will generate a hit. */ src2_r = get_immediate(src1w); @@ -1656,6 +1664,7 @@ static int emit_op(struct sljit_compiler *compiler, in flags |= ARGS_SWAPPED; src1 = src2; src1w = src2w; + break; } if (inp_flags & ALLOW_INV_IMM) { src2_r = get_immediate(~src1w); @@ -1663,16 +1672,26 @@ static int emit_op(struct sljit_compiler *compiler, in flags |= ARGS_SWAPPED | INV_IMM; src1 = src2; src1w = src2w; + break; } } + if (GET_OPCODE(op) == SLJIT_ADD) { + src2_r = get_immediate(-src1w); + if (src2_r) { + /* Note: ARGS_SWAPPED is intentionally not applied! */ + src1 = src2; + src1w = src2w; + op = SLJIT_SUB | GET_ALL_FLAGS(op); + break; + } + } } - src1_r = 0; if (getput_arg_fast(compiler, inp_flags | LOAD_DATA, TMP_REG1, src1, src1w)) { FAIL_IF(compiler->error); src1_r = TMP_REG1; } - } + } while (0); /* Source 2. */ if (src2_r == 0) { @@ -1694,6 +1713,22 @@ static int emit_op(struct sljit_compiler *compiler, in break; } } + if (GET_OPCODE(op) == SLJIT_ADD) { + src2_r = get_immediate(-src2w); + if (src2_r) { + op = SLJIT_SUB | GET_ALL_FLAGS(op); + flags &= ~ARGS_SWAPPED; + break; + } + } + if (GET_OPCODE(op) == SLJIT_SUB && !(flags & ARGS_SWAPPED)) { + src2_r = get_immediate(-src2w); + if (src2_r) { + op = SLJIT_ADD | GET_ALL_FLAGS(op); + flags &= ~ARGS_SWAPPED; + break; + } + } } /* src2_r is 0. */ @@ -1825,6 +1860,8 @@ SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op1(struct slj { CHECK_ERROR(); check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw); + ADJUST_LOCAL_OFFSET(dst, dstw); + ADJUST_LOCAL_OFFSET(src, srcw); switch (GET_OPCODE(op)) { case SLJIT_MOV: @@ -1868,7 +1905,7 @@ SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op1(struct slj #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG) compiler->skip_checks = 1; #endif - return sljit_emit_op2(compiler, SLJIT_SUB | GET_FLAGS(op), dst, dstw, SLJIT_IMM, 0, src, srcw); + return sljit_emit_op2(compiler, SLJIT_SUB | GET_ALL_FLAGS(op), dst, dstw, SLJIT_IMM, 0, src, srcw); case SLJIT_CLZ: return emit_op(compiler, op, 0, dst, dstw, TMP_REG1, 0, src, srcw); @@ -1884,6 +1921,9 @@ SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op2(struct slj { CHECK_ERROR(); 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); switch (GET_OPCODE(op)) { case SLJIT_ADD: @@ -2141,24 +2181,12 @@ SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop2(struct sl /* Other instructions */ /* --------------------------------------------------------------------- */ -SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw, int args, int temporaries, int saveds, int local_size) +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw) { - int size; - CHECK_ERROR(); - check_sljit_emit_fast_enter(compiler, dst, dstw, args, temporaries, saveds, local_size); + check_sljit_emit_fast_enter(compiler, dst, dstw); + ADJUST_LOCAL_OFFSET(dst, dstw); - compiler->temporaries = temporaries; - compiler->saveds = saveds; - - size = (1 + saveds) * sizeof(sljit_uw); - if (temporaries >= 4) - size += (temporaries - 3) * sizeof(sljit_uw); - local_size += size; - local_size = (local_size + 7) & ~7; - local_size -= size; - compiler->local_size = local_size; - if (dst >= SLJIT_TEMPORARY_REG1 && dst <= SLJIT_NO_REGISTERS) return push_inst(compiler, EMIT_DATA_PROCESS_INS(MOV_DP, 0, dst, SLJIT_UNUSED, RM(TMP_REG3))); else if (dst & SLJIT_MEM) { @@ -2177,6 +2205,7 @@ SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_return(st { CHECK_ERROR(); check_sljit_emit_fast_return(compiler, src, srcw); + ADJUST_LOCAL_OFFSET(src, srcw); if (src >= SLJIT_TEMPORARY_REG1 && src <= SLJIT_NO_REGISTERS) EMIT_INSTRUCTION(EMIT_DATA_PROCESS_INS(MOV_DP, 0, TMP_REG3, SLJIT_UNUSED, RM(src))); @@ -2316,6 +2345,7 @@ SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ijump(struct s CHECK_ERROR(); check_sljit_emit_ijump(compiler, type, src, srcw); + ADJUST_LOCAL_OFFSET(src, srcw); /* In ARM, we don't need to touch the arguments. */ if (src & SLJIT_IMM) { @@ -2355,6 +2385,7 @@ SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_cond_value(str CHECK_ERROR(); check_sljit_emit_cond_value(compiler, op, dst, dstw, type); + ADJUST_LOCAL_OFFSET(dst, dstw); if (dst == SLJIT_UNUSED) return SLJIT_SUCCESS; @@ -2393,6 +2424,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emi CHECK_ERROR_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)); PTR_FAIL_IF(!const_);