[pypy-commit] pypy remove-raisingops: Goal: kill this amount of code. Now I have to make things work again :-)

arigo pypy.commits at gmail.com
Mon Apr 25 03:28:41 EDT 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: remove-raisingops
Changeset: r83850:7b1fbbe1f814
Date: 2016-04-25 09:24 +0200
http://bitbucket.org/pypy/pypy/changeset/7b1fbbe1f814/

Log:	Goal: kill this amount of code. Now I have to make things work again
	:-)

diff --git a/rpython/config/translationoption.py b/rpython/config/translationoption.py
--- a/rpython/config/translationoption.py
+++ b/rpython/config/translationoption.py
@@ -213,11 +213,6 @@
                    default=False),
         BoolOption("merge_if_blocks", "Merge if ... elif chains",
                    cmdline="--if-block-merge", default=True),
-        BoolOption("raisingop2direct_call",
-                   "Transform operations that can implicitly raise an "
-                   "exception into calls to functions that explicitly "
-                   "raise exceptions",
-                   default=False, cmdline="--raisingop2direct_call"),
         BoolOption("mallocs", "Remove mallocs", default=True),
         BoolOption("constfold", "Constant propagation",
                    default=True),
diff --git a/rpython/rtyper/lltypesystem/lloperation.py b/rpython/rtyper/lltypesystem/lloperation.py
--- a/rpython/rtyper/lltypesystem/lloperation.py
+++ b/rpython/rtyper/lltypesystem/lloperation.py
@@ -166,8 +166,6 @@
 # ____________________________________________________________
 #
 # This list corresponds to the operations implemented by the LLInterpreter.
