+2007-12-20 Aleksey Demakov <ademakov@gmail.com>
+
+ * include/jit/jit-plus.h: add jit_context::build_start() and
+ jit_context::build_end() methods.
+
+ * include/jit/jit-function.h, jit/jit-function.c
+ (jit_function_recompile): remove.
+ * include/jit/jit-plus.h, jitplus/jit-plus-function.cpp
+ (jit_function::recompile): remove.
+ * tutorial/t3.c, tutorial/t4.cpp: recompile manually
+ instead of using removed recompile functions.
+
2007-12-16 Klaus Treichel <ktreichel@web.de>
* configure.in: Add support for multi os archs (like x86_64). Put the
jit_block_t jit_function_get_current(jit_function_t func) JIT_NOTHROW;
jit_function_t jit_function_get_nested_parent(jit_function_t func) JIT_NOTHROW;
int jit_function_compile(jit_function_t func) JIT_NOTHROW;
-int jit_function_recompile(jit_function_t func) JIT_NOTHROW;
int jit_function_is_compiled(jit_function_t func) JIT_NOTHROW;
void jit_function_set_recompilable(jit_function_t func) JIT_NOTHROW;
void jit_function_clear_recompilable(jit_function_t func) JIT_NOTHROW;
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:
int is_compiled() const { return jit_function_is_compiled(func); }
- int recompile();
-
int is_recompilable() const { return jit_function_is_recompilable(func); }
void set_recompilable() { jit_function_set_recompilable(func); }
_jit_function_free_builder(func);
}
-/*@
- * @deftypefun int jit_function_recompile (jit_function_t func)
- * Force @code{func} to be recompiled, by calling its on-demand
- * compiler again. It is highly recommended that you set the
- * recompilable flag with @code{jit_function_set_recompilable}
- * when you initially create the function.
- *
- * This function returns one of @code{JIT_RESULT_OK},
- * @code{JIT_RESULT_COMPILE_ERROR}, or @code{JIT_RESULT_OUT_OF_MEMORY}.
- * @end deftypefun
-@*/
-int jit_function_recompile(jit_function_t func)
-{
- int result;
-
- /* Lock down the context */
- jit_context_build_start(func->context);
-
- /* Call the user's on-demand compiler if we don't have a builder yet.
- Bail out with an error if there is no on-demand compiler */
- if(!(func->builder))
- {
- if(func->on_demand)
- {
- result = (*(func->on_demand))(func);
- if(result != JIT_RESULT_OK)
- {
- _jit_function_free_builder(func);
- jit_context_build_end(func->context);
- return result;
- }
- }
- else
- {
- jit_context_build_end(func->context);
- return JIT_RESULT_COMPILE_ERROR;
- }
- }
-
- /* Compile the function */
- if(!jit_function_compile(func))
- {
- _jit_function_free_builder(func);
- jit_context_build_end(func->context);
- return JIT_RESULT_OUT_OF_MEMORY;
- }
-
- /* Unlock the context and report that we are ready to go */
- jit_context_build_end(func->context);
- return JIT_RESULT_OK;
-}
-
/*@
* @deftypefun int jit_function_is_compiled (jit_function_t func)
* Determine if a function has already been compiled.
}
/*@
+ * @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
}
}
-/*@
- * @deftypemethod jit_function int recompile ()
- * Force a function to be recompiled.
- * @end deftypemethod
- *
- * @deftypemethod jit_function int is_recompilable () const
- * Determine if this function is recompilable.
- * @end deftypemethod
- *
- * @deftypemethod jit_function void set_recompilable ()
- * @deftypemethodx jit_function void clear_recompilable ()
- * @deftypemethodx jit_function void set_recompilable (int flag)
- * Modify the "recompilable" flag on this function.
- * @end deftypemethod
-@*/
-int jit_function::recompile()
-{
- if(!func)
- {
- return JIT_RESULT_COMPILE_ERROR;
- }
- else
- {
- return jit_function_recompile(func);
- }
-}
-
/*@
* @deftypemethod jit_function void set_optimization_level ({unsigned int} level)
* @deftypemethodx jit_function {unsigned int} optimization_level () const
/* Force the function to be recompiled. Normally we'd use another
on-demand compiler with greater optimization capabilities */
- 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);
/* Execute the function a third time, after it is recompiled */
arg1 = 2;
set_recompilable();
}
+ virtual void build();
+
protected:
virtual jit_type_t create_signature();
- virtual void build();
};
jit_type_t mul_add_function::create_signature()
printf("mul_add(13, 5, 7) = %d\n", (int)result);
// Force the function to be recompiled.
- mul_add.recompile();
+ mul_add.build_start();
+ mul_add.build();
+ mul_add.compile();
+ mul_add.build_end();
// Execute the function a third time, after it is recompiled.
arg1 = 2;