Exemple #1
0
 def ll_build(ll_builder):
     final_size = ll_builder.used
     assert final_size >= 0
     if final_size < ll_builder.allocated:
         ll_builder.allocated = final_size
         ll_builder.buf = rgc.ll_shrink_array(ll_builder.buf, final_size)
     return ll_builder.buf
Exemple #2
0
 def ll_build(ll_builder):
     final_size = ll_builder.used
     assert final_size >= 0
     if final_size < ll_builder.allocated:
         ll_builder.allocated = final_size
         ll_builder.buf = rgc.ll_shrink_array(ll_builder.buf, final_size)
     return ll_builder.buf
Exemple #3
0
 def f():
     ptr = lltype.malloc(STR, 3)
     ptr.hash = 0x62
     ptr.chars[0] = '0'
     ptr.chars[1] = 'B'
     ptr.chars[2] = 'C'
     ptr2 = rgc.ll_shrink_array(ptr, 2)
     return ((ptr == ptr2) + ord(ptr2.chars[0]) +
             (ord(ptr2.chars[1]) << 8) + (len(ptr2.chars) << 16) +
             (ptr2.hash << 24))
Exemple #4
0
 def f(n, m):
     ptr = lltype.malloc(STR, n)
     ptr.hash = 0x62
     ptr.chars[0] = 'A'
     ptr.chars[1] = 'B'
     ptr.chars[2] = 'C'
     ptr2 = rgc.ll_shrink_array(ptr, 2)
     assert (ptr == ptr2) == GC_CAN_SHRINK_ARRAY
     rgc.collect()
     return (ord(ptr2.chars[0]) + (ord(ptr2.chars[1]) << 8) +
             (len(ptr2.chars) << 16) + (ptr2.hash << 24))
Exemple #5
0
 def f():
     ptr = lltype.malloc(STR, 3)
     ptr.hash = 0x62
     ptr.chars[0] = '0'
     ptr.chars[1] = 'B'
     ptr.chars[2] = 'C'
     ptr2 = rgc.ll_shrink_array(ptr, 2)
     return ((ptr == ptr2)             +
              ord(ptr2.chars[0])       +
             (ord(ptr2.chars[1]) << 8) +
             (len(ptr2.chars)   << 16) +
             (ptr2.hash         << 24))
Exemple #6
0
def test_ll_shrink_array_2():
    S = lltype.GcStruct('S', ('x', lltype.Signed),
                             ('vars', lltype.Array(lltype.Signed)))
    s1 = lltype.malloc(S, 5)
    s1.x = 1234
    for i in range(5):
        s1.vars[i] = 50 + i
    s2 = rgc.ll_shrink_array(s1, 3)
    assert lltype.typeOf(s2) == lltype.Ptr(S)
    assert s2.x == 1234
    assert len(s2.vars) == 3
    for i in range(3):
        assert s2.vars[i] == 50 + i
Exemple #7
0
def test_ll_shrink_array_2():
    S = lltype.GcStruct('S', ('x', lltype.Signed),
                        ('vars', lltype.Array(lltype.Signed)))
    s1 = lltype.malloc(S, 5)
    s1.x = 1234
    for i in range(5):
        s1.vars[i] = 50 + i
    s2 = rgc.ll_shrink_array(s1, 3)
    assert lltype.typeOf(s2) == lltype.Ptr(S)
    assert s2.x == 1234
    assert len(s2.vars) == 3
    for i in range(3):
        assert s2.vars[i] == 50 + i
Exemple #8
0
 def f(n, m, gc_can_shrink_array):
     ptr = lltype.malloc(STR, n)
     ptr.hash = 0x62
     ptr.chars[0] = 'A'
     ptr.chars[1] = 'B'
     ptr.chars[2] = 'C'
     ptr2 = rgc.ll_shrink_array(ptr, 2)
     assert (ptr == ptr2) == gc_can_shrink_array
     rgc.collect()
     return ( ord(ptr2.chars[0])       +
             (ord(ptr2.chars[1]) << 8) +
             (len(ptr2.chars)   << 16) +
             (ptr2.hash         << 24))
Exemple #9
0
 def ll_build(ll_builder):
     final_size = ll_builder.used
     assert final_size >= 0
     if final_size == ll_builder.allocated:
         return ll_builder.buf
     return rgc.ll_shrink_array(ll_builder.buf, final_size)
Exemple #10
0
 def ll_build(ll_builder):
     final_size = ll_builder.used
     assert final_size >= 0
     if final_size == ll_builder.allocated:
         return ll_builder.buf
     return rgc.ll_shrink_array(ll_builder.buf, final_size)