diff options
author | zherczeg <zherczeg@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2011-10-31 06:10:14 +0000 |
---|---|---|
committer | zherczeg <zherczeg@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2011-10-31 06:10:14 +0000 |
commit | a29ff98c9e8af311491720b4b61281ee707dafc2 (patch) | |
tree | 96f2cce4e694baf7cb26309ac8ab468db41da204 /sljit/sljitLir.c | |
parent | adb232d7233c9a3e8d4bde718215395f937e8fb2 (diff) | |
download | pcre-a29ff98c9e8af311491720b4b61281ee707dafc2.tar.gz |
Updating the JIT compiler
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@740 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'sljit/sljitLir.c')
-rw-r--r-- | sljit/sljitLir.c | 121 |
1 files changed, 51 insertions, 70 deletions
diff --git a/sljit/sljitLir.c b/sljit/sljitLir.c index dcc82c4..592aa0e 100644 --- a/sljit/sljitLir.c +++ b/sljit/sljitLir.c @@ -192,24 +192,22 @@ static int compiler_initialized = 0; static void init_compiler(void); #endif -struct sljit_compiler* sljit_create_compiler(void) -{ - struct sljit_compiler *compiler = (struct sljit_compiler*)SLJIT_MALLOC(sizeof(struct sljit_compiler)); - /* Compile time assert. */ - SLJIT_CONST int minus1[sizeof(sljit_b) == 1 && sizeof(sljit_h) == 2 && - sizeof(sljit_i) == 4 && (sizeof(sljit_w) == 4 || sizeof(sljit_w) == 8) ? 1 : -1] = { -1 }; +SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void) +{ + struct sljit_compiler *compiler = (struct sljit_compiler*)SLJIT_MALLOC_ZEROED(sizeof(struct sljit_compiler)); if (!compiler) return NULL; - compiler->error = SLJIT_SUCCESS; + SLJIT_COMPILE_ASSERT( + sizeof(sljit_b) == 1 && sizeof(sljit_ub) == 1 + && sizeof(sljit_h) == 2 && sizeof(sljit_uh) == 2 + && sizeof(sljit_i) == 4 && sizeof(sljit_ui) == 4 + && ((sizeof(sljit_w) == 4 && sizeof(sljit_uw) == 4) || (sizeof(sljit_w) == 8 && sizeof(sljit_uw) == 8)), + invalid_integer_types); - compiler->labels = NULL; - compiler->jumps = NULL; - compiler->consts = NULL; - compiler->last_label = NULL; - compiler->last_jump = NULL; - compiler->last_const = NULL; + /* Only the non-zero members must be set. */ + compiler->error = SLJIT_SUCCESS; compiler->buf = (struct sljit_memory_fragment*)SLJIT_MALLOC(BUF_SIZE); compiler->abuf = (struct sljit_memory_fragment*)SLJIT_MALLOC(ABUF_SIZE); @@ -228,19 +226,13 @@ struct sljit_compiler* sljit_create_compiler(void) compiler->abuf->next = NULL; compiler->abuf->used_size = 0; - compiler->temporaries = minus1[0]; - compiler->generals = minus1[0]; - compiler->local_size = 0; - compiler->size = 0; + compiler->temporaries = -1; + compiler->generals = -1; #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) compiler->args = -1; #endif -#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) - compiler->flags_saved = 0; -#endif - #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) compiler->cpool = (sljit_uw*)SLJIT_MALLOC(CPOOL_SIZE * sizeof(sljit_uw) + CPOOL_SIZE * sizeof(sljit_ub)); if (!compiler->cpool) { @@ -251,23 +243,12 @@ struct sljit_compiler* sljit_create_compiler(void) } compiler->cpool_unique = (sljit_ub*)(compiler->cpool + CPOOL_SIZE); compiler->cpool_diff = 0xffffffff; - compiler->cpool_fill = 0; - compiler->patches = 0; #endif #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) - compiler->has_locals = 0; compiler->delay_slot = UNMOVABLE_INS; #endif -#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) - compiler->verbose = NULL; -#endif - -#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG) - compiler->skip_checks = 0; -#endif - #if (defined SLJIT_NEEDS_COMPILER_INIT && SLJIT_NEEDS_COMPILER_INIT) if (!compiler_initialized) { init_compiler(); @@ -278,7 +259,7 @@ struct sljit_compiler* sljit_create_compiler(void) return compiler; } -void sljit_free_compiler(struct sljit_compiler *compiler) +SLJIT_API_FUNC_ATTRIBUTE void sljit_free_compiler(struct sljit_compiler *compiler) { struct sljit_memory_fragment *buf; struct sljit_memory_fragment *curr; @@ -304,26 +285,26 @@ void sljit_free_compiler(struct sljit_compiler *compiler) } #if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) -void sljit_free_code(void* code) +SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code) { /* Remove thumb mode flag. */ SLJIT_FREE_EXEC((void*)((sljit_uw)code & ~0x1)); } #elif (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) -void sljit_free_code(void* code) +SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code) { /* Resolve indirection. */ code = (void*)(*(sljit_uw*)code); SLJIT_FREE_EXEC(code); } #else -void sljit_free_code(void* code) +SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code) { SLJIT_FREE_EXEC(code); } #endif -void sljit_set_label(struct sljit_jump *jump, struct sljit_label* label) +SLJIT_API_FUNC_ATTRIBUTE void sljit_set_label(struct sljit_jump *jump, struct sljit_label* label) { if (SLJIT_LIKELY(!!jump) && SLJIT_LIKELY(!!label)) { jump->flags &= ~JUMP_ADDR; @@ -332,7 +313,7 @@ void sljit_set_label(struct sljit_jump *jump, struct sljit_label* label) } } -void sljit_set_target(struct sljit_jump *jump, sljit_uw target) +SLJIT_API_FUNC_ATTRIBUTE void sljit_set_target(struct sljit_jump *jump, sljit_uw target) { if (SLJIT_LIKELY(!!jump)) { SLJIT_ASSERT(jump->flags & SLJIT_REWRITABLE_JUMP); @@ -383,7 +364,7 @@ static void* ensure_abuf(struct sljit_compiler *compiler, int size) return new_frag->memory; } -void* sljit_alloc_memory(struct sljit_compiler *compiler, int size) +SLJIT_API_FUNC_ATTRIBUTE void* sljit_alloc_memory(struct sljit_compiler *compiler, int size) { CHECK_ERROR_PTR(); @@ -448,7 +429,7 @@ static SLJIT_INLINE void set_const(struct sljit_const *const_, struct sljit_comp compiler->last_const = const_; } -#define depends_on(exp, reg) \ +#define ADDRESSING_DEPENDS_ON(exp, reg) \ (((exp) & SLJIT_MEM) && (((exp) & 0xf) == reg || (((exp) >> 4) & 0xf) == reg)) #if (defined SLJIT_DEBUG && SLJIT_DEBUG) @@ -563,7 +544,7 @@ static SLJIT_INLINE void set_const(struct sljit_const *const_, struct sljit_comp #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) -void sljit_compiler_verbose(struct sljit_compiler *compiler, FILE* verbose) +SLJIT_API_FUNC_ATTRIBUTE void sljit_compiler_verbose(struct sljit_compiler *compiler, FILE* verbose) { compiler->verbose = verbose; } @@ -1104,7 +1085,7 @@ static SLJIT_INLINE void check_sljit_emit_const(struct sljit_compiler *compiler, #endif #if !(defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) -struct sljit_jump* sljit_emit_cmp(struct sljit_compiler *compiler, int type, +SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler *compiler, int type, int src1, sljit_w src1w, int src2, sljit_w src2w) { @@ -1176,24 +1157,24 @@ struct sljit_jump* sljit_emit_cmp(struct sljit_compiler *compiler, int type, /* Empty function bodies for those machines, which are not (yet) supported. */ -SLJIT_CONST char* sljit_get_platform_name() +SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name() { return "unsupported"; } -struct sljit_compiler* sljit_create_compiler(void) +SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void) { SLJIT_ASSERT_STOP(); return NULL; } -void sljit_free_compiler(struct sljit_compiler *compiler) +SLJIT_API_FUNC_ATTRIBUTE void sljit_free_compiler(struct sljit_compiler *compiler) { SLJIT_UNUSED_ARG(compiler); SLJIT_ASSERT_STOP(); } -void* sljit_alloc_memory(struct sljit_compiler *compiler, int size) +SLJIT_API_FUNC_ATTRIBUTE void* sljit_alloc_memory(struct sljit_compiler *compiler, int size) { SLJIT_UNUSED_ARG(compiler); SLJIT_UNUSED_ARG(size); @@ -1202,7 +1183,7 @@ void* sljit_alloc_memory(struct sljit_compiler *compiler, int size) } #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) -void sljit_compiler_verbose(struct sljit_compiler *compiler, FILE* verbose) +SLJIT_API_FUNC_ATTRIBUTE void sljit_compiler_verbose(struct sljit_compiler *compiler, FILE* verbose) { SLJIT_UNUSED_ARG(compiler); SLJIT_UNUSED_ARG(verbose); @@ -1210,20 +1191,20 @@ void sljit_compiler_verbose(struct sljit_compiler *compiler, FILE* verbose) } #endif -void* sljit_generate_code(struct sljit_compiler *compiler) +SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler) { SLJIT_UNUSED_ARG(compiler); SLJIT_ASSERT_STOP(); return NULL; } -void sljit_free_code(void* code) +SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code) { SLJIT_UNUSED_ARG(code); SLJIT_ASSERT_STOP(); } -int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, int generals, int local_size) +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, int generals, int local_size) { SLJIT_UNUSED_ARG(compiler); SLJIT_UNUSED_ARG(args); @@ -1234,7 +1215,7 @@ int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, return SLJIT_ERR_UNSUPPORTED; } -void sljit_fake_enter(struct sljit_compiler *compiler, int args, int temporaries, int generals, int local_size) +SLJIT_API_FUNC_ATTRIBUTE void sljit_fake_enter(struct sljit_compiler *compiler, int args, int temporaries, int generals, int local_size) { SLJIT_UNUSED_ARG(compiler); SLJIT_UNUSED_ARG(args); @@ -1244,7 +1225,7 @@ void sljit_fake_enter(struct sljit_compiler *compiler, int args, int temporaries SLJIT_ASSERT_STOP(); } -int sljit_emit_return(struct sljit_compiler *compiler, int src, sljit_w srcw) +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int src, sljit_w srcw) { SLJIT_UNUSED_ARG(compiler); SLJIT_UNUSED_ARG(src); @@ -1253,7 +1234,7 @@ int sljit_emit_return(struct sljit_compiler *compiler, int src, sljit_w srcw) return SLJIT_ERR_UNSUPPORTED; } -int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw, int args, int temporaries, int generals, int local_size) +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw, int args, int temporaries, int generals, int local_size) { SLJIT_UNUSED_ARG(compiler); SLJIT_UNUSED_ARG(dst); @@ -1266,7 +1247,7 @@ int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw return SLJIT_ERR_UNSUPPORTED; } -int sljit_emit_fast_return(struct sljit_compiler *compiler, int src, sljit_w srcw) +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_return(struct sljit_compiler *compiler, int src, sljit_w srcw) { SLJIT_UNUSED_ARG(compiler); SLJIT_UNUSED_ARG(src); @@ -1275,7 +1256,7 @@ int sljit_emit_fast_return(struct sljit_compiler *compiler, int src, sljit_w src return SLJIT_ERR_UNSUPPORTED; } -int sljit_emit_op0(struct sljit_compiler *compiler, int op) +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op0(struct sljit_compiler *compiler, int op) { SLJIT_UNUSED_ARG(compiler); SLJIT_UNUSED_ARG(op); @@ -1283,7 +1264,7 @@ int sljit_emit_op0(struct sljit_compiler *compiler, int op) return SLJIT_ERR_UNSUPPORTED; } -int sljit_emit_op1(struct sljit_compiler *compiler, int op, +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op1(struct sljit_compiler *compiler, int op, int dst, sljit_w dstw, int src, sljit_w srcw) { @@ -1297,7 +1278,7 @@ int sljit_emit_op1(struct sljit_compiler *compiler, int op, return SLJIT_ERR_UNSUPPORTED; } -int sljit_emit_op2(struct sljit_compiler *compiler, int op, +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op2(struct sljit_compiler *compiler, int op, int dst, sljit_w dstw, int src1, sljit_w src1w, int src2, sljit_w src2w) @@ -1314,13 +1295,13 @@ int sljit_emit_op2(struct sljit_compiler *compiler, int op, return SLJIT_ERR_UNSUPPORTED; } -int sljit_is_fpu_available(void) +SLJIT_API_FUNC_ATTRIBUTE int sljit_is_fpu_available(void) { SLJIT_ASSERT_STOP(); return 0; } -int sljit_emit_fop1(struct sljit_compiler *compiler, int op, +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop1(struct sljit_compiler *compiler, int op, int dst, sljit_w dstw, int src, sljit_w srcw) { @@ -1334,7 +1315,7 @@ int sljit_emit_fop1(struct sljit_compiler *compiler, int op, return SLJIT_ERR_UNSUPPORTED; } -int sljit_emit_fop2(struct sljit_compiler *compiler, int op, +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop2(struct sljit_compiler *compiler, int op, int dst, sljit_w dstw, int src1, sljit_w src1w, int src2, sljit_w src2w) @@ -1351,14 +1332,14 @@ int sljit_emit_fop2(struct sljit_compiler *compiler, int op, return SLJIT_ERR_UNSUPPORTED; } -struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) +SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) { SLJIT_UNUSED_ARG(compiler); SLJIT_ASSERT_STOP(); return NULL; } -struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, int type) +SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, int type) { SLJIT_UNUSED_ARG(compiler); SLJIT_UNUSED_ARG(type); @@ -1366,7 +1347,7 @@ struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, int type) return NULL; } -struct sljit_jump* sljit_emit_cmp(struct sljit_compiler *compiler, int type, +SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler *compiler, int type, int src1, sljit_w src1w, int src2, sljit_w src2w) { @@ -1380,21 +1361,21 @@ struct sljit_jump* sljit_emit_cmp(struct sljit_compiler *compiler, int type, return NULL; } -void sljit_set_label(struct sljit_jump *jump, struct sljit_label* label) +SLJIT_API_FUNC_ATTRIBUTE void sljit_set_label(struct sljit_jump *jump, struct sljit_label* label) { SLJIT_UNUSED_ARG(jump); SLJIT_UNUSED_ARG(label); SLJIT_ASSERT_STOP(); } -void sljit_set_target(struct sljit_jump *jump, sljit_uw target) +SLJIT_API_FUNC_ATTRIBUTE void sljit_set_target(struct sljit_jump *jump, sljit_uw target) { SLJIT_UNUSED_ARG(jump); SLJIT_UNUSED_ARG(target); SLJIT_ASSERT_STOP(); } -int sljit_emit_ijump(struct sljit_compiler *compiler, int type, int src, sljit_w srcw) +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ijump(struct sljit_compiler *compiler, int type, int src, sljit_w srcw) { SLJIT_UNUSED_ARG(compiler); SLJIT_UNUSED_ARG(type); @@ -1404,7 +1385,7 @@ int sljit_emit_ijump(struct sljit_compiler *compiler, int type, int src, sljit_w return SLJIT_ERR_UNSUPPORTED; } -int sljit_emit_cond_value(struct sljit_compiler *compiler, int op, int dst, sljit_w dstw, int type) +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_cond_value(struct sljit_compiler *compiler, int op, int dst, sljit_w dstw, int type) { SLJIT_UNUSED_ARG(compiler); SLJIT_UNUSED_ARG(op); @@ -1415,7 +1396,7 @@ int sljit_emit_cond_value(struct sljit_compiler *compiler, int op, int dst, slji return SLJIT_ERR_UNSUPPORTED; } -struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w initval) +SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w initval) { SLJIT_UNUSED_ARG(compiler); SLJIT_UNUSED_ARG(dst); @@ -1425,14 +1406,14 @@ struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, s return NULL; } -void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_addr) +SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_addr) { SLJIT_UNUSED_ARG(addr); SLJIT_UNUSED_ARG(new_addr); SLJIT_ASSERT_STOP(); } -void sljit_set_const(sljit_uw addr, sljit_w new_constant) +SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_w new_constant) { SLJIT_UNUSED_ARG(addr); SLJIT_UNUSED_ARG(new_constant); |