1. Gil Shwartz
  2. pypy

Commits

Maciej Fijalkowski  committed 314c3f8

port more of those tests

  • Participants
  • Parent commits 2c656fa
  • Branches result-in-resops

Comments (0)

Files changed (4)

File pypy/jit/backend/llgraph/llimpl.py

View file
 
     op_getarrayitem_raw_pure = op_getarrayitem_raw
 
-    def op_getfield_gc(self, fielddescr, struct):
-        if fielddescr.typeinfo == REF:
-            return do_getfield_gc_ptr(struct, fielddescr.ofs)
-        elif fielddescr.typeinfo == INT:
-            return do_getfield_gc_int(struct, fielddescr.ofs)
-        elif fielddescr.typeinfo == FLOAT:
-            return do_getfield_gc_float(struct, fielddescr.ofs)
-        else:
-            raise NotImplementedError
+    def op_getfield_gc_i(self, fielddescr, struct):
+        return do_getfield_gc_int(struct, fielddescr.ofs)
 
-    op_getfield_gc_pure = op_getfield_gc
+    def op_getfield_gc_f(self, fielddescr, struct):
+        return do_getfield_gc_float(struct, fielddescr.ofs)
+
+    def op_getfield_gc_p(self, fielddescr, struct):
+        return do_getfield_gc_ptr(struct, fielddescr.ofs)
+
+    op_getfield_gc_pure_i = op_getfield_gc_i
+    op_getfield_gc_pure_f = op_getfield_gc_f
+    op_getfield_gc_pure_p = op_getfield_gc_p
 
     def op_getfield_raw(self, fielddescr, struct):
         if fielddescr.typeinfo == REF:
 
     def op_call_i(self, calldescr, func, *args):
         return self._do_call(calldescr, func, args, call_with_llptr=False)
+    op_call_f = op_call_i
+    op_call_N = op_call_i
+    op_call_p = op_call_i
 
     def op_call_release_gil(self, calldescr, func, *args):
         return self._do_call(calldescr, func, args, call_with_llptr=True)

File pypy/jit/backend/llgraph/runner.py

View file
         try:
             for arg in cif_description.atypes:
                 kind = get_ffi_type_kind(self, arg)
-                if kind != history.VOID:
+                if kind != resoperation.VOID:
                     arg_types.append(kind)
             reskind = get_ffi_type_kind(self, cif_description.rtype)
         except UnsupportedKind:

File pypy/jit/backend/llsupport/descr.py

View file
 from pypy.rpython.lltypesystem import lltype, rffi, llmemory
 from pypy.rpython.lltypesystem.lloperation import llop
 from pypy.jit.backend.llsupport import symbolic, support
-from pypy.jit.metainterp.history import AbstractDescr, getkind
-from pypy.jit.metainterp import history
+from pypy.jit.metainterp.history import AbstractDescr
+from pypy.jit.metainterp.resoperation import getkind
+from pypy.jit.metainterp import resoperation
 from pypy.jit.codewriter import heaptracker, longlong
 from pypy.jit.codewriter.longlong import is_longlong
 
                 result_flag = FLAG_SIGNED
             else:
                 result_flag = FLAG_UNSIGNED
-        elif result_type == history.REF:
+        elif result_type == resoperation.REF:
             result_flag = FLAG_POINTER
-        elif result_type == history.FLOAT or result_type == 'L':
+        elif result_type == resoperation.FLOAT or result_type == 'L':
             result_flag = FLAG_FLOAT
         elif result_type == 'S':
             result_flag = FLAG_UNSIGNED
         args = ", ".join([process(c) for c in self.arg_classes])
 
         result_type = self.get_result_type()
-        if result_type == history.INT:
+        if result_type == resoperation.INT:
             result = 'rffi.cast(lltype.Signed, res)'
             category = 'i'
-        elif result_type == history.REF:
+        elif result_type == resoperation.REF:
             assert RESULT == llmemory.GCREF   # should be ensured by the caller
             result = 'lltype.cast_opaque_ptr(llmemory.GCREF, res)'
             category = 'r'
-        elif result_type == history.FLOAT:
+        elif result_type == resoperation.FLOAT:
             result = 'longlong.getfloatstorage(res)'
             category = 'f'
         elif result_type == 'L':
             result = 'rffi.cast(lltype.SignedLongLong, res)'
             category = 'f'
-        elif result_type == history.VOID:
+        elif result_type == resoperation.VOID:
             result = '0'
             category = 'i'
         elif result_type == 'S':

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

View file
         else:
             self.guard_failed = True
         if result_type == 'int':
-            return BoxInt(self.cpu.get_latest_value_int(0))
+            return self.cpu.get_latest_value_int(0)
         elif result_type == 'ref':
-            return BoxPtr(self.cpu.get_latest_value_ref(0))
+            return self.cpu.get_latest_value_ref(0)
         elif result_type == 'float':
-            return BoxFloat(self.cpu.get_latest_value_float(0))
+            return self.cpu.get_latest_value_float(0)
         elif result_type == 'void':
             return None
         else:
         elif result_type == 'int':
             result = 0
         elif result_type == 'ref':
-            result = lltype.nullptr(llmemory.GCREF)
+            result = lltype.nullptr(llmemory.GCREF.TO)
         elif result_type == 'float':
             result = 0.0
         else:
             results = [op0]
         op1 = create_resop(rop.FINISH, None, results, descr=BasicFailDescr(0))
         if op0.is_guard():
-            op0.setfailargs([])
+            op0.set_extra("failargs", [])
             if not descr:
                 descr = BasicFailDescr(1)
         if descr is not None:
         from pypy.jit.metainterp.test.test_executor import get_int_tests
         for opnum, boxargs, retvalue in get_int_tests():
             res = self.execute_operation(opnum, boxargs, 'int')
-            assert res.value == retvalue
+            assert res == retvalue
 
     def test_float_operations(self):
         from pypy.jit.metainterp.test.test_executor import get_float_tests
         for opnum, boxargs, rettype, retvalue in get_float_tests(self.cpu):
             res = self.execute_operation(opnum, boxargs, rettype)
-            if isinstance(res, BoxFloat):
-                assert res.getfloat() == retvalue
-            else:
-                assert res.value == retvalue
+            assert res == retvalue
 
     def test_ovf_operations(self, reversed=False):
         minint = -sys.maxint-1
             res = self.execute_operation(rop.CALL_i,
                                          [funcbox, BoxInt(num), BoxInt(num)],
                                          'int', descr=calldescr)
-            assert res.value == 2 * num
+            assert res == 2 * num
             # then, try it with the dynamic calldescr
             dyn_calldescr = cpu._calldescr_dynamic_for_tests(
                 [ffi_type, ffi_type], ffi_type)
-            res = self.execute_operation(rop.CALL,
+            res = self.execute_operation(rop.CALL_i,
                                          [funcbox, BoxInt(num), BoxInt(num)],
                                          'int', descr=dyn_calldescr)
-            assert res.value == 2 * num
+            assert res == 2 * num
 
 
         if cpu.supports_floats:
             args = ([boxfloat(.1) for i in range(7)] +
                     [BoxInt(1), BoxInt(2), boxfloat(.2), boxfloat(.3),
                      boxfloat(.4)])
-            res = self.execute_operation(rop.CALL,
+            res = self.execute_operation(rop.CALL_f,
                                          [funcbox] + args,
                                          'float', descr=calldescr)
-            assert abs(res.getfloat() - 4.6) < 0.0001
+            assert abs(res - 4.6) < 0.0001
 
     def test_call_many_arguments(self):
         # Test calling a function with a large number of arguments (more than
         func_ptr = llhelper(FPTR, func)
         args = range(16)
         funcbox = self.get_funcbox(self.cpu, func_ptr)
-        res = self.execute_operation(rop.CALL, [funcbox] + map(BoxInt, args), 'int', descr=calldescr)
-        assert res.value == func(*args)
+        res = self.execute_operation(rop.CALL_i, [funcbox] + map(BoxInt, args), 'int', descr=calldescr)
+        assert res == func(*args)
 
     def test_call_box_func(self):
         def a(a1, a2):
             funcbox = funcconst.clonebox()
             calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
                                         EffectInfo.MOST_GENERAL)
-            res = self.execute_operation(rop.CALL,
+            res = self.execute_operation(rop.CALL_i,
                                          [funcbox, BoxInt(arg1), BoxInt(arg2)],
                                          'int', descr=calldescr)
-            assert res.getint() == f(arg1, arg2)
+            assert res == f(arg1, arg2)
 
     def test_call_stack_alignment(self):
         # test stack alignment issues, notably for Mac OS/X.
                                         EffectInfo.MOST_GENERAL)
             funcbox = self.get_funcbox(cpu, func_ptr)
             args = [280-24*i for i in range(nb_args)]
-            res = self.execute_operation(rop.CALL,
+            res = self.execute_operation(rop.CALL_i,
                                          [funcbox] + map(BoxInt, args),
                                          'int', descr=calldescr)
-            assert res.value == func_ints(*args)
+            assert res == func_ints(*args)
 
     def test_call_with_const_floats(self):
         def func(f1, f2):
                                          EffectInfo.MOST_GENERAL)
         func_ptr = llhelper(FPTR, func)
         funcbox = self.get_funcbox(self.cpu, func_ptr)
-        res = self.execute_operation(rop.CALL, [funcbox, constfloat(1.5),
+        res = self.execute_operation(rop.CALL_f, [funcbox, constfloat(1.5),
                                                 constfloat(2.5)], 'float',
                                      descr=calldescr)
-        assert res.getfloat() == 4.0
+        assert res == 4.0
 
 
     def test_field_basic(self):
         res = self.execute_operation(rop.SETFIELD_GC, [t_box, BoxInt(39082)],
                                      'void', descr=fielddescr)
         assert res is None
-        res = self.execute_operation(rop.GETFIELD_GC, [t_box],
+        res = self.execute_operation(rop.GETFIELD_GC_i, [t_box],
                                      'int', descr=fielddescr)
-        assert res.value == 39082
+        assert res == 39082
         #
         fielddescr1 = self.cpu.fielddescrof(self.S, 'chr1')
         fielddescr2 = self.cpu.fielddescrof(self.S, 'chr2')
                                'void', descr=fielddescr1)
         self.execute_operation(rop.SETFIELD_GC, [t_box, BoxInt(1331)],
                                'void', descr=shortdescr)
-        res = self.execute_operation(rop.GETFIELD_GC, [t_box],
+        res = self.execute_operation(rop.GETFIELD_GC_i, [t_box],
                                      'int', descr=fielddescr2)
-        assert res.value == 250
-        res = self.execute_operation(rop.GETFIELD_GC, [t_box],
+        assert res == 250
+        res = self.execute_operation(rop.GETFIELD_GC_i, [t_box],
                                      'int', descr=fielddescr1)
-        assert res.value == 133
-        res = self.execute_operation(rop.GETFIELD_GC, [t_box],
+        assert res == 133
+        res = self.execute_operation(rop.GETFIELD_GC_i, [t_box],
                                      'int', descr=shortdescr)
-        assert res.value == 1331
+        assert res == 1331
 
         #
         u_box, U_box = self.alloc_instance(self.U)
         res = self.execute_operation(rop.SETFIELD_GC, [t_box, u_box],
                                      'void', descr=fielddescr2)
         assert res is None
-        res = self.execute_operation(rop.GETFIELD_GC, [t_box],
+        res = self.execute_operation(rop.GETFIELD_GC_p, [t_box],
                                      'ref', descr=fielddescr2)
-        assert res.value == u_box.value
+        assert res == u_box.value
         #
         null_const = self.null_instance().constbox()
         res = self.execute_operation(rop.SETFIELD_GC, [t_box, null_const],
                                      'void', descr=fielddescr2)
         assert res is None
-        res = self.execute_operation(rop.GETFIELD_GC, [t_box],
+        res = self.execute_operation(rop.GETFIELD_GC_p, [t_box],
                                      'ref', descr=fielddescr2)
-        assert res.value == null_const.value
+        assert res == null_const.value
         if self.cpu.supports_floats:
             floatdescr = self.cpu.fielddescrof(self.S, 'float')
             self.execute_operation(rop.SETFIELD_GC, [t_box, boxfloat(3.4)],
                                    'void', descr=floatdescr)
-            res = self.execute_operation(rop.GETFIELD_GC, [t_box],
+            res = self.execute_operation(rop.GETFIELD_GC_f, [t_box],
                                          'float', descr=floatdescr)
-            assert res.getfloat() == 3.4
+            assert res == 3.4
             #
             self.execute_operation(rop.SETFIELD_GC, [t_box, constfloat(-3.6)],
                                    'void', descr=floatdescr)
-            res = self.execute_operation(rop.GETFIELD_GC, [t_box],
+            res = self.execute_operation(rop.GETFIELD_GC_f, [t_box],
                                          'float', descr=floatdescr)
-            assert res.getfloat() == -3.6
+            assert res == -3.6
 
 
     def test_passing_guards(self):
         u2_box, U_box = self.alloc_instance(self.U)
         r = self.execute_operation(rop.PTR_EQ, [u1_box,
                                                 u1_box.clonebox()], 'int')
-        assert r.value == 1
+        assert r == 1
         r = self.execute_operation(rop.PTR_NE, [u2_box,
                                                 u2_box.clonebox()], 'int')
-        assert r.value == 0
+        assert r == 0
         r = self.execute_operation(rop.PTR_EQ, [u1_box, u2_box], 'int')
-        assert r.value == 0
+        assert r == 0
         r = self.execute_operation(rop.PTR_NE, [u2_box, u1_box], 'int')
-        assert r.value == 1
+        assert r == 1
         #
         null_box = self.null_instance()
         r = self.execute_operation(rop.PTR_EQ, [null_box,
                                                 null_box.clonebox()], 'int')
-        assert r.value == 1
+        assert r == 1
         r = self.execute_operation(rop.PTR_EQ, [u1_box, null_box], 'int')
-        assert r.value == 0
+        assert r == 0
         r = self.execute_operation(rop.PTR_EQ, [null_box, u2_box], 'int')
-        assert r.value == 0
+        assert r == 0
         r = self.execute_operation(rop.PTR_NE, [null_box,
                                                 null_box.clonebox()], 'int')
-        assert r.value == 0
+        assert r == 0
         r = self.execute_operation(rop.PTR_NE, [u2_box, null_box], 'int')
-        assert r.value == 1
+        assert r == 1
         r = self.execute_operation(rop.PTR_NE, [null_box, u1_box], 'int')
-        assert r.value == 1
+        assert r == 1
 
     def test_array_basic(self):
         a_box, A = self.alloc_array_of(rffi.SHORT, 342)
         #
         r = self.execute_operation(rop.ARRAYLEN_GC, [a_box],
                                    'int', descr=arraydescr)
-        assert r.value == 342
+        assert r == 342
         r = self.execute_operation(rop.SETARRAYITEM_GC, [a_box, BoxInt(310),
                                                          BoxInt(744)],
                                    'void', descr=arraydescr)
         assert r is None
-        r = self.execute_operation(rop.GETARRAYITEM_GC, [a_box, BoxInt(310)],
+        import pdb
+        pdb.set_trace()
+        r = self.execute_operation(rop.GETARRAYITEM_GC_i, [a_box, BoxInt(310)],
                                    'int', descr=arraydescr)
-        assert r.value == 744
+        assert r == 744
 
         a_box, A = self.alloc_array_of(lltype.Signed, 342)
         arraydescr = self.cpu.arraydescrof(A)