2000-11-03 17:52:20 +00:00
|
|
|
;;;; gc.test --- test guile's garbage collection -*- scheme -*-
|
2009-09-15 22:31:45 +02:00
|
|
|
;;;; Copyright (C) 2000, 2001, 2004, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
|
2000-11-03 17:52:20 +00:00
|
|
|
;;;;
|
2003-04-05 19:15:35 +00:00
|
|
|
;;;; This library is free software; you can redistribute it and/or
|
|
|
|
|
;;;; modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
;;;; License as published by the Free Software Foundation; either
|
2009-06-17 00:22:09 +01:00
|
|
|
;;;; version 3 of the License, or (at your option) any later version.
|
2003-04-05 19:15:35 +00:00
|
|
|
;;;;
|
|
|
|
|
;;;; This library is distributed in the hope that it will be useful,
|
2000-11-03 17:52:20 +00:00
|
|
|
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2003-04-05 19:15:35 +00:00
|
|
|
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
;;;; Lesser General Public License for more details.
|
|
|
|
|
;;;;
|
|
|
|
|
;;;; You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
;;;; License along with this library; if not, write to the Free Software
|
2005-05-23 19:57:22 +00:00
|
|
|
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2000-11-03 17:52:20 +00:00
|
|
|
|
2004-09-01 01:46:19 +00:00
|
|
|
(use-modules (ice-9 documentation)
|
|
|
|
|
(test-suite lib))
|
2000-11-03 17:52:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; miscellaneous
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define (documented? object)
|
2001-02-28 08:41:06 +00:00
|
|
|
(not (not (object-documentation object))))
|
2000-11-03 17:52:20 +00:00
|
|
|
|
2004-09-01 01:46:19 +00:00
|
|
|
;; In guile 1.6.4 this test bombed, due to the record in h being collected
|
|
|
|
|
;; by the gc, but not removed from h, leaving "x" as a freed cell.
|
|
|
|
|
;; The usual correct result here is for x to be #f, but there's always a
|
|
|
|
|
;; chance gc will mark something used when it isn't, so we allow x to be a
|
|
|
|
|
;; record too.
|
|
|
|
|
(pass-if "weak-values versus records"
|
|
|
|
|
(let ((rec-type (make-record-type "foo" '()))
|
|
|
|
|
(h (make-weak-value-hash-table 61)))
|
|
|
|
|
(hash-set! h "foo" ((record-constructor rec-type)))
|
|
|
|
|
(gc)
|
|
|
|
|
(let ((x (hash-ref h "foo")))
|
|
|
|
|
(or (not x)
|
|
|
|
|
((record-predicate rec-type) x)))))
|
|
|
|
|
|
2000-11-03 17:52:20 +00:00
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;;
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "gc"
|
|
|
|
|
|
|
|
|
|
(pass-if "after-gc-hook gets called"
|
|
|
|
|
(let* ((foo #f)
|
|
|
|
|
(thunk (lambda () (set! foo #t))))
|
|
|
|
|
(add-hook! after-gc-hook thunk)
|
|
|
|
|
(gc)
|
|
|
|
|
(remove-hook! after-gc-hook thunk)
|
|
|
|
|
foo)))
|
2005-06-11 01:48:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
(with-test-prefix "gc"
|
|
|
|
|
(pass-if "Unused modules are removed"
|
2007-10-21 18:53:50 +00:00
|
|
|
(let* ((guard (make-guardian))
|
|
|
|
|
(total 1000))
|
|
|
|
|
|
|
|
|
|
(for-each (lambda (x) (guard (make-module))) (iota total))
|
2008-02-15 16:02:22 +00:00
|
|
|
|
really boot primitive-eval from scheme.
* libguile/eval.c (scm_primitive_eval, scm_c_primitive_eval):
(scm_init_eval): Rework so that scm_primitive_eval always calls out to
the primitive-eval variable. The previous definition is the default
value, which is probably overridden by scm_init_eval_in_scheme.
* libguile/init.c (scm_i_init_guile): Move ports and load-path up, so we
can debug when initing eval. Call scm_init_eval_in_scheme. Awesome.
* libguile/load.h:
* libguile/load.c (scm_init_eval_in_scheme): New procedure, loads up
ice-9/eval.scm to replace the primitive-eval definition, if everything
is there and up-to-date.
* libguile/modules.c (scm_module_transformer): Export to Scheme, so it's
there for eval.go.
* module/ice-9/boot-9.scm: No need to define module-transformer.
* module/ice-9/eval.scm (capture-env): Only reference the-root-module if
modules are booted.
(primitive-eval): Inline a definition for identity. Throw a more
standard error for "wrong number of arguments".
* module/ice-9/psyntax.scm (chi-install-global): The macro binding for a
syncase macro is now a pair: the transformer, and the module that was
current when the transformer was installed. The latter is used for
hygiene purposes, replacing the use of procedure-module, which didn't
work with the interpreter's shared-code closures.
(chi-macro): Adapt for the binding being a pair, and get the hygiene
from the cdr.
(eval-local-transformer): Adapt to new form of macro bindings.
* module/ice-9/psyntax-pp.scm: Regenerated.
* .gitignore: Ignore eval.go.stamp.
* module/Makefile.am: Reorder for fastest serial compilation, now that
there are no ordering constraints. I did a number of experiments here
and this seems to be the best; but the bulk of the time is compiling
psyntax-pp.scm with eval.scm. Not so great.
* libguile/vm-engine.c (vm-engine): Throw a more standard error for
"wrong type to apply".
* test-suite/tests/gc.test ("gc"): Remove a hack that shouldn't affect
the new evaluator, and throw in another (gc) for good measure.
* test-suite/tests/goops.test ("defining classes"):
* test-suite/tests/hooks.test (proc1): We can't currently check what the
arity is of a closure made by eval.scm -- or more accurately all
closures have 0 required args and no rest args. So punt for now.
* test-suite/tests/syntax.test ("letrec"): The scheme evaluator can't
check that a variable is unbound, currently; perhaps the full "fixing
letrec" expansion could fix this. But barring that, punt.
2009-12-01 23:54:25 +01:00
|
|
|
(gc)
|
2005-06-11 01:48:19 +00:00
|
|
|
(gc) ;; twice: have to kill the weak vectors.
|
really boot primitive-eval from scheme.
* libguile/eval.c (scm_primitive_eval, scm_c_primitive_eval):
(scm_init_eval): Rework so that scm_primitive_eval always calls out to
the primitive-eval variable. The previous definition is the default
value, which is probably overridden by scm_init_eval_in_scheme.
* libguile/init.c (scm_i_init_guile): Move ports and load-path up, so we
can debug when initing eval. Call scm_init_eval_in_scheme. Awesome.
* libguile/load.h:
* libguile/load.c (scm_init_eval_in_scheme): New procedure, loads up
ice-9/eval.scm to replace the primitive-eval definition, if everything
is there and up-to-date.
* libguile/modules.c (scm_module_transformer): Export to Scheme, so it's
there for eval.go.
* module/ice-9/boot-9.scm: No need to define module-transformer.
* module/ice-9/eval.scm (capture-env): Only reference the-root-module if
modules are booted.
(primitive-eval): Inline a definition for identity. Throw a more
standard error for "wrong number of arguments".
* module/ice-9/psyntax.scm (chi-install-global): The macro binding for a
syncase macro is now a pair: the transformer, and the module that was
current when the transformer was installed. The latter is used for
hygiene purposes, replacing the use of procedure-module, which didn't
work with the interpreter's shared-code closures.
(chi-macro): Adapt for the binding being a pair, and get the hygiene
from the cdr.
(eval-local-transformer): Adapt to new form of macro bindings.
* module/ice-9/psyntax-pp.scm: Regenerated.
* .gitignore: Ignore eval.go.stamp.
* module/Makefile.am: Reorder for fastest serial compilation, now that
there are no ordering constraints. I did a number of experiments here
and this seems to be the best; but the bulk of the time is compiling
psyntax-pp.scm with eval.scm. Not so great.
* libguile/vm-engine.c (vm-engine): Throw a more standard error for
"wrong type to apply".
* test-suite/tests/gc.test ("gc"): Remove a hack that shouldn't affect
the new evaluator, and throw in another (gc) for good measure.
* test-suite/tests/goops.test ("defining classes"):
* test-suite/tests/hooks.test (proc1): We can't currently check what the
arity is of a closure made by eval.scm -- or more accurately all
closures have 0 required args and no rest args. So punt for now.
* test-suite/tests/syntax.test ("letrec"): The scheme evaluator can't
check that a variable is unbound, currently; perhaps the full "fixing
letrec" expansion could fix this. But barring that, punt.
2009-12-01 23:54:25 +01:00
|
|
|
(gc) ;; thrice: because the test doesn't succeed with only
|
|
|
|
|
;; one gc round. not sure why.
|
|
|
|
|
|
|
|
|
|
(= (let lp ((i 0))
|
|
|
|
|
(if (guard)
|
|
|
|
|
(lp (1+ i))
|
|
|
|
|
i))
|
2007-10-21 18:53:50 +00:00
|
|
|
total))))
|
really boot primitive-eval from scheme.
* libguile/eval.c (scm_primitive_eval, scm_c_primitive_eval):
(scm_init_eval): Rework so that scm_primitive_eval always calls out to
the primitive-eval variable. The previous definition is the default
value, which is probably overridden by scm_init_eval_in_scheme.
* libguile/init.c (scm_i_init_guile): Move ports and load-path up, so we
can debug when initing eval. Call scm_init_eval_in_scheme. Awesome.
* libguile/load.h:
* libguile/load.c (scm_init_eval_in_scheme): New procedure, loads up
ice-9/eval.scm to replace the primitive-eval definition, if everything
is there and up-to-date.
* libguile/modules.c (scm_module_transformer): Export to Scheme, so it's
there for eval.go.
* module/ice-9/boot-9.scm: No need to define module-transformer.
* module/ice-9/eval.scm (capture-env): Only reference the-root-module if
modules are booted.
(primitive-eval): Inline a definition for identity. Throw a more
standard error for "wrong number of arguments".
* module/ice-9/psyntax.scm (chi-install-global): The macro binding for a
syncase macro is now a pair: the transformer, and the module that was
current when the transformer was installed. The latter is used for
hygiene purposes, replacing the use of procedure-module, which didn't
work with the interpreter's shared-code closures.
(chi-macro): Adapt for the binding being a pair, and get the hygiene
from the cdr.
(eval-local-transformer): Adapt to new form of macro bindings.
* module/ice-9/psyntax-pp.scm: Regenerated.
* .gitignore: Ignore eval.go.stamp.
* module/Makefile.am: Reorder for fastest serial compilation, now that
there are no ordering constraints. I did a number of experiments here
and this seems to be the best; but the bulk of the time is compiling
psyntax-pp.scm with eval.scm. Not so great.
* libguile/vm-engine.c (vm-engine): Throw a more standard error for
"wrong type to apply".
* test-suite/tests/gc.test ("gc"): Remove a hack that shouldn't affect
the new evaluator, and throw in another (gc) for good measure.
* test-suite/tests/goops.test ("defining classes"):
* test-suite/tests/hooks.test (proc1): We can't currently check what the
arity is of a closure made by eval.scm -- or more accurately all
closures have 0 required args and no rest args. So punt for now.
* test-suite/tests/syntax.test ("letrec"): The scheme evaluator can't
check that a variable is unbound, currently; perhaps the full "fixing
letrec" expansion could fix this. But barring that, punt.
2009-12-01 23:54:25 +01:00
|
|
|
|