|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
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
jit_function_compile to convert it into its executable form.
It is recommended that you call
jit_function_create, and then call
jit_context_build_end after you have called
jit_function_compile. This will protect the JIT’s internal
data structures within a multi-threaded environment.
Create a new function block and associate it with a JIT context. In addition, this function is nested inside the specified parent function and is able to access its parent’s (and grandparent’s) local variables.
The front end is responsible for ensuring that the nested function can never be called by anyone except its parent and sibling functions. The front end is also responsible for ensuring that the nested function is compiled before its parent.
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 func object is completely destroyed and detached from its owning context. The function is left alone if it was already compiled.
Get the context associated with a function.
Get the signature associated with a function.
Tag a function with some metadata. Returns zero if out of memory.
Metadata may be used to store dependency graphs, branch prediction information, or any other information that is useful to optimizers or code generators. It can also be used by higher level user code to store information about the function that is specific to the virtual machine or language.
If the type already has some metadata associated with it, then the previous value will be freed.
If build_only is non-zero, then the metadata will be freed
when the function is compiled with
Otherwise the metadata will persist until the JIT context is destroyed,
jit_function_free_meta is called for the specified type.
Metadata type values of 10000 or greater are reserved for internal use.
Get the metadata associated with a particular tag. Returns NULL if type does not have any metadata associated with it.
Free metadata of a specific type on a function. Does nothing if the type does not have any metadata associated with it.
Iterate over the defined functions in creation order. The prev argument should be NULL on the first call. Returns NULL at the end.
Iterate over the defined functions in reverse creation order.
Get the entry block for a function. This is always the first block
Get the current block for a function. New blocks are created by
Get the nested parent for a function, or NULL if func does not have a nested parent.
Determine if a function has already been compiled.
Mark this function as a candidate for recompilation. That is,
it is possible that we may call
more than once, to re-optimize an existing function.
It is very important that this be called before the first time that
jit_function_compile. Functions that are recompilable
are invoked in a slightly different way to non-recompilable functions.
If you don’t set this flag, then existing invocations of the function
may continue to be sent to the original compiled version, not the new
Clear the recompilable flag on this function. Normally you would use
this once you have decided that the function has been optimized enough,
and that you no longer intend to call
Future uses of the function with
jit_insn_call will output a
direct call to the function, which is more efficient than calling
its recompilable version. Pre-existing calls to the function may still
use redirection stubs, and will remain so until the pre-existing
functions are themselves recompiled.
Determine if this function is recompilable.
Convert a compiled function into a closure that can called directly from C. Returns NULL if out of memory, or if closures are not supported on this platform.
If the function has not been compiled yet, then this will return a pointer to a redirector that will arrange for the function to be compiled on-demand when it is called.
Creating a closure for a nested function is not recommended as C does not have any way to call such closures directly.
Convert a closure back into a function. Returns NULL if the closure does not correspond to a function in the specified context.
Get the function that contains the specified program counter location.
Also return the address of the
catch handler for the same location.
Returns NULL if the program counter does not correspond to a function
under the control of context.
Return a pointer that is suitable for referring to this function
from a vtable. Such pointers should only be used with the
jit_insn_call_vtable is generally more efficient than
jit_insn_call_indirect for calling virtual methods.
The vtable pointer might be the same as the closure, but this isn’t
guaranteed. Closures can be used with
Convert a vtable_pointer back into a function. Returns NULL if the vtable_pointer does not correspond to a function in the specified context.
Specify the C function to be called when 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,
libjit takes the following
libjitunlocks the context and returns immediately. This can happen because of race conditions between threads: some other thread may have beaten us to the on-demand compiler.
jit_function_compileto compile the function.
libjitjumps to the newly-compiled entry point. If an error occurs, a built-in exception of type
JIT_RESULT_OUT_OF_MEMORYwill be thrown.
Normally you will need some kind of context information to tell you
which higher-level construct is being compiled. You can use the
metadata facility to add this context information to the function
just after you create it with
Returns function’s on-demand compiler.
Call the function func with the supplied arguments. Each element in args is a pointer to one of the arguments, and return_area points to a buffer to receive the return value. Returns zero if an exception occurred.
This is the primary means for executing a function from ordinary
C code without creating a closure first with
Closures may not be supported on all platforms, but function application
is guaranteed to be supported everywhere.
Function applications acts as an exception blocker. If any exceptions occur during the execution of func, they won’t travel up the stack any further than this point. This prevents ordinary C code from being accidentally presented with a situation that it cannot handle. This blocking protection is not present when a function is invoked via its closure.
Call the function func with the supplied arguments. There may
be more arguments than are specified in the function’s original signature,
in which case the additional values are passed as variable arguments.
This function is otherwise identical to
Set the optimization level for func. Increasing values indicate
libjit dynamic compiler should expend more effort to
generate better code for this function. Usually you would increase
this value just before forcing func to recompile.
When the optimization level reaches the value returned by
jit_function_get_max_optimization_level(), there is usually
little point in continuing to recompile the function because
libjit may not be able to do any better.
The front end is usually responsible for choosing candidates for function inlining. If it has identified more such candidates, then it may still want to recompile func again even once it has reached the maximum optimization level.
Get the current optimization level for func.
Get the maximum optimization level that is supported by
Allocate a new label for later use within the function func. Most instructions that require a label could perform label allocation themselves. A separate label allocation could be useful to fill a jump table with identical entries.
Check if labels label and label2 defined within the function func are equal that is belong to the same basic block. Labels that are not associated with any block are never considered equal.
|[ << ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
This document was generated by Aleksey Demakov on October 17, 2013 using texi2html 1.82.