Alien-LibJIT

 view release on metacpan or  search on metacpan

libjit/COPYING  view on Meta::CPAN


If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices.  Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

  8. If the distribution and/or use of the Program is restricted in

libjit/COPYING  view on Meta::CPAN

TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

		     END OF TERMS AND CONDITIONS

	    How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

libjit/COPYING.LESSER  view on Meta::CPAN

refrain entirely from distribution of the Library.

If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices.  Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

  12. If the distribution and/or use of the Library is restricted in

libjit/COPYING.LESSER  view on Meta::CPAN

RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.

		     END OF TERMS AND CONDITIONS

           How to Apply These Terms to Your New Libraries

  If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change.  You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).

  To apply these terms, attach the following notices to the library.  It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.

    <one line to give the library's name and a brief idea of what it does.>

libjit/ChangeLog  view on Meta::CPAN

	* jit/jit-cache.c (jit_default_memory_manager): add function that
	gets memory mamnager plugin interface.
	* jit/jit-cache.h: remove file.
	* include/jit/jit-context.h:
	* jit/jit-context.c (jit_context_set_memory_manager): add function.

2012-10-12  Aleksey Demakov  <ademakov@gmail.com>

	* include/jit/jit-util.h, jit/jit-alloc.c (jit_malloc_exec)
	(jit_free_exec, jit_flush_exec, jit_exec_page_size): remove functions
	from public API.
	* jit/jit-internal.h, jit/jit-alloc.c (_jit_malloc_exec)
	(_jit_free_exec, _jit_flush_exec): make these functions internal.

	* jit/jit-util.c: new file, move here all public util functions from
	jit/jit-alloc.c, jit/jit-memory.c, jit/jit-string.c.

2012-10-08  Aleksey Demakov  <ademakov@gmail.com>

	* jit/jit-cache.c, jit/jit-cache.c(_jit_cache_alloc_trampoline)
	(_jit_cache_free_trampoline, _jit_cache_alloc_closure)
	(_jit_cache_free_closure): add functions.
	* jit/jit-function.c (jit_function_create, _jit_function_destroy):
	use trampoline alloc/free functions.

libjit/ChangeLog  view on Meta::CPAN

	include/jit/Makefile.am, include/jit/jit-dynamic.h,
	include/jit/jit-util.h, jit/Makefile.am, jit/jit-dynlib.c,
	jit/jit-mangle.c, jitdynamic/.cvsignore, jitdynamic/Makefile.am,
	jitdynamic/jit-cpp-mangle.c, jitdynamic/jit-dynlib.c:
	move the dynlib and C++ name mangling routines into a separate
	"jitdynamic" library, which will handle all of the cross-language
	naming and dynamic invocation logic.

	* include/jit/jit-type.h, jit/jit-internal.h, jit/jit-type.c,
	jitdynamic/jit-cpp-mangle.c: move the "JIT_TYPE_xxx" constants
	into the public headers and add "jit_type_get_kind" so that
	front end code can classify types quickly.

	* jit/jit-dump.c: use "objdump" to dump compiled native code.

2004-05-07  Rhys Weatherley  <rweather@southern-storm.com.au>

	* dpas/dpas-function.c, dpas/dpas-internal.h, dpas/dpas-main.c,
	dpas/dpas-parser.y, jit/jit-interp.cpp, jit/jit-interp.h,
	jit/jit-opcode.c, jit/jit-rules-interp.c: execute the "main"
	method once a Dynamic Pascal program has been compiled;

libjit/ChangeLog  view on Meta::CPAN

	jit/jit-cache.c: use CPU-specifc padding for aligning code
	areas with NOP's, for greater runtime efficiency.

	* include/jit/jit-elf.h, jit/Makefile.am, jit/jit-elf-write.c:
	add the skeleton of the ELF writing routines.

	* jit/jit-interp.cpp: modify VM_BR_TARGET so that it is PIC-friendly.