-# Note that many exception-raising operations can be replaced by calls
-# to helper functions in rpython.rtyper.raisingops.
 # ***** Run test_lloperation after changes. *****
 
 LL_OPERATIONS = {
@@ -191,18 +189,14 @@
 
     'int_is_true':          LLOp(canfold=True),
     'int_neg':              LLOp(canfold=True),
-    'int_neg_ovf':          LLOp(canraise=(OverflowError,), tryfold=True),
     'int_abs':              LLOp(canfold=True),
-    'int_abs_ovf':          LLOp(canraise=(OverflowError,), tryfold=True),
     'int_invert':           LLOp(canfold=True),
 
     'int_add':              LLOp(canfold=True),
     'int_sub':              LLOp(canfold=True),
     'int_mul':              LLOp(canfold=True),
-    'int_floordiv':         LLOp(canfold=True),
-    'int_floordiv_zer':     LLOp(canraise=(ZeroDivisionError,), tryfold=True),
-    'int_mod':              LLOp(canfold=True),
-    'int_mod_zer':          LLOp(canraise=(ZeroDivisionError,), tryfold=True),
+    'int_floordiv':         LLOp(canfold=True),  # C-like behavior for neg num
+    'int_mod':              LLOp(canfold=True),  # C-like behavior for neg num
     'int_lt':               LLOp(canfold=True),
     'int_le':               LLOp(canfold=True),
     'int_eq':               LLOp(canfold=True),
@@ -218,20 +212,6 @@
     'int_between':          LLOp(canfold=True),   # a <= b < c
     'int_force_ge_zero':    LLOp(canfold=True),   # 0 if a < 0 else a
 
-    'int_add_ovf':          LLOp(canraise=(OverflowError,), tryfold=True),
-    'int_add_nonneg_ovf':   LLOp(canraise=(OverflowError,), tryfold=True),
-              # ^^^ more efficient version when 2nd arg is nonneg
-    'int_sub_ovf':          LLOp(canraise=(OverflowError,), tryfold=True),
-    'int_mul_ovf':          LLOp(canraise=(OverflowError,), tryfold=True),
-    # the following operations overflow in one case: (-sys.maxint-1) // (-1)
-    'int_floordiv_ovf':     LLOp(canraise=(OverflowError,), tryfold=True),
-    'int_floordiv_ovf_zer': LLOp(canraise=(OverflowError, ZeroDivisionError),
-                                                            tryfold=True),
-    'int_mod_ovf':          LLOp(canraise=(OverflowError,), tryfold=True),
-    'int_mod_ovf_zer':      LLOp(canraise=(OverflowError, ZeroDivisionError),
-                                                            tryfold=True),
-    'int_lshift_ovf':       LLOp(canraise=(OverflowError,), tryfold=True),
-
     'uint_is_true':         LLOp(canfold=True),
     'uint_invert':          LLOp(canfold=True),
 
@@ -239,9 +219,7 @@
     'uint_sub':             LLOp(canfold=True),
     'uint_mul':             LLOp(canfold=True),
     'uint_floordiv':        LLOp(canfold=True),
-    'uint_floordiv_zer':    LLOp(canraise=(ZeroDivisionError,), tryfold=True),
     'uint_mod':             LLOp(canfold=True),
-    'uint_mod_zer':         LLOp(canraise=(ZeroDivisionError,), tryfold=True),
     'uint_lt':              LLOp(canfold=True),
     'uint_le':              LLOp(canfold=True),
     'uint_eq':              LLOp(canfold=True),
@@ -280,9 +258,7 @@
     'llong_sub':            LLOp(canfold=True),
     'llong_mul':            LLOp(canfold=True),
     'llong_floordiv':       LLOp(canfold=True),
-    'llong_floordiv_zer':   LLOp(canraise=(ZeroDivisionError,), tryfold=True),
     'llong_mod':            LLOp(canfold=True),
-    'llong_mod_zer':        LLOp(canraise=(ZeroDivisionError,), tryfold=True),
     'llong_lt':             LLOp(canfold=True),
     'llong_le':             LLOp(canfold=True),
     'llong_eq':             LLOp(canfold=True),
@@ -302,9 +278,7 @@
     'ullong_sub':           LLOp(canfold=True),
     'ullong_mul':           LLOp(canfold=True),
     'ullong_floordiv':      LLOp(canfold=True),
-    'ullong_floordiv_zer':  LLOp(canraise=(ZeroDivisionError,), tryfold=True),
     'ullong_mod':           LLOp(canfold=True),
-    'ullong_mod_zer':       LLOp(canraise=(ZeroDivisionError,), tryfold=True),
     'ullong_lt':            LLOp(canfold=True),
     'ullong_le':            LLOp(canfold=True),
     'ullong_eq':            LLOp(canfold=True),
@@ -326,9 +300,7 @@
     'lllong_sub':            LLOp(canfold=True),
     'lllong_mul':            LLOp(canfold=True),
     'lllong_floordiv':       LLOp(canfold=True),
-    'lllong_floordiv_zer':   LLOp(canraise=(ZeroDivisionError,), tryfold=True),
     'lllong_mod':            LLOp(canfold=True),
-    'lllong_mod_zer':        LLOp(canraise=(ZeroDivisionError,), tryfold=True),
     'lllong_lt':             LLOp(canfold=True),
     'lllong_le':             LLOp(canfold=True),
     'lllong_eq':             LLOp(canfold=True),
diff --git a/rpython/translator/backendopt/all.py b/rpython/translator/backendopt/all.py
--- a/rpython/translator/backendopt/all.py
+++ b/rpython/translator/backendopt/all.py
@@ -1,4 +1,3 @@
-from rpython.translator.backendopt.raisingop2direct_call import raisingop2direct_call
 from rpython.translator.backendopt import removenoops
 from rpython.translator.backendopt import inline
 from rpython.translator.backendopt.malloc import remove_mallocs
@@ -34,7 +33,7 @@
 def backend_optimizations(translator, graphs=None, secondary=False,
                           inline_graph_from_anywhere=False, **kwds):
     # sensible keywords are
-    # raisingop2direct_call, inline_threshold, mallocs
+    # inline_threshold, mallocs
     # merge_if_blocks, constfold, heap2stack
     # clever_malloc_removal, remove_asserts
 
@@ -50,9 +49,6 @@
         print "before optimizations:"
         print_statistics(translator.graphs[0], translator, "per-graph.txt")
 
-    if config.raisingop2direct_call:
-        raisingop2direct_call(translator, graphs)
-
     if config.remove_asserts:
         constfold(config, graphs)
         remove_asserts(translator, graphs)
diff --git a/rpython/translator/backendopt/raisingop2direct_call.py b/rpython/translator/backendopt/raisingop2direct_call.py
deleted file mode 100644
--- a/rpython/translator/backendopt/raisingop2direct_call.py
+++ /dev/null
@@ -1,64 +0,0 @@
-from rpython.translator.backendopt.support import log, all_operations, annotate
-import rpython.rtyper.raisingops
-
-
-log = log.raisingop2directcall
-
-def is_raisingop(op):
-    s = op.opname
-    if (not s.startswith('int_') and not s.startswith('uint_') and
-        not s.startswith('float_') and not s.startswith('llong_')):
-        return False
-    if not s.endswith('_zer') and not s.endswith('_ovf') and not s.endswith('_val'): #not s in special_operations:
-        return False
-    return True
-
-def raisingop2direct_call(translator, graphs=None):
-    """search for operations that could raise an exception and change that
-    operation into a direct_call to a function from the raisingops module.
-    This function also needs to be annotated and specialized.
-
-    note: this could be extended to allow for any operation to be changed into
-          a direct_call to a (RPython) function!
-    """
-    #special_operations = "int_floordiv int_mod".split()
-    if graphs is None:
-        graphs = translator.graphs
-
-    log('starting')
-    seen = {}
-    for op in all_operations(graphs):
-        if not is_raisingop(op):
-            continue
-        func = getattr(rpython.rtyper.raisingops, op.opname, None)
-        if not func:
-            log.warning("%s not found" % op.opname)
-            continue
-        if op.opname not in seen:
-            seen[op.opname] = 0
-        seen[op.opname] += 1
-        op.args.insert(0, annotate(translator, func, op.result, op.args))
-        op.opname = 'direct_call'
-
-    #statistics...
-    for k, v in seen.iteritems():
-        log("%dx %s" % (v, k))
-
-    #specialize newly annotated functions
-    if seen != {}:
-        translator.rtyper.specialize_more_blocks()
-
-    #rename some operations (that were introduced in the newly specialized graphs)
-    #so this transformation becomes idempotent...
-    #for op in all_operations(graphs):
-    #   if op.opname in special_operations:
-    #       log('renamed %s to %s_' % (op.opname, op.opname))
-    #       op.opname += '_'
-
-    #selfdiagnostics... assert that there are no more raisingops
-    for op in all_operations(graphs):
-        if is_raisingop(op):
-            log.warning("%s not transformed" % op.opname)
-
-    #translator.view()
-    log('finished')
diff --git a/rpython/translator/backendopt/test/test_all.py b/rpython/translator/backendopt/test/test_all.py
--- a/rpython/translator/backendopt/test/test_all.py
+++ b/rpython/translator/backendopt/test/test_all.py
@@ -135,10 +135,8 @@
             return 33 + big() + g(10)
 
         t  = self.translateopt(idempotent, [int, int],
-                               raisingop2direct_call=True,
                                constfold=False)
-        #backend_optimizations(t, raisingop2direct_call=True,
-        #                      inline_threshold=0, constfold=False)
+        #backend_optimizations(t, inline_threshold=0, constfold=False)
 
         digest1 = md5digest(t)
 
@@ -155,8 +153,7 @@
 
         #XXX Inlining and constfold are currently non-idempotent.
         #    Maybe they just renames variables but the graph changes in some way.
-        backend_optimizations(t, raisingop2direct_call=True,
-                              inline_threshold=0, constfold=False)
+        backend_optimizations(t, inline_threshold=0, constfold=False)
         digest3 = md5digest(t)
         compare(digest1, digest3)
 
diff --git a/rpython/translator/backendopt/test/test_raisingop2direct_call.py b/rpython/translator/backendopt/test/test_raisingop2direct_call.py
deleted file mode 100644
--- a/rpython/translator/backendopt/test/test_raisingop2direct_call.py
+++ /dev/null
@@ -1,107 +0,0 @@
-from rpython.translator.backendopt import raisingop2direct_call, support
-from rpython.rtyper.test.test_llinterp import get_interpreter
-from rpython.rlib.rarithmetic import ovfcheck
-
-import sys
-
-import py
-
-
-def get_runner(f, exceptedop, types):
-    values = [t() for t in types]
-    interp, graph = get_interpreter(f, values)
-    for op in support.graph_operations(graph):
-        if op.opname == exceptedop:
-            break
-    else:
-        assert False, "op %r not found!"%(exceptedop,)
-    t = interp.typer.annotator.translator # FIIISH!
-    raisingop2direct_call.raisingop2direct_call(t, [graph])
-    def ret(*args):
-        assert map(type, args) == types
-        return interp.eval_graph(graph, args)
-    return ret
-
-def test_test_machinery():
-    def f(x, y):
-        try:
-            return x + y
-        except OverflowError:
-            return 123
-    py.test.raises(AssertionError, "get_runner(f, 'int_add_ovf', [int, int])")
-    def f(x, y):
-        try:
-            return ovfcheck(x + y)
-        except OverflowError:
-            return 123
-    fn = get_runner(f, 'int_add_ovf', [int, int])
-    res = fn(0, 0)
-    assert res == 0
-
-
-def test_division():
-    def f(x, y):
-        try:
-            return x//y
-        except ZeroDivisionError:
-            return 123
-    fn = get_runner(f, 'int_floordiv_zer', [int, int])
-    res = fn(1, 0)
-    assert res == 123
-    res = fn(-5, 2)
-    assert res == -3
-
-    def h(x, y):
-        try:
-            return ovfcheck(x//y)
-        except OverflowError:
-            return 123
-        except ZeroDivisionError:
-            return 246
-    hn = get_runner(h, 'int_floordiv_ovf_zer', [int, int])
-    res = hn(-sys.maxint-1, -1)
-    assert res == 123
-    res = hn(1, 0)
-    assert res == 246
-    res = hn(-5, 2)
-    assert res == -3
-
-def test_modulo():
-    def f(x, y):
-        try:
-            return x%y
-        except ZeroDivisionError:
-            return 123
-    fn = get_runner(f, 'int_mod_zer', [int, int])
-    res = fn(0, 0)
-    assert res == 123
-    res = fn(-5, 2)
-    assert res == 1
-
-
-    # this becomes an int_mod_ovf_zer already?
-##     def g(x, y):
-##         try:
-##             return ovfcheck(x%y)
-##         except OverflowError:
-##             return 123
-##     gn = get_runner(g, 'int_mod_ovf', [int, int])
-##     res = gn(-sys.maxint-1, -1)
-##     assert res == 123
-##     res = gn(-5, 2)
-##     assert res == -3
-
-    def h(x, y):
-        try:
-            return ovfcheck(x%y)
-        except OverflowError:
-            return 123
-        except ZeroDivisionError:
-            return 246
-    hn = get_runner(h, 'int_mod_ovf_zer', [int, int])
-    res = hn(-sys.maxint-1, -1)
-    assert res == 123
-    res = hn(1, 0)
-    assert res == 246
-    res = hn(-5, 2)
-    assert res == 1
diff --git a/rpython/translator/backendopt/test/test_removenoops.py b/rpython/translator/backendopt/test/test_removenoops.py
--- a/rpython/translator/backendopt/test/test_removenoops.py
+++ b/rpython/translator/backendopt/test/test_removenoops.py
@@ -19,8 +19,7 @@
     t.buildrtyper().specialize()
     if all_opts:
         backend_optimizations(t, inline_threshold=INLINE_THRESHOLD_FOR_TEST,
-                              constfold=False,
-                              raisingop2direct_call=False)
+                              constfold=False)
     graph = graphof(t, fn)
     if option.view:
         t.view()
diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py
--- a/rpython/translator/c/genc.py
+++ b/rpython/translator/c/genc.py
@@ -800,7 +800,6 @@
         srcdir / 'debug_traceback.c',  # ifdef HAVE_RTYPER
         srcdir / 'asm.c',
         srcdir / 'instrument.c',
-        srcdir / 'int.c',
         srcdir / 'stack.c',
         srcdir / 'threadlocal.c',
     ]
