remove debug code

This commit is contained in:
Yuichi Nishiwaki 2016-02-21 20:13:05 +09:00
parent d49e25a5b4
commit 5c7c5a69cf
8 changed files with 15 additions and 143 deletions

View File

@ -60,10 +60,6 @@ EOL
}
print <<EOL;
#if DEBUG
puts("successfully loaded stdlib");
#endif
}
EOL

View File

@ -826,7 +826,7 @@ pic_compile(pic_state *pic, pic_value obj)
pic_value proc;
size_t ai = pic_enter(pic);
#if DEBUG
#if 0
fprintf(stdout, "ai = %zu\n", pic_enter(pic));
fprintf(stdout, "# input expression\n");
@ -838,7 +838,7 @@ pic_compile(pic_state *pic, pic_value obj)
/* optimize */
obj = pic_optimize(pic, obj);
#if DEBUG
#if 0
fprintf(stdout, "## optimize completed\n");
pic_write(pic, obj);
fprintf(stdout, "\n");
@ -849,7 +849,7 @@ pic_compile(pic_state *pic, pic_value obj)
/* analyze */
obj = pic_analyze(pic, obj);
#if DEBUG
#if 0
fprintf(stdout, "## analyzer completed\n");
pic_write(pic, obj);
fprintf(stdout, "\n");
@ -860,15 +860,6 @@ pic_compile(pic_state *pic, pic_value obj)
/* codegen */
irep = pic_codegen(pic, obj);
#if DEBUG
fprintf(stdout, "## codegen completed\n");
pic_dump_irep(irep);
#endif
#if DEBUG
fprintf(stdout, "# compilation finished\n");
puts("");
#endif
proc = pic_make_proc_irep(pic, irep, NULL);

View File

@ -42,12 +42,3 @@
/* #define PIC_SYMS_SIZE 32 */
/* #define PIC_ISEQ_SIZE 1024 */
/** enable all debug flags */
/* #define DEBUG 1 */
/** auxiliary debug flags */
/* #define GC_STRESS 1 */
/* #define VM_DEBUG 1 */
/* #define GC_DEBUG 1 */
/* #define GC_DEBUG_DETAIL 1 */

View File

@ -119,11 +119,6 @@ pic_value pic_fdisplay(pic_state *, pic_value, xFILE *);
pic_value pic_library_environment(pic_state *, const char *);
#if DEBUG
# define pic_debug(pic,obj) pic_fwrite(pic,obj,xstderr)
# define pic_fdebug(pic,obj,file) pic_fwrite(pic,obj,file)
#endif
#if defined(__cplusplus)
}
#endif

View File