2004-04-24  Rhys Weatherley  <rweather@southern-storm.com.au>

	* */*: Initial public release.  Most of the skeleton code is in place.

libjit/doc/libjit.texi  view on Meta::CPAN

#include <jit/jit-plus.h>
@end example

This file incorporates all of the definitions from @code{<jit/jit.h>},
so you have full access to the underlying C API if you need it.

This time, instead of building the @code{mul_add} function with
@code{jit_function_create} and friends, we define a class to represent it:

@example
class mul_add_function : public jit_function
@{
public:
    mul_add_function(jit_context& context) : jit_function(context)
    @{
        create();
        set_recompilable();
    @}

    virtual void build();

protected:
    virtual jit_type_t create_signature();

libjit/doc/libjit.texi  view on Meta::CPAN


This chapter describes what needs to be done to port @code{libjit}
to a new CPU architecture.  It is assumed that the reader is familiar
with compiler implementation techniques and the particulars of their
target CPU's instruction set.

We will use @code{ARCH} to represent the name of the architecture
in the sections that follow.  It is usually the name of the CPU in
lower case (e.g. @code{x86}, @code{arm}, @code{ppc}, etc).  By
convention, all back end functions should be prefixed with @code{_jit},
because they are not part of the public API.

@menu
* Porting Apply::           Porting the function apply facility
* Instruction Generation::  Creating the instruction generation macros
* Architecture Rules::      Writing the architecture definition rules
* Register Allocation::     Allocating registers in the back end
@end menu

@c -----------------------------------------------------------------------

libjit/doc/mangling_rules.txt  view on Meta::CPAN


<member-function>	::= '?' <name> '@' <class-name> '@@' <access>
							[<const>] <callconv> <return-type> <parameters>

<ctor-function>		::= '??0' <class-name> '@@' <access> <const> <callconv>
							'@' <parameters>

<dtor-function>		::= '??1' <class-name> '@@' <access> <const> <callconv>
							'@' <parameters>

<access>			::= 'Q'				# public instance
					::= 'I'				# protected instance
					::= 'A'				# private instance
					::= 'S'				# public static
					::= 'K'				# protected static
					::= 'C'				# private static
					::= 'U'				# public virtual
					::= 'M'				# protected virtual
					::= 'E'				# private virtual

<callconv>			::= 'A'				# cdecl
					::= 'E'				# thiscall
					::= 'G'				# stdcall
					::= 'I'				# fastcall

<const>				::= 'A'				# non-const method (instance only)
					::= 'B'				# const method (instance only)

libjit/include/jit/jit-plus.h  view on Meta::CPAN


#ifndef	_JIT_PLUS_H
#define	_JIT_PLUS_H

#include <jit/jit.h>

#ifdef __cplusplus

class jit_build_exception
{
public:
	jit_build_exception(int result) { this->result = result; }
	~jit_build_exception() {}

	int result;
};

class jit_value
{
public:
	jit_value() { this->value = 0; }
	jit_value(jit_value_t value) { this->value = value; }
	jit_value(const jit_value& value) { this->value = value.value; }
	~jit_value() {}

	jit_value& operator=(const jit_value& value)
		{ this->value = value.value; return *this; }

	jit_value_t raw() const { return value; }
	int is_valid() const { return (value != 0); }

libjit/include/jit/jit-plus.h  view on Meta::CPAN

jit_value operator>>(const jit_value& value1, const jit_value& value2);
jit_value operator==(const jit_value& value1, const jit_value& value2);
jit_value operator!=(const jit_value& value1, const jit_value& value2);
jit_value operator<(const jit_value& value1, const jit_value& value2);
jit_value operator<=(const jit_value& value1, const jit_value& value2);
jit_value operator>(const jit_value& value1, const jit_value& value2);
jit_value operator>=(const jit_value& value1, const jit_value& value2);

class jit_label
{
public:
	jit_label() { label = jit_label_undefined; }
	jit_label(jit_label_t label) { this->label = label; }
	jit_label(const jit_label& label) { this->label = label.label; }
	~jit_label() {}

	jit_label_t raw() const { return label; }
	jit_label_t *rawp() { return &label; }
	int is_valid() const { return (label != jit_label_undefined); }

	jit_label& operator=(const jit_label& value)
		{ this->label = value.label; return *this; }

private:
	jit_label_t label;
};

class jit_jump_table
{
 public:

	jit_jump_table(int size);
	~jit_jump_table();

	int size() { return num_labels; }
	jit_label_t *raw() { return labels; }

	jit_label get(int index);

	void set(int index, jit_label label);

libjit/include/jit/jit-plus.h  view on Meta::CPAN

	jit_label_t *labels;
	int num_labels;

	// forbid copying
	jit_jump_table(const jit_jump_table&);
	jit_jump_table& operator=(const jit_jump_table&);
};

class jit_context
{
public:
	jit_context();
	jit_context(jit_context_t context);
	~jit_context();

	void build_start() { jit_context_build_start(context); }
	void build_end() { jit_context_build_end(context); }
	jit_context_t raw() const { return context; }

private:
	jit_context_t context;
	int copied;
};

class jit_function
{
public:
	jit_function(jit_context& context, jit_type_t signature);
	jit_function(jit_context& context);
	jit_function(jit_function_t func);
	virtual ~jit_function();

	jit_function_t raw() const { return func; }
	int is_valid() const { return (func != 0); }

	static jit_function *from_raw(jit_function_t func);

libjit/include/jit/jit-plus.h  view on Meta::CPAN


	static jit_type_t const end_params;
	static jit_type_t signature_helper(jit_type_t return_type, ...);

protected:
	virtual void build();
	virtual jit_type_t create_signature();
	void fail();
	void out_of_memory();

public:
	void build_start()
		{ jit_context_build_start(jit_function_get_context(func)); }
	void build_end()
		{ jit_context_build_end(jit_function_get_context(func)); }

	jit_value new_value(jit_type_t type);
	jit_value new_constant(jit_sbyte value, jit_type_t type=0);
	jit_value new_constant(jit_ubyte value, jit_type_t type=0);
	jit_value new_constant(jit_short value, jit_type_t type=0);
	jit_value new_constant(jit_ushort value, jit_type_t type=0);

libjit/jit/jit-apply-arm.h  view on Meta::CPAN

 * This includes any extra bytes that are needed for alignment.
 */