diff --git a/rpython/translator/c/src/asm_gcc_x86.c b/rpython/translator/c/src/asm_gcc_x86.c
--- a/rpython/translator/c/src/asm_gcc_x86.c
+++ b/rpython/translator/c/src/asm_gcc_x86.c
@@ -5,12 +5,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#  if 0   /* disabled */
-void op_int_overflowed(void)
-{
-  FAIL_OVF("integer operation");
-}
-#  endif
 
 #  ifdef PYPY_X86_CHECK_SSE2
 void pypy_x86_check_sse2(void)
diff --git a/rpython/translator/c/src/exception.c b/rpython/translator/c/src/exception.c
--- a/rpython/translator/c/src/exception.c
+++ b/rpython/translator/c/src/exception.c
@@ -32,14 +32,6 @@
 		RPyClearException();					\
 	} while (0)
 
-/* implementations */
-
-void _RPyRaiseSimpleException(RPYTHON_EXCEPTION rexc)
-{
-	/* XXX msg is ignored */
-	RPyRaiseException(RPYTHON_TYPE_OF_EXC_INST(rexc), rexc);
-}
-
 
 /******************************************************************/
 #endif                                             /* HAVE_RTYPER */
diff --git a/rpython/translator/c/src/exception.h b/rpython/translator/c/src/exception.h
--- a/rpython/translator/c/src/exception.h
+++ b/rpython/translator/c/src/exception.h
@@ -35,9 +35,4 @@
 		RPyClearException();					\
 	} while (0)
 