@ -52,31 +52,31 @@ enum {
OP_STOP
};
struct code {
typedef struct {
int insn;
int a;
int b;
}
} pic_code;
struct list_head {
struct list_head *prev, *next;
struct pic_list {
struct pic_list *prev, *next;
};
struct irep {
struct list_head list;
struct pic_irep {
struct pic_list list;
unsigned refc;
int argc, localc, capturec;
bool varg;
struct code *code;
struct irep **irep;
pic_code *code;
struct pic_irep **irep;
int *ints;
double *nums;
struct object **pool;
struct pic_object **pool;
size_t ncode, nirep, nints, nnums, npool;
};
void pic_irep_incref(pic_state *, struct irep *);
void pic_irep_decref(pic_state *, struct irep *);
void pic_irep_incref(pic_state *, struct pic_irep *);
void pic_irep_decref(pic_state *, struct pic_irep *);
#if defined(__cplusplus)
}

View File

@ -83,14 +83,6 @@
# define PIC_ISEQ_SIZE 1024
#endif
#if DEBUG
# include <stdio.h>
# define GC_STRESS 0
# define VM_DEBUG 1
# define GC_DEBUG 0
# define GC_DEBUG_DETAIL 0
#endif
/* check compatibility */
#if __STDC_VERSION__ >= 199901L

View File

@ -334,23 +334,11 @@ pic_expand(pic_state *pic, pic_value expr, pic_value env)
{
pic_value v, deferred;
#if DEBUG
puts("before expand:");
pic_debug(pic, expr);
puts("");
#endif
deferred = pic_list(pic, 1, pic_nil_value(pic));
v = expand(pic, expr, env, deferred);
expand_deferred(pic, deferred, env);
#if DEBUG
puts("after expand:");
pic_debug(pic, v);
puts("");
#endif
return v;
}

View File

@ -292,15 +292,9 @@ pic_vm_tear_off(pic_state *pic)
}
}
#if VM_DEBUG
# define OPCODE_EXEC_HOOK pic_dump_code(c)
#else
# define OPCODE_EXEC_HOOK ((void)0)
#endif
#if PIC_DIRECT_THREADED_VM
# define VM_LOOP JUMP;
# define CASE(x) L_##x: OPCODE_EXEC_HOOK;
# define CASE(x) L_##x:
# define NEXT pic->ip++; JUMP;
# define JUMP c = *pic->ip; goto *oplabels[c.insn];
# define VM_LOOP_END
@ -318,69 +312,6 @@ pic_vm_tear_off(pic_state *pic)
#define PUSHCI() (++pic->ci)
#define POPCI() (pic->ci--)
#if VM_DEBUG
# define VM_BOOT_PRINT \
do { \
puts("### booting VM... ###"); \
stbase = pic->sp; \
cibase = pic->ci; \
} while (0)
#else
# define VM_BOOT_PRINT
#endif
#if VM_DEBUG
# define VM_END_PRINT \
do { \
puts("**VM END STATE**"); \
printf("stbase\t= %p\nsp\t= %p\n", (void *)stbase, (void *)pic->sp); \
printf("cibase\t= %p\nci\t= %p\n", (void *)cibase, (void *)pic->ci); \
if (stbase < pic->sp - 1) { \
pic_value *sp; \
printf("* stack trace:"); \
for (sp = stbase; pic->sp != sp; ++sp) { \
pic_debug(pic, *sp); \
puts(""); \
} \
} \
if (stbase > pic->sp - 1) { \
puts("*** stack underflow!"); \
} \
} while (0)
#else
# define VM_END_PRINT
#endif
#if VM_DEBUG
# define VM_CALL_PRINT \
do { \
short i; \
puts("\n== calling proc..."); \
printf(" proc = "); \
pic_debug(pic, pic_obj_value(proc)); \
puts(""); \
printf(" argv = ("); \
for (i = 1; i < c.u.i; ++i) { \
if (i > 1) \
printf(" "); \
pic_debug(pic, pic->sp[-c.u.i + i]); \
} \
puts(")"); \
if (! pic_proc_func_p(proc)) { \
printf(" irep = %p\n", proc->u.i.irep); \
printf(" name = %s\n", pic_str(pic, pic_sym_name(pic, pic_proc_name(proc)))); \
pic_dump_irep(proc->u.i.irep); \
} \
else { \
printf(" cfunc = %p\n", (void *)proc->u.f.func); \
printf(" name = %s\n", pic_str(pic, pic_sym_name(pic, pic_proc_name(proc)))); \
} \
puts("== end\n"); \
} while (0)
#else
# define VM_CALL_PRINT
#endif
/* for arithmetic instructions */
pic_value pic_add(pic_state *, pic_value, pic_value);
pic_value pic_sub(pic_state *, pic_value, pic_value);
@ -414,19 +345,12 @@ pic_apply(pic_state *pic, pic_value proc, int argc, pic_value *argv)
};
#endif
#if VM_DEBUG
pic_value *stbase;
pic_callinfo *cibase;
#endif
PUSH(proc);
for (i = 0; i < argc; ++i) {
PUSH(argv[i]);
}
VM_BOOT_PRINT;
/* boot! */
boot[0].insn = OP_CALL;
boot[0].a = argc + 1;
@ -568,8 +492,6 @@ pic_apply(pic_state *pic, pic_value proc, int argc, pic_value *argv)
}
proc = pic_proc_ptr(pic, x);
VM_CALL_PRINT;
if (pic->sp >= pic->stend) {
pic_panic(pic, "VM stack overflow");
}
@ -841,9 +763,6 @@ pic_apply(pic_state *pic, pic_value proc, int argc, pic_value *argv)
}
CASE(OP_STOP) {
VM_END_PRINT;
return pic_protect(pic, POP());
}
} VM_LOOP_END;