debug output

pull/81/head
dibyendumajumdar 9 years ago
parent 57d89d90ee
commit 00d1845b38

@ -755,12 +755,30 @@ extern void ravi_dump_lvalue(gcc_jit_lvalue *lv);
extern void ravi_debug_printf(ravi_function_def_t *def, const char *str);
extern void ravi_debug_printf2(ravi_function_def_t *def, const char *str,
extern void ravi_debug_printf1(ravi_function_def_t *def, const char *str,
gcc_jit_rvalue *arg1);
extern void ravi_debug_printf3(ravi_function_def_t *def, const char *str,
extern void ravi_debug_printf2(ravi_function_def_t *def, const char *str,
gcc_jit_rvalue *arg1, gcc_jit_rvalue *arg2);
extern void ravi_debug_printf3(ravi_function_def_t *def, const char *str,
gcc_jit_rvalue *arg1, gcc_jit_rvalue *arg2,
gcc_jit_rvalue *arg3);
extern void ravi_debug_printf4(ravi_function_def_t *def, const char *str,
gcc_jit_rvalue *arg1, gcc_jit_rvalue *arg2,
gcc_jit_rvalue *arg3, gcc_jit_rvalue *arg4);
extern gcc_jit_rvalue *ravi_int_constant(ravi_function_def_t *def, int value);
extern gcc_jit_rvalue *ravi_bool_constant(ravi_function_def_t *def, int value);
extern gcc_jit_rvalue *ravi_lua_Integer_constant(ravi_function_def_t *def, int value);
extern gcc_jit_rvalue *ravi_lua_Number_constant(ravi_function_def_t *def, double value);
#ifdef __cplusplus
};
#endif

@ -4,5 +4,5 @@ function x()
end
--ravi.dumplua(x)
--ravi.compile(x)
ravi.compile(x,1)
assert(x() == false)

@ -39,6 +39,7 @@ void ravi_emit_JMP(ravi_function_def_t *def, int A, int j, int pc) {
def->jit_function, unique_name(def, "OP_JMP", pc));
ravi_set_current_block(def, jmp_block);
}
//ravi_debug_printf2(def, "OP_JMP(%d) jmp to %d\n", ravi_int_constant(def, pc+1), ravi_int_constant(def, j+1));
// if (a > 0) luaF_close(L, ci->u.l.base + a - 1);
if (A > 0) {

@ -163,7 +163,12 @@ static bool create_function(ravi_gcc_codegen_t *codegen,
if (def->dump_asm) {
gcc_jit_context_set_bool_option(def->function_context,
GCC_JIT_BOOL_OPTION_DUMP_GENERATED_CODE, 1);
// gcc_jit_context_set_bool_option(def->function_context,
// GCC_JIT_BOOL_OPTION_DUMP_INITIAL_TREE, 1);
gcc_jit_context_set_bool_option(def->function_context,
GCC_JIT_BOOL_OPTION_DUMP_INITIAL_GIMPLE, 1);
}
gcc_jit_context_set_bool_allow_unreachable_blocks(def->function_context, 1);
gcc_jit_context_set_int_option(def->function_context,
GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL,
def->opt_level);
@ -1356,7 +1361,7 @@ void ravi_debug_printf(ravi_function_def_t *def, const char *str) {
gcc_jit_context_new_string_literal(def->function_context, str)));
}
void ravi_debug_printf2(ravi_function_def_t *def, const char *str,
void ravi_debug_printf1(ravi_function_def_t *def, const char *str,
gcc_jit_rvalue *arg1) {
gcc_jit_block_add_eval(
def->current_block, NULL,
@ -1366,7 +1371,7 @@ void ravi_debug_printf2(ravi_function_def_t *def, const char *str,
arg1));
}
void ravi_debug_printf3(ravi_function_def_t *def, const char *str,
void ravi_debug_printf2(ravi_function_def_t *def, const char *str,
gcc_jit_rvalue *arg1, gcc_jit_rvalue *arg2) {
gcc_jit_block_add_eval(
def->current_block, NULL,
@ -1376,6 +1381,43 @@ void ravi_debug_printf3(ravi_function_def_t *def, const char *str,
arg2));
}
void ravi_debug_printf3(ravi_function_def_t *def, const char *str,
gcc_jit_rvalue *arg1, gcc_jit_rvalue *arg2, gcc_jit_rvalue *arg3) {
gcc_jit_block_add_eval(
def->current_block, NULL,
ravi_function_call4_rvalue(
def, def->ravi->types->printfT,
gcc_jit_context_new_string_literal(def->function_context, str), arg1,
arg2, arg3));
}
void ravi_debug_printf4(ravi_function_def_t *def, const char *str,
gcc_jit_rvalue *arg1, gcc_jit_rvalue *arg2, gcc_jit_rvalue *arg3, gcc_jit_rvalue *arg4) {
gcc_jit_block_add_eval(
def->current_block, NULL,
ravi_function_call5_rvalue(
def, def->ravi->types->printfT,
gcc_jit_context_new_string_literal(def->function_context, str), arg1,
arg2, arg3, arg4));
}
gcc_jit_rvalue *ravi_int_constant(ravi_function_def_t *def, int value) {
return gcc_jit_context_new_rvalue_from_int(def->function_context, def->ravi->types->C_intT, value);
}
gcc_jit_rvalue *ravi_bool_constant(ravi_function_def_t *def, int value) {
return gcc_jit_context_new_rvalue_from_int(def->function_context, def->ravi->types->C_boolT, value ? 1 : 0);
}
gcc_jit_rvalue *ravi_lua_Integer_constant(ravi_function_def_t *def, int value) {
return gcc_jit_context_new_rvalue_from_int(def->function_context, def->ravi->types->lua_IntegerT, value);
}
gcc_jit_rvalue *ravi_lua_Number_constant(ravi_function_def_t *def, double value) {
return gcc_jit_context_new_rvalue_from_double(def->function_context, def->ravi->types->lua_NumberT, value);
}
// Free the JIT compiled function
// Note that this is called by the garbage collector
void raviV_freeproto(struct lua_State *L, struct Proto *p) {

@ -212,6 +212,15 @@ void ravi_emit_TEST(ravi_function_def_t *def, int A, int B, int C, int j,
(void)B;
// if (C) {
// ravi_debug_printf3(def, "OP_TEST(%d C=1)) if (!reg(A=%d)) then skip next else jmp to %d\n", ravi_int_constant(def, pc+1),
// ravi_int_constant(def, A), ravi_int_constant(def, j+1));
// }
// else {
// ravi_debug_printf3(def, "OP_TEST(%d C=0) if (reg(A=%d)) then skip next else jmp to %d\n", ravi_int_constant(def, pc+1),
// ravi_int_constant(def, A), ravi_int_constant(def, j+1));
// }
// Load pointer to base
ravi_emit_load_base(def);

@ -42,7 +42,7 @@ ravi_gcc_context_t *ravi_jit_new_context(void) {
ravi->enabled_ = true;
ravi->min_code_size_ = 150;
ravi->min_exec_count_ = 50;
ravi->opt_level_ = 3;
ravi->opt_level_ = 2;
ravi->size_level_ = 0;
if (!ravi_setup_lua_types(ravi)) {

@ -116,6 +116,7 @@ void ravi_emit_LOADBOOL(ravi_function_def_t *def, int A, int B, int C, int j,
// setbvalue(ra, GETARG_B(i));
// if (GETARG_C(i)) ci->u.l.savedpc++; /* skip next instruction (if C) */
// ravi_debug_printf4(def, "LOADBOOL(pc=%d) set reg(A=%d) to boolean(B=%d); if ((C=%d) != 0) skip next\n", ravi_int_constant(def, pc+1), ravi_int_constant(def, A), ravi_int_constant(def, B), ravi_int_constant(def, C));
// Load pointer to base
ravi_emit_load_base(def);
// ra

@ -53,6 +53,8 @@ void ravi_emit_RETURN(ravi_function_def_t *def, int A, int B, int pc) {
def->current_block_terminated = false;
}
// ravi_debug_printf2(def, "OP_RETURN(pc=%d) return %d args\n", ravi_int_constant(def, pc+1), ravi_int_constant(def, B-1));
// Load pointer to base
ravi_emit_load_base(def);

Loading…
Cancel
Save