-/* prototypes */
-
-RPY_EXTERN
-void _RPyRaiseSimpleException(RPYTHON_EXCEPTION rexc);
-
 #endif
diff --git a/rpython/translator/c/src/int.c b/rpython/translator/c/src/int.c
deleted file mode 100644
--- a/rpython/translator/c/src/int.c
+++ /dev/null
@@ -1,45 +0,0 @@
-#include "common_header.h"
-#include "structdef.h"
-#include "forwarddecl.h"
-#include "preimpl.h"
-#include <src/int.h>
-#include <src/support.h>
-#include <src/exception.h>
-
-/* adjusted from intobject.c, Python 2.3.3 */
-
-long long op_llong_mul_ovf(long long a, long long b)
-{
-    double doubled_longprod;	/* (double)longprod */
-    double doubleprod;		/* (double)a * (double)b */
-    long long longprod;
-
-    longprod = a * b;
-    doubleprod = (double)a * (double)b;
-    doubled_longprod = (double)longprod;
-
-    /* Fast path for normal case:  small multiplicands, and no info
-       is lost in either method. */
-    if (doubled_longprod == doubleprod)
-	return longprod;
-
-    /* Somebody somewhere lost info.  Close enough, or way off?  Note
-       that a != 0 and b != 0 (else doubled_longprod == doubleprod == 0).
-       The difference either is or isn't significant compared to the
-       true value (of which doubleprod is a good approximation).
-    */
-    {
-	const double diff = doubled_longprod - doubleprod;
-	const double absdiff = diff >= 0.0 ? diff : -diff;
-	const double absprod = doubleprod >= 0.0 ? doubleprod :
-	    -doubleprod;
-	/* absdiff/absprod <= 1/32 iff
-	   32 * absdiff <= absprod -- 5 good bits is "close enough" */
-	if (32.0 * absdiff <= absprod)
-	    return longprod;
-
-	FAIL_OVF("integer multiplication");
-	return -1;
-    }
-}
-
diff --git a/rpython/translator/c/src/int.h b/rpython/translator/c/src/int.h
--- a/rpython/translator/c/src/int.h
+++ b/rpython/translator/c/src/int.h
@@ -21,16 +21,8 @@
 #define OP_INT_INVERT(x,r)    r = ~(x)
 #define OP_INT_NEG(x,r)       r = -(x)
 
