Commits

Armin Rigo  committed 23b55c5

fixfixfix

  • Participants
  • Parent commits d8d8425
  • Branches no-failargs

Comments (0)

Files changed (4)

File pypy/jit/backend/test/runner_test.py

         elif result_type == 'ref':
             result = lltype.nullptr(llmemory.GCREF.TO)
         elif result_type == 'float' or result_type == 'longlong':
-            result = 0.0
+            result = longlong.ZEROF
         else:
             raise ValueError(result_type)
         op0 = create_resop_dispatch(opnum, result, valueboxes,
         if descr is not None:
             op0.setdescr(descr)
         inputargs = [box for box in valueboxes if not box.is_constant()]
+        inputargs = list(set(inputargs))
         return inputargs, [op0, op1]
 
+    def _duplicate_boxes(self, inputargs):
+        seen = {}
+        for box in inputargs:
+            if box not in seen:
+                seen[box] = create_resop_0(box.opnum, box.constbox().value,
+                                           mutable=True)
+        return [seen[box] for box in inputargs]
+
 class BaseBackendTest(Runner):
 
     avoid_instances = False
                 else:
                     x = r.random()
                     operations.append(
-                        create_resop_2(rop.FLOAT_ADD, 0.0, inputargs[k],
+                        create_resop_2(rop.FLOAT_ADD,
+                                       longlong.ZEROF, inputargs[k],
                                        constfloat(x))
                         )
                     y = longlong.getrealfloat(values[k]) + x
                 op0 = create_resop_1(opname, 0, box)
                 op1 = create_resop_1(opguard, None, op0, mutable=True)
                 op1.setdescr(faildescr1)
-                op1.setfailargs([])
                 op2 = create_resop(rop.FINISH, None, [], descr=faildescr2,
                                    mutable=True)
+                operations = [op0, op1, op2]
                 looptoken = JitCellToken()
-                self.cpu.compile_loop(inputargs, [op0, op1, op2], looptoken)
+                oparser.assign_all_varindices(inputargs + operations)
+                self.cpu.compile_loop(inputargs, operations, looptoken)
                 #
                 cpu = self.cpu
                 for value in [-42, 0, 1, 10]:
                     op0 = create_resop_2(opname, 0, ibox1, ibox2)
                     op1 = create_resop_1(opguard, None, op0, mutable=True)
                     op1.setdescr(faildescr1)
-                    op1.setfailargs([])
                     op2 = create_resop(rop.FINISH, None, [], descr=faildescr2,
                                        mutable=True)
                     operations = [op0, op1, op2]
+                    oparser.assign_all_varindices(inputargs + operations)
                     looptoken = JitCellToken()
                     self.cpu.compile_loop(inputargs, operations, looptoken)
                     #
                     op0 = create_resop_2(opname, 0, ibox1, ibox2)
                     op1 = create_resop_1(opguard, None, op0, descr=faildescr1,
                                          mutable=True)
-                    op1.setfailargs([])
                     op2 = create_resop(rop.FINISH, None, [], descr=faildescr2,
                                        mutable=True)
+                    operations = [op0, op1, op2]
                     looptoken = JitCellToken()
-                    self.cpu.compile_loop(inputargs, [op0, op1, op2], looptoken)
+                    oparser.assign_all_varindices(inputargs + operations)
+                    self.cpu.compile_loop(inputargs, operations, looptoken)
                     #
                     cpu = self.cpu
                     for test1 in [65, 42, 11, 0, 1]:
                     op0 = create_resop_2(opname, 0, fbox1, fbox2)
                     op1 = create_resop_1(opguard, None, op0, mutable=True)
                     op1.setdescr(faildescr1)
-                    op1.setfailargs([])
                     op2 = create_resop(rop.FINISH, None, [], descr=faildescr2,
                                        mutable=True)
                     operations = [op0, op1, op2]
                     looptoken = JitCellToken()
+                    oparser.assign_all_varindices(inputargs + operations)
                     self.cpu.compile_loop(inputargs, operations, looptoken)
                     #
                     cpu = self.cpu
             if rettype == 'int':
                 res = 0
             elif rettype == 'float':
-                res = 0.0
+                res = longlong.ZEROF
             else:
                 assert 0
             operations.append(create_resop_dispatch(opnum, res, boxargs,
         operations.append(create_resop(rop.FINISH, None, [],
                                        descr=faildescr, mutable=True))
         looptoken = JitCellToken()
+        oparser.assign_all_varindices(inputargs + operations)
         #
         self.cpu.compile_loop(inputargs, operations, looptoken)
         #
 
         def nan_and_infinity(opnum, realoperation, testcases):
             for testcase in testcases:
-                realvalues = [b.getfloat() for b in testcase]
+                testcase = self._duplicate_boxes(testcase)
+                realvalues = [x.getfloat() for x in testcase]
                 expected = realoperation(*realvalues)
                 if isinstance(expected, float):
                     expectedtype = 'float'
                 else:
                     expectedtype = 'int'
-                got = self.execute_operation(opnum, list(testcase),
-                                             expectedtype)
+                got = self.execute_operation(opnum, testcase, expectedtype)
                 if isnan(expected):
                     ok = isnan(got)
                 elif isinf(expected):
                 if not ok:
                     raise AssertionError("%s(%s): got %r, expected %r" % (
                         opname[opnum], ', '.join(map(repr, realvalues)),
-                        got.getfloat(), expected))
+                        got, expected))
                 # if we expect a boolean, also check the combination with
                 # a GUARD_TRUE or GUARD_FALSE
                 if isinstance(expected, bool):
                         op0 = create_resop_2(opnum, 0, *testcase)
                         op1 = create_resop_1(guard_opnum, None, op0,
                                              mutable=True)
-                        op1.setfailargs([])
                         op1.setdescr(BasicFailDescr(4))
                         op2 = create_resop(rop.FINISH, None, [],
                                            descr=BasicFailDescr(5),
                         looptoken = JitCellToken()
                         # Use "set" to unique-ify inputargs
                         unique_testcase_list = list(set(testcase))
+                        oparser.assign_all_varindices(unique_testcase_list +
+                                                      operations)
                         self.cpu.compile_loop(unique_testcase_list, operations,
                                               looptoken)
                         args = [box.getfloatstorage()

File pypy/jit/metainterp/resoperation.py

     type = FLOAT
 
     def __init__(self, floatval):
-        #assert isinstance(floatval, float)
-        # XXX not sure between float or float storage
+        assert lltype.typeOf(floatval) is longlong.FLOATSTORAGE
         self._floatval = floatval
 
     def getresultrepr(self):
     if opclasses[opnum].type == INT:
         return 0
     elif opclasses[opnum].type == FLOAT:
-        return 0.0
+        return longlong.ZEROF
     else:
         return lltype.nullptr(llmemory.GCREF.TO)
 

File pypy/jit/metainterp/test/support.py

 from pypy.jit.codewriter import codewriter, longlong
 from pypy.rlib.rfloat import isnan
 
-def boxfloat(x=None):
-    if x is None:
-        x = example_for_opnum(rop.INPUT_f)
+def boxfloat(x=0.0):
     return create_resop_0(rop.INPUT_f, longlong.getfloatstorage(x))
 
 def boxlonglong_on_32bit(x):

File pypy/jit/tool/oparser.py

                 raise Exception("unexpected var %s" % (arg,))
             return self.vars[arg]
 
-    def _example_for(self, opnum):
-        kind = opclasses[opnum].type
-        if kind == 'i':
-            return 0
-        elif kind == 'f':
-            return 0.0
-        elif kind == 'r':
-            return lltype.nullptr(llmemory.GCREF.TO)
-        else:
-            return None
-
     def parse_args(self, opname, argspec):
         args = []
         descr = None
         if res in self.vars:
             raise ParseError("Double assign to var %s in line: %s" % (res, line))
         if self.results is None:
-            result = self._example_for(opnum)
+            result = example_for_opnum(opnum)
         else:
             result = self.results[num]
         opres = self.create_op(opnum, result, args, descr)