#define	jit_indirector_size		24

/*
 * We should pad unused code space with NOP's.
 */
#define	jit_should_pad			1

/*
 * Defines the alignment for the stack pointer at a public interface.
 * As of the "Procedure Call Standard for the ARM Architecture" (AAPCS release 2.07)
 *    SP mod 8 = 0
 * must always be true at every public interface (function calls, etc)
 */
#define JIT_SP_ALIGN_PUBLIC 8

/*
 * Redefine jit_builtin_apply in order to correctly align the stack pointer
 * to JIT_SP_ALING_PUBLIC bytes before calling __builtin_apply to execute the
 * jit-compiled function
 */
#define	jit_builtin_apply(func,args,size,return_float,return_buf)	\
do {									\

libjit/jit/jit-interp-opcodes.ops  view on Meta::CPAN

	/*
	 * Marker opcode for the end of a function.
	 */
	op_def("end_marker") { }
}

%[

/*
 * Opcode version.  Should be increased whenever new opcodes
 * are added to this list or the public list in "jit-opcode.h".
 * This value is written to ELF binaries, to ensure that code
 * for one version of libjit is not inadvertantly used in another.
 */
#define	JIT_OPCODE_VERSION					0

/*
 * Additional opcode definition flags.
 */
#define	JIT_OPCODE_INTERP_ARGS_MASK			0x7E000000
#define	JIT_OPCODE_NINT_ARG					0x02000000

libjit/jit/jit-objmodel.c  view on Meta::CPAN

}

/*@
 * @deftypefun int jitom_class_get_modifiers (jit_objmodel_t @var{model}, jitom_class_t @var{klass})
 * Get the access modifiers for a particular class.  The following lists
 * all access modifiers, for classes, fields and methods:
 *
 * @table @code
 * @vindex JITOM_MODIFIER_ACCESS_MASK
 * @item JITOM_MODIFIER_ACCESS_MASK
 * Mask to strip out just the public, private, etc access flags.
 *
 * @vindex JITOM_MODIFIER_PUBLIC
 * @vindex JITOM_MODIFIER_PRIVATE
 * @vindex JITOM_MODIFIER_PROTECTED
 * @vindex JITOM_MODIFIER_PACKAGE
 * @vindex JITOM_MODIFIER_PACKAGE_OR_PROTECTED
 * @vindex JITOM_MODIFIER_PACKAGE_AND_PROTECTED
 * @vindex JITOM_MODIFIER_OTHER1
 * @vindex JITOM_MODIFIER_OTHER2
 * @item JITOM_MODIFIER_PUBLIC

libjit/jit/jit-opcode-apply.c  view on Meta::CPAN

		return 0;
	}

	return jit_constant_convert(const_result, &const_value,
				    const_result->type, overflow_check);
}

/*
 * NOTE: value1 is guaranteed to be valid and a constant n entry of each
 * of the apply_* functions.
 * This is checked on entry of the public _jit_opcode_apply function.
 */
static int
apply_i_i(jit_constant_t *const_result, jit_value_t value1,
	  jit_cf_i_i_func intrinsic)
{
	if(value1->is_nint_constant)
	{
		const_result->un.int_value = (*intrinsic)(value1->address);
		return 1;
	}

libjit/jit/jit-rules-arm.ins  view on Meta::CPAN

		mov_reg_imm(gen, &inst, $1, pc);
	}
}

