Debian Codegraph @

rpython/memory/test/test_hybrid_gc_smallheap.py

raw symbols SCIP
1 import py
2
3 from rpython.rlib.rarithmetic import LONG_BIT
4
5 from rpython.memory.test.gc_test_base import GCTest
6
7 WORD = LONG_BIT // 8
8
9 class TestHybridGCSmallHeap(GCTest):
10 from rpython.memory.gc.hybrid import HybridGC as GCClass
11 GC_CAN_MOVE = False # with this size of heap, stuff gets allocated
12 # in 3rd gen.
13 GC_PARAMS = {'space_size': 48*WORD,
14 'min_nursery_size': 12*WORD,
15 'nursery_size': 12*WORD,
16 'large_object': 3*WORD,
17 'large_object_gcptrs': 3*WORD,
18 'generation3_collect_threshold': 5,
19 }
20
21 def test_gen3_to_gen2_refs(self):
22 class A(object):
23 def __init__(self):
24 self.x1 = -1
25 def f(x):
26 loop = A()
27 loop.next = loop
28 loop.prev = loop
29 i = 0
30 while i < x:
31 i += 1
32 a1 = A()
33 a1.x1 = i
34 a2 = A()
35 a2.x1 = i + 1000
36 a1.prev = loop.prev
37 a1.prev.next = a1
38 a1.next = loop
39 loop.prev = a1
40 a2.prev = loop
41 a2.next = loop.next
42 a2.next.prev = a2
43 loop.next = a2
44 i = 0
45 a = loop
46 while True:
47 a = a.next
48 i += 1
49 if a is loop:
50 return i
51 res = self.interpret(f, [200])
52 assert res == 401