Esempio n. 1
0
def dump_storage(storage, liveboxes):
    "For profiling only."
    from pypy.rlib.objectmodel import compute_unique_id
    debug_start("jit-resume")
    if have_debug_prints():
        debug_print('Log storage', compute_unique_id(storage))
        frameinfo = storage.rd_frame_info_list
        while frameinfo is not None:
            try:
                jitcodename = frameinfo.jitcode.name
            except AttributeError:
                jitcodename = str(compute_unique_id(frameinfo.jitcode))
            debug_print('\tjitcode/pc', jitcodename,
                        frameinfo.pc, frameinfo.exception_target,
                        'at', compute_unique_id(frameinfo))
            frameinfo = frameinfo.prev
        numb = storage.rd_numb
        while numb is not None:
            debug_print('\tnumb', str([untag(i) for i in numb.nums]),
                        'at', compute_unique_id(numb))
            numb = numb.prev
        for const in storage.rd_consts:
            debug_print('\tconst', const.repr_rpython())
        for box in liveboxes:
            if box is None:
                debug_print('\tbox', 'None')
            else:
                debug_print('\tbox', box.repr_rpython())
        if storage.rd_virtuals is not None:
            for virtual in storage.rd_virtuals:
                if virtual is None:
                    debug_print('\t\t', 'None')
                else:
                    virtual.debug_prints()
    debug_stop("jit-resume")
Esempio n. 2
0
def dump_storage(logname, storage, liveboxes):
    "For profiling only."
    import os
    from pypy.rlib import objectmodel
    assert logname is not None    # annotator hack
    fd = os.open(logname, os.O_WRONLY | os.O_APPEND | os.O_CREAT, 0666)
    os.write(fd, 'Log(%d, [\n' % objectmodel.compute_unique_id(storage))
    frameinfo = storage.rd_frame_info_list
    while True:
        os.write(fd, '\t("%s", %d, %d) at %xd,\n' % (
            frameinfo.jitcode, frameinfo.pc, frameinfo.exception_target,
            objectmodel.compute_unique_id(frameinfo)))
        frameinfo = frameinfo.prev
        if frameinfo is None:
            break
    os.write(fd, '\t],\n\t[\n')
    numb = storage.rd_numb
    while True:
        os.write(fd, '\t\t%s at %xd,\n' % ([untag(i) for i in numb.nums],
                                           objectmodel.compute_unique_id(numb)))
        numb = numb.prev
        if numb is None:
            break
    os.write(fd, '\t], [\n')
    for const in storage.rd_consts:
        os.write(fd, '\t"%s",\n' % (const.repr_rpython(),))
    os.write(fd, '\t], [\n')
    for box in liveboxes:
        os.write(fd, '\t"%s",\n' % (box.repr_rpython(),))
    os.write(fd, '\t], [\n')
    if storage.rd_virtuals is not None:
        for virtual in storage.rd_virtuals:
            os.write(fd, '\t%s,\n' % (virtual.repr_rpython(),))
    os.write(fd, '\t])\n')
    os.close(fd)
Esempio n. 3
0
 def run_once():
     a = A()
     ida = compute_unique_id(a)
     b = B()
     idb = compute_unique_id(b)
     c = C()
     idc = compute_unique_id(c)
     llop.gc__collect(lltype.Void)
     llop.gc__collect(lltype.Void)
     llop.gc__collect(lltype.Void)
     return ida, idb, idc
Esempio n. 4
0
 def run_once():
     a = A()
     ida = compute_unique_id(a)
     b = B()
     idb = compute_unique_id(b)
     c = C()
     idc = compute_unique_id(c)
     llop.gc__collect(lltype.Void)
     llop.gc__collect(lltype.Void)
     llop.gc__collect(lltype.Void)
     return ida, idb, idc
Esempio n. 5
0
 def fn(n):
     id_prebuilt1 = compute_unique_id(u.x)
     if n > 0:
         x = BoxedObject(n)
     else:
         x = UnboxedObject(n)
     id_x1 = compute_unique_id(x)
     rgc.collect() # check that a prebuilt tagged pointer doesn't explode
     id_prebuilt2 = compute_unique_id(u.x)
     id_x2 = compute_unique_id(x)
     print u.x, id_prebuilt1, id_prebuilt2
     print x, id_x1, id_x2
     return ((id_x1 == id_x2) * 1 +
             (id_prebuilt1 == id_prebuilt2) * 10 +
             (id_x1 != id_prebuilt1) * 100)
Esempio n. 6
0
 def fn(n):
     id_prebuilt1 = compute_unique_id(u.x)
     if n > 0:
         x = BoxedObject(n)
     else:
         x = UnboxedObject(n)
     id_x1 = compute_unique_id(x)
     rgc.collect() # check that a prebuilt tagged pointer doesn't explode
     id_prebuilt2 = compute_unique_id(u.x)
     id_x2 = compute_unique_id(x)
     print u.x, id_prebuilt1, id_prebuilt2
     print x, id_x1, id_x2
     return ((id_x1 == id_x2) * 1 +
             (id_prebuilt1 == id_prebuilt2) * 10 +
             (id_x1 != id_prebuilt1) * 100)
