Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sljit_get_local_base #282

Merged
merged 1 commit into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sljit_src/sljitNativeARM_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions sljit_src/sljitNativeX86_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -5002,15 +5002,14 @@ 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);

#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
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));
Expand Down
11 changes: 8 additions & 3 deletions test_src/sljitTest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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] */
Expand All @@ -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);
Expand All @@ -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);

Expand Down