Author: Carl Friedrich Bolz <[email protected]>
Branch: typed-cells
Changeset: r75473:0e13cfc290da
Date: 2015-01-22 00:44 +0100
http://bitbucket.org/pypy/pypy/changeset/0e13cfc290da/
Log: update test_pypy_c
diff --git a/pypy/module/pypyjit/test_pypy_c/test_instance.py
b/pypy/module/pypyjit/test_pypy_c/test_instance.py
--- a/pypy/module/pypyjit/test_pypy_c/test_instance.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_instance.py
@@ -83,7 +83,7 @@
loops = log.loops_by_filename(self.filepath)
assert len(loops) == 1
- def test_mutate_class(self):
+ def test_mutate_class_int(self):
def fn(n):
class A(object):
count = 1
@@ -106,7 +106,7 @@
entry_bridge, = log.loops_by_filename(self.filepath,
is_entry_bridge=True)
ops = entry_bridge.ops_by_id('mutate', opcode='LOAD_ATTR')
assert log.opnames(ops) == ['guard_value', 'guard_not_invalidated',
- 'getfield_gc', 'guard_nonnull_class']
+ 'getfield_gc']
# the STORE_ATTR is folded away
assert list(entry_bridge.ops_by_id('meth1', opcode='STORE_ATTR')) == []
#
@@ -114,19 +114,77 @@
# ----------------------
loop, = log.loops_by_filename(self.filepath)
assert loop.match("""
- i8 = getfield_gc_pure(p5, descr=...)
- i9 = int_lt(i8, i7)
- guard_true(i9, descr=.*)
- guard_not_invalidated(descr=.*)
- i82 = getfield_gc_pure(p8, descr=...)
- i11 = int_add_ovf(i82, 1)
+ i58 = int_lt(i38, i31)
+ guard_true(i58, descr=...)
+ guard_not_invalidated(descr=...)
+ i59 = int_add_ovf(i57, 1)
guard_no_overflow(descr=...)
- i12 = force_token()
- --TICK--
- p20 = new_with_vtable(ConstClass(W_IntObject))
- setfield_gc(p20, i11, descr=<FieldS.*W_IntObject.inst_intval .*>)
- setfield_gc(ConstPtr(ptr21), p20, descr=<FieldP
.*TypeCell.inst_w_value .*>)
- jump(..., descr=...)
+ p60 = force_token()
+ i61 = getfield_raw(..., descr=...)
+ setfield_gc(ConstPtr(ptr39), i59, descr=...)
+ i62 = int_lt(i61, 0)
+ guard_false(i62, descr=...)
+ jump(p0, p1, p3, p6, p7, p12, i59, p18, i31, i59, descr=...)
+ """)
+
+ def test_mutate_class(self):
+ def fn(n):
+ class LL(object):
+ def __init__(self, n):
+ self.n = n
+ class A(object):
+ count = None
+ def __init__(self, a):
+ self.a = a
+ def f(self):
+ return self.count
+ i = 0
+ a = A(1)
+ while i < n:
+ A.count = LL(A.count) # ID: mutate
+ a.f() # ID: meth1
+ i += 1
+ return i
+ #
+ log = self.run(fn, [1000], threshold=10)
+ assert log.result == 1000
+ #
+ # first, we test the entry bridge
+ # -------------------------------
+ entry_bridge, = log.loops_by_filename(self.filepath,
is_entry_bridge=True)
+ ops = entry_bridge.ops_by_id('mutate', opcode='LOAD_ATTR')
+ assert log.opnames(ops) == ['guard_value', 'guard_not_invalidated',
+ 'getfield_gc', 'guard_nonnull_class',
+ 'getfield_gc', 'guard_value', # type check
on the attribute
+ ]
+ # the STORE_ATTR is folded away
+ assert list(entry_bridge.ops_by_id('meth1', opcode='STORE_ATTR')) == []
+ #
+ # then, the actual loop
+ # ----------------------
+ loop, = log.loops_by_filename(self.filepath)
+ assert loop.match("""
+ i70 = int_lt(i58, i33)
+ guard_true(i70, descr=...)
+ guard_not_invalidated(descr=...)
+ p71 = getfield_gc(p64, descr=...)
+ guard_value(p71, ConstPtr(ptr42), descr=...)
+ p72 = force_token()
+ p73 = force_token()
+ i74 = int_add(i58, 1)
+ i75 = getfield_raw(..., descr=...)
+ i76 = int_lt(i75, 0)
+ guard_false(i76, descr=...)
+ p77 = new_with_vtable(...)
+ setfield_gc(p77, p64, descr=...)
+ setfield_gc(p77, ConstPtr(null), descr=...)
+ setfield_gc(p77, ConstPtr(null), descr=...)
+ setfield_gc(p77, ConstPtr(null), descr=...)
+ setfield_gc(p77, ConstPtr(null), descr=...)
+ setfield_gc(p77, ConstPtr(ptr42), descr=...)
+ setfield_gc(ConstPtr(ptr69), p77, descr=...)
+ jump(p0, p1, p3, p6, p7, p12, i74, p20, p26, i33, p77, descr=...)
+
""")
def test_oldstyle_newstyle_mix(self):
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -407,6 +407,7 @@
w_class, w_value = tup_w
if (space.config.objspace.std.withtypeversion and
isinstance(w_value, MutableCell)):
+ import pdb; pdb.set_trace()
return w_class, w_value.unwrap_cell(space)
return tup_w # don't make a new tuple, reuse the old one
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit