[pypy-svn] r65092 - in pypy/branch/pyjitpl5/pypy/jit/backend: llgraph test

arigo at codespeak.net arigo at codespeak.net
Wed May 6 14:20:41 CEST 2009


Author: arigo
Date: Wed May  6 14:20:40 2009
New Revision: 65092

Modified:
   pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
   pypy/branch/pyjitpl5/pypy/jit/backend/test/test_random.py
Log:
* Support in the llgraph backend simple exceptions without a rtyper.
* Support for the remaining INT_xxx_OVF operations in test_random.py.
  (using real multiple inheritance, argh!)


Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py	Wed May  6 14:20:40 2009
@@ -887,15 +887,26 @@
     global _last_exception
     _last_exception = None
 
+_pseudo_exceptions = {}
+
 def _set_error(Class):
     global _last_exception
-    llframe = _llinterp.frame_class(None, None, _llinterp)
-    try:
-        llframe.make_llexception(Class())
-    except LLException, e:
-        _last_exception = e
+    if _llinterp.typer is not None:
+        llframe = _llinterp.frame_class(None, None, _llinterp)
+        try:
+            llframe.make_llexception(Class())
+        except LLException, e:
+            _last_exception = e
+        else:
+            assert 0, "should have raised"
     else:
-        assert 0, "should have raised"
+        # for tests, a random emulated ll_inst will do
+        if Class not in _pseudo_exceptions:
+            ll_inst = lltype.malloc(rclass.OBJECT)
+            ll_inst.typeptr = lltype.malloc(rclass.OBJECT_VTABLE,
+                                            immortal=True)
+            _pseudo_exceptions[Class] = LLException(ll_inst.typeptr, ll_inst)
+        _last_exception = _pseudo_exceptions[Class]
 
 def set_overflow_error():
     _set_error(OverflowError)

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/test/test_random.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/test/test_random.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/test/test_random.py	Wed May  6 14:20:40 2009
@@ -176,7 +176,7 @@
 class CannotProduceOperation(Exception):
     pass
 
-class AbstractOperation:
+class AbstractOperation(object):
     def __init__(self, opnum, boolres=False):
         self.opnum = opnum
         self.boolres = boolres
@@ -219,9 +219,9 @@
             v_second = v
         self.put(builder, [v_first, v_second])
 
-class BinaryOvfOperation(BinaryOperation):
+class AbstractOvfOperation(AbstractOperation):
     def produce_into(self, builder, r):
-        BinaryOperation.produce_into(self, builder, r)
+        super(AbstractOvfOperation, self).produce_into(builder, r)
         exc = builder.cpu.get_exception()
         if exc:     # OverflowError
             builder.cpu.clear_exception()
@@ -233,6 +233,12 @@
         op.suboperations = [ResOperation(rop.FAIL, [], None)]
         builder.loop.operations.append(op)
 
+class BinaryOvfOperation(AbstractOvfOperation, BinaryOperation):
+    pass
+
+class UnaryOvfOperation(AbstractOvfOperation, UnaryOperation):
+    pass
+
 class GuardOperation(AbstractOperation):
     def gen_guard(self, builder, r):
         v = builder.get_bool_var(r)
@@ -322,7 +328,7 @@
 for _op in [rop.INT_NEG_OVF,
             rop.INT_ABS_OVF,
             ]:
-    pass #OPERATIONS.append(UnaryOvfOperation(_op))
+    OPERATIONS.append(UnaryOvfOperation(_op))
 
 OperationBuilder.OPERATIONS = OPERATIONS
 



More information about the Pypy-commit mailing list