diff --git a/sljit_src/sljitNativeARM_64.c b/sljit_src/sljitNativeARM_64.c index d80c9e54..f1ae3d9e 100644 --- a/sljit_src/sljitNativeARM_64.c +++ b/sljit_src/sljitNativeARM_64.c @@ -3467,6 +3467,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_get_local_base(struct sljit_compiler *c CHECK_ERROR(); CHECK(check_sljit_get_local_base(compiler, dst, dstw, offset)); + ADJUST_LOCAL_OFFSET(dst, dstw); ADJUST_LOCAL_OFFSET(SLJIT_MEM1(SLJIT_SP), offset); dst_reg = FAST_IS_REG(dst) ? dst : TMP_REG1; diff --git a/sljit_src/sljitNativeX86_common.c b/sljit_src/sljitNativeX86_common.c index 9f599d5f..bb86bce0 100644 --- a/sljit_src/sljitNativeX86_common.c +++ b/sljit_src/sljitNativeX86_common.c @@ -5002,6 +5002,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_get_local_base(struct sljit_compiler *c CHECK_ERROR(); CHECK(check_sljit_get_local_base(compiler, dst, dstw, offset)); ADJUST_LOCAL_OFFSET(dst, dstw); + ADJUST_LOCAL_OFFSET(SLJIT_MEM1(SLJIT_SP), offset); CHECK_EXTRA_REGS(dst, dstw, (void)0); @@ -5009,8 +5010,6 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_get_local_base(struct sljit_compiler *c compiler->mode32 = 0; #endif - ADJUST_LOCAL_OFFSET(SLJIT_MEM1(SLJIT_SP), offset); - #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) if (NOT_HALFWORD(offset)) { FAIL_IF(emit_load_imm64(compiler, TMP_REG1, offset)); diff --git a/test_src/sljitTest.c b/test_src/sljitTest.c index 62444c5a..b4262857 100644 --- a/test_src/sljitTest.c +++ b/test_src/sljitTest.c @@ -1571,7 +1571,7 @@ static void test17(void) struct sljit_compiler* compiler = sljit_create_compiler(NULL); struct sljit_jump* jump; struct sljit_label* label; - sljit_sw buf[6]; + sljit_sw buf[7]; sljit_sw offset_value = WCONST(0x1234567812345678, 0x12345678); if (verbose) @@ -1583,7 +1583,7 @@ static void test17(void) buf[2] = 0; buf[3] = 0; buf[4] = 111; - buf[5] = -12345; + buf[6] = -12345; sljit_emit_enter(compiler, 0, SLJIT_ARGS1(W, P), 5, 5, 4 * sizeof(sljit_sw)); /* buf[0] */ @@ -1603,8 +1603,12 @@ static void test17(void) sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R1, 0, SLJIT_MEM1(SLJIT_S0), 0); /* buf[4] */ sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_MEM1(SLJIT_S0), 4 * sizeof(sljit_uw), SLJIT_MEM1(SLJIT_R0), offset_value, SLJIT_MEM1(SLJIT_R1), 0x1234 + sizeof(sljit_sw)); + sljit_get_local_base(compiler, SLJIT_MEM1(SLJIT_SP), 0, 8); + sljit_get_local_base(compiler, SLJIT_R0, 0, 4); /* buf[5] */ - sljit_emit_return(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), 5 * sizeof(sljit_uw)); + sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_MEM1(SLJIT_S0), 5 * sizeof(sljit_uw), SLJIT_MEM1(SLJIT_SP), 0, SLJIT_R0, 0); + /* buf[6] */ + sljit_emit_return(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_S0), 6 * sizeof(sljit_uw)); /* Dummy last instructions. */ sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_S0, 0, SLJIT_IMM, 23); sljit_emit_label(compiler); @@ -1618,6 +1622,7 @@ static void test17(void) FAILED(buf[2] != 60, "test17 case 2 failed\n"); FAILED(buf[3] != 17, "test17 case 3 failed\n"); FAILED(buf[4] != 7, "test17 case 4 failed\n"); + FAILED(buf[5] != 4, "test17 case 5 failed\n"); sljit_free_code(code.code, NULL);