Esempio n. 7
0
 def f():
     from pypy.rpython.lltypesystem import lltype, rffi
     alist = [A() for i in range(50)]
     idarray = lltype.malloc(rffi.INTP.TO, len(alist), flavor='raw')
     # Compute the id of all the elements of the list.  The goal is
     # to not allocate memory, so that if the GC needs memory to
     # remember the ids, it will trigger some collections itself
     i = 0
     while i < len(alist):
         idarray[i] = compute_unique_id(alist[i])
         i += 1
     j = 0
     while j < 2:
         if j == 1:     # allocate some stuff between the two iterations
             [A() for i in range(20)]
         i = 0
         while i < len(alist):
             assert idarray[i] == compute_unique_id(alist[i])
             i += 1
         j += 1
     lltype.free(idarray, flavor='raw')
Esempio n. 8
0
 def f():
     from pypy.rpython.lltypesystem import lltype, rffi
     alist = [A() for i in range(50)]
     idarray = lltype.malloc(rffi.INTP.TO, len(alist), flavor='raw')
     # Compute the id of all the elements of the list.  The goal is
     # to not allocate memory, so that if the GC needs memory to
     # remember the ids, it will trigger some collections itself
     i = 0
     while i < len(alist):
         idarray[i] = compute_unique_id(alist[i])
         i += 1
     j = 0
     while j < 2:
         if j == 1:     # allocate some stuff between the two iterations
             [A() for i in range(20)]
         i = 0
         while i < len(alist):
             assert idarray[i] == compute_unique_id(alist[i])
             i += 1
         j += 1
     lltype.free(idarray, flavor='raw')
Esempio n. 9
0
 def fn():
     return (compute_unique_id("foo"),
             compute_unique_id(u"bar"),
             compute_unique_id([1]),
             compute_unique_id({"foo": 3}),
             compute_unique_id(StringBuilder()),
             compute_unique_id(UnicodeBuilder()))
Esempio n. 10
0
def cmp_standard_order(obj1, obj2, heap):
    c = rcmp(obj1.STANDARD_ORDER, obj2.STANDARD_ORDER)
    if c != 0:
        return c
    if isinstance(obj1, Var):
        assert isinstance(obj2, Var)
        return rcmp(compute_unique_id(obj1), compute_unique_id(obj2))
    if isinstance(obj1, Atom):
        assert isinstance(obj2, Atom)
        return rcmp(obj1.name, obj2.name)
    if isinstance(obj1, Term):
        assert isinstance(obj2, Term)
        c = rcmp(len(obj1.args), len(obj2.args))
        if c != 0:
            return c
        c = rcmp(obj1.name, obj2.name)
        if c != 0:
            return c
        for i in range(len(obj1.args)):
            a1 = obj1.args[i].dereference(heap)
            a2 = obj2.args[i].dereference(heap)
            c = cmp_standard_order(a1, a2, heap)
            if c != 0:
                return c
        return 0
    # XXX hum
    if isinstance(obj1, Number):
        if isinstance(obj2, Number):
            return rcmp(obj1.num, obj2.num)
        elif isinstance(obj2, Float):
            return rcmp(obj1.num, obj2.floatval)
    if isinstance(obj1, Float):
        if isinstance(obj2, Number):
            return rcmp(obj1.floatval, obj2.num)
        elif isinstance(obj2, Float):
            return rcmp(obj1.floatval, obj2.floatval)
    assert 0
Esempio n. 11
0
def cmp_standard_order(obj1, obj2, heap):
    c = rcmp(obj1.STANDARD_ORDER, obj2.STANDARD_ORDER)
    if c != 0:
        return c
    if isinstance(obj1, Var):
        assert isinstance(obj2, Var)
        return rcmp(compute_unique_id(obj1), compute_unique_id(obj2))
    if isinstance(obj1, Atom):
        assert isinstance(obj2, Atom)
        return rcmp(obj1.name, obj2.name)
    if isinstance(obj1, Term):
        assert isinstance(obj2, Term)
        c = rcmp(len(obj1.args), len(obj2.args))
        if c != 0:
            return c
        c = rcmp(obj1.name, obj2.name)
        if c != 0:
            return c
        for i in range(len(obj1.args)):
            a1 = obj1.args[i].dereference(heap)
            a2 = obj2.args[i].dereference(heap)
            c = cmp_standard_order(a1, a2, heap)
            if c != 0:
                return c
        return 0
    # XXX hum
    if isinstance(obj1, Number):
        if isinstance(obj2, Number):
            return rcmp(obj1.num, obj2.num)
        elif isinstance(obj2, Float):
            return rcmp(obj1.num, obj2.floatval)
    if isinstance(obj1, Float):
        if isinstance(obj2, Number):
            return rcmp(obj1.floatval, obj2.num)
        elif isinstance(obj2, Float):
            return rcmp(obj1.floatval, obj2.floatval)
    assert 0
