Adding option to disable automatic running of finalizers altogether.

This commit is contained in:
Alex Shinn 2015-06-14 16:19:55 +09:00
parent 4527c772c5
commit 6db194171e
4 changed files with 16 additions and 0 deletions

2
gc.c
View file

@ -322,6 +322,7 @@ void sexp_reset_weak_references(sexp ctx) {
#define sexp_reset_weak_references(ctx)
#endif
#if SEXP_USE_FINALIZERS
sexp sexp_finalize (sexp ctx) {
size_t size;
sexp p, t, end;
@ -368,6 +369,7 @@ sexp sexp_finalize (sexp ctx) {
#endif
return sexp_make_fixnum(finalize_count);
}
#endif
sexp sexp_sweep (sexp ctx, size_t *sum_freed_ptr) {
size_t freed, max_freed=0, sum_freed=0, size;

View file

@ -84,6 +84,11 @@
/* go away and you're not working on your own C extension. */
/* #define SEXP_USE_CONSERVATIVE_GC 1 */
/* uncomment this to disable automatic running of finalizers */
/* You will need to close ports and file descriptors manually */
/* (as you should anyway) and some C extensions may break. */
/* #define SEXP_USE_FINALIZERS 0 */
/* uncomment this to add additional native checks to only mark objects in the heap */
/* #define SEXP_USE_SAFE_GC_MARK 1 */
@ -387,6 +392,10 @@
#define SEXP_USE_CONSERVATIVE_GC 0
#endif
#ifndef SEXP_USE_FINALIZERS
#define SEXP_USE_FINALIZERS 1
#endif
#ifndef SEXP_USE_TRACK_ALLOC_SOURCE
#define SEXP_USE_TRACK_ALLOC_SOURCE SEXP_USE_DEBUG_GC > 2
#endif

View file

@ -1522,7 +1522,11 @@ SEXP_API int sexp_grow_heap (sexp ctx, size_t size, size_t chunk_size);
SEXP_API sexp_heap sexp_make_heap (size_t size, size_t max_size, size_t chunk_size);
SEXP_API void sexp_mark (sexp ctx, sexp x);
SEXP_API sexp sexp_sweep (sexp ctx, size_t *sum_freed_ptr);
#if SEXP_USE_FINALIZERS
SEXP_API sexp sexp_finalize (sexp ctx);
#else
#define sexp_finalize(ctx) SEXP_ZERO
#endif
#endif
#if SEXP_USE_GLOBAL_HEAP

View file

@ -5,6 +5,7 @@ CPPFLAGS=-DSEXP_USE_SIMPLIFY=0
CPPFLAGS=-DSEXP_USE_TYPE_DEFS=0
SEXP_USE_BOEHM=1;CPPFLAGS=-I/opt/local/include;LDFLAGS=-L/opt/local/lib
CPPFLAGS=-DSEXP_USE_DEBUG_GC=1
CPPFLAGS=-DSEXP_USE_FINALIZERS=0
CPPFLAGS=-DSEXP_USE_CONSERVATIVE_GC=1
CPPFLAGS=-DSEXP_USE_GLOBAL_HEAP=1
CPPFLAGS=-DSEXP_USE_GLOBAL_SYMBOLS=1