[pypy-commit] pypy optresult: hack at tests for the first test_expand_xxx to pass

fijal noreply at buildbot.pypy.org
Sun Nov 23 09:35:35 CET 2014


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: optresult
Changeset: r74646:e40642f20836
Date: 2014-11-23 10:35 +0200
http://bitbucket.org/pypy/pypy/changeset/e40642f20836/

Log:	hack at tests for the first test_expand_xxx to pass

diff --git a/rpython/jit/metainterp/history.py b/rpython/jit/metainterp/history.py
--- a/rpython/jit/metainterp/history.py
+++ b/rpython/jit/metainterp/history.py
@@ -240,6 +240,8 @@
     def getint(self):
         return self.value
 
+    getvalue = getint
+
     def getaddr(self):
         return heaptracker.int2adr(self.value)
 
@@ -280,6 +282,8 @@
     def getfloatstorage(self):
         return self.value
 
+    getvalue = getfloatstorage
+
     def _get_hash_(self):
         return longlong.gethash(self.value)
 
@@ -322,6 +326,8 @@
     def getref_base(self):
         return self.value
 
+    getvalue = getref_base
+
     def getref(self, PTR):
         return lltype.cast_opaque_ptr(PTR, self.getref_base())
     getref._annspecialcase_ = 'specialize:arg(1)'
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
@@ -8,7 +8,8 @@
 from rpython.jit.metainterp.optimize import InvalidLoop
 from rpython.jit.metainterp.history import ConstInt, get_const_ptr_for_string
 from rpython.jit.metainterp import executor, compile, resume
-from rpython.jit.metainterp.resoperation import rop, ResOperation, InputArgInt
+from rpython.jit.metainterp.resoperation import rop, ResOperation, InputArgInt,\
+     OpHelpers
 from rpython.rlib.rarithmetic import LONG_BIT
 
 def test_store_final_boxes_in_guard():
@@ -2420,12 +2421,12 @@
             pfieldvar = match.group(3)
             pendingfields.append((pvar, pfieldname, pfieldvar))
         #
-        def _variables_equal(box, varname, strict):
+        def _variables_equal(value, varname, strict):
             if varname not in virtuals:
                 if strict:
                     assert box.same_box(oparse.getvar(varname))
                 else:
-                    assert box.value == oparse.getvar(varname).value
+                    assert value == oparse.getvar(varname).getvalue()
             else:
                 tag, resolved, fieldstext = virtuals[varname]
                 if tag[0] == 'virtual':
@@ -2469,8 +2470,8 @@
                 if tag[0] in ('virtual', 'vstruct'):
                     fieldname, fieldvalue = fieldtext.split('=')
                     fielddescr = self.namespace[fieldname.strip()]
-                    fieldbox = executor.execute(self.cpu, None,
-                                                rop.GETFIELD_GC,
+                    opnum = OpHelpers.getfield_for_descr(fielddescr)
+                    fieldval = executor.execute(self.cpu, None, opnum,
                                                 fielddescr,
                                                 resolved)
                 elif tag[0] == 'varray':
@@ -2481,7 +2482,7 @@
                                                 resolved, ConstInt(index))
                 else:
                     assert 0
-                _variables_equal(fieldbox, fieldvalue.strip(), strict=False)
+                _variables_equal(fieldval, fieldvalue.strip(), strict=False)
                 index += 1
 
     def check_expanded_fail_descr(self, expectedtext, guard_opnum):
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_util.py b/rpython/jit/metainterp/optimizeopt/test/test_util.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_util.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_util.py
@@ -77,7 +77,8 @@
     type_system = 'lltype'
 
     def get_class_of_box(self, box):
-        return box.getref(rclass.OBJECTPTR).typeptr
+        base = box.getref_base()
+        return lltype.cast_opaque_ptr(rclass.OBJECTPTR, base).typeptr
 
     node_vtable = lltype.malloc(OBJECT_VTABLE, immortal=True)
     node_vtable.name = rclass.alloc_array_name('node')
diff --git a/rpython/jit/metainterp/resoperation.py b/rpython/jit/metainterp/resoperation.py
--- a/rpython/jit/metainterp/resoperation.py
+++ b/rpython/jit/metainterp/resoperation.py
@@ -298,6 +298,8 @@
     def getint(self):
         return self._resint
 
+    getvalue = getint
+
     def setint(self, intval):
         self._resint = intval
 
@@ -317,6 +319,8 @@
     def getfloatstorage(self):
         return self._resfloat
 
+    getvalue = getfloatstorage
+
     def setfloatstorage(self, floatval):
         self._resfloat = floatval
 
@@ -336,6 +340,8 @@
     def getref_base(self):
         return self._resref
 
+    getvalue = getref_base
+
     def setref_base(self, refval):
         self._resref = refval
 
@@ -912,6 +918,14 @@
         return rop.GETFIELD_GC_PURE_I
 
     @staticmethod
+    def getfield_for_descr(descr):
+        if descr.is_pointer_field():
+            return rop.GETFIELD_GC_R
+        elif descr.is_float_field():
+            return rop.GETFIELD_GC_F
+        return rop.GETFIELD_GC_I
+
+    @staticmethod
     def getarrayitem_pure_for_descr(descr):
         if descr.is_array_of_pointers():
             return rop.GETARRAYITEM_GC_PURE_R
diff --git a/rpython/jit/metainterp/resume.py b/rpython/jit/metainterp/resume.py
--- a/rpython/jit/metainterp/resume.py
+++ b/rpython/jit/metainterp/resume.py
@@ -1142,9 +1142,9 @@
                 box = self.consts[num]
         elif tag == TAGVIRTUAL:
             if kind == INT:
-                box = InputArgInt(self.getvirtual_int(num))
+                box = self.getvirtual_int(num)
             else:
-                box = InputArgRef(self.getvirtual_ptr(num))
+                box = self.getvirtual_ptr(num)
         elif tag == TAGINT:
             box = ConstInt(num)
         else:
diff --git a/rpython/jit/metainterp/test/test_resume.py b/rpython/jit/metainterp/test/test_resume.py
--- a/rpython/jit/metainterp/test/test_resume.py
+++ b/rpython/jit/metainterp/test/test_resume.py
@@ -11,6 +11,7 @@
 from rpython.jit.metainterp.optimizeopt.test.test_util import LLtypeMixin
 from rpython.jit.metainterp import executor
 from rpython.jit.codewriter import heaptracker, longlong
+from rpython.jit.metainterp.resoperation import ResOperation
 
 class Storage:
     rd_frame_info_list = None
@@ -144,7 +145,6 @@
         self.cpu = cpu
         self.trace = []
         self.framestack = []
-        self.resboxes = []
 
     def newframe(self, jitcode):
         frame = FakeFrame(jitcode, -1)
@@ -152,14 +152,11 @@
         return frame    
 
     def execute_and_record(self, opnum, descr, *argboxes):
-        resbox = executor.execute(self.cpu, None, opnum, descr, *argboxes)
-        self.trace.append((opnum,
-                           list(argboxes),
-                           resbox,
-                           descr))
-        if resbox is not None:
-            self.resboxes.append(resbox)
-        return resbox
+        resvalue = executor.execute(self.cpu, None, opnum, descr, *argboxes)
+        op = ResOperation(opnum, list(argboxes), descr)
+        op.setvalue(resvalue)
+        self.trace.append(op)
+        return op
 
     def execute_new_with_vtable(self, known_class):
         return self.execute_and_record(rop.NEW_WITH_VTABLE, None,


More information about the pypy-commit mailing list