[pypy-commit] pypy optresult: whack at some tests

fijal noreply at buildbot.pypy.org
Wed Jun 3 15:54:08 CEST 2015


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: optresult
Changeset: r77822:7b0a6633ec26
Date: 2015-06-03 15:54 +0200
http://bitbucket.org/pypy/pypy/changeset/7b0a6633ec26/

Log:	whack at some tests

diff --git a/rpython/jit/backend/test/runner_test.py b/rpython/jit/backend/test/runner_test.py
--- a/rpython/jit/backend/test/runner_test.py
+++ b/rpython/jit/backend/test/runner_test.py
@@ -1807,9 +1807,17 @@
         vtable_for_T = lltype.malloc(self.MY_VTABLE, immortal=True)
         vtable_for_T_addr = llmemory.cast_ptr_to_adr(vtable_for_T)
         cpu = self.cpu
-        if not hasattr(cpu, '_cache_gcstruct2vtable'):
-            cpu._cache_gcstruct2vtable = {}
-        cpu._cache_gcstruct2vtable.update({T: vtable_for_T})
+        class FakeGCCache(object):
+            pass
+        
+        if not hasattr(cpu.gc_ll_descr, '_cache_gcstruct2vtable'):
+            cpu.gc_ll_descr._cache_gcstruct2vtable = {}
+        cpu.gc_ll_descr._cache_gcstruct2vtable.update({T: vtable_for_T})
+        p = T
+        while hasattr(p, 'parent'):
+            vtable_for_parent = lltype.malloc(self.MY_VTABLE, immortal=True)
+            cpu.gc_ll_descr._cache_gcstruct2vtable[p.parent] = vtable_for_parent
+            p = p.parent
         t = lltype.malloc(T)
         if T == self.T:
             t.parent.parent.typeptr = vtable_for_T
@@ -1817,7 +1825,10 @@
             t.parent.parent.parent.typeptr = vtable_for_T
         t_box = InputArgRef(lltype.cast_opaque_ptr(llmemory.GCREF, t))
         T_box = ConstInt(heaptracker.adr2int(vtable_for_T_addr))
-        descr = cpu.sizeof(T, True)
+        is_object = True
+        if not hasattr(T, 'parent'):
+            is_object = False
+        descr = cpu.sizeof(T, is_object)
         return t_box, T_box, descr
 
     def null_instance(self):
@@ -3405,6 +3416,7 @@
                                   ('value', lltype.Signed),
                                   ('chr1', lltype.Char),
                                   ('chr2', lltype.Char))
+        self.alloc_instance(S)
         chr1 = self.cpu.fielddescrof(S, 'chr1').sort_key()
         value = self.cpu.fielddescrof(S, 'value').sort_key()
         chr2 = self.cpu.fielddescrof(S, 'chr2').sort_key()
diff --git a/rpython/jit/backend/x86/test/test_regalloc2.py b/rpython/jit/backend/x86/test/test_regalloc2.py
--- a/rpython/jit/backend/x86/test/test_regalloc2.py
+++ b/rpython/jit/backend/x86/test/test_regalloc2.py
@@ -1,6 +1,6 @@
-from rpython.jit.metainterp.history import ResOperation, BoxInt, ConstInt,\
+from rpython.jit.metainterp.history import ResOperation, ConstInt,\
      BasicFailDescr, JitCellToken, BasicFinalDescr, TargetToken, ConstPtr,\
-     BoxPtr, BoxFloat, ConstFloat
+     ConstFloat
 from rpython.jit.metainterp.resoperation import rop
 from rpython.jit.backend.detect_cpu import getcpuclass
 from rpython.jit.backend.x86.arch import WORD
@@ -15,11 +15,11 @@
 CPU = getcpuclass()
 
 def test_bug_rshift():
