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 | |
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
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | sljit/sljitConfigInternal.h | 30 | ||||
-rw-r--r-- | sljit/sljitLir.c | 121 | ||||
-rw-r--r-- | sljit/sljitLir.h | 71 | ||||
-rw-r--r-- | sljit/sljitNativeARM_Thumb2.c | 40 | ||||
-rw-r--r-- | sljit/sljitNativeARM_v5.c | 42 | ||||
-rw-r--r-- | sljit/sljitNativeMIPS_32.c | 4 | ||||
-rw-r--r-- | sljit/sljitNativeMIPS_common.c | 40 | ||||
-rw-r--r-- | sljit/sljitNativePPC_32.c | 4 | ||||
-rw-r--r-- | sljit/sljitNativePPC_64.c | 6 | ||||
-rw-r--r-- | sljit/sljitNativePPC_common.c | 36 | ||||
-rw-r--r-- | sljit/sljitNativeX86_32.c | 10 | ||||
-rw-r--r-- | sljit/sljitNativeX86_64.c | 83 | ||||
-rw-r--r-- | sljit/sljitNativeX86_common.c | 44 | ||||
-rw-r--r-- | sljit/sljitUtils.c | 16 |
15 files changed, 298 insertions, 255 deletions
@@ -1,6 +1,12 @@ ChangeLog for PCRE ------------------ +Version 8.21 +------------ + +1. Updating the JIT compiler. + + Version 8.20 21-Oct-2011 ------------------------ diff --git a/sljit/sljitConfigInternal.h b/sljit/sljitConfigInternal.h index e82bed7..8ba1bb8 100644 --- a/sljit/sljitConfigInternal.h +++ b/sljit/sljitConfigInternal.h @@ -129,6 +129,7 @@ /* General allocation. */ #define SLJIT_MALLOC(size) malloc(size) +#define SLJIT_MALLOC_ZEROED(size) calloc((size), 1) #define SLJIT_FREE(ptr) free(ptr) #define SLJIT_MEMMOVE(dest, src, len) memmove(dest, src, len) @@ -161,6 +162,20 @@ #define SLJIT_UNUSED_ARG(arg) (void)arg #endif +#if (defined SLJIT_CONFIG_STATIC && SLJIT_CONFIG_STATIC) +/* Static ABI functions. For all-in-one programs. */ + +#if defined(__GNUC__) +/* Disable unused warnings in gcc. */ +#define SLJIT_API_FUNC_ATTRIBUTE static __attribute__((unused)) +#else +#define SLJIT_API_FUNC_ATTRIBUTE static +#endif + +#else +#define SLJIT_API_FUNC_ATTRIBUTE +#endif /* (defined SLJIT_CONFIG_STATIC && SLJIT_CONFIG_STATIC) */ + #ifndef SLJIT_CACHE_FLUSH #if !(defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) && !(defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) @@ -332,11 +347,14 @@ void sljit_free_exec(void* ptr); /* Feel free to redefine these two macros. */ #ifndef SLJIT_ASSERT +#define SLJIT_HALT_PROCESS() \ + *((int*)0) = 0 + #define SLJIT_ASSERT(x) \ do { \ if (SLJIT_UNLIKELY(!(x))) { \ printf("Assertion failed at " __FILE__ ":%d\n", __LINE__); \ - *((int*)0) = 0; \ + SLJIT_HALT_PROCESS(); \ } \ } while (0) @@ -347,7 +365,7 @@ void sljit_free_exec(void* ptr); #define SLJIT_ASSERT_STOP() \ do { \ printf("Should never been reached " __FILE__ ":%d\n", __LINE__); \ - *((int*)0) = 0; \ + SLJIT_HALT_PROCESS(); \ } while (0) #endif /* !SLJIT_ASSERT_STOP */ @@ -364,4 +382,12 @@ void sljit_free_exec(void* ptr); #endif /* (defined SLJIT_DEBUG && SLJIT_DEBUG) */ +#ifndef SLJIT_COMPILE_ASSERT + +/* Should be improved eventually. */ +#define SLJIT_COMPILE_ASSERT(x, description) \ + SLJIT_ASSERT(x) + +#endif /* !SLJIT_COMPILE_ASSERT */ + #endif 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); diff --git a/sljit/sljitLir.h b/sljit/sljitLir.h index 9502f14..f519a4e 100644 --- a/sljit/sljitLir.h +++ b/sljit/sljitLir.h @@ -199,6 +199,9 @@ struct sljit_compiler { #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) int mode32; +#ifdef _WIN64 + int has_locals; +#endif #endif #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) @@ -257,9 +260,9 @@ struct sljit_compiler { /* Creates an sljit compiler. Returns NULL if failed. */ -struct sljit_compiler* sljit_create_compiler(void); +SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void); /* Free everything except the codes. */ -void sljit_free_compiler(struct sljit_compiler *compiler); +SLJIT_API_FUNC_ATTRIBUTE void sljit_free_compiler(struct sljit_compiler *compiler); static SLJIT_INLINE int sljit_get_compiler_error(struct sljit_compiler *compiler) { return compiler->error; } @@ -273,15 +276,15 @@ static SLJIT_INLINE int sljit_get_compiler_error(struct sljit_compiler *compiler but this return value does not indicate that there is no more memory (does not set the compiler to out-of-memory status). */ -void* sljit_alloc_memory(struct sljit_compiler *compiler, int size); +SLJIT_API_FUNC_ATTRIBUTE void* sljit_alloc_memory(struct sljit_compiler *compiler, int size); #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) /* Passing NULL disables 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); #endif -void* sljit_generate_code(struct sljit_compiler *compiler); -void sljit_free_code(void* code); +SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler); +SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code); /* Instruction generation. Returns with error code. */ @@ -302,7 +305,7 @@ void sljit_free_code(void* code); #define SLJIT_MAX_LOCAL_SIZE 65536 -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); /* Since sljit_emit_return (and many asserts) uses variables which are initialized by sljit_emit_enter, a simple return is not possible if these variables are not @@ -311,10 +314,10 @@ int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, /* Note: multiple calls of this function overwrites the previous call. */ -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); /* Return from jit. See below the possible values for src and srcw. */ -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); /* Really fast calling method for utility functions inside sljit (see SLJIT_FAST_CALL). All registers and even the stack frame is passed to the callee. The return address is @@ -331,8 +334,8 @@ int sljit_emit_return(struct sljit_compiler *compiler, int src, sljit_w srcw); /* Note: although sljit_emit_fast_return could be replaced by an ijump, it is not suggested, since many architectures do clever branch prediction on call / return instruction pairs. */ -int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw, int args, int temporaries, int generals, int local_size); -int sljit_emit_fast_return(struct sljit_compiler *compiler, int src, sljit_w srcw); +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_API_FUNC_ATTRIBUTE int sljit_emit_fast_return(struct sljit_compiler *compiler, int src, sljit_w srcw); /* Source and destination values for arithmetical instructions @@ -427,7 +430,7 @@ int sljit_emit_fast_return(struct sljit_compiler *compiler, int src, sljit_w src it can even decrease the runtime in a few cases. */ #define SLJIT_NOP 1 -int sljit_emit_op0(struct sljit_compiler *compiler, int op); +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op0(struct sljit_compiler *compiler, int op); /* Notes for MOV instructions: U = Mov with update (post form). If source or destination defined as SLJIT_MEM1(r1) @@ -473,7 +476,7 @@ int sljit_emit_op0(struct sljit_compiler *compiler, int op); Flags: I | E | K */ #define SLJIT_CLZ 18 -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); @@ -501,12 +504,12 @@ int sljit_emit_op1(struct sljit_compiler *compiler, int op, /* Flags: I | E | K */ #define SLJIT_ASHR 29 -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); -int sljit_is_fpu_available(void); +SLJIT_API_FUNC_ATTRIBUTE int sljit_is_fpu_available(void); /* Note: dst is the left and src is the right operand for SLJIT_FCMP. Note: NaN check is always performed. If SLJIT_C_FLOAT_NAN is set, @@ -520,7 +523,7 @@ int sljit_is_fpu_available(void); /* Flags: - (never set any flags) */ #define SLJIT_FABS 33 -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); @@ -533,14 +536,14 @@ int sljit_emit_fop1(struct sljit_compiler *compiler, int op, /* Flags: - (never set any flags) */ #define SLJIT_FDIV 37 -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); /* Label and jump instructions. */ -struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler); +SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler); /* Invert conditional instruction: xor (^) with 0x1 */ #define SLJIT_C_EQUAL 0 @@ -589,7 +592,7 @@ struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler); type can be combined (or'ed) with SLJIT_REWRITABLE_JUMP Flags: - (never set any flags) for both conditional and unconditional jumps. Flags: destroy all flags for calls. */ -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); /* Basic arithmetic comparison. In most architectures it is equal to an SLJIT_SUB operation (with SLJIT_UNUSED destination) followed by a @@ -599,15 +602,15 @@ struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, int type); type must be between SLJIT_C_EQUAL and SLJIT_C_SIG_LESS_EQUAL type can be combined (or'ed) with SLJIT_REWRITABLE_JUMP or SLJIT_INT_OP Flags: destroy flags. */ -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); /* Set the destination of the jump to this label. */ -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); /* Only for jumps defined with SLJIT_REWRITABLE_JUMP flag. Note: use sljit_emit_ijump for fixed jumps. */ -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); /* Call function or jump anywhere. Both direct and indirect form type must be between SLJIT_JUMP and SLJIT_CALL3 @@ -615,7 +618,7 @@ void sljit_set_target(struct sljit_jump *jump, sljit_uw target); Indirect form: any other valid addressing mode Flags: - (never set any flags) for unconditional jumps. Flags: destroy all flags for calls. */ -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); /* If op == SLJIT_MOV: Set dst to 1 if condition is fulfilled, 0 otherwise @@ -626,11 +629,11 @@ int sljit_emit_ijump(struct sljit_compiler *compiler, int type, int src, sljit_w the condition is fulfilled. Otherwise it does nothing. Flags: E | K Note: sljit_emit_cond_value does nothing, if dst is SLJIT_UNUSED (regardless of op). */ -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); /* The constant can be changed runtime (see: sljit_set_const) Flags: - (never set any flags) */ -struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w init_value); +SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w init_value); /* After the code generation the address for label, jump and const instructions are computed. Since these structures are freed sljit_free_compiler, the @@ -640,8 +643,8 @@ static SLJIT_INLINE sljit_uw sljit_get_jump_addr(struct sljit_jump *jump) { retu static SLJIT_INLINE sljit_uw sljit_get_const_addr(struct sljit_const *const_) { return const_->addr; } /* Only the address is required to rewrite the code. */ -void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_addr); -void sljit_set_const(sljit_uw addr, sljit_w new_constant); +SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_addr); +SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_w new_constant); /* --------------------------------------------------------------------- */ /* Miscellaneous utility functions */ @@ -653,15 +656,15 @@ void sljit_set_const(sljit_uw addr, sljit_w new_constant); /* Get the human readable name of the platfrom. Can be useful for debugging on platforms like ARM, where ARM and Thumb2 functions can be mixed. */ -SLJIT_CONST char* sljit_get_platform_name(void); +SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name(void); /* Portble helper function to get an offset of a member. */ #define SLJIT_OFFSETOF(base, member) ((sljit_w)(&((base*)0x10)->member) - 0x10) #if (defined SLJIT_UTIL_GLOBAL_LOCK && SLJIT_UTIL_GLOBAL_LOCK) /* This global lock is useful to compile common functions. */ -void SLJIT_CALL sljit_grab_lock(void); -void SLJIT_CALL sljit_release_lock(void); +SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_grab_lock(void); +SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_release_lock(void); #endif #if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK) @@ -696,8 +699,8 @@ struct sljit_stack { /* Returns NULL if unsuccessful. Note: limit and max_limit contains the size for stack allocation Note: the top field is initialized to base. */ -struct sljit_stack* SLJIT_CALL sljit_allocate_stack(sljit_w limit, sljit_w max_limit); -void SLJIT_CALL sljit_free_stack(struct sljit_stack* stack); +SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CALL sljit_allocate_stack(sljit_uw limit, sljit_uw max_limit); +SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_free_stack(struct sljit_stack* stack); /* Can be used to increase (allocate) or decrease (free) the memory area. Returns with a non-zero value if unsuccessful. If new_limit is greater than @@ -705,7 +708,7 @@ void SLJIT_CALL sljit_free_stack(struct sljit_stack* stack); since the growth ratio can be added to the current limit, and sljit_stack_resize will do all the necessary checks. The fields of the stack are not changed if sljit_stack_resize fails. */ -sljit_w SLJIT_CALL sljit_stack_resize(struct sljit_stack* stack, sljit_uw new_limit); +SLJIT_API_FUNC_ATTRIBUTE sljit_w SLJIT_CALL sljit_stack_resize(struct sljit_stack* stack, sljit_uw new_limit); #endif /* (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK) */ @@ -730,7 +733,7 @@ struct sljit_function_context { /* Fill the context arguments using the addr and the function. If func_ptr is NULL, it will not be set to the address of context If addr is NULL, the function address also comes from the func pointer. */ -void sljit_set_function_context(void** func_ptr, struct sljit_function_context* context, sljit_w addr, void* func); +SLJIT_API_FUNC_ATTRIBUTE void sljit_set_function_context(void** func_ptr, struct sljit_function_context* context, sljit_w addr, void* func); #endif /* !(defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL) */ diff --git a/sljit/sljitNativeARM_Thumb2.c b/sljit/sljitNativeARM_Thumb2.c index 9a7d6b9..c476711 100644 --- a/sljit/sljitNativeARM_Thumb2.c +++ b/sljit/sljitNativeARM_Thumb2.c @@ -24,7 +24,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -SLJIT_CONST char* sljit_get_platform_name() +SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name() { return "arm-thumb2"; } @@ -340,7 +340,7 @@ static SLJIT_INLINE void set_jump_instruction(struct sljit_jump *jump) SLJIT_ASSERT_STOP(); } -void* sljit_generate_code(struct sljit_compiler *compiler) +SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler) { struct sljit_memory_fragment *buf; sljit_uh *code; @@ -1076,7 +1076,7 @@ static SLJIT_INLINE int emit_op_mem(struct sljit_compiler *compiler, int flags, return getput_arg(compiler, flags, reg, arg, argw, 0, 0); } -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) { int size; sljit_ins push; @@ -1127,7 +1127,7 @@ int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, return SLJIT_SUCCESS; } -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) { int size; @@ -1144,7 +1144,7 @@ void sljit_fake_enter(struct sljit_compiler *compiler, int args, int temporaries compiler->local_size = local_size; } -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_ins pop; @@ -1187,7 +1187,7 @@ int sljit_emit_return(struct sljit_compiler *compiler, int src, sljit_w srcw) /* Operators */ /* --------------------------------------------------------------------- */ -int sljit_emit_op0(struct sljit_compiler *compiler, int op) +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op0(struct sljit_compiler *compiler, int op) { CHECK_ERROR(); check_sljit_emit_op0(compiler, op); @@ -1205,7 +1205,7 @@ int sljit_emit_op0(struct sljit_compiler *compiler, int op) return SLJIT_SUCCESS; } -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) { @@ -1332,7 +1332,7 @@ int sljit_emit_op1(struct sljit_compiler *compiler, int op, return SLJIT_SUCCESS; } -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) @@ -1415,7 +1415,7 @@ int sljit_emit_op2(struct sljit_compiler *compiler, int op, /* Floating point operators */ /* --------------------------------------------------------------------- */ -int sljit_is_fpu_available(void) +SLJIT_API_FUNC_ATTRIBUTE int sljit_is_fpu_available(void) { return 1; } @@ -1470,7 +1470,7 @@ static int emit_fop_mem(struct sljit_compiler *compiler, int flags, int reg, int return push_inst32(compiler, inst | 0x800000 | RN4(TMP_REG3) | DD4(reg)); } -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) { @@ -1519,7 +1519,7 @@ int sljit_emit_fop1(struct sljit_compiler *compiler, int op, return SLJIT_SUCCESS; } -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) @@ -1566,7 +1566,7 @@ int sljit_emit_fop2(struct sljit_compiler *compiler, int op, /* Other instructions */ /* --------------------------------------------------------------------- */ -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) { int size; @@ -1596,7 +1596,7 @@ int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw return SLJIT_SUCCESS; } -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) { CHECK_ERROR(); check_sljit_emit_fast_return(compiler, src, srcw); @@ -1676,7 +1676,7 @@ static sljit_uw get_cc(int type) } } -struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) +SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) { struct sljit_label *label; @@ -1692,7 +1692,7 @@ struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) return label; } -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) { struct sljit_jump *jump; int cc; @@ -1725,7 +1725,7 @@ struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, int type) return jump; } -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) { struct sljit_jump *jump; @@ -1754,7 +1754,7 @@ int sljit_emit_ijump(struct sljit_compiler *compiler, int type, int src, sljit_w return SLJIT_SUCCESS; } -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) { int dst_r; sljit_uw cc; @@ -1801,7 +1801,7 @@ int sljit_emit_cond_value(struct sljit_compiler *compiler, int op, int dst, slji return SLJIT_SUCCESS; } -struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w init_value) +SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w init_value) { struct sljit_const *const_; int dst_r; @@ -1821,12 +1821,12 @@ struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, s return const_; } -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) { inline_set_jump_addr(addr, new_addr, 1); } -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_uh* inst = (sljit_uh*)addr; modify_imm32_const(inst, new_constant); diff --git a/sljit/sljitNativeARM_v5.c b/sljit/sljitNativeARM_v5.c index 075fefe..1b40afa 100644 --- a/sljit/sljitNativeARM_v5.c +++ b/sljit/sljitNativeARM_v5.c @@ -24,7 +24,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -SLJIT_CONST char* sljit_get_platform_name() +SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name() { #if (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) return "arm-v7"; @@ -548,7 +548,7 @@ static SLJIT_INLINE void inline_set_const(sljit_uw addr, sljit_w new_constant, i #endif } -void* sljit_generate_code(struct sljit_compiler *compiler) +SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler) { struct sljit_memory_fragment *buf; sljit_uw *code; @@ -818,7 +818,7 @@ static int emit_op(struct sljit_compiler *compiler, int op, int inp_flags, int src1, sljit_w src1w, int src2, sljit_w src2w); -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) { int size; sljit_uw push; @@ -869,7 +869,7 @@ int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, return SLJIT_SUCCESS; } -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) { int size; @@ -888,7 +888,7 @@ void sljit_fake_enter(struct sljit_compiler *compiler, int args, int temporaries compiler->local_size = local_size; } -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_uw pop; @@ -1754,7 +1754,7 @@ static int emit_op(struct sljit_compiler *compiler, int op, int inp_flags, return SLJIT_SUCCESS; } -int sljit_emit_op0(struct sljit_compiler *compiler, int op) +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op0(struct sljit_compiler *compiler, int op) { CHECK_ERROR(); check_sljit_emit_op0(compiler, op); @@ -1772,7 +1772,7 @@ int sljit_emit_op0(struct sljit_compiler *compiler, int op) return SLJIT_SUCCESS; } -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) { @@ -1830,7 +1830,7 @@ int sljit_emit_op1(struct sljit_compiler *compiler, int op, return SLJIT_SUCCESS; } -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) @@ -1888,7 +1888,7 @@ static void init_compiler() arm_fpu_type = 1; } -int sljit_is_fpu_available(void) +SLJIT_API_FUNC_ATTRIBUTE int sljit_is_fpu_available(void) { if (arm_fpu_type == -1) init_compiler(); @@ -1899,7 +1899,7 @@ int sljit_is_fpu_available(void) #define arm_fpu_type 1 -int sljit_is_fpu_available(void) +SLJIT_API_FUNC_ATTRIBUTE int sljit_is_fpu_available(void) { /* Always available. */ return 1; @@ -1973,7 +1973,7 @@ static int emit_fpu_data_transfer(struct sljit_compiler *compiler, int fpu_reg, return SLJIT_SUCCESS; } -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) { @@ -2025,7 +2025,7 @@ int sljit_emit_fop1(struct sljit_compiler *compiler, int op, return SLJIT_SUCCESS; } -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) @@ -2078,7 +2078,7 @@ int sljit_emit_fop2(struct sljit_compiler *compiler, int op, /* Other instructions */ /* --------------------------------------------------------------------- */ -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) { int size; @@ -2110,7 +2110,7 @@ int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw return SLJIT_SUCCESS; } -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) { CHECK_ERROR(); check_sljit_emit_fast_return(compiler, src, srcw); @@ -2190,7 +2190,7 @@ static sljit_uw get_cc(int type) } } -struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) +SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) { struct sljit_label *label; @@ -2206,7 +2206,7 @@ struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) return label; } -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) { struct sljit_jump *jump; @@ -2247,7 +2247,7 @@ struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, int type) return jump; } -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) { struct sljit_jump *jump; @@ -2285,7 +2285,7 @@ int sljit_emit_ijump(struct sljit_compiler *compiler, int type, int src, sljit_w return SLJIT_SUCCESS; } -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) { int reg; sljit_uw cc; @@ -2323,7 +2323,7 @@ int sljit_emit_cond_value(struct sljit_compiler *compiler, int op, int dst, slji return SLJIT_SUCCESS; } -struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w init_value) +SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w init_value) { struct sljit_const *const_; int reg; @@ -2350,12 +2350,12 @@ struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, s return const_; } -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) { inline_set_jump_addr(addr, new_addr, 1); } -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) { inline_set_const(addr, new_constant, 1); } diff --git a/sljit/sljitNativeMIPS_32.c b/sljit/sljitNativeMIPS_32.c index 54a5ade..d8b7db4 100644 --- a/sljit/sljitNativeMIPS_32.c +++ b/sljit/sljitNativeMIPS_32.c @@ -386,7 +386,7 @@ static SLJIT_INLINE int emit_const(struct sljit_compiler *compiler, int reg, slj return push_inst(compiler, ORI | S(reg) | T(reg) | IMM(init_value), DR(reg)); } -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_ins *inst = (sljit_ins*)addr; @@ -395,7 +395,7 @@ void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_addr) SLJIT_CACHE_FLUSH(inst, inst + 2); } -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_ins *inst = (sljit_ins*)addr; diff --git a/sljit/sljitNativeMIPS_common.c b/sljit/sljitNativeMIPS_common.c index 7c7df5f..c4fe152 100644 --- a/sljit/sljitNativeMIPS_common.c +++ b/sljit/sljitNativeMIPS_common.c @@ -24,7 +24,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -SLJIT_CONST char* sljit_get_platform_name() +SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name() { #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) return "mips-32"; @@ -290,7 +290,7 @@ static __attribute__ ((noinline)) void sljit_cache_flush(void* code, void* code_ } #endif -void* sljit_generate_code(struct sljit_compiler *compiler) +SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler) { struct sljit_memory_fragment *buf; sljit_ins *code; @@ -454,7 +454,7 @@ static int emit_op(struct sljit_compiler *compiler, int op, int inp_flags, int src1, sljit_w src1w, int src2, sljit_w src2w); -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_ins base; @@ -509,7 +509,7 @@ int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, return SLJIT_SUCCESS; } -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) { CHECK_ERROR_VOID(); check_sljit_fake_enter(compiler, args, temporaries, generals, local_size); @@ -522,7 +522,7 @@ void sljit_fake_enter(struct sljit_compiler *compiler, int args, int temporaries compiler->local_size = (local_size + 15) & ~0xf; } -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) { int local_size; sljit_ins base; @@ -917,7 +917,7 @@ static int emit_op(struct sljit_compiler *compiler, int op, int flags, return SLJIT_SUCCESS; } -int sljit_emit_op0(struct sljit_compiler *compiler, int op) +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op0(struct sljit_compiler *compiler, int op) { CHECK_ERROR(); check_sljit_emit_op0(compiler, op); @@ -933,7 +933,7 @@ int sljit_emit_op0(struct sljit_compiler *compiler, int op) return SLJIT_SUCCESS; } -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) { @@ -944,7 +944,7 @@ int sljit_emit_op1(struct sljit_compiler *compiler, int op, CHECK_ERROR(); check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw); - SLJIT_ASSERT(SLJIT_MOV + 7 == SLJIT_MOVU); + SLJIT_COMPILE_ASSERT(SLJIT_MOV + 7 == SLJIT_MOVU, movu_offset); switch (GET_OPCODE(op)) { case SLJIT_MOV: @@ -1005,7 +1005,7 @@ int sljit_emit_op1(struct sljit_compiler *compiler, int op, #endif } -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) @@ -1057,7 +1057,7 @@ int sljit_emit_op2(struct sljit_compiler *compiler, int op, /* Floating point operators */ /* --------------------------------------------------------------------- */ -int sljit_is_fpu_available(void) +SLJIT_API_FUNC_ATTRIBUTE int sljit_is_fpu_available(void) { #if (defined SLJIT_QEMU && SLJIT_QEMU) /* Qemu says fir is 0 by default. */ @@ -1109,7 +1109,7 @@ static int emit_fpu_data_transfer(struct sljit_compiler *compiler, int fpu_reg, return push_inst(compiler, (load ? LDC1 : SDC1) | S(TMP_REG3) | FT(fpu_reg) | IMM(0), MOVABLE_INS); } -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) { @@ -1178,7 +1178,7 @@ int sljit_emit_fop1(struct sljit_compiler *compiler, int op, return SLJIT_SUCCESS; } -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) @@ -1231,7 +1231,7 @@ int sljit_emit_fop2(struct sljit_compiler *compiler, int op, /* Other instructions */ /* --------------------------------------------------------------------- */ -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) { CHECK_ERROR(); check_sljit_emit_fast_enter(compiler, dst, dstw, args, temporaries, generals, local_size); @@ -1250,7 +1250,7 @@ int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw return SLJIT_SUCCESS; } -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) { CHECK_ERROR(); check_sljit_emit_fast_return(compiler, src, srcw); @@ -1270,7 +1270,7 @@ int sljit_emit_fast_return(struct sljit_compiler *compiler, int src, sljit_w src /* Conditional instructions */ /* --------------------------------------------------------------------- */ -struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) +SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) { struct sljit_label *label; @@ -1313,7 +1313,7 @@ struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) flags = IS_BIT16_COND; \ delay_check = FCSR_FCC; -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) { struct sljit_jump *jump; sljit_ins inst; @@ -1429,7 +1429,7 @@ struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, int type) src2 = 0; \ } -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) { @@ -1560,7 +1560,7 @@ struct sljit_jump* sljit_emit_cmp(struct sljit_compiler *compiler, int type, #undef BR_T #undef BR_F -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) { int src_r = TMP_REG2; struct sljit_jump *jump = NULL; @@ -1617,7 +1617,7 @@ int sljit_emit_ijump(struct sljit_compiler *compiler, int type, int src, sljit_w return SLJIT_SUCCESS; } -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) { int sugg_dst_ar, dst_ar; @@ -1703,7 +1703,7 @@ int sljit_emit_cond_value(struct sljit_compiler *compiler, int op, int dst, slji return SLJIT_SUCCESS; } -struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w init_value) +SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w init_value) { struct sljit_const *const_; int reg; diff --git a/sljit/sljitNativePPC_32.c b/sljit/sljitNativePPC_32.c index 5dedfe5..4b01a76 100644 --- a/sljit/sljitNativePPC_32.c +++ b/sljit/sljitNativePPC_32.c @@ -227,7 +227,7 @@ static SLJIT_INLINE int emit_const(struct sljit_compiler *compiler, int reg, slj return push_inst(compiler, ORI | S(reg) | A(reg) | IMM(init_value)); } -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_ins *inst = (sljit_ins*)addr; @@ -236,7 +236,7 @@ void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_addr) SLJIT_CACHE_FLUSH(inst, inst + 2); } -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_ins *inst = (sljit_ins*)addr; diff --git a/sljit/sljitNativePPC_64.c b/sljit/sljitNativePPC_64.c index 5e9b7fb..e3da625 100644 --- a/sljit/sljitNativePPC_64.c +++ b/sljit/sljitNativePPC_64.c @@ -381,7 +381,7 @@ static SLJIT_INLINE int emit_const(struct sljit_compiler *compiler, int reg, slj return push_inst(compiler, ORI | S(reg) | A(reg) | IMM(init_value)); } -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_ins *inst = (sljit_ins*)addr; @@ -392,7 +392,7 @@ void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_addr) SLJIT_CACHE_FLUSH(inst, inst + 5); } -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_ins *inst = (sljit_ins*)addr; @@ -403,7 +403,7 @@ void sljit_set_const(sljit_uw addr, sljit_w new_constant) SLJIT_CACHE_FLUSH(inst, inst + 5); } -void sljit_set_function_context(void** func_ptr, struct sljit_function_context* context, sljit_w addr, void* func) +SLJIT_API_FUNC_ATTRIBUTE void sljit_set_function_context(void** func_ptr, struct sljit_function_context* context, sljit_w addr, void* func) { sljit_w* ptrs; if (func_ptr) diff --git a/sljit/sljitNativePPC_common.c b/sljit/sljitNativePPC_common.c index d356af2..fcabcfc 100644 --- a/sljit/sljitNativePPC_common.c +++ b/sljit/sljitNativePPC_common.c @@ -24,7 +24,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -SLJIT_CONST char* sljit_get_platform_name() +SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name() { #if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) return "ppc-32"; @@ -205,7 +205,7 @@ static SLJIT_INLINE int optimize_jump(struct sljit_jump *jump, sljit_ins *code_p return 0; } -void* sljit_generate_code(struct sljit_compiler *compiler) +SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler) { struct sljit_memory_fragment *buf; sljit_ins *code; @@ -415,7 +415,7 @@ static int emit_op(struct sljit_compiler *compiler, int op, int inp_flags, int src1, sljit_w src1w, int src2, sljit_w src2w); -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) { CHECK_ERROR(); check_sljit_emit_enter(compiler, args, temporaries, generals, local_size); @@ -478,7 +478,7 @@ int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, return SLJIT_SUCCESS; } -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) { CHECK_ERROR_VOID(); check_sljit_fake_enter(compiler, args, temporaries, generals, local_size); @@ -495,7 +495,7 @@ void sljit_fake_enter(struct sljit_compiler *compiler, int args, int temporaries compiler->local_size = (compiler->local_size + 15) & ~0xf; } -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) { CHECK_ERROR(); check_sljit_emit_return(compiler, src, srcw); @@ -1010,7 +1010,7 @@ static int emit_op(struct sljit_compiler *compiler, int op, int inp_flags, return SLJIT_SUCCESS; } -int sljit_emit_op0(struct sljit_compiler *compiler, int op) +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op0(struct sljit_compiler *compiler, int op) { CHECK_ERROR(); check_sljit_emit_op0(compiler, op); @@ -1026,7 +1026,7 @@ int sljit_emit_op0(struct sljit_compiler *compiler, int op) return SLJIT_SUCCESS; } -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) { @@ -1133,7 +1133,7 @@ int sljit_emit_op1(struct sljit_compiler *compiler, int op, ((src) & SLJIT_IMM) #endif -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) @@ -1315,7 +1315,7 @@ int sljit_emit_op2(struct sljit_compiler *compiler, int op, /* Floating point operators */ /* --------------------------------------------------------------------- */ -int sljit_is_fpu_available(void) +SLJIT_API_FUNC_ATTRIBUTE int sljit_is_fpu_available(void) { /* Always available. */ return 1; @@ -1359,7 +1359,7 @@ static int emit_fpu_data_transfer(struct sljit_compiler *compiler, int fpu_reg, return push_inst(compiler, (load ? LFDUX : STFDUX) | FD(fpu_reg) | A(TMP_REG3) | B(arg & 0xf)); } -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) { @@ -1409,7 +1409,7 @@ int sljit_emit_fop1(struct sljit_compiler *compiler, int op, return SLJIT_SUCCESS; } -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) @@ -1462,7 +1462,7 @@ int sljit_emit_fop2(struct sljit_compiler *compiler, int op, /* Other instructions */ /* --------------------------------------------------------------------- */ -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) { CHECK_ERROR(); check_sljit_emit_fast_enter(compiler, dst, dstw, args, temporaries, generals, local_size); @@ -1488,7 +1488,7 @@ int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw return SLJIT_SUCCESS; } -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) { CHECK_ERROR(); check_sljit_emit_fast_return(compiler, src, srcw); @@ -1509,7 +1509,7 @@ int sljit_emit_fast_return(struct sljit_compiler *compiler, int src, sljit_w src /* Conditional instructions */ /* --------------------------------------------------------------------- */ -struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) +SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) { struct sljit_label *label; @@ -1588,7 +1588,7 @@ static sljit_ins get_bo_bi_flags(struct sljit_compiler *compiler, int type) } } -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) { struct sljit_jump *jump; sljit_ins bo_bi_flags; @@ -1616,7 +1616,7 @@ struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, int type) return jump; } -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_ins bo_bi_flags; struct sljit_jump *jump = NULL; @@ -1658,7 +1658,7 @@ int sljit_emit_ijump(struct sljit_compiler *compiler, int type, int src, sljit_w #define INVERT_BIT(dst) \ FAIL_IF(push_inst(compiler, XORI | S(dst) | A(dst) | 0x1)); -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) { int reg; @@ -1762,7 +1762,7 @@ int sljit_emit_cond_value(struct sljit_compiler *compiler, int op, int dst, slji return SLJIT_SUCCESS; } -struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w init_value) +SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w init_value) { struct sljit_const *const_; int reg; diff --git a/sljit/sljitNativeX86_32.c b/sljit/sljitNativeX86_32.c index 97e6ade..69ac8fe 100644 --- a/sljit/sljitNativeX86_32.c +++ b/sljit/sljitNativeX86_32.c @@ -63,7 +63,7 @@ static sljit_ub* generate_far_jump_code(struct sljit_jump *jump, sljit_ub *code_ return code_ptr; } -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) { int size; sljit_ub *buf; @@ -156,7 +156,7 @@ int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, return SLJIT_SUCCESS; } -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) { CHECK_ERROR_VOID(); check_sljit_fake_enter(compiler, args, temporaries, generals, local_size); @@ -173,7 +173,7 @@ void sljit_fake_enter(struct sljit_compiler *compiler, int args, int temporaries compiler->local_size += (generals - 3) * sizeof(sljit_uw); } -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) { int size; sljit_ub *buf; @@ -435,7 +435,7 @@ static SLJIT_INLINE int call_with_args(struct sljit_compiler *compiler, int type return SLJIT_SUCCESS; } -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_ub *buf; @@ -479,7 +479,7 @@ int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw return SLJIT_SUCCESS; } -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_ub *buf; diff --git a/sljit/sljitNativeX86_64.c b/sljit/sljitNativeX86_64.c index 0ee34f0..5f577f3 100644 --- a/sljit/sljitNativeX86_64.c +++ b/sljit/sljitNativeX86_64.c @@ -46,7 +46,7 @@ static sljit_ub* generate_far_jump_code(struct sljit_jump *jump, sljit_ub *code_ *code_ptr++ = 10 + 3; } - SLJIT_ASSERT(reg_map[TMP_REG3] == 9); + SLJIT_COMPILE_ASSERT(reg_map[TMP_REG3] == 9, tmp3_is_9_first); *code_ptr++ = REX_W | REX_B; *code_ptr++ = 0xb8 + 1; jump->addr = (sljit_uw)code_ptr; @@ -73,7 +73,7 @@ static sljit_ub* generate_fixed_jump(sljit_ub *code_ptr, sljit_w addr, int type) *(sljit_w*)code_ptr = delta; } else { - SLJIT_ASSERT(reg_map[TMP_REG3] == 9); + SLJIT_COMPILE_ASSERT(reg_map[TMP_REG3] == 9, tmp3_is_9_second); *code_ptr++ = REX_W | REX_B; *code_ptr++ = 0xb8 + 1; *(sljit_w*)code_ptr = addr; @@ -86,9 +86,9 @@ static sljit_ub* generate_fixed_jump(sljit_ub *code_ptr, sljit_w addr, int type) return code_ptr; } -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) { - int size; + int size, pushed_size; sljit_ub *buf; CHECK_ERROR(); @@ -99,16 +99,24 @@ int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, compiler->flags_saved = 0; size = generals; + /* Including the return address saved by the call instruction. */ + pushed_size = (generals + 1) * sizeof(sljit_w); #ifndef _WIN64 if (generals >= 2) size += generals - 1; #else - if (local_size > 0) + /* Saving the virtual stack pointer. */ + compiler->has_locals = local_size > 0; + if (local_size > 0) { size += 2; + pushed_size += sizeof(sljit_w); + } if (generals >= 4) size += generals - 3; - if (temporaries >= 5) + if (temporaries >= 5) { size += (5 - 4) * 2; + pushed_size += sizeof(sljit_w); + } #endif size += args * 3; if (size > 0) { @@ -117,45 +125,45 @@ int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, INC_SIZE(size); if (generals >= 5) { - SLJIT_ASSERT(reg_map[SLJIT_GENERAL_EREG2] >= 8); + SLJIT_COMPILE_ASSERT(reg_map[SLJIT_GENERAL_EREG2] >= 8, general_ereg2_is_hireg); *buf++ = REX_B; PUSH_REG(reg_lmap[SLJIT_GENERAL_EREG2]); } if (generals >= 4) { - SLJIT_ASSERT(reg_map[SLJIT_GENERAL_EREG1] >= 8); + SLJIT_COMPILE_ASSERT(reg_map[SLJIT_GENERAL_EREG1] >= 8, general_ereg1_is_hireg); *buf++ = REX_B; PUSH_REG(reg_lmap[SLJIT_GENERAL_EREG1]); } if (generals >= 3) { #ifndef _WIN64 - SLJIT_ASSERT(reg_map[SLJIT_GENERAL_REG3] >= 8); + SLJIT_COMPILE_ASSERT(reg_map[SLJIT_GENERAL_REG3] >= 8, general_reg3_is_hireg); *buf++ = REX_B; #else - SLJIT_ASSERT(reg_map[SLJIT_GENERAL_REG3] < 8); + SLJIT_COMPILE_ASSERT(reg_map[SLJIT_GENERAL_REG3] < 8, general_reg3_is_loreg); #endif PUSH_REG(reg_lmap[SLJIT_GENERAL_REG3]); } if (generals >= 2) { #ifndef _WIN64 - SLJIT_ASSERT(reg_map[SLJIT_GENERAL_REG2] >= 8); + SLJIT_COMPILE_ASSERT(reg_map[SLJIT_GENERAL_REG2] >= 8, general_reg2_is_hireg); *buf++ = REX_B; #else - SLJIT_ASSERT(reg_map[SLJIT_GENERAL_REG2] < 8); + SLJIT_COMPILE_ASSERT(reg_map[SLJIT_GENERAL_REG2] < 8, general_reg2_is_loreg); #endif PUSH_REG(reg_lmap[SLJIT_GENERAL_REG2]); } if (generals >= 1) { - SLJIT_ASSERT(reg_map[SLJIT_GENERAL_REG1] < 8); + SLJIT_COMPILE_ASSERT(reg_map[SLJIT_GENERAL_REG1] < 8, general_reg1_is_loreg); PUSH_REG(reg_lmap[SLJIT_GENERAL_REG1]); } #ifdef _WIN64 if (temporaries >= 5) { - SLJIT_ASSERT(reg_map[SLJIT_TEMPORARY_EREG2] >= 8); + SLJIT_COMPILE_ASSERT(reg_map[SLJIT_TEMPORARY_EREG2] >= 8, temporary_ereg2_is_hireg); *buf++ = REX_B; PUSH_REG(reg_lmap[SLJIT_TEMPORARY_EREG2]); } if (local_size > 0) { - SLJIT_ASSERT(reg_map[SLJIT_LOCALS_REG] >= 8); + SLJIT_COMPILE_ASSERT(reg_map[SLJIT_LOCALS_REG] >= 8, locals_reg_is_hireg); *buf++ = REX_B; PUSH_REG(reg_lmap[SLJIT_LOCALS_REG]); } @@ -196,7 +204,7 @@ int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, #endif } - local_size = (local_size + 16 - 1) & ~(16 - 1); + local_size = ((local_size + pushed_size + 16 - 1) & ~(16 - 1)) - pushed_size; #ifdef _WIN64 local_size += 4 * sizeof(sljit_w); compiler->local_size = local_size; @@ -208,8 +216,15 @@ int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, *buf++ = REX_W; *buf++ = 0x83; *buf++ = 0xc0 | (5 << 3) | 4; - *buf++ = 4 * sizeof(sljit_w); - local_size -= 4 * sizeof(sljit_w); + /* Pushed size must be divisible by 8. */ + SLJIT_ASSERT(!(pushed_size & 0x7)); + if (pushed_size & 0x8) { + *buf++ = 5 * sizeof(sljit_w); + local_size -= 5 * sizeof(sljit_w); + } else { + *buf++ = 4 * sizeof(sljit_w); + local_size -= 4 * sizeof(sljit_w); + } FAIL_IF(emit_load_imm64(compiler, SLJIT_TEMPORARY_REG1, local_size)); FAIL_IF(sljit_emit_ijump(compiler, SLJIT_CALL1, SLJIT_IMM, SLJIT_FUNC_OFFSET(sljit_touch_stack))); } @@ -217,6 +232,7 @@ int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, compiler->local_size = local_size; if (local_size > 0) { #endif + /* In case of Win64, local_size is always > 4 * sizeof(sljit_w) */ if (local_size <= 127) { buf = (sljit_ub*)ensure_buf(compiler, 1 + 4); FAIL_IF(!buf); @@ -241,7 +257,7 @@ int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, #endif #ifdef _WIN64 - if (local_size > 4 * sizeof(sljit_w)) { + if (compiler->has_locals) { buf = (sljit_ub*)ensure_buf(compiler, 1 + 5); FAIL_IF(!buf); INC_SIZE(5); @@ -257,20 +273,31 @@ int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, return SLJIT_SUCCESS; } -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) { + int pushed_size; + CHECK_ERROR_VOID(); check_sljit_fake_enter(compiler, args, temporaries, generals, local_size); compiler->temporaries = temporaries; compiler->generals = generals; - compiler->local_size = (local_size + 16 - 1) & ~(16 - 1); + /* Including the return address saved by the call instruction. */ + pushed_size = (generals + 1) * sizeof(sljit_w); +#ifdef _WIN64 + compiler->has_locals = local_size > 0; + if (local_size > 0) + pushed_size += sizeof(sljit_w); + if (temporaries >= 5) + pushed_size += sizeof(sljit_w); +#endif + compiler->local_size = ((local_size + pushed_size + 16 - 1) & ~(16 - 1)) - pushed_size; #ifdef _WIN64 compiler->local_size += 4 * sizeof(sljit_w); #endif } -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) { int size; sljit_ub *buf; @@ -311,7 +338,7 @@ int sljit_emit_return(struct sljit_compiler *compiler, int src, sljit_w srcw) if (compiler->generals >= 2) size += compiler->generals - 1; #else - if (compiler->local_size > 4 * sizeof(sljit_w)) + if (compiler->has_locals) size += 2; if (compiler->generals >= 4) size += compiler->generals - 3; @@ -324,7 +351,7 @@ int sljit_emit_return(struct sljit_compiler *compiler, int src, sljit_w srcw) INC_SIZE(size); #ifdef _WIN64 - if (compiler->local_size > 4 * sizeof(sljit_w)) { + if (compiler->has_locals) { *buf++ = REX_B; POP_REG(reg_lmap[SLJIT_LOCALS_REG]); } @@ -618,7 +645,7 @@ static SLJIT_INLINE int call_with_args(struct sljit_compiler *compiler, int type sljit_ub *buf; #ifndef _WIN64 - SLJIT_ASSERT(reg_map[SLJIT_TEMPORARY_REG2] == 6 && reg_map[SLJIT_TEMPORARY_REG1] < 8 && reg_map[SLJIT_TEMPORARY_REG3] < 8); + SLJIT_COMPILE_ASSERT(reg_map[SLJIT_TEMPORARY_REG2] == 6 && reg_map[SLJIT_TEMPORARY_REG1] < 8 && reg_map[SLJIT_TEMPORARY_REG3] < 8, args_registers); buf = (sljit_ub*)ensure_buf(compiler, 1 + ((type < SLJIT_CALL3) ? 3 : 6)); FAIL_IF(!buf); @@ -632,7 +659,7 @@ static SLJIT_INLINE int call_with_args(struct sljit_compiler *compiler, int type *buf++ = 0x8b; *buf++ = 0xc0 | (0x7 << 3) | reg_lmap[SLJIT_TEMPORARY_REG1]; #else - SLJIT_ASSERT(reg_map[SLJIT_TEMPORARY_REG2] == 2 && reg_map[SLJIT_TEMPORARY_REG1] < 8 && reg_map[SLJIT_TEMPORARY_REG3] < 8); + SLJIT_COMPILE_ASSERT(reg_map[SLJIT_TEMPORARY_REG2] == 2 && reg_map[SLJIT_TEMPORARY_REG1] < 8 && reg_map[SLJIT_TEMPORARY_REG3] < 8, args_registers); buf = (sljit_ub*)ensure_buf(compiler, 1 + ((type < SLJIT_CALL3) ? 3 : 6)); FAIL_IF(!buf); @@ -649,7 +676,7 @@ static SLJIT_INLINE int call_with_args(struct sljit_compiler *compiler, int type return SLJIT_SUCCESS; } -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_ub *buf; @@ -696,7 +723,7 @@ int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw return SLJIT_SUCCESS; } -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_ub *buf; diff --git a/sljit/sljitNativeX86_common.c b/sljit/sljitNativeX86_common.c index f86546e..c6661bc 100644 --- a/sljit/sljitNativeX86_common.c +++ b/sljit/sljitNativeX86_common.c @@ -24,7 +24,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -SLJIT_CONST char* sljit_get_platform_name() +SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name() { #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) return "x86-32"; @@ -275,7 +275,7 @@ static sljit_ub* generate_near_jump_code(struct sljit_jump *jump, sljit_ub *code return code_ptr; } -void* sljit_generate_code(struct sljit_compiler *compiler) +SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler) { struct sljit_memory_fragment *buf; sljit_ub *code; @@ -473,7 +473,7 @@ static void SLJIT_CALL sljit_touch_stack(sljit_w local_size) #include "sljitNativeX86_64.c" #endif -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_ub *buf; @@ -927,7 +927,7 @@ static int emit_clz(struct sljit_compiler *compiler, int op, return SLJIT_SUCCESS; } -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) { @@ -955,7 +955,7 @@ int sljit_emit_op1(struct sljit_compiler *compiler, int op, compiler->mode32 = 0; #endif - SLJIT_ASSERT(SLJIT_MOV + 7 == SLJIT_MOVU); + SLJIT_COMPILE_ASSERT(SLJIT_MOV + 7 == SLJIT_MOVU, movu_offset); if (op >= SLJIT_MOVU) { update = 1; op -= 7; @@ -1418,7 +1418,7 @@ static int emit_mul(struct sljit_compiler *compiler, } else { /* Neither argument is immediate. */ - if (depends_on(src2, dst_r)) + if (ADDRESSING_DEPENDS_ON(src2, dst_r)) dst_r = TMP_REGISTER; EMIT_MOV(compiler, dst_r, 0, src1, src1w); code = emit_x86_instruction(compiler, 2, dst_r, 0, src2, src2w); @@ -1706,7 +1706,7 @@ static int emit_shift(struct sljit_compiler *compiler, *code |= mode; EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REGISTER, 0); } - else if (dst >= SLJIT_TEMPORARY_REG1 && dst <= SLJIT_NO_REGISTERS && dst != src2 && !depends_on(src2, dst)) { + else if (dst >= SLJIT_TEMPORARY_REG1 && dst <= SLJIT_NO_REGISTERS && dst != src2 && !ADDRESSING_DEPENDS_ON(src2, dst)) { if (src1 != dst) EMIT_MOV(compiler, dst, 0, src1, src1w); EMIT_MOV(compiler, TMP_REGISTER, 0, SLJIT_PREF_SHIFT_REG, 0); @@ -1744,7 +1744,7 @@ static int emit_shift(struct sljit_compiler *compiler, return SLJIT_SUCCESS; } -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) @@ -1893,7 +1893,7 @@ static void init_compiler() #endif -int sljit_is_fpu_available(void) +SLJIT_API_FUNC_ATTRIBUTE int sljit_is_fpu_available(void) { /* Always available. */ return 1; @@ -1938,7 +1938,7 @@ static SLJIT_INLINE int emit_sse2_store(struct sljit_compiler *compiler, } #if !(defined SLJIT_SSE2_AUTO && SLJIT_SSE2_AUTO) -int sljit_emit_fop1(struct sljit_compiler *compiler, int op, +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop1(struct sljit_compiler *compiler, int op, #else static int sljit_emit_sse2_fop1(struct sljit_compiler *compiler, int op, #endif @@ -2000,7 +2000,7 @@ static int sljit_emit_sse2_fop1(struct sljit_compiler *compiler, int op, } #if !(defined SLJIT_SSE2_AUTO && SLJIT_SSE2_AUTO) -int sljit_emit_fop2(struct sljit_compiler *compiler, int op, +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop2(struct sljit_compiler *compiler, int op, #else static int sljit_emit_sse2_fop2(struct sljit_compiler *compiler, int op, #endif @@ -2123,7 +2123,7 @@ static int emit_fop_regs(struct sljit_compiler *compiler, } #if !(defined SLJIT_SSE2_AUTO && SLJIT_SSE2_AUTO) -int sljit_emit_fop1(struct sljit_compiler *compiler, int op, +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop1(struct sljit_compiler *compiler, int op, #else static int sljit_emit_fpu_fop1(struct sljit_compiler *compiler, int op, #endif @@ -2188,7 +2188,7 @@ static int sljit_emit_fpu_fop1(struct sljit_compiler *compiler, int op, } #if !(defined SLJIT_SSE2_AUTO && SLJIT_SSE2_AUTO) -int sljit_emit_fop2(struct sljit_compiler *compiler, int op, +SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop2(struct sljit_compiler *compiler, int op, #else static int sljit_emit_fpu_fop2(struct sljit_compiler *compiler, int op, #endif @@ -2266,7 +2266,7 @@ static int sljit_emit_fpu_fop2(struct sljit_compiler *compiler, int op, #if (defined SLJIT_SSE2_AUTO && SLJIT_SSE2_AUTO) -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) { @@ -2276,7 +2276,7 @@ int sljit_emit_fop1(struct sljit_compiler *compiler, int op, return sljit_emit_fpu_fop1(compiler, op, dst, dstw, src, srcw); } -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) @@ -2293,7 +2293,7 @@ int sljit_emit_fop2(struct sljit_compiler *compiler, int op, /* Conditional instructions */ /* --------------------------------------------------------------------- */ -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_ub *buf; struct sljit_label *label; @@ -2322,7 +2322,7 @@ struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler) return label; } -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_ub *buf; struct sljit_jump *jump; @@ -2359,7 +2359,7 @@ struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, int type) return jump; } -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_ub *code; struct sljit_jump *jump; @@ -2441,7 +2441,7 @@ int sljit_emit_ijump(struct sljit_compiler *compiler, int type, int src, sljit_w return SLJIT_SUCCESS; } -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_ub *buf; sljit_ub cond_set = 0; @@ -2629,7 +2629,7 @@ int sljit_emit_cond_value(struct sljit_compiler *compiler, int op, int dst, slji return SLJIT_SUCCESS; } -struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w init_value) +SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w init_value) { sljit_ub *buf; struct sljit_const *const_; @@ -2675,7 +2675,7 @@ struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, s return const_; } -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) { #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) *(sljit_w*)addr = new_addr - (addr + 4); @@ -2684,7 +2684,7 @@ void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_addr) #endif } -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_w*)addr = new_constant; } diff --git a/sljit/sljitUtils.c b/sljit/sljitUtils.c index 6656bf4..49d7aaa 100644 --- a/sljit/sljitUtils.c +++ b/sljit/sljitUtils.c @@ -58,7 +58,7 @@ static SLJIT_INLINE void allocator_release_lock(void) static HANDLE global_mutex = 0; -void SLJIT_CALL sljit_grab_lock(void) +SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_grab_lock(void) { /* No idea what to do if an error occures. Static mutexes should never fail... */ if (!global_mutex) @@ -67,7 +67,7 @@ void SLJIT_CALL sljit_grab_lock(void) WaitForSingleObject(global_mutex, INFINITE); } -void SLJIT_CALL sljit_release_lock(void) +SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_release_lock(void) { ReleaseMutex(global_mutex); } @@ -98,12 +98,12 @@ static SLJIT_INLINE void allocator_release_lock(void) static pthread_mutex_t global_mutex = PTHREAD_MUTEX_INITIALIZER; -void SLJIT_CALL sljit_grab_lock(void) +SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_grab_lock(void) { pthread_mutex_lock(&global_mutex); } -void SLJIT_CALL sljit_release_lock(void) +SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_release_lock(void) { pthread_mutex_unlock(&global_mutex); } @@ -128,7 +128,7 @@ void SLJIT_CALL sljit_release_lock(void) /* Planning to make it even more clever in the future. */ static sljit_w sljit_page_align = 0; -struct sljit_stack* SLJIT_CALL sljit_allocate_stack(sljit_w limit, sljit_w max_limit) +SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CALL sljit_allocate_stack(sljit_uw limit, sljit_uw max_limit) { struct sljit_stack *stack; union { @@ -139,7 +139,7 @@ struct sljit_stack* SLJIT_CALL sljit_allocate_stack(sljit_w limit, sljit_w max_l SYSTEM_INFO si; #endif - if (limit > max_limit) + if (limit > max_limit || limit < 1) return NULL; #ifdef _WIN32 @@ -193,7 +193,7 @@ struct sljit_stack* SLJIT_CALL sljit_allocate_stack(sljit_w limit, sljit_w max_l #undef PAGE_ALIGN -void SLJIT_CALL sljit_free_stack(struct sljit_stack* stack) +SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_free_stack(struct sljit_stack* stack) { #ifdef _WIN32 VirtualFree((void*)stack->base, 0, MEM_RELEASE); @@ -203,7 +203,7 @@ void SLJIT_CALL sljit_free_stack(struct sljit_stack* stack) SLJIT_FREE(stack); } -sljit_w SLJIT_CALL sljit_stack_resize(struct sljit_stack* stack, sljit_uw new_limit) +SLJIT_API_FUNC_ATTRIBUTE sljit_w SLJIT_CALL sljit_stack_resize(struct sljit_stack* stack, sljit_uw new_limit) { sljit_uw aligned_old_limit; sljit_uw aligned_new_limit; |