-#define OP_INT_NEG_OVF(x,r) \
-	if ((x) == SIGNED_MIN) FAIL_OVF("integer negate"); \
-	OP_INT_NEG(x,r)
-
 #define OP_INT_ABS(x,r)    r = (x) >= 0 ? x : -(x)
 
-#define OP_INT_ABS_OVF(x,r) \
-	if ((x) == SIGNED_MIN) FAIL_OVF("integer absolute"); \
-	OP_INT_ABS(x,r)
-
 /***  binary operations ***/
 
 #define OP_INT_EQ(x,y,r)	  r = ((x) == (y))
@@ -53,36 +45,9 @@
 /* addition, subtraction */
 
 #define OP_INT_ADD(x,y,r)     r = (x) + (y)
-
-/* cast to avoid undefined behaviour on overflow */
-#define OP_INT_ADD_OVF(x,y,r) \
-        r = (Signed)((Unsigned)x + y); \
-        if ((r^x) < 0 && (r^y) < 0) FAIL_OVF("integer addition")
-
-#define OP_INT_ADD_NONNEG_OVF(x,y,r)  /* y can be assumed >= 0 */ \
-        r = (Signed)((Unsigned)x + y); \
-        if ((r&~x) < 0) FAIL_OVF("integer addition")
-
 #define OP_INT_SUB(x,y,r)     r = (x) - (y)
