sasagawa888 / eisl

ISLisp interpreter/compiler
Other
267 stars 22 forks source link

Bug copy GC #281

Closed sasagawa888 closed 1 year ago

sasagawa888 commented 1 year ago
tests/hiroi.lsp
(defun taxi (n)
  (for ((a 1 (+ a 1)))
       ((< n a))
       (for ((b a (+ b 1)))
            ((< n b))
            (for ((c (+ a 1) (+ c 1)))
                 ((< n c))
                 (for ((d c (+ d 1)))
                      ((<= b d))
                      (let ((e (+ (* a a a) (* b b b))))
                        (if (= (+ (* c c c) (* d d d)) e)
                            (format (standard-output) "~D: (~D, ~D), (~D,~D)~%" e a b c d))))))))

> (load "tests/hiroi.lsp")
T
> (gbc 'copy)
T
> (gbc t)
T
> (taxi 70)
1729: (1, 12), (9,10)
4104: (2, 16), (9,15)
13832: (2, 24), (18,20)
39312: (2, 34), (15,33)
46683: (3, 36), (27,30)
216027: (3, 60), (22,59)
32832: (4, 32), (18,30)
110656: (4, 48), (36,40)
314496: (4, 68), (30,66)
216125: (5, 60), (45,50)
enter COPY-GC free=895
exit  COPY-GC free=6999987
110808: (6, 48), (27,45)
149389: (8, 53), (29,50)
262656: (8, 64), (36,60)
40033: (9, 34), (16,33)
195841: (9, 58), (22,57)
20683: (10, 27), (19,24)
65728: (12, 40), (31,33)
134379: (12, 51), (38,43)
enter COPY-GC free=897
exit  COPY-GC free=6999989
Unbound variable at EVAL N
debug mode ?(help)
>>
sasagawa888 commented 1 year ago

The cause was that the environment pointed to by ep spanned two cell regions. It was difficult to solve this problem and coexist with M&S. This time, it will be integrated into M&S.