~ chicken-core (chicken-5) cae39e635a499bf6f6adb02a3fb79213d7f2f6bc
commit cae39e635a499bf6f6adb02a3fb79213d7f2f6bc
Author: felix <felix@call-with-current-continuation.org>
AuthorDate: Thu Sep 29 15:19:38 2016 +0200
Commit: felix <felix@call-with-current-continuation.org>
CommitDate: Thu Sep 29 15:19:38 2016 +0200
(by Peter Bex) Make weak symbol GC the default.
Because symbol GC is now nothing special, we can do this. The overhead
of the symbol table fixup in update_symbol_tables() is neglible, and in
many cases offset by the gains of not needlessly copying symbol data.
This removes the -:w option, and the SYMBOLGC compile-time option no
longer does anything.
Signed-off-by: felix <felix@call-with-current-continuation.org>
diff --git a/Makefile.aix b/Makefile.aix
index fd71f7fd..2d203ed1 100644
--- a/Makefile.aix
+++ b/Makefile.aix
@@ -96,9 +96,6 @@ chicken-config.h: chicken-defaults.h
echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@
ifdef GCHOOKS
echo "#define C_GC_HOOKS" >>$@
-endif
-ifdef SYMBOLGC
- echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
endif
cat chicken-defaults.h >>$@
diff --git a/Makefile.android b/Makefile.android
index 2fe785a8..d0c677ea 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -90,9 +90,6 @@ chicken-config.h: chicken-defaults.h
echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@
ifdef GCHOOKS
echo "#define C_GC_HOOKS" >>$@
-endif
-ifdef SYMBOLGC
- echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
endif
cat chicken-defaults.h >>$@
diff --git a/Makefile.bsd b/Makefile.bsd
index 8a089bc6..b4a47d0e 100644
--- a/Makefile.bsd
+++ b/Makefile.bsd
@@ -96,9 +96,6 @@ chicken-config.h: chicken-defaults.h
echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@
ifdef GCHOOKS
echo "#define C_GC_HOOKS" >>$@
-endif
-ifdef SYMBOLGC
- echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
endif
cat chicken-defaults.h >>$@
diff --git a/Makefile.cross-linux-mingw b/Makefile.cross-linux-mingw
index 338adfdb..488d41b0 100644
--- a/Makefile.cross-linux-mingw
+++ b/Makefile.cross-linux-mingw
@@ -113,9 +113,6 @@ chicken-config.h: chicken-defaults.h
echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@
ifdef GCHOOKS
echo "#define C_GC_HOOKS" >>$@
-endif
-ifdef SYMBOLGC
- echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
endif
cat chicken-defaults.h >>$@
diff --git a/Makefile.cygwin b/Makefile.cygwin
index 05b0014f..161a31f2 100644
--- a/Makefile.cygwin
+++ b/Makefile.cygwin
@@ -110,9 +110,6 @@ chicken-config.h: chicken-defaults.h
echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@
ifdef GCHOOKS
echo "#define C_GC_HOOKS" >>$@
-endif
-ifdef SYMBOLGC
- echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
endif
cat chicken-defaults.h >>$@
diff --git a/Makefile.haiku b/Makefile.haiku
index 4e448e90..7fe7576b 100644
--- a/Makefile.haiku
+++ b/Makefile.haiku
@@ -90,9 +90,6 @@ chicken-config.h: chicken-defaults.h
echo "#define SIGIO 0" >>$@
ifdef GCHOOKS
echo "#define C_GC_HOOKS" >>$@
-endif
-ifdef SYMBOLGC
- echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
endif
cat chicken-defaults.h >>$@
diff --git a/Makefile.hurd b/Makefile.hurd
index bd7549b2..a0ebff49 100644
--- a/Makefile.hurd
+++ b/Makefile.hurd
@@ -91,9 +91,6 @@ chicken-config.h: chicken-defaults.h
echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@
ifdef GCHOOKS
echo "#define C_GC_HOOKS" >>$@
-endif
-ifdef SYMBOLGC
- echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
endif
cat chicken-defaults.h >>$@
diff --git a/Makefile.ios b/Makefile.ios
index 70a5f279..9f460646 100644
--- a/Makefile.ios
+++ b/Makefile.ios
@@ -94,9 +94,6 @@ chicken-config.h: chicken-defaults.h
echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@
ifdef GCHOOKS
echo "#define C_GC_HOOKS" >>$@
-endif
-ifdef SYMBOLGC
- echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
endif
cat chicken-defaults.h >>$@
diff --git a/Makefile.linux b/Makefile.linux
index f0d3ae6b..7c0bc2af 100644
--- a/Makefile.linux
+++ b/Makefile.linux
@@ -98,9 +98,6 @@ chicken-config.h: chicken-defaults.h
echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@
ifdef GCHOOKS
echo "#define C_GC_HOOKS" >>$@
-endif
-ifdef SYMBOLGC
- echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
endif
cat chicken-defaults.h >>$@
diff --git a/Makefile.macosx b/Makefile.macosx
index 88906dd1..f89669b1 100644
--- a/Makefile.macosx
+++ b/Makefile.macosx
@@ -119,9 +119,6 @@ chicken-config.h: chicken-defaults.h
echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@
ifdef GCHOOKS
echo "#define C_GC_HOOKS" >>$@
-endif
-ifdef SYMBOLGC
- echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
endif
cat chicken-defaults.h >>$@
diff --git a/Makefile.mingw b/Makefile.mingw
index c249f45e..87143b75 100644
--- a/Makefile.mingw
+++ b/Makefile.mingw
@@ -100,9 +100,6 @@ chicken-config.h: chicken-defaults.h
echo #define C_STACK_GROWS_DOWNWARD 1 >>$@
ifdef GCHOOKS
echo #define C_GC_HOOKS >>$@
-endif
-ifdef SYMBOLGC
- echo #define C_COLLECT_ALL_SYMBOLS >>$@
endif
type chicken-defaults.h >>$@
diff --git a/Makefile.mingw-msys b/Makefile.mingw-msys
index 5b2aab90..e6aa4039 100644
--- a/Makefile.mingw-msys
+++ b/Makefile.mingw-msys
@@ -105,9 +105,6 @@ chicken-config.h: chicken-defaults.h
echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@
ifdef GCHOOKS
echo "#define C_GC_HOOKS" >>$@
-endif
-ifdef SYMBOLGC
- echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
endif
cat chicken-defaults.h >>$@
diff --git a/Makefile.solaris b/Makefile.solaris
index 22daf3f7..111b0a23 100644
--- a/Makefile.solaris
+++ b/Makefile.solaris
@@ -120,9 +120,6 @@ chicken-config.h: chicken-defaults.h
echo "#define C_STACK_GROWS_DOWNWARD 1" >>$@
ifdef GCHOOKS
echo "#define C_GC_HOOKS" >>$@
-endif
-ifdef SYMBOLGC
- echo "#define C_COLLECT_ALL_SYMBOLS" >>$@
endif
cat chicken-defaults.h >>$@
diff --git a/NEWS b/NEWS
index 6d643d3c..f76a7b7d 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@
flag to a bitmap, to allow for multidirectional ports.
- Weak symbol GC is faster, simpler, and can now collect all
unreferenced symbols instead of a maximum of 997 per major GC.
+ - The -:w option has been removed; symbols are now always collected.
- Compiler
- Fixed an off by one allocation problem in generated C code for (list ...).
diff --git a/README b/README
index af965474..9acba391 100644
--- a/README
+++ b/README
@@ -164,15 +164,6 @@
`chicken-status' will not be generated, as it is mostly
useless unless compiled code can be loaded.
- SYMBOLGC=1
- Always enable garbage collection for unused symbols in the
- symbol table by default. This will result in slightly slower
- garbage collection, but minimizes the amount of garbage
- retained at runtime (which might be important for long
- running server applications). If you don't specify this
- option you can still enable symbol GC at runtime by passing
- the `-:w' runtime option when running the program.
-
EXTRA_CHICKEN_OPTIONS=...
Additional options that should be passed to `chicken' when
building the system.
diff --git a/chicken.h b/chicken.h
index 33018c9a..5a64f543 100644
--- a/chicken.h
+++ b/chicken.h
@@ -1765,7 +1765,6 @@ C_varextern C_TLS int
C_abort_on_thread_exceptions,
C_interrupts_enabled,
C_disable_overflow_check,
- C_enable_gcweak,
C_heap_size_is_fixed,
C_max_pending_finalizers,
C_trace_buffer_size,
@@ -2780,8 +2779,7 @@ C_inline int C_persistable_symbol(C_word x)
{
C_word val = C_symbol_value(x);
/* Symbol is bound (and not a keyword), or has a non-empty plist */
- return (!C_enable_gcweak || /* Overrides to always true */
- (val != C_SCHEME_UNBOUND && val != x) ||
+ return ((val != C_SCHEME_UNBOUND && val != x) ||
C_symbol_plist(x) != C_SCHEME_END_OF_LIST);
}
@@ -3421,7 +3419,7 @@ C_inline C_word C_fcall C_a_bucket(C_word **ptr, C_word head, C_word tail)
{
C_word *p = *ptr, *p0 = p;
- *(p++) = C_enable_gcweak ? C_WEAK_BUCKET_TAG : C_BUCKET_TAG;
+ *(p++) = C_WEAK_BUCKET_TAG; /* Changes to strong if sym is persisted */
*(p++) = head;
*(p++) = tail;
*ptr = p;
diff --git a/config.make b/config.make
index 04d7cf1a..0cfe765b 100644
--- a/config.make
+++ b/config.make
@@ -20,9 +20,6 @@
# Build static runtime library only:
#STATICBUILD=1
-# Enable GC of symbols:
-#SYMBOLGC=1
-
# Use alternative C compiler
#C_COMPILER=
diff --git a/runtime.c b/runtime.c
index 1c6091c2..27f1964d 100644
--- a/runtime.c
+++ b/runtime.c
@@ -370,11 +370,6 @@ C_TLS int
C_enable_repl,
C_interrupts_enabled,
C_disable_overflow_check,
-#ifdef C_COLLECT_ALL_SYMBOLS
- C_enable_gcweak = 1,
-#else
- C_enable_gcweak = 0,
-#endif
C_heap_size_is_fixed,
C_trace_buffer_size = DEFAULT_TRACE_BUFFER_SIZE,
C_max_pending_finalizers = C_DEFAULT_MAX_PENDING_FINALIZERS,
@@ -1468,10 +1463,6 @@ void CHICKEN_parse_command_line(int argc, char *argv[], C_word *heap, C_word *st
gc_report_flag = 2;
break;
- case 'w':
- C_enable_gcweak = 1;
- break;
-
case 'P':
profiling = 1;
profile_frequency = arg_val(ptr);
@@ -4152,59 +4143,43 @@ C_regparm void C_fcall update_symbol_tables(int mode)
C_SYMBOL_TABLE *stp;
assert(mode != GC_MINOR); /* Call only in major or realloc mode */
- if(C_enable_gcweak) {
- /* Update symbol locations through fptrs or drop if unreferenced */
- for(stp = symbol_table_list; stp != NULL; stp = stp->next) {
- for(i = 0; i < stp->size; ++i) {
- last = 0;
+ /* Update symbol locations through fptrs or drop if unreferenced */
+ for(stp = symbol_table_list; stp != NULL; stp = stp->next) {
+ for(i = 0; i < stp->size; ++i) {
+ last = 0;
- for(bucket = stp->table[ i ]; bucket != C_SCHEME_END_OF_LIST; bucket = C_block_item(bucket,1)) {
+ for(bucket = stp->table[ i ]; bucket != C_SCHEME_END_OF_LIST; bucket = C_block_item(bucket,1)) {
- sym = C_block_item(bucket, 0);
- h = C_block_header(sym);
+ sym = C_block_item(bucket, 0);
+ h = C_block_header(sym);
- /* Resolve any forwarding pointers */
- while(is_fptr(h)) {
- sym = fptr_to_ptr(h);
- h = C_block_header(sym);
- }
+ /* Resolve any forwarding pointers */
+ while(is_fptr(h)) {
+ sym = fptr_to_ptr(h);
+ h = C_block_header(sym);
+ }
- assert((h & C_HEADER_TYPE_BITS) == C_SYMBOL_TYPE);
+ assert((h & C_HEADER_TYPE_BITS) == C_SYMBOL_TYPE);
- /* If the symbol is unreferenced, drop it: */
- if(!C_truep(C_permanentp(sym)) && (mode == GC_REALLOC ?
- !C_in_new_heapp(sym) :
- !C_in_fromspacep(sym))) {
+ /* If the symbol is unreferenced, drop it: */
+ if(!C_truep(C_permanentp(sym)) && (mode == GC_REALLOC ?
+ !C_in_new_heapp(sym) :
+ !C_in_fromspacep(sym))) {
- if(last) C_set_block_item(last, 1, C_block_item(bucket,1));
- else stp->table[ i ] = C_block_item(bucket,1);
+ if(last) C_set_block_item(last, 1, C_block_item(bucket,1));
+ else stp->table[ i ] = C_block_item(bucket,1);
- assert(!C_persistable_symbol(sym));
- ++weakn;
- } else {
- C_set_block_item(bucket,0,sym); /* Might have moved */
- last = bucket;
- }
+ assert(!C_persistable_symbol(sym));
+ ++weakn;
+ } else {
+ C_set_block_item(bucket,0,sym); /* Might have moved */
+ last = bucket;
}
}
}
- if(gc_report_flag && weakn)
- C_dbg("GC", C_text("%d recoverable weakly held items found\n"), weakn);
- } else {
-#ifdef DEBUGBUILD
- /* Sanity check: all symbols should've been marked */
- for(stp = symbol_table_list; stp != NULL; stp = stp->next)
- for(i = 0; i < stp->size; ++i)
- for(bucket = stp->table[ i ]; bucket != C_SCHEME_END_OF_LIST; bucket = C_block_item(bucket,1)) {
- sym = C_block_item(bucket, 0);
- assert(!is_fptr(C_block_header(sym)) &&
- (C_truep(C_permanentp(sym)) ||
- (mode == GC_REALLOC ?
- C_in_new_heapp(sym) :
- C_in_fromspacep(sym))));
- }
-#endif
}
+ if(gc_report_flag && weakn)
+ C_dbg("GC", C_text("%d recoverable weakly held items found\n"), weakn);
}
@@ -4921,7 +4896,7 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor)
return C_mk_bool(C_interrupts_enabled);
case C_fix(15): /* symbol-gc enabled? */
- return C_mk_bool(C_enable_gcweak);
+ return C_SCHEME_TRUE;
case C_fix(16): /* milliseconds (wall clock) */
panic(C_text("(##sys#fudge 16) [current wall clock milliseconds] not implemented"));
diff --git a/tests/runtests.bat b/tests/runtests.bat
index 591b1a10..248a1528 100644
--- a/tests/runtests.bat
+++ b/tests/runtests.bat
@@ -489,7 +489,7 @@ for %%s in (100000 120000 200000 250000 300000 350000 400000 450000 500000) do (
echo ======================================== symbol-GC tests ...
%compile% symbolgc-tests.scm
if errorlevel 1 exit /b 1
-a.out -:w
+a.out
if errorlevel 1 exit /b 1
echo ======================================== finalizer tests ...
diff --git a/tests/runtests.sh b/tests/runtests.sh
index 23e6763e..e10482eb 100755
--- a/tests/runtests.sh
+++ b/tests/runtests.sh
@@ -422,7 +422,7 @@ done
echo "======================================== symbol-GC tests ..."
$compile symbolgc-tests.scm
-./a.out -:w
+./a.out
echo "======================================== finalizer tests ..."
$interpret -s test-finalizers.scm
diff --git a/tests/symbolgc-tests.scm b/tests/symbolgc-tests.scm
index 0b458599..923ee71b 100644
--- a/tests/symbolgc-tests.scm
+++ b/tests/symbolgc-tests.scm
@@ -1,11 +1,7 @@
;;;; symbolgc-tests.scm
-;
-; - run this with the "-:w" option
(use gc (chicken format))
-(assert (##sys#fudge 15) "please run this test with the `-:w' runtime option")
-
;; Ensure counts are defined before creating the disposable symbols.
;; This way, this program can also be run in interpreted mode.
(define *count-before* #f)
Trap