1 USING: accessors byte-arrays effects kernel kernel.private math memory
2 prettyprint io sequences tools.test words namespaces layouts classes
3 classes.builtin arrays quotations system ;
4 FROM: tools.memory => data-room code-room ;
7 [ save-image-and-exit ] must-fail
9 ! Tests for 'instances'
10 [ [ ] instances ] must-infer
11 2 [ [ [ 3 throw ] instances ] must-fail ] times
14 { } [ { } { } become ] unit-test
16 ! Become something when it's on the data stack.
18 "original" dup 1array { "replacer" } become
23 "original" [ 5 [ 1array ] times ] [ 1array ] bi
25 { "replacer" } become 5 [ first ] times
28 ! Also when it is nested in nursery
31 "original" [ 5 [ 1array ] times ] [ 1array ] bi { "replacer" } become
35 ! Bug found on Windows build box, having too many words in the
36 ! image breaks 'become'
37 { } [ 100000 [ f <uninterned-word> ] replicate { } { } become drop ] unit-test
39 ! Bug: code heap collection had to be done when data heap was
40 ! full, not just when code heap was full. If the code heap
41 ! contained dead code blocks referring to large data heap
42 ! objects, those large objects would continue to live on even
43 ! if the code blocks were not reachable, as long as the code
44 ! heap did not fill up.
45 : leak-step ( -- ) 800000 f <array> 1quotation call( -- obj ) drop ;
47 : leak-loop ( -- ) 100 [ leak-step ] times ;
49 { } [ leak-loop ] unit-test
51 ! Bug: allocation of large objects directly into tenured space
52 ! can proceed past the high water mark.
54 ! Suppose the nursery and aging spaces are mostly comprised of
55 ! reachable objects. When doing a full GC, objects from young
56 ! generations ere promoted *before* unreachable objects in
57 ! tenured space are freed by the sweep phase. So if large object
58 ! allocation filled up the heap past the high water mark, this
59 ! promotion might trigger heap growth, even if most of those
60 ! large objects are unreachable.
66 data-room tenured>> size>>
69 4 [ 120 1024 * f <array> ] replicate foo set-global
70 100 [ 256 1024 * f <array> drop ] times
73 data-room tenured>> size>>
77 ! Perform one gc cycle. Then increase the stack height by 100 and
78 ! force a gc cycle again.
82 { 1 2 3 } { 4 5 6 } <effect> drop ;
84 : deep-stack-minor-gc ( n -- )
86 dup 0 > [ 1 - deep-stack-minor-gc ] [
87 drop 100000 [ perform ] times
92 minor-gc 100 deep-stack-minor-gc
99 20 f <array> 20 f <array> assert=
100 ! Allocates a byte array so large that the next allocation will
102 drop 2097103 <byte-array> ;
106 ! D 0 is scrubbed, but if the branch calling 'inner' was
107 ! called, then both D 0 and D 1 should have been scrubbed.