Revision: 705
http://vcs.pcre.org/viewvc?view=rev&revision=705
Author: zherczeg
Date: 2011-09-22 11:44:35 +0100 (Thu, 22 Sep 2011)
Log Message:
-----------
JIT compiler fix for MIPS position independent calls
Modified Paths:
--------------
code/trunk/sljit/sljitNativeMIPS_common.c
Modified: code/trunk/sljit/sljitNativeMIPS_common.c
===================================================================
--- code/trunk/sljit/sljitNativeMIPS_common.c 2011-09-21 12:35:36 UTC (rev 704)
+++ code/trunk/sljit/sljitNativeMIPS_common.c 2011-09-22 10:44:35 UTC (rev 705)
@@ -1560,15 +1560,28 @@
check_sljit_emit_ijump(compiler, type, src, srcw);
if (src >= SLJIT_TEMPORARY_REG1 && src <= SLJIT_NO_REGISTERS) {
- if (DR(src) < 4 || DR(src) > 6)
+ if (DR(src) != 4)
src_r = src;
else
FAIL_IF(push_inst(compiler, ADDU_W | S(src) | TA(0) | D(TMP_REG2), DR(TMP_REG2)));
}
- if (type >= SLJIT_CALL1)
- FAIL_IF(push_inst(compiler, ADDU_W | S(SLJIT_TEMPORARY_REG1) | TA(0) | DA(4), 4));
+ if (type >= SLJIT_CALL0) {
+ if (src & SLJIT_IMM) {
+ FAIL_IF(load_immediate(compiler, 25, srcw));
+ FAIL_IF(push_inst(compiler, JALR | SA(25) | DA(31), UNMOVABLE_INS));
+ /* We need an extra instruction in any case. */
+ return push_inst(compiler, ADDU_W | S(SLJIT_TEMPORARY_REG1) | TA(0) | DA(4), UNMOVABLE_INS);
+ }
+ if (src & SLJIT_MEM)
+ FAIL_IF(emit_op(compiler, SLJIT_MOV, WORD_DATA, TMP_REG2, 0, TMP_REG1, 0, src, srcw));
+ if (type >= SLJIT_CALL1)
+ FAIL_IF(push_inst(compiler, ADDU_W | S(SLJIT_TEMPORARY_REG1) | TA(0) | DA(4), 4));
+ FAIL_IF(push_inst(compiler, JALR | S(src_r) | DA(31), UNMOVABLE_INS));
+ return push_inst(compiler, ADDU_W | S(src_r) | TA(0) | DA(25), UNMOVABLE_INS);
+ }
+
if (src & SLJIT_IMM) {
jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
FAIL_IF(!jump);
@@ -1583,10 +1596,7 @@
else if (src & SLJIT_MEM)
FAIL_IF(emit_op(compiler, SLJIT_MOV, WORD_DATA, TMP_REG2, 0, TMP_REG1, 0, src, srcw));
- if (type <= SLJIT_JUMP)
- FAIL_IF(push_inst(compiler, JR | S(src_r), UNMOVABLE_INS));
- else
- FAIL_IF(push_inst(compiler, JALR | S(src_r) | DA(31), UNMOVABLE_INS));
+ FAIL_IF(push_inst(compiler, JR | S(src_r), UNMOVABLE_INS));
if (jump)
jump->addr = compiler->size;
FAIL_IF(push_inst(compiler, NOP, UNMOVABLE_INS));