issue #157 Cleanup some unwanted api functions that are really only for debugging

nometajit
Dibyendu Majumdar 4 years ago
parent e9cb1d3b20
commit 84b4949aa9

@ -627,35 +627,17 @@ LUA_API void ravi_writestringerror(lua_State *L, const char *fmt, const char *p)
LUA_API void ravi_set_debugger_data(lua_State *L, void *data);
LUA_API void *ravi_get_debugger_data(lua_State *L);
/*
** Experimental (wip) implementation of new
** parser and code generator
*/
LUA_API int (ravi_build_ast_from_buffer) (lua_State *L, lua_Reader reader, void *dt,
const char *chunkname, const char *mode);
/////////////////////////////////////////////////////////////////////////////
/*
Bunch of useful functions for debugging
*/
struct lua_TValue;
struct Proto;
LUA_API void ravi_dump_value(lua_State *L, const struct lua_TValue *v);
LUA_API void ravi_dump_stack(lua_State *L, const char *s);
LUA_API void ravi_dump_stacktop(lua_State *L, const char *s);
LUA_API void ravi_debug_trace(lua_State *L, int opCode, int pc);
LUA_API void ravi_print_function(const struct Proto *f, int full);
/* Dumps the ravi Bytecode to stdout */
LUA_API void ravi_dump_function(lua_State *L);
/* Returns a table of lines containing Ravi bytecode */
LUA_API int ravi_list_code(lua_State *L);
/* Returns a table with various system limits */
LUA_API int ravi_get_limits(lua_State *L);
/* Following are for debugging purposes only */
LUAI_DDEC int ravi_parser_debug;
LUA_API void ravi_set_debuglevel(int level);
#define RAVI_DEBUG_STACK(p) if ((ravi_parser_debug & 8) != 0) {p;} else {}
#define RAVI_BYTECODE_PROFILING_ENABLED 0

