[pypy-svn] r67024 - in pypy/branch/pyjitpl5/pypy/jit/backend: llgraph test
pedronis at codespeak.net
pedronis at codespeak.net
Thu Aug 20 14:35:29 CEST 2009
Author: pedronis
Date: Thu Aug 20 14:35:28 2009
New Revision: 67024
Modified:
pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/llimpl.py
pypy/branch/pyjitpl5/pypy/jit/backend/test/runner_test.py
pypy/branch/pyjitpl5/pypy/jit/backend/test/test_ll_random.py
Log:
(iko, pedronis)
fix guard_excecption to use an exact match
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 Thu Aug 20 14:35:28 2009
@@ -552,7 +552,8 @@
exc = _last_exception
if exc:
got = exc.args[0]
- if not self._issubclass(got, expected_exception):
+ # exact match!
+ if got != expected_exception:
return False
return True
else:
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/test/runner_test.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/test/runner_test.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/test/runner_test.py Thu Aug 20 14:35:28 2009
@@ -266,35 +266,65 @@
assert not self.cpu.get_exc_value()
def test_exceptions(self):
+ exc_tp = None
+ exc_ptr = None
def func(i):
if i:
- raise LLException(zdtp, zdptr)
+ raise LLException(exc_tp, exc_ptr)
ops = '''
[i0]
call(ConstClass(fptr), i0, descr=calldescr)
- p0 = guard_exception(ConstClass(zdtp))
+ p0 = guard_exception(ConstClass(xtp))
fail(1)
fail(0, p0)
'''
FPTR = lltype.Ptr(lltype.FuncType([lltype.Signed], lltype.Void))
fptr = llhelper(FPTR, func)
calldescr = self.cpu.calldescrof(FPTR.TO, FPTR.TO.ARGS, FPTR.TO.RESULT)
- zdtp, zdptr = self.cpu.get_zero_division_error()
- zd_addr = self.cpu.cast_int_to_adr(zdtp)
- zdtp = llmemory.cast_adr_to_ptr(zd_addr, lltype.Ptr(self.MY_VTABLE))
+
+ xtp = lltype.malloc(rclass.OBJECT_VTABLE, immortal=True)
+ xtp.subclassrange_min = 1
+ xtp.subclassrange_max = 3
+ X = lltype.GcStruct('X', ('parent', rclass.OBJECT),
+ hints={'vtable': xtp._obj})
+ xptr = lltype.cast_opaque_ptr(llmemory.GCREF, lltype.malloc(X))
+
+
+ exc_tp = xtp
+ exc_ptr = xptr
loop = parse(ops, self.cpu, namespace=locals())
self.cpu.compile_operations(loop)
self.cpu.set_future_value_int(0, 1)
self.cpu.execute_operations(loop)
assert self.cpu.get_latest_value_int(0) == 0
- assert self.cpu.get_latest_value_ptr(1) == zdptr
+ assert self.cpu.get_latest_value_ptr(1) == xptr
self.cpu.clear_exception()
self.cpu.set_future_value_int(0, 0)
self.cpu.execute_operations(loop)
assert self.cpu.get_latest_value_int(0) == 1
self.cpu.clear_exception()
+ ytp = lltype.malloc(rclass.OBJECT_VTABLE, immortal=True)
+ ytp.subclassrange_min = 2
+ ytp.subclassrange_max = 2
+ assert rclass.ll_issubclass(ytp, xtp)
+ Y = lltype.GcStruct('Y', ('parent', rclass.OBJECT),
+ hints={'vtable': ytp._obj})
+ yptr = lltype.cast_opaque_ptr(llmemory.GCREF, lltype.malloc(Y))
+
+ # guard_exception uses an exact match
+ exc_tp = ytp
+ exc_ptr = yptr
+ loop = parse(ops, self.cpu, namespace=locals())
+ self.cpu.compile_operations(loop)
+ self.cpu.set_future_value_int(0, 1)
+ self.cpu.execute_operations(loop)
+ assert self.cpu.get_latest_value_int(0) == 1
+ self.cpu.clear_exception()
+
+ exc_tp = xtp
+ exc_ptr = xptr
ops = '''
[i0]
call(ConstClass(fptr), i0, descr=calldescr)
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/test/test_ll_random.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/test/test_ll_random.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/test/test_ll_random.py Thu Aug 20 14:35:28 2009
@@ -532,7 +532,7 @@
builder.cpu.clear_exception()
while True:
_, vtableptr = builder.get_random_structure_type_and_vtable(r)
- if not rclass.ll_issubclass(vtableptr, exc):
+ if vtableptr != exc:
break
other_box = ConstAddr(llmemory.cast_ptr_to_adr(vtableptr), builder.cpu)
op = ResOperation(rop.GUARD_EXCEPTION, [other_box], BoxPtr())
More information about the Pypy-commit
mailing list