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

misc: avoid unnecesary shadowed variable #287

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 8 additions & 8 deletions sljit_src/sljitNativeARM_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ static void reduce_code_size(struct sljit_compiler *compiler)
struct sljit_jump *jump;
struct sljit_const *const_;
SLJIT_NEXT_DEFINE_TYPES;
sljit_uw total_size;
sljit_uw jump_total_size;
sljit_uw size_reduce = 0;
sljit_sw diff;

Expand Down Expand Up @@ -813,7 +813,7 @@ static void reduce_code_size(struct sljit_compiler *compiler)

jump->addr -= size_reduce;
if (!(jump->flags & JUMP_MOV_ADDR)) {
total_size = JUMP_MAX_SIZE - 1;
jump_total_size = JUMP_MAX_SIZE - 1;

if (!(jump->flags & (SLJIT_REWRITABLE_JUMP | JUMP_ADDR))) {
/* Unit size: instruction. */
Expand All @@ -824,13 +824,13 @@ static void reduce_code_size(struct sljit_compiler *compiler)
}

if (diff <= (0x01ffffff / SSIZE_OF(ins)) && diff >= (-0x02000000 / SSIZE_OF(ins)))
total_size = 1 - 1;
jump_total_size = 1 - 1;
}

size_reduce += JUMP_MAX_SIZE - 1 - total_size;
size_reduce += JUMP_MAX_SIZE - 1 - jump_total_size;
} else {
/* Real size minus 1. Unit size: instruction. */
total_size = 1;
jump_total_size = 1;

if (!(jump->flags & JUMP_ADDR)) {
diff = (sljit_sw)jump->u.label->size - (sljit_sw)jump->addr;
Expand All @@ -840,13 +840,13 @@ static void reduce_code_size(struct sljit_compiler *compiler)
}

if (diff <= 0xff + 2 && diff >= -0xff + 2)
total_size = 0;
jump_total_size = 0;
}

size_reduce += 1 - total_size;
size_reduce += 1 - jump_total_size;
}

jump->flags |= total_size << JUMP_SIZE_SHIFT;
jump->flags |= jump_total_size << JUMP_SIZE_SHIFT;
jump = jump->next;
next_jump_addr = SLJIT_GET_NEXT_ADDRESS(jump);
}
Expand Down
30 changes: 15 additions & 15 deletions sljit_src/sljitNativeARM_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ static void reduce_code_size(struct sljit_compiler *compiler)
struct sljit_jump *jump;
struct sljit_const *const_;
SLJIT_NEXT_DEFINE_TYPES;
sljit_uw total_size;
sljit_uw jump_total_size;
sljit_uw size_reduce = 0;
sljit_sw diff;

Expand Down Expand Up @@ -425,14 +425,14 @@ static void reduce_code_size(struct sljit_compiler *compiler)

jump->addr -= size_reduce;
if (!(jump->flags & JUMP_MOV_ADDR)) {
total_size = JUMP_MAX_SIZE;
jump_total_size = JUMP_MAX_SIZE;

if (!(jump->flags & SLJIT_REWRITABLE_JUMP)) {
if (jump->flags & JUMP_ADDR) {
if (jump->u.target < 0x100000000l)
total_size = 3;
jump_total_size = 3;
else if (jump->u.target < 0x1000000000000l)
total_size = 4;
jump_total_size = 4;
} else {
/* Unit size: instruction. */
diff = (sljit_sw)jump->u.label->size - (sljit_sw)jump->addr;
Expand All @@ -442,18 +442,18 @@ static void reduce_code_size(struct sljit_compiler *compiler)
}

if ((jump->flags & IS_COND) && (diff + 1) <= (0xfffff / SSIZE_OF(ins)) && (diff + 1) >= (-0x100000 / SSIZE_OF(ins)))
total_size = 0;
jump_total_size = 0;
else if (diff <= (0x7ffffff / SSIZE_OF(ins)) && diff >= (-0x8000000 / SSIZE_OF(ins)))
total_size = 1;
jump_total_size = 1;
else if (diff <= (0xfffff000l / SSIZE_OF(ins)) && diff >= (-0x100000000l / SSIZE_OF(ins)))
total_size = 3;
jump_total_size = 3;
}
}

size_reduce += JUMP_MAX_SIZE - total_size;
size_reduce += JUMP_MAX_SIZE - jump_total_size;
} else {
/* Real size minus 1. Unit size: instruction. */
total_size = 3;
jump_total_size = 3;

if (!(jump->flags & JUMP_ADDR)) {
diff = (sljit_sw)jump->u.label->size - (sljit_sw)jump->addr;
Expand All @@ -463,18 +463,18 @@ static void reduce_code_size(struct sljit_compiler *compiler)
}

if (diff <= (0xfffff / SSIZE_OF(ins)) && diff >= (-0x100000 / SSIZE_OF(ins)))
total_size = 0;
jump_total_size = 0;
else if (diff <= (0xfffff000l / SSIZE_OF(ins)) && diff >= (-0x100000000l / SSIZE_OF(ins)))
total_size = 1;
jump_total_size = 1;
} else if (jump->u.target < 0x100000000l)
total_size = 1;
jump_total_size = 1;
else if (jump->u.target < 0x1000000000000l)
total_size = 2;
jump_total_size = 2;