JIT_OP_ENTER_FINALLY:
[] -> { /* 
	 * The return address is in the link register
	 * We must save it on the stack in case it will be overwritten by the content
	 * of the "finally" block.
	 * In order to respect the ABI of the ARM architecture, that prescribes an 8-byte
	 * alignment for the stack at a public interface, we save the value twice, 
	 * in order to move the current SP by 8 bytes 
	 * (we could have just saved the value once and then moved the SP by 4 bytes)
	 */
	arm_push_reg(inst, ARM_LINK);
	arm_push_reg(inst, ARM_LINK);
}

JIT_OP_LEAVE_FINALLY: branch
[] -> {
	/* The "finally" return address is on the stack (twice, just for padding)*/

libjit/jit/jit-rules-arm.ins  view on Meta::CPAN

JIT_OP_STORE_ELEMENT_FLOAT64: ternary
[reg, reg, freg64, scratch reg] -> {
	arm_fst_memindex(inst, $3, $1, 0, $2, 3, 1, $4);
}

/*
* Allocate memory from the stack.
*/
JIT_OP_ALLOCA:
[reg] -> {
	//The ARM stack must always be 4-byte aligned and must be 8-byte aligned at a public interface.
	//Since we don't know when this function will be called, let's align to 8 bytes.
	arm_alu_reg_imm(inst, ARM_ADD, $1, $1, 7);
	arm_alu_reg_imm(inst, ARM_AND, $1, $1, ~7);
	arm_alu_reg_reg(inst, ARM_SUB, ARM_SP, ARM_SP, $1);
	arm_mov_reg_reg(inst, $1, ARM_SP);
	gen->stack_changed = 1;
}

/*
 * Block operations

libjit/jitdynamic/jit-cpp-mangle.c  view on Meta::CPAN


/*@
 * @deftypefun {char *} jit_mangle_member_function (const char *@var{class_name}, const char *@var{name}, jit_type_t @var{signature}, int @var{form}, int @var{flags})
 * Mangle the name of a C++ member function using the specified @var{form}.
 * Returns NULL if out of memory, or if the form is not supported.
 * The following flags may be specified to modify the mangling rules:
 *
 * @table @code
 * @vindex JIT_MANGLE_PUBLIC
 * @item JIT_MANGLE_PUBLIC
 * The method has @code{public} access within its containing class.
 *
 * @vindex JIT_MANGLE_PROTECTED
 * @item JIT_MANGLE_PROTECTED
 * The method has @code{protected} access within its containing class.
 *
 * @vindex JIT_MANGLE_PRIVATE
 * @item JIT_MANGLE_PRIVATE
 * The method has @code{private} access within its containing class.
 *
 * @vindex JIT_MANGLE_STATIC

libjit/jitdynamic/jit-cpp-mangle.c  view on Meta::CPAN

				else
				{
					/* instance private */
					add_ch(&mangler, 'A');
				}
			}
			else
			{
				if((flags & JIT_MANGLE_STATIC) != 0)
				{
					/* static public */
					add_ch(&mangler, 'S');
				}
				else if((flags & JIT_MANGLE_VIRTUAL) != 0)
				{
					/* virtual public */
					add_ch(&mangler, 'U');
				}
				else
				{
					/* instance public */
					add_ch(&mangler, 'Q');
				}
			}
			if((flags & JIT_MANGLE_STATIC) == 0)
			{
				if((flags & JIT_MANGLE_CONST) != 0)
				{
					add_ch(&mangler, 'B');
				}
				else

libjit/tutorial/README  view on Meta::CPAN


This directory contains the source code for the tutorial programs.
The tutorials themselves can be found in "libjit/doc/libjit.texi".

The source code for these tutorials is hereby placed into the public domain.
You can do whatever you wish with the source, including cutting and pasting
bits and pieces into your own program.

However, libjit itself remains under the terms of the GNU Lesser General
Public License, so you must still obey the terms of the LGPL when you link
your program against libjit.

libjit/tutorial/t4.cpp  view on Meta::CPAN

	return x * y + z;
}

Differs from Tutorial 3 in that this version is written in C++.

*/

#include <stdio.h>
#include <jit/jit-plus.h>

class mul_add_function : public jit_function
{
public:
	mul_add_function(jit_context& context) : jit_function(context)
	{
		create();
		set_recompilable();
	}

	virtual void build();

protected:
	virtual jit_type_t create_signature();



( run in 0.522 second using v1.01-cache-2.11-cpan-64827b87656 )