@ -162,5 +162,6 @@ LUAI_FUNC void raviV_settable_i(lua_State *L, const TValue *t, TValue *key, StkI
LUAI_FUNC void raviV_op_totype(lua_State *L, TValue *ra, TValue *rb);
LUAI_FUNC int raviV_check_usertype(lua_State *L, TString *name, const TValue *o);
LUAI_FUNC void raviV_op_defer(lua_State *L, TValue *ra);
LUAI_FUNC void raviV_debug_trace(lua_State *L, int opCode, int pc);
#endif

@ -293,9 +293,11 @@ struct LuaLLVMTypes {
llvm::FunctionType *raviH_set_intT;
llvm::FunctionType *raviH_set_floatT;
#if 0
llvm::FunctionType *ravi_dump_valueT;
llvm::FunctionType *ravi_dump_stackT;
llvm::FunctionType *ravi_dump_stacktopT;
#endif
llvm::FunctionType *ravi_debug_traceT;
std::array<llvm::Constant *, 256> kInt;
@ -486,9 +488,6 @@ class RaviJITState {
unsigned int use_dmrc_ : 1;
// Flag to control calls to collect
int gcstep_;
// min code size for compilation
int min_code_size_;
@ -576,8 +575,6 @@ class RaviJITState {
void set_minexeccount(int value) { min_exec_count_ = value > 0 ? value : min_exec_count_; }
int get_validation() const { return validation_; }
void set_validation(bool value) { validation_ = value; }
int get_gcstep() const { return gcstep_; }
void set_gcstep(int value) { gcstep_ = value > 0 ? value : gcstep_; }
bool is_tracehook_enabled() const { return tracehook_enabled_; }
void set_tracehook_enabled(bool value) { tracehook_enabled_ = value; }
void incr_allocated_modules() { allocated_modules_++; }
@ -839,9 +836,12 @@ struct RaviFunctionDef {
llvm::Function *raviH_set_intF;
llvm::Function *raviH_set_floatF;
#if 0
// DEBUG routines
llvm::Function *ravi_dump_valueF;
llvm::Function *ravi_dump_stackF;
llvm::Function *ravi_dump_stacktopF;
#endif
llvm::Function *ravi_debug_traceF;
// standard C functions
@ -1143,8 +1143,10 @@ class RaviCodeGenerator {
void debug_printf4(RaviFunctionDef *def, const char *str, llvm::Value *arg1, llvm::Value *arg2, llvm::Value *arg3,
llvm::Value *arg4);
#if 0
void emit_dump_stack(RaviFunctionDef *def, const char *str);
void emit_dump_stacktop(RaviFunctionDef *def, const char *str);
#endif
bool emit_debug_trace(RaviFunctionDef *def, int opCode, int pc);
// Look for Lua bytecodes that are jump targets and allocate

@ -611,7 +611,7 @@ static void PrintDebug(const Proto* f)
}
}
void ravi_print_function(const Proto* f, int full)
static void ravi_print_function(const Proto* f, int full)
{
int i, n = f->sizep;
PrintHeader(f);

@ -2637,20 +2637,20 @@ void ravi_dump_stacktop(lua_State *L, const char *s) {
** enabled; the function needs to update the savedpc and
** call luaG_traceexec() if necessary
*/
void ravi_debug_trace(lua_State *L, int opCode, int pc) {
RAVI_DEBUG_STACK(
char buf[100]; CallInfo *ci = L->ci;
int funcpos = (int)(ci->func - L->stack);
int top = (int)(L->top - L->stack);
int ci_top = (int)(ci->top - L->stack);
int base = (int)(ci->u.l.base - L->stack); raviP_instruction_to_str(
buf, sizeof buf, clvalue(L->ci->func)->l.p->code[pc]);
printf(
"Stack dump %s (%s) function %d, pc=%d, L->top = %d, ci->top = %d\n",
luaP_opnames[opCode], buf, funcpos, pc, (top - base),
(ci_top - base));
lua_assert(L->ci->u.l.base <= L->top &&
L->top < L->stack + L->stacksize);)
void raviV_debug_trace(lua_State *L, int opCode, int pc) {
// RAVI_DEBUG_STACK(
// char buf[100]; CallInfo *ci = L->ci;
// int funcpos = (int)(ci->func - L->stack);
// int top = (int)(L->top - L->stack);
// int ci_top = (int)(ci->top - L->stack);
// int base = (int)(ci->u.l.base - L->stack); raviP_instruction_to_str(
// buf, sizeof buf, clvalue(L->ci->func)->l.p->code[pc]);
// printf(
// "Stack dump %s (%s) function %d, pc=%d, L->top = %d, ci->top = %d\n",
// luaP_opnames[opCode], buf, funcpos, pc, (top - base),
// (ci_top - base));
// lua_assert(L->ci->u.l.base <= L->top &&
// L->top < L->stack + L->stacksize);)
// Updates the savedpc pointer in the call frame
// The savedpc is unimportant for the JIT but it is relied upon

@ -948,6 +948,7 @@ std::unique_ptr<RaviJITFunction> RaviCodeGenerator::create_function(
return func;
}
#if 0
void RaviCodeGenerator::emit_dump_stack(RaviFunctionDef *def, const char *str) {
CreateCall2(def->builder, def->ravi_dump_stackF, def->L,
def->builder->CreateGlobalStringPtr(str));
@ -958,6 +959,7 @@ void RaviCodeGenerator::emit_dump_stacktop(RaviFunctionDef *def,
CreateCall2(def->builder, def->ravi_dump_stacktopF, def->L,
def->builder->CreateGlobalStringPtr(str));
}
#endif
// Emit a call to ravi_debug_trace() function.
// This function will set savedpc and also invoke
@ -1206,6 +1208,8 @@ void RaviCodeGenerator::emit_extern_declarations(RaviFunctionDef *def) {
def->types->raviV_op_deferT, reinterpret_cast<void *>(&raviV_op_defer),
"raviV_op_defer");
#if 0
// DEBUG routines
def->ravi_dump_valueF = def->raviF->addExternFunction(
def->types->ravi_dump_valueT, reinterpret_cast<void *>(&ravi_dump_value),
"ravi_dump_value");
@ -1215,9 +1219,10 @@ void RaviCodeGenerator::emit_extern_declarations(RaviFunctionDef *def) {
def->ravi_dump_stacktopF = def->raviF->addExternFunction(
def->types->ravi_dump_stacktopT,
reinterpret_cast<void *>(&ravi_dump_stacktop), "ravi_dump_stacktop");
#endif
def->ravi_debug_traceF = def->raviF->addExternFunction(
def->types->ravi_debug_traceT,
reinterpret_cast<void *>(&ravi_debug_trace), "ravi_debug_trace");
reinterpret_cast<void *>(&raviV_debug_trace), "raviV_debug_trace");
// Create printf declaration
std::vector<llvm::Type *> args;

@ -183,7 +183,6 @@ RaviJITState::RaviJITState()
tracehook_enabled_(false),
validation_(false),
use_dmrc_(false),
gcstep_(300),
min_code_size_(150),
min_exec_count_(50),
allocated_modules_(0),

@ -1002,6 +1002,8 @@ LuaLLVMTypes::LuaLLVMTypes(llvm::LLVMContext &context) : mdbuilder(context) {
raviH_set_floatT =
llvm::FunctionType::get(llvm::Type::getVoidTy(context), elements, false);
#if 0
// DEBUG tools
elements.clear();
elements.push_back(plua_StateT);
elements.push_back(pTValueT);
@ -1016,6 +1018,7 @@ LuaLLVMTypes::LuaLLVMTypes(llvm::LLVMContext &context) : mdbuilder(context) {
ravi_dump_stacktopT =
llvm::FunctionType::get(llvm::Type::getVoidTy(context), elements, false);
#endif
elements.clear();
elements.push_back(plua_StateT);
elements.push_back(C_intT);

@ -171,7 +171,6 @@ static LuaFunc Lua_functions[] = {
{ "lua_rawsetp", lua_rawsetp },
{ "lua_setmetatable", lua_setmetatable },
{ "lua_setuservalue", lua_setuservalue },
{ "ravi_dump_value", ravi_dump_value },
{ NULL, NULL }
};

@ -144,15 +144,6 @@ int raviV_getverbosity(lua_State *L) {
return 0;
}
void raviV_setgcstep(struct lua_State *L, int value) {
(void)L;
(void)value;
}
int raviV_getgcstep(struct lua_State *L) {
(void)L;
return 0;
}
void raviV_setvalidation(struct lua_State *L, int value) {
(void)L;
(void)value;

Loading…
Cancel
Save