size_reduce += 3 - total_size;
size_reduce += 3 - jump_total_size;
}

jump->flags |= total_size << JUMP_SIZE_SHIFT;
jump->flags |= jump_total_size << JUMP_SIZE_SHIFT;
jump = jump->next;
next_jump_addr = SLJIT_GET_NEXT_ADDRESS(jump);
}
Expand Down
24 changes: 12 additions & 12 deletions sljit_src/sljitNativeARM_T2_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ static void reduce_code_size(struct sljit_compiler *compiler)
struct sljit_jump *jump;
struct sljit_const *const_;
SLJIT_NEXT_DEFINE_TYPES;
sljit_uw total_size;
sljit_uw jump_total_size;
sljit_uw size_reduce = 0;
sljit_sw diff;

Expand Down Expand Up @@ -546,7 +546,7 @@ static void reduce_code_size(struct sljit_compiler *compiler)

jump->addr -= size_reduce;
if (!(jump->flags & JUMP_MOV_ADDR)) {
total_size = JUMP_MAX_SIZE;
jump_total_size = JUMP_MAX_SIZE;

if (!(jump->flags & (SLJIT_REWRITABLE_JUMP | JUMP_ADDR))) {
/* Unit size: instruction. */
Expand All @@ -560,21 +560,21 @@ static void reduce_code_size(struct sljit_compiler *compiler)
diff++;

if (diff <= (0xff / SSIZE_OF(u16)) && diff >= (-0x100 / SSIZE_OF(u16)))
total_size = 0;
jump_total_size = 0;
else if (diff <= (0xfffff / SSIZE_OF(u16)) && diff >= (-0x100000 / SSIZE_OF(u16)))
total_size = 1;
jump_total_size = 1;
diff--;
} else if (!(jump->flags & IS_BL) && diff <= (0x7ff / SSIZE_OF(u16)) && diff >= (-0x800 / SSIZE_OF(u16)))
total_size = 1;
jump_total_size = 1;

if (total_size == JUMP_MAX_SIZE && diff <= (0xffffff / SSIZE_OF(u16)) && diff >= (-0x1000000 / SSIZE_OF(u16)))
total_size = 2;
if (jump_total_size == JUMP_MAX_SIZE && diff <= (0xffffff / SSIZE_OF(u16)) && diff >= (-0x1000000 / SSIZE_OF(u16)))
jump_total_size = 2;
}

size_reduce += JUMP_MAX_SIZE - total_size;
size_reduce += JUMP_MAX_SIZE - jump_total_size;
} else {
/* Real size minus 1. Unit size: instruction. */
total_size = 3;
jump_total_size = 3;

if (!(jump->flags & JUMP_ADDR)) {
diff = (sljit_sw)jump->u.label->size - (sljit_sw)jump->addr;
Expand All @@ -584,13 +584,13 @@ static void reduce_code_size(struct sljit_compiler *compiler)
}

if (diff <= (0xffd / SSIZE_OF(u16)) && diff >= (-0xfff / SSIZE_OF(u16)))
total_size = 1;
jump_total_size = 1;
}

size_reduce += 3 - total_size;
size_reduce += 3 - jump_total_size;
}

jump->flags |= total_size << JUMP_SIZE_SHIFT;
jump->flags |= jump_total_size << JUMP_SIZE_SHIFT;
jump = jump->next;
next_jump_addr = SLJIT_GET_NEXT_ADDRESS(jump);
}
Expand Down
30 changes: 15 additions & 15 deletions sljit_src/sljitNativeLOONGARCH_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ static void reduce_code_size(struct sljit_compiler *compiler)
struct sljit_jump *jump;
struct sljit_const *const_;
SLJIT_NEXT_DEFINE_TYPES;
sljit_uw total_size;
sljit_uw jump_total_size;
sljit_uw size_reduce = 0;
sljit_sw diff;

Expand Down Expand Up @@ -621,14 +621,14 @@ static void reduce_code_size(struct sljit_compiler *compiler)

jump->addr -= size_reduce;
if (!(jump->flags & JUMP_MOV_ADDR)) {
total_size = JUMP_MAX_SIZE;
jump_total_size = JUMP_MAX_SIZE;

if (!(jump->flags & SLJIT_REWRITABLE_JUMP)) {
if (jump->flags & JUMP_ADDR) {
if (jump->u.target <= S32_MAX)
total_size = 2;
jump_total_size = 2;
else if (jump->u.target <= S52_MAX)
total_size = 3;
jump_total_size = 3;
} else {
/* Unit size: instruction. */
diff = (sljit_sw)jump->u.label->size - (sljit_sw)jump->addr;
Expand All @@ -638,18 +638,18 @@ static void reduce_code_size(struct sljit_compiler *compiler)
}

if ((jump->flags & IS_COND) && (diff + 1) <= (BRANCH16_MAX / SSIZE_OF(ins)) && (diff + 1) >= (BRANCH16_MIN / SSIZE_OF(ins)))
total_size = 0;
jump_total_size = 0;
else if (diff >= (JUMP_MIN / SSIZE_OF(ins)) && diff <= (JUMP_MAX / SSIZE_OF(ins)))
total_size = 1;
jump_total_size = 1;
else if (diff >= (S32_MIN / SSIZE_OF(ins)) && diff <= (S32_MAX / SSIZE_OF(ins)))
total_size = 2;
jump_total_size = 2;
}
}

