view release on metacpan or search on metacpan
libjit/ChangeLog view on Meta::CPAN
* jitplus/jit-plus-function.cpp (insn_trunc): Implement wrapper for
the new trunc insn.
2010-08-04 Klaus Treichel <ktreichel@web.de>
* include/jit/Makefile.am: Don't include jit-arch.h in the
distribution.
* tools/gen-apply.c: Include a local copy of jit-arch.h instead of
the one in the include dir because that one is not yet present in
the build process.
* tools/Makefile.am: Create a local symbolic link jit-arch.h to
the arch specific header in the include dir.
2010-08-03 Klaus Treichel <ktreichel@web.de>
* Makefile.am: Add config to the subdirectories.
* configure.ac: Add config/Makefile the the makefiles to generate.
libjit/attic/jit-gen-alpha.h view on Meta::CPAN
/*
* jit-gen-alpha.h - Code generation macros for the alpha processor.
*
* Copyright (C) 2006 Southern Storm Software, Pty Ltd.
*
* This file is part of the libjit library.
*
* The libjit library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 2.1 of
* the License, or (at your option) any later version.
*
libjit/attic/jit-rules-alpha.c view on Meta::CPAN
* alpha_trapb(inst);
*
* RETURN VALUE:
* - TRUE if the CPU fully supports IEEE floating-point (i.e. >=ev6)
* - FALSE if the CPU needs kernel assistance
*/
int _alpha_has_ieeefp() {
unsigned long __implver;
/*
* __implver - major version number of the processor
*
* (__implver == 0) ev4 class processors
* (__implver == 1) ev5 class processors
* (__implver == 2) ev6 class processors
*/
__asm__ ("implver %0" : "=r"(__implver));
return (__implver >= 2);
}
/*
* Round a size up to a multiple of the stack word size.
*/
#define ROUND_STACK(size) \
(((size) + (sizeof(alpha_inst) - 1)) & ~(sizeof(alpha_inst) - 1))
/*
* Setup or teardown the alpha code output process.
*/
#define jit_cache_setup_output(needed) \
alpha_inst inst = (alpha_inst) gen->ptr; \
_jit_gen_check_space(gen, (needed))
#define jit_cache_end_output() \
gen->ptr = (unsigned char*) inst
/*
* Load the instruction pointer from the generation context.
libjit/attic/jit-rules-alpha.c view on Meta::CPAN
info->machine = EM_ALPHA;
info->abi = ELFOSABI_SYSV;
info->abi_version = 0;
}
/*
* Generate the prolog for a function into a previously-prepared buffer
* area of JIT_PROLOG_SIZE bytes in size. Returns the start of the
* prolog, which may be different than buf.
*
* This function is called at the end of the code generation process,
* not the beginning. At this point, it is known which callee save
* registers must be preserved, allowing the back end to output the
* most compact prolog possible.
*/
void *_jit_gen_prolog(jit_gencode_t gen, jit_function_t func, void *buf) {
unsigned int prolog[JIT_PROLOG_SIZE];
alpha_inst inst = prolog;
/* Compute and load the global pointer (2 instruction) */
alpha_ldah(inst,ALPHA_GP,ALPHA_PV,0);
libjit/attic/jit-rules-alpha.c view on Meta::CPAN
return (void *) buf;
}
/*
* Generate a function epilog, restoring the registers that were saved on entry to the
* function, and then returning.
*
* Only one epilog is generated per function. Functions with multiple jit_insn_return
* instructions will all jump to the common epilog. This is needed because the code
* generator may not know which callee save registers need to be restored by the
* epilog until the full function has been processed.
*/
void _jit_gen_epilog(jit_gencode_t gen, jit_function_t func) {
void **fixup, **next;
jit_cache_setup_output(20);
/* Perform fixups on any blocks that jump to the epilog */
fixup = (void **)(gen->epilog_fixup);
while (fixup) {
alpha_inst code = (alpha_inst) fixup;
libjit/attic/jit-rules-alpha.c view on Meta::CPAN
* perform floating-point.
*
* If this function returns zero, then jit-insn.c will output a call to an intrinsic
* function that is equivalent to the desired opcode. This is how you tell libjit that
* you cannot handle the opcode natively.
*
* This function can also help you develop your back end incrementally. Initially, you
* can report that only integer operations are supported, and then once you have them
* working you can move on to the floating point operations.
*
* Since alpha processors below ev6 need help with floating-point, we'll use the
* intrinsic floating-point functions on this systems.
*/
int _jit_opcode_is_supported(int opcode) {
switch(opcode) {
#define JIT_INCLUDE_SUPPORTED
#include "jit-rules-alpha.inc"
#undef JIT_INCLUDE_SUPPORTED
}
libjit/doc/libjit.3 view on Meta::CPAN
.TH libjit 3 "18 April 2004" "Southern Storm Software" "Just-In-Time Compiler Library"
.SH NAME
libjit \- Just-In-Time Compiler Library
.SH SYNOPSIS
.B #include <jit/jit.h>
Link with
.B -ljit
.SH DESCRIPTION
The \fBlibjit\fR library has an extensive set of routines that takes care
of the bulk of the Just-In-Time compilation process, without tying the
programmer down with language or bytecode specifics.
Unlike other systems such as the JVM, .NET, Parrot, and LLVM, \fBlibjit\fR
is not a virtual machine in its own right. It is the foundation upon which a
number of different virtual machines, dynamic scripting languages, etc,
can be built.
.SH "AUTHOR"
Written by Southern Storm Software, Pty Ltd.
http://www.southern-storm.com.au/
libjit/doc/libjit.texi view on Meta::CPAN
@settitle Just-In-Time Compiler Library
@setchapternewpage off
@c %** end of header
@dircategory Libraries
@direntry
* Libjit: (libjit). Just-In-Time Compiler Library
@end direntry
@ifinfo
The libjit library assists with the process of building
Just-In-Time compilers for languages, virtual machines,
and emulators.
Copyright @copyright{} 2004 Southern Storm Software, Pty Ltd
@end ifinfo
@titlepage
@sp 10
@center @titlefont{Just-In-Time Compiler Library}
libjit/doc/libjit.texi view on Meta::CPAN
on the fly, customized to the rendering task at hand, rather than using
static routines. Needless to say, such applications have no need for
object models, garbage collectors, or huge runtime class libraries.
Most of the work on a JIT is concerned with arithmetic, numeric type
conversion, memory loads/stores, looping, performing data flow analysis,
assigning registers, and generating the executable machine code.
Only a very small proportion of the work is concerned with language specifics.
The goal of the @code{libjit} project is to provide an extensive set of
routines that takes care of the bulk of the JIT process, without tying the
programmer down with language specifics. Where we provide support for
common object models, we do so strictly in add-on libraries,
not as part of the core code.
Unlike other systems such as the JVM, .NET, and Parrot, @code{libjit}
is not a virtual machine in its own right. It is the foundation upon which a
number of different virtual machines, dynamic scripting languages,
or customized rendering routines can be built.
The LLVM project (@uref{http://www.llvm.org/}) has some similar
libjit/doc/libjit.texi view on Meta::CPAN
...
context = jit_context_create();
@end example
Almost everything that is done with @code{libjit} is done relative
to a context. In particular, a context holds all of the functions
that you have built and compiled.
You can have multiple contexts at any one time, but normally you will
only need one. Multiple contexts may be useful if you wish to
run multiple virtual machines side by side in the same process,
without them interfering with each other.
Whenever we are constructing a function, we need to lock down the
context to prevent multiple threads from using the builder at a time:
@example
jit_context_build_start(context);
@end example
The next step is to construct the function object that will represent
libjit/doc/libjit.texi view on Meta::CPAN
parameter values:
@example
jit_value_t x, y, z;
...
x = jit_value_get_param(function, 0);
y = jit_value_get_param(function, 1);
z = jit_value_get_param(function, 2);
@end example
Values are one of the two cornerstones of the @code{libjit} process.
Values represent parameters, local variables, and intermediate
temporary results. Once we have the parameters, we compute
the result of @code{x * y + z} as follows:
@example
jit_value_t temp1, temp2;
...
temp1 = jit_insn_mul(function, x, y);
temp2 = jit_insn_add(function, temp1, z);
@end example
This demonstrates the other cornerstone of the @code{libjit} process:
instructions. Each of these instructions takes two values as arguments
and returns a new temporary value with the result.
Students of compiler design will notice that the above statements look
very suspiciously like the "three address statements" that are described
in compiler textbooks. And that is indeed what they are internally within
@code{libjit}.
If you don't know what three address statements are, then don't worry.
The library hides most of the details from you. All you need to do is
libjit/doc/libjit.texi view on Meta::CPAN
the temporary values in subsequent steps. @xref{Instructions}, for
a complete list of all instructions that are supported by @code{libjit}.
Now that we have computed the desired result, we return it to the caller
using @code{jit_insn_return}:
@example
jit_insn_return(function, temp2);
@end example
We have completed the process of building the function body. Now we
compile it into its executable form:
@example
jit_function_compile(function);
jit_context_build_end(context);
@end example
As a side-effect, this will discard all of the memory associated with
the values and instructions that we constructed while building the
function. They are no longer required, because we now have the
executable form that we require.
We also unlock the context, because it is now safe for other threads
to access the function building process.
Up until this point, we haven't executed the @code{mul_add} function.
All we have done is build and compile it, ready for execution. To execute it,
we call @code{jit_function_apply}:
@example
jit_int arg1, arg2, arg3;
void *args[3];
jit_int result;
...
libjit/doc/libjit.texi view on Meta::CPAN
insn_return(x * y + z);
@}
@end example
This is similar to the first version that we wrote in Tutorial 1.
Instructions are created with @code{insn_*} methods that correspond
to their @code{jit_insn_*} counterparts in the C library.
One of the nice things about the C++ API compared to the C API is that we
can use overloaded operators to manipulate @code{jit_value} objects.
This can simplify the function build process considerably when we
have lots of expressions to compile. We could have used @code{insn_mul}
and @code{insn_add} instead in this example and the result would have
been the same.
Now that we have our @code{mul_add_function} class, we can create
an instance of the function and apply it as follows:
@example
jit_context context;
mul_add_function mul_add(context);
libjit/dpas/dpas-parser.y view on Meta::CPAN
} Statement
;
WhileStatement
: K_WHILE {
jit_label_t label = jit_label_undefined;
/* Jump to the beginning of the expression block.
Right now, the expression block is at the head
of the loop body. Once we've process the entire
body, we will move the expression block to the end */
if(!jit_insn_branch(dpas_current_function(), &label))
{
dpas_out_of_memory();
}
/* Mark the start of the expression block */
if(!jit_insn_label(dpas_current_function(), &label))
{
dpas_out_of_memory();
libjit/dpas/dpas-scanner.l view on Meta::CPAN
dpas_filename = filename;
dpas_linenum = 1;
yy_switch_to_buffer(new_buffer);
/* Call the parser */
if(yyparse())
{
dpas_error_reported = 1;
}
/* Bail out if this was the top-most file in the parse process,
because flex cannot switch to a NULL buffer */
if(!saved_buffer)
{
return;
}
/* Switch back to the original file */
dpas_filename = saved_filename;
dpas_linenum = saved_linenum;
yy_switch_to_buffer(saved_buffer);
libjit/include/jit/jit-common.h view on Meta::CPAN
*/
#define JIT_NO_OFFSET (~((unsigned int)0))
/*
* Function that is used to free user-supplied metadata.
*/
typedef void (*jit_meta_free_func)(void *data);
/*
* Function that is used to compile a function on demand.
* Returns zero if the compilation process failed for some reason.
*/
typedef int (*jit_on_demand_func)(jit_function_t func);
/*
* Function that is used to control on demand compilation.
* Typically, it should take care of the context locking and unlocking,
* calling function's on demand compiler, and final compilation.
*/
typedef void *(*jit_on_demand_driver_func)(jit_function_t func);
libjit/jit/jit-compile.c view on Meta::CPAN
#endif
/* Perform code generation */
codegen(state);
#ifdef jit_extra_gen_cleanup
/* Clean up the extra code generation state */
jit_extra_gen_cleanup(&state->gen);
#endif
/* End the function's output process */
memory_flush(state);
/* Compilation done, no exceptions occurred */
result = JIT_RESULT_OK;
exit:
/* Release the memory context */
memory_release(state);
/* Restore the "setjmp" context */
libjit/jit/jit-context.c view on Meta::CPAN
care of that. But the library is thread-aware, as long as you take
some very simple steps.
In a multi-threaded environment, you must ensure that only one
thread can build functions at any one time. Otherwise the
JIT's context may become corrupted. To protect the system,
you should call @code{jit_context_build_start} before
creating the function. And then call @code{jit_context_build_end}
once the function has been fully compiled.
You can compile multiple functions during the one build process
if you wish, which is the normal case when compiling a class.
It is usually a good idea to suspend the finalization of
garbage-collected objects while function building is in progress.
Otherwise you may get a deadlock when the finalizer thread tries
to call the builder to compile a finalization routine. Suspension
of finalization is the responsibility of the caller.
@section Context functions
@cindex jit-context.h
libjit/jit/jit-context.c view on Meta::CPAN
jit_mutex_destroy(&context->memory_lock);
jit_mutex_destroy(&context->builder_lock);
jit_free(context);
}
/*@
* @deftypefun void jit_context_build_start (jit_context_t @var{context})
* This routine should be called before you start building a function
* to be JIT'ed. It acquires a lock on the context to prevent other
* threads from accessing the build process, since only one thread
* can be performing build operations at any one time.
* @end deftypefun
@*/
void
jit_context_build_start(jit_context_t context)
{
jit_mutex_lock(&context->builder_lock);
}
/*@
libjit/jit/jit-debugger.c view on Meta::CPAN
location. When a break occurs, the debugging routines are passed
@var{func}, @var{data1}, and @var{data2} as arguments. By convention,
@var{data1} is the type of breakpoint (source line, function entry,
function exit, etc).
@end deftypefun
There are two ways for a front end to receive notification about breakpoints.
The bulk of this chapter describes the @code{jit_debugger_t} interface,
which handles most of the ugly details. In addition, a low-level "debug hook
mechanism" is provided for front ends that wish more control over the
process. The debug hook mechanism is described below, under the
@code{jit_debugger_set_hook} function.
This debugger implementation requires a threading system to work
successfully. At least two threads are required, in addition to those of
the program being debugged:
@enumerate
@item
Event thread which calls @code{jit_debugger_wait_event} to receive
notifications of breakpoints and other interesting events.
@item
User interface thread which calls functions like @code{jit_debugger_run},
@code{jit_debugger_step}, etc, to control the debug process.
@end enumerate
These two threads should be set to "unbreakable" with a call to
@code{jit_debugger_set_breakable}. This prevents them from accidentally
stopping at a breakpoint, which would cause a system deadlock.
Other housekeeping threads, such as a finalization thread, should
also be set to "unbreakable" for the same reason.
@noindent
Events have the following members:
libjit/jit/jit-dump.c view on Meta::CPAN
#endif /* !JIT_BACKEND_INTERP */
/*@
* @deftypefun void jit_dump_function (FILE *@var{stream}, jit_function_t @var{func}, const char *@var{name})
* Dump the three-address instructions within a function to a stream.
* The @var{name} is attached to the output as a friendly label, but
* has no other significance.
*
* If the function has not been compiled yet, then this will dump the
* three address instructions from the build process. Otherwise it will
* disassemble and dump the compiled native code.
* @end deftypefun
@*/
void jit_dump_function(FILE *stream, jit_function_t func, const char *name)
{
jit_block_t block;
jit_insn_iter_t iter;
jit_insn_t insn;
jit_type_t signature;
unsigned int param;
libjit/jit/jit-elf-defs.h view on Meta::CPAN
#define EM_H8_300H 47 /* Hitachi H8/300H */
#define EM_H8S 48 /* Hitachi H8S */
#define EM_H8_500 49 /* Hitachi H8/500 */
#define EM_IA_64 50 /* Intel Merced */
#define EM_MIPS_X 51 /* Stanford MIPS-X */
#define EM_COLDFIRE 52 /* Motorola Coldfire */
#define EM_68HC12 53 /* Motorola M68HC12 */
#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/
#define EM_PCP 55 /* Siemens PCP */
#define EM_NCPU 56 /* Sony nCPU embeeded RISC */
#define EM_NDR1 57 /* Denso NDR1 microprocessor */
#define EM_STARCORE 58 /* Motorola Start*Core processor */
#define EM_ME16 59 /* Toyota ME16 processor */
#define EM_ST100 60 /* STMicroelectronic ST100 processor */
#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/
#define EM_X86_64 62 /* AMD x86-64 architecture */
#define EM_PDSP 63 /* Sony DSP Processor */
#define EM_FX66 66 /* Siemens FX66 microcontroller */
#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */
#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */
#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */
#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */
#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */
#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */
#define EM_SVX 73 /* Silicon Graphics SVx */
#define EM_AT19 74 /* STMicroelectronics ST19 8 bit mc */
#define EM_VAX 75 /* Digital VAX */
#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */
#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */
#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */
#define EM_HUANY 81 /* Harvard University machine-independent object files */
#define EM_PRISM 82 /* SiTera Prism */
#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
#define EM_FR30 84 /* Fujitsu FR30 */
#define EM_D10V 85 /* Mitsubishi D10V */
#define EM_D30V 86 /* Mitsubishi D30V */
#define EM_V850 87 /* NEC v850 */
#define EM_M32R 88 /* Mitsubishi M32R */
#define EM_MN10300 89 /* Matsushita MN10300 */
#define EM_MN10200 90 /* Matsushita MN10200 */
#define EM_PJ 91 /* picoJava */
#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
#define EM_NUM 95
/* If it is necessary to assign new unofficial EM_* values, please
pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
chances of collision with official or non-GNU unofficial values. */
/*
* This is an interim value that will be used until the committee comes
libjit/jit/jit-elf-defs.h view on Meta::CPAN
Elf64_Word sh_link; /* Link to another section */
Elf64_Word sh_info; /* Additional section information */
Elf64_Xword sh_addralign; /* Section alignment */
Elf64_Xword sh_entsize; /* Entry size if section holds table */
} Elf64_Shdr;
/* Special section indices. */
#define SHN_UNDEF 0 /* Undefined section */
#define SHN_LORESERVE 0xff00 /* Start of reserved indices */
#define SHN_LOPROC 0xff00 /* Start of processor-specific */
#define SHN_HIPROC 0xff1f /* End of processor-specific */
#define SHN_LOOS 0xff20 /* Start of OS-specific */
#define SHN_HIOS 0xff3f /* End of OS-specific */
#define SHN_ABS 0xfff1 /* Associated symbol is absolute */
#define SHN_COMMON 0xfff2 /* Associated symbol is common */
#define SHN_XINDEX 0xffff /* Index is in extra table. */
#define SHN_HIRESERVE 0xffff /* End of reserved indices */
/* Legal values for sh_type (section type). */
#define SHT_NULL 0 /* Section header table entry unused */
libjit/jit/jit-elf-defs.h view on Meta::CPAN
#define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */
#define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */
#define SHT_SUNW_move 0x6ffffffa
#define SHT_SUNW_COMDAT 0x6ffffffb
#define SHT_SUNW_syminfo 0x6ffffffc
#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */
#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */
#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */
#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */
#define SHT_HIOS 0x6fffffff /* End OS-specific type */
#define SHT_LOPROC 0x70000000 /* Start of processor-specific */
#define SHT_HIPROC 0x7fffffff /* End of processor-specific */
#define SHT_LOUSER 0x80000000 /* Start of application-specific */
#define SHT_HIUSER 0x8fffffff /* End of application-specific */
/* Legal values for sh_flags (section flags). */
#define SHF_WRITE (1 << 0) /* Writable */
#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */
#define SHF_EXECINSTR (1 << 2) /* Executable */
#define SHF_MERGE (1 << 4) /* Might be merged */
#define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */
libjit/jit/jit-elf-defs.h view on Meta::CPAN
#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type))
/* Legal values for ST_BIND subfield of st_info (symbol binding). */
#define STB_LOCAL 0 /* Local symbol */
#define STB_GLOBAL 1 /* Global symbol */
#define STB_WEAK 2 /* Weak symbol */
#define STB_NUM 3 /* Number of defined types. */
#define STB_LOOS 10 /* Start of OS-specific */
#define STB_HIOS 12 /* End of OS-specific */
#define STB_LOPROC 13 /* Start of processor-specific */
#define STB_HIPROC 15 /* End of processor-specific */
/* Legal values for ST_TYPE subfield of st_info (symbol type). */
#define STT_NOTYPE 0 /* Symbol type is unspecified */
#define STT_OBJECT 1 /* Symbol is a data object */
#define STT_FUNC 2 /* Symbol is a code object */
#define STT_SECTION 3 /* Symbol associated with a section */
#define STT_FILE 4 /* Symbol's name is file name */
#define STT_COMMON 5 /* Symbol is a common data object */
#define STT_NUM 6 /* Number of defined types. */
#define STT_LOOS 10 /* Start of OS-specific */
#define STT_HIOS 12 /* End of OS-specific */
#define STT_LOPROC 13 /* Start of processor-specific */
#define STT_HIPROC 15 /* End of processor-specific */
/* Symbol table indices are found in the hash buckets and chain table
of a symbol hash table section. This special index value indicates
the end of a chain, meaning no further symbols are found in that bucket. */
#define STN_UNDEF 0 /* End of a chain. */
/* How to extract and insert information held in the st_other field. */
libjit/jit/jit-elf-defs.h view on Meta::CPAN
#define PT_DYNAMIC 2 /* Dynamic linking information */
#define PT_INTERP 3 /* Program interpreter */
#define PT_NOTE 4 /* Auxiliary information */
#define PT_SHLIB 5 /* Reserved */
#define PT_PHDR 6 /* Entry for header table itself */
#define PT_TLS 7 /* Thread-local storage segment */
#define PT_NUM 8 /* Number of defined types */
#define PT_LOOS 0x60000000 /* Start of OS-specific */
#define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */
#define PT_HIOS 0x6fffffff /* End of OS-specific */
#define PT_LOPROC 0x70000000 /* Start of processor-specific */
#define PT_HIPROC 0x7fffffff /* End of processor-specific */
/* Legal values for p_flags (segment flags). */
#define PF_X (1 << 0) /* Segment is executable */
#define PF_W (1 << 1) /* Segment is writable */
#define PF_R (1 << 2) /* Segment is readable */
#define PF_MASKOS 0x0ff00000 /* OS-specific */
#define PF_MASKPROC 0xf0000000 /* Processor-specific */
/* Legal values for note segment descriptor types for core files. */
libjit/jit/jit-elf-defs.h view on Meta::CPAN
#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */
#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */
#define DT_RUNPATH 29 /* Library search path */
#define DT_FLAGS 30 /* Flags for the object being loaded */
#define DT_ENCODING 32 /* Start of encoded range */
#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/
#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */
#define DT_NUM 34 /* Number used */
#define DT_LOOS 0x60000000 /* Start of OS-specific */
#define DT_HIOS 0x6fffffff /* End of OS-specific */
#define DT_LOPROC 0x70000000 /* Start of processor-specific */
#define DT_HIPROC 0x7fffffff /* End of processor-specific */
#define DT_PROCNUM DT_MIPS_NUM /* Most used by any processor */
/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the
Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's
approach. */
#define DT_VALRNGLO 0x6ffffd00
#define DT_GNU_PRELINKED 0x6ffffdf5 /* Prelinking timestamp */
#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* Size of conflict section */
#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* Size of library list */
#define DT_CHECKSUM 0x6ffffdf8
#define DT_PLTPADSZ 0x6ffffdf9
libjit/jit/jit-elf-defs.h view on Meta::CPAN
#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */
#define DT_VERDEF 0x6ffffffc /* Address of version definition
table */
#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */
#define DT_VERNEED 0x6ffffffe /* Address of table with needed
versions */
#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */
#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
#define DT_VERSIONTAGNUM 16
/* Sun added these machine-independent extensions in the "processor-specific"
range. Be compatible. */
#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */
#define DT_FILTER 0x7fffffff /* Shared object to get values from */
#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)
#define DT_EXTRANUM 3
/* Values of `d_un.d_val' in the DT_FLAGS entry. */
#define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */
#define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */
#define DF_TEXTREL 0x00000004 /* Object contains text relocations */
libjit/jit/jit-elf-defs.h view on Meta::CPAN
#define AT_NOTELF 10 /* Program is not ELF */
#define AT_UID 11 /* Real uid */
#define AT_EUID 12 /* Effective uid */
#define AT_GID 13 /* Real gid */
#define AT_EGID 14 /* Effective gid */
#define AT_CLKTCK 17 /* Frequency of times() */
/* Some more special a_type values describing the hardware. */
#define AT_PLATFORM 15 /* String identifying platform. */
#define AT_HWCAP 16 /* Machine dependent hints about
processor capabilities. */
/* This entry gives some information about the FPU initialization
performed by the kernel. */
#define AT_FPUCW 18 /* Used FPU control word. */
/* Cache block sizes. */
#define AT_DCACHEBSIZE 19 /* Data cache block size. */
#define AT_ICACHEBSIZE 20 /* Instruction cache block size. */
#define AT_UCACHEBSIZE 21 /* Unified cache block size. */
libjit/jit/jit-elf-defs.h view on Meta::CPAN
Elf32_Word gt_g_value; /* If this value were used for -G */
Elf32_Word gt_bytes; /* This many bytes would be used */
} gt_entry; /* Subsequent entries in section */
} Elf32_gptab;
/* Entry found in sections of type SHT_MIPS_REGINFO. */
typedef struct
{
Elf32_Word ri_gprmask; /* General registers used */
Elf32_Word ri_cprmask[4]; /* Coprocessor registers used */
Elf32_Sword ri_gp_value; /* $gp register value */
} Elf32_RegInfo;
/* Entries found in sections of type SHT_MIPS_OPTIONS. */
typedef struct
{
unsigned char kind; /* Determines interpretation of the
variable part of descriptor. */
unsigned char size; /* Size of descriptor, including header. */
Elf32_Section section; /* Section header index of section affected,
0 for global options. */
Elf32_Word info; /* Kind-specific information. */
} Elf_Options;
/* Values for `kind' field in Elf_Options. */
#define ODK_NULL 0 /* Undefined. */
#define ODK_REGINFO 1 /* Register usage information. */
#define ODK_EXCEPTIONS 2 /* Exception processing options. */
#define ODK_PAD 3 /* Section padding options. */
#define ODK_HWPATCH 4 /* Hardware workarounds performed */
#define ODK_FILL 5 /* record the fill value used by the linker. */
#define ODK_TAGS 6 /* reserve space for desktop tools to write. */
#define ODK_HWAND 7 /* HW workarounds. 'AND' bits when merging. */
#define ODK_HWOR 8 /* HW workarounds. 'OR' bits when merging. */
/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries. */
#define OEX_FPU_MIN 0x1f /* FPE's which MUST be enabled. */
libjit/jit/jit-elf-write.c view on Meta::CPAN
jit_memzero(&dyn, sizeof(dyn));
dyn.d_tag = type;
dyn.d_un.d_ptr = value;
/* Add the entry to the section's contents */
return add_to_section(section, &dyn, sizeof(dyn));
}
/*@
* @deftypefun jit_writeelf_t jit_writeelf_create (const char *@var{library_name})
* Create an object to assist with the process of writing an ELF binary.
* The @var{library_name} will be embedded into the binary. Returns NULL
* if out of memory.
* @end deftypefun
@*/
jit_writeelf_t jit_writeelf_create(const char *library_name)
{
jit_writeelf_t writeelf;
Elf_Word name_index;
union
{
libjit/jit/jit-function.c view on Meta::CPAN
#include "jit-setjmp.h"
/*@
* @deftypefun jit_function_t jit_function_create (jit_context_t @var{context}, jit_type_t @var{signature})
* Create a new function block and associate it with a JIT context.
* Returns NULL if out of memory.
*
* A function persists for the lifetime of its containing context.
* It initially starts life in the "building" state, where the user
* constructs instructions that represents the function body.
* Once the build process is complete, the user calls
* @code{jit_function_compile} to convert it into its executable form.
*
* It is recommended that you call @code{jit_context_build_start} before
* calling @code{jit_function_create}, and then call
* @code{jit_context_build_end} after you have called
* @code{jit_function_compile}. This will protect the JIT's internal
* data structures within a multi-threaded environment.
* @end deftypefun
@*/
jit_function_t
libjit/jit/jit-function.c view on Meta::CPAN
_jit_memory_free_trampoline(context, func->indirector);
# endif
#endif
_jit_memory_free_function(context, func);
_jit_memory_unlock(context);
}
/*@
* @deftypefun void jit_function_abandon (jit_function_t @var{func})
* Abandon this function during the build process. This should be called
* when you detect a fatal error that prevents the function from being
* properly built. The @var{func} object is completely destroyed and
* detached from its owning context. The function is left alone if
* it was already compiled.
* @end deftypefun
@*/
void jit_function_abandon(jit_function_t func)
{
if(func && func->builder)
{
libjit/jit/jit-function.c view on Meta::CPAN
}
return _jit_memory_get_function(context, func_info);
#endif
}
/*@
* @deftypefun void jit_function_set_on_demand_compiler (jit_function_t @var{func}, jit_on_demand_func @var{on_demand})
* Specify the C function to be called when @var{func} needs to be
* compiled on-demand. This should be set just after the function
* is created, before any build or compile processes begin.
*
* You won't need an on-demand compiler if you always build and compile
* your functions before you call them. But if you can call a function
* before it is built, then you must supply an on-demand compiler.
*
* When on-demand compilation is requested, @code{libjit} takes the following
* actions:
*
* @enumerate
* @item
libjit/jit/jit-gen-arm.h view on Meta::CPAN
/*
* jit-gen-arm.h - Code generation macros for the ARM processor.
*
* Copyright (C) 2003, 2004 Southern Storm Software, Pty Ltd.
* Copyright (C) 2008, 2009 Michele Tartara <mikyt@users.sourceforge.net>
*
* This file is part of the libjit library.
*
* The libjit library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 2.1 of
* the License, or (at your option) any later version.
libjit/jit/jit-insn.c view on Meta::CPAN
return jit_insn_move_blocks_to_start(func, start_label, end_label);
#else
/* The interpreter doesn't need the "setjmp" setup block */
func->builder->catcher_label = jit_label_undefined;
return 1;
#endif
}
/*@
* @deftypefun int jit_insn_uses_catcher (jit_function_t @var{func})
* Notify the function building process that @var{func} contains
* some form of @code{catch} clause for catching exceptions. This must
* be called before any instruction that is covered by a @code{try},
* ideally at the start of the function output process.
* @end deftypefun
@*/
int jit_insn_uses_catcher(jit_function_t func)
{
if(!_jit_function_ensure_builder(func))
{
return 0;
}
if(func->has_try)
{
libjit/jit/jit-insn.c view on Meta::CPAN
}
/*@
* @deftypefun jit_value_t jit_insn_start_filter (jit_function_t @var{func}, jit_label_t *@var{label}, jit_type_t @var{type})
* Define the start of a filter. Filters are embedded subroutines within
* functions that are used to filter exceptions in @code{catch} blocks.
*
* A filter subroutine takes a single argument (usually a pointer) and
* returns a single result (usually a boolean). The filter has complete
* access to the local variables of the function, and can use any of
* them in the filtering process.
*
* This function returns a temporary value of the specified @var{type},
* indicating the parameter that is supplied to the filter.
* @end deftypefun
@*/
jit_value_t jit_insn_start_filter
(jit_function_t func, jit_label_t *label, jit_type_t type)
{
/* Set a label at this point to start a new block */
if(!jit_insn_label(func, label))
libjit/jit/jit-internal.h view on Meta::CPAN
/*
* Internal structure of a context.
*/
struct _jit_context
{
/* The context's memory control */
jit_memory_manager_t memory_manager;
jit_memory_context_t memory_context;
jit_mutex_t memory_lock;
/* Lock that controls access to the building process */
jit_mutex_t builder_lock;
/* List of functions that are currently registered with the context */
jit_function_t functions;
jit_function_t last_function;
/* Metadata that is associated with the context */
jit_meta_t meta;
/* ELF binaries that have been loaded into this context */
libjit/jit/jit-memory-cache.c view on Meta::CPAN
The function initializes the "posn" structure to point to the start
and end of the space available for the method output. The function
returns one of three result codes:
JIT_CACHE_OK The function call was successful.
JIT_CACHE_RESTART The cache does not currently have enough
space to fit any method. This code may
only be returned if the "factor" value
was 0. In this case it is necessary to
restart the method output process by
calling _jit_cache_start_method again
with a bigger "factor" value.
JIT_CACHE_TOO_BIG The cache does not have any space left
for allocation. In this case a restart
won't help.
Some CPU optimization guides recommend that labels should be aligned.
This can be achieved using _jit_cache_align.
Once the method code has been output, call _jit_cache_end_method to finalize
the process. This function returns one of two result codes:
JIT_CACHE_OK The method output process was successful.
JIT_CACHE_RESTART The cache space overflowed. It is necessary
to restart the method output process by
calling _jit_cache_start_method again
with a bigger "factor" value.
The caller should repeatedly translate the method while _jit_cache_end_method
continues to return JIT_CACHE_END_RESTART. Normally there will be no
more than a single request to restart, but the caller should not rely
upon this. The cache algorithm guarantees that the restart loop will
eventually terminate.
Cache data structure
--------------------
The cache consists of one or more "cache pages", which contain method
code and auxiliary data. The default size for a cache page is 64k
(JIT_CACHE_PAGE_SIZE). The size is adjusted to be a multiple
of the system page size (usually 4k), and then stored in "pageSize".
Method code is written into a cache page starting at the bottom of the
page, and growing upwards. Auxiliary data is written into a cache page
starting at the top of the page, and growing downwards. When the two
regions meet, a new cache page is allocated and the process restarts.
To allow methods bigger than a single cache page it is possible to
allocate a block of consecutive pages as a single unit. The method
code and auxiliary data is written to such a multiple-page block in
the same manner as into an ordinary page.
Each method has one or more jit_cache_method auxiliary data blocks associated
with it. These blocks indicate the start and end of regions within the
method. Normally these regions correspond to exception "try" blocks, or
regular code between "try" blocks.
The jit_cache_method blocks are organised into a red-black tree, which
is used to perform fast lookups by address (_jit_cache_get_method). These
lookups are used when walking the stack during exceptions or security
processing.
Each method can also have offset information associated with it, to map
between native code addresses and offsets within the original bytecode.
This is typically used to support debugging. Offset information is stored
as auxiliary data, attached to the jit_cache_method block.
Threading issues
----------------
Writing a method to the cache, querying a method by address, or querying
libjit/jit/jit-objmodel.c view on Meta::CPAN
*/
#include <jit/jit.h>
#include <jit/jit-objmodel-private.h>
/*@
The @code{libjit} library does not implement a particular object model
of its own, so that it is generic across bytecode formats and front end
languages. However, it does provide support for plugging object models
into the JIT process, and for transparently proxying to external libraries
that may use a foreign object model.
There may be more than one object model active in the system at any
one time. For example, a JVM implementation might have a primary
object model for its own use, and a secondary object model for
calling methods in an imported Objective C library.
The functions in this section support pluggable object models. There is
no requirement that you use them: you can ignore them and use the rest
of @code{libjit} directly if you wish.
libjit/jit/jit-rules-arm.c view on Meta::CPAN
ptr = (void *)&(func->entry_point);
entry = gen->ptr;
arm_load_membase(inst, ARM_WORK, ARM_PC, 0);
arm_load_membase(inst, ARM_PC, ARM_WORK, 0);
arm_inst_add(inst, (unsigned int)ptr);
jit_gen_save_inst_ptr(gen, inst);
return entry;
}
#endif
/*
* Setup or teardown the ARM code output process.
*/
#define jit_cache_setup_output(needed) \
arm_inst_buf inst; \
jit_gen_load_inst_ptr(gen, inst)
#define jit_cache_end_output() \
jit_gen_save_inst_ptr(gen, inst)
/**
* Spill the content of register "reg" (and "other_reg", if it's different from -1)
* into the global register or the memory area associated with "value"
libjit/jit/jit-rules-arm.c view on Meta::CPAN
else if(jit_type_normalize(value->type)->kind == JIT_TYPE_FLOAT32)
{
arm_store_membase_float32(inst, _jit_reg_info[value->reg].cpu_reg, ARM_FP, offset);
}
else
{
arm_store_membase_float64(inst, _jit_reg_info[value->reg].cpu_reg, ARM_FP, offset);
}
}
/* End the code output process */
jit_cache_end_output();
}
void _jit_gen_free_reg(jit_gencode_t gen, int reg,
int other_reg, int value_used)
{
/* We don't have to do anything to free ARM registers */
}
/*
libjit/jit/jit-rules-arm.c view on Meta::CPAN
else
{
arm_load_membase_float64
(inst, _jit_reg_info[reg].cpu_reg, ARM_FP, offset);
}
}
break;
}
}
/* End the code output process */
jit_cache_end_output();
}
/**
* Loads a struct indicated by "value" into the given register reg
*/
void _jit_gen_load_value_struct (jit_gencode_t gen, int reg, jit_value_t value)
{
int offset;
libjit/jit/jit-rules-arm.c view on Meta::CPAN
arm_load_membase(inst, _jit_reg_info[reg].cpu_reg, ARM_FP, offset);
if (jit_type_get_size(jit_value_get_type(value)) > 4)
{
TODO();
abort();
}
}
/* End the code output process */
jit_cache_end_output();
}
void _jit_gen_spill_global(jit_gencode_t gen, int reg, jit_value_t value)
{
/* TODO: Implement if ARM needs it. */
}
void _jit_gen_load_global(jit_gencode_t gen, int reg, jit_value_t value)
{
libjit/jit/jit-rules-interp.c view on Meta::CPAN
/* Return the final size to the caller */
return size;
}
/*@
* @deftypefun {void *} _jit_gen_prolog (jit_gencode_t @var{gen}, jit_function_t @var{func}, void *@var{buf})
* Generate the prolog for a function into a previously-prepared
* buffer area of @code{JIT_PROLOG_SIZE} bytes in size. Returns
* the start of the prolog, which may be different than @var{buf}.
*
* This function is called at the end of the code generation process,
* not the beginning. At this point, it is known which callee save
* registers must be preserved, allowing the back end to output the
* most compact prolog possible.
* @end deftypefun
@*/
void *_jit_gen_prolog(jit_gencode_t gen, jit_function_t func, void *buf)
{
/* Output the jit_function_interp structure at the beginning */
jit_function_interp_t interp = (jit_function_interp_t)buf;
unsigned int max_working_area =
libjit/jit/jit-rules-interp.c view on Meta::CPAN
/*@
* @deftypefun void _jit_gen_epilog (jit_gencode_t @var{gen}, jit_function_t @var{func})
* Generate a function epilog, restoring the registers that
* were saved on entry to the function, and then returning.
*
* Only one epilog is generated per function. Functions with multiple
* @code{jit_insn_return} instructions will all jump to the common epilog.
* This is needed because the code generator may not know which callee
* save registers need to be restored by the epilog until the full function
* has been processed.
* @end deftypefun
@*/
void _jit_gen_epilog(jit_gencode_t gen, jit_function_t func)
{
/* The interpreter doesn't use epilogs */
}
/*@
* @deftypefun {void *} _jit_gen_redirector (jit_gencode_t @var{gen}, jit_function_t @var{func})
* Generate code for a redirector, which makes an indirect jump
libjit/jit/jit-rules-x86-64.c view on Meta::CPAN
#define HAVE_X86_SSE_3 0
#define HAVE_X86_FISTTP 0
*/
#define TODO() \
do { \
fprintf(stderr, "TODO at %s, %d\n", __FILE__, (int)__LINE__); \
} while(0)
/*
* Setup or teardown the x86 code output process.
*/
#define jit_cache_setup_output(needed) \
unsigned char *inst = gen->ptr; \
_jit_gen_check_space(gen, (needed))
#define jit_cache_end_output() \
gen->ptr = inst
/*
* Set this to 1 for debugging fixups
libjit/jit/jit-rules-x86-64.c view on Meta::CPAN
/* Fix the value in place within the local variable frame */
_jit_gen_fix_value(value);
/* Get the normalized type */
type = jit_type_normalize(value->type);
/* and spill the register */
_spill_reg(&inst, type, reg, value->frame_offset);
/* End the code output process */
jit_cache_end_output();
}
void
_jit_gen_free_reg(jit_gencode_t gen, int reg,
int other_reg, int value_used)
{
/* We only need to take explicit action if we are freeing a
floating-point register whose value hasn't been used yet */
if(!value_used && IS_FPU_REG(reg))
libjit/jit/jit-rules-x86-64.c view on Meta::CPAN
x86_64_fstp_membase_size(inst, X86_64_RBP, offset, 10);
if(!pop)
{
x86_64_fld_membase_size(inst, X86_64_RBP, offset, 10);
}
}
}
break;
}
/* End the code output process */
jit_cache_end_output();
}
}
void
_jit_gen_load_value(jit_gencode_t gen, int reg, int other_reg, jit_value_t value)
{
jit_type_t type;
int src_reg, other_src_reg;
void *ptr;
libjit/jit/jit-rules-x86-64.c view on Meta::CPAN
{
x86_64_movups_reg_membase(inst, _jit_reg_info[reg].cpu_reg,
X86_64_RBP, offset);
}
}
}
}
}
}
/* End the code output process */
jit_cache_end_output();
}
void
_jit_gen_get_elf_info(jit_elf_info_t *info)
{
info->machine = 62; /* EM_X86_64 */
info->abi = 0; /* ELFOSABI_SYSV */
info->abi_version = 0;
}
libjit/jit/jit-rules-x86-64.c view on Meta::CPAN
return 0;
}
if(!_jit_setup_call_stack(func, &passing))
{
return 0;
}
#endif
/* Now setup the arguments on the stack or in the registers in reverse order */
/* First process the params passed on the stack */
current_param = num_args;
while(current_param > 0)
{
--current_param;
if(param[current_param].arg_class == JIT_ARG_CLASS_STACK)
{
jit_type_t param_type;
param_type = jit_type_get_param(signature, current_param);
if(!_jit_setup_outgoing_param(func, &(param[current_param]), param_type))
libjit/jit/jit-rules-x86.c view on Meta::CPAN
void *ptr, *entry;
_jit_gen_check_space(gen, 8);
ptr = (void *)&(func->entry_point);
entry = gen->ptr;
x86_jump_mem(gen->ptr, ptr);
return entry;
}
#endif
/*
* Setup or teardown the x86 code output process.
*/
#define jit_cache_setup_output(needed) \
unsigned char *inst = gen->ptr; \
_jit_gen_check_space(gen, (needed))
#define jit_cache_end_output() \
gen->ptr = inst
/*
* Get a temporary register that isn't one of the specified registers.
libjit/jit/jit-rules-x86.c view on Meta::CPAN
break;
case JIT_TYPE_NFLOAT:
{
x86_fst80_membase(inst, X86_EBP, offset);
}
break;
}
}
/* End the code output process */
jit_cache_end_output();
}
void
_jit_gen_free_reg(jit_gencode_t gen, int reg, int other_reg, int value_used)
{
/* We only need to take explicit action if we are freeing a
floating-point register whose value hasn't been used yet */
if(!value_used && IS_FLOAT_REG(reg))
{
libjit/jit/jit-rules-x86.c view on Meta::CPAN
{
x86_fst80_membase(inst, X86_EBP, offset);
if(!pop)
{
x86_fld80_membase(inst, X86_EBP, offset);
}
}
break;
}
/* End the code output process */
jit_cache_end_output();
}
}
void
_jit_gen_load_value(jit_gencode_t gen, int reg, int other_reg, jit_value_t value)
{
jit_type_t type;
int src_reg, other_src_reg;
void *ptr;
libjit/jit/jit-rules-x86.c view on Meta::CPAN
}
else
{
x86_fld80_membase(inst, X86_EBP, offset);
}
}
break;
}
}
/* End the code output process */
jit_cache_end_output();
}
void _jit_gen_spill_global(jit_gencode_t gen, int reg, jit_value_t value)
{
jit_cache_setup_output(16);
if(value)
{
_jit_gen_fix_value(value);
x86_mov_membase_reg(inst,
libjit/jitdynamic/jit-cpp-mangle.c view on Meta::CPAN
#include <jit/jit.h>
#include <config.h>
#include <stdio.h>
/*@
@cindex Name mangling
Sometimes you want to retrieve a C++ method from a dynamic library
using @code{jit_dynlib_get_symbol}. Unfortunately, C++ name mangling
rules differ from one system to another, making this process very
error-prone.
The functions that follow try to help. They aren't necessarily fool-proof,
but they should work in the most common cases. The only alternative is
to wrap your C++ library with C functions, so that the names are predictable.
The basic idea is that you supply a description of the C++ method that
you wish to access, and these functions return a number of candidate forms
that you can try with @code{jit_dynlib_get_symbol}. If one form fails,
you move on and try the next form, until either symbol lookup succeeds
libjit/jitplus/jit-plus-context.cpp view on Meta::CPAN
jit_context::~jit_context()
{
if(!copied)
{
jit_context_destroy(context);
}
}
/*@
* @deftypemethod jit_context void build_start ()
* Start an explicit build process. Not needed if you will be using
* on-demand compilation.
* @end deftypemethod
*
* @deftypemethod jit_context void build_end ()
* End an explicit build process.
* @end deftypemethod
*
* @deftypemethod jit_context jit_context_t raw () const
* Get the raw C context pointer that underlies this object.
* @end deftypemethod
@*/
libjit/jitplus/jit-plus-function.cpp view on Meta::CPAN
@*/
jit_type_t jit_function::create_signature()
{
// Normally overridden by subclasses.
return signature_helper(jit_type_void, end_params);
}
/*@
* @deftypemethod jit_function void fail ()
* This method can be called by @code{build} to fail the on-demand
* compilation process. It throws an exception to unwind the build.
* @end deftypemethod
@*/
void jit_function::fail()
{
throw jit_build_exception(JIT_RESULT_COMPILE_ERROR);
}
/*@
* @deftypemethod jit_function void out_of_memory ()
* This method can be called by @code{build} to indicate that the on-demand
* compilation process ran out of memory. It throws an exception to
* unwind the build.
* @end deftypemethod
@*/
void jit_function::out_of_memory()
{
throw jit_build_exception(JIT_RESULT_OUT_OF_MEMORY);
}
/*@
* @deftypemethod jit_function void build_start ()
* Start an explicit build process. Not needed if you will be using
* on-demand compilation.
* @end deftypemethod
*
* @deftypemethod jit_function void build_end ()
* End an explicit build process.
* @end deftypemethod
@*/
#define value_wrap(x) \
jit_value val((x)); \
if(!(val.raw())) \
out_of_memory(); \
return val
/*@
libjit/jitplus/jit-plus-value.cpp view on Meta::CPAN
* License along with the libjit library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include <jit/jit-plus.h>
/*@
The @code{jit_value} class provides a C++ counterpart to the
@code{jit_value_t} type. Values normally result by calling methods
on the @code{jit_function} class during the function building process.
@xref{Values}, for more information on creating and managing values.
@defop Constructor jit_value jit_value ()
Construct an empty value.
@end defop
@defop Constructor jit_value jit_value (jit_value_t @var{value})
Construct a value by wrapping up a raw C @code{jit_value_t} object.
@end defop
libjit/jitruby/ext/rubypp.rb view on Meta::CPAN
class Preprocessor
def initialize(input, output, filename)
@input = input
@output = output
@filename = filename
@linenum = 1
end
def getline
line = @input.gets
@linenum += 1 if not line.nil?
return line
end
def preprocess
success = false
begin
loop do
line = getline
break if line.nil?
case line
when /(.*[^\\]|^)\#\{(.*?)\}(.*)/
puts "#{$1}#{evaluate($2, @linenum)}#{$3}"
when /^\#ruby\s+<<(.*)/
marker = $1
libjit/jitruby/ext/rubypp.rb view on Meta::CPAN
success = true
return result
end
def puts(line='')
@output.puts(line)
end
end
def puts(line='')
$preprocessor.puts(line)
end
def rubypp(input_file, output_file)
input = input_file ? File.open(input_file) : $stdin
output = output_file ? File.open(output_file, 'w') : $stdout
success = false
begin
$preprocessor = Preprocessor.new(input, output, input_file || "(stdin)")
$preprocessor.preprocess()
success = true
ensure
if not success then
File.unlink(output_file) rescue Errno::ENOENT
end
end
end
if __FILE__ == $0 then
input_file = ARGV[0]