From: Aleksey Demakov Date: Thu, 20 Dec 2007 17:31:50 +0000 (+0000) Subject: update tutorial wrt recomplation X-Git-Tag: before.move.to.git~126 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=8b8f26700c6aa112e8b544ad7cffd7478d24a65f;p=francis%2Flibjit.git update tutorial wrt recomplation --- diff --git a/ChangeLog b/ChangeLog index 8c0568e..3d58cbe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,8 @@ * tutorial/t3.c, tutorial/t4.cpp: recompile manually instead of using removed recompile functions. + * doc/libjit.texi: update tutorial. + 2007-12-16 Klaus Treichel * configure.in: Add support for multi os archs (like x86_64). Put the diff --git a/doc/libjit.texi b/doc/libjit.texi index e49f773..3357e05 100644 --- a/doc/libjit.texi +++ b/doc/libjit.texi @@ -599,6 +599,9 @@ When the on-demand compiler returns, @code{libjit} will call @code{jit_function_compile} and then jump to the newly compiled code. Upon the second and subsequent calls to the function, @code{libjit} will bypass the on-demand compiler and call the compiled code directly. +Note that in case of on-demand compilation @code{libjit} automatically +locks and unlocks the corresponding context with +@code{jit_context_build_start} and @code{jit_context_build_end} calls. Sometimes you may wish to force a commonly used function to be recompiled, so that you can apply additional optimization. @@ -613,11 +616,18 @@ jit_function_set_recompilable(function); jit_function_set_on_demand_compiler(function, compile_mul_add); @end example -Then, you force the function to be recompiled with a call to -@code{jit_function_recompile}: +Once the function is compiled (either on-demand or up-front) its +intermediate representation built by @code{libjit} is discarded. +To force the function to be recompiled you need to build it again +and call @code{jit_function_compile} after that. As always when +the function is built and compiled manually it is necessary +to take care of context locking: @example -jit_function_recompile(function); +jit_context_build_start(context); +jit_function_get_on_demand_compiler(function)(function); +jit_function_compile(function); +jit_context_build_end(context); @end example After this, any existing references to the function will be redirected @@ -677,9 +687,10 @@ public: set_recompilable(); @} + virtual void build(); + protected: virtual jit_type_t create_signature(); - virtual void build(); @}; @end example