size_reduce += JUMP_MAX_SIZE - total_size;
jump->flags |= total_size << JUMP_SIZE_SHIFT;
size_reduce += JUMP_MAX_SIZE - jump_total_size;
jump->flags |= jump_total_size << JUMP_SIZE_SHIFT;
} else {
total_size = 3;
jump_total_size = 3;

if (!(jump->flags & JUMP_ADDR)) {
/* Real size minus 1. Unit size: instruction. */
Expand All @@ -660,14 +660,14 @@ static void reduce_code_size(struct sljit_compiler *compiler)
}

if (diff >= (S32_MIN / SSIZE_OF(ins)) && diff <= (S32_MAX / SSIZE_OF(ins)))
total_size = 1;
jump_total_size = 1;
} else if (jump->u.target < S32_MAX)
total_size = 1;
jump_total_size = 1;
else if (jump->u.target <= S52_MAX)
total_size = 2;
jump_total_size = 2;

size_reduce += 3 - total_size;
jump->flags |= total_size << JUMP_SIZE_SHIFT;
size_reduce += 3 - jump_total_size;
jump->flags |= jump_total_size << JUMP_SIZE_SHIFT;
}

jump = jump->next;
Expand Down
28 changes: 14 additions & 14 deletions sljit_src/sljitNativePPC_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ static void reduce_code_size(struct sljit_compiler *compiler)
struct sljit_jump *jump;
struct sljit_const *const_;
SLJIT_NEXT_DEFINE_TYPES;
sljit_uw total_size;
sljit_uw jump_total_size;
sljit_uw size_reduce = 0;
sljit_sw diff;

Expand Down Expand Up @@ -544,17 +544,17 @@ static void reduce_code_size(struct sljit_compiler *compiler)

jump->addr -= size_reduce;
if (!(jump->flags & JUMP_MOV_ADDR)) {
total_size = JUMP_MAX_SIZE - 1;
jump_total_size = JUMP_MAX_SIZE - 1;

if (!(jump->flags & SLJIT_REWRITABLE_JUMP)) {
if (jump->flags & JUMP_ADDR) {
if (jump->u.target <= 0x01ffffff)
total_size = 1 - 1;
jump_total_size = 1 - 1;
#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
else if (jump->u.target < 0x80000000l)
total_size = 4 - 1;
jump_total_size = 4 - 1;
else if (jump->u.target < 0x800000000000l)
total_size = 6 - 1;
jump_total_size = 6 - 1;
#endif /* SLJIT_CONFIG_PPC_64 */
} else {
/* Unit size: instruction. */
Expand All @@ -566,30 +566,30 @@ static void reduce_code_size(struct sljit_compiler *compiler)

if (jump->flags & IS_COND) {
if (diff <= (0x7fff / SSIZE_OF(ins)) && diff >= (-0x8000 / SSIZE_OF(ins)))
total_size = 1 - 1;
jump_total_size = 1 - 1;
else if ((diff - 1) <= (0x01ffffff / SSIZE_OF(ins)) && (diff - 1) >= (-0x02000000 / SSIZE_OF(ins)))
total_size = 2 - 1;
jump_total_size = 2 - 1;
} else if (diff <= (0x01ffffff / SSIZE_OF(ins)) && diff >= (-0x02000000 / SSIZE_OF(ins)))
total_size = 1 - 1;
jump_total_size = 1 - 1;
}
}

size_reduce += (JUMP_MAX_SIZE - 1) - total_size;
jump->flags |= total_size << JUMP_SIZE_SHIFT;
size_reduce += (JUMP_MAX_SIZE - 1) - jump_total_size;
jump->flags |= jump_total_size << JUMP_SIZE_SHIFT;
#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
} else {
total_size = (sljit_uw)4 << JUMP_SIZE_SHIFT;
jump_total_size = (sljit_uw)4 << JUMP_SIZE_SHIFT;

if (jump->flags & JUMP_ADDR) {
if (jump->u.target < 0x80000000l) {
total_size = (sljit_uw)1 << JUMP_SIZE_SHIFT;
jump_total_size = (sljit_uw)1 << JUMP_SIZE_SHIFT;
size_reduce += 3;
} else if (jump->u.target < 0x800000000000l) {
total_size = (sljit_uw)3 << JUMP_SIZE_SHIFT;
jump_total_size = (sljit_uw)3 << JUMP_SIZE_SHIFT;
size_reduce += 1;
}
}
jump->flags |= total_size;
jump->flags |= jump_total_size;
#endif /* SLJIT_CONFIG_PPC_64 */
}

Expand Down
Loading
Loading