-
-#define OP_INT_SUB_OVF(x,y,r) \
-        r = (Signed)((Unsigned)x - y); \
-        if ((r^x) < 0 && (r^~y) < 0) FAIL_OVF("integer subtraction")
-
 #define OP_INT_MUL(x,y,r)     r = (x) * (y)
 
-#if SIZEOF_LONG * 2 <= SIZEOF_LONG_LONG && !defined(_WIN64)
-#define OP_INT_MUL_OVF(x,y,r) \
-	{ \
-		long long _lr = (long long)x * y; \
-		r = (long)_lr; \
-		if (_lr != (long long)r) FAIL_OVF("integer multiplication"); \
-	}
-#else
-#define OP_INT_MUL_OVF(x,y,r) \
-	r = op_llong_mul_ovf(x, y)   /* long == long long */
-#endif
-
 /* shifting */
 
 /* NB. shifting has same limitations as C: the shift count must be
@@ -111,11 +76,6 @@
 #define OP_ULLONG_LSHIFT(x,y,r) CHECK_SHIFT_RANGE(y, PYPY_LONGLONG_BIT); \
 							r = (x) << (y)
 
-#define OP_INT_LSHIFT_OVF(x,y,r) \
-	OP_INT_LSHIFT(x,y,r); \
-	if ((x) != Py_ARITHMETIC_RIGHT_SHIFT(Signed, r, (y))) \
-		FAIL_OVF("x<<y losing bits or changing sign")
-
 /* floor division */
 
 #define OP_INT_FLOORDIV(x,y,r)    r = (x) / (y)
@@ -124,46 +84,6 @@
 #define OP_ULLONG_FLOORDIV(x,y,r) r = (x) / (y)
 #define OP_LLLONG_FLOORDIV(x,y,r)  r = (x) / (y)
 
-#define OP_INT_FLOORDIV_OVF(x,y,r)                      \
-	if ((y) == -1 && (x) == SIGNED_MIN)               \
-	    { FAIL_OVF("integer division"); r=0; }      \
-	else                                            \
-	    r = (x) / (y)
-
-#define OP_INT_FLOORDIV_ZER(x,y,r)                      \
-	if ((y) == 0)                                   \
-	    { FAIL_ZER("integer division"); r=0; }      \
-	else                                            \
-	    r = (x) / (y)
-#define OP_UINT_FLOORDIV_ZER(x,y,r)                             \
-	if ((y) == 0)                                           \
-	    { FAIL_ZER("unsigned integer division"); r=0; }     \
-	else                                                    \
-	    r = (x) / (y)
-#define OP_LLONG_FLOORDIV_ZER(x,y,r)                    \
-	if ((y) == 0)                                   \
-	    { FAIL_ZER("integer division"); r=0; }      \
-	else                                            \
-	    r = (x) / (y)
-
-#define OP_ULLONG_FLOORDIV_ZER(x,y,r)                           \
-	if ((y) == 0)                                           \
-	    { FAIL_ZER("unsigned integer division"); r=0; }     \
-	else                                                    \
-	    r = (x) / (y)
-	    
-#define OP_LLLONG_FLOORDIV_ZER(x,y,r)                    \
-        if ((y) == 0)                                   \
-            { FAIL_ZER("integer division"); r=0; }      \
-        else                                            \
-            r = (x) / (y)
-            
-#define OP_INT_FLOORDIV_OVF_ZER(x,y,r)                  \
-	if ((y) == 0)                                   \
-	    { FAIL_ZER("integer division"); r=0; }      \
-	else                                            \
-	    { OP_INT_FLOORDIV_OVF(x,y,r); }
-
 /* modulus */
 
 #define OP_INT_MOD(x,y,r)     r = (x) % (y)
