示例#1
0
        def do_call(result, path, index, remaining_depth):
            # clone the while path
            clonedata.gcobjectptr = lltype.cast_opaque_ptr(llmemory.GCREF,
                                                           path)
            clonedata.pool = lltype.nullptr(X_POOL)
            llop.gc_x_clone(lltype.Void, clonedata)
            # install the new pool as the current one
            parentpool = llop.gc_x_swap_pool(X_POOL_PTR, clonedata.pool)
            path = lltype.cast_opaque_ptr(lltype.Ptr(NODE),
                                          clonedata.gcobjectptr)

            # The above should have the same effect as:
            #    path = clone(path)

            # bump all the path node counters by one
            p = path
            while p:
                p.counter += 1
                p = p.next

            if remaining_depth == 0:
                llop.debug_print(lltype.Void, "setting", index, "with", path)
                result[index] = path   # leaf
            else:
                node = lltype.malloc(NODE)
                node.index = index * 2
                node.counter = 0
                node.next = path
                do_call(result, node, index * 2, remaining_depth - 1)
                node.index += 1    # mutation!
                do_call(result, node, index * 2 + 1, remaining_depth - 1)

            # restore the parent pool
            llop.gc_x_swap_pool(X_POOL_PTR, parentpool)
示例#2
0
 def func():
     oldpool = llop.gc_x_swap_pool(X_POOL_PTR, lltype.nullptr(X_POOL))
     a2 = make(22)
     newpool = llop.gc_x_swap_pool(X_POOL_PTR, oldpool)
     # clone a2
     a2ref = lltype.cast_opaque_ptr(llmemory.GCREF, a2)
     clonedata = lltype.malloc(X_CLONE)
     clonedata.gcobjectptr = a2ref
     clonedata.pool = newpool
     llop.gc_x_clone(lltype.Void, clonedata)
     a2copyref = clonedata.gcobjectptr
     a2copy = lltype.cast_opaque_ptr(lltype.Ptr(A), a2copyref)
     a2copy.b.x = 44
     a2copy.more[0].x = 440
     a2copy.more[1].x = 441
     return a2.b.x * 1000000 + a2.more[0].x * 1000 + a2.more[1].x
示例#3
0
 def func():
     a1 = make(111)
     # start recording mallocs in a new pool
     oldpool = llop.gc_x_swap_pool(X_POOL_PTR, lltype.nullptr(X_POOL))
     # the following a2 goes into the new list
     a2 = make(222)
     # now put the old pool back and get the new pool
     newpool = llop.gc_x_swap_pool(X_POOL_PTR, oldpool)
     a3 = make(333)
     # clone a2
     a2ref = lltype.cast_opaque_ptr(llmemory.GCREF, a2)
     clonedata = lltype.malloc(X_CLONE)
     clonedata.gcobjectptr = a2ref
     clonedata.pool = newpool
     llop.gc_x_clone(lltype.Void, clonedata)
     a2copyref = clonedata.gcobjectptr
     a2copy = lltype.cast_opaque_ptr(lltype.Ptr(A), a2copyref)
     a2copy.b.x = 444
     return a1.b.x * 1000000 + a2.b.x * 1000 + a3.b.x