Execution engine¶
The execution engine is where actual code generation and execution happen. The currently supported LLVM version—LLVM 3.8—exposes a single execution engine, named MCJIT.
Functions¶
-
llvmlite.binding.
create_mcjit_compiler
(module, target_machine)¶ Create a MCJIT-powered engine from the given module and target_machine.
- module does not need to contain any code.
- Returns a
ExecutionEngine
instance.
-
-
llvmlite.binding.
check_jit_execution
()¶ Ensure that the system allows creation of executable memory ranges for JIT-compiled code. If some security mechanism such as SELinux prevents it, an exception is raised. Otherwise the function returns silently.
Calling this function early can help diagnose system configuration issues, instead of letting JIT-compiled functions crash mysteriously.
-
The ExecutionEngine class¶
-
class
llvmlite.binding.
ExecutionEngine
¶ A wrapper around an LLVM execution engine. The following methods and properties are available:
-
finalize_object
()¶ Make sure all modules owned by the execution engine are fully processed and usable for execution.
-
-
get_pointer_to_function
(gv)¶ CAUTION: This method is deprecated. Use
ExecutionEngine.get_function_address()
andExecutionEngine.get_global_value_address()
instead.Return the address of the function value gv, as an integer. The value should have been looked up on one of the modules owned by the execution engine.
NOTE: This method may implicitly generate code for the object being looked up.
This method is formerly an alias to
get_pointer_to_global()
, which is now removed because it returns an invalid address in MCJIT when given a non-function global value.
-
-
get_function_address
(name)¶ Return the address of the function name as an integer.
-
-
get_global_value_address
(name)¶ Return the address of the global value name as an integer.
-
-
set_object_cache
(notify_func=None, getbuffer_func=None)¶ Set the object cache callbacks for this engine.
notify_func, if given, is called whenever the engine has finished compiling a module. It is passed the
(module, buffer)
arguments:- module is a
ModuleRef
instance. - buffer is a bytes object of the code generated for the module.
The return value is ignored.
- module is a
getbuffer_func, if given, is called before the engine starts compiling a module. It is passed an argument, module, a
ModuleRef
instance of the module being compiled.- It can return
None
, in which case the module is compiled normally. - It can return a bytes object of native code for the module, which bypasses compilation entirely.
- It can return
-
-
target_data
¶ The
TargetData
used by the execution engine.
-