@@ -172,44 +92,6 @@
 #define OP_ULLONG_MOD(x,y,r)  r = (x) % (y)
 #define OP_LLLONG_MOD(x,y,r)   r = (x) % (y)
 
-#define OP_INT_MOD_OVF(x,y,r)                           \
-	if ((y) == -1 && (x) == SIGNED_MIN)               \
-	    { FAIL_OVF("integer modulo"); r=0; }        \
-	else                                            \
-	    r = (x) % (y)
-#define OP_INT_MOD_ZER(x,y,r)                           \
-	if ((y) == 0)                                   \
-	    { FAIL_ZER("integer modulo"); r=0; }        \
-	else                                            \
-	    r = (x) % (y)
-#define OP_UINT_MOD_ZER(x,y,r)                                  \
-	if ((y) == 0)                                           \
-	    { FAIL_ZER("unsigned integer modulo"); r=0; }       \
-	else                                                    \
-	    r = (x) % (y)
-#define OP_LLONG_MOD_ZER(x,y,r)                         \
-	if ((y) == 0)                                   \
-	    { FAIL_ZER("integer modulo"); r=0; }        \
-	else                                            \
-	    r = (x) % (y)
-#define OP_ULLONG_MOD_ZER(x,y,r)                                \
-	if ((y) == 0)                                           \
-	    { FAIL_ZER("unsigned integer modulo"); r=0; }       \
-	else                                                    \
-	    r = (x) % (y)
-
-#define OP_LLLONG_MOD_ZER(x,y,r)                         \
-        if ((y) == 0)                                   \
-            { FAIL_ZER("integer modulo"); r=0; }        \
-        else                                            \
-            r = (x) % (y)
-            
-#define OP_INT_MOD_OVF_ZER(x,y,r)                       \
-	if ((y) == 0)                                   \
-	    { FAIL_ZER("integer modulo"); r=0; }        \
-	else                                            \
-	    { OP_INT_MOD_OVF(x,y,r); }
-
 /* bit operations */
 
 #define OP_INT_AND(x,y,r)     r = (x) & (y)
diff --git a/rpython/translator/c/src/support.h b/rpython/translator/c/src/support.h
--- a/rpython/translator/c/src/support.h
+++ b/rpython/translator/c/src/support.h
@@ -8,10 +8,6 @@
 #define RUNNING_ON_LLINTERP	0
 #define OP_JIT_RECORD_EXACT_CLASS(i, c, r)  /* nothing */
 
-#define FAIL_OVF(msg) _RPyRaiseSimpleException(RPyExc_OverflowError)
-#define FAIL_VAL(msg) _RPyRaiseSimpleException(RPyExc_ValueError)
-#define FAIL_ZER(msg) _RPyRaiseSimpleException(RPyExc_ZeroDivisionError)
-
 /* Extra checks can be enabled with the RPY_ASSERT or RPY_LL_ASSERT
  * macros.  They differ in the level at which the tests are made.
  * Remember that RPython lists, for example, are implemented as a
diff --git a/rpython/translator/c/test/test_backendoptimized.py b/rpython/translator/c/test/test_backendoptimized.py
--- a/rpython/translator/c/test/test_backendoptimized.py
+++ b/rpython/translator/c/test/test_backendoptimized.py
@@ -204,7 +204,7 @@
 
 class TestTypedOptimizedRaisingOps:
     def getcompiled(self, func, argtypes):
-        return compile(func, argtypes, raisingop2direct_call=True)
+        return compile(func, argtypes)
 
     def test_int_floordiv_zer(self):
         def f(x):


More information about the pypy-commit mailing list