Alien-LibJIT
view release on metacpan or search on metacpan
libjit/jit/jit-internal.h view on Meta::CPAN
* the License, or (at your option) any later version.
*
* The libjit library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the libjit library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef _JIT_INTERNAL_H
#define _JIT_INTERNAL_H
#include <jit/jit.h>
#include "jit-config.h"
#if defined(HAVE_STRING_H)
# include <string.h>
#elif defined(HAVE_STRINGS_H)
# include <strings.h>
#endif
#if defined(HAVE_MEMORY_H)
# include <memory.h>
#endif
/*
* Macros that replace the routines in <jit/jit-util.h>
* with direct calls on the underlying library functions.
*/
#if defined(HAVE_MEMSET)
# define jit_memset(s, c, len) (memset((s), (c), (len)))
# define jit_memzero(s, len) (memset((s), 0, (len)))
#elif defined(HAVE_BZERO)
# define jit_memzero(s, len) (bzero((char *)(s), (len)))
#else
# define jit_memzero(s, len) (jit_memset((char *)(s), 0, (len)))
#endif
#if defined(HAVE_MEMCPY)
# define jit_memcpy(s1, s2, len) (memcpy((s1), (s2), (len)))
#endif
#if defined(HAVE_MEMMOVE)
# define jit_memmove(s1, s2, len) (memmove((s1), (s2), (len)))
#endif
#if defined(HAVE_MEMCMP)
# define jit_memcmp(s1, s2, len) (memcmp((s1), (s2), (len)))
#elif defined(HAVE_BCMP)
# define jit_memcmp(s1, s2, len) (bcmp((char *)(s1), (char *)(s2), (len)))
#endif
#if defined(HAVE_MEMCHR)
# define jit_memchr(s, c, len) (memchr((s), (c), (len)))
#endif
/*
* We need the apply rules for "jit_redirector_size".
*/
#include "jit-apply-func.h"
/*
* Include the thread routines.
*/
#include "jit-thread.h"
/*
* Include varint encoding for bytecode offset data.
*/
#include "jit-varint.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* The following is some macro magic that attempts to detect
* the best alignment to use on the target platform. The final
* value, "JIT_BEST_ALIGNMENT", will be a compile-time constant.
*/
#define _JIT_ALIGN_CHECK_TYPE(type,name) \
struct _JIT_align_##name { \
jit_sbyte pad; \
type field; \
}
#define _JIT_ALIGN_FOR_TYPE(name) \
((jit_nuint)(&(((struct _JIT_align_##name *)0)->field)))
#define _JIT_ALIGN_MAX(a,b) \
((a) > (b) ? (a) : (b))
#define _JIT_ALIGN_MAX3(a,b,c) \
(_JIT_ALIGN_MAX((a), _JIT_ALIGN_MAX((b), (c))))
_JIT_ALIGN_CHECK_TYPE(jit_sbyte, sbyte);
_JIT_ALIGN_CHECK_TYPE(jit_short, short);
_JIT_ALIGN_CHECK_TYPE(jit_int, int);
_JIT_ALIGN_CHECK_TYPE(jit_long, long);
_JIT_ALIGN_CHECK_TYPE(jit_ptr, ptr);
_JIT_ALIGN_CHECK_TYPE(jit_float32, float);
_JIT_ALIGN_CHECK_TYPE(jit_float64, double);
_JIT_ALIGN_CHECK_TYPE(jit_nfloat, nfloat);
#if defined(JIT_X86)
/* Sometimes the code below guesses wrong on Win32 platforms */
#define JIT_BEST_ALIGNMENT 4
#else
#define JIT_BEST_ALIGNMENT \
_JIT_ALIGN_MAX(_JIT_ALIGN_MAX3(_JIT_ALIGN_FOR_TYPE(int), \
_JIT_ALIGN_FOR_TYPE(long), \
_JIT_ALIGN_FOR_TYPE(ptr)), \
_JIT_ALIGN_MAX3(_JIT_ALIGN_FOR_TYPE(float), \
_JIT_ALIGN_FOR_TYPE(double), \
_JIT_ALIGN_FOR_TYPE(nfloat)))
#endif
/*
* Get the alignment values for various system types.
* These will also be compile-time constants.
*/
#define JIT_ALIGN_SBYTE _JIT_ALIGN_FOR_TYPE(sbyte)
#define JIT_ALIGN_UBYTE _JIT_ALIGN_FOR_TYPE(sbyte)
#define JIT_ALIGN_SHORT _JIT_ALIGN_FOR_TYPE(short)
libjit/jit/jit-internal.h view on Meta::CPAN
void *_jit_malloc_exec(unsigned int size);
void _jit_free_exec(void *ptr, unsigned int size);
void _jit_flush_exec(void *ptr, unsigned int size);
void _jit_memory_lock(jit_context_t context);
void _jit_memory_unlock(jit_context_t context);
int _jit_memory_ensure(jit_context_t context);
void _jit_memory_destroy(jit_context_t context);
jit_function_info_t _jit_memory_find_function_info(jit_context_t context, void *pc);
jit_function_t _jit_memory_get_function(jit_context_t context, jit_function_info_t info);
void *_jit_memory_get_function_start(jit_context_t context, jit_function_info_t info);
void *_jit_memory_get_function_end(jit_context_t context, jit_function_info_t info);
jit_function_t _jit_memory_alloc_function(jit_context_t context);
void _jit_memory_free_function(jit_context_t context, jit_function_t func);
int _jit_memory_start_function(jit_context_t context, jit_function_t func);
int _jit_memory_end_function(jit_context_t context, int result);
int _jit_memory_extend_limit(jit_context_t context, int count);
void *_jit_memory_get_limit(jit_context_t context);
void *_jit_memory_get_break(jit_context_t context);
void _jit_memory_set_break(jit_context_t context, void *brk);
void *_jit_memory_alloc_trampoline(jit_context_t context);
void _jit_memory_free_trampoline(jit_context_t context, void *ptr);
void *_jit_memory_alloc_closure(jit_context_t context);
void _jit_memory_free_closure(jit_context_t context, void *ptr);
void *_jit_memory_alloc_data(jit_context_t context, jit_size_t size, jit_size_t align);
/*
* Backtrace control structure, for managing stack traces.
* These structures must be allocated on the stack.
*/
typedef struct jit_backtrace *jit_backtrace_t;
struct jit_backtrace
{
jit_backtrace_t parent;
void *pc;
void *security_object;
jit_meta_free_func free_security_object;
};
/*
* Push a new backtrace onto the stack. The fields in "trace" are filled in.
*/
void _jit_backtrace_push(jit_backtrace_t trace, void *pc);
/*
* Pop the top-most backtrace item.
*/
void _jit_backtrace_pop(void);
/*
* Reset the backtrace stack to "trace". Used in exception catch
* blocks to fix up the backtrace information.
*/
void _jit_backtrace_set(jit_backtrace_t trace);
/*
* Control information that is associated with a thread.
*/
struct jit_thread_control
{
void *last_exception;
jit_exception_func exception_handler;
jit_backtrace_t backtrace_head;
struct jit_jmp_buf *setjmp_head;
};
/*
* Initialize the block list for a function.
*/
int _jit_block_init(jit_function_t func);
/*
* Free all blocks that are associated with a function.
*/
void _jit_block_free(jit_function_t func);
/*
* Build control flow graph edges for all blocks associated with a
* function.
*/
void _jit_block_build_cfg(jit_function_t func);
/*
* Eliminate useless control flow between blocks in a function.
*/
void _jit_block_clean_cfg(jit_function_t func);
/*
* Compute block postorder for control flow graph depth first traversal.
*/
int _jit_block_compute_postorder(jit_function_t func);
/*
* Create a new block and associate it with a function.
*/
jit_block_t _jit_block_create(jit_function_t func);
/*
* Destroy a block.
*/
void _jit_block_destroy(jit_block_t block);
/*
* Detach blocks from their current position in a function.
*/
void _jit_block_detach(jit_block_t first, jit_block_t last);
/*
* Attach blocks to a function after a specific position.
*/
void _jit_block_attach_after(jit_block_t block, jit_block_t first, jit_block_t last);
/*
* Attach blocks to a function before a specific position.
*/
void _jit_block_attach_before(jit_block_t block, jit_block_t first, jit_block_t last);
/*
* Record the label mapping for a block.
( run in 1.094 second using v1.01-cache-2.11-cpan-97f6503c9c8 )