diff options
author | zherczeg <zherczeg@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2011-12-01 15:15:31 +0000 |
---|---|---|
committer | zherczeg <zherczeg@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2011-12-01 15:15:31 +0000 |
commit | a5b453e62eb0aa93248d87650fd7bcf6b8153c17 (patch) | |
tree | 3502ffe4b812ebdd13fcb714375f094c3ed81d51 | |
parent | e3827e39b49ae5a5095aa7964cc9d3dde6ccdf5c (diff) | |
download | pcre-a5b453e62eb0aa93248d87650fd7bcf6b8153c17.tar.gz |
Retrieve executable code size support for the JIT compiler and fixing some warnings.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@777 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | sljit/sljitConfigInternal.h | 4 | ||||
-rw-r--r-- | sljit/sljitExecAllocator.c | 4 | ||||
-rw-r--r-- | sljit/sljitLir.h | 11 | ||||
-rw-r--r-- | sljit/sljitNativeARM_Thumb2.c | 1 | ||||
-rw-r--r-- | sljit/sljitNativeARM_v5.c | 1 | ||||
-rw-r--r-- | sljit/sljitNativeMIPS_common.c | 1 | ||||
-rw-r--r-- | sljit/sljitNativePPC_common.c | 1 | ||||
-rw-r--r-- | sljit/sljitNativeX86_common.c | 15 |
9 files changed, 30 insertions, 11 deletions
@@ -87,6 +87,9 @@ Version 8.21 19. If the /S+ option was used in pcretest to study a pattern using JIT, subsequent uses of /S (without +) incorrectly behaved like /S+. +21. Retrieve executable code size support for the JIT compiler and fixing + some warnings. + Version 8.20 21-Oct-2011 ------------------------ diff --git a/sljit/sljitConfigInternal.h b/sljit/sljitConfigInternal.h index b0750d3..ad0be19 100644 --- a/sljit/sljitConfigInternal.h +++ b/sljit/sljitConfigInternal.h @@ -354,8 +354,8 @@ typedef long int sljit_w; #endif /* !SLJIT_UNALIGNED */ #if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR) -void* sljit_malloc_exec(sljit_uw size); -void sljit_free_exec(void* ptr); +SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size); +SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr); #define SLJIT_MALLOC_EXEC(size) sljit_malloc_exec(size) #define SLJIT_FREE_EXEC(ptr) sljit_free_exec(ptr) #endif diff --git a/sljit/sljitExecAllocator.c b/sljit/sljitExecAllocator.c index f3567b2..cdea346 100644 --- a/sljit/sljitExecAllocator.c +++ b/sljit/sljitExecAllocator.c @@ -163,7 +163,7 @@ static SLJIT_INLINE void sljit_remove_free_block(struct free_block *free_block) } } -void* sljit_malloc_exec(sljit_uw size) +SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size) { struct block_header *header; struct block_header *next_header; @@ -231,7 +231,7 @@ void* sljit_malloc_exec(sljit_uw size) return MEM_START(header); } -void sljit_free_exec(void* ptr) +SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr) { struct block_header *header; struct free_block* free_block; diff --git a/sljit/sljitLir.h b/sljit/sljitLir.h index 2a82968..54906bc 100644 --- a/sljit/sljitLir.h +++ b/sljit/sljitLir.h @@ -195,6 +195,8 @@ struct sljit_compiler { int local_size; /* Code size. */ sljit_uw size; + /* For statistical purposes. */ + sljit_uw executable_size; #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) int args; @@ -291,6 +293,15 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_compiler_verbose(struct sljit_compiler *comp SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler); SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code); +/* + After the code generation we can retrieve the allocated executable memory size, + although this area may not be fully filled with instructions depending on some + optimizations. This function is useful only for statistical purposes. + + Before a successful code generation, this function returns with 0. +*/ +static SLJIT_INLINE sljit_uw sljit_get_generated_code_size(struct sljit_compiler *compiler) { return compiler->executable_size; } + /* Instruction generation. Returns with error code. */ /* diff --git a/sljit/sljitNativeARM_Thumb2.c b/sljit/sljitNativeARM_Thumb2.c index c476711..3764aeb 100644 --- a/sljit/sljitNativeARM_Thumb2.c +++ b/sljit/sljitNativeARM_Thumb2.c @@ -416,6 +416,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil SLJIT_CACHE_FLUSH(code, code_ptr); compiler->error = SLJIT_ERR_COMPILED; + compiler->executable_size = compiler->size * sizeof(sljit_uh); /* Set thumb mode flag. */ return (void*)((sljit_uw)code | 0x1); } diff --git a/sljit/sljitNativeARM_v5.c b/sljit/sljitNativeARM_v5.c index 1b40afa..99584cf 100644 --- a/sljit/sljitNativeARM_v5.c +++ b/sljit/sljitNativeARM_v5.c @@ -788,6 +788,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil SLJIT_CACHE_FLUSH(code, code_ptr); compiler->error = SLJIT_ERR_COMPILED; + compiler->executable_size = size * sizeof(sljit_uw); return code; } diff --git a/sljit/sljitNativeMIPS_common.c b/sljit/sljitNativeMIPS_common.c index c4fe152..7fcb6d6 100644 --- a/sljit/sljitNativeMIPS_common.c +++ b/sljit/sljitNativeMIPS_common.c @@ -397,6 +397,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil } compiler->error = SLJIT_ERR_COMPILED; + compiler->executable_size = compiler->size * sizeof(sljit_ins); #ifndef __GNUC__ SLJIT_CACHE_FLUSH(code, code_ptr); #else diff --git a/sljit/sljitNativePPC_common.c b/sljit/sljitNativePPC_common.c index af14b75..28afd9e 100644 --- a/sljit/sljitNativePPC_common.c +++ b/sljit/sljitNativePPC_common.c @@ -354,6 +354,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil SLJIT_CACHE_FLUSH(code, code_ptr); compiler->error = SLJIT_ERR_COMPILED; + compiler->executable_size = compiler->size * sizeof(sljit_ins); #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) if (((sljit_w)code_ptr) & 0x4) diff --git a/sljit/sljitNativeX86_common.c b/sljit/sljitNativeX86_common.c index c6661bc..cc215a2 100644 --- a/sljit/sljitNativeX86_common.c +++ b/sljit/sljitNativeX86_common.c @@ -357,22 +357,22 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil while (jump) { if (jump->flags & PATCH_MB) { SLJIT_ASSERT((sljit_w)(jump->u.label->addr - (jump->addr + sizeof(sljit_b))) >= -128 && (sljit_w)(jump->u.label->addr - (jump->addr + sizeof(sljit_b))) <= 127); - *(sljit_ub*)jump->addr = jump->u.label->addr - (jump->addr + sizeof(sljit_b)); + *(sljit_ub*)jump->addr = (sljit_ub)(jump->u.label->addr - (jump->addr + sizeof(sljit_b))); } else if (jump->flags & PATCH_MW) { if (jump->flags & JUMP_LABEL) { #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) - *(sljit_w*)jump->addr = jump->u.label->addr - (jump->addr + sizeof(sljit_w)); + *(sljit_w*)jump->addr = (sljit_w)(jump->u.label->addr - (jump->addr + sizeof(sljit_w))); #else SLJIT_ASSERT((sljit_w)(jump->u.label->addr - (jump->addr + sizeof(sljit_hw))) >= -0x80000000ll && (sljit_w)(jump->u.label->addr - (jump->addr + sizeof(sljit_hw))) <= 0x7fffffffll); - *(sljit_hw*)jump->addr = jump->u.label->addr - (jump->addr + sizeof(sljit_hw)); + *(sljit_hw*)jump->addr = (sljit_hw)(jump->u.label->addr - (jump->addr + sizeof(sljit_hw))); #endif } else { #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) - *(sljit_w*)jump->addr = jump->u.target - (jump->addr + sizeof(sljit_w)); + *(sljit_w*)jump->addr = (sljit_w)(jump->u.target - (jump->addr + sizeof(sljit_w))); #else SLJIT_ASSERT((sljit_w)(jump->u.target - (jump->addr + sizeof(sljit_hw))) >= -0x80000000ll && (sljit_w)(jump->u.target - (jump->addr + sizeof(sljit_hw))) <= 0x7fffffffll); - *(sljit_hw*)jump->addr = jump->u.target - (jump->addr + sizeof(sljit_hw)); + *(sljit_hw*)jump->addr = (sljit_hw)(jump->u.target - (jump->addr + sizeof(sljit_hw))); #endif } } @@ -387,6 +387,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil /* Maybe we waste some space because of short jumps. */ SLJIT_ASSERT(code_ptr <= code + compiler->size); compiler->error = SLJIT_ERR_COMPILED; + compiler->executable_size = compiler->size; return (void*)code; } @@ -1360,7 +1361,7 @@ static int emit_mul(struct sljit_compiler *compiler, code = (sljit_ub*)ensure_buf(compiler, 1 + 4); FAIL_IF(!code); INC_CSIZE(4); - *(sljit_hw*)code = src1w; + *(sljit_hw*)code = (sljit_hw)src1w; } else { EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_IMM, src1w); @@ -1403,7 +1404,7 @@ static int emit_mul(struct sljit_compiler *compiler, code = (sljit_ub*)ensure_buf(compiler, 1 + 4); FAIL_IF(!code); INC_CSIZE(4); - *(sljit_hw*)code = src2w; + *(sljit_hw*)code = (sljit_hw)src2w; } else { EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_IMM, src1w); |