-    v1 = BoxInt()
-    v2 = BoxInt()
-    v3 = BoxInt()
-    v4 = BoxInt()
-    zero = BoxInt()
+    v1 = InputArgInt()
+    v2 = InputArgInt()
+    v3 = InputArgInt()
+    v4 = InputArgInt()
+    zero = InputArgInt()
     inputargs = [v1]
     operations = [
         ResOperation(rop.INT_ADD, [v1, v1], v2),
@@ -39,12 +39,12 @@
     assert cpu.get_int_value(deadframe, 1) == (~18)
 
 def test_bug_int_is_true_1():
-    v1 = BoxInt()
-    v2 = BoxInt()
-    v3 = BoxInt()
-    v4 = BoxInt()
-    zero = BoxInt()
-    tmp5 = BoxInt()
+    v1 = InputArgInt()
+    v2 = InputArgInt()
+    v3 = InputArgInt()
+    v4 = InputArgInt()
+    zero = InputArgInt()
+    tmp5 = InputArgInt()
     inputargs = [v1]
     operations = [
         ResOperation(rop.INT_MUL, [v1, v1], v2),
@@ -66,53 +66,53 @@
     assert cpu.get_int_value(deadframe, 2) == 1
 
 def test_bug_0():
-    v1 = BoxInt()
-    v2 = BoxInt()
-    v3 = BoxInt()
-    v4 = BoxInt()
-    v5 = BoxInt()
-    v6 = BoxInt()
-    v7 = BoxInt()
-    v8 = BoxInt()
-    v9 = BoxInt()
-    v10 = BoxInt()
-    v11 = BoxInt()
-    v12 = BoxInt()
-    v13 = BoxInt()
-    v14 = BoxInt()
-    v15 = BoxInt()
-    v16 = BoxInt()
-    v17 = BoxInt()
-    v18 = BoxInt()
-    v19 = BoxInt()
-    v20 = BoxInt()
-    v21 = BoxInt()
-    v22 = BoxInt()
-    v23 = BoxInt()
-    v24 = BoxInt()
-    v25 = BoxInt()
-    v26 = BoxInt()
-    v27 = BoxInt()
-    v28 = BoxInt()
-    v29 = BoxInt()
-    v30 = BoxInt()
-    v31 = BoxInt()
-    v32 = BoxInt()
-    v33 = BoxInt()
-    v34 = BoxInt()
-    v35 = BoxInt()
-    v36 = BoxInt()
-    v37 = BoxInt()
-    v38 = BoxInt()
-    v39 = BoxInt()
-    v40 = BoxInt()
-    zero = BoxInt()
-    tmp41 = BoxInt()
-    tmp42 = BoxInt()
-    tmp43 = BoxInt()
-    tmp44 = BoxInt()
-    tmp45 = BoxInt()
-    tmp46 = BoxInt()
+    v1 = InputArgInt()
+    v2 = InputArgInt()
+    v3 = InputArgInt()
+    v4 = InputArgInt()
+    v5 = InputArgInt()
+    v6 = InputArgInt()
+    v7 = InputArgInt()
+    v8 = InputArgInt()
+    v9 = InputArgInt()
+    v10 = InputArgInt()
+    v11 = InputArgInt()
+    v12 = InputArgInt()
+    v13 = InputArgInt()
+    v14 = InputArgInt()
+    v15 = InputArgInt()
+    v16 = InputArgInt()
+    v17 = InputArgInt()
+    v18 = InputArgInt()
+    v19 = InputArgInt()
+    v20 = InputArgInt()
+    v21 = InputArgInt()
+    v22 = InputArgInt()
+    v23 = InputArgInt()
+    v24 = InputArgInt()
+    v25 = InputArgInt()
+    v26 = InputArgInt()
+    v27 = InputArgInt()
+    v28 = InputArgInt()
+    v29 = InputArgInt()
+    v30 = InputArgInt()
+    v31 = InputArgInt()
+    v32 = InputArgInt()
+    v33 = InputArgInt()
+    v34 = InputArgInt()
+    v35 = InputArgInt()
+    v36 = InputArgInt()
+    v37 = InputArgInt()
+    v38 = InputArgInt()
+    v39 = InputArgInt()
+    v40 = InputArgInt()
+    zero = InputArgInt()
+    tmp41 = InputArgInt()
+    tmp42 = InputArgInt()
+    tmp43 = InputArgInt()
+    tmp44 = InputArgInt()
+    tmp45 = InputArgInt()
+    tmp46 = InputArgInt()
     inputargs = [v1, v2, v3, v4, v5, v6, v7, v8, v9, v10]
     operations = [
         ResOperation(rop.UINT_GT, [v3, ConstInt(-48)], v11),
@@ -179,52 +179,52 @@
     assert cpu.get_int_value(deadframe, 13) == 0
 
 def test_bug_1():
-    v1 = BoxInt()
-    v2 = BoxInt()
-    v3 = BoxInt()
-    v4 = BoxInt()
-    v5 = BoxInt()
-    v6 = BoxInt()
-    v7 = BoxInt()
-    v8 = BoxInt()
-    v9 = BoxInt()
-    v10 = BoxInt()
-    v11 = BoxInt()
-    v12 = BoxInt()
-    v13 = BoxInt()
-    v14 = BoxInt()
-    v15 = BoxInt()
-    v16 = BoxInt()
-    v17 = BoxInt()
-    v18 = BoxInt()
-    v19 = BoxInt()
-    v20 = BoxInt()
-    v21 = BoxInt()
-    v22 = BoxInt()
-    v23 = BoxInt()
-    v24 = BoxInt()
-    v25 = BoxInt()
-    v26 = BoxInt()
-    v27 = BoxInt()
-    v28 = BoxInt()
-    v29 = BoxInt()
-    v30 = BoxInt()
-    v31 = BoxInt()
-    v32 = BoxInt()
-    v33 = BoxInt()
-    v34 = BoxInt()
-    v35 = BoxInt()
-    v36 = BoxInt()
-    v37 = BoxInt()
-    v38 = BoxInt()
-    v39 = BoxInt()
-    v40 = BoxInt()
-    zero = BoxInt()
-    tmp41 = BoxInt()
-    tmp42 = BoxInt()
-    tmp43 = BoxInt()
-    tmp44 = BoxInt()
-    tmp45 = BoxInt()
+    v1 = InputArgInt()
+    v2 = InputArgInt()
+    v3 = InputArgInt()
+    v4 = InputArgInt()
+    v5 = InputArgInt()
+    v6 = InputArgInt()
+    v7 = InputArgInt()
+    v8 = InputArgInt()
+    v9 = InputArgInt()
+    v10 = InputArgInt()
+    v11 = InputArgInt()
+    v12 = InputArgInt()
+    v13 = InputArgInt()
+    v14 = InputArgInt()
+    v15 = InputArgInt()
+    v16 = InputArgInt()
+    v17 = InputArgInt()
+    v18 = InputArgInt()
+    v19 = InputArgInt()
+    v20 = InputArgInt()
+    v21 = InputArgInt()
+    v22 = InputArgInt()
+    v23 = InputArgInt()
+    v24 = InputArgInt()
+    v25 = InputArgInt()
+    v26 = InputArgInt()
+    v27 = InputArgInt()
+    v28 = InputArgInt()
+    v29 = InputArgInt()
+    v30 = InputArgInt()
+    v31 = InputArgInt()
+    v32 = InputArgInt()
+    v33 = InputArgInt()
+    v34 = InputArgInt()
+    v35 = InputArgInt()
+    v36 = InputArgInt()
+    v37 = InputArgInt()
+    v38 = InputArgInt()
+    v39 = InputArgInt()
+    v40 = InputArgInt()
+    zero = InputArgInt()
+    tmp41 = InputArgInt()
+    tmp42 = InputArgInt()
+    tmp43 = InputArgInt()
+    tmp44 = InputArgInt()
+    tmp45 = InputArgInt()
     inputargs = [v1, v2, v3, v4, v5, v6, v7, v8, v9, v10]
     operations = [
         ResOperation(rop.UINT_LT, [v6, ConstInt(0)], v11),
@@ -347,20 +347,20 @@
 
     S4 = lltype.Struct('Sx', ("f0", lltype.Char), ("f1", lltype.Signed), ("f2", lltype.Signed), ("f3", lltype.Signed))
     S5 = lltype.GcArray(S4)
-    v1 = BoxInt()
-    v2 = BoxInt()
-    v3 = BoxInt()
-    v4 = BoxInt()
-    v5 = BoxInt()
-    v6 = BoxInt()
-    v7 = BoxInt()
-    v8 = BoxInt()
-    v9 = BoxInt()
-    v10 = BoxInt()
-    tmp11 = BoxInt()
-    tmp12 = BoxPtr()
+    v1 = InputArgInt()
+    v2 = InputArgInt()
+    v3 = InputArgInt()
+    v4 = InputArgInt()
+    v5 = InputArgInt()
+    v6 = InputArgInt()
+    v7 = InputArgInt()
+    v8 = InputArgInt()
+    v9 = InputArgInt()
+    v10 = InputArgInt()
+    tmp11 = InputArgInt()
+    tmp12 = InputArgRef()
     faildescr0 = BasicFailDescr()
-    tmp13 = BoxPtr()
+    tmp13 = InputArgRef()
     faildescr1 = BasicFailDescr()
     finishdescr2 = BasicFinalDescr()
     const_ptr14 = ConstPtr(lltype.cast_opaque_ptr(llmemory.GCREF, lltype.malloc(rstr.STR, 1)))
@@ -401,39 +401,39 @@
     S7 = lltype.GcStruct('Sx', ("parent", rclass.OBJECT), ("f0", lltype.Char))
     S8 = lltype.Struct('Sx', ("f0", lltype.Char), ("f1", lltype.Signed), ("f2", lltype.Signed), ("f3", lltype.Signed))
     S9 = lltype.GcArray(S8)
-    v1 = BoxInt()
-    v2 = BoxInt()
-    v3 = BoxInt()
-    v4 = BoxInt()
-    v5 = BoxInt()
-    v6 = BoxInt()
-    v7 = BoxInt()
-    v8 = BoxInt()
-    v9 = BoxInt()
-    v10 = BoxInt()
-    v11 = BoxInt()
-    v12 = BoxInt()
-    v13 = BoxInt()
-    v14 = BoxInt()
-    v15 = BoxInt()
-    v16 = BoxInt()
-    v17 = BoxInt()
-    v18 = BoxInt()
-    v19 = BoxInt()
-    p20 = BoxPtr()
-    tmp21 = BoxPtr()
+    v1 = InputArgInt()
+    v2 = InputArgInt()
+    v3 = InputArgInt()
+    v4 = InputArgInt()
+    v5 = InputArgInt()
+    v6 = InputArgInt()
+    v7 = InputArgInt()
+    v8 = InputArgInt()
+    v9 = InputArgInt()
+    v10 = InputArgInt()
+    v11 = InputArgInt()
+    v12 = InputArgInt()
+    v13 = InputArgInt()
+    v14 = InputArgInt()
+    v15 = InputArgInt()
+    v16 = InputArgInt()
+    v17 = InputArgInt()
+    v18 = InputArgInt()
+    v19 = InputArgInt()
+    p20 = InputArgRef()
+    tmp21 = InputArgRef()
     faildescr3 = BasicFailDescr()
-    tmp22 = BoxPtr()
+    tmp22 = InputArgRef()
     faildescr4 = BasicFailDescr()
-    tmp23 = BoxInt()
-    tmp24 = BoxInt()
-    tmp25 = BoxInt()
-    tmp26 = BoxInt()
-    tmp27 = BoxInt()
-    tmp28 = BoxInt()
-    tmp29 = BoxInt()
+    tmp23 = InputArgInt()
+    tmp24 = InputArgInt()
+    tmp25 = InputArgInt()
+    tmp26 = InputArgInt()
+    tmp27 = InputArgInt()
+    tmp28 = InputArgInt()
+    tmp29 = InputArgInt()
     faildescr5 = BasicFailDescr()
-    tmp30 = BoxPtr()
+    tmp30 = InputArgRef()
     faildescr6 = BasicFailDescr()
     finishdescr7 = BasicFinalDescr()
     const_ptr31 = ConstPtr(lltype.cast_opaque_ptr(llmemory.GCREF, lltype.malloc(S4)))
@@ -508,36 +508,36 @@
     S4 = lltype.GcStruct('Sx', ("parent", rclass.OBJECT), ("f0", lltype.Signed), ("f1", lltype.Signed))
     S5 = lltype.GcStruct('Sx', ("parent", rclass.OBJECT), ("f0", lltype.Signed))
     S6 = lltype.GcStruct('Sx', ("f0", lltype.Signed), ("f1", rffi.UCHAR))
-    v1 = BoxInt()
-    v2 = BoxInt()
-    v3 = BoxInt()
-    v4 = BoxInt()
-    v5 = BoxInt()
-    v6 = BoxInt()
-    v7 = BoxInt()
-    v8 = BoxInt()
-    v9 = BoxInt()
-    v10 = BoxInt()
-    v11 = BoxInt()
-    v12 = BoxInt()
-    v13 = BoxInt()
-    v14 = BoxInt()
-    v15 = BoxInt()
-    v16 = BoxInt()
-    v17 = BoxInt()
-    v18 = BoxInt()
-    tmp19 = BoxPtr()
+    v1 = InputArgInt()
+    v2 = InputArgInt()
+    v3 = InputArgInt()
+    v4 = InputArgInt()
+    v5 = InputArgInt()
+    v6 = InputArgInt()
+    v7 = InputArgInt()
+    v8 = InputArgInt()
+    v9 = InputArgInt()
+    v10 = InputArgInt()
+    v11 = InputArgInt()
+    v12 = InputArgInt()
+    v13 = InputArgInt()
+    v14 = InputArgInt()
+    v15 = InputArgInt()
+    v16 = InputArgInt()
+    v17 = InputArgInt()
+    v18 = InputArgInt()
+    tmp19 = InputArgRef()
     faildescr8 = BasicFailDescr()
-    tmp20 = BoxInt()
-    tmp21 = BoxInt()
-    tmp22 = BoxInt()
-    tmp23 = BoxInt()
+    tmp20 = InputArgInt()
+    tmp21 = InputArgInt()
+    tmp22 = InputArgInt()
+    tmp23 = InputArgInt()
     faildescr9 = BasicFailDescr()
-    tmp24 = BoxInt()
-    tmp25 = BoxInt()
-    tmp26 = BoxInt()
-    tmp27 = BoxPtr()
-    tmp28 = BoxPtr()
+    tmp24 = InputArgInt()
+    tmp25 = InputArgInt()
+    tmp26 = InputArgInt()
+    tmp27 = InputArgRef()
+    tmp28 = InputArgRef()
     faildescr10 = BasicFailDescr()
     finishdescr11 = BasicFinalDescr()
     const_ptr29 = ConstPtr(lltype.cast_opaque_ptr(llmemory.GCREF, lltype.malloc(S4)))
@@ -587,11 +587,11 @@
     cpu.compile_bridge(faildescr6, inputargs, operations, looptoken)
     frame = cpu.execute_token(looptoken, *loop_args)
     #assert cpu.get_int_value(frame, 0) == -9223372036854775808
-    v1 = BoxInt()
-    v2 = BoxInt()
-    p3 = BoxPtr()
-    tmp4 = BoxInt()
-    tmp5 = BoxPtr()
+    v1 = InputArgInt()
+    v2 = InputArgInt()
+    p3 = InputArgRef()
+    tmp4 = InputArgInt()
+    tmp5 = InputArgRef()
     faildescr12 = BasicFailDescr()
     finishdescr13 = BasicFinalDescr()
     inputargs = [v1]
diff --git a/rpython/jit/backend/x86/test/test_runner.py b/rpython/jit/backend/x86/test/test_runner.py
--- a/rpython/jit/backend/x86/test/test_runner.py
+++ b/rpython/jit/backend/x86/test/test_runner.py
@@ -55,8 +55,8 @@
 
     def test_execute_ptr_operation(self):
         cpu = self.cpu
-        u = lltype.malloc(U)
-        u_box = InputArgRef(lltype.cast_opaque_ptr(llmemory.GCREF, u))
+        u_box, _, _ = self.alloc_instance(U)
+        u = u_box.getref(lltype.Ptr(U))
         ofs = cpu.fielddescrof(S, 'value')
         assert self.execute_operation(rop.SETFIELD_GC,
                                       [u_box, InputArgInt(3)],
diff --git a/rpython/jit/codewriter/heaptracker.py b/rpython/jit/codewriter/heaptracker.py
--- a/rpython/jit/codewriter/heaptracker.py
+++ b/rpython/jit/codewriter/heaptracker.py
@@ -65,7 +65,7 @@
         return None
     setup_cache_gcstruct2vtable(gccache)
     if not hasattr(gccache, '_cache_gcstruct2vtable'):
-        return GCSTRUCT.typeptr
+        return lltype.malloc(GCSTRUCT.typeptr.TO, flavor='raw', immortal=True)
     return gccache._cache_gcstruct2vtable[GCSTRUCT]
 
 def setup_cache_gcstruct2vtable(gccache):
diff --git a/rpython/jit/metainterp/optimizeopt/info.py b/rpython/jit/metainterp/optimizeopt/info.py
--- a/rpython/jit/metainterp/optimizeopt/info.py
+++ b/rpython/jit/metainterp/optimizeopt/info.py
@@ -348,7 +348,10 @@
         self._items = [None] * (size * lgt)
 
     def _compute_index(self, index, fielddescr):
-        one_size = len(fielddescr.get_arraydescr().get_all_fielddescrs())
+        all_fdescrs = fielddescr.get_arraydescr().get_all_fielddescrs()
+        if all_fdescrs is None:
+            return 0 # annotation hack
+        one_size = len(all_fdescrs)
         return index * one_size + fielddescr.fielddescr.get_index()
         
     def setinteriorfield_virtual(self, index, fielddescr, fld):
diff --git a/rpython/jit/metainterp/optimizeopt/rawbuffer.py b/rpython/jit/metainterp/optimizeopt/rawbuffer.py
--- a/rpython/jit/metainterp/optimizeopt/rawbuffer.py
+++ b/rpython/jit/metainterp/optimizeopt/rawbuffer.py
@@ -44,10 +44,10 @@
         if not we_are_translated() and isinstance(value, str):
             return value # for tests
         if self.logops:
-            s = self.logops.repr_of_arg(value.box)
+            s = self.logops.repr_of_arg(value)
         else:
-            s = str(value.box)
-        s += " at %d" % compute_unique_id(value.box)
+            s = str(value)
+        s += " at %d" % compute_unique_id(value)
         return s
 
     def _dump_to_log(self):
diff --git a/rpython/jit/metainterp/optimizeopt/vstring.py b/rpython/jit/metainterp/optimizeopt/vstring.py
--- a/rpython/jit/metainterp/optimizeopt/vstring.py
+++ b/rpython/jit/metainterp/optimizeopt/vstring.py
@@ -250,7 +250,7 @@
         visitor.register_virtual_fields(instbox, boxes)
         opinfo = optimizer.getptrinfo(self.s)
         if opinfo and opinfo.is_virtual():
-            opinfo.visitor_walk_recursive(visitor)
+            opinfo.visitor_walk_recursive(self.s, visitor, optimizer)
 
     @specialize.argtype(1)
     def visitor_dispatch_virtual_type(self, visitor):


More information about the pypy-commit mailing list