[pypy-svn] r61653 - in pypy/branch/oo-jit/pypy/jit/codegen/cli: . test
antocuni at codespeak.net
antocuni at codespeak.net
Mon Feb 9 14:17:38 CET 2009
Author: antocuni
Date: Mon Feb 9 14:17:37 2009
New Revision: 61653
Modified:
pypy/branch/oo-jit/pypy/jit/codegen/cli/operation.py
pypy/branch/oo-jit/pypy/jit/codegen/cli/rgenop.py
pypy/branch/oo-jit/pypy/jit/codegen/cli/test/test_rgenop.py
Log:
add support for int_add_ovf
Modified: pypy/branch/oo-jit/pypy/jit/codegen/cli/operation.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/codegen/cli/operation.py (original)
+++ pypy/branch/oo-jit/pypy/jit/codegen/cli/operation.py Mon Feb 9 14:17:37 2009
@@ -9,6 +9,7 @@
class Operation(object):
_gv_res = None
+ _gv_excflag = None
def restype(self):
return self.gv_x.getCliType()
@@ -20,6 +21,11 @@
self._gv_res = self.meth.newlocalvar(restype)
return self._gv_res
+ def gv_excflag(self):
+ if self._gv_excflag is None:
+ self._gv_excflag = self.meth.newlocalvar(typeof(System.Int32))
+ return self._gv_excflag
+
def emit(self):
raise NotImplementedError
@@ -29,6 +35,9 @@
def storeResult(self):
self.gv_res().store(self.meth)
+ def storeExcFlag(self):
+ self.gv_excflag().store(self.meth)
+
class UnaryOp(Operation):
def __init__(self, meth, gv_x):
@@ -331,6 +340,25 @@
def emit(self):
self.meth.il.EmitWriteLine(self.message)
+class IntAddOvf(BinaryOp):
+
+ def getOpCode(self):
+ return OpCodes.Add_Ovf
+
+ def emit(self):
+ il = self.meth.il
+ lbl = il.BeginExceptionBlock()
+ self.pushAllArgs()
+ il.Emit(self.getOpCode())
+ self.storeResult()
+ il.Emit(OpCodes.Leave, lbl)
+
+ il.BeginCatchBlock(typeof(System.OverflowException))
+ il.Emit(OpCodes.Ldc_I4, 1)
+ self.storeExcFlag()
+ il.EndExceptionBlock()
+
+
def opcode2attrname(opcode):
if opcode == 'ldc.r8 0':
return 'Ldc_R8, 0' # XXX this is a hack
Modified: pypy/branch/oo-jit/pypy/jit/codegen/cli/rgenop.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/codegen/cli/rgenop.py (original)
+++ pypy/branch/oo-jit/pypy/jit/codegen/cli/rgenop.py Mon Feb 9 14:17:37 2009
@@ -812,6 +812,22 @@
gv_res = op.gv_res()
return gv_res
+## @specialize.arg(1)
+## def genraisingop1(self, opname, gv_arg):
+## return a pair (gv_result, gv_flag_set_if_exception)
+
+ @specialize.arg(1)
+ def genraisingop2(self, opname, gv_arg1, gv_arg2):
+ if opname == 'int_add_ovf':
+ opcls = ops.IntAddOvf
+ op = opcls(self.meth, gv_arg1, gv_arg2)
+ self.appendop(op)
+ gv_res = op.gv_res()
+ gv_excflag = op.gv_excflag()
+ return gv_res, gv_excflag
+ else:
+ assert False
+
def genop_call(self, sigtoken, gv_fnptr, args_gv):
op = ops.Call(self.meth, sigtoken, gv_fnptr, args_gv)
self.appendop(op)
Modified: pypy/branch/oo-jit/pypy/jit/codegen/cli/test/test_rgenop.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/codegen/cli/test/test_rgenop.py (original)
+++ pypy/branch/oo-jit/pypy/jit/codegen/cli/test/test_rgenop.py Mon Feb 9 14:17:37 2009
@@ -66,9 +66,6 @@
def test_from_random_5_direct(self):
py.test.skip('mono crash')
- def test_ovfcheck_adder_direct(self):
- py.test.skip('fixme')
-
def test_ovfcheck1_direct(self):
py.test.skip('fixme')
@@ -137,8 +134,5 @@
def test_genconst_from_frame_float_var_compile(self):
py.test.skip('fixme: add support for frames')
- def test_ovfcheck_adder_compile(self):
- py.test.skip('fixme')
-
def test_ovfcheck1_compile(self):
py.test.skip('fixme')
More information about the Pypy-commit
mailing list