"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "sljit/sljitNativeX86_common.c" between
pcre-8.43.tar.bz2 and pcre-8.44.tar.bz2

About: The PCRE library implements Perl compatible regular expression pattern matching.

sljitNativeX86_common.c  (pcre-8.43.tar.bz2):sljitNativeX86_common.c  (pcre-8.44.tar.bz2)
skipping to change at line 431 skipping to change at line 431
case SLJIT_UNORDERED_F64: case SLJIT_UNORDERED_F64:
return 0x8a /* jp */; return 0x8a /* jp */;
case SLJIT_ORDERED_F64: case SLJIT_ORDERED_F64:
return 0x8b /* jpo */; return 0x8b /* jpo */;
} }
return 0; return 0;
} }
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
static sljit_u8* generate_far_jump_code(struct sljit_jump *jump, sljit_u8 *code_ ptr, sljit_s32 type, sljit_sw executable_offset); static sljit_u8* generate_far_jump_code(struct sljit_jump *jump, sljit_u8 *code_ ptr, sljit_sw executable_offset);
#else #else
static sljit_u8* generate_far_jump_code(struct sljit_jump *jump, sljit_u8 *code_ static sljit_u8* generate_far_jump_code(struct sljit_jump *jump, sljit_u8 *code_
ptr, sljit_s32 type); ptr);
static sljit_u8* generate_put_label_code(struct sljit_put_label *put_label, slji
t_u8 *code_ptr, sljit_uw max_label);
#endif #endif
static sljit_u8* generate_near_jump_code(struct sljit_jump *jump, sljit_u8 *code _ptr, sljit_u8 *code, sljit_s32 type, sljit_sw executable_offset) static sljit_u8* generate_near_jump_code(struct sljit_jump *jump, sljit_u8 *code _ptr, sljit_u8 *code, sljit_sw executable_offset)
{ {
sljit_s32 type = jump->flags >> TYPE_SHIFT;
sljit_s32 short_jump; sljit_s32 short_jump;
sljit_uw label_addr; sljit_uw label_addr;
if (jump->flags & JUMP_LABEL) if (jump->flags & JUMP_LABEL)
label_addr = (sljit_uw)(code + jump->u.label->size); label_addr = (sljit_uw)(code + jump->u.label->size);
else else
label_addr = jump->u.target - executable_offset; label_addr = jump->u.target - executable_offset;
short_jump = (sljit_sw)(label_addr - (jump->addr + 2)) >= -128 && (sljit_ sw)(label_addr - (jump->addr + 2)) <= 127; short_jump = (sljit_sw)(label_addr - (jump->addr + 2)) >= -128 && (sljit_ sw)(label_addr - (jump->addr + 2)) <= 127;
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
if ((sljit_sw)(label_addr - (jump->addr + 1)) > HALFWORD_MAX || (sljit_sw )(label_addr - (jump->addr + 1)) < HALFWORD_MIN) if ((sljit_sw)(label_addr - (jump->addr + 1)) > HALFWORD_MAX || (sljit_sw )(label_addr - (jump->addr + 1)) < HALFWORD_MIN)
return generate_far_jump_code(jump, code_ptr, type); return generate_far_jump_code(jump, code_ptr);
#endif #endif
if (type == SLJIT_JUMP) { if (type == SLJIT_JUMP) {
if (short_jump) if (short_jump)
*code_ptr++ = JMP_i8; *code_ptr++ = JMP_i8;
else else
*code_ptr++ = JMP_i32; *code_ptr++ = JMP_i32;
jump->addr++; jump->addr++;
} }
else if (type >= SLJIT_FAST_CALL) { else if (type >= SLJIT_FAST_CALL) {
skipping to change at line 500 skipping to change at line 502
sljit_u8 *code_ptr; sljit_u8 *code_ptr;
sljit_u8 *buf_ptr; sljit_u8 *buf_ptr;
sljit_u8 *buf_end; sljit_u8 *buf_end;
sljit_u8 len; sljit_u8 len;
sljit_sw executable_offset; sljit_sw executable_offset;
sljit_sw jump_addr; sljit_sw jump_addr;
struct sljit_label *label; struct sljit_label *label;
struct sljit_jump *jump; struct sljit_jump *jump;
struct sljit_const *const_; struct sljit_const *const_;
struct sljit_put_label *put_label;
CHECK_ERROR_PTR(); CHECK_ERROR_PTR();
CHECK_PTR(check_sljit_generate_code(compiler)); CHECK_PTR(check_sljit_generate_code(compiler));
reverse_buf(compiler); reverse_buf(compiler);
/* Second code generation pass. */ /* Second code generation pass. */
code = (sljit_u8*)SLJIT_MALLOC_EXEC(compiler->size); code = (sljit_u8*)SLJIT_MALLOC_EXEC(compiler->size);
PTR_FAIL_WITH_EXEC_IF(code); PTR_FAIL_WITH_EXEC_IF(code);
buf = compiler->buf; buf = compiler->buf;
code_ptr = code; code_ptr = code;
label = compiler->labels; label = compiler->labels;
jump = compiler->jumps; jump = compiler->jumps;
const_ = compiler->consts; const_ = compiler->consts;
put_label = compiler->put_labels;
executable_offset = SLJIT_EXEC_OFFSET(code); executable_offset = SLJIT_EXEC_OFFSET(code);
do { do {
buf_ptr = buf->memory; buf_ptr = buf->memory;
buf_end = buf_ptr + buf->used_size; buf_end = buf_ptr + buf->used_size;
do { do {
len = *buf_ptr++; len = *buf_ptr++;
if (len > 0) { if (len > 0) {
/* The code is already generated. */ /* The code is already generated. */
SLJIT_MEMCPY(code_ptr, buf_ptr, len); SLJIT_MEMCPY(code_ptr, buf_ptr, len);
code_ptr += len; code_ptr += len;
buf_ptr += len; buf_ptr += len;
} }
else { else {
if (*buf_ptr >= 2) { switch (*buf_ptr) {
case 0:
label->addr = (sljit_uw)SLJIT_ADD_EXEC_OF
FSET(code_ptr, executable_offset);
label->size = code_ptr - code;
label = label->next;
break;
case 1:
jump->addr = (sljit_uw)code_ptr; jump->addr = (sljit_uw)code_ptr;
if (!(jump->flags & SLJIT_REWRITABLE_JUMP )) if (!(jump->flags & SLJIT_REWRITABLE_JUMP ))
code_ptr = generate_near_jump_cod e(jump, code_ptr, code, *buf_ptr - 2, executable_offset); code_ptr = generate_near_jump_cod e(jump, code_ptr, code, executable_offset);
else { else {
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
code_ptr = generate_far_jump_code (jump, code_ptr, *buf_ptr - 2, executable_offset); code_ptr = generate_far_jump_code (jump, code_ptr, executable_offset);
#else #else
code_ptr = generate_far_jump_code (jump, code_ptr, *buf_ptr - 2); code_ptr = generate_far_jump_code (jump, code_ptr);
#endif #endif
} }
jump = jump->next; jump = jump->next;
} break;
else if (*buf_ptr == 0) { case 2:
label->addr = ((sljit_uw)code_ptr) + exec
utable_offset;
label->size = code_ptr - code;
label = label->next;
}
else { /* *buf_ptr is 1 */
const_->addr = ((sljit_uw)code_ptr) - siz eof(sljit_sw); const_->addr = ((sljit_uw)code_ptr) - siz eof(sljit_sw);
const_ = const_->next; const_ = const_->next;
break;
default:
SLJIT_ASSERT(*buf_ptr == 3);
SLJIT_ASSERT(put_label->label);
put_label->addr = (sljit_uw)code_ptr;
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
code_ptr = generate_put_label_code(put_la
bel, code_ptr, (sljit_uw)(SLJIT_ADD_EXEC_OFFSET(code, executable_offset) + put_l
abel->label->size));
#endif
put_label = put_label->next;
break;
} }
buf_ptr++; buf_ptr++;
} }
} while (buf_ptr < buf_end); } while (buf_ptr < buf_end);
SLJIT_ASSERT(buf_ptr == buf_end); SLJIT_ASSERT(buf_ptr == buf_end);
buf = buf->next; buf = buf->next;
} while (buf); } while (buf);
SLJIT_ASSERT(!label); SLJIT_ASSERT(!label);
SLJIT_ASSERT(!jump); SLJIT_ASSERT(!jump);
SLJIT_ASSERT(!const_); SLJIT_ASSERT(!const_);
SLJIT_ASSERT(!put_label);
SLJIT_ASSERT(code_ptr <= code + compiler->size);
jump = compiler->jumps; jump = compiler->jumps;
while (jump) { while (jump) {
jump_addr = jump->addr + executable_offset; jump_addr = jump->addr + executable_offset;
if (jump->flags & PATCH_MB) { if (jump->flags & PATCH_MB) {
SLJIT_ASSERT((sljit_sw)(jump->u.label->addr - (jump_addr + sizeof(sljit_s8))) >= -128 && (sljit_sw)(jump->u.label->addr - (jump_addr + si zeof(sljit_s8))) <= 127); SLJIT_ASSERT((sljit_sw)(jump->u.label->addr - (jump_addr + sizeof(sljit_s8))) >= -128 && (sljit_sw)(jump->u.label->addr - (jump_addr + si zeof(sljit_s8))) <= 127);
*(sljit_u8*)jump->addr = (sljit_u8)(jump->u.label->addr - (jump_addr + sizeof(sljit_s8))); *(sljit_u8*)jump->addr = (sljit_u8)(jump->u.label->addr - (jump_addr + sizeof(sljit_s8)));
} else if (jump->flags & PATCH_MW) { } else if (jump->flags & PATCH_MW) {
if (jump->flags & JUMP_LABEL) { if (jump->flags & JUMP_LABEL) {
skipping to change at line 594 skipping to change at line 611
} }
} }
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
else if (jump->flags & PATCH_MD) else if (jump->flags & PATCH_MD)
sljit_unaligned_store_sw((void*)jump->addr, jump->u.label ->addr); sljit_unaligned_store_sw((void*)jump->addr, jump->u.label ->addr);
#endif #endif
jump = jump->next; jump = jump->next;
} }
/* Some space may be wasted because of short jumps. */ put_label = compiler->put_labels;
SLJIT_ASSERT(code_ptr <= code + compiler->size); while (put_label) {
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
sljit_unaligned_store_sw((void*)(put_label->addr - sizeof(sljit_s
w)), (sljit_sw)put_label->label->addr);
#else
if (put_label->flags & PATCH_MD) {
SLJIT_ASSERT(put_label->label->addr > HALFWORD_MAX);
sljit_unaligned_store_sw((void*)(put_label->addr - sizeof
(sljit_sw)), (sljit_sw)put_label->label->addr);
}
else {
SLJIT_ASSERT(put_label->label->addr <= HALFWORD_MAX);
sljit_unaligned_store_s32((void*)(put_label->addr - sizeo
f(sljit_s32)), (sljit_s32)put_label->label->addr);
}
#endif
put_label = put_label->next;
}
compiler->error = SLJIT_ERR_COMPILED; compiler->error = SLJIT_ERR_COMPILED;
compiler->executable_offset = executable_offset; compiler->executable_offset = executable_offset;
compiler->executable_size = code_ptr - code; compiler->executable_size = code_ptr - code;
return (void*)(code + executable_offset); return (void*)(code + executable_offset);
} }
SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_has_cpu_feature(sljit_s32 feature_type) SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_has_cpu_feature(sljit_s32 feature_type)
{ {
switch (feature_type) { switch (feature_type) {
case SLJIT_HAS_FPU: case SLJIT_HAS_FPU:
skipping to change at line 2484 skipping to change at line 2517
SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile r *compiler, sljit_s32 type) SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile r *compiler, sljit_s32 type)
{ {
sljit_u8 *inst; sljit_u8 *inst;
struct sljit_jump *jump; struct sljit_jump *jump;
CHECK_ERROR_PTR(); CHECK_ERROR_PTR();
CHECK_PTR(check_sljit_emit_jump(compiler, type)); CHECK_PTR(check_sljit_emit_jump(compiler, type));
jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump )); jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump ));
PTR_FAIL_IF_NULL(jump); PTR_FAIL_IF_NULL(jump);
set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP); set_jump(jump, compiler, (type & SLJIT_REWRITABLE_JUMP) | ((type & 0xff) << TYPE_SHIFT));
type &= 0xff; type &= 0xff;
/* Worst case size. */ /* Worst case size. */
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
compiler->size += (type >= SLJIT_JUMP) ? 5 : 6; compiler->size += (type >= SLJIT_JUMP) ? 5 : 6;
#else #else
compiler->size += (type >= SLJIT_JUMP) ? (10 + 3) : (2 + 10 + 3); compiler->size += (type >= SLJIT_JUMP) ? (10 + 3) : (2 + 10 + 3);
#endif #endif
inst = (sljit_u8*)ensure_buf(compiler, 2); inst = (sljit_u8*)ensure_buf(compiler, 2);
PTR_FAIL_IF_NULL(inst); PTR_FAIL_IF_NULL(inst);
*inst++ = 0; *inst++ = 0;
*inst++ = type + 2; *inst++ = 1;
return jump; return jump;
} }
SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_ijump(struct sljit_compiler *compi ler, sljit_s32 type, sljit_s32 src, sljit_sw srcw) SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_ijump(struct sljit_compiler *compi ler, sljit_s32 type, sljit_s32 src, sljit_sw srcw)
{ {
sljit_u8 *inst; sljit_u8 *inst;
struct sljit_jump *jump; struct sljit_jump *jump;
CHECK_ERROR(); CHECK_ERROR();
CHECK(check_sljit_emit_ijump(compiler, type, src, srcw)); CHECK(check_sljit_emit_ijump(compiler, type, src, srcw));
ADJUST_LOCAL_OFFSET(src, srcw); ADJUST_LOCAL_OFFSET(src, srcw);
CHECK_EXTRA_REGS(src, srcw, (void)0); CHECK_EXTRA_REGS(src, srcw, (void)0);
if (src == SLJIT_IMM) { if (src == SLJIT_IMM) {
jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sl jit_jump)); jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sl jit_jump));
FAIL_IF_NULL(jump); FAIL_IF_NULL(jump);
set_jump(jump, compiler, JUMP_ADDR); set_jump(jump, compiler, JUMP_ADDR | (type << TYPE_SHIFT));
jump->u.target = srcw; jump->u.target = srcw;
/* Worst case size. */ /* Worst case size. */
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
compiler->size += 5; compiler->size += 5;
#else #else
compiler->size += 10 + 3; compiler->size += 10 + 3;
#endif #endif
inst = (sljit_u8*)ensure_buf(compiler, 2); inst = (sljit_u8*)ensure_buf(compiler, 2);
FAIL_IF_NULL(inst); FAIL_IF_NULL(inst);
*inst++ = 0; *inst++ = 0;
*inst++ = type + 2; *inst++ = 1;
} }
else { else {
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
/* REX_W is not necessary (src is not immediate). */ /* REX_W is not necessary (src is not immediate). */
compiler->mode32 = 1; compiler->mode32 = 1;
#endif #endif
inst = emit_x86_instruction(compiler, 1, 0, 0, src, srcw); inst = emit_x86_instruction(compiler, 1, 0, 0, src, srcw);
FAIL_IF(!inst); FAIL_IF(!inst);
*inst++ = GROUP_FF; *inst++ = GROUP_FF;
*inst |= (type >= SLJIT_FAST_CALL) ? CALL_rm : JMP_rm; *inst |= (type >= SLJIT_FAST_CALL) ? CALL_rm : JMP_rm;
skipping to change at line 2834 skipping to change at line 2867
return NULL; return NULL;
#else #else
if (emit_mov(compiler, dst, dstw, SLJIT_IMM, init_value)) if (emit_mov(compiler, dst, dstw, SLJIT_IMM, init_value))
return NULL; return NULL;
#endif #endif
inst = (sljit_u8*)ensure_buf(compiler, 2); inst = (sljit_u8*)ensure_buf(compiler, 2);
PTR_FAIL_IF(!inst); PTR_FAIL_IF(!inst);
*inst++ = 0; *inst++ = 0;
*inst++ = 1; *inst++ = 2;
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
if (dst & SLJIT_MEM) if (dst & SLJIT_MEM)
if (emit_mov(compiler, dst, dstw, TMP_REG1, 0)) if (emit_mov(compiler, dst, dstw, TMP_REG1, 0))
return NULL; return NULL;
#endif #endif
return const_; return const_;
} }
SLJIT_API_FUNC_ATTRIBUTE struct sljit_put_label* sljit_emit_put_label(struct slj
it_compiler *compiler, sljit_s32 dst, sljit_sw dstw)
{
struct sljit_put_label *put_label;
sljit_u8 *inst;
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
sljit_s32 reg;
sljit_uw start_size;
#endif
CHECK_ERROR_PTR();
CHECK_PTR(check_sljit_emit_put_label(compiler, dst, dstw));
ADJUST_LOCAL_OFFSET(dst, dstw);
CHECK_EXTRA_REGS(dst, dstw, (void)0);
put_label = (struct sljit_put_label*)ensure_abuf(compiler, sizeof(struct
sljit_put_label));
PTR_FAIL_IF(!put_label);
set_put_label(put_label, compiler, 0);
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
compiler->mode32 = 0;
reg = FAST_IS_REG(dst) ? dst : TMP_REG1;
if (emit_load_imm64(compiler, reg, 0))
return NULL;
#else
if (emit_mov(compiler, dst, dstw, SLJIT_IMM, 0))
return NULL;
#endif
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
if (dst & SLJIT_MEM) {
start_size = compiler->size;
if (emit_mov(compiler, dst, dstw, TMP_REG1, 0))
return NULL;
put_label->flags = compiler->size - start_size;
}
#endif
inst = (sljit_u8*)ensure_buf(compiler, 2);
PTR_FAIL_IF(!inst);
*inst++ = 0;
*inst++ = 3;
return put_label;
}
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_ta rget, sljit_sw executable_offset) SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_ta rget, sljit_sw executable_offset)
{ {
SLJIT_UNUSED_ARG(executable_offset); SLJIT_UNUSED_ARG(executable_offset);
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
sljit_unaligned_store_sw((void*)addr, new_target - (addr + 4) - (sljit_uw )executable_offset); sljit_unaligned_store_sw((void*)addr, new_target - (addr + 4) - (sljit_uw )executable_offset);
#else #else
sljit_unaligned_store_sw((void*)addr, (sljit_sw) new_target); sljit_unaligned_store_sw((void*)addr, (sljit_sw) new_target);
#endif #endif
} }
 End of changes. 21 change blocks. 
24 lines changed or deleted 113 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)