Commit 659d419d authored by Laszlo Domoszlai's avatar Laszlo Domoszlai
Browse files

add more GC debug

parent c593fce1
......@@ -3,7 +3,9 @@
#include "debug.h"
int debug_cnt = 0;
#ifdef DEBUG
int gc_cnt = 0;
#endif
void not_implemented(char* msg)
{
......
#ifndef DEBUG_H
#define DEBUG_H
//#define DEBUG
//#define BENCHMARK
#define DEBUG
//#define DEBUG_GC
#define BENCHMARK
#ifndef DEBUG
#define NDEBUG
......@@ -13,7 +14,9 @@
void not_implemented(char* msg);
void abort(char* msg);
extern int debug_cnt;
#ifdef DEBUG
extern int gc_cnt;
#endif
#endif /* DEBUG_H */
......@@ -11,7 +11,6 @@
// http://stackoverflow.com/questions/17095324/fastest-way-to-determine-if-an-integer-is-between-two-integers-inclusive-with/17095534#17095534
//#define inheap(addr) ((unsigned)((int)addr-(int)heap_base_curr) < HEAP_SIZE)
#define inheap(addr) ((char*)addr >= heap_base_curr && (char*)addr < (heap_base_curr + HEAP_SIZE))
//#define instackb(addr) ((char*)addr >= (char*) &stack_b[0] && (char*)addr < (char*) &stack_b[STACK_SIZE_B])
int gc_enabled = 1;
......@@ -19,8 +18,15 @@ void gc()
{
if(!gc_enabled) return;
// gc_enabled = 0;
#ifdef DEBUG
gc_cnt++;
#endif
debug_cnt++;
#ifdef DEBUG_GC
printf("GC %i START\n", gc_cnt);
printf("ALLOC BEFORE: %i\n", (int) (heap_curr - heap_base_curr));
#endif
char* allocptr = heap_base_swap;
char* scanptr = heap_base_swap;
......@@ -58,6 +64,10 @@ void gc()
}
}
}
#ifdef DEBUG_GC
printf("ALLOC AFTER FIRST STAGE: %i\n", allocptr - heap_base_swap);
#endif
while(scanptr < allocptr)
{
......@@ -98,10 +108,19 @@ void gc()
}
}
}
#ifdef DEBUG_GC
printf("ALLOC AFTER SECOND STAGE: %i\n", allocptr - heap_base_swap);
#endif
heap_curr = allocptr;
char *tmp = heap_base_curr;
heap_base_curr = heap_base_swap;
heap_base_swap = tmp;
gc_trigger = heap_base_curr + HEAP_SIZE - 1024;
#ifdef DEBUG_GC
printf("GC %i END\n", gc_cnt);
#endif
}
......@@ -100,10 +100,10 @@ int main ( int argc, char *argv[] )
double elapsedTime = (t2.tv_sec - t1.tv_sec) * 1000.0; // sec to ms
elapsedTime += (t2.tv_usec - t1.tv_usec) / 1000.0; // us to ms
printf("\n\nExecution time: %G ms\n", elapsedTime);
printf("\nCount: %i\n", debug_cnt);
#endif
#ifdef DEBUG
printf("\nGC count: %i\n", gc_cnt);
print_stat();
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment