[pypy-svn] r77201 - in pypy/branch/resoperation-refactoring/pypy/jit/backend/x86: . test

antocuni at codespeak.net antocuni at codespeak.net
Mon Sep 20 14:05:53 CEST 2010


Author: antocuni
Date: Mon Sep 20 14:05:52 2010
New Revision: 77201

Modified:
   pypy/branch/resoperation-refactoring/pypy/jit/backend/x86/regalloc.py
   pypy/branch/resoperation-refactoring/pypy/jit/backend/x86/test/test_regalloc.py
Log:
fix various places in regalloc that instantiated ResOperations with the wrong number of arguments


Modified: pypy/branch/resoperation-refactoring/pypy/jit/backend/x86/regalloc.py
==============================================================================
--- pypy/branch/resoperation-refactoring/pypy/jit/backend/x86/regalloc.py	(original)
+++ pypy/branch/resoperation-refactoring/pypy/jit/backend/x86/regalloc.py	Mon Sep 20 14:05:52 2010
@@ -798,7 +798,7 @@
         else:
             tempbox = None
             other_loc = imm(ofs_items + (v.getint() << scale))
-        self._call(ResOperation(rop.NEW, [v], res_v),
+        self._call(ResOperation(rop.NEW, [], res_v),
                    [other_loc], [v])
         loc = self.rm.make_sure_var_in_reg(v, [res_v])
         assert self.loc(res_v) == eax
@@ -806,7 +806,7 @@
         self.rm.possibly_free_var(v)
         if tempbox is not None:
             self.rm.possibly_free_var(tempbox)
-        self.PerformDiscard(ResOperation(rop.SETFIELD_GC, [], None),
+        self.PerformDiscard(ResOperation(rop.SETFIELD_GC, [None, None], None),
                             [eax, imm(ofs_length), imm(WORD), loc])
 
     def consider_new_array(self, op):
@@ -1027,12 +1027,21 @@
 def add_none_argument(fn):
     return lambda self, op: fn(self, op, None)
 
+def is_comparison_or_ovf_op(opnum):
+    from pypy.jit.metainterp.resoperation import opclasses, AbstractResOp
+    cls = opclasses[opnum]
+    # hack hack: in theory they are instance method, but they don't use
+    # any instance field, we can use a fake object
+    class Fake(cls):
+        pass
+    op = Fake(None)
+    return op.is_comparison() or op.is_ovf()
+
 for name, value in RegAlloc.__dict__.iteritems():
     if name.startswith('consider_'):
         name = name[len('consider_'):]
         num = getattr(rop, name.upper())
-        if (ResOperation(num, [], None).is_comparison()
-            or ResOperation(num, [], None).is_ovf()
+        if (is_comparison_or_ovf_op(num)
             or num == rop.CALL_MAY_FORCE or num == rop.CALL_ASSEMBLER):
             oplist_with_guard[num] = value
             oplist[num] = add_none_argument(value)

Modified: pypy/branch/resoperation-refactoring/pypy/jit/backend/x86/test/test_regalloc.py
==============================================================================
--- pypy/branch/resoperation-refactoring/pypy/jit/backend/x86/test/test_regalloc.py	(original)
+++ pypy/branch/resoperation-refactoring/pypy/jit/backend/x86/test/test_regalloc.py	Mon Sep 20 14:05:52 2010
@@ -9,7 +9,7 @@
 from pypy.jit.backend.llsupport.descr import GcCache
 from pypy.jit.backend.detect_cpu import getcpuclass
 from pypy.jit.backend.x86.regalloc import RegAlloc, X86RegisterManager,\
-     FloatConstants
+     FloatConstants, is_comparison_or_ovf_op
 from pypy.jit.backend.x86.arch import IS_X86_32, IS_X86_64
 from pypy.jit.metainterp.test.oparser import parse
 from pypy.rpython.lltypesystem import lltype, llmemory, rffi
@@ -17,6 +17,11 @@
 from pypy.rpython.lltypesystem import rclass, rstr
 from pypy.jit.backend.x86.rx86 import *
 
+def test_is_comparison_or_ovf_op():
+    assert not is_comparison_or_ovf_op(rop.INT_ADD)
+    assert is_comparison_or_ovf_op(rop.INT_ADD_OVF)
+    assert is_comparison_or_ovf_op(rop.INT_EQ)
+
 CPU = getcpuclass()
 class MockGcDescr(GcCache):
     def get_funcptr_for_new(self):



More information about the Pypy-commit mailing list