Esempio n. 12
0
def dump_storage(storage, liveboxes):
    "For profiling only."
    from pypy.rlib.objectmodel import compute_unique_id
    debug_start("jit-resume")
    if have_debug_prints():
        debug_print('Log storage', compute_unique_id(storage))
        frameinfo = storage.rd_frame_info_list
        while frameinfo is not None:
            try:
                jitcodename = frameinfo.jitcode.name
            except AttributeError:
                jitcodename = str(compute_unique_id(frameinfo.jitcode))
            debug_print('\tjitcode/pc', jitcodename,
                        frameinfo.pc,
                        'at', compute_unique_id(frameinfo))
            frameinfo = frameinfo.prev
        numb = storage.rd_numb
        while numb:
            debug_print('\tnumb', str([untag(numb.nums[i])
                                       for i in range(len(numb.nums))]),
                        'at', compute_unique_id(numb))
            numb = numb.prev
        for const in storage.rd_consts:
            debug_print('\tconst', const.repr_rpython())
        for box in liveboxes:
            if box is None:
                debug_print('\tbox', 'None')
            else:
                debug_print('\tbox', box.repr_rpython())
        if storage.rd_virtuals is not None:
            for virtual in storage.rd_virtuals:
                if virtual is None:
                    debug_print('\t\t', 'None')
                else:
                    virtual.debug_prints()
    debug_stop("jit-resume")
Esempio n. 13
0
 def func():
     a2 = A()
     a3 = A()
     id1 = compute_unique_id(a1)
     id2 = compute_unique_id(a2)
     id3 = compute_unique_id(a3)
     llop.gc__collect(lltype.Void)
     error = 0
     if id1 != compute_unique_id(a1): error += 1
     if id2 != compute_unique_id(a2): error += 2
     if id3 != compute_unique_id(a3): error += 4
     return error
Esempio n. 14
0
 def externfn(node):
     llop.debug_print(lltype.Void, compute_unique_id(node),
                      node.value, node.extra)
     return node.value * 2
Esempio n. 15
0
 def fn():
     a1 = A()
     a2 = A()
     return (compute_unique_id(a1), current_object_addr_as_int(a1),
             compute_unique_id(a2), current_object_addr_as_int(a2))
Esempio n. 16
0
 def immutable_unique_id(self, space):
     if self.user_overridden_class:
         return None
     return space.wrap(compute_unique_id(space.unicode_w(self)))
Esempio n. 17
0
 def externalfn(n):
     if n > 1000:
         return compute_unique_id(exctx.topframeref())
     return 1
Esempio n. 18
0
 def method___id__(self, space):
     return space.newint(compute_unique_id(self))
Esempio n. 19
0
 def getids(i, j):
     e1 = ExampleClass(1)
     e2 = ExampleClass(2)
     a = [e1, e2][i]
     b = [e1, e2][j]
     return (compute_unique_id(a) == compute_unique_id(b)) == (a is b)
Esempio n. 20
0
 def method___id__(self, space):
     return space.newint(compute_unique_id(self))
Esempio n. 21
0
 def externfn(node):
     llop.debug_print(lltype.Void, compute_unique_id(node), node.value,
                      node.extra)
     return node.value * 2
Esempio n. 22
0
def repr_rpython(box, typechars):
    return '%s/%s%d' % (box._get_hash_(), typechars,
                        compute_unique_id(box))
Esempio n. 23
0
 def fn(s1, s2):
     return (compute_unique_id(s1), compute_unique_id(s2))
Esempio n. 24
0
def id__ANY(space, w_obj):
    # print 'id:', w_obj
    return space.wrap(objectmodel.compute_unique_id(w_obj))
Esempio n. 25
0
 def repr_of_descr(self):
     return 'TargetToken(%d)' % compute_unique_id(self)
Esempio n. 26
0
 def fn(s1, s2):
     return (compute_unique_id(s1), compute_unique_id(s2))
Esempio n. 27
0
 def repr_of_descr(self):
     return 'TargetToken(%d)' % compute_unique_id(self)
Esempio n. 28
0
 def externalfn(n):
     if n > 1000:
         return compute_unique_id(exctx.topframeref())
     return 1
Esempio n. 29
0
 def unique_id(self, space):
     if self.user_overridden_class:
         return W_Object.unique_id(self, space)
     return space.wrap(compute_unique_id(space.str_w(self)))
Esempio n. 30
0
def id__ANY(space, w_obj):
    #print 'id:', w_obj
    return space.wrap(objectmodel.compute_unique_id(w_obj))
Esempio n. 31
0
def repr_rpython(box, typechars):
    return '%s/%s%d' % (box._get_hash_(), typechars, compute_unique_id(box))
Esempio n. 32
0
 def fn():
     a1 = A()
     a2 = A()
     return (compute_unique_id(a1), current_object_addr_as_int(a1),
             compute_unique_id(a2), current_object_addr_as_int(a2))
Esempio n. 33
0
 def fn():
     return (compute_unique_id("foo"), compute_unique_id(u"bar"),
             compute_unique_id([1]), compute_unique_id({"foo": 3}),
             compute_unique_id(StringBuilder()),
             compute_unique_id(UnicodeBuilder()))