Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-and-itasks
sapl-interpreter
Commits
659d419d
Commit
659d419d
authored
Jan 11, 2016
by
Laszlo Domoszlai
Browse files
add more GC debug
parent
c593fce1
Changes
4
Hide whitespace changes
Inline
Side-by-side
interpreter/debug.c
View file @
659d419d
...
...
@@ -3,7 +3,9 @@
#include
"debug.h"
int
debug_cnt
=
0
;
#ifdef DEBUG
int
gc_cnt
=
0
;
#endif
void
not_implemented
(
char
*
msg
)
{
...
...
interpreter/debug.h
View file @
659d419d
#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 */
interpreter/gc.c
View file @
659d419d
...
...
@@ -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
}
interpreter/main.c
View file @
659d419d
...
...
@@ -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\n
Execution time: %G ms
\n
"
,
elapsedTime
);
printf
(
"
\n
Count: %i
\n
"
,
debug_cnt
);
#endif
#ifdef DEBUG
printf
(
"
\n
GC count: %i
\n
"
,
gc_cnt
);
print_stat
();
#endif
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment