! Tests for 'become'
[ ] [ { } { } become ] unit-test
+! Become something when it's on the data stack.
+{ "replacer" } [
+ "original" dup 1array { "replacer" } become
+] unit-test
+
+! Nested in aging
+{ "replacer" } [
+ "original" [ 5 [ 1array ] times ] [ 1array ] bi
+ minor-gc
+ { "replacer" } become 5 [ first ] times
+] unit-test
+
+! Also when it is nested in nursery
+{ "replacer" } [
+ minor-gc
+ "original" [ 5 [ 1array ] times ] [ 1array ] bi { "replacer" } become
+ 5 [ first ] times
+] unit-test
+
! Bug found on Windows build box, having too many words in the
! image breaks 'become'
[ ] [ 100000 [ f <uninterned-word> ] replicate { } { } become drop ] unit-test
gc
data-room tenured>> size>>
-
+
10 [
4 [ 120 1024 * f <array> ] replicate foo set-global
100 [ 256 1024 * f <array> drop ] times
] times
-
+
data-room tenured>> size>>
assert=
] unit-test
/* Allocates memory */
cell factor_vm::instances(cell type) {
+ primitive_full_gc();
object_accumulator accum(type);
each_object(accum);
return std_vector_to_array(accum.objects);
/* Allocates memory */
void factor_vm::primitive_all_instances() {
- primitive_full_gc();
ctx->push(instances(TYPE_COUNT));
}
/* classes.tuple uses this to reshape tuples; tools.deploy.shaker uses this
to coalesce equal but distinct quotations and wrappers. */
void factor_vm::primitive_become() {
+ primitive_minor_gc();
array* new_objects = untag_check<array>(ctx->pop());
array* old_objects = untag_check<array>(ctx->pop());
}
template <typename Iterator> inline void each_object(Iterator& iterator) {
- gc_off = true;
+ /* The nursery can't be iterated because there may be gaps between
+ the objects (see factor_vm::reallot_array) so we require it to
+ be empty first. */
+ FACTOR_ASSERT(nursery.occupied_space() == 0);
+
+ gc_off = true;
each_object(data->tenured, iterator);
each_object(data->aging, iterator);
- each_object(data->nursery, iterator);
-
gc_off = false;
}